OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
Treatment.hpp File Reference

Treatment expression evaluator for water quality. More...

#include <string>
#include <vector>
Include dependency graph for Treatment.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  openswmm::treatment::Token
 
struct  openswmm::treatment::TreatExpr
 

Namespaces

namespace  openswmm
 
namespace  openswmm::treatment
 

Enumerations

enum class  openswmm::treatment::TokenType : int {
  openswmm::treatment::NUMBER = 0 ,
  openswmm::treatment::VARIABLE = 1 ,
  openswmm::treatment::ADD = 2 ,
  openswmm::treatment::SUB = 3 ,
  openswmm::treatment::MUL = 4 ,
  openswmm::treatment::DIV = 5 ,
  openswmm::treatment::POW = 6 ,
  openswmm::treatment::NEG = 7 ,
  openswmm::treatment::FUNC_EXP = 8 ,
  openswmm::treatment::FUNC_LOG = 9 ,
  openswmm::treatment::FUNC_SQRT = 10 ,
  openswmm::treatment::FUNC_MIN = 11 ,
  openswmm::treatment::FUNC_MAX = 12 ,
  openswmm::treatment::FUNC_ABS = 13 ,
  openswmm::treatment::FUNC_SGN = 14 ,
  openswmm::treatment::FUNC_STEP = 15 ,
  openswmm::treatment::LPAREN = 16 ,
  openswmm::treatment::RPAREN = 17 ,
  openswmm::treatment::COMMA = 18
}
 
enum class  openswmm::treatment::TreatVar : int {
  openswmm::treatment::C = 0 ,
  openswmm::treatment::R = 1 ,
  openswmm::treatment::DT = 2 ,
  openswmm::treatment::HRT = 3 ,
  openswmm::treatment::Q = 4 ,
  openswmm::treatment::V = 5 ,
  openswmm::treatment::D = 6
}
 

Functions

int openswmm::treatment::parse (const std::string &expr_str, TreatExpr &result)
 Parse a treatment expression string into postfix tokens.
 
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.
 
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.
 

Detailed Description

Treatment expression evaluator for water quality.

Evaluates user-defined treatment expressions at nodes to modify pollutant concentrations. Expressions can reference:

  • C (current concentration)
  • R (removal fraction)
  • DT (timestep in seconds)
  • HRT (hydraulic residence time in hours)
  • Q (flow rate)
  • V (volume)
  • D (depth)

Treatment expression strings have the form: "R = <expression>" — removal equation "C = <expression>" — concentration equation

Expressions are parsed at input time into a postfix token list using the Shunting-yard algorithm. Evaluation is a simple stack machine — vectorisable across nodes when all nodes use the same expression (batch eval with different variable values).

Note
Legacy reference: src/legacy/engine/treatmnt.c, mathexpr.c
Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License\n MIT License