[Input] Create ConstDensityThermo objects from YAML definitions

This commit is contained in:
Ray Speth 2019-02-04 22:57:01 -05:00
parent ecc1cf0db2
commit 3011374ff6
5 changed files with 23 additions and 0 deletions

View file

@ -136,6 +136,7 @@ public:
n = 1;
}
virtual void initThermo();
virtual void setParametersFromXML(const XML_Node& eosdata);
protected:

View file

@ -105,6 +105,14 @@ void ConstDensityThermo::_updateThermo() const
}
}
void ConstDensityThermo::initThermo()
{
if (m_input.hasKey("density")) {
setDensity(m_input.convert("density", "kg/m^3"));
}
ThermoPhase::initThermo();
}
void ConstDensityThermo::setParametersFromXML(const XML_Node& eosdata)
{
eosdata._require("model","Incompressible");

View file

@ -52,6 +52,7 @@ ThermoFactory::ThermoFactory()
reg("IdealGas", []() { return new IdealGasPhase(); });
m_synonyms["ideal-gas"] = "IdealGas";
reg("Incompressible", []() { return new ConstDensityThermo(); });
m_synonyms["constant-density"] = "Incompressible";
reg("Surface", []() { return new SurfPhase(); });
m_synonyms["ideal-surface"] = "Surface";
reg("Edge", []() { return new EdgePhase(); });

View file

@ -179,6 +179,13 @@ phases:
thermo: pure-fluid
pure-fluid-name: nitrogen
- name: const-density
thermo: constant-density
density: 0.7 g/cm^3
species: [NaCl(s), KCl(s)]
state: {T: 320, P: 1 atm}
species:
- name: NaCl(s)
composition: {Na: 1, Cl: 1}

View file

@ -332,3 +332,9 @@ TEST(ThermoFromYaml, PureFluid_nitrogen)
EXPECT_NEAR(thermo->density(), 841.0420151, 1e-6);
EXPECT_NEAR(thermo->gibbs_mole(), -17654452.8821914, 1e-6);
}
TEST(ThermoFromYaml, ConstDensityThermo)
{
auto thermo = newThermo("thermo-models.yaml", "const-density");
EXPECT_DOUBLE_EQ(thermo->density(), 700.0);
}