From 61a457121aaf5c64027e6776a85edb84947930da Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 23 Nov 2015 19:18:24 -0500 Subject: [PATCH] [Test] Move testIAPWSTripP into the gtest suite --- test/thermo/water_iapws.cpp | 35 +++++++ test_problems/SConscript | 2 - test_problems/cathermo/testIAPWSTripP/README | 11 --- .../testIAPWSTripP/output_blessed.txt | 19 ---- .../cathermo/testIAPWSTripP/testTripleP.cpp | 92 ------------------- 5 files changed, 35 insertions(+), 124 deletions(-) delete mode 100644 test_problems/cathermo/testIAPWSTripP/README delete mode 100644 test_problems/cathermo/testIAPWSTripP/output_blessed.txt delete mode 100644 test_problems/cathermo/testIAPWSTripP/testTripleP.cpp diff --git a/test/thermo/water_iapws.cpp b/test/thermo/water_iapws.cpp index 0ad24d079e..19ed58b3d5 100644 --- a/test/thermo/water_iapws.cpp +++ b/test/thermo/water_iapws.cpp @@ -1,5 +1,6 @@ #include "gtest/gtest.h" #include "cantera/thermo/WaterPropsIAPWSphi.h" +#include "cantera/thermo/WaterPropsIAPWS.h" using namespace Cantera; @@ -46,3 +47,37 @@ TEST_F(WaterPropsIAPWSphi_Test, check2) { EXPECT_NEAR(phi0_dt(), 0.000000000000e+00, 1e-11); EXPECT_NEAR(phiR_dt(), -1.332147204361e+00, 1e-11); } + +class WaterPropsIAPWS_Test : public testing::Test +{ +public: + WaterPropsIAPWS water; +}; + +// See values on p. 395 of Wagner & Pruss. +TEST_F(WaterPropsIAPWS_Test, triple_point_liquid) +{ + double T = 273.16; + double pres = water.psat(T); + EXPECT_NEAR(pres, 611.655, 2e-3); + EXPECT_NEAR(water.density(T, pres, WATER_LIQUID), 999.793, 2e-3); + EXPECT_NEAR(water.intEnergy(), 0.0, 5e-7); + EXPECT_NEAR(water.entropy(), 0.0, 5e-9); + EXPECT_NEAR(water.enthalpy(), 11.0214, 2e-4); + EXPECT_NEAR(water.Gibbs(), 11.0214, 2e-4); + EXPECT_NEAR(water.cv(), 75978.2, 2e-1); + EXPECT_NEAR(water.cp(), 76022.8, 2e-1); +} + +TEST_F(WaterPropsIAPWS_Test, triple_point_gas) +{ + double T = 273.16; + double pres = water.psat(T); + EXPECT_NEAR(water.density(T, pres, WATER_GAS), 4.85458e-3, 2e-8); + EXPECT_NEAR(water.intEnergy(), 4.27848e7, 2e2); + EXPECT_NEAR(water.entropy(), 164939., 2e0); + EXPECT_NEAR(water.enthalpy(), 4.50547e7, 2e2); + EXPECT_NEAR(water.Gibbs(), 11.0214, 2e-4); + EXPECT_NEAR(water.cv(), 25552.6, 2e-1); + EXPECT_NEAR(water.cp(), 33947.1, 2e-1); +} diff --git a/test_problems/SConscript b/test_problems/SConscript index a712094d69..153b21d5b7 100644 --- a/test_problems/SConscript +++ b/test_problems/SConscript @@ -205,8 +205,6 @@ CompileAndTest('stoichSub', 'cathermo/stoichSub', 'stoichSub', 'output_blessed.txt') CompileAndTest('IAPWSPres', 'cathermo/testIAPWSPres', 'testIAPWSPres', 'output_blessed.txt') -CompileAndTest('IAPWSTripP', 'cathermo/testIAPWSTripP', - 'testIAPWSTripP', 'output_blessed.txt') CompileAndTest('WaterPDSS', 'cathermo/testWaterPDSS', 'testWaterPDSS', 'output_blessed.txt') CompileAndTest('WaterSSTP', 'cathermo/testWaterTP', diff --git a/test_problems/cathermo/testIAPWSTripP/README b/test_problems/cathermo/testIAPWSTripP/README deleted file mode 100644 index b963c19747..0000000000 --- a/test_problems/cathermo/testIAPWSTripP/README +++ /dev/null @@ -1,11 +0,0 @@ - -This test is used to make sure that the basic functions in -the water property routine satisfy tests -specified in the paper: - -W. Wagner, A. Prub, "The IAPWS Formulation 1995 for the -Thermodynamic Properties of Ordinary Water Substance -for General and Scientific Use," J. Phys. Chem. -Ref. Data, v. 31, 387 - 442, 2002. - -This routine exercises the calculation of triple point thermo properties. diff --git a/test_problems/cathermo/testIAPWSTripP/output_blessed.txt b/test_problems/cathermo/testIAPWSTripP/output_blessed.txt deleted file mode 100644 index 62cf72cad4..0000000000 --- a/test_problems/cathermo/testIAPWSTripP/output_blessed.txt +++ /dev/null @@ -1,19 +0,0 @@ -psat(273.16) = 611.655 -dens (liquid) = 999.793 kg m-3 -intEng (liquid) = ~0.0 J/kmol (fabs(u) < 5.0E-7) -S (liquid) = ~0.0 J/kmolK (fabs(s) < 5.0E-9) -h (liquid) = 11.0214 J/kmol -h (liquid) = 0.611782 J/kg -g (liquid) = 11.0214 J/kmol -cv (liquid) = 75978.2 J/kmolK -cp (liquid) = 76022.8 J/kmolK -dens (gas) = 0.00485458 kg m-3 -intEng (gas) = 4.27848e+07 J/kmol -S (gas) = 164939 J/kmolK -h (gas) = 4.50547e+07 J/kmol -h (gas) = 2.50092e+06 J/kg -g (gas) = 11.0214 J/kmol -cv (gas) = 25552.6 J/kmolK -cp (gas) = 33947.1 J/kmolK - -Delta g = ~0.0 J/kmol ( < 1.0E-5) diff --git a/test_problems/cathermo/testIAPWSTripP/testTripleP.cpp b/test_problems/cathermo/testIAPWSTripP/testTripleP.cpp deleted file mode 100644 index 93ff4d25be..0000000000 --- a/test_problems/cathermo/testIAPWSTripP/testTripleP.cpp +++ /dev/null @@ -1,92 +0,0 @@ - -#include "cantera/thermo/WaterPropsIAPWS.h" - -#include -#include - -using namespace std; -using namespace Cantera; - -int main() -{ -#if defined(_MSC_VER) && _MSC_VER < 1900 - _set_output_format(_TWO_DIGIT_EXPONENT); -#endif - double dens, u, s, h, cv, cp, pres; - WaterPropsIAPWS* water = new WaterPropsIAPWS(); - - double T; - - /* - * Print out the triple point conditions - */ - T = 273.16; - pres = water->psat(T); - printf("psat(%g) = %g\n", T, pres); - - dens = water->density(T, pres, WATER_LIQUID); - printf("dens (liquid) = %g kg m-3\n", dens); - - u = water->intEnergy(); - if (fabs(u) < 5.0E-7) { - printf("intEng (liquid) = ~0.0 J/kmol (fabs(u) < 5.0E-7)\n"); - } else { - printf("intEng (liquid) = %g J/kmol\n", u); - } - - s = water->entropy(); - if (fabs(s) < 5.0E-9) { - printf("S (liquid) = ~0.0 J/kmolK (fabs(s) < 5.0E-9)\n"); - } else { - printf("S (liquid) = %g J/kmolK\n", s); - } - - h = water->enthalpy(); - printf("h (liquid) = %g J/kmol\n", h); - printf("h (liquid) = %g J/kg\n", (h)/18.015268); - - double g_liq = water->Gibbs(); - printf("g (liquid) = %g J/kmol\n", g_liq); - - - cv = water->cv(); - printf("cv (liquid) = %g J/kmolK\n", cv); - - cp = water->cp(); - printf("cp (liquid) = %g J/kmolK\n", cp); - - - dens = water->density(T, pres, WATER_GAS); - printf("dens (gas) = %g kg m-3\n", dens); - - - u = water->intEnergy(); - printf("intEng (gas) = %g J/kmol\n", u); - - s = water->entropy(); - printf("S (gas) = %g J/kmolK\n", s); - - h = water->enthalpy(); - printf("h (gas) = %g J/kmol\n", h); - printf("h (gas) = %g J/kg\n", (h)/18.015268); - - double g_gas = water->Gibbs(); - printf("g (gas) = %g J/kmol\n", g_gas); - - - cv = water->cv(); - printf("cv (gas) = %g J/kmolK\n", cv); - - cp = water->cp(); - printf("cp (gas) = %g J/kmolK\n", cp); - - printf("\n"); - double deltaG = g_liq - g_gas; - if (fabs(deltaG) < 1.0E-5) { - printf("Delta g = ~0.0 J/kmol ( < 1.0E-5)\n"); - } else { - printf("Delta g = %g J/kmol\n", g_liq - g_gas); - } - delete water; - return 0; -}