49 double domainLength = 0.01;
50 double tau0 = 0.00005;
53 bool forceTurb =
false;
54 vector<double> ScHips(54, 1);
57 auto cantSol = Cantera::newSolution(
"gri30.yaml");
58 auto gas = cantSol->thermo();
59 size_t nsp = gas->nSpecies();
63 hips HiPS(nLevels, domainLength, tau0, C_param, forceTurb, nVar, ScHips,
true, cantSol, 11);
68 vector<vector<double>> ysp(nsp, vector<double>(nparcels, 0));
69 vector<double> h(nparcels);
70 vector<double> rho(nparcels);
72 vector<double> y0(nsp), y1(nsp);
73 double T0 = 300.0, T1 = 300.0;
76 vector<string> variableNames(nsp + 1);
79 double fracBurn = 0.25;
82 gas->setState_TPX(T0, Cantera::OneAtm,
"C2H4:1, O2:3, N2:11.25");
83 h0 = gas->enthalpy_mass();
84 gas->getMassFractions(y0.data());
87 for (
int i = 0; i < nsp; i++) {
88 for (
int j = 0; j <= (1 - fracBurn) * nparcels; j++) {
91 rho[j] = gas->density();
96 gas->setState_TPX(T1, Cantera::OneAtm,
"C2H4:1, O2:3, N2:11.25");
97 h1 = gas->enthalpy_mass();
98 gas->setState_HP(h1, gas->pressure());
99 gas->equilibrate(
"HP");
100 gas->getMassFractions(y1.data());
103 for (
int i = 0; i < nsp; i++) {
104 for (
int j = ((1 - fracBurn) * nparcels + 1); j < nparcels; j++) {
107 rho[j] = gas->density();
113 variableNames[0] =
"enthalpy";
114 for (
int i = 0; i < ysp.size(); i++) {
115 variableNames[i + 1] = gas->speciesName(i);
118 vector<double> weight(nparcels, 1.0 / nparcels);
121 HiPS.
set_varData(h, weight, variableNames[0], rho);
122 for (
int k = 0; k < ysp.size(); k++)
123 HiPS.
set_varData(ysp[k], weight, variableNames[k + 1], rho);
void writeData(int real, const int ifile, const double outputTime)
Writes simulation data to a file for a specific realization, time, and file index.
void calculateSolution(const double tRun, bool shouldWriteData=false)
Runs the HiPS simulation, advancing the solution using eddy events.
void set_varData(std::vector< double > &v, std::vector< double > &w, const std::string &varN)
Assigns variables, their corresponding weights, and names to the parcels in the HiPS tree.