42#ifndef OPENSWMM_ODE_SOLVER_HPP
43#define OPENSWMM_ODE_SOLVER_HPP
56constexpr double TINY = 1.0e-30;
83using DerivFunc = std::function<void(
double x,
const double*
y,
double*
dydx)>;
109int integrate(
double*
y,
int n,
double x1,
double x2,
double eps,
double h1,
119int integrateCallable(
double*
y,
int n,
double x1,
double x2,
double eps,
double h1, F&& derivs);
136using BatchDerivFunc = std::function<void(
double x,
const double* y0,
const double* y1,
double* dy0,
137 double* dy1,
int n_sys)>;
155int integrate_batch_2eq(
double* y0,
double* y1,
int n_sys,
double x1,
double x2,
double eps,
Shared Cash-Karp implementation for typed and erased derivative callbacks.
Definition OdeSolver.cpp:35
constexpr int MAXSTP
Maximum integration steps.
Definition OdeSolver.hpp:55
constexpr double PSHRNK
Exponent for step decrease.
Definition OdeSolver.hpp:59
int integrateCallable(double *y, int n, double x1, double x2, double eps, double h1, F &&derivs)
Integrate with a concrete synchronous derivative callable.
Definition OdeSolverDetail.hpp:223
constexpr double SAFETY
Step adjustment safety factor.
Definition OdeSolver.hpp:57
constexpr double PGROW
Exponent for step increase.
Definition OdeSolver.hpp:58
constexpr int ODE_UNDERFLOW
Step size underflowed.
Definition OdeSolver.hpp:68
constexpr int ODE_OK
Success.
Definition OdeSolver.hpp:66
std::function< void(double x, const double *y, double *dydx)> DerivFunc
Synchronous derivative evaluator for an n-equation ODE system.
Definition OdeSolver.hpp:83
int integrate(double *ystart, int n, double x1, double x2, double eps, double h1, const DerivFunc &derivs)
Advance an ODE system with adaptive Cash-Karp RK45 steps.
Definition OdeSolver.cpp:112
constexpr int ODE_MAX_STEPS
Exceeded MAXSTP.
Definition OdeSolver.hpp:69
constexpr double TINY
Underflow protection.
Definition OdeSolver.hpp:56
int integrate_batch_2eq(double *y0, double *y1, int n_sys, double x1, double x2, double eps, double h1, const BatchDerivFunc &derivs)
Advance independent two-state systems with one explicit Euler step.
Definition OdeSolver.cpp:122
std::function< void(double x, const double *y0, const double *y1, double *dy0, double *dy1, int n_sys)> BatchDerivFunc
Synchronous derivative evaluator for a batch of two-state systems.
Definition OdeSolver.hpp:136
constexpr double ERRCON
= (5/SAFETY)^(1/PGROW)
Definition OdeSolver.hpp:60
constexpr int ODE_TOO_MANY
n > allocated max
Definition OdeSolver.hpp:67
Definition ExchangeLaw.hpp:60
double * dydx
Definition odesolve.c:41
double * y
Definition odesolve.c:37