[Thermo] Allow instantiation of WaterSSTP without XML

This commit is contained in:
Ray Speth 2017-02-03 23:46:03 -05:00
parent 86dca05369
commit 507a3a9985
3 changed files with 16 additions and 4 deletions

View file

@ -226,7 +226,7 @@ public:
*/
virtual void setDensity(const doublereal dens);
virtual void initThermoXML(XML_Node& phaseNode, const std::string& id);
virtual void initThermo();
virtual void setParametersFromXML(const XML_Node& eosdata);
//! Get a pointer to a changeable WaterPropsIAPWS object

View file

@ -78,10 +78,9 @@ ThermoPhase* WaterSSTP::duplMyselfAsThermoPhase() const
return new WaterSSTP(*this);
}
void WaterSSTP::initThermoXML(XML_Node& phaseNode, const std::string& id)
void WaterSSTP::initThermo()
{
// Do initializations that don't depend on knowing the XML file
initThermo();
SingleSpeciesTP::initThermo();
// Calculate the molecular weight. Note while there may be a very good
// calculated weight in the steam table class, using this weight may lead to

View file

@ -2,6 +2,7 @@
#include "cantera/thermo/ThermoFactory.h"
#include "cantera/thermo/FixedChemPotSSTP.h"
#include "cantera/thermo/PureFluidPhase.h"
#include "cantera/thermo/WaterSSTP.h"
#include "cantera/thermo/NasaPoly2.h"
#include "cantera/thermo/ShomatePoly.h"
#include "cantera/thermo/IdealGasPhase.h"
@ -199,4 +200,16 @@ TEST(PureFluidFromScratch, CarbonDioxide)
EXPECT_NEAR(p.pressure(), 4160236.987, 1e-2);
}
TEST(WaterSSTP, fromScratch)
{
WaterSSTP water;
auto sH2O = make_shared<Species>("H2O", parseCompString("H:2 O:1"));
sH2O->thermo.reset(new NasaPoly2(200, 3500, 101325, h2o_nasa_coeffs)); // unused
water.addUndefinedElements();
water.addSpecies(sH2O);
water.initThermo();
water.setState_TP(298.15, 1e5);
EXPECT_NEAR(water.enthalpy_mole() / 1e6, -285.83, 2e-2);
}
} // namespace Cantera