From b6b3789a6f41c785cb6a44c7dfd21e1fbc96dba5 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Tue, 4 Jul 2006 00:21:28 +0000 Subject: [PATCH] Added the first test for IAPWS --- test_problems/cathermo/Makefile.in | 3 + test_problems/cathermo/testIAPWS/.cvsignore | 10 ++ test_problems/cathermo/testIAPWS/Makefile.in | 112 ++++++++++++++++++ test_problems/cathermo/testIAPWS/README | 15 +++ .../cathermo/testIAPWS/output_blessed.txt | 14 +++ test_problems/cathermo/testIAPWS/runtest | 33 ++++++ .../cathermo/testIAPWS/testIAPWSphi.cpp | 18 +++ 7 files changed, 205 insertions(+) create mode 100644 test_problems/cathermo/testIAPWS/.cvsignore create mode 100755 test_problems/cathermo/testIAPWS/Makefile.in create mode 100644 test_problems/cathermo/testIAPWS/README create mode 100644 test_problems/cathermo/testIAPWS/output_blessed.txt create mode 100755 test_problems/cathermo/testIAPWS/runtest create mode 100644 test_problems/cathermo/testIAPWS/testIAPWSphi.cpp diff --git a/test_problems/cathermo/Makefile.in b/test_problems/cathermo/Makefile.in index 9fdfbc1d5..770df630d 100644 --- a/test_problems/cathermo/Makefile.in +++ b/test_problems/cathermo/Makefile.in @@ -13,6 +13,7 @@ ifeq ($(test_issp),1) endif ifeq ($(test_electrolytes),1) cd ims; @MAKE@ all + cd testIAPWS; @MAKE@ all endif test: @@ -21,6 +22,7 @@ ifeq ($(test_issp),1) endif ifeq ($(test_electrolytes),1) cd ims; @MAKE@ test + cd testIAPWS; @MAKE@ test endif clean: @@ -34,4 +36,5 @@ ifeq ($(test_issp),1) endif ifeq ($(test_electrolytes),1) cd ims; @MAKE@ depends + cd testIAPWS; @MAKE@ depends endif diff --git a/test_problems/cathermo/testIAPWS/.cvsignore b/test_problems/cathermo/testIAPWS/.cvsignore new file mode 100644 index 000000000..2c7702fdd --- /dev/null +++ b/test_problems/cathermo/testIAPWS/.cvsignore @@ -0,0 +1,10 @@ +testIAPWSphi +Makefile +output.txt +outputa.txt +*.d + .depends +csvCode.txt +diff_test.out +test.diff +test.out diff --git a/test_problems/cathermo/testIAPWS/Makefile.in b/test_problems/cathermo/testIAPWS/Makefile.in new file mode 100755 index 000000000..088d67754 --- /dev/null +++ b/test_problems/cathermo/testIAPWS/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 = testIAPWSphi + +# the object files to be linked together. List those generated from Fortran +# and from C/C++ separately +OBJS = testIAPWSphi.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/testIAPWS/README b/test_problems/cathermo/testIAPWS/README new file mode 100644 index 000000000..a93a48b7c --- /dev/null +++ b/test_problems/cathermo/testIAPWS/README @@ -0,0 +1,15 @@ + +This test is used to make sure that the basic functions in +the water property routine satisfies the derivative 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. + +On page 436 of that reference, value for phi, the nondimensional +helmholtz free energy and its first and second derivatives, +are given at 2 representative points. This test makes sure +that the values agree with the paper's values. + diff --git a/test_problems/cathermo/testIAPWS/output_blessed.txt b/test_problems/cathermo/testIAPWS/output_blessed.txt new file mode 100644 index 000000000..d035486b1 --- /dev/null +++ b/test_problems/cathermo/testIAPWS/output_blessed.txt @@ -0,0 +1,14 @@ + T = 500 K, rho = 838.025 kg m-3 +nau = 2.0479773347960e+00 res = -3.4269320568156e+00 +nau_d = 3.8423674711375e-01 res_d = -3.6436665036388e-01 +nau_dd = -1.4763787783256e-01 res_dd = 8.5606370097461e-01 +nau_t = 9.0461110617524e+00 res_t = -5.8140343523842e+00 +nau_tt = -1.9324918501305e+00 res_tt = -2.2344073688434e+00 +nau_dt = 0.0000000000000e+00 res_dt = -1.1217691467031e+00 + T = 647 K, rho = 358.0 kg m-3 +nau = -1.5631960505252e+00 res = -1.2120265650415e+00 +nau_d = 8.9944134078212e-01 res_d = -7.1401202437128e-01 +nau_dd = -8.0899472550794e-01 res_dd = 4.7573069564569e-01 +nau_t = 9.8034391793901e+00 res_t = -3.2172250077517e+00 +nau_tt = -3.4331633414307e+00 res_tt = -9.9602950655930e+00 +nau_dt = 0.0000000000000e+00 res_dt = -1.3321472043614e+00 diff --git a/test_problems/cathermo/testIAPWS/runtest b/test_problems/cathermo/testIAPWS/runtest new file mode 100755 index 000000000..60a2e297c --- /dev/null +++ b/test_problems/cathermo/testIAPWS/runtest @@ -0,0 +1,33 @@ +#!/bin/sh +# +# +temp_success="1" +/bin/rm -f output.txt outputa.txt + +testName=testIAPWSphi +################################################################# +# +################################################################# +CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA + +CANTERA_BIN=${CANTERA_BIN:=../../../bin} +./testIAPWSphi > 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/testIAPWS/testIAPWSphi.cpp b/test_problems/cathermo/testIAPWS/testIAPWSphi.cpp new file mode 100644 index 000000000..1689b2421 --- /dev/null +++ b/test_problems/cathermo/testIAPWS/testIAPWSphi.cpp @@ -0,0 +1,18 @@ +/* + * $Id$ + */ +#include "stdio.h" +#include "WaterPropsIAPWSphi.h" +#include +using namespace std; + +int main () { + + WaterPropsIAPWSphi *phi = new WaterPropsIAPWSphi(); + + phi->check1(); + phi->check2(); + + delete phi; + return 0; +}