[Test] Move tests for WaterPropsIAPWSphi to gtest suite

Remove test-related functions from the implementation.
This commit is contained in:
Ray Speth 2015-11-23 18:49:59 -05:00
parent 7562d79bad
commit 1cc0d42988
7 changed files with 49 additions and 112 deletions

View file

@ -71,12 +71,6 @@ public:
*/ */
doublereal phi_tt(doublereal tau, doublereal delta); doublereal phi_tt(doublereal tau, doublereal delta);
//! Internal check # 1
void check1();
//! Internal check # 2
void check2();
//! Calculate the dimensionless pressure at tau and delta; //! Calculate the dimensionless pressure at tau and delta;
/*! /*!
* pM/(rhoRT) = delta * phi_d() = 1.0 + delta phiR_d() * pM/(rhoRT) = delta * phi_d() = 1.0 + delta phiR_d()
@ -156,7 +150,7 @@ public:
*/ */
doublereal phiR() const; doublereal phiR() const;
private: protected:
//! Calculate Equation 6.5 for phi0, the ideal gas part of the //! Calculate Equation 6.5 for phi0, the ideal gas part of the
//! dimensionless Helmholtz free energy. //! dimensionless Helmholtz free energy.
doublereal phi0() const; doublereal phi0() const;
@ -183,15 +177,6 @@ private:
//! Calculate the mixed derivative d2_phi0/(dtau ddelta) //! Calculate the mixed derivative d2_phi0/(dtau ddelta)
doublereal phi0_dt() const; doublereal phi0_dt() const;
/**
* Calculates all of the functions at a one point and prints out the
* result. It's used for conducting the internal check.
*
* @param tau Dimensionless temperature = T_c/T
* @param delta Dimensionless density = delta = rho / Rho_c
*/
void intCheck(doublereal tau, doublereal delta);
//! Value of internally calculated polynomials of powers of TAU //! Value of internally calculated polynomials of powers of TAU
doublereal TAUp[52]; doublereal TAUp[52];

View file

