From 86c73dad20e2140e78d9befb27286c118209af1f Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 17 Dec 2018 11:41:35 -0500 Subject: [PATCH] [Input] Parse YAML entries for constant cp species thermo --- src/thermo/SpeciesThermoFactory.cpp | 14 ++++++++++++++ test/thermo/thermoParameterizations.cpp | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/thermo/SpeciesThermoFactory.cpp b/src/thermo/SpeciesThermoFactory.cpp index f7ee83ae3..50397f02d 100644 --- a/src/thermo/SpeciesThermoFactory.cpp +++ b/src/thermo/SpeciesThermoFactory.cpp @@ -294,6 +294,16 @@ static SpeciesThermoInterpType* newConstCpThermoFromXML(XML_Node& f) return newSpeciesThermoInterpType(CONSTANT_CP, tmin, tmax, p0, &c[0]); } +void setupConstCp(ConstCpPoly& thermo, const AnyMap& node, + const UnitSystem& units) +{ + double T0 = units.convert(node.at("T0"), "K"); + double h0 = units.convert(node, "h0", "J/kmol", 0.0); + double s0 = units.convert(node, "s0", "J/kmol/K", 0.0); + double cp0 = units.convert(node, "cp0", "J/kmol/K", 0.0); + thermo.setParameters(T0, h0, s0, cp0); +} + //! Create a NASA9 polynomial thermodynamic property parameterization for a //! species /*! @@ -432,6 +442,10 @@ unique_ptr newSpeciesThermo( unique_ptr thermo(new Nasa9PolyMultiTempRegion()); setupNasa9Poly(*thermo, node, units); return unique_ptr(move(thermo)); + } else if (model == "constant-cp") { + unique_ptr thermo(new ConstCpPoly()); + setupConstCp(*thermo, node, units); + return unique_ptr(move(thermo)); } else { throw CanteraError("newSpeciesThermo", "Uknown thermo model '{}'", model); diff --git a/test/thermo/thermoParameterizations.cpp b/test/thermo/thermoParameterizations.cpp index 4740375d8..1bbbb9afa 100644 --- a/test/thermo/thermoParameterizations.cpp +++ b/test/thermo/thermoParameterizations.cpp @@ -206,3 +206,19 @@ TEST(SpeciesThermo, Nasa9PolyFromYaml) { EXPECT_DOUBLE_EQ(h_RT, 3.3757914517886856); EXPECT_DOUBLE_EQ(s_R, 30.31743870437559); } + +TEST(SpeciesThermo, ConstCpPolyFromYaml) { + AnyMap data = AnyMap::fromYamlString( + "model: constant-cp # was 'const_cp'\n" + "T0: 1000 K\n" + "h0: 9.22 kcal/mol\n" + "s0: -3.02 cal/mol/K\n" + "cp0: 5.95 cal/mol/K\n"); + UnitSystem U; + double cp_R, h_RT, s_R; + auto st = newSpeciesThermo(data, U); + st->updatePropertiesTemp(1100, &cp_R, &h_RT, &s_R); + EXPECT_DOUBLE_EQ(cp_R * GasConst_cal_mol_K, 5.95); + 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)); +}