![]() |
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 } |
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) |
| 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) |
| Apply treatment at a node for one pollutant. | |
|
strong |
|
strong |
| double openswmm::treatment::applyTreatment | ( | const TreatExpr & | expr, |
| double | c_in, | ||
| double | dt, | ||
| double | hrt, | ||
| double | q, | ||
| double | v, | ||
| double | d | ||
| ) |
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 | ||
| ) |
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
| expr_str | Full expression string (e.g., "R = 1.0 - exp(-0.5 * HRT)"). |
| result | [out] Parsed expression with is_removal set. |