Added another test program for the element potential equilibrium

solver.
This test does a matrix of T, pres, and mixture fraction for the
gri30 mechanism. It does a total of 1500 calculation starting from
a bad initial guess.
This commit is contained in:
Harry Moffat 2006-10-20 21:12:45 +00:00
parent 0fcd46a958
commit 18152a04b3
6 changed files with 6861 additions and 0 deletions

View file

@ -0,0 +1,7 @@
Makefile
csvCode.txt
diff_test.out
gri_matrix
output.txt
outputa.txt
tmp

View file

@ -0,0 +1,110 @@
#!/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 = gri_matrix
# the object files to be linked together. List those generated from Fortran
# and from C/C++ separately
OBJS = gri_matrix.o
# Location of the current build. Will assume that tests are run
# in the source directory tree location
src_dir_tree = 0
# 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
else
CANTERA_INCDIR=@ctroot@/build/include/cantera
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 $< -I$(CANTERA_INCDIR) $(CXX_FLAGS)
# How to compile the dependency file
.cpp.d:
g++ -MM -I$(CANTERA_INCDIR) $(CXX_FLAGS) $*.cpp > $*.d
# List of dependency files to be created
DEPENDS=$(OBJS:.o=.d)
# Program Name
PROGRAM = $(PROG_NAME)$(EXE_EXT)
all: $(PROGRAM)
$(PROGRAM): $(OBJS) $(CANTERA_LIBDIR)/libcantera.a
$(CXX) -o $(PROGRAM) $(OBJS) $(LCXX_FLAGS) $(LINK_OPTIONS) \
$(CANTERA_LIBS) @LIBS@ $(FORT_LIBS) \
$(LCXX_END_LIBS)
# depends target -> forces recalculation of dependencies
depends:
$(RM) *.d .depends
@MAKE@ .depends
.depends: $(DEPENDS)
cat *.d > .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 )

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,249 @@
/*
* $Author$
* $Date$
* $Revision$
*
* Copyright 2002 California Institute of Technology
*
*/
#ifdef SRCDIRTREE
#include "ct_defs.h"
#include "ThermoPhase.h"
#include "IdealGasMix.h"
#include "equil.h"
#else
#include "Cantera.h"
#include "IdealGasMix.h"
#include "equilibrium.h"
#endif
int main(int argc, char **argv) {
int numSucc = 0;
int numFail = 0;
try {
int retnSub;
double T = 500.;
IdealGasMix g("gri30.xml", "gri30_mix");
double pres = OneAtm;
int kk = g.nSpecies();
vector_fp Xmol(kk, 0.0);
int iCH4 = g.speciesIndex("CH4");
int iO2 = g.speciesIndex("O2");
int iN2 = g.speciesIndex("N2");
/*
* Do an initial calculation that can be debugged
* easily
*/
Xmol[iCH4] = 0.6;
Xmol[iO2] = 0.0;
Xmol[iN2] = 0.4;
g.setState_TPX(T, pres, DATA_PTR(Xmol));
try {
retnSub = equilibrate(g, "TP", -1);
cout << g;
if (retnSub != 1) {
cerr << "ERROR: ChemEquil equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
cout << "ERROR: ChemEquil equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
exit(-1);
}
} catch (CanteraError) {
cout << g;
showErrors(cerr);
cerr << "ERROR: equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
cout << "ERROR: equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
exit(-1);
}
/*
* Do an initial calculation that can be debugged
* easily
*/
Xmol[iCH4] = 0.0;
Xmol[iO2] = 0.6;
Xmol[iN2] = 0.4;
g.setState_TPX(T, pres, DATA_PTR(Xmol));
try {
retnSub = equilibrate(g, "TP", -1);
cout << g;
if (retnSub != 1) {
cerr << "ERROR: ChemEquil equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
cout << "ERROR: ChemEquil equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
exit(-1);
}
} catch (CanteraError) {
cout << g;
showErrors(cerr);
cerr << "ERROR: equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
cout << "ERROR: equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
exit(-1);
}
/*
* Do an initial calculation that can be debugged
* easily
*/
Xmol[iCH4] = 0.3;
Xmol[iO2] = 0.3;
Xmol[iN2] = 0.4;
T = 2000.;
pres = OneAtm;
g.setState_TPX(T, pres, DATA_PTR(Xmol));
try {
retnSub = equilibrate(g, "TP", -1);
cout << g;
if (retnSub != 1) {
cerr << "ERROR: ChemEquil equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
cout << "ERROR: ChemEquil equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
exit(-1);
}
} catch (CanteraError) {
cout << g;
showErrors(cerr);
cerr << "ERROR: equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
cout << "ERROR: equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
exit(-1);
}
/*
* Do an initial calculation that can be debugged
* easily
*/
Xmol[iCH4] = 0.3;
Xmol[iO2] = 0.3;
Xmol[iN2] = 0.0;
T = 2000.;
pres = 1.0;
g.setState_TPX(T, pres, DATA_PTR(Xmol));
try {
retnSub = equilibrate(g, "TP", -1);
cout << g;
if (retnSub != 1) {
cerr << "ERROR: ChemEquil equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
cout << "ERROR: ChemEquil equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
exit(-1);
}
} catch (CanteraError) {
cout << g;
showErrors(cerr);
cerr << "ERROR: equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
cout << "ERROR: equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
exit(-1);
}
/*
* OK do the matrix.
*/
bool showResults = false;
for (int iS = 0; iS < 6; iS++) {
Xmol[iCH4] = iS * 0.6 / 5.0;
Xmol[iO2] = 1.0 - Xmol[iCH4] - Xmol[iN2];
for (int iP = 0; iP < 10; iP++) {
pres = pow(10.0, iP) *1.0E-2;
for (int iT = 0; iT < 25; iT++) {
double T = 100. * iT + 300.;
/*
* Reset mole fractions to a base state
*/
g.setState_TPX(T, pres, DATA_PTR(Xmol));
retnSub = 0;
try {
retnSub = equilibrate(g, "TP", -1);
if (retnSub != 1) {
cerr << "ERROR: ChemEquil equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
cout << "ERROR: ChemEquil equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
}
} catch (CanteraError) {
showErrors(cerr);
cerr << "ERROR: equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
cout << "ERROR: equilibration step failed at "
<< " T = " << T
<< " Pres = " << pres
<< endl;
}
if (showResults) {
cout << g;
}
if (retnSub ==1) {
numSucc++;
} else {
numFail++;
}
}
}
}
cout << "NUMBER OF SUCCESSES = " << numSucc << endl;
cout << "NUMBER OF FAILURES = " << numFail << endl;
return numFail;
}
catch (CanteraError) {
showErrors(cerr);
cerr << "ERROR: program terminating due to unforeseen circumstances." << endl;
return -1;
}
}

