[Input] Use YAML 'equation-of-state' field to create PDSS objects

This commit is contained in:
Ray Speth 2019-01-15 14:10:14 -05:00
parent 6dac1b0409
commit 89838c3ffb
3 changed files with 26 additions and 3 deletions

View file

@ -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<SpeciesThermoInterpType> m_spthermo;

View file

@ -503,6 +503,14 @@ void setupPhase(ThermoPhase& thermo, const AnyMap& phaseNode,
addSpecies(thermo, AnyValue("all"), rootNode["species"]);
}
auto* vpssThermo = dynamic_cast<VPStandardStateTP*>(&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<PDSS>(newPDSS(model)));
}
}
thermo.setParameters(phaseNode);
thermo.initThermo();

View file

@ -230,9 +230,13 @@ void VPStandardStateTP::installPDSS(size_t k, unique_ptr<PDSS>&& 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<AnyMap>());
}
m_minTemp = std::max(m_minTemp, pdss->minTemp());
m_maxTemp = std::min(m_maxTemp, pdss->maxTemp());