OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
odesolve.h File Reference

Adaptive integration of ordinary differential equations. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int odesolve_open (int n)
 Allocate the legacy solver's shared workspace for n equations.
 
void odesolve_close (void)
 Free every legacy ODE workspace array and reset capacity to zero.
 
int odesolve_integrate (double ystart[], int n, double x1, double x2, double eps, double h1, void(*derivs)(double, double *, double *))
 Integrate an ODE system with adaptive Cash-Karp RK45 steps.
 

Detailed Description

Adaptive integration of ordinary differential equations.

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com (OpenSWMM maintenance and extensions)
License
Apache-2.0 for OpenSWMM contributions; original EPA SWMM provenance is retained.

Function Documentation

◆ odesolve_close()

void odesolve_close ( void )

Free every legacy ODE workspace array and reset capacity to zero.

Note
Safe after partial allocation or a previous close; pointers are reset to NULL. Must not run concurrently with integration or inside its callback.
Here is the caller graph for this function:

◆ odesolve_integrate()

int odesolve_integrate ( double ystart[],
int n,
double x1,
double x2,
double eps,
double h1,
void(* derivs )(double, double *, double *) )

Integrate an ODE system with adaptive Cash-Karp RK45 steps.

Parameters
[in,out]ystartNon-null array of n initial states at x1, replaced with states at x2 on success; unchanged on an error return.
[in]nPositive equation count, no larger than allocated nmax.
[in]x1Finite start coordinate in caller-selected units.
[in]x2Finite end coordinate in the same units.
[in]epsPositive dimensionless tolerance relative to each state scale abs(y) + abs(h * dydx) + TINY.
[in]h1Nonzero initial step, in x units, directed from x1 toward x2.
[in]derivsNon-null synchronous callback filling n dy/dx values from n states; borrowed arrays must not be modified or retained except for writing the derivative output.
Returns
Zero on success, one when n exceeds nmax, two for a zero next step, or three for exhausted iterations or underflow during rejection.
Precondition
odesolve_open() succeeded. The callback must not recursively integrate because accepted states and intermediate buffers are shared globals.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ odesolve_open()

int odesolve_open ( int n)

Allocate the legacy solver's shared workspace for n equations.

Parameters
[in]nPositive equation capacity; n * 5 must be representable as int.
Returns
One after all allocations succeed, zero when an allocation returns NULL.
Postcondition
Sets nmax only after success; partial allocations remain for odesolve_close(). Arrays are zero-initialized and shared across all calls.
Precondition
Any earlier workspace has been closed. Calling open twice without close overwrites owned pointers. The legacy solver is not thread-safe.
Here is the caller graph for this function: