Ignis
Loading...
Searching...
No Matches
driver_diffusion_table.cc
Go to the documentation of this file.
1#include "ignis.h"
2#include "cantera/base/Solution.h"
3#include "yaml-cpp/yaml.h"
4#include "sootHeaders.h"
5
6#include <iostream>
7#include <sstream>
8#include <string>
9#include <iomanip>
10#include <algorithm>
11
12using namespace std;
13using namespace soot;
14
24
26
27 auto csol = Cantera::newSolution("gri30.yaml");
28 auto gas = csol->thermo();
29
30 //===================== read input file
31
32 YAML::Node inputFile = YAML::LoadFile("../input/input_diffusion_table.yaml");
33
34 //---------------------
35
36 size_t ngrd = inputFile["ngrd"].as<size_t>();
37 double L = inputFile["L"].as<double>();
38 double nTauSS = inputFile["nTauSS"].as<double>();
39 double nTauU = inputFile["nTauU"].as<double>();
40 int nsaveSS = inputFile["nsaveSS"].as<int>();
41 int nsaveU = inputFile["nsaveU"].as<int>();
42
43 vector<double> Ls;
44 for(size_t i=0; i<inputFile["Ls"].size(); i++)
45 Ls.push_back(inputFile["Ls"][i].as<double>());
46
47 //--------------------- gas streams
48
49 double P = inputFile["P"].as<double>();
50
51 double TLbc = inputFile["LBC"]["TLbc"].as<double>();
52 vector<double> yLbc(gas->nSpecies());
53 YAML::Node yy = inputFile["LBC"]["comp"];
54 for(auto it=yy.begin(); it!=yy.end(); it++)
55 yLbc[gas->speciesIndex(it->first.as<string>())] = it->second.as<double>();
56
57 double TRbc = inputFile["RBC"]["TRbc"].as<double>();
58 vector<double> yRbc(gas->nSpecies());
59 yy = inputFile["RBC"]["comp"];
60 for(auto it=yy.begin(); it!=yy.end(); it++)
61 yRbc[gas->speciesIndex(it->first.as<string>())] = it->second.as<double>();
62
63 //--------------------- soot
64
65 bool doSoot = inputFile["doSoot"].as<bool>();
66 size_t nsoot = doSoot ? inputFile["nsoot"].as<size_t>() : 0;
67
68 shared_ptr<sootModel> SM;
69 shared_ptr<state> SMstate;
70
71 if(doSoot) {
72
73 nucleationModel *nucl = new soot::nucleationModel_LL();
74 growthModel *grow = new soot::growthModel_LL();
75 oxidationModel *oxid = new soot::oxidationModel_LL();
76 coagulationModel *coag = new soot::coagulationModel_FM();
77
78 SM = make_shared<sootModel_QMOM>(nsoot, nucl, grow, oxid, coag);
79 SM->coag->set_FM_multiplier(9.0/2.0/2.2);
80 //vector<double> sootScales(nsoot, 1.0);
81 //sootScales[0] = 1e16;
82 //sootScales[1] = 0.01;
83 // need a scaling factor for each soot moment
84 SMstate = make_shared<state>(nsoot);
85 //SMstate->setSootScales(sootScales);
86 }
87
88 //--------------------- radiation
89
90 string radType = inputFile["radType"] ? inputFile["radType"].as<string>() : "planckmean";
91
92 //---------------------
93
94 bool doEnergyEqn = true;
95 bool isPremixed = false;
96 bool isFlamelet = false;
97
98 //=====================
99
100 ignis flm(isPremixed, doEnergyEqn, isFlamelet, doSoot,
101 ngrd, L, P, csol, radType,
102 yLbc, yRbc, TLbc, TRbc,
103 SM, SMstate);
104
105 //flm.doLe1 = true;
106
107 flm.setIC("equilibrium");
108 flm.storeState();
109 flm.writeFile("IC.dat");
110
111 //---------------
112
113 double Tmin, Tmax;
114
115 for(int i=0; i<Ls.size(); i++) {
116 L = Ls[i];
117
118 //----- do SS solution
119
120 Tmax = *max_element(flm.T.begin(), flm.T.end());
121 flm.setGrid(L); cout << "\n\nL = " << flm.L << endl;
122 cout << endl << "do SS"; cout.flush();
123 flm.doRadiation = false;
124 flm.solveUnsteady(nTauSS, nsaveSS, false);
125
126 //----- if blows out, rerun, store as it blows out, else run unsteady with heat loss
127
128 if(*max_element(flm.T.begin(), flm.T.end()) < 1.5*min(TLbc, TRbc)) {
129 cout << endl << "Extinction for L=" << flm.L << endl;
130 Tmin = *max_element(flm.T.begin(), flm.T.end());
131 flm.setIC("stored");
132 stringstream ss; ss << "L_" << L << "S_" << setfill('0') << setw(3) << 0 << ".dat";
133 string fname = ss.str();
134 flm.writeFile(fname);
135 flm.solveUnsteady(nTauU, nsaveU, false, Tmin, Tmax);
136 }
137
138 else {
139 stringstream ss; ss << "L_" << L << "S_" << setfill('0') << setw(3) << 0 << ".dat";
140 string fname = ss.str();
141 flm.writeFile(fname);
142
143 Tmax = *max_element(flm.T.begin(), flm.T.end());
144 flm.storeState();
145
146 //----- do unsteady with radiation to find Tmin
147
148 cout << endl << "do unsteady to get Tmin";
149 flm.doRadiation = true;
150 flm.solveUnsteady(nTauU, 1, false);
151 Tmin = *max_element(flm.T.begin(), flm.T.end());
152 flm.setIC("stored");
153
154 //----- do unsteady with radiation nominally evenly spaced between Tmax and Tmin
155
156 cout << endl << "do unsteady";
157 flm.solveUnsteady(nTauU, nsaveU, false, Tmin, Tmax);
158 flm.setIC("stored");
159 }
160 }
161
162 return 0;
163}
Definition ignis.h:29
void setGrid(double _L)
Definition ignis.cc:202
std::vector< double > T
temperature (K)
Definition ignis.h:41
bool doRadiation
radiation flag
Definition ignis.h:77
double L
domain size (m)
Definition ignis.h:56
void writeFile(const std::string fname)
Definition ignis.cc:345
void storeState()
Definition ignis.cc:469
void setIC(const std::string icType, const std::string fname="")
Definition ignis.cc:485
void solveUnsteady(const double nTauRun, const int nsteps, const bool doWriteTime=true, const double Tmin=0, const double Tmax=0)
Definition ignis.cc:1122
int driver_diffusion_table()