diff --git a/src/thermo/SpeciesThermoFactory.cpp b/src/thermo/SpeciesThermoFactory.cpp index 37089734c..229f23ce0 100644 --- a/src/thermo/SpeciesThermoFactory.cpp +++ b/src/thermo/SpeciesThermoFactory.cpp @@ -249,6 +249,30 @@ static SpeciesThermoInterpType* newShomateThermoFromXML( return newSpeciesThermoInterpType(SHOMATE, tmin, tmax, p0, &c[0]); } + +void setupShomatePoly(ShomatePoly2& thermo, const AnyMap& node, + const UnitSystem& units) +{ + setupSpeciesThermo(thermo, node, units); + vector_fp Tranges = units.convert( + node.at("temperature-ranges").asVector(2, 3), "K"); + const auto& data = node.at("data").asVector(Tranges.size()-1); + for (const auto& poly : data) { + if (poly.size() != 7) { + throw CanteraError("setupShomatePoly", "Wrong number of coefficients " + "for Shomate polynomial. Expected 7, but got {}", poly.size()); + } + } + thermo.setMinTemp(Tranges.front()); + thermo.setMaxTemp(Tranges.back()); + if (Tranges.size() == 3) { // standard 2 temperature range polynomial + thermo.setParameters(Tranges[1], data[0], data[1]); + } else { // Repeat data for single temperature range for both ranges + thermo.setParameters(Tranges[1], data[0], data[0]); + } +} + + //! Create a "simple" constant heat capacity thermodynamic property //! parameterization for a ! species /*! @@ -382,6 +406,10 @@ unique_ptr newSpeciesThermo( unique_ptr thermo(new NasaPoly2()); setupNasaPoly(*thermo, node, units); return unique_ptr(move(thermo)); + } else if (model == "Shomate") { + unique_ptr thermo(new ShomatePoly2()); + setupShomatePoly(*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 f614ffa0a..082c68abe 100644 --- a/test/thermo/thermoParameterizations.cpp +++ b/test/thermo/thermoParameterizations.cpp @@ -163,3 +163,21 @@ TEST(SpeciesThermo, NasaPoly2FromYaml2) { EXPECT_DOUBLE_EQ(h_RT, 13.735827875868003); EXPECT_DOUBLE_EQ(s_R, 28.913447733267262); } + +TEST(SpeciesThermo, Shomate2FromYaml1) { + AnyMap data = AnyMap::fromYamlString( + "model: Shomate\n" + "temperature-ranges: [298, 1300, 6000]\n" + "data:\n" + "- [25.56759, 6.096130, 4.054656, -2.671301, 0.131021, -118.0089, 227.3665]\n" + "- [35.15070, 1.300095, -0.205921, 0.013550, -3.282780, -127.8375, 231.7120]\n"); + UnitSystem U; + double cp_R, h_RT, s_R; + auto st = newSpeciesThermo(data, U); + st->validate("CO"); + st->updatePropertiesTemp(1500, &cp_R, &h_RT, &s_R); + EXPECT_DOUBLE_EQ(st->refPressure(), OneAtm); + EXPECT_DOUBLE_EQ(cp_R, 4.2365023429076265); + EXPECT_DOUBLE_EQ(h_RT, -5.747001162488512); + EXPECT_DOUBLE_EQ(s_R, 29.878976075583324); +}