Truncated Fourier Series¤
exponax.ic.RandomTruncatedFourierSeries
¤
Bases: BaseRandomICGenerator
Source code in exponax/ic/_truncated_fourier_series.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
__init__
¤
__init__(
num_spatial_dims: int,
*,
cutoff: int = 5,
amplitude_range: tuple[int, int] = (-1.0, 1.0),
angle_range: tuple[int, int] = (0.0, 2.0 * jnp.pi),
offset_range: tuple[int, int] = (0.0, 0.0),
std_one: bool = False,
max_one: bool = False
)
Random generator for initial states consisting of a truncated Fourier series with random Fourier coefficients.
In 1d, the functional form reads:
u(x) = o + ∑ₖ aₖ sin(k (2π/L) x) + bₖ cos(k (2 π)/L x)
where o
is the offset, aₖ
and bₖ
are the amplitudes of the sine
and cosine terms, respectively, and k
is the wavenumber which ranges
up to cutoff
. An equivalent representation is via angular offsets
u(x) = o + ∑ₖ aₖ sin(k (2π/L) x + ϕₖ)
where ϕₖ
is the angular offset.
The generalization to higher dimensions includes mixed terms and is not that straightforward to write down.
Offsets are drawn accoriding to a uniform distribution in the range
offset_range
. Amplitudes are drawn according to a uniform distribution
in the range amplitude_range
. Angles (=angular offsets) are drawn
according to a uniform distribution in the range angle_range
.
Arguments:
- num_spatial_dims
: The number of spatial dimensions d
.
- cutoff
: The cutoff of the wavenumbers. This limits the
"complexity" of the initial state. Note that some dynamics are
very sensitive to high-frequency information.
- amplitude_range
: The range of the amplitudes. Defaults to
(-1.0, 1.0)
.
- angle_range
: The range of the angles. Defaults to (0.0, 2π)
.
- offset_range
: The range of the offsets. Defaults to (0.0,
0.0)
, meaning zero-mean by default.
- std_one
: Whether to normalize the state to have a standard
deviation of one. Defaults to False
. Only works if the offset
is zero.
- max_one
: Whether to normalize the state to have the maximum
absolute value of one. Defaults to False
. Only one of
std_one
and max_one
can be True
.
Source code in exponax/ic/_truncated_fourier_series.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
__call__
¤
__call__(
num_points: int, *, key: PRNGKeyArray
) -> Float[Array, "1 ... N"]
Source code in exponax/ic/_truncated_fourier_series.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|