Ignis
Loading...
Searching...
No Matches
driver_premixed.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
12#include <memory>
13
14using namespace std;
15using namespace soot;
16
22
24
25 //auto csol = Cantera::newSolution("gri30.yaml");
26 auto csol = Cantera::newSolution("../input/c2h4det.yaml");
27 auto gas = csol->thermo();
28
29 //===================== read input file
30
31 YAML::Node inputFile = YAML::LoadFile("../input/input_premixed.yaml");
32
33 //---------------------
34
35 bool isPremixed = inputFile["isPremixed"].as<bool>();
36
37 //---------------------
38
39 size_t ngrd = inputFile["ngrd"].as<size_t>();
40 double L = inputFile["L"].as<double>();
41 double nTauRun = inputFile["nTauRun"].as<double>();
42 size_t nSteps = inputFile["nSteps"].as<size_t>();
43
44 //---------------------
45
46 bool doSoot = inputFile["doSoot"].as<bool>();
47 size_t nsoot = doSoot ? inputFile["nsoot"].as<size_t>() : 0;
48
49 shared_ptr<sootModel> SM;
50 shared_ptr<state> SMstate;
51
52 if(doSoot) {
53
54 nucleationModel *nucl = new soot::nucleationModel_LL();
55 growthModel *grow = new soot::growthModel_LL();
56 oxidationModel *oxid = new soot::oxidationModel_LL();
57 coagulationModel *coag = new soot::coagulationModel_FM();
58
59 SM = make_shared<sootModel_QMOM>(nsoot, nucl, grow, oxid, coag);
60 SM->coag->set_FM_multiplier(9.0/2.2);
61 SMstate = make_shared<state>(nsoot);
62 }
63
64 //---------------------
65
66 double P = inputFile["P"].as<double>();
67 double v = inputFile["v"].as<double>();
68 double TLbc = inputFile["LBC"]["TLbc"].as<double>();
69 vector<double> xLbc(gas->nSpecies());
70 YAML::Node xx = inputFile["LBC"]["comp"];
71 for(auto it=xx.begin(); it!=xx.end(); it++)
72 xLbc[gas->speciesIndex(it->first.as<string>())] = it->second.as<double>();
73
74 bool doEnergyEqn = inputFile["doEnergyEqn"].as<bool>();
75 vector<double> Tprof_h;
76 vector<double> Tprof_T;
77 if(!doEnergyEqn) {
78 for(size_t i=0; i<inputFile["Tprof"].size(); i++) {
79 Tprof_h.push_back(inputFile["Tprof"][i][0].as<double>());
80 Tprof_T.push_back(inputFile["Tprof"][i][1].as<double>());
81 }
82 }
83
84 //--------------------- radiation
85 bool doRadiation = inputFile["doRadiation"].as<bool>();
86 string radType = inputFile["radType"] ? inputFile["radType"].as<string>() : "planckmean";
87
88 //=====================
89
90 bool isFlamelet = false;
91
92 gas->setState_TPX(TLbc, P, &xLbc[0]);
93 vector<double> yLbc(ngrd);
94 gas->getMassFractions(&yLbc[0]);
95 double mflux = gas->density()*v;
96
97 ignis flm(isPremixed, doEnergyEqn, isFlamelet, doSoot,
98 ngrd, L, P, csol, radType,
99 yLbc, yLbc, TLbc, TLbc,
100 SM, SMstate);
101
102 flm.mflux = mflux;
103 if(!doEnergyEqn) flm.setTprof(Tprof_h, Tprof_T);
104
105 flm.setIC("premixed");
106 flm.writeFile("IC.dat");
107
108 //---------------------
109
110 flm.solveUnsteady(nTauRun, nSteps, false);
111 string fname = "premixed.dat";
112 flm.writeFile(fname);
113
114 //---------------------
115
116 return 0;
117}
Definition ignis.h:29
void setTprof(const std::vector< double > &_Tprof_h, const std::vector< double > &_Tprof_T)
Definition ignis.h:130
void writeFile(const std::string fname)
Definition ignis.cc:345
double mflux
premixed flame mass flux (kg/m2*s)
Definition ignis.h:96
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_premixed()