![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Namespaces | |
| namespace | detail |
Typedefs | |
| using | DerivFunc = std::function<void(double x, const double* y, double* dydx)> |
| Synchronous derivative evaluator for an n-equation ODE system. | |
| using | BatchDerivFunc |
| Synchronous derivative evaluator for a batch of two-state systems. | |
Functions | |
| int | integrate (double *y, int n, double x1, double x2, double eps, double h1, const DerivFunc &derivs) |
| Advance an ODE system with adaptive Cash-Karp RK45 steps. | |
| 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. | |
| template<typename F> | |
| int | integrateCallable (double *y, int n, double x1, double x2, double eps, double h1, F &&derivs) |
| Integrate with a concrete synchronous derivative callable. | |
Variables | |
| constexpr int | MAXSTP = 10000 |
| Maximum integration steps. | |
| constexpr double | TINY = 1.0e-30 |
| Underflow protection. | |
| constexpr double | SAFETY = 0.9 |
| Step adjustment safety factor. | |
| constexpr double | PGROW = -0.2 |
| Exponent for step increase. | |
| constexpr double | PSHRNK = -0.25 |
| Exponent for step decrease. | |
| constexpr double | ERRCON = 1.89e-4 |
| = (5/SAFETY)^(1/PGROW) | |
| constexpr int | ODE_OK = 0 |
| Success. | |
| constexpr int | ODE_TOO_MANY = 1 |
| n > allocated max | |
| constexpr int | ODE_UNDERFLOW = 2 |
| Step size underflowed. | |
| constexpr int | ODE_MAX_STEPS = 3 |
| Exceeded MAXSTP. | |
Synchronous derivative evaluator for a batch of two-state systems.
| [in] | x | Independent variable, in caller-selected units. |
| [in] | y0 | Borrowed array of n_sys first-state values. |
| [in] | y1 | Borrowed array of n_sys second-state values. |
| [out] | dy0 | Borrowed array to fill with n_sys first-state derivatives. |
| [out] | dy1 | Borrowed array to fill with n_sys second-state derivatives. |
| [in] | n_sys | Number of independent systems; nonnegative. |
| using openswmm::ode::DerivFunc = std::function<void(double x, const double* y, double* dydx)> |
Synchronous derivative evaluator for an n-equation ODE system.
| [in] | x | Independent variable, commonly elapsed time in seconds. |
| [in] | y | Borrowed, non-null array of n states at x; do not modify or retain. |
| [out] | dydx | Borrowed, non-null array of n derivatives dy_i/dx; write every component before returning and do not retain the pointer. |
| int openswmm::ode::integrate | ( | double * | y, |
| int | n, | ||
| double | x1, | ||
| double | x2, | ||
| double | eps, | ||
| double | h1, | ||
| const DerivFunc & | derivs ) |
Advance an ODE system with adaptive Cash-Karp RK45 steps.
| [in,out] | y | Non-null array of n initial states at x1. Replaced with states at x2 only on ODE_OK; error returns leave the caller's array unchanged. |
| [in] | n | Positive number of equations; controls all callback array lengths. |
| [in] | x1 | Finite start of the integration interval, in caller-selected units. |
| [in] | x2 | Finite end in the same units; forward and reverse intervals are supported when h1 has the corresponding sign. |
| [in] | eps | Positive dimensionless local error tolerance, relative to abs(y_i) + abs(h * dy_i/dx) + TINY at each attempted step. |
| [in] | h1 | Nonzero initial step guess, in x units, directed from x1 to x2. |
| [in] | derivs | Nonempty derivative callback. Called synchronously with borrowed workspace arrays; not retained, and exceptions propagate. |
Workspace is reused per thread and released at thread exit. The solver is not reentrant on the same thread: derivs must not recursively call integrate(). Allocation failures are not translated into an ODE status.
| int openswmm::ode::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.
| [in,out] | y0 | Array of n_sys first-state values; updated by dy0 * (x2 - x1). |
| [in,out] | y1 | Distinct array of n_sys second-state values; updated by dy1 * (x2 - x1). Arrays must be writable when n_sys > 0. |
| [in] | n_sys | Nonnegative number of systems and length of each array. |
| [in] | x1 | Finite start coordinate, also the sole derivative evaluation time. |
| [in] | x2 | Finite end coordinate in the same units as x1. |
| [in] | eps | Unused; this helper performs no tolerance or error control. |
| [in] | h1 | Unused; the only step has length x2 - x1. |
| [in] | derivs | Nonempty callback invoked once for the entire batch. Pointers are borrowed for that call; callback exceptions propagate. |
| int openswmm::ode::integrateCallable | ( | double * | y, |
| int | n, | ||
| double | x1, | ||
| double | x2, | ||
| double | eps, | ||
| double | h1, | ||
| F && | derivs ) |
Integrate with a concrete synchronous derivative callable.
|
constexpr |
= (5/SAFETY)^(1/PGROW)
|
constexpr |
Maximum integration steps.
|
constexpr |
Exceeded MAXSTP.
|
constexpr |
Success.
|
constexpr |
n > allocated max
|
constexpr |
Step size underflowed.
|
constexpr |
Exponent for step increase.
|
constexpr |
Exponent for step decrease.
|
constexpr |
Step adjustment safety factor.
|
constexpr |
Underflow protection.