[Transport] Migrate wtWater test to GTest test suite

This commit is contained in:
Ray Speth 2018-08-28 23:50:36 -04:00
parent b0deb41708
commit ff4958a720
4 changed files with 52 additions and 117 deletions

View file

@ -0,0 +1,52 @@
#include "gtest/gtest.h"
#include "cantera/transport/TransportFactory.h"
#include "cantera/thermo/ThermoFactory.h"
using namespace Cantera;
class WaterTransportTest : public testing::Test
{
public:
WaterTransportTest() {
phase = newPhase("liquid-water.xml");
tran = newDefaultTransportMgr(phase);
}
void check_viscosity(double T, double P, double mu_expected) {
phase->setState_TP(T + 273.15, P);
EXPECT_NEAR(tran->viscosity(), mu_expected, 2e-7);
}
void check_thermal_conductivity(double T, double P, double lambda_expected) {
phase->setState_TP(T + 273.15, P);
EXPECT_NEAR(tran->thermalConductivity(), lambda_expected, 3e-4);
}
ThermoPhase* phase;
Transport* tran;
};
// Reference values taken from tables in the Sengers and Watson paper
// (doi:10.1063/1.555763) which is the source of the interpolating equations.
TEST_F(WaterTransportTest, viscosity)
{
check_viscosity(25, 1e5, 890.5e-6);
check_viscosity(100, 5e5, 281.9e-6);
check_viscosity(100, 1e7, 284.5e-6);
check_viscosity(250, 5e6, 106.4e-6);
check_viscosity(250, 5e7, 117.5e-6);
check_viscosity(350, 1.75e7, 67.0e-6);
check_viscosity(400, 1.5e7, 24.93e-6);
}
TEST_F(WaterTransportTest, thermal_conductivity)
{
check_thermal_conductivity(25, 1e5, 0.6072);
check_thermal_conductivity(100, 5e5, 0.6793);
check_thermal_conductivity(100, 1e7, 0.6845);
check_thermal_conductivity(250, 5e6, 0.6227);
check_thermal_conductivity(250, 5e7, 0.6721);
check_thermal_conductivity(350, 1.75e7, 0.4523);
check_thermal_conductivity(400, 1.5e7, 0.08068);
}

View file

@ -217,8 +217,6 @@ CompileAndTest('WaterSSTP', 'cathermo/testWaterTP',
'testWaterSSTP', 'output_blessed.txt')
CompileAndTest('ISSPTester2', 'cathermo/VPissp',
'ISSPTester2', 'output_blessed.txt')
CompileAndTest('wtWater', 'cathermo/wtWater',
'wtWater', 'output_blessed.txt')
CompileAndTest('ChemEquil_ionizedGas',
'ChemEquil_ionizedGas', 'ionizedGasEquil',
'output_blessed.txt',

View file

@ -1,12 +0,0 @@
------------------------------------------------------------------------------------
T(C) MPa Phase Visc Visc(paper) lambda lambda(paper)
10-6 kg/m/s 10-3 W/m/s
------------------------------------------------------------------------------------
25 0.1 L 890.5 890.5 607.2 607.2
100 0.1 L 281.8 281.9 679.1 679.1
100 10 L 284.457 284.5 684.47 684.5
250 5 L 106.405 106.4 622.487 622.7
250 50 L 117.43 117.5 671.917 672.1
350 17.5 L 66.9916 67.0 452.197 452.3
400 15 SC 24.9278 24.93 80.6816 80.68
---------------------------------------------------------------------------------

View file

@ -1,103 +0,0 @@
#include "cantera/thermo/ThermoFactory.h"
#include "cantera/transport/TransportFactory.h"
#include <cstdio>
using namespace std;
using namespace Cantera;
double tvalue(double val, double atol = 1.0E-9)
{
double rval = val;
if (fabs(val) < atol) {
rval = 0.0;
}
return rval;
}
int main()
{
try {
double lambda;
ThermoPhase* w = newPhase("liquid-water.xml");
Transport* wtTran = newDefaultTransportMgr(w);
printf("------------------------------------------------------------------------------------\n");
printf(" T(C) MPa Phase Visc Visc(paper) lambda lambda(paper)\n");
printf(" 10-6 kg/m/s 10-3 W/m/s \n");
printf("------------------------------------------------------------------------------------\n");
double T = 273.15 + 25.0;
double pres = 1.0E5;
w->setState_TP(T, pres);
double visc = wtTran->viscosity();
lambda = wtTran->thermalConductivity();
printf("%8g %10.3g L %13.4g 890.5 %13.4g 607.2\n",
T - 273.15, pres * 1.0E-6, visc * 1.0E6, lambda * 1.0E3);
T = 273.15 + 100.0;
pres = 1.0E5;
w->setState_TP(T, pres);
visc = wtTran->viscosity();
lambda = wtTran->thermalConductivity();
printf("%8g %10.3g L %13.4g 281.9 %13.4g 679.1\n",
T - 273.15, pres * 1.0E-6, visc * 1.0E6, lambda * 1.0E3);
T = 273.15 + 100.0;
pres = 1.0E7;
w->setState_TP(T, pres);
visc = wtTran->viscosity();
lambda = wtTran->thermalConductivity();
printf("%8g %10.3g L %13.6g 284.5 %13.6g 684.5\n",
T - 273.15, pres * 1.0E-6, visc * 1.0E6, lambda * 1.0E3);
T = 273.15 + 250.0;
pres = 5.0E6;
w->setState_TP(T, pres);
visc = wtTran->viscosity();
lambda = wtTran->thermalConductivity();
printf("%8g %10.3g L %13.6g 106.4 %13.6g 622.7\n",
T - 273.15, pres * 1.0E-6, visc * 1.0E6, lambda * 1.0E3);
T = 273.15 + 250.0;
pres = 5.0E7;
w->setState_TP(T, pres);
visc = wtTran->viscosity();
lambda = wtTran->thermalConductivity();
printf("%8g %10.3g L %13.6g 117.5 %13.6g 672.1\n",
T - 273.15, pres * 1.0E-6, visc * 1.0E6, lambda * 1.0E3);
T = 273.15 + 350.0;
pres = 1.75E7;
w->setState_TP(T, pres);
visc = wtTran->viscosity();
lambda = wtTran->thermalConductivity();
printf("%8g %10.3g L %13.6g 67.0 %13.6g 452.3\n",
T - 273.15, pres * 1.0E-6, visc * 1.0E6, lambda * 1.0E3);
T = 273.15 + 400.0;
pres = 1.50E7;
w->setState_TP(T, pres);
visc = wtTran->viscosity();
lambda = wtTran->thermalConductivity();
printf("%8g %10.3g SC %13.6g 24.93 %13.6g 80.68\n",
T - 273.15, pres * 1.0E-6, visc * 1.0E6, lambda * 1.0E3);
printf("---------------------------------------------------------------------------------\n");
delete w;
} catch (CanteraError& err) {
std::cout << err.what() << std::endl;
Cantera::appdelete();
return -1;
}
return 0;
}