Skip to content

Commit

Permalink
[Test] Move tests for WaterPropsIAPWSphi to gtest suite
Browse files Browse the repository at this point in the history
Remove test-related functions from the implementation.
  • Loading branch information
speth committed Nov 24, 2015
1 parent 7562d79 commit 1cc0d42
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 112 deletions.
17 changes: 1 addition & 16 deletions include/cantera/thermo/WaterPropsIAPWSphi.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ class WaterPropsIAPWSphi
*/
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;
/*!
* pM/(rhoRT) = delta * phi_d() = 1.0 + delta phiR_d()
Expand Down Expand Up @@ -156,7 +150,7 @@ class WaterPropsIAPWSphi
*/
doublereal phiR() const;

private:
protected:
//! Calculate Equation 6.5 for phi0, the ideal gas part of the
//! dimensionless Helmholtz free energy.
doublereal phi0() const;
Expand All @@ -183,15 +177,6 @@ class WaterPropsIAPWSphi
//! Calculate the mixed derivative d2_phi0/(dtau ddelta)
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
doublereal TAUp[52];

Expand Down
44 changes: 0 additions & 44 deletions src/thermo/WaterPropsIAPWSphi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
if ((tau != TAUsave) || 1) {
Expand Down
48 changes: 48 additions & 0 deletions test/thermo/water_iapws.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 0 additions & 2 deletions test_problems/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -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('IAPWSphi', 'cathermo/testIAPWS',
'testIAPWSphi', 'output_blessed.txt')
CompileAndTest('IAPWSPres', 'cathermo/testIAPWSPres',
'testIAPWSPres', 'output_blessed.txt')
CompileAndTest('IAPWSTripP', 'cathermo/testIAPWSTripP',
Expand Down
15 changes: 0 additions & 15 deletions test_problems/cathermo/testIAPWS/README

This file was deleted.

14 changes: 0 additions & 14 deletions test_problems/cathermo/testIAPWS/output_blessed.txt

This file was deleted.

21 changes: 0 additions & 21 deletions test_problems/cathermo/testIAPWS/testIAPWSphi.cpp

This file was deleted.

0 comments on commit 1cc0d42

Please sign in to comment.