From 3a1794659a9492c5175eec96125627e3dfe1112a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20K=C3=B6hler?= <27728103+Ceyron@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:31:55 +0200 Subject: [PATCH] Small Improvements to Gaussian Random Field (#48) * Retain mean mode from white noise * Add comment on why there is a 2.0 in denominator --- exponax/ic/_gaussian_random_field.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/exponax/ic/_gaussian_random_field.py b/exponax/ic/_gaussian_random_field.py index 1af80c4..42d46ee 100644 --- a/exponax/ic/_gaussian_random_field.py +++ b/exponax/ic/_gaussian_random_field.py @@ -64,9 +64,12 @@ def __call__( self.num_spatial_dims, self.domain_extent, num_points ) wavenumer_norm_grid = jnp.linalg.norm(wavenumber_grid, axis=0, keepdims=True) + # Further division by 2.0 in the exponent is because we want to have the + # **power-spectrum** follow a **power-law**. See + # https://github.com/Ceyron/exponax/issues/9 for more details. amplitude = jnp.power(wavenumer_norm_grid, -self.powerlaw_exponent / 2.0) amplitude = ( - amplitude.flatten().at[0].set(0.0).reshape(wavenumer_norm_grid.shape) + amplitude.flatten().at[0].set(1.0).reshape(wavenumer_norm_grid.shape) ) real_key, imag_key = jr.split(key, 2)