diff --git a/include/cantera/base/ct_defs.h b/include/cantera/base/ct_defs.h index cfdd2ebf7..39ef19113 100644 --- a/include/cantera/base/ct_defs.h +++ b/include/cantera/base/ct_defs.h @@ -38,6 +38,7 @@ namespace Cantera #endif using std::shared_ptr; +using std::make_shared; /*! * All physical constants are stored here. diff --git a/src/kinetics/Reaction.cpp b/src/kinetics/Reaction.cpp index 9b6e7daf1..783439467 100644 --- a/src/kinetics/Reaction.cpp +++ b/src/kinetics/Reaction.cpp @@ -590,39 +590,39 @@ shared_ptr newReaction(const XML_Node& rxn_node) // Create a new Reaction object of the appropriate type if (type == "elementary" || type == "arrhenius" || type == "") { - shared_ptr R(new ElementaryReaction()); + auto R = make_shared(); setupElementaryReaction(*R, rxn_node); return R; } else if (type == "threebody" || type == "three_body") { - shared_ptr R(new ThreeBodyReaction()); + auto R = make_shared(); setupThreeBodyReaction(*R, rxn_node); return R; } else if (type == "falloff") { - shared_ptr R(new FalloffReaction()); + auto R = make_shared(); setupFalloffReaction(*R, rxn_node); return R; } else if (type == "chemact" || type == "chemically_activated") { - shared_ptr R(new ChemicallyActivatedReaction()); + auto R = make_shared(); setupChemicallyActivatedReaction(*R, rxn_node); return R; } else if (type == "plog" || type == "pdep_arrhenius") { - shared_ptr R(new PlogReaction()); + auto R = make_shared(); setupPlogReaction(*R, rxn_node); return R; } else if (type == "chebyshev") { - shared_ptr R(new ChebyshevReaction()); + auto R = make_shared(); setupChebyshevReaction(*R, rxn_node); return R; } else if (type == "interface" || type == "surface" || type == "edge" || type == "global") { - shared_ptr R(new InterfaceReaction()); + auto R = make_shared(); setupInterfaceReaction(*R, rxn_node); return R; } else if (type == "electrochemical" || type == "butlervolmer_noactivitycoeffs" || type == "butlervolmer" || type == "surfaceaffinity") { - shared_ptr R(new ElectrochemicalReaction()); + auto R = make_shared(); setupElectrochemicalReaction(*R, rxn_node); return R; } else { diff --git a/src/thermo/FixedChemPotSSTP.cpp b/src/thermo/FixedChemPotSSTP.cpp index dd1e092d8..6ba698823 100644 --- a/src/thermo/FixedChemPotSSTP.cpp +++ b/src/thermo/FixedChemPotSSTP.cpp @@ -49,7 +49,7 @@ FixedChemPotSSTP::FixedChemPotSSTP(const std::string& Ename, doublereal val) : setName(pname); setNDim(3); addElement(Ename); - shared_ptr sp(new Species(pname, parseCompString(Ename + ":1.0"))); + auto sp = make_shared(pname, parseCompString(Ename + ":1.0")); double c[4] = {298.15, val, 0.0, 0.0}; shared_ptr stit( newSpeciesThermoInterpType("const_cp", 0.1, 1e30, OneAtm, c)); diff --git a/src/thermo/GeneralSpeciesThermo.cpp b/src/thermo/GeneralSpeciesThermo.cpp index ec54466d0..3aec7ee96 100644 --- a/src/thermo/GeneralSpeciesThermo.cpp +++ b/src/thermo/GeneralSpeciesThermo.cpp @@ -99,7 +99,7 @@ void GeneralSpeciesThermo::install_STIT(size_t index, void GeneralSpeciesThermo::installPDSShandler(size_t k, PDSS* PDSS_ptr, VPSSMgr* vpssmgr_ptr) { - shared_ptr stit_ptr(new STITbyPDSS(vpssmgr_ptr, PDSS_ptr)); + auto stit_ptr = make_shared(vpssmgr_ptr, PDSS_ptr); install_STIT(k, stit_ptr); } diff --git a/src/thermo/Species.cpp b/src/thermo/Species.cpp index bd78517f0..82a9847a3 100644 --- a/src/thermo/Species.cpp +++ b/src/thermo/Species.cpp @@ -61,7 +61,7 @@ shared_ptr newSpecies(const XML_Node& species_node) { std::string name = species_node["name"]; compositionMap comp = parseCompString(species_node.child("atomArray").value()); - shared_ptr s(new Species(name, comp)); + auto s = make_shared(name, comp); if (species_node.hasChild("charge")) { s->charge = getFloat(species_node, "charge"); } diff --git a/src/transport/TransportData.cpp b/src/transport/TransportData.cpp index 79d5d7410..97324196f 100644 --- a/src/transport/TransportData.cpp +++ b/src/transport/TransportData.cpp @@ -129,12 +129,12 @@ shared_ptr newTransportData(const XML_Node& transport_node) { std::string model = transport_node["model"]; if (model == "gas_transport") { - shared_ptr tr(new GasTransportData()); + auto tr = make_shared(); setupGasTransportData(*tr, transport_node); return tr; } else { // Transport model not handled here - return shared_ptr(new TransportData()); + return make_shared(); } } diff --git a/test/kinetics/kineticsFromScratch.cpp b/test/kinetics/kineticsFromScratch.cpp index 18e7d65bb..81a956f72 100644 --- a/test/kinetics/kineticsFromScratch.cpp +++ b/test/kinetics/kineticsFromScratch.cpp @@ -54,7 +54,7 @@ TEST_F(KineticsFromScratch, add_elementary_reaction) Composition reac = parseCompString("O:1 H2:1"); Composition prod = parseCompString("H:1 OH:1"); Arrhenius rate(3.87e1, 2.7, 6260.0 / GasConst_cal_mol_K); - shared_ptr R(new ElementaryReaction(reac, prod, rate)); + auto R = make_shared(reac, prod, rate); kin.addReaction(R); kin.finalize(); @@ -71,7 +71,7 @@ TEST_F(KineticsFromScratch, add_three_body_reaction) Arrhenius rate(1.2e11, -1.0, 0.0); ThirdBody tbody; tbody.efficiencies = parseCompString("AR:0.83 H2:2.4 H2O:15.4"); - shared_ptr R(new ThreeBodyReaction(reac, prod, rate, tbody)); + auto R = make_shared(reac, prod, rate, tbody); kin.addReaction(R); kin.finalize(); @@ -85,7 +85,7 @@ TEST_F(KineticsFromScratch, undefined_third_body) Arrhenius rate(1.2e11, -1.0, 0.0); ThirdBody tbody; tbody.efficiencies = parseCompString("H2:0.1 CO2:0.83"); - shared_ptr R(new ThreeBodyReaction(reac, prod, rate, tbody)); + auto R = make_shared(reac, prod, rate, tbody); ASSERT_THROW(kin.addReaction(R), CanteraError); } @@ -97,7 +97,7 @@ TEST_F(KineticsFromScratch, skip_undefined_third_body) Arrhenius rate(1.2e11, -1.0, 0.0); ThirdBody tbody; tbody.efficiencies = parseCompString("H2:0.1 CO2:0.83"); - shared_ptr R(new ThreeBodyReaction(reac, prod, rate, tbody)); + auto R = make_shared(reac, prod, rate, tbody); kin.skipUndeclaredThirdBodies(true); kin.addReaction(R); @@ -120,8 +120,7 @@ TEST_F(KineticsFromScratch, add_falloff_reaction) 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 R(new FalloffReaction(reac, prod, low_rate, - high_rate, tbody)); + auto R = make_shared(reac, prod, low_rate, high_rate, tbody); R->falloff = newFalloff(TROE_FALLOFF, falloff_params); kin.addReaction(R); kin.finalize(); @@ -145,7 +144,7 @@ TEST_F(KineticsFromScratch, add_plog_reaction) { 100.0*101325, Arrhenius(5.963200e+56, -11.529, 52599.6 / GasConst_cal_mol_K) } }; - shared_ptr R(new PlogReaction(reac, prod, Plog(rates))); + auto R = make_shared(reac, prod, Plog(rates)); kin.addReaction(R); kin.finalize(); check_rates(3); @@ -162,7 +161,7 @@ TEST_F(KineticsFromScratch, plog_invalid_rate) { 100.0*101325, Arrhenius(5.9632e+56, -11.529, 52599.6 / GasConst_cal_mol_K) } }; - shared_ptr R(new PlogReaction(reac, prod, Plog(rates))); + auto R = make_shared(reac, prod, Plog(rates)); ASSERT_THROW(kin.addReaction(R), CanteraError); } @@ -193,7 +192,7 @@ TEST_F(KineticsFromScratch, add_chebyshev_reaction) coeffs(2,3) = -7.6385e-03; ChebyshevRate rate(290, 3000, 1000.0, 10000000.0, coeffs); - shared_ptr R(new ChebyshevReaction(reac, prod, rate)); + auto R = make_shared(reac, prod, rate); kin.addReaction(R); kin.finalize(); check_rates(4); @@ -204,7 +203,7 @@ TEST_F(KineticsFromScratch, undeclared_species) Composition reac = parseCompString("CO:1 OH:1"); Composition prod = parseCompString("CO2:1 H:1"); Arrhenius rate(3.87e1, 2.7, 6260.0 / GasConst_cal_mol_K); - shared_ptr R(new ElementaryReaction(reac, prod, rate)); + auto R = make_shared(reac, prod, rate); ASSERT_THROW(kin.addReaction(R), CanteraError); ASSERT_EQ(0, kin.nReactions()); @@ -215,7 +214,7 @@ TEST_F(KineticsFromScratch, skip_undeclared_species) Composition reac = parseCompString("CO:1 OH:1"); Composition prod = parseCompString("CO2:1 H:1"); Arrhenius rate(3.87e1, 2.7, 6260.0 / GasConst_cal_mol_K); - shared_ptr R(new ElementaryReaction(reac, prod, rate)); + auto R = make_shared(reac, prod, rate); kin.skipUndeclaredSpecies(true); kin.addReaction(R); @@ -227,7 +226,7 @@ TEST_F(KineticsFromScratch, negative_A_error) Composition reac = parseCompString("O:1 H2:1"); Composition prod = parseCompString("H:1 OH:1"); Arrhenius rate(-3.87e1, 2.7, 6260.0 / GasConst_cal_mol_K); - shared_ptr R(new ElementaryReaction(reac, prod, rate)); + auto R = make_shared(reac, prod, rate); ASSERT_THROW(kin.addReaction(R), CanteraError); ASSERT_EQ(0, kin.nReactions()); @@ -238,7 +237,7 @@ TEST_F(KineticsFromScratch, allow_negative_A) Composition reac = parseCompString("O:1 H2:1"); Composition prod = parseCompString("H:1 OH:1"); Arrhenius rate(-3.87e1, 2.7, 6260.0 / GasConst_cal_mol_K); - shared_ptr R(new ElementaryReaction(reac, prod, rate)); + auto R = make_shared(reac, prod, rate); R->allow_negative_pre_exponential_factor = true; kin.addReaction(R); @@ -250,7 +249,7 @@ TEST_F(KineticsFromScratch, invalid_reversible_with_orders) Composition reac = parseCompString("O:1 H2:1"); Composition prod = parseCompString("H:1 OH:1"); Arrhenius rate(3.87e1, 2.7, 6260.0 / GasConst_cal_mol_K); - shared_ptr R(new ElementaryReaction(reac, prod, rate)); + auto R = make_shared(reac, prod, rate); R->orders["H2"] = 0.5; ASSERT_THROW(kin.addReaction(R), CanteraError); @@ -262,7 +261,7 @@ TEST_F(KineticsFromScratch, negative_order_override) Composition reac = parseCompString("O:1 H2:1"); Composition prod = parseCompString("H:1 OH:1"); Arrhenius rate(3.87e1, 2.7, 6260.0 / GasConst_cal_mol_K); - shared_ptr R(new ElementaryReaction(reac, prod, rate)); + auto R = make_shared(reac, prod, rate); R->reversible = false; R->allow_negative_orders = true; R->orders["H2"] = - 0.5; @@ -276,7 +275,7 @@ TEST_F(KineticsFromScratch, invalid_negative_orders) Composition reac = parseCompString("O:1 H2:1"); Composition prod = parseCompString("H:1 OH:1"); Arrhenius rate(3.87e1, 2.7, 6260.0 / GasConst_cal_mol_K); - shared_ptr R(new ElementaryReaction(reac, prod, rate)); + auto R = make_shared(reac, prod, rate); R->reversible = false; R->orders["H2"] = - 0.5; @@ -289,7 +288,7 @@ TEST_F(KineticsFromScratch, nonreactant_order_override) Composition reac = parseCompString("O:1 H2:1"); Composition prod = parseCompString("H:1 OH:1"); Arrhenius rate(3.87e1, 2.7, 6260.0 / GasConst_cal_mol_K); - shared_ptr R(new ElementaryReaction(reac, prod, rate)); + auto R = make_shared(reac, prod, rate); R->reversible = false; R->allow_nonreactant_orders = true; R->orders["OH"] = 0.5; @@ -303,7 +302,7 @@ TEST_F(KineticsFromScratch, invalid_nonreactant_order) Composition reac = parseCompString("O:1 H2:1"); Composition prod = parseCompString("H:1 OH:1"); Arrhenius rate(3.87e1, 2.7, 6260.0 / GasConst_cal_mol_K); - shared_ptr R(new ElementaryReaction(reac, prod, rate)); + auto R = make_shared(reac, prod, rate); R->reversible = false; R->orders["OH"] = 0.5; @@ -368,7 +367,7 @@ TEST_F(InterfaceKineticsFromScratch, add_surface_reaction) Composition prod = parseCompString("OH(m):1 (m):1"); Arrhenius rate(5e21, 0, 100.0e6 / GasConstant); // kJ/mol -> J/kmol - shared_ptrR(new InterfaceReaction(reac, prod, rate)); + auto R = make_shared(reac, prod, rate); kin.addReaction(R); kin.finalize(); check_rates(3); @@ -383,7 +382,7 @@ TEST_F(InterfaceKineticsFromScratch, add_sticking_reaction) Composition prod = parseCompString("H(m):2"); Arrhenius rate(0.1, 0, 0.0); - shared_ptrR(new InterfaceReaction(reac, prod, rate, true)); + auto R = make_shared(reac, prod, rate, true); kin.addReaction(R); kin.finalize(); check_rates(0); diff --git a/test/thermo/thermoParameterizations.cpp b/test/thermo/thermoParameterizations.cpp index 370d525b4..69134c0ed 100644 --- a/test/thermo/thermoParameterizations.cpp +++ b/test/thermo/thermoParameterizations.cpp @@ -32,9 +32,9 @@ TEST_F(SpeciesThermoInterpTypeTest, install_const_cp) { // Compare against instantiation from CTI file IdealGasPhase p2("../data/simplephases.cti", "simple1"); - shared_ptr sO2(new Species("O2", parseCompString("O:2"))); - shared_ptr sH2(new Species("H2", parseCompString("H:2"))); - shared_ptr sH2O(new Species("H2O", parseCompString("H:2 O:1"))); + auto sO2 = make_shared("O2", parseCompString("O:2")); + auto sH2 = make_shared("H2", parseCompString("H:2")); + auto sH2O = make_shared("H2O", parseCompString("H:2 O:1")); sO2->thermo.reset(new ConstCpPoly(200, 5000, 101325, c_o2)); sH2->thermo.reset(new ConstCpPoly(200, 5000, 101325, c_h2)); sH2O->thermo.reset(new ConstCpPoly(200, 5000, 101325, c_h2o)); @@ -54,8 +54,8 @@ TEST_F(SpeciesThermoInterpTypeTest, DISABLED_install_bad_pref) { // Currently broken because GeneralSpeciesThermo does not enforce reference // pressure consistency. - shared_ptr sO2(new Species("O2", parseCompString("O:2"))); - shared_ptr sH2(new Species("H2", parseCompString("H:2"))); + auto sO2 = make_shared("O2", parseCompString("O:2")); + auto sH2 = make_shared("H2", parseCompString("H:2")); sO2->thermo.reset(new ConstCpPoly(200, 5000, 101325, c_o2)); sH2->thermo.reset(new ConstCpPoly(200, 5000, 100000, c_h2)); p.addSpecies(sO2); @@ -67,9 +67,9 @@ TEST_F(SpeciesThermoInterpTypeTest, install_nasa) { // Compare against instantiation from CTI file IdealGasPhase p2("../data/simplephases.cti", "nasa1"); - shared_ptr sO2(new Species("O2", parseCompString("O:2"))); - shared_ptr sH2(new Species("H2", parseCompString("H:2"))); - shared_ptr sH2O(new Species("H2O", parseCompString("H:2 O:1"))); + auto sO2 = make_shared("O2", parseCompString("O:2")); + auto sH2 = make_shared("H2", parseCompString("H:2")); + auto sH2O = make_shared("H2O", parseCompString("H:2 O:1")); sO2->thermo.reset(new NasaPoly2(200, 3500, 101325, o2_nasa_coeffs)); sH2->thermo.reset(new NasaPoly2(200, 3500, 101325, h2_nasa_coeffs)); sH2O->thermo.reset(new NasaPoly2(200, 3500, 101325, h2o_nasa_coeffs)); @@ -89,8 +89,8 @@ TEST_F(SpeciesThermoInterpTypeTest, install_shomate) { // Compare against instantiation from CTI file IdealGasPhase p2("../data/simplephases.cti", "shomate1"); - shared_ptr sCO(new Species("CO", parseCompString("C:1 O:1"))); - shared_ptr sCO2(new Species("CO2", parseCompString("C:1 O:2"))); + auto sCO = make_shared("CO", parseCompString("C:1 O:1")); + auto sCO2 = make_shared("CO2", parseCompString("C:1 O:2")); sCO->thermo.reset(new ShomatePoly2(200, 6000, 101325, co_shomate_coeffs)); sCO2->thermo.reset(new ShomatePoly2(200, 6000, 101325, co2_shomate_coeffs)); p.addSpecies(sCO);