HMath.ODE¶
Module index · Numerical conventions
Description
Checked real ODE/DAE integration. Fixed-step methods use the requested grid. Adaptive methods have explicit tolerances, step bounds and work budgets. Callbacks must be pure, total and retain the state dimension. Dense output uses a cubic Hermite interpolant, independently of the integration method.
On this page¶
| API | Purpose |
|---|---|
| ODE | Time and state callback, returning a derivative of exactly the same length. |
| Method | Explicit, multistep, implicit, and linearly implicit methods. |
| Euler | Declaration and type contract below. |
| Heun | Declaration and type contract below. |
| Midpoint | Declaration and type contract below. |
| RK2 | Declaration and type contract below. |
| RK4 | Declaration and type contract below. |
| RK23 | Declaration and type contract below. |
| RK45 | Declaration and type contract below. |
| DormandPrince | Declaration and type contract below. |
| DOP853 | Declaration and type contract below. |
| AdamsBashforth | Declaration and type contract below. |
| AdamsMoulton | Declaration and type contract below. |
| PredictorCorrector | Declaration and type contract below. |
| BackwardEuler | Declaration and type contract below. |
| BDF | Declaration and type contract below. |
| Radau | Declaration and type contract below. |
| Rosenbrock | Declaration and type contract below. |
| ODEOptions | Positive step bounds and tolerances; maximumSteps bounds accepted and rejected attempts, and newtonIterations bounds each implicit correction. |
| ODEOptions | Declaration and type contract below. |
| odeAbsoluteTolerance | Finite positive absolute local error tolerance. |
| odeRelativeTolerance | Finite nonnegative local error tolerance relative to state scale. |
| initialStep | Requested positive initial step magnitude; integration direction follows time bounds. |
| minimumStep | Positive minimum permitted step magnitude before reporting failure. |
| maximumStep | Positive maximum permitted step magnitude. |
| maximumSteps | Maximum integration-step work budget. |
| newtonIterations | Iteration budget for implicit-method nonlinear solves. |
| defaultODEOptions | Conservative default adaptive settings for Double callbacks. |
| Trajectory | Strictly monotonic time samples, states and endpoint derivatives. |
| Trajectory | Declaration and type contract below. |
| trajectoryTimes | Accepted sample times in integration order. |
| trajectoryStates | State vector at each trajectory time. |
| trajectoryDerivatives | ODE derivative vector at each trajectory sample, used by dense output. |
| solveIVP | Integrate on n equal panels. |
| solveAdaptive | Adaptive explicit RK integration. |
| interpolateTrajectory | Cubic Hermite interpolation inside the trajectory's closed time range. |
| Event | A located event time and its dense-interpolated state. |
| Event | Declaration and type contract below. |
| eventTime | Located event crossing time. |
| eventState | Interpolated state vector at eventTime. |
| EventDirection | Event direction in increasing physical time, even for backward integration. |
| AnyDirection | Declaration and type contract below. |
| Rising | Declaration and type contract below. |
| Falling | Declaration and type contract below. |
| locateEvents | Locate bracketed sign-changing events by dense-output bisection. |
| solveBoundary | Shooting boundary-value solver: all initial-state components are unknown. |
| solveDAE | Index-one implicit DAE driver F(t,y,y')=0 with backward differences. |
| solveHamiltonian | Fixed-step symplectic integration; output states concatenate q then p. |
| HamiltonianMethod | Separable Hamiltonian methods for q'=velocity(p), p'=force(q). |
| SymplecticEuler | Declaration and type contract below. |
| Verlet | Declaration and type contract below. |
| Leapfrog | Declaration and type contract below. |
| solveNystrom | Fourth-order explicit Runge-Kutta-Nystrom method for q''=a(t,q), with acceleration independent of velocity. |
| sensitivities | Terminal-state parameter sensitivities by centered perturbation of the complete IVP solve. |
| equilibrium | Find an autonomous equilibrium by a locally convergent Newton solve. |
| phaseTrajectories | Compute autonomous phase-space trajectories for independently supplied starts. |
| lyapunovExponents | Full Lyapunov spectrum by the Benettin tangent-space method: integrate variational equations with RK4, then modified Gram-Schmidt at each sample. |
Documentation
ODE
type ODE = Double -> [Double] -> [Double] Source #
Time and state callback, returning a derivative of exactly the same length.
Method
Explicit, multistep, implicit, and linearly implicit methods. RK45 is the Cash-Karp 5(4) pair; DormandPrince is the Dormand-Prince 5(4) pair. Radau is two-stage Radau IIA (order 3), BDF is order 2 with backward-Euler startup, and Rosenbrock is linearly implicit Rosenbrock-Euler (order 1).
ODEOptions
data ODEOptions Source #
Positive step bounds and tolerances; maximumSteps bounds accepted and rejected attempts, and newtonIterations bounds each implicit correction.
Constructors
| ODEOptions | |
Fields
| |
Instances
| Show ODEOptions Source # | |
Defined in HMath.ODE Methods showsPrec :: Int -> ODEOptions -> ShowS # show :: ODEOptions -> String # showList :: [ODEOptions] -> ShowS # | |
| Eq ODEOptions Source # | |
Defined in HMath.ODE | |
defaultODEOptions
defaultODEOptions :: ODEOptions Source #
Conservative default adaptive settings for Double callbacks.
Trajectory
data Trajectory Source #
Strictly monotonic time samples, states and endpoint derivatives. The constructor is public for inspection; interpolation validates all dimensions.
Constructors
| Trajectory | |
Fields
| |
Instances
| Show Trajectory Source # | |
Defined in HMath.ODE Methods showsPrec :: Int -> Trajectory -> ShowS # show :: Trajectory -> String # showList :: [Trajectory] -> ShowS # | |
| Eq Trajectory Source # | |
Defined in HMath.ODE | |
solveIVP
solveIVP :: Method -> ODEOptions -> Int -> ODE -> Double -> Double -> [Double] -> Either MathError Trajectory Source #
Integrate on n equal panels. Multistep methods use genuine derivative history; implicit methods use checked finite-difference Newton iterations.
solveAdaptive
solveAdaptive :: Method -> ODEOptions -> ODE -> Double -> Double -> [Double] -> Either MathError Trajectory Source #
Adaptive explicit RK integration. EulerHeunMidpoint/RK4 use step-doubling
error estimates. RK23RK45DormandPrince/DOP853 use their embedded estimates.
Multistep and implicit methods require solveIVP to preserve their grid/history.
interpolateTrajectory
interpolateTrajectory :: Trajectory -> Double -> Either MathError [Double] Source #
Cubic Hermite interpolation inside the trajectory's closed time range. Extrapolation, malformed public trajectories and repeated sample times fail.
Event
A located event time and its dense-interpolated state.
Constructors
| Event | |
Fields
| |
EventDirection
data EventDirection Source #
Event direction in increasing physical time, even for backward integration.
Constructors
| AnyDirection | |
| Rising | |
| Falling |
Instances
| Show EventDirection Source # | |
Defined in HMath.ODE Methods showsPrec :: Int -> EventDirection -> ShowS # show :: EventDirection -> String # showList :: [EventDirection] -> ShowS # | |
| Eq EventDirection Source # | |
Defined in HMath.ODE Methods (==) :: EventDirection -> EventDirection -> Bool # (/=) :: EventDirection -> EventDirection -> Bool # | |
locateEvents
locateEvents :: EventDirection -> Double -> (Double -> [Double] -> Double) -> Trajectory -> Either MathError [Event] Source #
Locate bracketed sign-changing events by dense-output bisection. Tangential roots and multiple roots inside one sample interval are not guaranteed.
solveBoundary
solveBoundary :: Method -> ODEOptions -> Int -> ODE -> ([Double] -> [Double] -> [Double]) -> Double -> Double -> [Double] -> Either MathError Trajectory Source #
Shooting boundary-value solver: all initial-state components are unknown. The boundary callback takes initial/final states and returns n residuals. Returns the trajectory matching a locally converged shooting root; convergence is local and depends on the supplied initial guess.
solveDAE
solveDAE :: ODEOptions -> Int -> (Double -> [Double] -> [Double] -> [Double]) -> Double -> Double -> [Double] -> [Double] -> Either MathError Trajectory Source #
Index-one implicit DAE driver F(t,y,y')=0 with backward differences. Initial y and y' must be consistent to the configured tolerance. Each subsequent state is obtained by a full residual Newton solve.
solveHamiltonian
solveHamiltonian :: HamiltonianMethod -> Int -> ([Double] -> [Double]) -> ([Double] -> [Double]) -> Double -> Double -> [Double] -> [Double] -> Either MathError Trajectory Source #
Fixed-step symplectic integration; output states concatenate q then p. Verlet is kick-drift-kick; Leapfrog is drift-kick-drift with integer-time output momenta. These equivalent second-order splittings have distinct order.
HamiltonianMethod
data HamiltonianMethod Source #
Separable Hamiltonian methods for q'=velocity(p), p'=force(q).
Constructors
| SymplecticEuler | |
| Verlet | |
| Leapfrog |
Instances
| Show HamiltonianMethod Source # | |
Defined in HMath.ODE Methods showsPrec :: Int -> HamiltonianMethod -> ShowS # show :: HamiltonianMethod -> String # showList :: [HamiltonianMethod] -> ShowS # | |
| Eq HamiltonianMethod Source # | |
Defined in HMath.ODE Methods (==) :: HamiltonianMethod -> HamiltonianMethod -> Bool # (/=) :: HamiltonianMethod -> HamiltonianMethod -> Bool # | |
solveNystrom
solveNystrom :: Int -> (Double -> [Double] -> [Double]) -> Double -> Double -> [Double] -> [Double] -> Either MathError Trajectory Source #
Fourth-order explicit Runge-Kutta-Nystrom method for q''=a(t,q), with acceleration independent of velocity. State output concatenates q and q'.
sensitivities
sensitivities :: Method -> ODEOptions -> Int -> Double -> ([Double] -> ODE) -> [Double] -> Double -> Double -> [Double] -> Either MathError (Matrix Double) Source #
Terminal-state parameter sensitivities by centered perturbation of the complete IVP solve. Parameters use the same explicit finite-difference step.
equilibrium
equilibrium :: ODEOptions -> ([Double] -> [Double]) -> [Double] -> Either MathError [Double] Source #
Find an autonomous equilibrium by a locally convergent Newton solve.
phaseTrajectories
phaseTrajectories :: Method -> ODEOptions -> Int -> ([Double] -> [Double]) -> Double -> Double -> [[Double]] -> Either MathError [Trajectory] Source #
Compute autonomous phase-space trajectories for independently supplied starts.
lyapunovExponents
lyapunovExponents :: ODEOptions -> Int -> Double -> ODE -> Double -> Double -> [Double] -> Either MathError [Double] Source #
Full Lyapunov spectrum by the Benettin tangent-space method: integrate variational equations with RK4, then modified Gram-Schmidt at each sample. Finite-difference Jacobians are used; results are finite-time estimates.