Skip to content

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

data Method Source #

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).

Instances

Instances details
Show Method Source # 
Instance details

Defined in HMath.ODE

Eq Method Source # 
Instance details

Defined in HMath.ODE

Methods

(==) :: Method -> Method -> Bool #

(/=) :: Method -> Method -> Bool #

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

Instances details
Show ODEOptions Source # 
Instance details

Defined in HMath.ODE

Eq ODEOptions Source # 
Instance details

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

Instances details
Show Trajectory Source # 
Instance details

Defined in HMath.ODE

Eq Trajectory Source # 
Instance details

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

data Event Source #

A located event time and its dense-interpolated state.

Constructors

Event 

Fields

Instances

Instances details
Show Event Source # 
Instance details

Defined in HMath.ODE

Methods

showsPrec :: Int -> Event -> ShowS #

show :: Event -> String #

showList :: [Event] -> ShowS #

Eq Event Source # 
Instance details

Defined in HMath.ODE

Methods

(==) :: Event -> Event -> Bool #

(/=) :: Event -> Event -> Bool #

EventDirection

data EventDirection Source #

Event direction in increasing physical time, even for backward integration.

Constructors

AnyDirection 
Rising 
Falling 

Instances

Instances details
Show EventDirection Source # 
Instance details

Defined in HMath.ODE

Eq EventDirection Source # 
Instance details

Defined in HMath.ODE

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).

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.