[Input] Create IdealGasVPSS and PDSS_IdealGas objects from YAML definitions
This commit is contained in:
parent
a3024d7699
commit
1e8b8b538c
4 changed files with 76 additions and 4 deletions
|
|
@ -52,9 +52,11 @@ void IdealSolnGasVPSS::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",
|
||||
|
|
@ -256,6 +258,18 @@ bool IdealSolnGasVPSS::addSpecies(shared_ptr<Species> spec)
|
|||
void IdealSolnGasVPSS::initThermo()
|
||||
{
|
||||
VPStandardStateTP::initThermo();
|
||||
if (m_input.hasKey("thermo")) {
|
||||
const string& model = m_input["thermo"].asString();
|
||||
if (model == "ideal-solution-VPSS") {
|
||||
setSolnMode();
|
||||
} else if (model == "ideal-gas-VPSS") {
|
||||
setGasMode();
|
||||
}
|
||||
}
|
||||
if (m_input.hasKey("standard-concentration-basis")) {
|
||||
setStandardConcentrationModel(m_input["standard-concentration-basis"].asString());
|
||||
}
|
||||
|
||||
if (m_idealGas == -1) {
|
||||
throw CanteraError("IdealSolnGasVPSS::initThermo",
|
||||
"solution / gas mode not set");
|
||||
|
|
|
|||
|
|
@ -67,7 +67,9 @@ ThermoFactory::ThermoFactory()
|
|||
reg("IdealMolalSolution", []() { return new IdealMolalSoln(); });
|
||||
m_synonyms["ideal-molal-solution"] = "IdealMolalSolution";
|
||||
reg("IdealGasVPSS", []() { return new IdealSolnGasVPSS(); });
|
||||
m_synonyms["IdealGasVPSS"] = "IdealSolnVPSS";
|
||||
m_synonyms["IdealSolnVPSS"] = "IdealGasVPSS";
|
||||
m_synonyms["ideal-solution-VPSS"] = "IdealGasVPSS";
|
||||
m_synonyms["ideal-gas-VPSS"] = "IdealGasVPSS";
|
||||
reg("Margules", []() { return new MargulesVPSSTP(); });
|
||||
reg("IonsFromNeutralMolecule", []() { return new IonsFromNeutralVPSSTP(); });
|
||||
m_synonyms["ions-from-neutral-molecule"] = "IonsFromNeutralMolecule";
|
||||
|
|
@ -511,7 +513,12 @@ void setupPhase(ThermoPhase& thermo, AnyMap& phaseNode, const AnyMap& rootNode)
|
|||
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();
|
||||
string model;
|
||||
if (thermo.species(k)->input.hasKey("equation-of-state")) {
|
||||
model = thermo.species(k)->input["equation-of-state"]["model"].asString();
|
||||
} else {
|
||||
model = "ideal-gas";
|
||||
}
|
||||
vpssThermo->installPDSS(k, unique_ptr<PDSS>(newPDSS(model)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,11 @@ phases:
|
|||
species: [KCl(l)]
|
||||
thermo: Margules
|
||||
|
||||
- name: IdealSolnGas-gas
|
||||
thermo: ideal-gas-VPSS
|
||||
species: [{gas-species: [H2O, H2, O2]}]
|
||||
state: {T: 400, P: 5 atm, X: {H2: 0.01, O2: 0.99}}
|
||||
|
||||
|
||||
species:
|
||||
- name: NaCl(s)
|
||||
|
|
@ -270,3 +275,37 @@ ions-from-neutral-species:
|
|||
special-species: true
|
||||
model: ions-from-neutral-molecule
|
||||
multipliers: {KCl(l): 1.5}
|
||||
|
||||
gas-species:
|
||||
- name: H2
|
||||
composition: {H: 2}
|
||||
thermo:
|
||||
model: NASA7
|
||||
temperature-ranges: [200.0, 1000.0, 3500.0]
|
||||
data:
|
||||
- [2.34433112, 0.00798052075, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12,
|
||||
-917.935173, 0.683010238]
|
||||
- [3.3372792, -4.94024731e-05, 4.99456778e-07, -1.79566394e-10, 2.00255376e-14,
|
||||
-950.158922, -3.20502331]
|
||||
equation-of-state:
|
||||
model: ideal-gas
|
||||
- name: H2O
|
||||
composition: {H: 2, O: 1}
|
||||
thermo:
|
||||
model: NASA7
|
||||
temperature-ranges: [200.0, 1000.0, 3500.0]
|
||||
data:
|
||||
- [4.19864056, -0.0020364341, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12,
|
||||
-30293.7267, -0.849032208]
|
||||
- [3.03399249, 0.00217691804, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14,
|
||||
-30004.2971, 4.9667701]
|
||||
- name: O2
|
||||
composition: {O: 2}
|
||||
thermo:
|
||||
model: NASA7
|
||||
temperature-ranges: [200.0, 1000.0, 3500.0]
|
||||
data:
|
||||
- [3.78245636, -0.00299673416, 9.84730201e-06, -9.68129509e-09, 3.24372837e-12,
|
||||
-1063.94356, 3.65767573]
|
||||
- [3.28253784, 0.00148308754, -7.57966669e-07, 2.09470555e-10, -2.16717794e-14,
|
||||
-1088.45772, 5.45323129]
|
||||
|
|
|
|||
|
|
@ -208,3 +208,15 @@ TEST(ThermoFromYaml, IonsFromNeutral)
|
|||
EXPECT_NEAR(mu[0], -4.66404010e+08, 1e1);
|
||||
EXPECT_NEAR(mu[1], -2.88157298e+06, 1e-1);
|
||||
}
|
||||
|
||||
TEST(ThermoFromYaml, IdealSolnGas_gas)
|
||||
{
|
||||
AnyMap infile = AnyMap::fromYamlFile("thermo-models.yaml");
|
||||
auto phaseNodes = infile["phases"].asMap("name");
|
||||
auto thermo = newPhase(*phaseNodes.at("IdealSolnGas-gas"), infile);
|
||||
|
||||
thermo->equilibrate("HP");
|
||||
EXPECT_NEAR(thermo->temperature(), 479.929, 1e-3); // based on h2o2.cti
|
||||
EXPECT_NEAR(thermo->moleFraction("H2O"), 0.01, 1e-4);
|
||||
EXPECT_NEAR(thermo->moleFraction("H2"), 0.0, 1e-4);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue