![]() |
OpenSWMM Engine
6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
|
Classes | |
| struct | Token |
| struct | TreatExpr |
Enumerations | |
| enum class | TokenType : int { NUMBER = 0 , VARIABLE = 1 , ADD = 2 , SUB = 3 , MUL = 4 , DIV = 5 , POW = 6 , NEG = 7 , FUNC_EXP = 8 , FUNC_LOG = 9 , FUNC_SQRT = 10 , FUNC_MIN = 11 , FUNC_MAX = 12 , FUNC_ABS = 13 , FUNC_SGN = 14 , FUNC_STEP = 15 , LPAREN = 16 , RPAREN = 17 , COMMA = 18 } |
| enum class | TreatVar : int { C = 0 , R = 1 , DT = 2 , HRT = 3 , Q = 4 , V = 5 , D = 6 , C_POLLUT = 7 , R_POLLUT = 8 , AREA = 9 } |
Functions | |
| int | parse (const std::string &expr_str, TreatExpr &result) |
| Parse a treatment expression string into postfix tokens. | |
| double | evaluate (const TreatExpr &expr, double c, double dt, double hrt, double q, double v, double d, double area=0.0) |
| Evaluate a treatment expression with given variable values. | |
| double | applyTreatment (const TreatExpr &expr, double c_in, double dt, double hrt, double q, double v, double d, double area=0.0) |
| Apply treatment at a node for one pollutant. | |
| int | parse (const std::string &expr_str, TreatExpr &result, int(*pollut_lookup)(const std::string &name)) |
| Parse with pollutant name resolution for co-treatment. | |
| double | evaluate (const TreatExpr &expr, double c, double dt, double hrt, double q, double v, double d, const double *cin, const double *removal, int n_pollut, double area=0.0) |
| Evaluate with co-treatment support (R_pollutant references). | |
|
strong |
|
strong |
| double openswmm::treatment::applyTreatment | ( | const TreatExpr & | expr, |
| double | c_in, | ||
| double | dt, | ||
| double | hrt, | ||
| double | q, | ||
| double | v, | ||
| double | d, | ||
| double | area = 0.0 |
||
| ) |
Apply treatment at a node for one pollutant.
For a removal equation (R=): the expression result is clamped to [0,1] and the output concentration is c_in * (1 - R). For a concentration equation (C=): the expression result is clamped to [0, c_in] and the output concentration is the expression result. This matches the legacy treatmnt.c behavior.
| expr | Treatment expression. |
| c_in | Inflow/current concentration (Cin for R=, node conc for C=). |
| dt | Timestep (sec). |
| hrt | Hydraulic residence time (hours). |
| q | Flow. |
| v | Volume. |
| d | Depth. |
| double openswmm::treatment::evaluate | ( | const TreatExpr & | expr, |
| double | c, | ||
| double | dt, | ||
| double | hrt, | ||
| double | q, | ||
| double | v, | ||
| double | d, | ||
| const double * | cin, | ||
| const double * | removal, | ||
| int | n_pollut, | ||
| double | area = 0.0 |
||
| ) |
Evaluate with co-treatment support (R_pollutant references).
| expr | Parsed expression. |
| c | Concentration for this pollutant. |
| dt | Timestep (sec). |
| hrt | HRT (hours). |
| q | Flow rate in user units. |
| v | Volume. |
| d | Depth in user units. |
| cin | Inflow concentrations for all pollutants. |
| removal | Removal fractions for all pollutants (-1=not computed). |
| n_pollut | Number of pollutants. |
| area | Node surface area in user units² (Gap #16, legacy pvAREA). |
| double openswmm::treatment::evaluate | ( | const TreatExpr & | expr, |
| double | c, | ||
| double | dt, | ||
| double | hrt, | ||
| double | q, | ||
| double | v, | ||
| double | d, | ||
| double | area = 0.0 |
||
| ) |
Evaluate a treatment expression with given variable values.
| expr | Parsed expression. |
| c | Current concentration. |
| dt | Timestep (sec). |
| hrt | Hydraulic residence time (hours). |
| q | Flow rate. |
| v | Volume. |
| d | Depth. |
| int openswmm::treatment::parse | ( | const std::string & | expr_str, |
| TreatExpr & | result | ||
| ) |
Parse a treatment expression string into postfix tokens.
The expression string should be of the form "C = ..." or "R = ...". The parser determines whether this is a concentration or removal equation from the left-hand side, then parses the right-hand side (after the '=') into a postfix token sequence using the Shunting-yard algorithm.
Supported operators: + - * / ^ (standard precedence) Supported functions: exp, log, sqrt, min, max, abs, sgn, step Supported variables: C, R, DT, HRT, Q, V, D, AREA
| expr_str | Full expression string (e.g., "R = 1.0 - exp(-0.5 * HRT)"). |
| result | [out] Parsed expression with is_removal set. |
| int openswmm::treatment::parse | ( | const std::string & | expr_str, |
| TreatExpr & | result, | ||
| int(*)(const std::string &name) | pollut_lookup | ||
| ) |
Parse with pollutant name resolution for co-treatment.
| expr_str | Full expression string. |
| result | [out] Parsed expression. |
| pollut_names | Pollutant name → index resolver. Returns -1 if not found. |