Repeated Stepper¤
Use this to create steppers that perform substepping. To do this instantiate those with a subset of the desired dt
. For example,
substepped_stepper = exponax.stepper.Burgers(1, 1.0, 64, 0.1/5)
stepper = exponax.stepper.RepeatedStepper(substepped_stepper, 5)
This will create a stepper that performs 5 substeps of 0.1/5=0.02 each time it is called.
exponax.RepeatedStepper
¤
Bases: Module
Source code in exponax/_repeated_stepper.py
9 10 11 12 13 14 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 |
|
__init__
¤
__init__(stepper: BaseStepper, num_sub_steps: int)
Sugarcoat the utility function repeat
in a callable PyTree for easy
composition with other equinox modules.
Info
Performs the substepping in Fourier space to avoid unnecessary back-and-forth transformations.
One intended usage is to get "more accurate" or "more stable" time steppers that perform substeps.
The effective time step is self.stepper.dt * self.num_sub_steps
. In order to
get a time step of X with Y substeps, first instantiate a stepper with a
time step of X/Y and then wrap it in a RepeatedStepper with num_sub_steps=Y.
Arguments:
stepper
: The stepper to repeat.num_sub_steps
: The number of substeps to perform.
Source code in exponax/_repeated_stepper.py
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 |
|
__call__
¤
__call__(
u: Float[Array, "C ... N"]
) -> Float[Array, "C ... N"]
Step the PDE forward in time by self.num_sub_steps time steps given the
current state u
.
Info
Performs the substepping in Fourier space to avoid unnecessary back-and-forth transformations.
Arguments:
u
: The current state.
Returns:
u_next
: The state afterself.num_sub_steps
time steps.
Tip
Use this call method together with exponax.rollout
to efficiently
produce temporal trajectories.
Info
For batched operation, use jax.vmap
on this function.
Source code in exponax/_repeated_stepper.py
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 |
|