astronomix.initial_condition_generation.turbulent_ic_generator module#
Generate Gaussian random fields with a prescribed power-law spectrum.
Builds a real-valued 3D turbulent field by sampling complex Fourier
coefficients with a target amplitude scaling A0 * k^slope inside a
wavenumber band, enforcing Hermitian symmetry so the inverse transform is
real, and transforming back to real space. The implementation deliberately
avoids explicit meshgrid / index arrays (relying on broadcasting and roll /
flip tricks instead) to keep the memory footprint low at large resolution.
- astronomix.initial_condition_generation.turbulent_ic_generator.create_turb_field(Ndim, A0, slope, kmin, kmax, key, sharding=None, kroll_frac=0.85, zero_mean=True)[source]#
Generate a real Gaussian random field with a target amplitude scaling.
This version is optimized for memory by avoiding explicit meshgrid / index arrays and using broadcasting and efficient array manipulations instead.
- Parameters:
Ndim – The number of grid points along each of the three axes.
A0 – The amplitude prefactor of the power-law spectrum.
slope – The spectral slope (
amplitude ~ A0 * k^slope).kmin – The lower edge of the wavenumber band carrying power.
kmax – The upper edge of the wavenumber band carrying power.
key – The PRNG key used to sample the Fourier coefficients.
sharding – An optional sharding applied to the large k-space arrays.
kroll_frac – The fraction of
kmaxat which the cosine roll-off begins.zero_mean – Whether to remove the DC component so the field has zero mean.
- Returns:
The real-valued turbulent field of shape
(Ndim, Ndim, Ndim).