SootLib
Loading...
Searching...
No Matches
simple_example.cc
Go to the documentation of this file.
1#include <iostream>
2#include <iomanip>
3
4#include "sootHeaders.h"
5
6using namespace std;
7using namespace soot;
8
9int main(int argc, char** argv) {
10
11 //---------- set up and create a soot model
12
17
18 size_t nsoot = 2; // 3; etc.
19
20 sootModel_QMOM SM(nsoot, nucl, grow, oxid, coag);
21 //sootModel_LOGN SM(nsoot, nucl, grow, oxid, coag);
22
23 SM.coag->set_FM_multiplier(9.0/2.0/2.2);
24
25 //---------- set up thermodynamic state variables
26
27 state S = state(nsoot);
28
29 double T = 2100; // temperature in K
30 double P = 101325; // pressure in Pa
31 double rhoGas = 0.1; // gas density in kg/m^3
32 double muGas = 1E-5; // gas viscosity in Pa*s
33
34 vector<double> yGas{3E-4, 0.002, 0.001, 0.05, 0.003, 0.07, 0.1, 0.002}; // gas species mass fractions [H, H2, O, O2, OH, H2O, CO, C2H2]
35 vector<double> yPAH{0, 0, 0, 0, 0, 0}; // PAH species mass fractions [C10H8, C12H8, C12H10, C14H10, C16H10, C18H10]
36 vector<double> Msoot{0.003, 1.5E-5, 1E-7, 1E-10}; // soot moment values [M0, M1, M2, M3]
37
38 S.setState(T, P, rhoGas, muGas, yGas, yPAH, Msoot, nsoot);
39
40 //---------- calculate source terms
41
42 SM.setSourceTerms(S);
43
44 //---------- output results
45
46 cout << setprecision(2) << fixed;
47
48 cout << endl << "T (K) = " << setw(14) << T;
49 cout << endl << "P (Pa) = " << setw(14) << P;
50
51 cout << setprecision(4) << scientific;
52
53 cout << endl << "M0 = " << setw(14) << Msoot[0];
54 cout << endl << "M1 = " << setw(14) << Msoot[1];
55 cout << endl << "M2 = " << setw(14) << Msoot[2];
56 //cout << endl << "M3 = " << setw(14) << Msoot[3];
57 cout << endl;
58
59 cout << endl << "Soot source terms" << endl;
60 cout << endl << "M0 = " << setw(14) << SM.sources.sootSources[0];
61 cout << endl << "M1 = " << setw(14) << SM.sources.sootSources[1];
62 cout << endl << "M2 = " << setw(14) << SM.sources.sootSources[2];
63 //cout << endl << "M3 = " << setw(14) << SM.sources.sootSources[3];
64 cout << endl;
65
66 cout << endl << "Gas source terms" << endl;
67 cout << endl << "xO2 = " << setw(14) << SM.sources.gasSources[(size_t)gasSp::O2];
68 cout << endl << "xO = " << setw(14) << SM.sources.gasSources[(size_t)gasSp::O];
69 cout << endl << "xH2 = " << setw(14) << SM.sources.gasSources[(size_t)gasSp::H2];
70 cout << endl << "xH = " << setw(14) << SM.sources.gasSources[(size_t)gasSp::H];
71 cout << endl << "xOH = " << setw(14) << SM.sources.gasSources[(size_t)gasSp::OH];
72 cout << endl << "xH2O = " << setw(14) << SM.sources.gasSources[(size_t)gasSp::H2O];
73 cout << endl << "xCO = " << setw(14) << SM.sources.gasSources[(size_t)gasSp::CO];
74 cout << endl << "xC2H2 = " << setw(14) << SM.sources.gasSources[(size_t)gasSp::C2H2];
75 cout << endl << "xC6H6 = " << setw(14) << SM.sources.gasSources[(size_t)gasSp::C6H6];
76 cout << endl;
77
78 if (nucl->mechType==nucleationMech::PAH) {
79 cout << endl << "PAH source terms" << endl;
80 cout << endl << "xC10H8 = " << setw(14) << SM.sources.pahSources[(size_t)pahSp::C10H8];
81 cout << endl << "xC12H8 = " << setw(14) << SM.sources.pahSources[(size_t)pahSp::C12H8];
82 cout << endl << "xC12H10 = " << setw(14) << SM.sources.pahSources[(size_t)pahSp::C12H10];
83 cout << endl << "xC14H10 = " << setw(14) << SM.sources.pahSources[(size_t)pahSp::C14H10];
84 cout << endl << "xC16H10 = " << setw(14) << SM.sources.pahSources[(size_t)pahSp::C16H10];
85 cout << endl << "xC18H10 = " << setw(14) << SM.sources.pahSources[(size_t)pahSp::C18H10];
86 cout << endl;
87 }
88
89 //-----------------
90
91 delete(nucl);
92 delete(grow);
93 delete(oxid);
94 delete(coag);
95
96 return 0;
97}
void set_FM_multiplier(double FM_multiplier_)
nucleationMech mechType
identity of the type of nucleation (child)
virtual void setSourceTerms(state &state)
coagulationModel * coag
pointer to coagulation mechanism
Definition: sootModel.h:33
sourceTerms sources
struct containing soot, gas, and pah source terms vectors
Definition: sootModel.h:42
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
Definition: sootDefs.h:11
int main(int argc, char **argv)
std::vector< double > pahSources
kg/m3*s
Definition: sootDefs.h:143
std::vector< double > gasSources
kg/m3*s
Definition: sootDefs.h:142
std::vector< double > sootSources
kg^r/m3*s (moments), or #/m3*s (sections)
Definition: sootDefs.h:141