diff --git a/include/cantera/thermo/PDSS.h b/include/cantera/thermo/PDSS.h index da5a3d700..7b00280e5 100644 --- a/include/cantera/thermo/PDSS.h +++ b/include/cantera/thermo/PDSS.h @@ -11,6 +11,7 @@ #ifndef CT_PDSS_H #define CT_PDSS_H #include "cantera/base/ct_defs.h" +#include "cantera/base/AnyMap.h" namespace Cantera { @@ -425,6 +426,12 @@ public: */ virtual void initThermo() {} + //! Set model parameters from an AnyMap phase description, e.g. from the + //! `equation-of-state` field of a species definition. + void setParameters(const AnyMap& node) { + m_input = node; + } + //! Initialization routine for the PDSS object based on the speciesNode /*! * This is a cascading call, where each level should call the the parent @@ -468,6 +475,10 @@ protected: //! Molecular Weight of the species doublereal m_mw; + //! Input data supplied via setParameters. This may include parameters for + //! different phase models, which will be used when initThermo() is called. + AnyMap m_input; + //! Pointer to the species thermodynamic property manager. Not used in all //! PDSS models. shared_ptr m_spthermo; diff --git a/src/thermo/ThermoFactory.cpp b/src/thermo/ThermoFactory.cpp index 8cb87b8e2..52cdb286d 100644 --- a/src/thermo/ThermoFactory.cpp +++ b/src/thermo/ThermoFactory.cpp @@ -503,6 +503,14 @@ void setupPhase(ThermoPhase& thermo, const AnyMap& phaseNode, addSpecies(thermo, AnyValue("all"), rootNode["species"]); } + auto* vpssThermo = dynamic_cast(&thermo); + if (vpssThermo) { + for (size_t k = 0; k < thermo.nSpecies(); k++) { + string model = thermo.species(k)->input["equation-of-state"]["model"].asString(); + vpssThermo->installPDSS(k, unique_ptr(newPDSS(model))); + } + } + thermo.setParameters(phaseNode); thermo.initThermo(); diff --git a/src/thermo/VPStandardStateTP.cpp b/src/thermo/VPStandardStateTP.cpp index d6bfa61dd..0f393874c 100644 --- a/src/thermo/VPStandardStateTP.cpp +++ b/src/thermo/VPStandardStateTP.cpp @@ -230,9 +230,13 @@ void VPStandardStateTP::installPDSS(size_t k, unique_ptr&& pdss) { pdss->setParent(this, k); pdss->setMolecularWeight(molecularWeight(k)); - if (species(k)->thermo) { - pdss->setReferenceThermo(species(k)->thermo); - species(k)->thermo->validate(speciesName(k)); + Species& spec = *species(k); + if (spec.thermo) { + pdss->setReferenceThermo(spec.thermo); + spec.thermo->validate(spec.name); + } + if (spec.input.hasKey("equation-of-state")) { + pdss->setParameters(spec.input["equation-of-state"].as()); } m_minTemp = std::max(m_minTemp, pdss->minTemp()); m_maxTemp = std::min(m_maxTemp, pdss->maxTemp());