4.5.5 pde.solvers.euler module

Defines an explicit solver for the Euler scheme.

EulerSolver

Explicit Euler solver.

class EulerSolver(pde: PDEBase, *, backend: str | pde.backends.base.BackendBase = 'auto', adaptive: bool = False, tolerance: float = 0.0001)[source]

Bases: AdaptiveSolverBase

Explicit Euler solver.

Parameters:
  • pde (PDEBase) – The partial differential equation that should be solved

  • backend (str) – The backend used for numerical operations

  • adaptive (bool) – Whether to use adaptive time stepping

  • tolerance (float) – Error tolerance for adaptive time stepping

property backend: BackendBase

The backend for this solver.

Type:

BackendBase

property backend_name: str

The name of the backend used for this solver.

Type:

str

classmethod from_name(name: str, pde: PDEBase, **kwargs) → SolverBase

Create a solver object from its registered name.

Solver classes are automatically registered when they inherit from SolverBase. Note that this also requires that the respective python module containing the solver has been loaded before it is attempted to be used.

Parameters:
  • name (str) – The name of the solver to construct

  • pde (PDEBase) – The partial differential equation that should be solved

  • **kwargs – Additional arguments for the constructor of the solver

Returns:

An instance of a subclass of SolverBase

make_stepper(state: TField, dt: float | None = None) → StepperType

Create the executable stepping function produced by this solver.

Parameters:
  • state (FieldBase) – An example for the state from which the grid and other information can be extracted

  • dt (float) – Time step used (Uses SolverBase.dt_default if None). This sets the initial time step for adaptive solvers.

Returns:

Function that can be called to advance the state from time t_start to time t_end. The function call signature is (state: numpy.ndarray, t_start: float, t_end: float)

class ExplicitSolver(pde: PDEBase, scheme: Literal['euler', 'runge-kutta', 'rk', 'rk45'] = 'euler', **kwargs)[source]

Bases: AdaptiveSolverBase

Various explicit PDE solvers.

Parameters:
  • pde (PDEBase) – The partial differential equation that should be solved

  • backend (str) – The backend used for numerical operations

  • adaptive (bool) – Whether to use adaptive time stepping

  • tolerance (float) – Error tolerance for adaptive time stepping

property backend: BackendBase

The backend for this solver.

Type:

BackendBase

property backend_name: str

The name of the backend used for this solver.

Type:

str

classmethod from_name(name: str, pde: PDEBase, **kwargs) → SolverBase

Create a solver object from its registered name.

Solver classes are automatically registered when they inherit from SolverBase. Note that this also requires that the respective python module containing the solver has been loaded before it is attempted to be used.

Parameters:
  • name (str) – The name of the solver to construct

  • pde (PDEBase) – The partial differential equation that should be solved

  • **kwargs – Additional arguments for the constructor of the solver

Returns:

An instance of a subclass of SolverBase

make_stepper(state: TField, dt: float | None = None) → StepperType

Create the executable stepping function produced by this solver.

Parameters:
  • state (FieldBase) – An example for the state from which the grid and other information can be extracted

  • dt (float) – Time step used (Uses SolverBase.dt_default if None). This sets the initial time step for adaptive solvers.

Returns:

Function that can be called to advance the state from time t_start to time t_end. The function call signature is (state: numpy.ndarray, t_start: float, t_end: float)