kspace.PowerSpectrum#

class kspace.PowerSpectrum(power_spec_func, ndim=3)[source]#

Bases: object

Base class wrapping a user-supplied power spectrum function P(k), with an adjustable normalization.

Parameters:
  • power_spec_func (callable) – A function of the wavenumber k returning the (unnormalized) power spectrum. Must be numba-jittable.

  • ndim (int, optional) – Number of dimensions (1, 2, or 3). Default is 3.

__init__(power_spec_func, ndim=3)[source]#

Methods

A(k)

The Fourier amplitude corresponding to the power spectrum at a given wavenumber k, A(k) = sqrt(E(k) * k).

E(k)

The "energy spectrum" of the power spectrum as a function of the wavenumber k.

__init__(power_spec_func[, ndim])

integrate_E(kmin, kmax)

Integrate the energy spectrum E(k) over a range of wavenumbers.

renormalize(f_rms[, kmin, kmax])

Rescale the power spectrum's normalization so that the integral of its energy spectrum over [kmin, kmax] gives the desired RMS field value.

A(k)[source]#

The Fourier amplitude corresponding to the power spectrum at a given wavenumber k, A(k) = sqrt(E(k) * k).

Parameters:

k (float or array-like) – The wavenumber(s).

E(k)[source]#

The “energy spectrum” of the power spectrum as a function of the wavenumber k.

Parameters:

k (float or array-like) – The wavenumber(s).

integrate_E(kmin, kmax)[source]#

Integrate the energy spectrum E(k) over a range of wavenumbers.

Parameters:
  • kmin (float) – The lower wavenumber bound of the integral.

  • kmax (float) – The upper wavenumber bound of the integral.

Returns:

The integral of E(k) from kmin to kmax.

Return type:

float

renormalize(f_rms, kmin=0.0, kmax=100.0)[source]#

Rescale the power spectrum’s normalization so that the integral of its energy spectrum over [kmin, kmax] gives the desired RMS field value.

Parameters:
  • f_rms (float) – The desired RMS value of the field.

  • kmin (float, optional) – The lower wavenumber bound of the integral. Default is 0.0.

  • kmax (float, optional) – The upper wavenumber bound of the integral. Default is 100.0.