OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm::findroot Namespace Reference

Typedefs

using NewtonFunc = std::function< void(double x, double *f, double *df)>
 Newton-Raphson with bisection fallback.
 
using RidderFunc = std::function< double(double x)>
 Ridder's method (derivative-free).
 

Functions

int newton (double x1, double x2, double *rts, double xacc, const NewtonFunc &func)
 
double ridder (double x1, double x2, double xacc, const RidderFunc &func)
 

Variables

constexpr int MAXIT = 60
 Maximum iterations.
 

Typedef Documentation

◆ NewtonFunc

using openswmm::findroot::NewtonFunc = typedef std::function<void(double x, double* f, double* df)>

Newton-Raphson with bisection fallback.

Finds x in [x1, x2] such that f(x) = 0. Requires f(x1) and f(x2) to have opposite signs. Uses Newton steps when reliable, falls back to bisection when Newton would exit the bracket or converge slowly.

Parameters
x1Left bracket.
x2Right bracket.
rts[in/out] Initial guess → root.
xaccConvergence tolerance (|dx| < xacc).
funcCallback: func(x, &f, &df) sets f=f(x), df=f'(x).
Returns
Number of function evaluations, or 0 if exceeded MAXIT.

◆ RidderFunc

using openswmm::findroot::RidderFunc = typedef std::function<double(double x)>

Ridder's method (derivative-free).

Parameters
x1Left bracket.
x2Right bracket.
xaccConvergence tolerance.
funcCallback: func(x) returns f(x).
Returns
Root value, or -1.0e10 if failed.

Function Documentation

◆ newton()

int openswmm::findroot::newton ( double  x1,
double  x2,
double *  rts,
double  xacc,
const NewtonFunc func 
)

◆ ridder()

double openswmm::findroot::ridder ( double  x1,
double  x2,
double  xacc,
const RidderFunc func 
)

Variable Documentation

◆ MAXIT

constexpr int openswmm::findroot::MAXIT = 60
constexpr

Maximum iterations.