[Input] Create IdealMolalSoln objects from YAML definitions

This commit is contained in:
Ray Speth 2019-01-15 17:08:14 -05:00
parent 1bdbf2a010
commit e7c6495ec7
4 changed files with 110 additions and 2 deletions

View file

@ -406,6 +406,33 @@ void IdealMolalSoln::initThermoXML(XML_Node& phaseNode, const std::string& id_)
void IdealMolalSoln::initThermo()
{
MolalityVPSSTP::initThermo();
if (m_input.hasKey("standard-concentration-basis")) {
setStandardConcentrationModel(m_input["standard-concentration-basis"].asString());
}
if (m_input.hasKey("cutoff")) {
auto& cutoff = m_input["cutoff"].as<AnyMap>();
setCutoffModel(cutoff.getString("model", "none"));
if (cutoff.hasKey("gamma_o")) {
IMS_gamma_o_min_ = cutoff["gamma_o"].asDouble();
}
if (cutoff.hasKey("gamma_k")) {
IMS_gamma_k_min_ = cutoff["gamma_k"].asDouble();
}
if (cutoff.hasKey("X_o")) {
IMS_X_o_cutoff_ = cutoff["X_o"].asDouble();
}
if (cutoff.hasKey("c_0")) {
IMS_cCut_ = cutoff["c_0"].asDouble();
}
if (cutoff.hasKey("slope_f")) {
IMS_slopefCut_ = cutoff["slope_f"].asDouble();
}
if (cutoff.hasKey("slope_g")) {
IMS_slopegCut_ = cutoff["slope_g"].asDouble();
}
}
for (size_t k = 0; k < nSpecies(); k++) {
m_speciesMolarVolume[k] = providePDSS(k)->molarVolume();
}
@ -419,9 +446,11 @@ void IdealMolalSoln::setStandardConcentrationModel(const std::string& model)
{
if (caseInsensitiveEquals(model, "unity")) {
m_formGC = 0;
} else if (caseInsensitiveEquals(model, "molar_volume")) {
} else if (caseInsensitiveEquals(model, "species-molar-volume")
|| caseInsensitiveEquals(model, "molar_volume")) {
m_formGC = 1;
} else if (caseInsensitiveEquals(model, "solvent_volume")) {
} else if (caseInsensitiveEquals(model, "solvent-molar-volume")
|| caseInsensitiveEquals(model, "solvent_volume")) {
m_formGC = 2;
} else {
throw CanteraError("IdealSolnGasVPSS::setStandardConcentrationModel",

View file

@ -64,6 +64,7 @@ ThermoFactory::ThermoFactory()
reg("IdealSolidSolution", []() { return new IdealSolidSolnPhase(); });
reg("DebyeHuckel", []() { return new DebyeHuckel(); });
reg("IdealMolalSolution", []() { return new IdealMolalSoln(); });
m_synonyms["ideal-molal-solution"] = "IdealMolalSolution";
reg("IdealGasVPSS", []() { return new IdealSolnGasVPSS(); });
m_synonyms["IdealGasVPSS"] = "IdealSolnVPSS";
reg("Margules", []() { return new MargulesVPSSTP(); });

View file

@ -29,6 +29,24 @@ phases:
excess-enthalpy: [-17570, -377]
excess-entropy: [-7.627, 4.958]
- name: ideal-molal-aqueous
thermo: ideal-molal-solution
species:
- {ideal-molal-fake-species: all}
standard-concentration-basis: solvent-molar-volume
cutoff:
model: polyexp
gamma_o: 0.0001
gamma_k: 10.0
X_o: 0.2
c_0: 0.05
slope_f: 0.6
slope_g: 0.0
state:
T: 298.15
P: 1 atm
molalities: {CH4(aq): 0.01, H2S(aq): 0.03, CO2(aq): 0.1}
species:
- name: NaCl(s)
composition: {Na: 1, Cl: 1}
@ -82,3 +100,51 @@ species:
equation-of-state:
model: constant-volume
molar-volume: 20.304 cm^3/gmol
ideal-molal-fake-species:
# Fake thermo data (GRI 3.0 coefficients for H2)
- name: H2O(l)
composition: {H: 2, O: 1}
thermo:
model: NASA7
temperature-ranges: [200.0, 1000.0]
data:
- [2.34433112, 0.00798052075, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12,
-917.935173, 0.683010238]
equation-of-state:
model: constant-volume
molar-volume: 1.5
- name: CO2(aq)
composition: {C: 1, O: 2}
thermo:
model: NASA7
temperature-ranges: [200.0, 1000.0]
data:
- [2.34433112, 0.00798052075, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12,
-917.935173, 0.683010238]
equation-of-state:
model: constant-volume
molar-volume: 1.3
- name: H2S(aq)
composition: {H: 2, S: 1}
thermo:
model: NASA7
temperature-ranges: [200.0, 1000.0]
data:
- [2.34433112, 0.00798052075, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12,
-917.935173, 0.683010238]
equation-of-state:
model: constant-volume
molar-volume: 0.1
- name: CH4(aq)
composition: {C: 1, H: 4}
thermo:
model: NASA7
temperature-ranges: [200.0, 1000.0]
data:
- [2.34433112, 0.00798052075, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12,
-917.935173, 0.683010238]
equation-of-state:
model: constant-volume
molar-volume: 0.1

View file

@ -126,3 +126,15 @@ TEST(ThermoFromYaml, Margules)
EXPECT_NEAR(thermo->gibbs_mass(), -9682981.421693124, 1e-5);
EXPECT_NEAR(thermo->cp_mole(), 67478.48085733457, 1e-8);
}
TEST(ThermoFromYaml, IdealMolalSoln)
{
AnyMap infile = AnyMap::fromYamlFile("thermo-models.yaml");
auto phaseNodes = infile["phases"].asMap("name");
auto thermo = newPhase(*phaseNodes.at("ideal-molal-aqueous"), infile);
EXPECT_EQ(thermo->type(), "IdealMolalSoln");
EXPECT_NEAR(thermo->enthalpy_mole(), 0.013282, 1e-6);
EXPECT_NEAR(thermo->gibbs_mole(), -3.8986e7, 1e3);
EXPECT_NEAR(thermo->density(), 12.058, 1e-3);
}