integrate - cchandre/HamLorenz GitHub Wiki
integrate
(function)
Purpose
Integrates the system's equations of motion from time 0
to tf
using either standard or custom numerical solvers.
Parameters
tf
: Final time of integration.x
: Initial condition vector.t_eval
: Optional array of time points to store in the output.events
: Optional event functions to monitor during integration.method
: Integration method ('RK45'
, or custom methods defined inMETHODS
).step
: Maximum step size (for fixed-step methods).tol
: Absolute and relative tolerance for adaptive solvers.
Method Selection
-
Standard methods (
solve_ivp
): Ifmethod
is inivp.METHODS
, use SciPy’ssolve_ivp
. -
Custom symplectic methods (
solve_ivp_symp
,solve_ivp_sympext
):- If
len(x)
is divisible byK + 1
, use a symplectic solver with internal functions_chi
and_chi_star
. - Otherwise, set up an auxiliary Hamiltonian system and integrate its transformed state, applying inverse transformation to the output.
- If
Methods include:
- For
solve_ivp
: 'RK23', 'RK45', 'DOP853', 'Radau', 'BDF', 'LSODA' - For
solve_ivp_symp
andsolve_ivp_sympext
: 'Verlet', 'FR', 'BM4' (recommended), 'BM6'. See pyhamsys for more details.
Outputs
sol
: ABunch
object (as returned bysolve_ivp
), containingt
,y
, and optionallyt_events
andy_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.