numerics
Loading...
Searching...
No Matches
ode.hpp File Reference

ODE time integrators: Euler, RK4, adaptive RK45 (Dormand-Prince), and symplectic Velocity Verlet / Yoshida-4 for Hamiltonian systems. More...

#include "core/types.hpp"
#include "core/vector.hpp"
#include <functional>

Go to the source code of this file.

Classes

struct  num::ODEResult
 Result returned by general ODE integrators. More...
 
struct  num::SymplecticResult
 Result returned by symplectic integrators. More...
 

Namespaces

namespace  num
 

Typedefs

using num::ODERhsFn = std::function< void(real t, const Vector &y, Vector &dydt)>
 Right-hand side callable: fills dydt = f(t, y) in-place.
 
using num::StepCallback = std::function< void(real t, const Vector &y)>
 
using num::AccelFn = std::function< void(const Vector &q, Vector &acc)>
 
using num::SymplecticCallback = std::function< void(real t, const Vector &q, const Vector &v)>
 

Functions

ODEResult num::ode_euler (ODERhsFn f, Vector y0, real t0, real t1, real h, StepCallback on_step=nullptr)
 
ODEResult num::ode_rk4 (ODERhsFn f, Vector y0, real t0, real t1, real h, StepCallback on_step=nullptr)
 Classic 4th-order Runge-Kutta (fixed step).
 
ODEResult num::ode_rk45 (ODERhsFn f, Vector y0, real t0, real t1, real rtol=1e-6, real atol=1e-9, real h0=1e-3, idx max_steps=1000000, StepCallback on_step=nullptr)
 
SymplecticResult num::ode_verlet (AccelFn accel, Vector q0, Vector v0, real t0, real t1, real h, SymplecticCallback on_step=nullptr)
 
SymplecticResult num::ode_yoshida4 (AccelFn accel, Vector q0, Vector v0, real t0, real t1, real h, SymplecticCallback on_step=nullptr)
 

Detailed Description

ODE time integrators: Euler, RK4, adaptive RK45 (Dormand-Prince), and symplectic Velocity Verlet / Yoshida-4 for Hamiltonian systems.

General ODE solvers (for dy/dt = f(t, y)): ode_euler – forward Euler, O(h) ode_rk4 – classic 4th-order Runge-Kutta, O(h⁴) ode_rk45 – adaptive Dormand-Prince with PI step control, O(h⁵)

Symplectic integrators (for separable H(q,p) = T(p) + V(q)): ode_verlet – velocity Verlet, 2nd-order symplectic, 1 force eval/step ode_yoshida4 – Yoshida (1990) 4th-order symplectic, 3 force evals/step

All integrators accept an optional on_step callback invoked after each accepted step, enabling trajectory recording and event detection without storing the full history in the integrator itself.

Definition in file ode.hpp.