diff --git a/include/cantera/thermo/ThermoPhase.h b/include/cantera/thermo/ThermoPhase.h index a6f06d8ff..318a9be00 100644 --- a/include/cantera/thermo/ThermoPhase.h +++ b/include/cantera/thermo/ThermoPhase.h @@ -1427,10 +1427,17 @@ public: * required after all species have been added. For example, it might be used * to resize internal work arrays that must have an entry for each species. * The base class implementation does nothing, and subclasses that do not - * require initialization do not need to overload this method. When - * importing a CTML phase description, this method is called from + * require initialization do not need to overload this method. Derived + * classes which do override this function should call their parent class's + * implementation of this function as their last action. + * + * When importing a CTML phase description, this method is called from * initThermoXML(), which is called from importPhase(), just prior to * returning from function importPhase(). + * + * When importing from an AnyMap phase desciption (or from a YAML file), + * this method is responsible for setting model parameters from the data + * stored in #m_input. */ virtual void initThermo(); @@ -1454,6 +1461,13 @@ public: virtual void getParameters(int& n, doublereal* const c) const { } + //! Set equation of state parameters from an AnyMap phase description + void setParameters(const AnyMap& phaseNode); + + //! Access input data associated with the phase description + const AnyMap& input() const; + AnyMap& input(); + //! Set equation of state parameter values from XML entries. /*! * This method is called by function importPhase() when processing a phase @@ -1606,6 +1620,10 @@ protected: */ MultiSpeciesThermo m_spthermo; + //! Data supplied via setParameters. When first set, this may include + //! parameters used by different phase models when initThermo() is called. + AnyMap m_input; + //! Vector of pointers to the species databases. /*! * This is used to access data needed to construct the transport manager and diff --git a/src/thermo/ThermoFactory.cpp b/src/thermo/ThermoFactory.cpp index efee3ea21..bdc7c24a4 100644 --- a/src/thermo/ThermoFactory.cpp +++ b/src/thermo/ThermoFactory.cpp @@ -498,6 +498,7 @@ void setupPhase(ThermoPhase& thermo, const AnyMap& phaseNode, addSpecies(thermo, AnyValue("all"), rootNode["species"]); } + thermo.setParameters(phaseNode); thermo.initThermo(); if (phaseNode.hasKey("state")) { diff --git a/src/thermo/ThermoPhase.cpp b/src/thermo/ThermoPhase.cpp index e59875332..e316d7652 100644 --- a/src/thermo/ThermoPhase.cpp +++ b/src/thermo/ThermoPhase.cpp @@ -750,6 +750,21 @@ const std::vector & ThermoPhase::speciesData() const return m_speciesData; } +void ThermoPhase::setParameters(const AnyMap& phaseNode) +{ + m_input = phaseNode; +} + +const AnyMap& ThermoPhase::input() const +{ + return m_input; +} + +AnyMap& ThermoPhase::input() +{ + return m_input; +} + void ThermoPhase::setStateFromXML(const XML_Node& state) { string comp = getChildValue(state,"moleFractions");