Remove 'thermo' argument from Species constructor
Since the Species object now stores its SpeciesThermoInterpType contents as a shared_ptr, it is undesirable to have the Species constructor take this as a raw pointer argument.
This commit is contained in:
parent
43952b30fc
commit
882a4986da
7 changed files with 44 additions and 50 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -933,7 +933,7 @@ void Phase::addSpecies(const std::string& name_, const doublereal* comp,
|
|||
cmap[elementName(i)] = comp[i];
|
||||
}
|
||||
}
|
||||
shared_ptr<Species> sp(new Species(name_, cmap, 0, charge_, size_));
|
||||
shared_ptr<Species> sp(new Species(name_, cmap, charge_, size_));
|
||||
Phase::addSpecies(sp);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -620,8 +620,8 @@ bool installSpecies(size_t k, const XML_Node& s, thermo_t& th,
|
|||
VPStandardStateTP* vp_ptr = dynamic_cast<VPStandardStateTP*>(&th);
|
||||
vp_ptr->createInstallPDSS(k, s, phaseNode_ptr);
|
||||
} else {
|
||||
SpeciesThermoInterpType* st = newSpeciesThermoInterpType(s);
|
||||
shared_ptr<Species> sp(new Species(s["name"], comp_map, st, chrg, sz));
|
||||
shared_ptr<Species> 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") &&
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<Species> sO2(new Species("O2", parseCompString("O:2"), stit_o2));
|
||||
shared_ptr<Species> sH2(new Species("H2", parseCompString("H:2"), stit_h2));
|
||||
shared_ptr<Species> sH2O(new Species("H2O", parseCompString("H:2 O:1"), stit_h2o));
|
||||
shared_ptr<Species> sO2(new Species("O2", parseCompString("O:2")));
|
||||
shared_ptr<Species> sH2(new Species("H2", parseCompString("H:2")));
|
||||
shared_ptr<Species> 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<Species> sO2(new Species("O2", parseCompString("O:2"), stit_o2));
|
||||
shared_ptr<Species> sH2(new Species("H2", parseCompString("H:2"), stit_h2));
|
||||
shared_ptr<Species> sO2(new Species("O2", parseCompString("O:2")));
|
||||
shared_ptr<Species> 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<Species> sO2(new Species("O2", parseCompString("O:2"), stit_o2));
|
||||
shared_ptr<Species> sH2(new Species("H2", parseCompString("H:2"), stit_h2));
|
||||
shared_ptr<Species> sH2O(new Species("H2O", parseCompString("H:2 O:1"), stit_h2o));
|
||||
shared_ptr<Species> sO2(new Species("O2", parseCompString("O:2")));
|
||||
shared_ptr<Species> sH2(new Species("H2", parseCompString("H:2")));
|
||||
shared_ptr<Species> 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<Species> sCO(new Species("CO", parseCompString("C:1 O:1"), stit_co));
|
||||
shared_ptr<Species> sCO2(new Species("CO2", parseCompString("C:1 O:2"), stit_co2));
|
||||
shared_ptr<Species> sCO(new Species("CO", parseCompString("C:1 O:1")));
|
||||
shared_ptr<Species> 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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue