Skip to content

Commit

Permalink
Small Improvements to Gaussian Random Field (#48)
Browse files Browse the repository at this point in the history
* Retain mean mode from white noise

* Add comment on why there is a 2.0 in denominator
  • Loading branch information
Ceyron authored Oct 22, 2024
1 parent e483557 commit 3a17946
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion exponax/ic/_gaussian_random_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3a17946

Please sign in to comment.