From 1f8fcc9cc432af4739653abd843ca40263899d59 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Tue, 4 Jul 2006 00:32:12 +0000 Subject: [PATCH] Second test. --- .../cathermo/testIAPWSPres/.cvsignore | 11 ++ .../cathermo/testIAPWSPres/Makefile.in | 112 ++++++++++++++++++ test_problems/cathermo/testIAPWSPres/README | 11 ++ .../cathermo/testIAPWSPres/output_blessed.txt | 16 +++ test_problems/cathermo/testIAPWSPres/runtest | 33 ++++++ .../cathermo/testIAPWSPres/testPress.cpp | 89 ++++++++++++++ 6 files changed, 272 insertions(+) create mode 100644 test_problems/cathermo/testIAPWSPres/.cvsignore create mode 100755 test_problems/cathermo/testIAPWSPres/Makefile.in create mode 100644 test_problems/cathermo/testIAPWSPres/README create mode 100644 test_problems/cathermo/testIAPWSPres/output_blessed.txt create mode 100755 test_problems/cathermo/testIAPWSPres/runtest create mode 100644 test_problems/cathermo/testIAPWSPres/testPress.cpp diff --git a/test_problems/cathermo/testIAPWSPres/.cvsignore b/test_problems/cathermo/testIAPWSPres/.cvsignore new file mode 100644 index 000000000..30c0b525d --- /dev/null +++ b/test_problems/cathermo/testIAPWSPres/.cvsignore @@ -0,0 +1,11 @@ +testIAPWSphi +Makefile +output.txt +outputa.txt +*.d + .depends +csvCode.txt +diff_test.out +test.diff +test.out +testPress diff --git a/test_problems/cathermo/testIAPWSPres/Makefile.in b/test_problems/cathermo/testIAPWSPres/Makefile.in new file mode 100755 index 000000000..602414300 --- /dev/null +++ b/test_problems/cathermo/testIAPWSPres/Makefile.in @@ -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 = testPress + +# the object files to be linked together. List those generated from Fortran +# and from C/C++ separately +OBJS = testPress.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 ) + diff --git a/test_problems/cathermo/testIAPWSPres/README b/test_problems/cathermo/testIAPWSPres/README new file mode 100644 index 000000000..a0b0e774b --- /dev/null +++ b/test_problems/cathermo/testIAPWSPres/README @@ -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. diff --git a/test_problems/cathermo/testIAPWSPres/output_blessed.txt b/test_problems/cathermo/testIAPWSPres/output_blessed.txt new file mode 100644 index 000000000..42d4ec45b --- /dev/null +++ b/test_problems/cathermo/testIAPWSPres/output_blessed.txt @@ -0,0 +1,16 @@ +pres = 182080 +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 +dens (gas) = 0.00485458 kg m-3 +psat(373.124) = 101324 +dens (liquid) = 958.368 kg m-3 +dens (gas) = 0.597651 kg m-3 +psat_est(273.15) = 611.212 +psat_est(314) = 7722.3 +psat_est(314) = 7675.46 +psat_est(373.15) = 101007 +psat_est(647.25) = 2.2093e+07 diff --git a/test_problems/cathermo/testIAPWSPres/runtest b/test_problems/cathermo/testIAPWSPres/runtest new file mode 100755 index 000000000..abc65a02b --- /dev/null +++ b/test_problems/cathermo/testIAPWSPres/runtest @@ -0,0 +1,33 @@ +#!/bin/sh +# +# +temp_success="1" +/bin/rm -f output.txt outputa.txt + +testName=testPress +################################################################# +# +################################################################# +CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA + +CANTERA_BIN=${CANTERA_BIN:=../../../bin} +./testPress > 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 + diff --git a/test_problems/cathermo/testIAPWSPres/testPress.cpp b/test_problems/cathermo/testIAPWSPres/testPress.cpp new file mode 100644 index 000000000..c03259cf7 --- /dev/null +++ b/test_problems/cathermo/testIAPWSPres/testPress.cpp @@ -0,0 +1,89 @@ + +#include "stdio.h" +#include "WaterPropsIAPWS.h" +#include +using namespace std; + +int main () { + + double dens, u, s, h; + WaterPropsIAPWS *water = new WaterPropsIAPWS(); + + double T = 273.15 + 100.; + double rho = 10125. * 18.01 / (8.314472E3 * T); + + double pres = water->pressure(T, rho); + printf("pres = %g\n", pres); + + /* + * 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); + + + dens = water->density(T, pres, WATER_GAS); + printf("dens (gas) = %g kg m-3\n", dens); + + + + /* + * Print out the normal boiling point conditions + */ + T = 373.124; + 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); + + dens = water->density(T, pres, WATER_GAS); + printf("dens (gas) = %g kg m-3\n", dens); + + /* + * Calculate a few test points for the estimated + * saturation pressure function + */ + T = 273.15 + 0.; + pres = water->psat_est(T); + printf("psat_est(%g) = %g\n", T, pres); + + T = 313.9999; + pres = water->psat_est(T); + printf("psat_est(%g) = %g\n", T, pres); + + T = 314.0001; + pres = water->psat_est(T); + printf("psat_est(%g) = %g\n", T, pres); + + T = 273.15 + 100.; + pres = water->psat_est(T); + printf("psat_est(%g) = %g\n", T, pres); + + T = 647.25; + pres = water->psat_est(T); + printf("psat_est(%g) = %g\n", T, pres); + + + + + + + + delete water; + return 0; +}