diff --git a/include/cantera/thermo/Species.h b/include/cantera/thermo/Species.h index 5c5fb08c8..1f79cc9bb 100644 --- a/include/cantera/thermo/Species.h +++ b/include/cantera/thermo/Species.h @@ -23,13 +23,8 @@ public: Species(); //! Constructor - /*! - * The Species object takes ownership of the SpeciesThermoInterpType - * object, if provided. - */ Species(const std::string& name, const compositionMap& comp, - SpeciesThermoInterpType* thermo=0, double charge=0.0, - double size=0.0); + double charge=0.0, double size=0.0); Species(const Species& other); Species& operator=(const Species& other); diff --git a/src/thermo/Phase.cpp b/src/thermo/Phase.cpp index 390306a4e..7379d5974 100644 --- a/src/thermo/Phase.cpp +++ b/src/thermo/Phase.cpp @@ -933,7 +933,7 @@ void Phase::addSpecies(const std::string& name_, const doublereal* comp, cmap[elementName(i)] = comp[i]; } } - shared_ptr sp(new Species(name_, cmap, 0, charge_, size_)); + shared_ptr sp(new Species(name_, cmap, charge_, size_)); Phase::addSpecies(sp); } diff --git a/src/thermo/Species.cpp b/src/thermo/Species.cpp index df1b38ae4..e01eb61f6 100644 --- a/src/thermo/Species.cpp +++ b/src/thermo/Species.cpp @@ -15,12 +15,11 @@ Species::Species() } Species::Species(const std::string& name_, const compositionMap& comp_, - SpeciesThermoInterpType* therm, double charge_, double size_) + double charge_, double size_) : name(name_) , composition(comp_) , charge(charge_) , size(size_) - , thermo(therm) { } diff --git a/src/thermo/ThermoFactory.cpp b/src/thermo/ThermoFactory.cpp index 4af76eda7..850b2c1c7 100644 --- a/src/thermo/ThermoFactory.cpp +++ b/src/thermo/ThermoFactory.cpp @@ -620,8 +620,8 @@ bool installSpecies(size_t k, const XML_Node& s, thermo_t& th, VPStandardStateTP* vp_ptr = dynamic_cast(&th); vp_ptr->createInstallPDSS(k, s, phaseNode_ptr); } else { - SpeciesThermoInterpType* st = newSpeciesThermoInterpType(s); - shared_ptr sp(new Species(s["name"], comp_map, st, chrg, sz)); + shared_ptr sp(new Species(s["name"], comp_map, chrg, sz)); + sp->thermo.reset(newSpeciesThermoInterpType(s)); // Read gas-phase transport data, if provided if (s.hasChild("transport") && diff --git a/test/thermo/phaseConstructors.cpp b/test/thermo/phaseConstructors.cpp index 86bac4be4..7279a47ad 100644 --- a/test/thermo/phaseConstructors.cpp +++ b/test/thermo/phaseConstructors.cpp @@ -105,19 +105,19 @@ class ConstructFromScratch : public testing::Test { public: ConstructFromScratch() - : sH2O(new Species("H2O", parseCompString("H:2 O:1"), - new NasaPoly2(200, 3500, 101325, h2o_nasa_coeffs))) - , sH2(new Species("H2", parseCompString("H:2"), - new NasaPoly2(200, 3500, 101325, h2_nasa_coeffs))) - , sO2(new Species("O2", parseCompString("O:2"), - new NasaPoly2(200, 3500, 101325, o2_nasa_coeffs))) - , sOH(new Species("OH", parseCompString("H:1 O:1"), - new NasaPoly2(200, 3500, 101325, oh_nasa_coeffs))) - , sCO(new Species("CO", parseCompString("C:1 O:1"), - new NasaPoly2(200, 3500, 101325, o2_nasa_coeffs))) - , sCO2(new Species("CO2", parseCompString("C:1 O:2"), - new NasaPoly2(200, 3500, 101325, h2o_nasa_coeffs))) + : sH2O(new Species("H2O", parseCompString("H:2 O:1"))) + , sH2(new Species("H2", parseCompString("H:2"))) + , sO2(new Species("O2", parseCompString("O:2"))) + , sOH(new Species("OH", parseCompString("H:1 O:1"))) + , sCO(new Species("CO", parseCompString("C:1 O:1"))) + , sCO2(new Species("CO2", parseCompString("C:1 O:2"))) { + sH2O->thermo.reset(new NasaPoly2(200, 3500, 101325, h2o_nasa_coeffs)); + sH2->thermo.reset(new NasaPoly2(200, 3500, 101325, h2_nasa_coeffs)); + sO2->thermo.reset(new NasaPoly2(200, 3500, 101325, o2_nasa_coeffs)); + sOH->thermo.reset(new NasaPoly2(200, 3500, 101325, oh_nasa_coeffs)); + sCO->thermo.reset(new NasaPoly2(200, 3500, 101325, o2_nasa_coeffs)); + sCO2->thermo.reset(new NasaPoly2(200, 3500, 101325, h2o_nasa_coeffs)); } IdealGasPhase p; diff --git a/test/thermo/thermoParameterizations.cpp b/test/thermo/thermoParameterizations.cpp index 3b20877cd..809b0d70b 100644 --- a/test/thermo/thermoParameterizations.cpp +++ b/test/thermo/thermoParameterizations.cpp @@ -32,12 +32,12 @@ TEST_F(SpeciesThermoInterpTypeTest, install_const_cp) { // Compare against instantiation from CTI file IdealGasPhase p2("../data/simplephases.cti", "simple1"); - SpeciesThermoInterpType* stit_o2 = new ConstCpPoly(200, 5000, 101325, c_o2); - SpeciesThermoInterpType* stit_h2 = new ConstCpPoly(200, 5000, 101325, c_h2); - SpeciesThermoInterpType* stit_h2o = new ConstCpPoly(200, 5000, 101325, c_h2o); - shared_ptr sO2(new Species("O2", parseCompString("O:2"), stit_o2)); - shared_ptr sH2(new Species("H2", parseCompString("H:2"), stit_h2)); - shared_ptr sH2O(new Species("H2O", parseCompString("H:2 O:1"), stit_h2o)); + 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"))); + 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)); p.addSpecies(sO2); p.addSpecies(sH2); p.addSpecies(sH2O); @@ -54,26 +54,25 @@ TEST_F(SpeciesThermoInterpTypeTest, DISABLED_install_bad_pref) { // Currently broken because GeneralSpeciesThermo does not enforce reference // pressure consistency. - SpeciesThermoInterpType* stit_o2 = new ConstCpPoly(200, 5000, 101325, c_o2); - SpeciesThermoInterpType* stit_h2 = new ConstCpPoly(200, 5000, 100000, c_h2); - shared_ptr sO2(new Species("O2", parseCompString("O:2"), stit_o2)); - shared_ptr sH2(new Species("H2", parseCompString("H:2"), stit_h2)); + shared_ptr sO2(new Species("O2", parseCompString("O:2"))); + shared_ptr sH2(new Species("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); // Pref does not match ASSERT_THROW(p.addSpecies(sH2), CanteraError); - delete stit_h2; } TEST_F(SpeciesThermoInterpTypeTest, install_nasa) { // Compare against instantiation from CTI file IdealGasPhase p2("../data/simplephases.cti", "nasa1"); - SpeciesThermoInterpType* stit_o2 = new NasaPoly2(200, 3500, 101325, o2_nasa_coeffs); - SpeciesThermoInterpType* stit_h2 = new NasaPoly2(200, 3500, 101325, h2_nasa_coeffs); - SpeciesThermoInterpType* stit_h2o = new NasaPoly2(200, 3500, 101325, h2o_nasa_coeffs); - shared_ptr sO2(new Species("O2", parseCompString("O:2"), stit_o2)); - shared_ptr sH2(new Species("H2", parseCompString("H:2"), stit_h2)); - shared_ptr sH2O(new Species("H2O", parseCompString("H:2 O:1"), stit_h2o)); + 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"))); + 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)); p.addSpecies(sO2); p.addSpecies(sH2); p.addSpecies(sH2O); @@ -90,10 +89,10 @@ TEST_F(SpeciesThermoInterpTypeTest, install_shomate) { // Compare against instantiation from CTI file IdealGasPhase p2("../data/simplephases.cti", "shomate1"); - SpeciesThermoInterpType* stit_co = new ShomatePoly2(200, 6000, 101325, co_shomate_coeffs); - SpeciesThermoInterpType* stit_co2 = new ShomatePoly2(200, 6000, 101325, co2_shomate_coeffs); - shared_ptr sCO(new Species("CO", parseCompString("C:1 O:1"), stit_co)); - shared_ptr sCO2(new Species("CO2", parseCompString("C:1 O:2"), stit_co2)); + shared_ptr sCO(new Species("CO", parseCompString("C:1 O:1"))); + shared_ptr sCO2(new Species("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); p.addSpecies(sCO2); p.initThermo(); diff --git a/test/transport/transportFromScratch.cpp b/test/transport/transportFromScratch.cpp index ac01d74d1..f1d3aa3c7 100644 --- a/test/transport/transportFromScratch.cpp +++ b/test/transport/transportFromScratch.cpp @@ -18,16 +18,17 @@ class TransportFromScratch : public testing::Test { public: TransportFromScratch() - : sH2(new Species("H2", parseCompString("H:2"), - new NasaPoly2(200, 3500, 101325, h2_nasa_coeffs))) - , sO2(new Species("O2", parseCompString("O:2"), - new NasaPoly2(200, 3500, 101325, o2_nasa_coeffs))) - , sH2O(new Species("H2O", parseCompString("H:2 O:1"), - new NasaPoly2(200, 3500, 101325, h2o_nasa_coeffs))) + : sH2(new Species("H2", parseCompString("H:2"))) + , sO2(new Species("O2", parseCompString("O:2"))) + , sH2O(new Species("H2O", parseCompString("H:2 O:1"))) , tH2(new GasTransportData()) , tO2(new GasTransportData()) , tH2O(new GasTransportData()) { + sH2->thermo.reset(new NasaPoly2(200, 3500, 101325, h2_nasa_coeffs)); + sO2->thermo.reset(new NasaPoly2(200, 3500, 101325, o2_nasa_coeffs)); + sH2O->thermo.reset(new NasaPoly2(200, 3500, 101325, h2o_nasa_coeffs)); + tH2->setCustomaryUnits("H2", "linear", 2.92, 38.0, 0.0, 0.79, 280.0); tO2->setCustomaryUnits("O2", "linear", 3.46, 107.40, 0.0, 1.60, 3.80); tH2O->setCustomaryUnits("H2O", "nonlinear", 2.60, 572.4, 1.84, 0.0, 4.00);