@ -375,50 +375,6 @@ WaterPropsIAPWSphi::WaterPropsIAPWSphi() :
} }
} }
void WaterPropsIAPWSphi::intCheck(doublereal tau, doublereal delta)
{
tdpolycalc(tau, delta);
doublereal nau = phi0();
doublereal res = phiR();
doublereal res_d = phiR_d();
doublereal nau_d = phi0_d();
doublereal res_dd = phiR_dd();
doublereal nau_dd = phi0_dd();
doublereal res_t = phiR_t();
doublereal nau_t = phi0_t();
doublereal res_tt = phiR_tt();
doublereal nau_tt = phi0_tt();
doublereal res_dt = phiR_dt();
doublereal nau_dt = phi0_dt();
writelogf("nau = %20.12e\t\tres = %20.12e\n", nau, res);
writelogf("nau_d = %20.12e\t\tres_d = %20.12e\n", nau_d, res_d);
writelogf("nau_dd = %20.12e\t\tres_dd = %20.12e\n", nau_dd, res_dd);
writelogf("nau_t = %20.12e\t\tres_t = %20.12e\n", nau_t, res_t);
writelogf("nau_tt = %20.12e\t\tres_tt = %20.12e\n", nau_tt, res_tt);
writelogf("nau_dt = %20.12e\t\tres_dt = %20.12e\n", nau_dt, res_dt);
}
void WaterPropsIAPWSphi::check1()
{
doublereal T = 500.;
doublereal rho = 838.025;
doublereal tau = T_c/T;
doublereal delta = rho / Rho_c;
writelog(" T = 500 K, rho = 838.025 kg m-3\n");
intCheck(tau, delta);
}
void WaterPropsIAPWSphi::check2()
{
doublereal T = 647;
doublereal rho = 358.0;
doublereal tau = T_c/T;
doublereal delta = rho / Rho_c;
writelog(" T = 647 K, rho = 358.0 kg m-3\n");
intCheck(tau, delta);
}
void WaterPropsIAPWSphi::tdpolycalc(doublereal tau, doublereal delta) void WaterPropsIAPWSphi::tdpolycalc(doublereal tau, doublereal delta)
{ {
if ((tau != TAUsave) || 1) { if ((tau != TAUsave) || 1) {

View file

@ -0,0 +1,48 @@
#include "gtest/gtest.h"
#include "cantera/thermo/WaterPropsIAPWSphi.h"
using namespace Cantera;
const double T_c = 647.096;
const double Rho_c = 322.0;
class WaterPropsIAPWSphi_Test : public testing::Test, public WaterPropsIAPWSphi
{
};
// Test agreement with values given in Table 6.6 of: W. Wagner, A. Pruss, "The
// IAPWS Formulation 1995 for the Thermodynamic Properties of Ordinary Water
// Substance for General and Scientific Use," J. Phys. Chem. Ref. Dat, 31, 387,
// 2002.
TEST_F(WaterPropsIAPWSphi_Test, check1) {
tdpolycalc(T_c / 500.0, 838.025 / Rho_c);
EXPECT_NEAR(phi0(), 2.047977334796e+00, 1e-11);
EXPECT_NEAR(phiR(), -3.426932056816e+00, 1e-11);
EXPECT_NEAR(phi0_d(), 3.842367471137e-01, 1e-11);
EXPECT_NEAR(phiR_d(), -3.643666503639e-01, 1e-11);
EXPECT_NEAR(phi0_dd(), -1.476378778326e-01, 1e-11);
EXPECT_NEAR(phiR_dd(), 8.560637009746e-01, 1e-11);
EXPECT_NEAR(phi0_t(), 9.046111061752e+00, 1e-11);
EXPECT_NEAR(phiR_t(), -5.814034352384e+00, 1e-11);
EXPECT_NEAR(phi0_tt(), -1.932491850131e+00, 1e-11);
EXPECT_NEAR(phiR_tt(), -2.234407368843e+00, 1e-11);
EXPECT_NEAR(phi0_dt(), 0.000000000000e+00, 1e-11);
EXPECT_NEAR(phiR_dt(), -1.121769146703e+00, 1e-11);
}
TEST_F(WaterPropsIAPWSphi_Test, check2) {
tdpolycalc(T_c / 647.0, 358.0 / Rho_c);
EXPECT_NEAR(phi0(), -1.563196050525e+00, 1e-11);
EXPECT_NEAR(phiR(), -1.212026565041e+00, 1e-11);
EXPECT_NEAR(phi0_d(), 8.994413407821e-01, 1e-11);
EXPECT_NEAR(phiR_d(), -7.140120243713e-01, 1e-11);
EXPECT_NEAR(phi0_dd(), -8.089947255079e-01, 1e-11);
EXPECT_NEAR(phiR_dd(), 4.757306956457e-01, 1e-11);
EXPECT_NEAR(phi0_t(), 9.803439179390e+00, 1e-11);
EXPECT_NEAR(phiR_t(), -3.217225007752e+00, 1e-11);
EXPECT_NEAR(phi0_tt(), -3.433163341431e+00, 1e-11);
EXPECT_NEAR(phiR_tt(), -9.960295065593e+00, 1e-11);
EXPECT_NEAR(phi0_dt(), 0.000000000000e+00, 1e-11);
EXPECT_NEAR(phiR_dt(), -1.332147204361e+00, 1e-11);
}

View file

@ -203,8 +203,6 @@ CompileAndTest('IMSTester', 'cathermo/ims', 'IMSTester', 'output_blessed.txt')
CompileAndTest('ISSPTester', 'cathermo/issp', 'ISSPTester', 'output_blessed.txt') CompileAndTest('ISSPTester', 'cathermo/issp', 'ISSPTester', 'output_blessed.txt')
CompileAndTest('stoichSub', 'cathermo/stoichSub', CompileAndTest('stoichSub', 'cathermo/stoichSub',
'stoichSub', 'output_blessed.txt') 'stoichSub', 'output_blessed.txt')
CompileAndTest('IAPWSphi', 'cathermo/testIAPWS',
'testIAPWSphi', 'output_blessed.txt')
CompileAndTest('IAPWSPres', 'cathermo/testIAPWSPres', CompileAndTest('IAPWSPres', 'cathermo/testIAPWSPres',
'testIAPWSPres', 'output_blessed.txt') 'testIAPWSPres', 'output_blessed.txt')
CompileAndTest('IAPWSTripP', 'cathermo/testIAPWSTripP', CompileAndTest('IAPWSTripP', 'cathermo/testIAPWSTripP',

View file

@ -1,15 +0,0 @@
This test is used to make sure that the basic functions in
the water property routine satisfies the derivative 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.
On page 436 of that reference, value for phi, the nondimensional
helmholtz free energy and its first and second derivatives,
are given at 2 representative points. This test makes sure
that the values agree with the paper's values.

View file

@ -1,14 +0,0 @@
T = 500 K, rho = 838.025 kg m-3
nau = 2.047977334796e+00 res = -3.426932056816e+00
nau_d = 3.842367471137e-01 res_d = -3.643666503639e-01
nau_dd = -1.476378778326e-01 res_dd = 8.560637009746e-01
nau_t = 9.046111061752e+00 res_t = -5.814034352384e+00
nau_tt = -1.932491850131e+00 res_tt = -2.234407368843e+00
nau_dt = 0.000000000000e+00 res_dt = -1.121769146703e+00
T = 647 K, rho = 358.0 kg m-3
nau = -1.563196050525e+00 res = -1.212026565041e+00
nau_d = 8.994413407821e-01 res_d = -7.140120243713e-01
nau_dd = -8.089947255079e-01 res_dd = 4.757306956457e-01
nau_t = 9.803439179390e+00 res_t = -3.217225007752e+00
nau_tt = -3.433163341431e+00 res_tt = -9.960295065593e+00
nau_dt = 0.000000000000e+00 res_dt = -1.332147204361e+00

View file

@ -1,21 +0,0 @@
#include "cantera/thermo/WaterPropsIAPWSphi.h"
#include <new>
#include <cstdio>
using namespace std;
using namespace Cantera;
int main()
{
#if defined(_MSC_VER) && _MSC_VER < 1900
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
WaterPropsIAPWSphi* phi = new WaterPropsIAPWSphi();
phi->check1();
phi->check2();
delete phi;
return 0;
}