integrate - cchandre/HamLorenz GitHub Wiki

integrate (function)

Purpose

Integrates the equations of motion of the Hamiltonian Lorenz system, from time 0 to tf using either standard or custom numerical solvers.

Parameters

  • tf: final time of integration.
  • x: initial condition vector. See generate_initial_conditions for a function to generate initial conditions compatible with the energy and Casimir invariants constraints.
  • t_eval: (optional) array of time points to store in the output. Default is None (i.e., use points selected by the solver).
  • events: (optional) event functions to monitor during integration. Default is None.
  • method: (optional) integration method ('RK45', or custom methods defined in METHODS). Default is 'BM4'.
  • step: (optional) maximum step size (for fixed-step methods). Default is 1e-2.
  • tol: (optional) absolute and relative tolerance for adaptive solvers. Default is 1e-8.
  • omega: (optional) coupling parameter in the extended phase space (see pyHamSys). Default is 10.

Method Selection

  • Standard methods (solve_ivp): If method is in ivp.METHODS, use SciPy’s solve_ivp.

  • Custom symplectic methods (solve_ivp_symp, solve_ivp_sympext):

    • If len(x) is divisible by K + 1, use a symplectic solver with internal functions _chi and _chi_star.
    • Otherwise, set up an extended Hamiltonian system and integrate its transformed state, applying inverse transformation to the output.

Methods include:

  • For solve_ivp: 'RK23', 'RK45', 'DOP853', 'Radau', 'BDF', 'LSODA'
  • For solve_ivp_symp and solve_ivp_sympext: 'Verlet', 'FR', 'BM4' (recommended), 'BM6'. See pyHamSys for more details.

Outputs

  • sol: A bunch object (as returned by solve_ivp), containing t, y, and optionally t_events and y_events.

Notes

  • Computes integration error relative to the initial state.
  • Prints the runtime of the integration process.
  • More information on the custom symplectic integrators is available at pyHamSys

Raises

  • ValueError if an unknown method is specified.