[Input] Parse YAML entries for piecewise Gibbs (Mu0Poly) species thermo

This commit is contained in:
Ray Speth 2018-12-17 23:37:46 -05:00
parent f0bb0d2262
commit 4c5040e829
2 changed files with 36 additions and 0 deletions

View file

@ -371,6 +371,23 @@ void setupNasa9Poly(Nasa9PolyMultiTempRegion& thermo, const AnyMap& node,
}
void setupMu0(Mu0Poly& thermo, const AnyMap& node, const UnitSystem& units)
{
setupSpeciesThermo(thermo, node, units);
bool dimensionless = node.getBool("dimensionless", false);
double h0 = units.convertMolarEnergy(node, "h0", "J/kmol", 0.0);
map<double, double> T_mu;
for (const auto& item : node.at("data")) {
double T = units.convert(fpValueCheck(item.first), "K");
if (dimensionless) {
T_mu[T] = item.second.asDouble() * GasConstant * T;
} else {
T_mu[T] = units.convertMolarEnergy(item.second, "J/kmol");
}
}
thermo.setParameters(h0, T_mu);
}
SpeciesThermoInterpType* newSpeciesThermoInterpType(const XML_Node& thermo)
{
std::string model = toLowerCopy(thermo["model"]);
@ -446,6 +463,10 @@ unique_ptr<SpeciesThermoInterpType> newSpeciesThermo(
unique_ptr<ConstCpPoly> thermo(new ConstCpPoly());
setupConstCp(*thermo, node, units);
return unique_ptr<SpeciesThermoInterpType>(move(thermo));
} else if (model == "piecewise-Gibbs") {
unique_ptr<Mu0Poly> thermo(new Mu0Poly());
setupMu0(*thermo, node, units);
return unique_ptr<SpeciesThermoInterpType>(move(thermo));
} else {
throw CanteraError("newSpeciesThermo",
"Uknown thermo model '{}'", model);

View file

@ -222,3 +222,18 @@ TEST(SpeciesThermo, ConstCpPolyFromYaml) {
EXPECT_DOUBLE_EQ(h_RT * GasConst_cal_mol_K * 1100, 9.22e3 + 100 * 5.95);
EXPECT_DOUBLE_EQ(s_R * GasConst_cal_mol_K, -3.02 + 5.95 * log(1100.0/1000.0));
}
TEST(SpeciesThermo, Mu0PolyFromYaml) {
AnyMap data = AnyMap::fromYamlString(
"{model: piecewise-Gibbs,"
" h0: -890 kJ/mol,"
" dimensionless: true,"
" data: {298.15: -363.2104, 323.15: -300}}");
UnitSystem U;
auto st = newSpeciesThermo(data, U);
double cp_R, h_RT, s_R;
st->updatePropertiesTemp(310, &cp_R, &h_RT, &s_R);
EXPECT_DOUBLE_EQ(cp_R, -11226.315195362145);
EXPECT_DOUBLE_EQ(h_RT, -774.4330249157999);
EXPECT_DOUBLE_EQ(s_R, -433.36374517067503);
}