View file

@ -0,0 +1,290 @@
gri30_mix:
temperature 500 K
pressure 101325 Pa
density 0.507719 kg/m^3
mean mol. weight 20.8311 amu
1 kg 1 kmol
----------- ------------
enthalpy -1.7981e+06 -3.746e+07 J
internal energy -1.99767e+06 -4.161e+07 J
entropy 10204.8 2.126e+05 J/K
Gibbs function -6.90049e+06 -1.437e+08 J
heat capacity c_p 1908.33 3.975e+04 J/K
heat capacity c_v 1509.19 3.144e+04 J/K
X Y Chem. Pot. / RT
------------- ------------ ------------
H2 0.000116242 1.1249e-05 -25.1739
H 7.50073e-23 3.62934e-24 -12.587
O 0 0
O2 0 0
OH 0 0
H2O 0 0
HO2 0 0
H2O2 0 0
C 2.51101e-63 1.44783e-63 8.95153
CH 5.65939e-55 3.53699e-55 -3.63544
CH2 2.17058e-38 1.46159e-38 -16.2224
CH2(S) 1.35699e-42 9.13749e-43 -16.2224
CH3 3.27367e-18 2.36277e-18 -28.8094
CH4 0.599767 0.461903 -41.3964
CO 0 0
CO2 0 0
HCO 0 0
CH2O 0 0
CH2OH 0 0
CH3O 0 0
CH3OH 0 0
C2H 3.61998e-46 4.34965e-46 5.31609
C2H2 6.0347e-17 7.5431e-17 -7.27089
C2H3 3.63018e-28 4.71321e-28 -19.8579
C2H4 1.47659e-08 1.98857e-08 -32.4448
C2H5 1.95525e-19 2.7278e-19 -45.0318
C2H6 0.000116084 0.000167567 -57.6188
HCCO 0 0
CH2CO 0 0
HCCOH 0 0
N 2.91172e-47 1.95783e-47 -12.1739
NH 3.97359e-39 2.8641e-39 -24.7609
NH2 1.27658e-26 9.81908e-27 -37.3479
NH3 2.50763e-07 2.05013e-07 -49.9348
NNH 6.80126e-31 9.47538e-31 -36.9348
NO 0 0
NO2 0 0
N2O 0 0
HNO 0 0
CN 3.39689e-37 4.24268e-37 -3.22238
HCN 1.71533e-10 2.22543e-10 -15.8094
H2CN 6.1207e-27 8.237e-27 -28.3963
HCNN 8.8321e-48 1.73972e-47 -27.9833
HCNO 0 0
HOCN 0 0
HNCO 0 0
NCO 0 0
N2 0.4 0.537918 -24.3478
AR 0 0
C3H7 3.21265e-22 6.64529e-22 -61.2542
C3H8 2.52213e-07 5.339e-07 -73.8412
CH2CHO 0 0
CH3CHO 0 0
gri30_mix:
temperature 500 K
pressure 101325 Pa
density 0.741058 kg/m^3
mean mol. weight 30.4047 amu
1 kg 1 kmol
----------- ------------
enthalpy 198008 6.02e+06 J
internal energy 61277.4 1.863e+06 J
entropy 7258.13 2.207e+05 J/K
Gibbs function -3.43106e+06 -1.043e+08 J
heat capacity c_p 1003.28 3.05e+04 J/K
heat capacity c_v 729.823 2.219e+04 J/K
X Y Chem. Pot. / RT
------------- ------------ ------------
H2 0 0
H 0 0
O 8.98043e-24 4.72564e-24 -12.7954
O2 0.6 0.631458 -25.5908
OH 0 0
H2O 0 0
HO2 0 0
H2O2 0 0
C 0 0
CH 0 0
CH2 0 0
CH2(S) 0 0
CH3 0 0
CH4 0 0
CO 0 0
CO2 0 0
HCO 0 0
CH2O 0 0
CH2OH 0 0
CH3O 0 0
CH3OH 0 0
C2H 0 0
C2H2 0 0
C2H3 0 0
C2H4 0 0
C2H5 0 0
C2H6 0 0
HCCO 0 0
CH2CO 0 0
HCCOH 0 0
N 2.91172e-47 1.34136e-47 -12.1739
NH 0 0
NH2 0 0
NH3 0 0
NNH 0 0
NO 6.40857e-10 6.32457e-10 -24.9693
NO2 6.36105e-08 9.62495e-08 -37.7647
N2O 1.20106e-13 1.73862e-13 -37.1432
HNO 0 0
CN 0 0
HCN 0 0
H2CN 0 0
HCNN 0 0
HCNO 0 0
HOCN 0 0
HNCO 0 0
NCO 0 0
N2 0.4 0.368542 -24.3478
AR 0 0
C3H7 0 0
C3H8 0 0
CH2CHO 0 0
CH3CHO 0 0
gri30_mix:
temperature 2000 K
pressure 101325 Pa
density 0.120021 kg/m^3
mean mol. weight 19.6972 amu
1 kg 1 kmol
----------- ------------
enthalpy -1.14349e+06 -2.252e+07 J
internal energy -1.98772e+06 -3.915e+07 J
entropy 12855 2.532e+05 J/K
Gibbs function -2.68534e+07 -5.289e+08 J
heat capacity c_p 2004.72 3.949e+04 J/K
heat capacity c_v 1582.61 3.117e+04 J/K
X Y Chem. Pot. / RT
------------- ------------ ------------
H2 0.262869 0.0269029 -20.8151
H 0.000834397 4.26975e-05 -10.4075
O 1.45323e-07 1.18041e-07 -22.8166
O2 4.72395e-08 7.67422e-08 -45.6333
OH 6.26815e-05 5.41216e-05 -33.2242
H2O 0.198012 0.181103 -43.6317
HO2 4.13259e-11 6.925e-11 -56.0408
H2O2 8.04483e-11 1.38924e-10 -66.4484
C 9.37794e-16 5.71849e-16 -13.1535
CH 2.5887e-15 1.71101e-15 -23.561
CH2 2.34345e-13 1.66883e-13 -33.9686
CH2(S) 1.13506e-14 8.08304e-15 -33.9686
CH3 5.70093e-11 4.3515e-11 -44.3761
CH4 9.12163e-10 7.42928e-10 -54.7837
CO 0.198076 0.281674 -35.9701
CO2 0.0325892 0.0728146 -58.7868
HCO 5.95957e-08 8.77975e-08 -46.3777
CH2O 2.14619e-08 3.27164e-08 -56.7852
CH2OH 3.20751e-13 5.05364e-13 -67.1928
CH3O 4.25882e-15 6.71004e-15 -67.1928
CH3OH 7.49906e-13 1.2199e-12 -77.6003
C2H 1.13972e-17 1.44828e-17 -36.7145
C2H2 1.92206e-13 2.54078e-13 -47.122
C2H3 8.41511e-18 1.15546e-17 -57.5296
C2H4 3.42916e-16 4.88397e-16 -67.9371
C2H5 2.15437e-20 3.17861e-20 -78.3447
C2H6 4.61488e-20 7.04504e-20 -88.7522
HCCO 5.83197e-15 1.2148e-14 -59.5311
CH2CO 2.60466e-13 5.5588e-13 -69.9387
HCCOH 1.13765e-16 2.42793e-16 -69.9387
N 5.02707e-10 3.57477e-10 -14.0552
NH 1.50719e-09 1.14889e-09 -24.4627
NH2 1.44254e-08 1.17343e-08 -34.8703
NH3 1.53645e-06 1.32844e-06 -45.2778
NNH 6.16147e-10 9.07817e-10 -38.5179
NO 2.27843e-06 3.47089e-06 -36.8718
NO2 1.87305e-12 4.37477e-12 -59.6885
N2O 8.05639e-11 1.80018e-10 -50.9271
HNO 3.16512e-10 4.98361e-10 -47.2794
CN 1.06666e-11 1.40893e-11 -27.2087
HCN 1.6694e-07 2.29051e-07 -37.6162
H2CN 2.03354e-13 2.89418e-13 -48.0238
HCNN 9.59376e-19 1.99853e-18 -51.6714
HCNO 2.14902e-15 4.69415e-15 -60.4329
HOCN 7.61903e-11 1.66424e-10 -60.4329
HNCO 4.82851e-08 1.0547e-07 -60.4329
NCO 4.83294e-11 1.03094e-10 -50.0253
N2 0.307552 0.437403 -28.1104
AR 0 0
C3H7 2.6613e-30 5.82171e-30 -112.313
C3H8 5.43498e-30 1.21674e-29 -122.721
CH2CHO 6.11141e-18 1.33555e-17 -80.3462
CH3CHO 3.34175e-17 7.47388e-17 -90.7538
gri30_mix:
temperature 2000 K
pressure 1 Pa
density 8.11603e-07 kg/m^3
mean mol. weight 13.4961 amu
1 kg 1 kmol
----------- ------------
enthalpy 1.84736e+06 2.493e+07 J
internal energy 615230 8.303e+06 J
entropy 24280.4 3.277e+05 J/K
Gibbs function -4.67135e+07 -6.304e+08 J
heat capacity c_p 2638.92 3.562e+04 J/K
heat capacity c_v 2022.85 2.73e+04 J/K
X Y Chem. Pot. / RT
------------- ------------ ------------
H2 0.234986 0.0350993 -32.4533
H 0.251121 0.0187546 -16.2267
O 0.0158988 0.0188478 -22.7399
O2 0.00558021 0.0132305 -45.4799
OH 0.0203687 0.0256679 -38.9666
H2O 0.19112 0.255117 -55.1932
HO2 1.44997e-08 3.54612e-08 -61.7065
H2O2 8.38392e-11 2.11303e-10 -77.9332
C 1.04601e-15 9.30911e-16 -24.5704
CH 8.57638e-18 8.27316e-18 -40.797
CH2 2.30606e-18 2.39676e-18 -57.0237
CH2(S) 1.11695e-19 1.16088e-19 -57.0237
CH3 1.6663e-18 1.85628e-18 -73.2503
CH4 7.91906e-20 9.41336e-20 -89.477
CO 0.238548 0.495094 -47.3103
CO2 0.0423771 0.138189 -70.0502
HCO 2.13182e-10 4.58369e-10 -63.5369
CH2O 2.28033e-13 5.07331e-13 -79.7636
CH2OH 1.01226e-20 2.32768e-20 -95.9903
CH3O 1.34404e-22 3.09061e-22 -95.9903
CH3OH 7.02945e-23 1.66892e-22 -112.217
C2H 4.15655e-25 7.70877e-25 -65.3674
C2H2 2.08207e-23 4.01692e-23 -81.594
C2H3 2.70758e-30 5.42591e-30 -97.8207
C2H4 3.27719e-31 6.81215e-31 -114.047
C2H5 6.11544e-38 1.31686e-37 -130.274
C2H6 3.89099e-40 8.66922e-40 -146.501
HCCO 2.29649e-22 6.98154e-22 -88.1073
CH2CO 3.04645e-23 9.489e-23 -104.334
HCCOH 1.33061e-26 4.14454e-26 -104.334
N 0 0
NH 0 0
NH2 0 0
NH3 0 0
NNH 0 0
NO 0 0
NO2 0 0
N2O 0 0
HNO 0 0
CN 0 0
HCN 0 0
H2CN 0 0
HCNN 0 0
HCNO 0 0
HOCN 0 0
HNCO 0 0
NCO 0 0
N2 0 0
AR 0 0
C3H7 7.33667e-58 2.34236e-57 -187.298
C3H8 4.45038e-60 1.4541e-59 -203.524
CH2CHO 2.12313e-30 6.77164e-30 -120.561
CH3CHO 3.44828e-32 1.12557e-31 -136.787
NUMBER OF SUCCESSES = 1500
NUMBER OF FAILURES = 0

View 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}
./gri_matrix > output.txt
retnStat=$?
if [ $retnStat != "0" ]
then
temp_success="0"
echo "silane_equil returned with bad status, $retnStat, check output"
fi
../../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 ChemEquil_gri_matrix test"
else
echo "unsuccessful diff comparison on ChemEquil_gri_matrix test"
echo "FAILED" > csvCode.txt
temp_success="0"
fi