Added a test for WaterTP

This commit is contained in:
Harry Moffat
2006-07-04 01:11:35 +00:00
parent d311f84913
commit 455c1249b4
8 changed files with 409 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ ifeq ($(test_electrolytes),1)
cd testIAPWSPres; @MAKE@ all
cd testIAPWSTripP; @MAKE@ all
cd testWaterPDSS; @MAKE@ all
cd testWaterTP; @MAKE@ all
endif
test:
@@ -29,6 +30,7 @@ ifeq ($(test_electrolytes),1)
cd testIAPWSPres; @MAKE@ test
cd testIAPWSTripP; @MAKE@ test
cd testWaterPDSS; @MAKE@ test
cd testWaterTP; @MAKE@ test
endif
clean:
@@ -39,6 +41,7 @@ clean:
cd testIAPWSPres; @MAKE@ clean
cd testIAPWSTripP; @MAKE@ clean
cd testWaterPDSS; @MAKE@ clean
cd testWaterTP; @MAKE@ clean
depends:
ifeq ($(test_issp),1)
@@ -50,4 +53,5 @@ ifeq ($(test_electrolytes),1)
cd testIAPWSPres; @MAKE@ depends
cd testIAPWSTripP; @MAKE@ depends
cd testWaterPDSS; @MAKE@ depends
cd testWaterTP; @MAKE@ depends
endif

View File

@@ -0,0 +1,11 @@
testIAPWSphi
Makefile
output.txt
outputa.txt
*.d
.depends
csvCode.txt
diff_test.out
test.diff
test.out
testWaterTP

View File

@@ -0,0 +1,112 @@
#!/bin/sh
############################################################################
#
# Makefile to compile and link a C++ application to
# Cantera.
#
#############################################################################
# addition to suffixes
.SUFFIXES : .d
# the name of the executable program to be created
PROG_NAME = testWaterTP
# the object files to be linked together. List those generated from Fortran
# and from C/C++ separately
OBJS = testWaterTP.o
# Location of the current build. Will assume that tests are run
# in the source directory tree location
src_dir_tree = 1
# additional flags to be passed to the linker. If your program
# requires other external libraries, put them here
LINK_OPTIONS = @EXTRA_LINK@
#############################################################################
# Check to see whether we are in the msvc++ environment
os_is_win = @OS_IS_WIN@
# Fortran libraries
FORT_LIBS = @FLIBS@
# the C++ compiler
CXX = @CXX@
# C++ compile flags
ifeq ($(src_dir_tree), 1)
CXX_FLAGS = -DSRCDIRTREE @CXXFLAGS@
else
CXX_FLAGS = @CXXFLAGS@
endif
# Ending C++ linking libraries
LCXX_END_LIBS = @LCXX_END_LIBS@
# the directory where the Cantera libraries are located
CANTERA_LIBDIR=@buildlib@
# required Cantera libraries
CANTERA_LIBS = @LOCAL_LIBS@ -lctcxx
# the directory where Cantera include files may be found.
ifeq ($(src_dir_tree), 1)
CANTERA_INCDIR=../../../Cantera/src
INCLUDES=-I$(CANTERA_INCDIR) -I$(CANTERA_INCDIR)/thermo
else
CANTERA_INCDIR=@ctroot@/build/include/cantera
INCLUDES=-I$(CANTERA_INCDIR) -I$(CANTERA_INCDIR)/kernel
endif
# flags passed to the C++ compiler/linker for the linking step
LCXX_FLAGS = -L$(CANTERA_LIBDIR) @LOCAL_LIB_DIRS@ @CXXFLAGS@
# How to compile C++ source files to object files
.@CXX_EXT@.@OBJ_EXT@:
$(CXX) -c $< $(INCLUDES) $(CXX_FLAGS)
# How to compile the dependency file
.cpp.d:
g++ -MM $(INCLUDES) $(CXX_FLAGS) $*.cpp > $*.d
# List of dependency files to be created
DEPENDS=$(OBJS:.o=.d)
# Program Name
PROGRAM = $(PROG_NAME)$(EXE_EXT)
all: $(PROGRAM) .depends
$(PROGRAM): $(OBJS) $(CANTERA_LIBDIR)/libcantera.a \
$(CANTERA_LIBDIR)/libcaThermo.a
$(CXX) -o $(PROGRAM) $(OBJS) $(LCXX_FLAGS) $(LINK_OPTIONS) \
$(CANTERA_LIBS) @LIBS@ $(FORT_LIBS) \
$(LCXX_END_LIBS)
# depends target -> forces recalculation of dependencies
depends:
@MAKE@ .depends
.depends: $(DEPENDS)
cat $(DEPENDS) > .depends
# Do the test -> For the windows vc++ environment, we have to skip checking on
# whether the program is uptodate, because we don't utilize make
# in that environment to build programs.
test:
ifeq ($(os_is_win), 1)
else
@MAKE@ $(PROGRAM)
endif
./runtest
clean:
$(RM) $(OBJS) $(PROGRAM) $(DEPENDS) .depends
../../../bin/rm_cvsignore
(if test -d SunWS_cache ; then \
$(RM) -rf SunWS_cache ; \
fi )

