From cae5c498cae2de692a89e53a521ba15c5bc5a80f Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Thu, 10 Jan 2019 22:45:09 -0500 Subject: [PATCH] [Input] Create WaterSSTP objects from YAML definitions --- src/thermo/ThermoFactory.cpp | 1 + test/data/thermo-models.yaml | 5 +++++ test/thermo/thermoFromYaml.cpp | 12 ++++++++++++ 3 files changed, 18 insertions(+) diff --git a/src/thermo/ThermoFactory.cpp b/src/thermo/ThermoFactory.cpp index 7dd04c754..746587e79 100644 --- a/src/thermo/ThermoFactory.cpp +++ b/src/thermo/ThermoFactory.cpp @@ -74,6 +74,7 @@ ThermoFactory::ThermoFactory() m_synonyms["RedlichKwongMFTP"] = "RedlichKwong"; reg("MaskellSolidSolnPhase", []() { return new MaskellSolidSolnPhase(); }); reg("PureLiquidWater", []() { return new WaterSSTP(); }); + m_synonyms["water-IAPWS95"] = "PureLiquidWater"; reg("BinarySolutionTabulatedThermo", []() { return new BinarySolutionTabulatedThermo(); }); } diff --git a/test/data/thermo-models.yaml b/test/data/thermo-models.yaml index f21a9af83..49447926b 100644 --- a/test/data/thermo-models.yaml +++ b/test/data/thermo-models.yaml @@ -10,6 +10,9 @@ phases: species: [KCl(s)] state: {T: 300.0, P: 1 atm} +- name: liquid-water + thermo: water-IAPWS95 + species: [H2O(l)] species: - name: NaCl(s) @@ -37,3 +40,5 @@ species: model: constant-volume molar-volume: 0.0376521717 L/mol +- name: H2O(l) + composition: {H: 2, O: 1} diff --git a/test/thermo/thermoFromYaml.cpp b/test/thermo/thermoFromYaml.cpp index 93566584a..d56111fa7 100644 --- a/test/thermo/thermoFromYaml.cpp +++ b/test/thermo/thermoFromYaml.cpp @@ -90,3 +90,15 @@ TEST(ThermoFromYaml, StoichSubstance2) EXPECT_EQ(thermo->nElements(), (size_t) 2); EXPECT_NEAR(thermo->density(), 1980, 0.1); } + +TEST(ThermoFromYaml, WaterSSTP) +{ + AnyMap infile = AnyMap::fromYamlFile("thermo-models.yaml"); + auto phaseNodes = infile["phases"].asMap("name"); + auto thermo = newPhase(*phaseNodes.at("liquid-water"), infile); + EXPECT_EQ(thermo->nSpecies(), (size_t) 1); + thermo->setState_TP(350, 2*OneAtm); + // Regression tests based on XML + EXPECT_NEAR(thermo->density(), 973.7736331, 1e-6); + EXPECT_NEAR(thermo->enthalpy_mass(), -15649442.2898854, 1e-6); +}