diff --git a/test_problems/cathermo/Makefile.in b/test_problems/cathermo/Makefile.in index 996316116..a35e9148b 100644 --- a/test_problems/cathermo/Makefile.in +++ b/test_problems/cathermo/Makefile.in @@ -16,6 +16,7 @@ ifeq ($(test_electrolytes),1) cd testIAPWS; @MAKE@ all cd testIAPWSPres; @MAKE@ all cd testIAPWSTripP; @MAKE@ all + cd testWaterPDSS; @MAKE@ all endif test: @@ -27,6 +28,7 @@ ifeq ($(test_electrolytes),1) cd testIAPWS; @MAKE@ test cd testIAPWSPres; @MAKE@ test cd testIAPWSTripP; @MAKE@ test + cd testWaterPDSS; @MAKE@ test endif clean: @@ -36,6 +38,7 @@ clean: cd testIAPWS; @MAKE@ clean cd testIAPWSPres; @MAKE@ clean cd testIAPWSTripP; @MAKE@ clean + cd testWaterPDSS; @MAKE@ clean depends: ifeq ($(test_issp),1) @@ -46,4 +49,5 @@ ifeq ($(test_electrolytes),1) cd testIAPWS; @MAKE@ depends cd testIAPWSPres; @MAKE@ depends cd testIAPWSTripP; @MAKE@ depends + cd testWaterPDSS; @MAKE@ depends endif diff --git a/test_problems/cathermo/testWaterPDSS/.cvsignore b/test_problems/cathermo/testWaterPDSS/.cvsignore new file mode 100644 index 000000000..06416aa3f --- /dev/null +++ b/test_problems/cathermo/testWaterPDSS/.cvsignore @@ -0,0 +1,11 @@ +testIAPWSphi +Makefile +output.txt +outputa.txt +*.d + .depends +csvCode.txt +diff_test.out +test.diff +test.out +testWaterPDSS diff --git a/test_problems/cathermo/testWaterPDSS/Makefile.in b/test_problems/cathermo/testWaterPDSS/Makefile.in new file mode 100755 index 000000000..b9485b35b --- /dev/null +++ b/test_problems/cathermo/testWaterPDSS/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 = testWaterPDSS + +# the object files to be linked together. List those generated from Fortran +# and from C/C++ separately +OBJS = testWaterPDSS.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/testWaterPDSS/output_blessed.txt b/test_problems/cathermo/testWaterPDSS/output_blessed.txt new file mode 100644 index 000000000..c9eeac340 --- /dev/null +++ b/test_problems/cathermo/testWaterPDSS/output_blessed.txt @@ -0,0 +1,37 @@ +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 diff --git a/test_problems/cathermo/testWaterPDSS/runtest b/test_problems/cathermo/testWaterPDSS/runtest new file mode 100755 index 000000000..e97266c9c --- /dev/null +++ b/test_problems/cathermo/testWaterPDSS/runtest @@ -0,0 +1,33 @@ +#!/bin/sh +# +# +temp_success="1" +/bin/rm -f output.txt outputa.txt + +testName=testWaterPDSS +################################################################# +# +################################################################# +CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA + +CANTERA_BIN=${CANTERA_BIN:=../../../bin} +./testWaterPDSS > 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/testWaterPDSS/testWaterPDSS.cpp b/test_problems/cathermo/testWaterPDSS/testWaterPDSS.cpp new file mode 100644 index 000000000..a4de4e16e --- /dev/null +++ b/test_problems/cathermo/testWaterPDSS/testWaterPDSS.cpp @@ -0,0 +1,153 @@ +/* + * $Id$ + */ +#include "stdio.h" +#include "ct_defs.h" +#include "ctexceptions.h" +#include "global.h" +#include "xml.h" +#include "ctml.h" +#include "WaterPDSS.h" +#include "ThermoPhase.h" +#include +using namespace std; +using namespace Cantera; + +int main () { + + double dens, u, s, h, cv, cp, pres; + try { + Cantera::ThermoPhase *nnn = 0; + Cantera::WaterPDSS *w = new Cantera::WaterPDSS(nnn, 0); + + 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(); + 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; +}