Added a new test.
This commit is contained in:
parent
5a8ba61ffd
commit
e3762fc983
6 changed files with 506 additions and 0 deletions
8
test_problems/cathermo/ims/.cvsignore
Normal file
8
test_problems/cathermo/ims/.cvsignore
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Makefile
|
||||
.depends
|
||||
IMSTester
|
||||
IMSTester.d
|
||||
csvCode.txt
|
||||
diff_test.out
|
||||
output.txt
|
||||
outputa.txt
|
||||
160
test_problems/cathermo/ims/IMSTester.cpp
Normal file
160
test_problems/cathermo/ims/IMSTester.cpp
Normal file
|
|
@ -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 <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
/***********************************************************/
|
||||
112
test_problems/cathermo/ims/Makefile.in
Normal file
112
test_problems/cathermo/ims/Makefile.in
Normal 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 = 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 )
|
||||
|
||||
167
test_problems/cathermo/ims/WaterPlusSolutes.xml
Normal file
167
test_problems/cathermo/ims/WaterPlusSolutes.xml
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
<?xml version="1.0"?>
|
||||
<ctml>
|
||||
|
||||
<phase id="WaterPlusSolutes" dim="3">
|
||||
<state>
|
||||
<temperature units="K">300</temperature>
|
||||
</state>
|
||||
<!-- thermo model identifies the inherited class
|
||||
from ThermoPhase that will handle the thermodynamics.
|
||||
-->
|
||||
<thermo model="IdealMolalSoln">
|
||||
<standardConc model="solvent_volume" />
|
||||
<solvent> H2O(l) </solvent>
|
||||
</thermo>
|
||||
<elementArray datasrc="elements.xml">
|
||||
O H C Fe Ca N S
|
||||
</elementArray>
|
||||
<speciesArray datasrc="#species_waterSolution">
|
||||
H2O(l) CO2(aq) H2S(aq) CH4(aq) C6H6(aq)
|
||||
</speciesArray>
|
||||
</phase>
|
||||
|
||||
<!-- species data
|
||||
Note that these entries are for demonstration only, and the thermo
|
||||
is made up.
|
||||
-->
|
||||
|
||||
<speciesData id="species_waterSolution">
|
||||
|
||||
<species name="H2O(l)">
|
||||
<note>This corresponds to new soot</note>
|
||||
<atomArray>H:2 O:1 </atomArray>
|
||||
<thermo>
|
||||
<NASA P0="100000.0" Tmax="1000.0" Tmin="200.0">
|
||||
<floatArray size="7" title="low">
|
||||
2.344331120E+000, 7.980520750E-003, -1.947815100E-005,
|
||||
2.015720940E-008, -7.376117610E-012, -9.179351730E+002,
|
||||
6.830102380E-001
|
||||
</floatArray>
|
||||
</NASA>
|
||||
<NASA P0="100000.0" Tmax="3500.0" Tmin="1000.0">
|
||||
<floatArray size="7" title="high">
|
||||
3.337279200E+000, -4.940247310E-005, 4.994567780E-007,
|
||||
-1.795663940E-010, 2.002553760E-014, -9.501589220E+002,
|
||||
-3.205023310E+000
|
||||
</floatArray>
|
||||
</NASA>
|
||||
</thermo>
|
||||
<standardState model="constant_incompressible">
|
||||
<molarVolume> 1.5 </molarVolume>
|
||||
</standardState>
|
||||
</species>
|
||||
|
||||
<species name="CO2(aq)">
|
||||
<atomArray> C:1 O:2 </atomArray>
|
||||
<thermo>
|
||||
<NASA P0="100000.0" Tmax="1000.0" Tmin="200.0">
|
||||
<floatArray size="7" title="low">
|
||||
2.344331120E+000, 7.980520750E-003, -1.947815100E-005,
|
||||
2.015720940E-008, -7.376117610E-012, -9.179351730E+002,
|
||||
6.830102380E-001
|
||||
</floatArray>
|
||||
</NASA>
|
||||
<NASA P0="100000.0" Tmax="3500.0" Tmin="1000.0">
|
||||
<floatArray size="7" title="high">
|
||||
3.337279200E+000, -4.940247310E-005, 4.994567780E-007,
|
||||
-1.795663940E-010, 2.002553760E-014, -9.501589220E+002,
|
||||
-3.205023310E+000
|
||||
</floatArray>
|
||||
</NASA>
|
||||
</thermo>
|
||||
<standardState model="constant_incompressible">
|
||||
<molarVolume> 1.3 </molarVolume>
|
||||
</standardState>
|
||||
</species>
|
||||
|
||||
<species name="H2S(aq)">
|
||||
<atomArray> H:2 S:1 </atomArray>
|
||||
<thermo>
|
||||
<NASA P0="100000.0" Tmax="1000.0" Tmin="200.0">
|
||||
<floatArray size="7" title="low">
|
||||
2.344331120E+000, 7.980520750E-003, -1.947815100E-005,
|
||||
2.015720940E-008, -7.376117610E-012, -9.179351730E+002,
|
||||
6.830102380E-001
|
||||
</floatArray>
|
||||
</NASA>
|
||||
<NASA P0="100000.0" Tmax="3500.0" Tmin="1000.0">
|
||||
<floatArray size="7" title="high">
|
||||
3.337279200E+000, -4.940247310E-005, 4.994567780E-007,
|
||||
-1.795663940E-010, 2.002553760E-014, -9.501589220E+002,
|
||||
-3.205023310E+000
|
||||
</floatArray>
|
||||
</NASA>
|
||||
</thermo>
|
||||
<standardState model="constant_incompressible">
|
||||
<molarVolume> 0.1 </molarVolume>
|
||||
</standardState>
|
||||
</species>
|
||||
|
||||
<species name="CH4(aq)">
|
||||
<atomArray> C:1 H:4 </atomArray>
|
||||
<thermo>
|
||||
<NASA P0="100000.0" Tmax="1000.0" Tmin="200.0">
|
||||
<floatArray size="7" title="low">
|
||||
2.344331120E+000, 7.980520750E-003, -1.947815100E-005,
|
||||
2.015720940E-008, -7.376117610E-012, -9.179351730E+002,
|
||||
6.830102380E-001
|
||||
</floatArray>
|
||||
</NASA>
|
||||
<NASA P0="100000.0" Tmax="3500.0" Tmin="1000.0">
|
||||
<floatArray size="7" title="high">
|
||||
3.337279200E+000, -4.940247310E-005, 4.994567780E-007,
|
||||
-1.795663940E-010, 2.002553760E-014, -9.501589220E+002,
|
||||
-3.205023310E+000
|
||||
</floatArray>
|
||||
</NASA>
|
||||
</thermo>
|
||||
<standardState model="constant_incompressible">
|
||||
<molarVolume> 0.1 </molarVolume>
|
||||
</standardState>
|
||||
</species>
|
||||
|
||||
<species name="C6H6(aq)">
|
||||
<atomArray> C:6 H:6 </atomArray>
|
||||
<thermo>
|
||||
<NASA P0="100000.0" Tmax="1000.0" Tmin="200.0">
|
||||
<floatArray size="7" title="low">
|
||||
2.344331120E+000, 7.980520750E-003, -1.947815100E-005,
|
||||
2.015720940E-008, -7.376117610E-012, -9.179351730E+002,
|
||||
6.830102380E-001
|
||||
</floatArray>
|
||||
</NASA>
|
||||
<NASA P0="100000.0" Tmax="3500.0" Tmin="1000.0">
|
||||
<floatArray size="7" title="high">
|
||||
3.337279200E+000, -4.940247310E-005, 4.994567780E-007,
|
||||
-1.795663940E-010, 2.002553760E-014, -9.501589220E+002,
|
||||
-3.205023310E+000
|
||||
</floatArray>
|
||||
</NASA>
|
||||
</thermo>
|
||||
<standardState model="constant_incompressible">
|
||||
<molarVolume> 0.1 </molarVolume>
|
||||
</standardState>
|
||||
</species>
|
||||
|
||||
</speciesData>
|
||||
|
||||
<!-- reaction data -->
|
||||
<reactionData id="reactions_solidSolution" model="SolidKinetics" submodel="SolidKinetics_0">
|
||||
<standardConc model="solvent_volume" />
|
||||
|
||||
<!-- reaction 1 -->
|
||||
<reaction id="bulk_rxn_1" reversible="yes">
|
||||
<equation>C2H2-graph [=] H2-solute + 2 C-graph</equation>
|
||||
<reactants> C2H2-graph:1 </reactants>
|
||||
<products>H2-solute:1 C-graph:2 </products>
|
||||
<rateCoeff>
|
||||
<Arrhenius order="1">
|
||||
<A> 1.0E10 </A>
|
||||
<b> 0.0 </b>
|
||||
<E units="cal/mol"> 10000. </E>
|
||||
</Arrhenius>
|
||||
</rateCoeff>
|
||||
</reaction>
|
||||
|
||||
</reactionData>
|
||||
</ctml>
|
||||
27
test_problems/cathermo/ims/output_blessed.txt
Normal file
27
test_problems/cathermo/ims/output_blessed.txt
Normal file
|
|
@ -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
|
||||
32
test_problems/cathermo/ims/runtest
Executable file
32
test_problems/cathermo/ims/runtest
Executable file
|
|
@ -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
|
||||
|
||||
Loading…
Add table
Reference in a new issue