4.6.16 pde.tools.spectral module
Functions making use of spectral decompositions.
Return a function creating an array of random values that obey. |
|
Return a function creating random values with specified spatial correlations. |
- make_colored_noise(shape, dx=1.0, exponent=0, scale=1, rng=None)[source]
Return a function creating an array of random values that obey.
\[\langle c(\boldsymbol k) c(\boldsymbol k’) \rangle = \Gamma^2 |\boldsymbol k|^\nu \delta(\boldsymbol k-\boldsymbol k’)\]in spectral space on a Cartesian grid. The special case \(\nu = 0\) corresponds to white noise. For simplicity, the correlations respect periodic boundary conditions.
- Parameters:
shape (tuple of ints) – Number of supports points in each spatial dimension. The number of the list defines the spatial dimension.
dx (float or list of floats) – Discretization along each dimension. A uniform discretization in each direction can be indicated by a single number.
exponent (float) – Exponent \(\nu\) of the power spectrum
scale (float) – Scaling factor \(\Gamma\) determining noise strength
rng (
Generator
) – Random number generator (default:default_rng()
)
- Returns:
a function returning a random realization
- Return type:
callable
Return a function creating random values with specified spatial correlations.
The returned field \(f\) generally obeys a selected correlation function \(C(k)\). In Fourier space, we thus have
\[\langle f(\boldsymbol k) f(\boldsymbol k’) \rangle = C(|\boldsymbol k|) \delta(\boldsymbol k-\boldsymbol k’)\]For simplicity, the correlations respect periodic boundary conditions.
- Parameters:
shape (tuple of ints) – Number of supports points in each spatial dimension. The number of the list defines the spatial dimension.
correlation (str) – Selects the correlation function used to make the correlated noise. Many of the options (described below) support additional parameters that can be supplied as keyword arguments.
discretization (float or list of floats) – Discretization along each dimension. A uniform discretization in each direction can be indicated by a single number.
rng (
Generator
) – Random number generator (default:default_rng()
)**kwargs – Additional parameters can affect details of the correlation function
- Return type:
Supported correlation functions Identifier
Correlation function
none
No correlation, \(C(k) = \delta(k)\)
gaussian
\(C(k) = \exp(\frac12 k^2 \lambda^2)\) with the length scale \(\lambda\) set by argument
length_scale
.power law
\(C(k) = k^{\nu/2}\) with exponent \(\nu\) set by argument
exponent
.cosine
\(C(k) = \exp\bigl(-s^2(\lambda k - 1)^2\bigr)\) with the length scale \(\lambda\) set by argument
length_scale
, whereas the sharpness parameter \(s\) is set bysharpness
and defaults to 10.