Make use of initializer lists where appropriate
This commit is contained in:
parent
f9375e1a09
commit
a945ef2c23
18 changed files with 54 additions and 112 deletions
|
|
@ -225,10 +225,7 @@ protected:
|
|||
// Add dummy terminator domains on either side of this one.
|
||||
m_left = new Cantera::Empty1D;
|
||||
m_right = new Cantera::Empty1D;
|
||||
std::vector<Cantera::Domain1D*> domains;
|
||||
domains.push_back(m_left);
|
||||
domains.push_back(this);
|
||||
domains.push_back(m_right);
|
||||
std::vector<Cantera::Domain1D*> domains { m_left, this, m_right };
|
||||
|
||||
// create the Sim1D instance that will control the
|
||||
// solution process
|
||||
|
|
|
|||
|
|
@ -105,15 +105,16 @@ void runexample()
|
|||
double tres;
|
||||
|
||||
std::ofstream f("combustor_cxx.csv");
|
||||
std::vector<size_t> k_out;
|
||||
k_out.push_back(gas.speciesIndex("CH4"));
|
||||
k_out.push_back(gas.speciesIndex("O2"));
|
||||
k_out.push_back(gas.speciesIndex("CO2"));
|
||||
k_out.push_back(gas.speciesIndex("H2O"));
|
||||
k_out.push_back(gas.speciesIndex("CO"));
|
||||
k_out.push_back(gas.speciesIndex("OH"));
|
||||
k_out.push_back(gas.speciesIndex("H"));
|
||||
k_out.push_back(gas.speciesIndex("C2H6"));
|
||||
std::vector<size_t> k_out {
|
||||
gas.speciesIndex("CH4"),
|
||||
gas.speciesIndex("O2"),
|
||||
gas.speciesIndex("CO2"),
|
||||
gas.speciesIndex("H2O"),
|
||||
gas.speciesIndex("CO"),
|
||||
gas.speciesIndex("OH"),
|
||||
gas.speciesIndex("H"),
|
||||
gas.speciesIndex("C2H6")
|
||||
};
|
||||
|
||||
while (tnow < tfinal) {
|
||||
tnow += 0.005;
|
||||
|
|
|
|||
|
|
@ -107,11 +107,7 @@ int flamespeed(double phi)
|
|||
|
||||
//=================== create the container and insert the domains =====
|
||||
|
||||
std::vector<Domain1D*> domains;
|
||||
domains.push_back(&inlet);
|
||||
domains.push_back(&flow);
|
||||
domains.push_back(&outlet);
|
||||
|
||||
std::vector<Domain1D*> domains { &inlet, &flow, &outlet };
|
||||
Sim1D flame(domains);
|
||||
|
||||
//----------- Supply initial guess----------------------
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ XML_Node* Application::get_XML_File(const std::string& file, int debug)
|
|||
}
|
||||
}
|
||||
x->lock();
|
||||
xmlfiles[path] = std::make_pair(x, mtime);
|
||||
xmlfiles[path] = {x, mtime};
|
||||
return x;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -226,12 +226,12 @@ std::pair<size_t, size_t> Kinetics::checkDuplicates(bool throw_err) const
|
|||
"Reaction {}: {}\nReaction {}: {}\n",
|
||||
i+1, other.equation(), m+1, R.equation());
|
||||
} else {
|
||||
return make_pair(i,m);
|
||||
return {i,m};
|
||||
}
|
||||
}
|
||||
participants[key].push_back(i);
|
||||
}
|
||||
return make_pair(npos, npos);
|
||||
return {npos, npos};
|
||||
}
|
||||
|
||||
double Kinetics::checkDuplicateStoich(std::map<int, double>& r1,
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ Plog::Plog(const std::multimap<double, Arrhenius>& rates)
|
|||
double logp = std::log(rate.first);
|
||||
if (pressures_.empty() || pressures_.rbegin()->first != logp) {
|
||||
// starting a new group
|
||||
pressures_[logp] = std::make_pair(j, j+1);
|
||||
pressures_[logp] = {j, j+1};
|
||||
} else {
|
||||
// another rate expression at the same pressure
|
||||
pressures_[logp].second = j+1;
|
||||
|
|
|
|||
|
|
@ -28,10 +28,7 @@ Sim1D::Sim1D(vector<Domain1D*>& domains) :
|
|||
|
||||
// set some defaults
|
||||
m_tstep = 1.0e-5;
|
||||
m_steps.push_back(1);
|
||||
m_steps.push_back(2);
|
||||
m_steps.push_back(5);
|
||||
m_steps.push_back(10);
|
||||
m_steps = { 1, 2, 5, 10 };
|
||||
}
|
||||
|
||||
void Sim1D::setInitialGuess(const std::string& component, vector_fp& locs, vector_fp& vals)
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void GeneralSpeciesThermo::install_STIT(size_t index,
|
|||
"GeneralSpeciesThermo::install_STIT",
|
||||
"Index position isn't null, duplication of assignment: {}", index);
|
||||
int type = stit_ptr->reportType();
|
||||
m_speciesLoc[index] = std::make_pair(type, m_sp[type].size());
|
||||
m_speciesLoc[index] = {type, m_sp[type].size()};
|
||||
m_sp[type].emplace_back(index, stit_ptr);
|
||||
if (m_sp[type].size() == 1) {
|
||||
m_tpoly[type].resize(stit_ptr->temperaturePolySize());
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ void ReactorNet::registerSensitivityReaction(void* reactor,
|
|||
"Sensitivity reactions cannot be added after the"
|
||||
"integrator has been initialized.");
|
||||
}
|
||||
std::pair<void*, int> R = std::make_pair(reactor, leftright);
|
||||
std::pair<void*, int> R = {reactor, leftright};
|
||||
if (m_sensOrder.count(R) &&
|
||||
m_sensOrder[R].count(reactionIndex)) {
|
||||
throw CanteraError("ReactorNet::registerSensitivityReaction",
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@ TEST(parseCompString, extra_spaces)
|
|||
|
||||
TEST(parseCompString, default_values)
|
||||
{
|
||||
std::vector<std::string> x;
|
||||
x.push_back("foo");
|
||||
x.push_back("bar");
|
||||
x.push_back("baz");
|
||||
std::vector<std::string> x = { "foo", "bar", "baz" };
|
||||
compositionMap c = parseCompString("foo:1.0 baz:2", x);
|
||||
ASSERT_EQ((size_t) 3, c.size());
|
||||
ASSERT_FALSE(c.find("bar") == c.end());
|
||||
|
|
@ -48,9 +45,7 @@ TEST(parseCompString, delimiters)
|
|||
|
||||
TEST(parseCompString, missing_element)
|
||||
{
|
||||
std::vector<std::string> x;
|
||||
x.push_back("foo");
|
||||
x.push_back("bar");
|
||||
std::vector<std::string> x = { "foo", "bar" };
|
||||
ASSERT_THROW(parseCompString("foo:1.0 bar:2 baz:1e-4", x),
|
||||
CanteraError);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,11 +117,7 @@ TEST_F(KineticsFromScratch, add_falloff_reaction)
|
|||
Composition prod = parseCompString("H2O2:1");
|
||||
Arrhenius high_rate(7.4e10, -0.37, 0.0);
|
||||
Arrhenius low_rate(2.3e12, -0.9, -1700.0 / GasConst_cal_mol_K);
|
||||
vector_fp falloff_params;
|
||||
falloff_params.push_back(0.7346);
|
||||
falloff_params.push_back(94.0);
|
||||
falloff_params.push_back(1756.0);
|
||||
falloff_params.push_back(5182.0);
|
||||
vector_fp falloff_params { 0.7346, 94.0, 1756.0, 5182.0 };
|
||||
ThirdBody tbody;
|
||||
tbody.efficiencies = parseCompString("AR:0.7 H2:2.0 H2O:6.0");
|
||||
shared_ptr<FalloffReaction> R(new FalloffReaction(reac, prod, low_rate,
|
||||
|
|
@ -142,12 +138,12 @@ TEST_F(KineticsFromScratch, add_plog_reaction)
|
|||
// [(100.0, 'atm'), 5.963200e+56, -11.529, 52599.6])
|
||||
Composition reac = parseCompString("H2:1, O2:1");
|
||||
Composition prod = parseCompString("OH:2");
|
||||
std::multimap<double, Arrhenius> rates;
|
||||
typedef std::multimap<double, Arrhenius>::value_type item;
|
||||
rates.insert(item(0.01*101325, Arrhenius(1.212400e+16, -0.5779, 10872.7 / GasConst_cal_mol_K)));
|
||||
rates.insert(item(1.0*101325, Arrhenius(4.910800e+31, -4.8507, 24772.8 / GasConst_cal_mol_K)));
|
||||
rates.insert(item(10.0*101325, Arrhenius(1.286600e+47, -9.0246, 39796.5 / GasConst_cal_mol_K)));
|
||||
rates.insert(item(100.0*101325, Arrhenius(5.963200e+56, -11.529, 52599.6 / GasConst_cal_mol_K)));
|
||||
std::multimap<double, Arrhenius> rates {
|
||||
{ 0.01*101325, Arrhenius(1.212400e+16, -0.5779, 10872.7 / GasConst_cal_mol_K) },
|
||||
{ 1.0*101325, Arrhenius(4.910800e+31, -4.8507, 24772.8 / GasConst_cal_mol_K) },
|
||||
{ 10.0*101325, Arrhenius(1.286600e+47, -9.0246, 39796.5 / GasConst_cal_mol_K) },
|
||||
{ 100.0*101325, Arrhenius(5.963200e+56, -11.529, 52599.6 / GasConst_cal_mol_K) }
|
||||
};
|
||||
|
||||
shared_ptr<PlogReaction> R(new PlogReaction(reac, prod, Plog(rates)));
|
||||
kin.addReaction(R);
|
||||
|
|
@ -159,12 +155,12 @@ TEST_F(KineticsFromScratch, plog_invalid_rate)
|
|||
{
|
||||
Composition reac = parseCompString("H2:1, O2:1");
|
||||
Composition prod = parseCompString("OH:2");
|
||||
std::multimap<double, Arrhenius> rates;
|
||||
typedef std::multimap<double, Arrhenius>::value_type item;
|
||||
rates.insert(item(0.01*101325, Arrhenius(1.2124e+16, -0.5779, 10872.7 / GasConst_cal_mol_K)));
|
||||
rates.insert(item(10.0*101325, Arrhenius(1e15, -1, 10000 / GasConst_cal_mol_K)));
|
||||
rates.insert(item(10.0*101325, Arrhenius(-2e20, -2.0, 20000 / GasConst_cal_mol_K)));
|
||||
rates.insert(item(100.0*101325, Arrhenius(5.9632e+56, -11.529, 52599.6 / GasConst_cal_mol_K)));
|
||||
std::multimap<double, Arrhenius> rates {
|
||||
{ 0.01*101325, Arrhenius(1.2124e+16, -0.5779, 10872.7 / GasConst_cal_mol_K) },
|
||||
{ 10.0*101325, Arrhenius(1e15, -1, 10000 / GasConst_cal_mol_K) },
|
||||
{ 10.0*101325, Arrhenius(-2e20, -2.0, 20000 / GasConst_cal_mol_K) },
|
||||
{ 100.0*101325, Arrhenius(5.9632e+56, -11.529, 52599.6 / GasConst_cal_mol_K) }
|
||||
};
|
||||
|
||||
shared_ptr<PlogReaction> R(new PlogReaction(reac, prod, Plog(rates)));
|
||||
ASSERT_THROW(kin.addReaction(R), CanteraError);
|
||||
|
|
@ -324,9 +320,7 @@ public:
|
|||
, surf("../data/sofc-test.xml", "metal_surface")
|
||||
, surf_ref("../data/sofc-test.xml", "metal_surface")
|
||||
{
|
||||
std::vector<ThermoPhase*> th;
|
||||
th.push_back(&surf_ref);
|
||||
th.push_back(&gas_ref);
|
||||
std::vector<ThermoPhase*> th = { &surf_ref, &gas_ref };
|
||||
importKinetics(surf_ref.xml(), th, &kin_ref);
|
||||
kin.addPhase(surf);
|
||||
kin.addPhase(gas);
|
||||
|
|
|
|||
|
|
@ -9,14 +9,12 @@ namespace Cantera
|
|||
TEST(FracCoeff, ConvertFracCoeff)
|
||||
{
|
||||
IdealGasPhase thermo1("../data/frac.cti", "gas");
|
||||
std::vector<ThermoPhase*> phases1;
|
||||
phases1.push_back(&thermo1);
|
||||
std::vector<ThermoPhase*> phases1 { &thermo1 };
|
||||
GasKinetics kinetics1;
|
||||
importKinetics(thermo1.xml(), phases1, &kinetics1);
|
||||
|
||||
IdealGasPhase thermo2("../data/frac.xml", "gas");
|
||||
std::vector<ThermoPhase*> phases2;
|
||||
phases2.push_back(&thermo2);
|
||||
std::vector<ThermoPhase*> phases2 { &thermo2 };
|
||||
GasKinetics kinetics2;
|
||||
importKinetics(thermo2.xml(), phases2, &kinetics2);
|
||||
|
||||
|
|
@ -40,8 +38,7 @@ public:
|
|||
FracCoeffTest() :
|
||||
therm("../data/frac.xml", "gas")
|
||||
{
|
||||
std::vector<ThermoPhase*> phases;
|
||||
phases.push_back(&therm);
|
||||
std::vector<ThermoPhase*> phases { &therm };
|
||||
importKinetics(therm.xml(), phases, &kin);
|
||||
therm.setState_TPX(2000, 4*OneAtm,
|
||||
"H2O:0.5, OH:.05, H:0.1, O2:0.15, H2:0.2");
|
||||
|
|
@ -150,8 +147,7 @@ public:
|
|||
NegativePreexponentialFactor() {}
|
||||
void setup(const std::string& infile) {
|
||||
therm.reset(newPhase(infile));
|
||||
std::vector<ThermoPhase*> phases;
|
||||
phases.push_back(therm.get());
|
||||
std::vector<ThermoPhase*> phases { therm.get() };
|
||||
importKinetics(therm->xml(), phases, &kin);
|
||||
therm->setState_TPX(2000, OneAtm,
|
||||
"H2O:1.0, H:0.2, O2:0.3, NH:0.05, NO:0.05, N2O:0.05");
|
||||
|
|
@ -199,9 +195,7 @@ TEST_F(NegativePreexponentialFactor, fromXml)
|
|||
TEST(InterfaceReaction, CoverageDependency) {
|
||||
IdealGasPhase gas("ptcombust.cti", "gas");
|
||||
SurfPhase surf("ptcombust.cti", "Pt_surf");
|
||||
std::vector<ThermoPhase*> phases;
|
||||
phases.push_back(&gas);
|
||||
phases.push_back(&surf);
|
||||
std::vector<ThermoPhase*> phases { &gas, &surf };
|
||||
shared_ptr<Kinetics> kin(newKineticsMgr(surf.xml(), phases));
|
||||
ASSERT_EQ(kin->nReactions(), 25);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,10 +57,7 @@ int main(int argc, char** argv)
|
|||
size_t nsp_d100 = diamond100TP->nSpecies();
|
||||
cout << "Number of species in diamond_100 = " << nsp_d100 << endl;
|
||||
|
||||
vector<ThermoPhase*> phaseList;
|
||||
phaseList.push_back(gasTP);
|
||||
phaseList.push_back(diamondTP);
|
||||
phaseList.push_back(diamond100TP);
|
||||
vector<ThermoPhase*> phaseList { gasTP, diamondTP, diamond100TP };
|
||||
InterfaceKinetics* iKin_ptr = new InterfaceKinetics();
|
||||
importKinetics(*xs, phaseList, iKin_ptr);
|
||||
size_t nr = iKin_ptr->nReactions();
|
||||
|
|
|
|||
|
|
@ -49,10 +49,7 @@ int main(int argc, char** argv)
|
|||
int nsp_d100 = diamond100TP->nSpecies();
|
||||
cout << "Number of species in diamond_100 = " << nsp_d100 << endl;
|
||||
|
||||
vector<ThermoPhase*> phaseList;
|
||||
phaseList.push_back(gasTP);
|
||||
phaseList.push_back(diamondTP);
|
||||
phaseList.push_back(diamond100TP);
|
||||
vector<ThermoPhase*> phaseList { gasTP, diamondTP, diamond100TP };
|
||||
InterfaceKinetics* iKin_ptr = new InterfaceKinetics();
|
||||
importKinetics(*xs, phaseList, iKin_ptr);
|
||||
int nr = iKin_ptr->nReactions();
|
||||
|
|
@ -142,11 +139,8 @@ int main(int argc, char** argv)
|
|||
ThermoPhase* diamondTP_dupl = diamondTP->duplMyselfAsThermoPhase();
|
||||
ThermoPhase* diamond100TP_dupl = diamond100TP->duplMyselfAsThermoPhase();
|
||||
|
||||
|
||||
vector<ThermoPhase*> phaseList_dupl;
|
||||
phaseList_dupl.push_back(gasTP_dupl);
|
||||
phaseList_dupl.push_back(diamondTP_dupl);
|
||||
phaseList_dupl.push_back(diamond100TP_dupl);
|
||||
vector<ThermoPhase*> phaseList_dupl { gasTP_dupl, diamondTP_dupl,
|
||||
diamond100TP_dupl };
|
||||
InterfaceKinetics* iKin_ptr_dupl = new InterfaceKinetics();
|
||||
importKinetics(*xs, phaseList_dupl, iKin_ptr_dupl);
|
||||
int nr_dupl = iKin_ptr_dupl->nReactions();
|
||||
|
|
|
|||
|
|
@ -57,16 +57,10 @@ void testProblem()
|
|||
unique_ptr<ThermoPhase> feo_s(newPhase("solidPhases.xml", "FeO(S)"));
|
||||
unique_ptr<ThermoPhase> fe_s(newPhase("solidPhases.xml", "Fe(S)"));
|
||||
|
||||
vector<ThermoPhase*> phaseList;
|
||||
phaseList.push_back(gasTP.get());
|
||||
phaseList.push_back(cao_s.get());
|
||||
phaseList.push_back(caco3_s.get());
|
||||
phaseList.push_back(c_s.get());
|
||||
phaseList.push_back(fe3o4_s.get());
|
||||
phaseList.push_back(feo_s.get());
|
||||
phaseList.push_back(fe_s.get());
|
||||
phaseList.push_back(surfTP.get());
|
||||
|
||||
vector<ThermoPhase*> phaseList {
|
||||
gasTP.get(), cao_s.get(), caco3_s.get(), c_s.get(), fe3o4_s.get(),
|
||||
feo_s.get(), fe_s.get(), surfTP.get()
|
||||
};
|
||||
InterfaceKinetics iKin;
|
||||
importKinetics(*xg, phaseList, &iKin);
|
||||
|
||||
|
|
|
|||
|
|
@ -244,10 +244,7 @@ int main(int argc, char** argv)
|
|||
cout << "Number of species in surface phase, " << surfParticlePhaseName
|
||||
<< " = " << nsp_d100 << endl;
|
||||
|
||||
vector<ThermoPhase*> phaseList;
|
||||
phaseList.push_back(gasTP);
|
||||
phaseList.push_back(bulkPhaseTP);
|
||||
phaseList.push_back(surfPhaseTP);
|
||||
vector<ThermoPhase*> phaseList { gasTP, bulkPhaseTP, surfPhaseTP };
|
||||
|
||||
InterfaceKinetics* iKin_ptr = new InterfaceKinetics();
|
||||
importKinetics(*xs, phaseList, iKin_ptr);
|
||||
|
|
|
|||
|
|
@ -242,13 +242,7 @@ int main(int argc, char** argv)
|
|||
cout << "Number of species in surface phase, " << surfParticlePhaseName
|
||||
<< " = " << nsp_d100 << endl;
|
||||
|
||||
vector<ThermoPhase*> phaseList;
|
||||
phaseList.push_back(gasTP);
|
||||
phaseList.push_back(bulkPhaseTP);
|
||||
phaseList.push_back(surfPhaseTP);
|
||||
|
||||
|
||||
|
||||
vector<ThermoPhase*> phaseList { gasTP, bulkPhaseTP, surfPhaseTP };
|
||||
InterfaceKinetics* iKin_ptr = new InterfaceKinetics();
|
||||
importKinetics(*xs, phaseList, iKin_ptr);
|
||||
size_t nr = iKin_ptr->nReactions();
|
||||
|
|
@ -265,10 +259,7 @@ int main(int argc, char** argv)
|
|||
cout << "Number of species in 2nd surface phase, " << pname
|
||||
<< " = " << nsp2 << endl;
|
||||
|
||||
vector<ThermoPhase*> phaseList2;
|
||||
phaseList2.push_back(gasTP);
|
||||
phaseList2.push_back(bulkPhaseTP);
|
||||
phaseList2.push_back(surfPhaseTP2);
|
||||
vector<ThermoPhase*> phaseList2 { gasTP, bulkPhaseTP, surfPhaseTP2 };
|
||||
|
||||
// create the second InterfaceKinetics object based on the
|
||||
// second surface phase.
|
||||
|
|
@ -329,9 +320,7 @@ int main(int argc, char** argv)
|
|||
* Set-up the Surface Problem
|
||||
* This problem will consist of 2 identical InterfaceKinetics objects
|
||||
*/
|
||||
vector<InterfaceKinetics*> vecKinPtrs;
|
||||
vecKinPtrs.push_back(iKin_ptr);
|
||||
vecKinPtrs.push_back(iKin2_ptr);
|
||||
vector<InterfaceKinetics*> vecKinPtrs { iKin_ptr, iKin2_ptr };
|
||||
|
||||
// Create the ImplicitSurfChem problem
|
||||
// Initialize it and call the pseudo steadystate capability.
|
||||
|
|
|
|||
|
|
@ -16,12 +16,9 @@ int main()
|
|||
gas.setState_TPX(1200.0, OneAtm,
|
||||
"H2:2, O2:1, OH:0.01, H:0.01, O:0.01");
|
||||
|
||||
vector<ThermoPhase*> phases;
|
||||
phases.push_back(&gas);
|
||||
vector<ThermoPhase*> phases { &gas };
|
||||
Interface surf("surface.xml", "surface", phases);
|
||||
vector_fp cov;
|
||||
cov.push_back(0.8);
|
||||
cov.push_back(0.2);
|
||||
vector_fp cov { 0.8, 0.2 };
|
||||
cout.precision(4);
|
||||
surf.setCoverages(DATA_PTR(cov));
|
||||
vector_fp wdot(gas.nSpecies() + surf.nSpecies());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue