CrankNicolsonStep
Defaults
algorithm="crank_nicolson" performs a single-stage, order-2
update and runs a backward-Euler companion solve each step; the
difference between the two supplies an embedded error estimate, so
the method defaults to Gustafsson predictive control (step-size
growth clamped to 0.2–8.0×). Both implicit
solves use the shared Newton–Krylov defaults listed in
Default settings.
- class cubie.integrators.CrankNicolsonStep(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], n_states: int, dxdt_fn: Callable | None = None, observables_fn: Callable | None = None, drivers_fn: Callable | None = None, get_solver_helper_fn: Callable | None = None, **kwargs)[source]
Bases:
ODEImplicitStepCrank–Nicolson step with embedded backward Euler error estimation.
- __init__(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], n_states: int, dxdt_fn: Callable | None = None, observables_fn: Callable | None = None, drivers_fn: Callable | None = None, get_solver_helper_fn: Callable | None = None, **kwargs) None[source]
Initialise the Crank–Nicolson step configuration.
- Parameters:
precision – Precision applied to device buffers.
n_states – Number of state entries advanced per step.
dxdt_fn – Device function for evaluating f(t, y) right-hand side.
observables_fn – Device function computing system observables.
drivers_fn – Optional device function evaluating drivers at arbitrary times.
get_solver_helper_fn – Callable returning device helpers used by the nonlinear solver.
**kwargs – Optional parameters passed to config classes. See CrankNicolsonStepConfig, ImplicitStepConfig, and solver config classes for available parameters. None values are ignored.
- build_step(dxdt_fn: Callable, observables_fn: Callable, drivers_fn: Callable | None, solver_function: Callable, numba_precision: type, n: int, n_drivers: int) StepCache[source]
Build the device function for the Crank–Nicolson step.
- Parameters:
dxdt_fn – Device function for evaluating f(t, y).
observables_fn – Device function for computing observables.
drivers_fn – Optional device function for evaluating drivers at time t.
solver_function – Device function for the Newton-Krylov nonlinear solver.
numba_precision – Numba precision corresponding to the configured precision.
n – Dimension of the state vector.
n_drivers – Number of driver signals provided to the system.
- Returns:
Container holding the compiled step function and solver.
- Return type:
- classmethod family_defaults(tableau=None) AlgorithmDefaults[source]
Return the Crank-Nicolson defaults.
- has_error_estimate = True