scimba_torch.flows.integrators_ode

ODE integrators for geometric numerical integration.

This module provides various numerical integrators for ordinary differential equations, with a focus on structure-preserving (symplectic) methods for Hamiltonian systems.

Note

The implementations are based on the following references: [Hair03] and [Raz18].

[Hair03]

E. Hairer, C. Lubich, and G. Wanner. Geometric numerical integration illustrated by the Störmer-Verlet method. Cambridge University Press, 2003.

[Raz18]

Razafindralandy, D., Hamdouni, A. & Chhay, M. A review of some geometric integrators. Adv. Model. and Simul. in Eng. Sci. 5, 16 (2018). https://doi.org/10.1186/s40323-018-0110-y

Functions

euler_midpoint(d_p_h, d_q_h, mu, x0, t)

Midpoint Euler integrator for Hamiltonian systems.

euler_symplectic(d_p_h, d_q_h, mu, x0, t)

Symplectic Euler integrator for Hamiltonian systems.

gauss_legendre(d_p_h, d_q_h, mu, x0, t)

Gauss-Legendre integrator for Hamiltonian systems.

rk4(f, mu, x0, t)

Generic Runge-Kutta 4th order integrator.

rk4_symplectic(d_p_h, d_q_h, mu, x0, t)

RK4 symplectic integrator for Hamiltonian systems.

verlet_explicit(d_p_h, d_q_h, mu, x0, t)

Verlet explicit integrator for separated Hamiltonians.

verlet_implicit(d_p_h, d_q_h, mu, x0, t)

Verlet implicit integrator for non-separated Hamiltonians.

rk4(f, mu, x0, t)[source]

Generic Runge-Kutta 4th order integrator.

Parameters:
  • f (Callable) – Function defining the ODE, of the form f(t, mu, x).

  • mu (Any) – Additional parameters for the function f.

  • x0 (Tensor) – Initial condition tensor.

  • t (Tensor) – 1D tensor of time points where the solution is computed.

Return type:

Tensor

Returns:

Tensor containing the solution at each time point in t.

verlet_explicit(d_p_h, d_q_h, mu, x0, t)[source]

Verlet explicit integrator for separated Hamiltonians.

Parameters:
  • d_p_h (Callable) – Function computing the derivative of the Hamiltonian with respect to p.

  • d_q_h (Callable) – Function computing the derivative of the Hamiltonian with respect to q.

  • mu (Any) – Additional parameters for the functions DpH and DqH.

  • x0 (Tensor) – Initial condition tensor.

  • t (Tensor) – 1D tensor of time points where the solution is computed.

Return type:

Tensor

Returns:

Tensor containing the solution at each time point in t.

verlet_implicit(d_p_h, d_q_h, mu, x0, t)[source]

Verlet implicit integrator for non-separated Hamiltonians.

Parameters:
  • d_p_h (Callable) – Function computing the derivative of the Hamiltonian with respect to p.

  • d_q_h (Callable) – Function computing the derivative of the Hamiltonian with respect to q.

  • mu (Any) – Additional parameters for the functions d_p_h and d_q_h.

  • x0 (Tensor) – Initial condition tensor.

  • t (Tensor) – 1D tensor of time points where the solution is computed.

Return type:

Tensor

Returns:

Tensor containing the solution at each time point in t.

euler_symplectic(d_p_h, d_q_h, mu, x0, t)[source]

Symplectic Euler integrator for Hamiltonian systems.

Parameters:
  • d_p_h (Callable) – Function computing the derivative of the Hamiltonian with respect to p.

  • d_q_h (Callable) – Function computing the derivative of the Hamiltonian with respect to q.

  • mu (Any) – Additional parameters for the functions d_p_h and d_q_h.

  • x0 (Tensor) – Initial condition tensor.

  • t (Tensor) – 1D tensor of time points where the solution is computed.

Return type:

Tensor

Returns:

Tensor containing the solution at each time point in t.

euler_midpoint(d_p_h, d_q_h, mu, x0, t)[source]

Midpoint Euler integrator for Hamiltonian systems.

Parameters:
  • d_p_h (Callable) – Function computing the derivative of the Hamiltonian with respect to p.

  • d_q_h (Callable) – Function computing the derivative of the Hamiltonian with respect to q.

  • mu (Any) – Additional parameters for the functions d_p_h and d_q_h.

  • x0 (Tensor) – Initial condition tensor.

  • t (Tensor) – 1D tensor of time points where the solution is computed.

Return type:

Tensor

Returns:

Tensor containing the solution at each time point in t.

gauss_legendre(d_p_h, d_q_h, mu, x0, t)[source]

Gauss-Legendre integrator for Hamiltonian systems.

Parameters:
  • d_p_h (Callable) – Function computing the derivative of the Hamiltonian with respect to p.

  • d_q_h (Callable) – Function computing the derivative of the Hamiltonian with respect to q.

  • mu (Any) – Additional parameters for the functions d_p_h and d_q_h.

  • x0 (Tensor) – Initial condition tensor.

  • t (Tensor) – 1D tensor of time points where the solution is computed.

Return type:

Tensor

Returns:

Tensor containing the solution at each time point in t.

rk4_symplectic(d_p_h, d_q_h, mu, x0, t)[source]

RK4 symplectic integrator for Hamiltonian systems.

Parameters:
  • d_p_h (Callable) – Function computing the derivative of the Hamiltonian with respect to p.

  • d_q_h (Callable) – Function computing the derivative of the Hamiltonian with respect to q.

  • mu (Any) – Additional parameters for the functions d_p_h and d_q_h.

  • x0 (Tensor) – Initial condition tensor.

  • t (Tensor) – 1D tensor of time points where the solution is computed.

Return type:

Tensor

Returns:

Tensor containing the solution at each time point in t.