Triple point calcultion test routine.

This commit is contained in:
Harry Moffat 2006-07-04 00:39:45 +00:00
parent 1f8fcc9cc4
commit d294f18177
6 changed files with 264 additions and 0 deletions

View file

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

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 = testTripleP
# the object files to be linked together. List those generated from Fortran
# and from C/C++ separately
OBJS = testTripleP.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 calculation of triple point thermo properties.

View file

@ -0,0 +1,19 @@
psat(273.16) = 611.655
dens (liquid) = 999.793 kg m-3
intEng (liquid) = -1.91143e-08 J/kmol
S (liquid) = -8.47431e-11 J/kmolK
h (liquid) = 11.0214 J/kmol
h (liquid) = 0.611782 J/kg
g (liquid) = 11.0214 J/kmol
cv (liquid) = 75978.2 J/kmolK
cp (liquid) = 76022.8 J/kmolK
dens (gas) = 0.00485458 kg m-3
intEng (gas) = 4.27848e+07 J/kmol
S (gas) = 164939 J/kmolK
h (gas) = 4.50547e+07 J/kmol
h (gas) = 2.50092e+06 J/kg
g (gas) = 11.0214 J/kmol
cv (gas) = 25552.6 J/kmolK
cp (gas) = 33947.1 J/kmolK
Delta g = 4.13909e-06 J/kmol

View file

@ -0,0 +1,33 @@
#!/bin/sh
#
#
temp_success="1"
/bin/rm -f output.txt outputa.txt
testName=testTripleP
#################################################################
#
#################################################################
CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA
CANTERA_BIN=${CANTERA_BIN:=../../../bin}
./testTripleP > 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,77 @@
#include "stdio.h"
#include "WaterPropsIAPWS.h"
#include <new>
using namespace std;
int main () {
double dens, u, s, h, cv, cp, pres;
WaterPropsIAPWS *water = new WaterPropsIAPWS();
double T;
double rho;
/*
* 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(T, dens);
printf("intEng (liquid) = %g J/kmol\n", u);
s = water->entropy(T, dens);
printf("S (liquid) = %g J/kmolK\n", s);
h = water->enthalpy(T, dens);
printf("h (liquid) = %g J/kmol\n", h);
printf("h (liquid) = %g J/kg\n", (h)/18.015268);
double g_liq = water->Gibbs(T, dens);
printf("g (liquid) = %g J/kmol\n", g_liq);
cv = water->cv(T, dens);
printf("cv (liquid) = %g J/kmolK\n", cv);
cp = water->cp(T, dens);
printf("cp (liquid) = %g J/kmolK\n", cp);
dens = water->density(T, pres, WATER_GAS);
printf("dens (gas) = %g kg m-3\n", dens);
u = water->intEnergy(T, dens);
printf("intEng (gas) = %g J/kmol\n", u);
s = water->entropy(T, dens);
printf("S (gas) = %g J/kmolK\n", s);
h = water->enthalpy(T, dens);
printf("h (gas) = %g J/kmol\n", h);
printf("h (gas) = %g J/kg\n", (h)/18.015268);
double g_gas = water->Gibbs(T, dens);
printf("g (gas) = %g J/kmol\n", g_gas);
cv = water->cv(T, dens);
printf("cv (gas) = %g J/kmolK\n", cv);
cp = water->cp(T, dens);
printf("cp (gas) = %g J/kmolK\n", cp);
printf("\n");
printf("Delta g = %g J/kmol\n", g_liq - g_gas);
delete water;
return 0;
}