pub struct RandomField {
pub grid: Array2<f64>,
pub covariance: CorrelationFunction,
}Expand description
A realised random field on a 2-D grid.
Fields§
§grid: Array2<f64>Grid values, shape [nx, ny].
covariance: CorrelationFunctionCovariance structure used to generate this field.
Implementations§
Source§impl RandomField
impl RandomField
Sourcepub fn sample_circulant_embedding(
grid_x: ArrayView1<'_, f64>,
grid_y: ArrayView1<'_, f64>,
cov: CorrelationFunction,
rng: &mut StdRng,
) -> IntegrateResult<Array2<f64>>
pub fn sample_circulant_embedding( grid_x: ArrayView1<'_, f64>, grid_y: ArrayView1<'_, f64>, cov: CorrelationFunction, rng: &mut StdRng, ) -> IntegrateResult<Array2<f64>>
Sample a Gaussian random field using the circulant embedding method.
Embeds the covariance into a [2nx × 2ny] circulant block matrix,
computes eigenvalues via 2-D FFT, and multiplies complex Gaussian noise
by the square-root eigenvalues in the frequency domain.
§Errors
Returns an error if nx or ny is zero.
Sourcepub fn sample_kl_expansion(
grid_x: ArrayView1<'_, f64>,
grid_y: ArrayView1<'_, f64>,
cov: CorrelationFunction,
n_terms: usize,
rng: &mut StdRng,
) -> IntegrateResult<Array2<f64>>
pub fn sample_kl_expansion( grid_x: ArrayView1<'_, f64>, grid_y: ArrayView1<'_, f64>, cov: CorrelationFunction, n_terms: usize, rng: &mut StdRng, ) -> IntegrateResult<Array2<f64>>
Sample a Gaussian random field using the Karhunen-Loève expansion.
Builds the discrete covariance matrix over a flattened [nx × ny] grid,
extracts leading n_terms eigenpairs via power iteration, then assembles:
u(x) = Σ_{k=1}^{n_terms} sqrt(λ_k) * ξ_k * φ_k(x)§Errors
Returns an error if the grid or n_terms is invalid.
Sourcepub fn sample_fourier(
nx: usize,
ny: usize,
lx: f64,
ly: f64,
cov: CorrelationFunction,
rng: &mut StdRng,
) -> IntegrateResult<Array2<f64>>
pub fn sample_fourier( nx: usize, ny: usize, lx: f64, ly: f64, cov: CorrelationFunction, rng: &mut StdRng, ) -> IntegrateResult<Array2<f64>>
Sample a Gaussian random field using the Fourier spectral method.
Assumes periodic BCs and separable (isotropic) covariance.
§Errors
Returns an error if nx or ny is zero.
Trait Implementations§
Source§impl Clone for RandomField
impl Clone for RandomField
Source§fn clone(&self) -> RandomField
fn clone(&self) -> RandomField
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RandomField
impl RefUnwindSafe for RandomField
impl Send for RandomField
impl Sync for RandomField
impl Unpin for RandomField
impl UnsafeUnpin for RandomField
impl UnwindSafe for RandomField
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more