From 311ae765103c97ea691cf90a6832e4b6faa32a4b Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 11 Jan 2019 16:08:14 -0500 Subject: [PATCH] [Thermo] Allow species without thermo data In some models, SpeciesThermoInterpType objects on individual species are not used. Instead of requiring the specification of placeholder thermo data, this allows the base SpeciesThermoInterpType class to be used, which will throw an exception if it is inadvertently used. --- .../cantera/thermo/SpeciesThermoInterpType.h | 6 ++--- src/thermo/Species.cpp | 6 ++++- src/thermo/SpeciesThermoInterpType.cpp | 15 ++++++++++++ test/data/LiFixed.xml | 23 ------------------- test/data/liquid-water.xml | 12 ---------- 5 files changed, 23 insertions(+), 39 deletions(-) diff --git a/include/cantera/thermo/SpeciesThermoInterpType.h b/include/cantera/thermo/SpeciesThermoInterpType.h index 15d727e5d..0eb6cdcd9 100644 --- a/include/cantera/thermo/SpeciesThermoInterpType.h +++ b/include/cantera/thermo/SpeciesThermoInterpType.h @@ -151,7 +151,7 @@ public: virtual void validate(const std::string& name) {} //! Returns an integer representing the type of parameterization - virtual int reportType() const = 0; + virtual int reportType() const { return 0; }; //! Number of terms in the temperature polynomial for this parameterization virtual size_t temperaturePolySize() const { return 1; } @@ -195,7 +195,7 @@ public: virtual void updatePropertiesTemp(const doublereal temp, doublereal* cp_R, doublereal* h_RT, - doublereal* s_R) const = 0; + doublereal* s_R) const; //! This utility function reports back the type of parameterization and all //! of the parameters for the species. @@ -213,7 +213,7 @@ public: virtual void reportParameters(size_t& index, int& type, doublereal& minTemp, doublereal& maxTemp, doublereal& refPressure, - doublereal* const coeffs) const = 0; + doublereal* const coeffs) const; //! Report the 298 K Heat of Formation of the standard state of one species //! (J kmol-1) diff --git a/src/thermo/Species.cpp b/src/thermo/Species.cpp index 0275cc4ea..08ca73490 100644 --- a/src/thermo/Species.cpp +++ b/src/thermo/Species.cpp @@ -43,7 +43,11 @@ shared_ptr newSpecies(const XML_Node& species_node) if (species_node.hasChild("size")) { s->size = getFloat(species_node, "size"); } - s->thermo.reset(newSpeciesThermoInterpType(species_node.child("thermo"))); + if (species_node.hasChild("thermo")) { + s->thermo.reset(newSpeciesThermoInterpType(species_node.child("thermo"))); + } else { + s->thermo.reset(new SpeciesThermoInterpType()); + } // Read transport data, if provided if (species_node.hasChild("transport")) { diff --git a/src/thermo/SpeciesThermoInterpType.cpp b/src/thermo/SpeciesThermoInterpType.cpp index 13f96687a..e1f15a984 100644 --- a/src/thermo/SpeciesThermoInterpType.cpp +++ b/src/thermo/SpeciesThermoInterpType.cpp @@ -34,6 +34,21 @@ void SpeciesThermoInterpType::updateProperties(const doublereal* tempPoly, updatePropertiesTemp(T, cp_R, h_RT, s_R); } +void SpeciesThermoInterpType::updatePropertiesTemp(const double temp, + double* cp_R, double* h_RT, double* s_R) const +{ + throw CanteraError("SpeciesThermoInterpType::updatePropertiesTemp", + "Not implemented"); +} + +void SpeciesThermoInterpType::reportParameters(size_t& index, int& type, + double& minTemp, double& maxTemp, double& refPressure, + double* const coeffs) const +{ + throw CanteraError("SpeciesThermoInterpType::reportParameters", + "Not implemented"); +} + doublereal SpeciesThermoInterpType::reportHf298(doublereal* const h298) const { throw CanteraError("SpeciesThermoInterpType::reportHf298", diff --git a/test/data/LiFixed.xml b/test/data/LiFixed.xml index d7dea7cfe..2b117a1e2 100644 --- a/test/data/LiFixed.xml +++ b/test/data/LiFixed.xml @@ -16,34 +16,11 @@ - - - Li - - - LiFixed - - - -2.3E7 - - - - - Li:1 - - - - 50.72389, 6.672267, -2.517167, - 10.15934, -0.200675, -427.2115, - 130.3973 - - - diff --git a/test/data/liquid-water.xml b/test/data/liquid-water.xml index 798f0895e..63bf8551c 100644 --- a/test/data/liquid-water.xml +++ b/test/data/liquid-water.xml @@ -23,18 +23,6 @@ H:2 O:1 - - - - 4.198640560E+00, -2.036434100E-03, 6.520402110E-06, -5.487970620E-09, - 1.771978170E-12, -3.029372670E+04, -8.490322080E-01 - - - - 3.033992490E+00, 2.176918040E-03, -1.640725180E-07, -9.704198700E-11, - 1.682009920E-14, -3.000429710E+04, 4.966770100E+00 - -