26#ifndef OPENSWMM_ODE_SOLVER_HPP
27#define OPENSWMM_ODE_SOLVER_HPP
40constexpr double TINY = 1.0e-30;
66using DerivFunc = std::function<void(
double x,
const double*
y,
double*
dydx)>;
84int integrate(
double*
y,
int n,
double x1,
double x2,
85 double eps,
double h1,
const DerivFunc& derivs);
111 const double* y0,
const double* y1,
112 double* dy0,
double* dy1,
int n_sys)>;
115 double x1,
double x2,
double eps,
double h1,
constexpr int MAXSTP
Maximum integration steps.
Definition OdeSolver.hpp:39
constexpr double PSHRNK
Exponent for step decrease.
Definition OdeSolver.hpp:43
constexpr double SAFETY
Step adjustment safety factor.
Definition OdeSolver.hpp:41
std::function< void(double x, const double *y, double *dydx)> DerivFunc
Derivative function signature.
Definition OdeSolver.hpp:66
constexpr double PGROW
Exponent for step increase.
Definition OdeSolver.hpp:42
std::function< void(double x, const double *y0, const double *y1, double *dy0, double *dy1, int n_sys)> BatchDerivFunc
Integrate N independent 2-equation ODE systems in batch.
Definition OdeSolver.hpp:112
constexpr int ODE_UNDERFLOW
Step size underflowed.
Definition OdeSolver.hpp:52
constexpr int ODE_OK
Success.
Definition OdeSolver.hpp:50
int integrate(double *y, int n, double x1, double x2, double eps, double h1, const DerivFunc &derivs)
Integrate an ODE system from x1 to x2 using RK45 Cash-Karp.
Definition OdeSolver.cpp:114
constexpr int ODE_MAX_STEPS
Exceeded MAXSTP.
Definition OdeSolver.hpp:53
constexpr double TINY
Underflow protection.
Definition OdeSolver.hpp:40
int integrate_batch_2eq(double *y0, double *y1, int n_sys, double x1, double x2, double eps, double h1, const BatchDerivFunc &derivs)
Definition OdeSolver.cpp:146
constexpr double ERRCON
= (5/SAFETY)^(1/PGROW)
Definition OdeSolver.hpp:44
constexpr int ODE_TOO_MANY
n > allocated max
Definition OdeSolver.hpp:51
Definition Controls.cpp:24
double * dydx
Definition odesolve.c:32
double * y
Definition odesolve.c:28