SootLib
Loading...
Searching...
No Matches
state.cc
Go to the documentation of this file.
1#include "state.h"
2
3#include <numeric>
4
5using namespace soot;
6using namespace std;
7
35
36void state::setState(double T_, double P_, double rhoGas_, double muGas_,
37 vector<double> yGas_, vector<double> yPah_, vector<double> sootVar_, int nsoot_, double cMin_) {
38
39 //------------ scalar variable values
40
41 if (T_ <= 0) throw domain_error("Unphysical state value input: T");
42 else T = T_;
43
44 if (P_ <= 0) throw domain_error("Unphysical state value input: P");
45 else P = P_;
46
47 if (rhoGas_ <= 0) throw domain_error("Unphysical state value input: rhoGas");
48 else rhoGas = rhoGas_;
49
50 if (muGas_ <= 0) throw domain_error("Unphysical state value input: muGas");
51 else muGas = muGas_;
52
53 if (cMin_ <= 0) throw domain_error("Unphysical state value input: cMin");
54 else cMin = cMin_;
55
56 //------------ gas mean molecular weight
57
58 MWGas = rhoGas*Rg*T/P;
59
60 //------------ soot moments/bins
61
62 nsoot = nsoot_;
63 for (double s : sootVar_)
64 if (s < 0)
65 throw domain_error("Unphysical state value input: negative soot moment(s)");
66
67 sootVar = sootVar_;
68
69 //------------ gas species mass fractions
70
71 for (double y : yGas_) {
72 if (y < 0) {
73 y = 0;
74 }
75 if (y > 1)
76 throw domain_error("Unphysical state value input: gas species mass fraction > 1.0");
77 }
78
79 double yGas_sum = 0;
80 for(double y : yGas_)
81 yGas_sum += y;
82 if (yGas_sum > 1.0)
83 throw domain_error("Unphysical state value input: sum of gas species mass fractions greater than one");
84
85 yGas = yGas_;
86
87 //------------ PAH mass fractions
88
89 if (yPah_.size() != (yPah.size()))
90 throw domain_error("Invalid input vector size: PAH species mass fractions");
91
92 for (double y : yPah_)
93 if (y < 0 || y > 1)
94 throw domain_error("Unphysical state value input: PAH species mass fraction(s)");
95
96 double yPAH_sum = 0;
97 for(double y :yPah_)
98 yPAH_sum += y;
99 if (yPAH_sum > 1.0)
100 throw domain_error("Unphysical state value input: sum of PAH species mass fractions greater than one");
101
102 yPah = yPah_;
103
104}
105
107
double rhoGas
gas density (kg/m3)
Definition: state.h:25
std::vector< double > yPah
gas PAH species mass fractions
Definition: state.h:29
double T
gas temperature (K)
Definition: state.h:23
void setState(double T_, double P_, double rhoGas_, double muGas_, std::vector< double > yGas_, std::vector< double > yPAH_, std::vector< double > sootVar_, int nsoot_, double cMin_=100)
Definition: state.cc:36
double MWGas
gas mean molecular weight (kg/kmol)
Definition: state.h:26
double P
gas pressure (Pa)
Definition: state.h:24
std::vector< double > sootVar
soot variables (moments or # in sections>
Definition: state.h:32
double muGas
gas viscosity (kg/m*s)
Definition: state.h:27
int nsoot
# of soot variables
Definition: state.h:31
std::vector< double > yGas
gas species mass fractions
Definition: state.h:28
double cMin
soot min num carbon atoms (dynamic for PAH nucleation)
Definition: state.h:36
Definition: sootDefs.h:11
const double Rg
Universal gas constant: J/kmol*K.
Definition: sootDefs.h:17