[Input] Create FixedChemPot objects from YAML definitions
This commit is contained in:
parent
d7734e3f19
commit
2c58dd78c6
5 changed files with 30 additions and 0 deletions
|
|
@ -318,6 +318,8 @@ public:
|
|||
|
||||
virtual void initThermoXML(XML_Node& phaseNode, const std::string& id);
|
||||
|
||||
virtual void initThermo();
|
||||
|
||||
//! Set the equation of state parameters
|
||||
/*!
|
||||
* @internal
|
||||
|
|
|
|||
|
|
@ -212,6 +212,14 @@ void FixedChemPotSSTP::initThermoXML(XML_Node& phaseNode, const std::string& id_
|
|||
}
|
||||
}
|
||||
|
||||
void FixedChemPotSSTP::initThermo()
|
||||
{
|
||||
if (m_input.hasKey("chemical-potential")) {
|
||||
chemPot_ = m_input.convert("chemical-potential", "J/kmol");
|
||||
}
|
||||
SingleSpeciesTP::initThermo();
|
||||
}
|
||||
|
||||
void FixedChemPotSSTP::setParameters(int n, doublereal* const c)
|
||||
{
|
||||
chemPot_ = c[0];
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ ThermoFactory::ThermoFactory()
|
|||
reg("Margules", []() { return new MargulesVPSSTP(); });
|
||||
reg("IonsFromNeutralMolecule", []() { return new IonsFromNeutralVPSSTP(); });
|
||||
reg("FixedChemPot", []() { return new FixedChemPotSSTP(); });
|
||||
m_synonyms["fixed-chemical-potential"] = "FixedChemPot";
|
||||
reg("Redlich-Kister", []() { return new RedlichKisterVPSSTP(); });
|
||||
reg("RedlichKwong", []() { return new RedlichKwongMFTP(); });
|
||||
m_synonyms["RedlichKwongMFTP"] = "RedlichKwong";
|
||||
|
|
|
|||
|
|
@ -14,6 +14,11 @@ phases:
|
|||
thermo: water-IAPWS95
|
||||
species: [H2O(l)]
|
||||
|
||||
- name: Li-fixed
|
||||
thermo: fixed-chemical-potential
|
||||
species: [Li]
|
||||
chemical-potential: -2.3e7 J/kmol
|
||||
|
||||
species:
|
||||
- name: NaCl(s)
|
||||
composition: {Na: 1, Cl: 1}
|
||||
|
|
@ -42,3 +47,6 @@ species:
|
|||
|
||||
- name: H2O(l)
|
||||
composition: {H: 2, O: 1}
|
||||
|
||||
- name: Li
|
||||
composition: {Li: 1}
|
||||
|
|
|
|||
|
|
@ -102,3 +102,14 @@ TEST(ThermoFromYaml, WaterSSTP)
|
|||
EXPECT_NEAR(thermo->density(), 973.7736331, 1e-6);
|
||||
EXPECT_NEAR(thermo->enthalpy_mass(), -15649442.2898854, 1e-6);
|
||||
}
|
||||
|
||||
TEST(ThermoFromYaml, FixedChemPot)
|
||||
{
|
||||
AnyMap infile = AnyMap::fromYamlFile("thermo-models.yaml");
|
||||
auto phaseNodes = infile["phases"].asMap("name");
|
||||
auto thermo = newPhase(*phaseNodes.at("Li-fixed"), infile);
|
||||
EXPECT_EQ(thermo->nSpecies(), (size_t) 1);
|
||||
double mu;
|
||||
thermo->getChemPotentials(&mu);
|
||||
EXPECT_DOUBLE_EQ(mu, -2.3e7);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue