diff --git a/test_problems/cathermo/ims/.cvsignore b/test_problems/cathermo/ims/.cvsignore new file mode 100644 index 000000000..ab19b1895 --- /dev/null +++ b/test_problems/cathermo/ims/.cvsignore @@ -0,0 +1,8 @@ +Makefile +.depends +IMSTester +IMSTester.d +csvCode.txt +diff_test.out +output.txt +outputa.txt diff --git a/test_problems/cathermo/ims/IMSTester.cpp b/test_problems/cathermo/ims/IMSTester.cpp new file mode 100644 index 000000000..8508b2b0d --- /dev/null +++ b/test_problems/cathermo/ims/IMSTester.cpp @@ -0,0 +1,160 @@ +/** + * @file IMSTester.cpp + * + * $Id$ + */ +/* + * Copywrite 2005 Sandia Corporation. Under the terms of Contract + * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government + * retains certain rights in this software. + * See file License.txt for licensing information. + */ + +// Example +// +// Read a mechanism and a thermodynamics file for the +// class IdealMolalSoln in order to test that it's +// working correctly +// + + + +#include +#include +#include +#include + +#ifdef SRCDIRTREE +#include "ct_defs.h" +#include "IdealMolalSoln.h" +#else +#include "Cantera.h" +#include "kernel/thermo/IdealMolalSoln.h" +#endif + +using namespace std; + +#ifdef DEBUG_HKM +int iDebug_HKM = 0; +#endif + +/*****************************************************************/ +/*****************************************************************/ +/*****************************************************************/ +static void printUsage() +{ + +} + + +using namespace Cantera; + +int main(int argc, char** argv) { + string infile; + // look for command-line options + if (argc > 1) { + string tok; + for (int j = 1; j < argc; j++) { + tok = string(argv[j]); + if (tok[0] == '-') { + int nopt = tok.size(); + for (int n = 1; n < nopt; n++) { + if (tok[n] == 'h') { + printUsage(); + exit(0); + } else { + printUsage(); + exit(1); + } + } + } else if (infile == "") { + infile = tok; + } + else { + printUsage(); + exit(1); + } + } + } + + try { + double Tkelvin = 298.15; + IdealMolalSoln ims("WaterPlusSolutes.xml"); + ims.setState_TPM(Tkelvin, OneAtm, + "CH4(aq):0.01, H2S(aq):0.03, CO2(aq):0.1"); + double hm = ims.enthalpy_mole(); + printf("molar enthalpy = %13.5g J kg-1\n", hm); + + double um = ims.intEnergy_mole(); + printf("molar intEnergy = %13.5g J kg-1\n", um); + + + double sm = ims.entropy_mole(); + printf("molar entropy = %13.5g J kg-1 K-1\n", sm); + + double gm = ims.gibbs_mole(); + printf("molar gibbs = %13.5g J kg-1\n", gm); + + double cpm = ims.cp_mole(); + printf("molar Cp = %13.5g J kg-1 K-1\n", cpm); + + double dens = ims.density(); + printf("mixture density = %13.5g kg m-3\n", dens); + + double mdens = ims.molarDensity(); + printf("molar density = %13.5g kmol m-3\n", mdens); + + double mmw = ims.meanMolecularWeight(); + printf("mean molecular weight = %13.5g kg kmol-1\n", mmw); + + int n = ims.nSpecies(); + + double HiSS[20], muiSS[20],SiSS[20], CpiSS[20], VoliSS[20]; + double RT = GasConstant * Tkelvin; + ims.getStandardChemPotentials(muiSS); + ims.getEnthalpy_RT(HiSS); + ims.getEntropy_R (SiSS); + ims.getCp_R(CpiSS); + ims.getStandardVolumes(VoliSS); + + + for (int i = 0; i < n; i++) { + HiSS[i] *= RT; + SiSS[i] *= RT; + CpiSS[i] *= GasConstant; + } + + printf(" Printout of standard state properties\n"); + printf(" Name mu_i H_i_SS " + " S_i_SS Cp_i_SS Vol_i_SS\n"); + for (int i = 0; i < n; i++) { + string sn = ims.speciesName(i); + printf(" %15s %12.5g %12.5g %12.5g %12.5g %12.5g\n", sn.c_str(), muiSS[i], + HiSS[i], SiSS[i], CpiSS[i], VoliSS[i]); + } + + + + double HiPM[20], mui[20],SiPM[20], CpiPM[20], VoliPM[20]; + + ims.getChemPotentials(mui); + ims.getPartialMolarEnthalpies(HiPM); + ims.getPartialMolarEntropies(SiPM); + ims.getPartialMolarCp(CpiPM); + ims.getPartialMolarVolumes(VoliPM); + printf(" Printout of Partial molar properties\n"); + printf(" Name mu_i H_i_PM " + " S_i_PM Cp_i_PM Vol_i_PM\n"); + for (int i = 0; i < n; i++) { + string sn = ims.speciesName(i); + printf(" %15s %12.5g %12.5g %12.5g %12.5g %12.5g\n", sn.c_str(), mui[i], + HiPM[i], SiPM[i], CpiPM[i], VoliPM[i]); + } + } + catch (CanteraError) { + showErrors(cout); + } + + return 0; +} +/***********************************************************/ diff --git a/test_problems/cathermo/ims/Makefile.in b/test_problems/cathermo/ims/Makefile.in new file mode 100644 index 000000000..0337068c0 --- /dev/null +++ b/test_problems/cathermo/ims/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 = IMSTester + +# the object files to be linked together. List those generated from Fortran +# and from C/C++ separately +OBJS = IMSTester.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/ims/WaterPlusSolutes.xml b/test_problems/cathermo/ims/WaterPlusSolutes.xml new file mode 100644 index 000000000..a10c2d030 --- /dev/null +++ b/test_problems/cathermo/ims/WaterPlusSolutes.xml @@ -0,0 +1,167 @@ + + + + + + 300 + + + + + H2O(l) + + + O H C Fe Ca N S + + + H2O(l) CO2(aq) H2S(aq) CH4(aq) C6H6(aq) + + + + + + + + + This corresponds to new soot + H:2 O:1 + + + + 2.344331120E+000, 7.980520750E-003, -1.947815100E-005, + 2.015720940E-008, -7.376117610E-012, -9.179351730E+002, + 6.830102380E-001 + + + + + 3.337279200E+000, -4.940247310E-005, 4.994567780E-007, + -1.795663940E-010, 2.002553760E-014, -9.501589220E+002, + -3.205023310E+000 + + + + + 1.5 + + + + + C:1 O:2 + + + + 2.344331120E+000, 7.980520750E-003, -1.947815100E-005, + 2.015720940E-008, -7.376117610E-012, -9.179351730E+002, + 6.830102380E-001 + + + + + 3.337279200E+000, -4.940247310E-005, 4.994567780E-007, + -1.795663940E-010, 2.002553760E-014, -9.501589220E+002, + -3.205023310E+000 + + + + + 1.3 + + + + + H:2 S:1 + + + + 2.344331120E+000, 7.980520750E-003, -1.947815100E-005, + 2.015720940E-008, -7.376117610E-012, -9.179351730E+002, + 6.830102380E-001 + + + + + 3.337279200E+000, -4.940247310E-005, 4.994567780E-007, + -1.795663940E-010, 2.002553760E-014, -9.501589220E+002, + -3.205023310E+000 + + + + + 0.1 + + + + + C:1 H:4 + + + + 2.344331120E+000, 7.980520750E-003, -1.947815100E-005, + 2.015720940E-008, -7.376117610E-012, -9.179351730E+002, + 6.830102380E-001 + + + + + 3.337279200E+000, -4.940247310E-005, 4.994567780E-007, + -1.795663940E-010, 2.002553760E-014, -9.501589220E+002, + -3.205023310E+000 + + + + + 0.1 + + + + + C:6 H:6 + + + + 2.344331120E+000, 7.980520750E-003, -1.947815100E-005, + 2.015720940E-008, -7.376117610E-012, -9.179351730E+002, + 6.830102380E-001 + + + + + 3.337279200E+000, -4.940247310E-005, 4.994567780E-007, + -1.795663940E-010, 2.002553760E-014, -9.501589220E+002, + -3.205023310E+000 + + + + + 0.1 + + + + + + + + + + + + C2H2-graph [=] H2-solute + 2 C-graph + C2H2-graph:1 + H2-solute:1 C-graph:2 + + + 1.0E10 + 0.0 + 10000. + + + + + + diff --git a/test_problems/cathermo/ims/output_blessed.txt b/test_problems/cathermo/ims/output_blessed.txt new file mode 100644 index 000000000..5d7311069 --- /dev/null +++ b/test_problems/cathermo/ims/output_blessed.txt @@ -0,0 +1,27 @@ +species H2O(l) has volume 1.5 +species CO2(aq) has volume 1.3 +species H2S(aq) has volume 0.1 +species CH4(aq) has volume 0.1 +species C6H6(aq) has volume 0.1 +molar enthalpy = 0.013282 J kg-1 +molar intEnergy = 0.013282 J kg-1 +molar entropy = 93.636 J kg-1 K-1 +molar gibbs = -3.8986e+07 J kg-1 +molar Cp = 28836 J kg-1 K-1 +mixture density = 0.001 kg m-3 +molar density = 5.5339e-05 kmol m-3 +mean molecular weight = 18.07 kg kmol-1 + Printout of standard state properties + Name mu_i H_i_SS S_i_SS Cp_i_SS Vol_i_SS + H2O(l) -3.8962e+07 0.013282 3.8962e+07 28836 1.5 + CO2(aq) -3.8962e+07 0.013282 3.8962e+07 28836 1.3 + H2S(aq) -3.8962e+07 0.013282 3.8962e+07 28836 0.1 + CH4(aq) -3.8962e+07 0.013282 3.8962e+07 28836 0.1 + C6H6(aq) -3.8962e+07 0.013282 3.8962e+07 28836 0.1 + Printout of Partial molar properties + Name mu_i H_i_PM S_i_PM Cp_i_PM Vol_i_PM + H2O(l) -3.8969e+07 0.013282 36.687 28836 1.5 + CO2(aq) -4.467e+07 0.013282 19160 28836 1.3 + H2S(aq) -4.7655e+07 0.013282 29171 28836 0.1 + CH4(aq) -5.0378e+07 0.013282 38305 28836 0.1 + C6H6(aq) -8.9516e+08 0.013282 5.7434e+06 28836 0.1 diff --git a/test_problems/cathermo/ims/runtest b/test_problems/cathermo/ims/runtest new file mode 100755 index 000000000..bf0e5e34f --- /dev/null +++ b/test_problems/cathermo/ims/runtest @@ -0,0 +1,32 @@ +#!/bin/sh +# +# +temp_success="1" +/bin/rm -f output.txt outputa.txt + +################################################################# +# +################################################################# +CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA + +CANTERA_BIN=${CANTERA_BIN:=../../../bin} +./IMSTester > output.txt +retnStat=$? +if [ $retnStat != "0" ] +then + temp_success="0" + echo "IMSTester 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 IMSTester test" +else + echo "unsuccessful diff comparison on IMSTester test" + echo "FAILED" > csvCode.txt + temp_success="0" +fi +