View File

@@ -0,0 +1,11 @@
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.

View File

@@ -0,0 +1,39 @@
s = 188835
h = -2.41826e+08
psat(273.16) = 611.655
Comparisons to NIST: (see http://webbook.nist.gov):
H0(298.15) = -2.41826e+08 J/kmol
S0(298.15) = 188835 J/kmolK
Ideal Gas Standard State:
T Cp0 S0 -(G0-H298)/T H0-H298
(K) (J/molK) (J/molK) (J/molK) (kJ/mol)
298.15 33.5873 188.835 188.835 0
500 35.2263 206.535 192.686 6.92447
600 36.3249 213.053 195.551 10.5013
1000 41.2673 232.739 206.738 26.0001
H_liq(298.15, onebar) = -2.85838e+08 J/kmol
S_liq(298.15, onebar) = 69922.4 J/kmolK
Liquid 1bar or psat Standard State
T press psat Cp0 S0 -(G0-H298)/T H0-H298
(K) (bar) (bar) (J/molK) (J/molK) (J/molK) (kJ/mol)
273.19 1 0.00612989 76.0121 63.3157 70.2194 -1.88603
298.15 1 0.0316993 75.3276 69.9224 69.9224 2.38419e-13
300 1 0.0353681 75.3153 70.3884 69.9239 0.139344
373.15 1.01621 1.01418 75.9465 86.857 71.6855 5.66125
400 2.46261 2.45769 76.6642 92.1544 72.8766 7.71115
500 26.4447 26.392 84.0126 109.805 78.4402 15.6825
Liquid Densities:
T press psat Density molarVol
(K) (bar) (bar) (kg/m3) (m3/kmol)
273.19 1 0.00612989 999.845 0.0180181
298.15 1 0.0316993 997.047 0.0180686
300 1 0.0353681 996.556 0.0180775
373.15 1.01621 1.01418 958.349 0.0187982
400 2.46261 2.45769 937.486 0.0192166
500 26.4447 26.392 831.318 0.0216707

View File

@@ -0,0 +1,33 @@
#!/bin/sh
#
#
temp_success="1"
/bin/rm -f output.txt outputa.txt
testName=testWaterTP
#################################################################
#
#################################################################
CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA
CANTERA_BIN=${CANTERA_BIN:=../../../bin}
./testWaterTP > output.txt
retnStat=$?
if [ $retnStat != "0" ]
then
temp_success="0"
echo "$testName returned with bad status, $retnStat, check output"
fi
$CANTERA_BIN/exp3to2.sh output.txt > outputa.txt
diff -w outputa.txt output_blessed.txt > diff_test.out
retnStat=$?
if [ $retnStat = "0" ]
then
echo "successful diff comparison on $testName test"
else
echo "unsuccessful diff comparison on $testName test"
echo "FAILED" > csvCode.txt
temp_success="0"
fi

View File

@@ -0,0 +1,145 @@
/*
* $Id$
*/
#include "stdio.h"
#include "WaterTP.h"
#include <new>
using namespace std;
int main () {
double dens, u, s, h, cv, cp, pres;
try {
WaterTP *w = new WaterTP("waterTPphase.xml","");
double rho;
/*
* Print out the triple point conditions
*/
double temp = 273.16;
pres = w->satPressure(temp);
printf("psat(%g) = %g\n", temp, pres);
double presLow = 1.0E-2;
temp = 298.15;
double oneBar = 1.0E5;
printf("Comparisons to NIST: (see http://webbook.nist.gov):\n\n");
w->setDensity(1.0E-8);
w->setState_TP(temp, presLow);
double h = w->enthalpy_mole();
printf("H0(298.15) = %g J/kmol\n", h);
double h298 = h;
double s = w->entropy_mole();
s -= GasConstant * log(oneBar/presLow);
printf("S0(298.15) = %g J/kmolK\n", s);
double T[20];
T[0] = 298.15;
T[1] = 500.;
T[2] = 600.;
T[3] = 1000.;
double Cp0, delh0, delg0, g;
printf("\nIdeal Gas Standard State:\n");
printf (" T Cp0 S0 "
" -(G0-H298)/T H0-H298\n");
printf (" (K) (J/molK) (J/molK) "
" (J/molK) (kJ/mol)\n");
for (int i = 0; i < 4; i++) {
temp = T[i];
w->setState_TP(temp, presLow);
h = w->enthalpy_mole();
delh0 = h - h298;
g = w->gibbs_mole();
delg0 = (g - h298)/temp + GasConstant * log(oneBar/presLow);
Cp0 = w->cp_mole();
s = w->entropy_mole();
s -= GasConstant * log(oneBar/presLow);
printf("%10g %10g %13g %13g %13g\n", temp, Cp0*1.0E-3, s*1.0E-3,
-delg0*1.0E-3, delh0*1.0E-6);
}
printf("\n\n");
temp = 298.15;
w->setDensity(1000.);
w->setState_TP(temp, oneBar);
h = w->enthalpy_mole();
printf("H_liq(298.15, onebar) = %g J/kmol\n", h);
double h298l = h;
s = w->entropy_mole();
printf("S_liq(298.15, onebar) = %g J/kmolK\n", s);
T[0] = 273.19;
T[1] = 298.15;
T[2] = 300.;
T[3] = 373.15;
T[4] = 400.;
T[5] = 500.;
printf("\nLiquid 1bar or psat Standard State\n");
printf (" T press psat Cp0 S0 "
" -(G0-H298)/T H0-H298\n");
printf (" (K) (bar) (bar) (J/molK) (J/molK)"
" (J/molK) (kJ/mol)\n");
for (int i = 0; i < 6; i++) {
temp = T[i];
double psat = w->satPressure(temp);
double press = oneBar;
if (psat > press) {
press = psat*1.002;
}
w->setState_TP(temp, press);
h = w->enthalpy_mole();
delh0 = h - h298l;
g = w->gibbs_mole();
delg0 = (g - h298l)/temp;
Cp0 = w->cp_mole();
s = w->entropy_mole();
printf("%10g %10g %12g %13g %13g %13g %13g\n", temp, press*1.0E-5,
psat*1.0E-5,
Cp0*1.0E-3, s*1.0E-3,
-delg0*1.0E-3, delh0*1.0E-6);
}
printf("\nLiquid Densities:\n");
printf (" T press psat Density molarVol "
"\n");
printf (" (K) (bar) (bar) (kg/m3) (m3/kmol)"
"\n");
for (int i = 0; i < 6; i++) {
temp = T[i];
double psat = w->satPressure(temp);
double press = oneBar;
if (psat > press) {
press = psat*1.002;
}
w->setState_TP(temp, press);
double d = w->density();
double mw = w->molecularWeight(0);
double vbar = mw/d;
// not implemented
//w.getPartialMolarVolumes(&vbar);
printf("%10g %10g %12g %13g %13g\n", temp, press*1.0E-5,
psat*1.0E-5, d, vbar);
}
delete w;
} catch (CanteraError) {
showErrors();
Cantera::appdelete();
return -1;
}
return 0;
}

View File

@@ -0,0 +1,54 @@
<?xml version="1.0"?>
<ctml>
<validate reactions="yes" species="yes"/>
<!-- phase water -->
<phase dim="3" id="water">
<elementArray datasrc="elements.xml">O H </elementArray>
<speciesArray datasrc="#species_data">H2O</speciesArray>
<state>
<temperature units="K">300.0</temperature>
<pressure units="Pa">101325.0</pressure>
</state>
<thermo model="PureFluid" fluid_type="0"/>
<kinetics model="none"/>
</phase>
<!-- species definitions -->
<speciesData id="species_data">
<!-- species H2O -->
<species name="H2O">
<atomArray>H:2 O:1 </atomArray>
<thermo>
<NASA Tmax="1000.0" Tmin="273.16000000000003" P0="100000.0">
<floatArray name="coeffs" size="7">
4.198640560E+00, -2.036434100E-03, 6.520402110E-06, -5.487970620E-09,
1.771978170E-12, -3.029372670E+04, -8.490322080E-01</floatArray>
</NASA>
<NASA Tmax="1600.0" Tmin="1000.0" P0="100000.0">
<floatArray name="coeffs" size="7">
3.033992490E+00, 2.176918040E-03, -1.640725180E-07, -9.704198700E-11,
1.682009920E-14, -3.000429710E+04, 4.966770100E+00</floatArray>
</NASA>
</thermo>
</species>
<!-- species C2F4H2 -->
<species name="C2F4H2">
<atomArray>H:2 C:2 F:4 </atomArray>
<thermo>
<const_cp Tmax="5000.0" Tmin="100.0">
<t0 units="K">273.14999999999998</t0>
<h0 units="J/kmol">23083414.8686</h0>
<s0 units="J/kmol/K">167025.46599999999</s0>
<cp0 units="J/kmol/K">0.0</cp0>
</const_cp>
</thermo>
</species>
</speciesData>
<reactionData id="reaction_data"/>
</ctml>