CrankNicolsonStep

class cubie.integrators.CrankNicolsonStep(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], n: int, evaluate_f: Callable | None = None, evaluate_observables: Callable | None = None, evaluate_driver_at_t: Callable | None = None, get_solver_helper_fn: Callable | None = None, **kwargs)[source]

Bases: ODEImplicitStep

Crank–Nicolson step with embedded backward Euler error estimation.

__init__(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], n: int, evaluate_f: Callable | None = None, evaluate_observables: Callable | None = None, evaluate_driver_at_t: 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 – Number of state entries advanced per step.

  • evaluate_f – Device function for evaluating f(t, y) right-hand side.

  • evaluate_observables – Device function computing system observables.

  • evaluate_driver_at_t – 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(evaluate_f: Callable, evaluate_observables: Callable, evaluate_driver_at_t: 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:
  • evaluate_f – Device function for evaluating f(t, y).

  • evaluate_observables – Device function for computing observables.

  • evaluate_driver_at_t – 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:

StepCache

property is_adaptive: bool

Return True because the embedded error estimate enables adaptivity.

property is_multistage: bool

Return False because Crank–Nicolson is a single-stage method.

property order: int

Return the classical order of the Crank–Nicolson method.

register_buffers() None[source]

Register buffers with buffer_registry.

property threads_per_step: int

Return the number of threads used per step.