DOPRI5-based solver made specifically for log grids.
A nonlinear update step is decoupled from the linear update step.
Special care is given to handling numerical (float-induced) random numerical errors which yield huge gradients.
Based on scipy’s DOPRI5 implementation
Perform a single Runge-Kutta step.
This function computes a prediction of an explicit Runge-Kutta method and
also estimates the error of a less accurate method.
Notation for Butcher tableau is as in [2].
Parameters:
fun – Right-hand side of the system.
t – Current time.
y – Current state.
h – Step to use.
A – Coefficients for combining previous RK stages to compute the next stage. For explicit methods the coefficients at and above the main diagonal are zeros.
B – Coefficients for combining RK stages for computing the final prediction.
C – Coefficients for incrementing time for consecutive RK stages. The value for the first stage is always zero.
K – Storage array for putting RK stages here. Stages are stored in rows. The last row is a linear combination of the previous rows with coefficients
Returns: tuple (y_new,f_new) where y_new is the solution at t+h computed with a higher accuracy, and f_new is the derivative fun(t+h,y_new).
Perform a single Runge-Kutta step.
This function computes a prediction of an explicit Runge-Kutta method and
also estimates the error of a less accurate method.
Notation for Butcher tableau is as in [3].
Parameters:
fun – Right-hand side of the system.
t – Current time.
y – Current state.
h – Step to use.
A – Coefficients for combining previous RK stages to compute the next stage. For explicit methods the coefficients at and above the main diagonal are zeros.
B – Coefficients for combining RK stages for computing the final prediction.
C – Coefficients for incrementing time for consecutive RK stages. The value for the first stage is always zero.
K – Storage array for putting RK stages here. Stages are stored in rows. The last row is a linear combination of the previous rows with coefficients
Returns: tuple (y_new,f_new) where y_new is the solution at t+h computed with a higher accuracy, and f_new is the derivative fun(t+h,y_new).
.. rubric:: References
Generic top-level object to handle solving log-grid equations
Parameters:
fields_names – the names of the grid-shaped fields
equation_nl – the function that performs the linear-less update step. Returns the time derivative of the fields
D – space dimension
l_params – parameters that define the grid parameter ̀`l` as a dict with keys {"a","b","plastic"}. “plastic” supercedes all other. For l=2, chose a=b=None
k_min – minimum k of the grid. Default is defined by Grid.
simu_params – physical quantities relevant to the simulation, fixed for the whole simulation.
n_threads – Number of threads to use, default is max/2 (not recommended, run benchmarking for better results. If running batch simulations, 1 is optimal.)
equation_l – implicit visocsity update step, called after the RK step has ended. Returns the new fields and their new time derivative
Solve the solver’s equation with the required numerical parameters.
Parameters:
save_path – where to save the fields and simulation parameters. Will backup if exists, will create otherwise
initial_conditions – if str: either "loadfromsave" to resume simulation, [legacy: or the path of the .npz save file whence to initialize the fields].
If tuple (name,step): load step step from .h5 name.
Otherwise: function that returns the initial fields.
If “loadfromsave”, it will override all dependant settings: end_simulation,rtol,atol,l_params,D,fields_name,simu_params,grid,k_min
solver_params – params forwarded to the solver
init_t – initial simulation time
end_simulation – dict of thresholds to end the simulation: {t:maxphysicaltime,elapsed_time:maxrealtimespentcomputing,step:maxsavestep}
save_one_in – save one step to file every X ode_step
update_gridsize_cb – optional callback to change the grid size after a step. Returns None if no change is to be made, returns the new grid size otherwise.
dt_params – {dt0:initialtimestep,dtmin,dtmax}
solver – among "ETD35" (default), "ETD4RK", "ViscDopri"