From 507a3a9985f2b0237f8d13442d6ac93f37a781d1 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 3 Feb 2017 23:46:03 -0500 Subject: [PATCH] [Thermo] Allow instantiation of WaterSSTP without XML --- include/cantera/thermo/WaterSSTP.h | 2 +- src/thermo/WaterSSTP.cpp | 5 ++--- test/thermo/phaseConstructors.cpp | 13 +++++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/cantera/thermo/WaterSSTP.h b/include/cantera/thermo/WaterSSTP.h index d70391da2..405f1cb9d 100644 --- a/include/cantera/thermo/WaterSSTP.h +++ b/include/cantera/thermo/WaterSSTP.h @@ -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 diff --git a/src/thermo/WaterSSTP.cpp b/src/thermo/WaterSSTP.cpp index 3ae8fe6dc..35079fc8d 100644 --- a/src/thermo/WaterSSTP.cpp +++ b/src/thermo/WaterSSTP.cpp @@ -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 diff --git a/test/thermo/phaseConstructors.cpp b/test/thermo/phaseConstructors.cpp index 226a8349f..24cd628f3 100644 --- a/test/thermo/phaseConstructors.cpp +++ b/test/thermo/phaseConstructors.cpp @@ -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("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