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

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.
 

Enumeration Type Documentation

◆ TokenType

enum class openswmm::treatment::TokenType : int
strong
Enumerator
NUMBER 
VARIABLE 
ADD 
SUB 
MUL 
DIV 
POW 
NEG 

Unary negation.

FUNC_EXP 
FUNC_LOG 
FUNC_SQRT 
FUNC_MIN 
FUNC_MAX 
FUNC_ABS 
FUNC_SGN 
FUNC_STEP 

Heaviside step.

LPAREN 

Left parenthesis (parser internal, never in output)

RPAREN 

Right parenthesis (parser internal, never in output)

COMMA 

Comma separator for min/max (parser internal)

◆ TreatVar

enum class openswmm::treatment::TreatVar : int
strong
Enumerator

Current concentration.

Removal fraction target.

DT 

Timestep (sec)

HRT 

Hydraulic residence time (hours, per legacy convention)

Flow rate.

Volume.

Depth.

Function Documentation

◆ applyTreatment()

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.

Parameters
exprTreatment expression.
c_inInflow/current concentration (Cin for R=, node conc for C=).
dtTimestep (sec).
hrtHydraulic residence time (hours).
qFlow.
vVolume.
dDepth.
Returns
Treated concentration.
Here is the call graph for this function:

◆ evaluate()

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.

Parameters
exprParsed expression.
cCurrent concentration.
dtTimestep (sec).
hrtHydraulic residence time (hours).
qFlow rate.
vVolume.
dDepth.
Returns
Computed value (concentration or removal fraction).
Here is the caller graph for this function:

◆ parse()

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

Parameters
expr_strFull expression string (e.g., "R = 1.0 - exp(-0.5 * HRT)").
result[out] Parsed expression with is_removal set.
Returns
0 on success, -1 on parse error.