[Test] Move testIAPWSPres into the gtest suite
This commit is contained in:
parent
61a457121a
commit
a75a8f2c82
5 changed files with 60 additions and 220 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include "gtest/gtest.h"
|
||||
#include "cantera/base/ct_defs.h"
|
||||
#include "cantera/thermo/WaterPropsIAPWSphi.h"
|
||||
#include "cantera/thermo/WaterPropsIAPWS.h"
|
||||
|
||||
|
|
@ -51,6 +52,16 @@ TEST_F(WaterPropsIAPWSphi_Test, check2) {
|
|||
class WaterPropsIAPWS_Test : public testing::Test
|
||||
{
|
||||
public:
|
||||
double dPdT(double T, double P) {
|
||||
double rho = water.density(T, P);
|
||||
water.setState_TR(T, rho);
|
||||
double P1 = water.pressure();
|
||||
double T2 = T + 0.001;
|
||||
water.setState_TR(T2, rho);
|
||||
double P2 = water.pressure();
|
||||
return (P2 - P1) / 0.001;
|
||||
}
|
||||
|
||||
WaterPropsIAPWS water;
|
||||
};
|
||||
|
||||
|
|
@ -81,3 +92,52 @@ TEST_F(WaterPropsIAPWS_Test, triple_point_gas)
|
|||
EXPECT_NEAR(water.cv(), 25552.6, 2e-1);
|
||||
EXPECT_NEAR(water.cp(), 33947.1, 2e-1);
|
||||
}
|
||||
|
||||
TEST_F(WaterPropsIAPWS_Test, normal_boiling_point)
|
||||
{
|
||||
double T = 373.124;
|
||||
double P = water.psat(T);
|
||||
EXPECT_NEAR(P, 101324., 1e0);
|
||||
double rho = water.density(T, P, WATER_LIQUID);
|
||||
EXPECT_NEAR(rho, 958.368, 2e-3);
|
||||
EXPECT_NEAR(water.isothermalCompressibility(), 4.901779037782e-10, 2e-21);
|
||||
|
||||
water.density(T, 1.001 * P, WATER_LIQUID);
|
||||
EXPECT_NEAR(water.isothermalCompressibility(), 4.901777340771e-10, 2e-21);
|
||||
|
||||
rho = water.density(T, P, WATER_GAS);
|
||||
EXPECT_NEAR(rho, 0.597651, 2e-6);
|
||||
EXPECT_NEAR(water.isothermalCompressibility(), 1.003322591472e-05, 2e-17);
|
||||
|
||||
rho = water.density(T, P * 0.999, WATER_GAS);
|
||||
EXPECT_NEAR(rho, 0.597043, 2e-6);
|
||||
EXPECT_NEAR(water.isothermalCompressibility(), 1.004308000545e-05, 2e-17);
|
||||
}
|
||||
|
||||
TEST_F(WaterPropsIAPWS_Test, saturation_pressure_estimate)
|
||||
{
|
||||
vector_fp TT{273.15, 313.9999, 314.0001, 373.15, 647.25};
|
||||
vector_fp psat{611.212, 7722.3, 7675.46, 101007, 2.2093e+07};
|
||||
|
||||
for (size_t i = 0; i < TT.size(); i++) {
|
||||
double P = water.psat_est(TT[i]);
|
||||
EXPECT_NEAR(P, psat[i], 2e-6 * psat[i]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(WaterPropsIAPWS_Test, expansion_coeffs)
|
||||
{
|
||||
vector_fp TT{300.0, 300.0, 700.0};
|
||||
vector_fp PP{10.0, 10.0e6, 10.0e6};
|
||||
vector_fp alpha{0.003333433139236, -0.02277763412159, 0.002346416555069};
|
||||
vector_fp beta{1.000020308917, 1265.572840683, 1.240519813089};
|
||||
vector_fp beta_num{1.0000203087, 1265.46651311, 1.240519294};
|
||||
for (size_t i = 0; i < TT.size(); i++) {
|
||||
double rho = water.density(TT[i], PP[i], WATER_GAS);
|
||||
water.setState_TR(TT[i], rho);
|
||||
EXPECT_NEAR(water.coeffThermExp(), alpha[i], 2e-14);
|
||||
EXPECT_NEAR(water.coeffPresExp(), beta[i], beta[i] * 2e-12);
|
||||
EXPECT_NEAR(dPdT(TT[i], PP[i]) * 18.015268 / (8.314371E3 * rho),
|
||||
beta_num[i], 2e-10 * beta_num[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,8 +203,6 @@ CompileAndTest('IMSTester', 'cathermo/ims', 'IMSTester', 'output_blessed.txt')
|
|||
CompileAndTest('ISSPTester', 'cathermo/issp', 'ISSPTester', 'output_blessed.txt')
|
||||
CompileAndTest('stoichSub', 'cathermo/stoichSub',
|
||||
'stoichSub', 'output_blessed.txt')
|
||||
CompileAndTest('IAPWSPres', 'cathermo/testIAPWSPres',
|
||||
'testIAPWSPres', 'output_blessed.txt')
|
||||
CompileAndTest('WaterPDSS', 'cathermo/testWaterPDSS',
|
||||
'testWaterPDSS', 'output_blessed.txt')
|
||||
CompileAndTest('WaterSSTP', 'cathermo/testWaterTP',
|
||||
|
|
|
|||
|
|
@ -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 saturation pressure routine.
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
pres = 10107
|
||||
psat(273.16) = 611.655
|
||||
dens (liquid) = 999.793 kg m-3
|
||||
intEng (liquid) = 4.77857e-09 J/kmol
|
||||
S (liquid) = 8.86157e-11 J/kmolK
|
||||
h (liquid) = 11.0214 J/kmol
|
||||
h (liquid) = 0.611782 J/kg
|
||||
dens (gas) = 0.00485458 kg m-3
|
||||
psat(373.124) = 101324
|
||||
dens (liquid) = 958.368 kg m-3
|
||||
kappa (liquid) = 4.901779037782e-10 kg m-3
|
||||
kappa (liquid) = 4.901777340771e-10 kg m-3
|
||||
dens (gas) = 0.597651 kg m-3
|
||||
kappa (gas) = 1.003322591472e-05 kg m-3
|
||||
dens (gas) = 0.597043 kg m-3
|
||||
kappa (gas) = 1.004308000545e-05 kg m-3
|
||||
psat_est(273.15) = 611.212
|
||||
psat_est(314) = 7722.3
|
||||
psat_est(314) = 7675.46
|
||||
psat_est(373.15) = 101007
|
||||
psat_est(647.25) = 2.2093e+07
|
||||
beta = 1.000020308917
|
||||
betaNum = 1.0000203087
|
||||
alpha = 0.003333433139236
|
||||
beta = 1265.572840683
|
||||
betaNum = 1265.46651311
|
||||
alpha = -0.02354957776458
|
||||
beta = 1.240519813089
|
||||
betaNum = 1.240519294
|
||||
alpha = 0.002346416555069
|
||||
|
|
@ -1,177 +0,0 @@
|
|||
|
||||
#include "cantera/thermo/WaterPropsIAPWS.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
|
||||
using namespace std;
|
||||
using namespace Cantera;
|
||||
|
||||
double numdpdt(WaterPropsIAPWS* water, double T, double pres)
|
||||
{
|
||||
double rho = water->density(T, pres);
|
||||
water->setState_TR(T, rho);
|
||||
double presB = water->pressure();
|
||||
double Td = T + 0.001;
|
||||
water->setState_TR(Td, rho);
|
||||
double presd = water->pressure();
|
||||
return (presd - presB) / 0.001;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
_set_output_format(_TWO_DIGIT_EXPONENT);
|
||||
#endif
|
||||
double dens, u, s, h;
|
||||
WaterPropsIAPWS* water = new WaterPropsIAPWS();
|
||||
|
||||
double T = 273.15 + 100.;
|
||||
double rho = 10125. * 18.01 / (8.314472E3 * T);
|
||||
|
||||
water->setState_TR(T, rho);
|
||||
double pres = water->pressure();
|
||||
printf("pres = %g\n", pres);
|
||||
|
||||
/*
|
||||
* 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();
|
||||
printf("intEng (liquid) = %.6f J/kmol\n", u);
|
||||
|
||||
s = water->entropy();
|
||||
printf("S (liquid) = %.6f 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);
|
||||
|
||||
|
||||
dens = water->density(T, pres, WATER_GAS);
|
||||
printf("dens (gas) = %g kg m-3\n", dens);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Print out the normal boiling point conditions
|
||||
*/
|
||||
T = 373.124;
|
||||
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);
|
||||
|
||||
double kappa = water->isothermalCompressibility();
|
||||
printf("kappa (liquid) = %20.13g kg m-3 \n", kappa);
|
||||
|
||||
double pres2 = pres * 1.001;
|
||||
dens = water->density(T, pres2, WATER_LIQUID);
|
||||
kappa = water->isothermalCompressibility();
|
||||
printf("kappa (liquid) = %20.13g kg m-3 \n", kappa);
|
||||
|
||||
dens = water->density(T, pres, WATER_GAS);
|
||||
printf("dens (gas) = %g kg m-3\n", dens);
|
||||
|
||||
kappa = water->isothermalCompressibility();
|
||||
printf("kappa (gas) = %20.13g kg m-3 \n", kappa);
|
||||
|
||||
pres2 = pres * (0.999);
|
||||
dens = water->density(T, pres2, WATER_GAS);
|
||||
printf("dens (gas) = %g kg m-3\n", dens);
|
||||
|
||||
kappa = water->isothermalCompressibility();
|
||||
printf("kappa (gas) = %20.13g kg m-3 \n", kappa);
|
||||
|
||||
/*
|
||||
* Calculate a few test points for the estimated
|
||||
* saturation pressure function
|
||||
*/
|
||||
T = 273.15 + 0.;
|
||||
pres = water->psat_est(T);
|
||||
printf("psat_est(%g) = %g\n", T, pres);
|
||||
|
||||
T = 313.9999;
|
||||
pres = water->psat_est(T);
|
||||
printf("psat_est(%g) = %g\n", T, pres);
|
||||
|
||||
T = 314.0001;
|
||||
pres = water->psat_est(T);
|
||||
printf("psat_est(%g) = %g\n", T, pres);
|
||||
|
||||
T = 273.15 + 100.;
|
||||
pres = water->psat_est(T);
|
||||
printf("psat_est(%g) = %g\n", T, pres);
|
||||
|
||||
T = 647.25;
|
||||
pres = water->psat_est(T);
|
||||
printf("psat_est(%g) = %g\n", T, pres);
|
||||
|
||||
|
||||
T = 300;
|
||||
pres = 10.;
|
||||
rho = water->density(T, pres, WATER_GAS);
|
||||
water->setState_TR(T, rho);
|
||||
double beta = water->coeffPresExp();
|
||||
|
||||
printf("beta = %20.13g\n", beta);
|
||||
|
||||
|
||||
double dpdt = numdpdt(water, T, pres);
|
||||
|
||||
rho = water->density(T,pres);
|
||||
double betaNum = dpdt * 18.015268 /(8.314371E3 * rho);
|
||||
printf("betaNum = %20.11g\n", betaNum);
|
||||
|
||||
double alpha = water->coeffThermExp();
|
||||
printf("alpha = %20.13g\n", alpha);
|
||||
|
||||
|
||||
T = 300;
|
||||
pres = 10.E6;
|
||||
rho = water->density(T, pres, WATER_GAS);
|
||||
water->setState_TR(T, rho);
|
||||
beta = water->coeffPresExp();
|
||||
|
||||
printf("beta = %20.13g\n", beta);
|
||||
|
||||
|
||||
dpdt = numdpdt(water, T, pres);
|
||||
|
||||
rho = water->density(T,pres);
|
||||
betaNum = dpdt * 18.015268 /(8.314371E3 * rho);
|
||||
|
||||
printf("betaNum = %20.12g\n", betaNum);
|
||||
|
||||
alpha = water->coeffThermExp();
|
||||
printf("alpha = %20.13g\n", alpha);
|
||||
|
||||
T = 700;
|
||||
pres = 10.E6;
|
||||
rho = water->density(T, pres, WATER_GAS);
|
||||
water->setState_TR(T, rho);
|
||||
beta = water->coeffPresExp();
|
||||
|
||||
printf("beta = %20.13g\n", beta);
|
||||
|
||||
|
||||
dpdt = numdpdt(water, T, pres);
|
||||
|
||||
rho = water->density(T,pres);
|
||||
betaNum = dpdt * 18.015268 /(8.314371E3 * rho);
|
||||
|
||||
printf("betaNum = %20.10g\n", betaNum);
|
||||
|
||||
alpha = water->coeffThermExp();
|
||||
printf("alpha = %20.13g\n", alpha);
|
||||
|
||||
delete water;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue