[Input] Create PDSS_SSVol objects from YAML definitions

This commit is contained in:
Ray Speth
2019-01-16 23:21:06 -05:00
parent 1e8b8b538c
commit 72d345619f
4 changed files with 56 additions and 1 deletions

View File

@@ -30,7 +30,7 @@ PDSSFactory::PDSSFactory()
m_synonyms["IonFromNeutral"] = "ions-from-neutral";
m_synonyms["ions-from-neutral-molecule"] = "ions-from-neutral";
reg("temperature_polynomial", []() { return new PDSS_SSVol(); });
m_synonyms["temperature-polynomial"] = "temperature_polynomial";
m_synonyms["molar-volume-temperature-polynomial"] = "temperature_polynomial";
m_synonyms["density_temperature_polynomial"] = "temperature_polynomial";
m_synonyms["density-temperature-polynomial"] = "temperature_polynomial";
reg("HKFT", []() { return new PDSS_HKFT(); });

View File

@@ -66,6 +66,27 @@ void PDSS_SSVol::setDensityPolynomial(double* coeffs) {
void PDSS_SSVol::initThermo()
{
PDSS::initThermo();
if (m_input.hasKey("model")) {
const string& model = m_input["model"].asString();
auto& data = m_input["data"].asVector<AnyValue>(4);
if (model == "density-temperature-polynomial") {
double coeffs[] {
m_input.units().convert(data[0], "kg/m^3"),
m_input.units().convert(data[1], "kg/m^3/K"),
m_input.units().convert(data[2], "kg/m^3/K^2"),
m_input.units().convert(data[3], "kg/m^3/K^3"),
};
setDensityPolynomial(coeffs);
} else if (model == "molar-volume-temperature-polynomial") {
double coeffs[] {
m_input.units().convert(data[0], "m^3/kmol"),
m_input.units().convert(data[1], "m^3/kmol/K"),
m_input.units().convert(data[2], "m^3/kmol/K^2"),
m_input.units().convert(data[3], "m^3/kmol/K^3"),
};
setVolumePolynomial(coeffs);
}
}
m_minTemp = m_spthermo->minTemp();
m_maxTemp = m_spthermo->maxTemp();
m_p0 = m_spthermo->refPressure();

View File

@@ -97,6 +97,10 @@ phases:
species: [{gas-species: [H2O, H2, O2]}]
state: {T: 400, P: 5 atm, X: {H2: 0.01, O2: 0.99}}
- name: IdealSolnGas-liquid
thermo: ideal-solution-VPSS
standard-concentration-basis: unity
species: [Li(l)]
species:
- name: NaCl(s)
@@ -152,6 +156,18 @@ species:
model: constant-volume
molar-volume: 20.304 cm^3/gmol
- name: Li(l)
composition: {Li: 1}
thermo:
model: Shomate
temperature-ranges: [298, 700, 3000]
data:
- [26.3072, 30.4657, -69.1692, 44.1951, 0.0776, -6.0337, 59.8106]
- [22.6832, 10.476, -6.5428, 1.3255, 0.8783, -2.0426, 62.8859]
equation-of-state:
model: density-temperature-polynomial
units: {mass: g, length: cm}
data: [0.536504, -1.04279e-4, 3.84825e-9, -5.2853e-12]
ideal-molal-fake-species:
# Fake thermo data (GRI 3.0 coefficients for H2)

View File

@@ -220,3 +220,21 @@ TEST(ThermoFromYaml, IdealSolnGas_gas)
EXPECT_NEAR(thermo->moleFraction("H2O"), 0.01, 1e-4);
EXPECT_NEAR(thermo->moleFraction("H2"), 0.0, 1e-4);
}
TEST(ThermoFromYaml, IdealSolnGas_liquid)
{
AnyMap infile = AnyMap::fromYamlFile("thermo-models.yaml");
auto phaseNodes = infile["phases"].asMap("name");
auto thermo = newPhase(*phaseNodes.at("IdealSolnGas-liquid"), infile);
thermo->setState_TP(300, OneAtm);
EXPECT_NEAR(thermo->density(), 505.42393940, 2e-8);
EXPECT_NEAR(thermo->gibbs_mole(), -7801634.1184443515, 2e-8);
thermo->setState_TP(400, 2*OneAtm);
EXPECT_NEAR(thermo->density(), 495.06986080, 2e-8);
EXPECT_NEAR(thermo->molarVolume(), 0.01402024350418708, 2e-12);
thermo->setState_TP(500, 2*OneAtm);
EXPECT_NEAR(thermo->density(), 484.66590, 2e-8);
EXPECT_NEAR(thermo->enthalpy_mass(), 1236522.9439646902, 2e-8);
EXPECT_NEAR(thermo->entropy_mole(), 49848.48843237689, 2e-8);
}