Updating demos to inclue sample output and a testing capability

This commit is contained in:
Harry Moffat 2009-03-16 20:02:27 +00:00
parent e5145855cb
commit 112a71013e
17 changed files with 1333 additions and 403 deletions

View file

@ -4,109 +4,32 @@
# Cantera.
#
#############################################################################
.SUFFIXES :
.SUFFIXES : .cpp .d .o .dh .h .h.gch
# the name of the executable program to be created
PROG_NAME = demos@EXE_EXT@
# the object files to be linked together. List those generated from Fortran
# and from C/C++ separately
OBJS = demos.o
# additional flags to be passed to the linker. If your program
# requires other external libraries, put them here
LINK_OPTIONS = @EXTRA_LINK@
#############################################################################
# True if we are in the source directory tree
srcdirtree=1
# Fortran libraries
FORT_LIBS = @FLIBS@
# Purify options
PURIFY=@PURIFY@
# the C++ compiler
CXX = @CXX@
# C++ compile flags
CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@
# external libraries
EXT_LIBS = @LOCAL_LIBS@ -ltpx -lctcxx
# 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 =
# Depends
ifeq ($srcdirtree, 1)
LOCAL_DEFNS = -DSRCDIRTREE
else
LOCAL_DEFNS =
endif
# the directory where Cantera include files may be found.
CANTERA_INCDIR=@ctroot@/build/include
# 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@:
$(PURIFY) $(CXX) -c $< -I$(CANTERA_INCDIR) $(CXX_FLAGS) $(LOCAL_DEFNS)
# how to create a dependency file
.@CXX_EXT@.d:
@CXX_DEPENDS@ -I$(CANTERA_INCDIR) $(CXX_FLAGS) $(LOCAL_DEFNS) $*.cpp > $*.d
PROGRAM = $(PROG_NAME)$(EXE_EXT)
DEPENDS = $(OBJS:.o=.d)
all: $(PROGRAM)
$(PROGRAM): $(OBJS)
$(PURIFY) $(CXX) -o $(PROGRAM) $(OBJS) $(LCXX_FLAGS) $(CANTERA_LIBS) \
$(LINK_OPTIONS) $(EXT_LIBS) @LIBS@ $(FORT_LIBS) \
$(LCXX_END_LIBS)
test:
@MAKE@ $(PROGRAM)
echo 100 | $(PROGRAM) > $(PROGRAM).out
cd combustor; @MAKE@ test
cd kinetics1; @MAKE@ test
cd flamespeed; @MAKE@ test
cd NASA_coeffs; @MAKE@ test
install:
@INSTALL@ -d @ct_demodir@/cxx
@(for ihhh in *.cpp *.h Makefile.install ; do \
@INSTALL@ -c $${ihhh} @ct_demodir@/cxx ; \
echo "@INSTALL@ -c $${ihhh} @ct_demodir@/cxx" ; \
done )
@INSTALL@ Makefile -m ug+rw,o+r @ct_demodir@/cxx
cd combustor; @MAKE@ install
cd flamespeed; @MAKE@ install
cd kinetics1; @MAKE@ install
cd NASA_coeffs; @MAKE@ install
depends: $(DEPENDS)
@MAKE@ .depends
depends:
cd combustor; @MAKE@ depends
cd kinetics1; @MAKE@ depends
cd flamespeed; @MAKE@ depends
cd NASA_coeffs; @MAKE@ depends
.depends: $(DEPENDS)
cat $(DEPENDS) > .depends
clean:
$(RM) $(OBJS) $(PROGRAM) .depends *.d
../../../bin/rm_cvsignore
(if test -d SunWS_cache ; then \
$(RM) -rf SunWS_cache ; \
fi )
cd combustor; @MAKE@ clean
cd kinetics1; @MAKE@ clean
cd flamespeed; @MAKE@ clean
cd NASA_coeffs; @MAKE@ clean
TAGS:
etags *.h *.cpp
ifeq ($(wildcard .depends), .depends)
include .depends
endif

View file

@ -1,34 +0,0 @@
# This Makefile uses script 'ctnew' to create the Makefiles for each
# demo program. This script is created during the Cantera build
# process, and is installed by default in /usr/local/bin.
# if script ctnew is not on the PATH, set this to the path to it.
CTNEW = ctnew
.SUFFIXES :
.SUFFIXES : .mak
SRCS = kinetics1.cpp flamespeed.cpp rankine.cpp
OBJS = $(SRCS:.cpp=.o)
EXES = $(SRCS:.cpp=.x)
MKS = $(SRCS:.cpp=.mak)
all: $(EXES)
%.mak:
$(CTNEW); sed 's/demo/$*/g' demo.mak > $*.mak
%.x:
@echo
@echo Building program $*.x...
@echo
make $*.mak; make -f $*.mak; mv $* $*.x
@echo
@echo type '$*.x' to run the program
@echo
clean:
rm -f $(OBJS) $(EXES) $(MKS)

View file

@ -0,0 +1,9 @@
Makefile
Makefile.install
NASA_coeffs
ct2ctml.log
diff_out_0.txt
gri30.xml
h2o2.xml
output_0.txt
transport_log.xml

View file

@ -0,0 +1,118 @@
############################################################################
#
# Makefile to compile and link a C++ application to
# Cantera.
#
#############################################################################
.SUFFIXES :
.SUFFIXES : .cpp .d .o .d .h
# the name of the executable program to be created
PROG_NAME = NASA_coeffs
# the object files to be linked together. List those generated from Fortran
# and from C/C++ separately
OBJS = NASA_coeffs.o
# additional flags to be passed to the linker. If your program
# requires other external libraries, put them here
LINK_OPTIONS = @EXTRA_LINK@
#############################################################################
# True if we are in the source directory tree
srcdirtree=1
# Fortran libraries
FORT_LIBS = @FLIBS@
# Purify options
PURIFY=@PURIFY@
# the C++ compiler
CXX = @CXX@
# C++ compile flags
CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@
# external libraries
EXT_LIBS = @LOCAL_LIBS@ -ltpx -lctcxx
# 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 =
# Depends
ifeq ($srcdirtree, 1)
LOCAL_DEFNS = -DSRCDIRTREE
else
LOCAL_DEFNS =
endif
# the directory where Cantera include files may be found.
CANTERA_INCDIR=@ctroot@/build/include
# 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@:
$(PURIFY) $(CXX) -c $< -I$(CANTERA_INCDIR) $(CXX_FLAGS) $(LOCAL_DEFNS)
# how to create a dependency file
.@CXX_EXT@.d:
@CXX_DEPENDS@ -I$(CANTERA_INCDIR) $(CXX_FLAGS) $(LOCAL_DEFNS) $*.cpp > $*.d
PROGRAM = $(PROG_NAME)$(EXE_EXT)
DEPENDS = $(OBJS:.o=.d)
all: $(PROGRAM)
$(PROGRAM): $(OBJS)
$(PURIFY) $(CXX) -o $(PROGRAM) $(OBJS) $(LCXX_FLAGS) $(CANTERA_LIBS) \
$(LINK_OPTIONS) $(EXT_LIBS) @LIBS@ $(FORT_LIBS) \
$(LCXX_END_LIBS)
test:
@MAKE@ $(PROGRAM)
./runtest
INSTALL_DIR=@ct_demodir@/cxx/NASA_coeffs
install:
@INSTALL@ -d $(INSTALL_DIR)
@INSTALL@ -c -m ug+rw,o+r Makefile.install $(INSTALL_DIR)/Makefile
@(for ihhh in *.cpp *blessed* ; do \
@INSTALL@ $${ihhh} -m ug+rw,o+r $(INSTALL_DIR) ; \
echo "@INSTALL@ $${ihhh} -m ug+rw,o+r $(INSTALL_DIR)" ; \
done )
@INSTALL@ runtest $(INSTALL_DIR) ;
depends: $(DEPENDS)
@MAKE@ .depends
.depends: $(DEPENDS)
cat $(DEPENDS) > .depends
clean:
$(RM) $(OBJS) $(PROGRAM) .depends *.d
$(RM) ct2ctml.log diff* output_0.txt transport_log.xml \
NASA_coeffs.csv
(if test -d SunWS_cache ; then \
$(RM) -rf SunWS_cache ; \
fi )
TAGS:
etags *.h *.cpp
ifeq ($(wildcard .depends), .depends)
include .depends
endif

View file

@ -0,0 +1,97 @@
#!/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 = NASA_coeffs
# the object files to be linked together. List those generated from Fortran
# and from C/C++ separately
OBJS = NASA_coeffs.o
# additional flags to be passed to the linker. If your program
# requires other external libraries, put them here
LINK_OPTIONS =
#############################################################################
# These links are to Cantera's install space
CANTERA_INCROOT = @ct_incroot@
#
# Bring in the Cantera includes through the .mak file
#
include $(CANTERA_INCROOT)/cantera/Cantera.mak
# 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@
#
# The directory where Cantera include files may be found.
#
INCLUDE_DIRS = -I../../src -I$(CANTERA_INCROOT)
#
# C++ compile flags
CXX_FLAGS = @CXXFLAGS@ $(INCLUDE_DIRS) -DUSE_VCSNONIDEAL
#
# Ending C++ linking libraries
LCXX_END_LIBS = @LCXX_END_LIBS@
# flags passed to the C++ compiler/linker for the linking step
LCXX_FLAGS = @CXXFLAGS@
# How to compile C++ source files to object files
.cpp.o:
$(CXX) $(CXX_FLAGS) -c $<
# How to compile the dependency file
.cpp.d:
@CXX_DEPENDS@ $(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_CORE_LIBS_DEP)
$(CXX) -o $(PROGRAM) $(OBJS) $(LCXX_FLAGS) $(LINK_OPTIONS) \
$(CANTERA_TOTAL_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) *.o $(PROGRAM) $(DEPENDS) .depends
(if test -d SunWS_cache ; then \
$(RM) -rf SunWS_cache ; \
fi )

View file

@ -2,6 +2,15 @@
#include <cantera/Cantera.h>
#include <cantera/IdealGasMix.h> // defines class IdealGasMix
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <algorithm>
using namespace std;
using namespace Cantera;
@ -29,7 +38,7 @@ void demoprog() {
// location, followed by the 7 low-temperature coefficients, then
// the seven high-temperature ones.
const int LOW_A6 = 6;
const int HIGH_A6 = 13;
//const int HIGH_A6 = 13;
for (n = 0; n < nsp; n++) {

View file

@ -0,0 +1,167 @@
**** Testing modifying NASA polynomial coefficients ****
H2 (original):
A1 A2 A3 A4 A5 A6 A7
low: 2.3443E+00 7.9805E-03 -1.9478E-05 2.0157E-08 -7.3761E-12 -9.1794E+02 6.8301E-01
high: 3.3373E+00 -4.9402E-05 4.9946E-07 -1.7957E-10 2.0026E-14 -9.5016E+02 -3.2050E+00
**** WARNING ****
For species H2, discontinuity in h/RT detected at Tmid = 1000
Value computed using low-temperature polynomial: 12.488.
Value computed using high-temperature polynomial: 2.48802.
H2 (modified):
A1 A2 A3 A4 A5 A6 A7
low: 2.3443E+00 7.9805E-03 -1.9478E-05 2.0157E-08 -7.3761E-12 9.0821E+03 6.8301E-01
high: 3.3373E+00 -4.9402E-05 4.9946E-07 -1.7957E-10 2.0026E-14 -9.5016E+02 -3.2050E+00
H (original):
A1 A2 A3 A4 A5 A6 A7
low: 2.5000E+00 7.0533E-13 -1.9959E-15 2.3008E-18 -9.2773E-22 2.5474E+04 -4.4668E-01
high: 2.5000E+00 -2.3084E-11 1.6156E-14 -4.7352E-18 4.9820E-22 2.5474E+04 -4.4668E-01
**** WARNING ****
For species H, discontinuity in h/RT detected at Tmid = 1000
Value computed using low-temperature polynomial: 37.9737.
Value computed using high-temperature polynomial: 27.9737.
H (modified):
A1 A2 A3 A4 A5 A6 A7
low: 2.5000E+00 7.0533E-13 -1.9959E-15 2.3008E-18 -9.2773E-22 3.5474E+04 -4.4668E-01
high: 2.5000E+00 -2.3084E-11 1.6156E-14 -4.7352E-18 4.9820E-22 2.5474E+04 -4.4668E-01
O (original):
A1 A2 A3 A4 A5 A6 A7
low: 3.1683E+00 -3.2793E-03 6.6431E-06 -6.1281E-09 2.1127E-12 2.9122E+04 2.0519E+00
high: 2.5694E+00 -8.5974E-05 4.1948E-08 -1.0018E-11 1.2283E-15 2.9218E+04 4.7843E+00
**** WARNING ****
For species O, discontinuity in h/RT detected at Tmid = 1000
Value computed using low-temperature polynomial: 41.7557.
Value computed using high-temperature polynomial: 31.7557.
O (modified):
A1 A2 A3 A4 A5 A6 A7
low: 3.1683E+00 -3.2793E-03 6.6431E-06 -6.1281E-09 2.1127E-12 3.9122E+04 2.0519E+00
high: 2.5694E+00 -8.5974E-05 4.1948E-08 -1.0018E-11 1.2283E-15 2.9218E+04 4.7843E+00
O2 (original):
A1 A2 A3 A4 A5 A6 A7
low: 3.7825E+00 -2.9967E-03 9.8473E-06 -9.6813E-09 3.2437E-12 -1.0639E+03 3.6577E+00
high: 3.2825E+00 1.4831E-03 -7.5797E-07 2.0947E-10 -2.1672E-14 -1.0885E+03 5.4532E+00
**** WARNING ****
For species O2, discontinuity in h/RT detected at Tmid = 1000
Value computed using low-temperature polynomial: 12.731.
Value computed using high-temperature polynomial: 2.731.
O2 (modified):
A1 A2 A3 A4 A5 A6 A7
low: 3.7825E+00 -2.9967E-03 9.8473E-06 -9.6813E-09 3.2437E-12 8.9361E+03 3.6577E+00
high: 3.2825E+00 1.4831E-03 -7.5797E-07 2.0947E-10 -2.1672E-14 -1.0885E+03 5.4532E+00
OH (original):
A1 A2 A3 A4 A5 A6 A7
low: 3.9920E+00 -2.4013E-03 4.6179E-06 -3.8811E-09 1.3641E-12 3.6151E+03 -1.0393E-01
high: 3.0929E+00 5.4843E-04 1.2651E-07 -8.7946E-11 1.1741E-14 3.8587E+03 4.4767E+00
**** WARNING ****
For species OH, discontinuity in h/RT detected at Tmid = 1000
Value computed using low-temperature polynomial: 17.2483.
Value computed using high-temperature polynomial: 7.24829.
OH (modified):
A1 A2 A3 A4 A5 A6 A7
low: 3.9920E+00 -2.4013E-03 4.6179E-06 -3.8811E-09 1.3641E-12 1.3615E+04 -1.0393E-01
high: 3.0929E+00 5.4843E-04 1.2651E-07 -8.7946E-11 1.1741E-14 3.8587E+03 4.4767E+00
H2O (original):
A1 A2 A3 A4 A5 A6 A7
low: 4.1986E+00 -2.0364E-03 6.5204E-06 -5.4880E-09 1.7720E-12 -3.0294E+04 -8.4903E-01
high: 3.0340E+00 2.1769E-03 -1.6407E-07 -9.7042E-11 1.6820E-14 -3.0004E+04 4.9668E+00
**** WARNING ****
For species H2O, discontinuity in h/RT detected at Tmid = 1000
Value computed using low-temperature polynomial: -15.9574.
Value computed using high-temperature polynomial: -25.9574.
H2O (modified):
A1 A2 A3 A4 A5 A6 A7
low: 4.1986E+00 -2.0364E-03 6.5204E-06 -5.4880E-09 1.7720E-12 -2.0294E+04 -8.4903E-01
high: 3.0340E+00 2.1769E-03 -1.6407E-07 -9.7042E-11 1.6820E-14 -3.0004E+04 4.9668E+00
HO2 (original):
A1 A2 A3 A4 A5 A6 A7
low: 4.3018E+00 -4.7491E-03 2.1158E-05 -2.4276E-08 9.2923E-12 2.9481E+02 3.7167E+00
high: 4.0172E+00 2.2398E-03 -6.3366E-07 1.1425E-10 -1.0791E-14 1.1186E+02 3.7851E+00
**** WARNING ****
For species HO2, discontinuity in h/RT detected at Tmid = 1000
Value computed using low-temperature polynomial: 15.0642.
Value computed using high-temperature polynomial: 5.06416.
HO2 (modified):
A1 A2 A3 A4 A5 A6 A7
low: 4.3018E+00 -4.7491E-03 2.1158E-05 -2.4276E-08 9.2923E-12 1.0295E+04 3.7167E+00
high: 4.0172E+00 2.2398E-03 -6.3366E-07 1.1425E-10 -1.0791E-14 1.1186E+02 3.7851E+00
H2O2 (original):
A1 A2 A3 A4 A5 A6 A7
low: 4.2761E+00 -5.4282E-04 1.6734E-05 -2.1577E-08 8.6245E-12 -1.7703E+04 3.4351E+00
high: 4.1650E+00 4.9083E-03 -1.9014E-06 3.7119E-10 -2.8791E-14 -1.7862E+04 2.9162E+00
**** WARNING ****
For species H2O2, discontinuity in h/RT detected at Tmid = 1000
Value computed using low-temperature polynomial: -1.78939.
Value computed using high-temperature polynomial: -11.7894.
H2O2 (modified):
A1 A2 A3 A4 A5 A6 A7
low: 4.2761E+00 -5.4282E-04 1.6734E-05 -2.1577E-08 8.6245E-12 -7.7026E+03 3.4351E+00
high: 4.1650E+00 4.9083E-03 -1.9014E-06 3.7119E-10 -2.8791E-14 -1.7862E+04 2.9162E+00
AR (original):
A1 A2 A3 A4 A5 A6 A7
low: 2.5000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 -7.4538E+02 4.3660E+00
high: 2.5000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 -7.4538E+02 4.3660E+00
**** WARNING ****
For species AR, discontinuity in h/RT detected at Tmid = 1000
Value computed using low-temperature polynomial: 11.7546.
Value computed using high-temperature polynomial: 1.75463.
AR (modified):
A1 A2 A3 A4 A5 A6 A7
low: 2.5000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 9.2546E+03 4.3660E+00
high: 2.5000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 -7.4538E+02 4.3660E+00

View file

@ -0,0 +1,49 @@
#!/bin/sh
#
#
temp_success="1"
/bin/rm -f output_0.txt diff_csv.txt diff_out_0.txt
##########################################################################
prog=NASA_coeffs
if test ! -x $prog ; then
echo $prog ' does not exist'
exit -1
fi
#################################################################
#
CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA
CANTERA_BIN=${CANTERA_BIN:=../../../bin}
#################################################################
$prog > output_0.txt <<+
1.0
+
retnStat=$?
if [ $retnStat != "0" ]
then
temp_success="0"
echo "$prog returned with bad status, $retnStat, check output"
fi
diff -w output_0_blessed.txt output_0.txt > diff_out_0.txt
retnStat_0=$?
retnTotal=1
if test $retnStat_0 = "0"
then
retnTotal=0
fi
if test $retnTotal = "0"
then
echo "Successful test comparison on "`pwd`
else
echo "Unsuccessful test comparison on "`pwd` " test"
echo " txt files are different - see diff_test*.txt"
fi

View file

@ -1,138 +0,0 @@
// A combustor. Two separate stream - one pure methane and the other
// air, both at 300 K and 1 atm flow into an adiabatic combustor where
// they mix. We are interested in the steady-state burning
// solution. Since at 300 K no reaction will occur between methane and
// air, we need to use an 'igniter' to initiate the chemistry. A simple
// igniter is a pulsed flow of atomic hydrogen. After the igniter is
// turned off, the system approaches the steady burning solution."""
#include <cantera/Cantera.h>
#include <cantera/zerodim.h>
#include <cantera/IdealGasMix.h>
using namespace CanteraZeroD;
void runexample() {
// use reaction mechanism GRI-Mech 3.0
IdealGasMix gas("gri30.cti", "gri30");
int nsp = gas.nSpecies();
// create a reservoir for the fuel inlet, and set to pure methane.
Reservoir fuel_in;
gas.setState_TPX(300.0, OneAtm, "CH4:1.0");
fuel_in.insert(gas);
double fuel_mw = gas.meanMolecularWeight();
// create a reservoir for the air inlet
Reservoir air_in;
IdealGasMix air("air.cti");
gas.setState_TPX(300.0, OneAtm, "N2:0.78, O2:0.21, AR:0.01");
double air_mw = air.meanMolecularWeight();
air_in.insert(gas);
// to ignite the fuel/air mixture, we'll introduce a pulse of radicals.
// The steady-state behavior is independent of how we do this, so we'll
// just use a stream of pure atomic hydrogen.
gas.setState_TPX(300.0, OneAtm, "H:1.0");
Reservoir igniter;
igniter.insert(gas);
// create the combustor, and fill it in initially with N2
gas.setState_TPX(300.0, OneAtm, "N2:1.0");
Reactor combustor;
combustor.insert(gas);
combustor.setInitialVolume(1.0);
// create a reservoir for the exhaust. The initial composition
// doesn't matter.
Reservoir exhaust;
exhaust.insert(gas);
// lean combustion, phi = 0.5
double equiv_ratio = 0.5;
// compute fuel and air mass flow rates
double factor = 0.1;
double air_mdot = factor*9.52*air_mw;
double fuel_mdot = factor*equiv_ratio*fuel_mw;
// create and install the mass flow controllers. Controllers
// m1 and m2 provide constant mass flow rates, and m3 provides
// a short Gaussian pulse only to ignite the mixture
MassFlowController m1;
m1.install(fuel_in, combustor);
m1.setMassFlowRate(fuel_mdot);
// Now create the air mass flow controller. Note that this connects
// two reactors with different reaction mechanisms and different
// numbers of species. Downstream and upstream species are matched by
// name.
MassFlowController m2;
m2.install(air_in, combustor);
m2.setMassFlowRate(air_mdot);
// The igniter will use a Guassiam 'functor' object to specify the
// time-dependent igniter mass flow rate.
double A = 0.1;
double FWHM = 0.2;
double t0 = 1.0;
Gaussian igniter_mdot(A, t0, FWHM);
MassFlowController m3;
m3.install(igniter, combustor);
m3.setFunction(&igniter_mdot);
// put a valve on the exhaust line to regulate the pressure
Valve v;
v.install(combustor, exhaust);
double Kv = 1.0;
v.setParameters(1, &Kv);
// the simulation only contains one reactor
ReactorNet sim;
sim.addReactor(&combustor);
// take single steps to 6 s, writing the results to a CSV file
// for later plotting.
double tfinal = 6.0;
double tnow = 0.0;
double tres;
int k;
ofstream f("combustor_cxx.csv");
while (tnow < tfinal) {
tnow = sim.step(tfinal);
tres = combustor.mass()/v.massFlowRate();
f << tnow << ", "
<< combustor.temperature() << ", "
<< tres << ", ";
ThermoPhase& c = combustor.contents();
for (k = 0; k < nsp; k++) {
f << c.moleFraction(k) << ", ";
}
f << endl;
}
f.close();
}
int main() {
try {
runexample();
return 0;
}
// handle exceptions thrown by Cantera
catch (CanteraError) {
showErrors(cout);
cout << " terminating... " << endl;
appdelete();
return 1;
}
}

View file

@ -0,0 +1,12 @@
Makefile
.depends
Makefile.install
ct2ctml.log
diff_csv.txt
diff_out_0.txt
flamespeed
flamespeed.csv
flamespeed.d
gri30.xml
output_0.txt
transport_log.xml

View file

@ -0,0 +1,118 @@
############################################################################
#
# Makefile to compile and link a C++ application to
# Cantera.
#
#############################################################################
.SUFFIXES :
.SUFFIXES : .cpp .d .o .d .h
# the name of the executable program to be created
PROG_NAME = flamespeed
# the object files to be linked together. List those generated from Fortran
# and from C/C++ separately
OBJS = flamespeed.o
# additional flags to be passed to the linker. If your program
# requires other external libraries, put them here
LINK_OPTIONS = @EXTRA_LINK@
#############################################################################
# True if we are in the source directory tree
srcdirtree=1
# Fortran libraries
FORT_LIBS = @FLIBS@
# Purify options
PURIFY=@PURIFY@
# the C++ compiler
CXX = @CXX@
# C++ compile flags
CXX_FLAGS = @CXXFLAGS@ @CXX_INCLUDES@
# external libraries
EXT_LIBS = @LOCAL_LIBS@ -ltpx -lctcxx
# 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 =
# Depends
ifeq ($srcdirtree, 1)
LOCAL_DEFNS = -DSRCDIRTREE
else
LOCAL_DEFNS =
endif
# the directory where Cantera include files may be found.
CANTERA_INCDIR=@ctroot@/build/include
# 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@:
$(PURIFY) $(CXX) -c $< -I$(CANTERA_INCDIR) $(CXX_FLAGS) $(LOCAL_DEFNS)
# how to create a dependency file
.@CXX_EXT@.d:
@CXX_DEPENDS@ -I$(CANTERA_INCDIR) $(CXX_FLAGS) $(LOCAL_DEFNS) $*.cpp > $*.d
PROGRAM = $(PROG_NAME)$(EXE_EXT)
DEPENDS = $(OBJS:.o=.d)
all: $(PROGRAM)
$(PROGRAM): $(OBJS)
$(PURIFY) $(CXX) -o $(PROGRAM) $(OBJS) $(LCXX_FLAGS) $(CANTERA_LIBS) \
$(LINK_OPTIONS) $(EXT_LIBS) @LIBS@ $(FORT_LIBS) \
$(LCXX_END_LIBS)
test:
@MAKE@ $(PROGRAM)
./runtest
INSTALL_DIR=@ct_demodir@/cxx/flamespeed
install:
@INSTALL@ -d $(INSTALL_DIR)
@INSTALL@ -c -m ug+rw,o+r Makefile.install $(INSTALL_DIR)/Makefile
@(for ihhh in *.cpp *blessed* ; do \
@INSTALL@ $${ihhh} -m ug+rw,o+r $(INSTALL_DIR) ; \
echo "@INSTALL@ $${ihhh} -m ug+rw,o+r $(INSTALL_DIR)" ; \
done )
@INSTALL@ runtest $(INSTALL_DIR) ;
depends: $(DEPENDS)
@MAKE@ .depends
.depends: $(DEPENDS)
cat $(DEPENDS) > .depends
clean:
$(RM) $(OBJS) $(PROGRAM) .depends *.d
$(RM) ct2ctml.log diff* output_0.txt transport_log.xml \
flamespeed.csv
(if test -d SunWS_cache ; then \
$(RM) -rf SunWS_cache ; \
fi )
TAGS:
etags *.h *.cpp
ifeq ($(wildcard .depends), .depends)
include .depends
endif

View file

@ -0,0 +1,97 @@
#!/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 = flamespeed
# the object files to be linked together. List those generated from Fortran
# and from C/C++ separately
OBJS = flamespeed.o
# additional flags to be passed to the linker. If your program
# requires other external libraries, put them here
LINK_OPTIONS =
#############################################################################
# These links are to Cantera's install space
CANTERA_INCROOT = @ct_incroot@
#
# Bring in the Cantera includes through the .mak file
#
include $(CANTERA_INCROOT)/cantera/Cantera.mak
# 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@
#
# The directory where Cantera include files may be found.
#
INCLUDE_DIRS = -I../../src -I$(CANTERA_INCROOT)
#
# C++ compile flags
CXX_FLAGS = @CXXFLAGS@ $(INCLUDE_DIRS) -DUSE_VCSNONIDEAL
#
# Ending C++ linking libraries
LCXX_END_LIBS = @LCXX_END_LIBS@
# flags passed to the C++ compiler/linker for the linking step
LCXX_FLAGS = @CXXFLAGS@
# How to compile C++ source files to object files
.cpp.o:
$(CXX) $(CXX_FLAGS) -c $<
# How to compile the dependency file
.cpp.d:
@CXX_DEPENDS@ $(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_CORE_LIBS_DEP)
$(CXX) -o $(PROGRAM) $(OBJS) $(LCXX_FLAGS) $(LINK_OPTIONS) \
$(CANTERA_TOTAL_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) *.o $(PROGRAM) $(DEPENDS) .depends
(if test -d SunWS_cache ; then \
$(RM) -rf SunWS_cache ; \
fi )

View file

@ -195,18 +195,21 @@ int flamespeed(int np, void* p) {
refine_grid = true;
flow.solveEnergyEqn();
flame.solve(loglevel,refine_grid);
double flameSpeed_mix = flame.value(flowdomain,flow.componentIndex("u"),0);
cout << "Flame speed with mixture-averaged transport: " <<
flame.value(flowdomain,flow.componentIndex("u"),0) << " m/s" << endl;
// now switch to multicomponent transport
flow.setTransport(*trmulti);
flame.solve(loglevel, refine_grid);
double flameSpeed_multi = flame.value(flowdomain,flow.componentIndex("u"),0);
cout << "Flame speed with multicomponent transport: " <<
flame.value(flowdomain,flow.componentIndex("u"),0) << " m/s" << endl;
// now enable Soret diffusion
flow.enableSoret(true);
flame.solve(loglevel, refine_grid);
double flameSpeed_full = flame.value(flowdomain,flow.componentIndex("u"),0);
cout << "Flame speed with multicomponent transport + Soret: " <<
flame.value(flowdomain,flow.componentIndex("u"),0) << " m/s" << endl;
@ -227,6 +230,23 @@ int flamespeed(int np, void* p) {
cout << endl<<"Adiabatic flame temperature from equilibrium is: "<<Tad<<endl;
cout << "Flame speed for phi="<<phi<<" is "<<Uvec[0]<<" m/s."<<endl;
string reportFile = "flamespeed.csv";
FILE * FP = fopen(reportFile.c_str(), "w");
if (!FP) {
printf("Failure to open file\n");
exit(-1);
}
fprintf(FP," Flame speed (mixture-averaged ) = %11.3e m/s\n", flameSpeed_mix);
fprintf(FP," Flame speed (multicomponent ) = %11.3e m/s\n", flameSpeed_multi);
fprintf(FP," Flame speed (multicomponent + Soret) = %11.3e m/s\n", flameSpeed_full);
fprintf(FP," Grid, Temperature, Uvec, CO, CO2\n");
for (int n = 0; n < np; n++) {
fprintf(FP," %11.3e, %11.3e, %11.3e, %11.3e, %11.3e\n",
flow.grid(n), Tvec[n], Uvec[n], COvec[n], CO2vec[n]);
}
fclose(FP);
return 0;
}
catch (CanteraError) {

View file

@ -0,0 +1,70 @@
Flame speed (mixture-averaged ) = 3.873e-01 m/s
Flame speed (multicomponent ) = 3.922e-01 m/s
Flame speed (multicomponent + Soret) = 3.922e-01 m/s
Grid, Temperature, Uvec, CO, CO2
0.000e+00, 3.000e+02, 3.922e-01, 4.970e-11, 2.546e-12
1.145e-03, 3.000e+02, 3.922e-01, 1.122e-09, 7.472e-11
2.291e-03, 3.000e+02, 3.922e-01, 2.534e-08, 2.190e-09
2.863e-03, 3.000e+02, 3.922e-01, 2.334e-07, 2.570e-08
3.436e-03, 3.002e+02, 3.926e-01, 2.686e-06, 3.818e-07
3.722e-03, 3.008e+02, 3.936e-01, 1.381e-05, 2.446e-06
4.008e-03, 3.044e+02, 3.989e-01, 8.416e-05, 1.891e-05
4.152e-03, 3.127e+02, 4.105e-01, 2.561e-04, 6.905e-05
4.223e-03, 3.241e+02, 4.261e-01, 5.033e-04, 1.555e-04
4.295e-03, 3.477e+02, 4.581e-01, 1.032e-03, 3.712e-04
4.331e-03, 3.683e+02, 4.859e-01, 1.515e-03, 5.942e-04
4.366e-03, 3.982e+02, 5.262e-01, 2.230e-03, 9.581e-04
4.402e-03, 4.399e+02, 5.824e-01, 3.251e-03, 1.527e-03
4.420e-03, 4.662e+02, 6.179e-01, 3.930e-03, 1.931e-03
4.438e-03, 4.968e+02, 6.592e-01, 4.736e-03, 2.435e-03
4.456e-03, 5.318e+02, 7.065e-01, 5.681e-03, 3.052e-03
4.474e-03, 5.714e+02, 7.600e-01, 6.778e-03, 3.800e-03
4.492e-03, 6.155e+02, 8.197e-01, 8.037e-03, 4.694e-03
4.509e-03, 6.641e+02, 8.856e-01, 9.467e-03, 5.750e-03
4.527e-03, 7.171e+02, 9.576e-01, 1.108e-02, 6.983e-03
4.545e-03, 7.742e+02, 1.035e+00, 1.288e-02, 8.409e-03
4.563e-03, 8.353e+02, 1.119e+00, 1.487e-02, 1.004e-02
4.581e-03, 9.000e+02, 1.207e+00, 1.706e-02, 1.190e-02
4.607e-03, 1.000e+03, 1.344e+00, 2.056e-02, 1.498e-02
4.633e-03, 1.106e+03, 1.489e+00, 2.443e-02, 1.858e-02
4.647e-03, 1.161e+03, 1.564e+00, 2.655e-02, 2.063e-02
4.660e-03, 1.216e+03, 1.641e+00, 2.874e-02, 2.284e-02
4.673e-03, 1.272e+03, 1.717e+00, 3.100e-02, 2.519e-02
4.686e-03, 1.327e+03, 1.793e+00, 3.329e-02, 2.770e-02
4.699e-03, 1.382e+03, 1.869e+00, 3.558e-02, 3.036e-02
4.712e-03, 1.435e+03, 1.943e+00, 3.785e-02, 3.316e-02
4.725e-03, 1.487e+03, 2.015e+00, 4.002e-02, 3.608e-02
4.738e-03, 1.536e+03, 2.083e+00, 4.206e-02, 3.912e-02
4.751e-03, 1.583e+03, 2.147e+00, 4.391e-02, 4.226e-02
4.764e-03, 1.625e+03, 2.206e+00, 4.551e-02, 4.547e-02
4.777e-03, 1.665e+03, 2.260e+00, 4.680e-02, 4.875e-02
4.791e-03, 1.699e+03, 2.308e+00, 4.774e-02, 5.206e-02
4.804e-03, 1.730e+03, 2.350e+00, 4.832e-02, 5.538e-02
4.817e-03, 1.757e+03, 2.386e+00, 4.853e-02, 5.869e-02
4.830e-03, 1.779e+03, 2.416e+00, 4.838e-02, 6.196e-02
4.843e-03, 1.798e+03, 2.441e+00, 4.791e-02, 6.517e-02
4.856e-03, 1.814e+03, 2.462e+00, 4.718e-02, 6.830e-02
4.869e-03, 1.827e+03, 2.479e+00, 4.623e-02, 7.132e-02
4.882e-03, 1.838e+03, 2.493e+00, 4.514e-02, 7.422e-02
4.895e-03, 1.847e+03, 2.504e+00, 4.396e-02, 7.699e-02
4.908e-03, 1.855e+03, 2.514e+00, 4.272e-02, 7.962e-02
4.921e-03, 1.862e+03, 2.522e+00, 4.149e-02, 8.210e-02
4.935e-03, 1.869e+03, 2.529e+00, 4.027e-02, 8.442e-02
4.948e-03, 1.875e+03, 2.535e+00, 3.909e-02, 8.660e-02
4.974e-03, 1.885e+03, 2.547e+00, 3.690e-02, 9.050e-02
5.000e-03, 1.894e+03, 2.557e+00, 3.497e-02, 9.388e-02
5.039e-03, 1.907e+03, 2.570e+00, 3.254e-02, 9.804e-02
5.078e-03, 1.918e+03, 2.582e+00, 3.058e-02, 1.014e-01
5.156e-03, 1.938e+03, 2.604e+00, 2.781e-02, 1.060e-01
5.312e-03, 1.969e+03, 2.640e+00, 2.485e-02, 1.109e-01
5.625e-03, 2.013e+03, 2.692e+00, 2.234e-02, 1.150e-01
5.938e-03, 2.046e+03, 2.730e+00, 2.083e-02, 1.174e-01
6.250e-03, 2.070e+03, 2.759e+00, 1.966e-02, 1.192e-01
6.875e-03, 2.103e+03, 2.797e+00, 1.792e-02, 1.220e-01
7.500e-03, 2.127e+03, 2.824e+00, 1.655e-02, 1.242e-01
8.750e-03, 2.156e+03, 2.857e+00, 1.469e-02, 1.271e-01
1.000e-02, 2.174e+03, 2.878e+00, 1.339e-02, 1.292e-01
1.250e-02, 2.195e+03, 2.900e+00, 1.185e-02, 1.316e-01
1.500e-02, 2.207e+03, 2.914e+00, 1.090e-02, 1.331e-01
2.000e-02, 2.218e+03, 2.926e+00, 1.002e-02, 1.345e-01
2.100e-02, 2.218e+03, 2.926e+00, 1.002e-02, 1.345e-01
1 Flame speed (mixture-averaged ) = 3.873e-01 m/s
2 Flame speed (multicomponent ) = 3.922e-01 m/s
3 Flame speed (multicomponent + Soret) = 3.922e-01 m/s
4 Grid, Temperature, Uvec, CO, CO2
5 0.000e+00, 3.000e+02, 3.922e-01, 4.970e-11, 2.546e-12
6 1.145e-03, 3.000e+02, 3.922e-01, 1.122e-09, 7.472e-11
7 2.291e-03, 3.000e+02, 3.922e-01, 2.534e-08, 2.190e-09
8 2.863e-03, 3.000e+02, 3.922e-01, 2.334e-07, 2.570e-08
9 3.436e-03, 3.002e+02, 3.926e-01, 2.686e-06, 3.818e-07
10 3.722e-03, 3.008e+02, 3.936e-01, 1.381e-05, 2.446e-06
11 4.008e-03, 3.044e+02, 3.989e-01, 8.416e-05, 1.891e-05
12 4.152e-03, 3.127e+02, 4.105e-01, 2.561e-04, 6.905e-05
13 4.223e-03, 3.241e+02, 4.261e-01, 5.033e-04, 1.555e-04
14 4.295e-03, 3.477e+02, 4.581e-01, 1.032e-03, 3.712e-04
15 4.331e-03, 3.683e+02, 4.859e-01, 1.515e-03, 5.942e-04
16 4.366e-03, 3.982e+02, 5.262e-01, 2.230e-03, 9.581e-04
17 4.402e-03, 4.399e+02, 5.824e-01, 3.251e-03, 1.527e-03
18 4.420e-03, 4.662e+02, 6.179e-01, 3.930e-03, 1.931e-03
19 4.438e-03, 4.968e+02, 6.592e-01, 4.736e-03, 2.435e-03
20 4.456e-03, 5.318e+02, 7.065e-01, 5.681e-03, 3.052e-03
21 4.474e-03, 5.714e+02, 7.600e-01, 6.778e-03, 3.800e-03
22 4.492e-03, 6.155e+02, 8.197e-01, 8.037e-03, 4.694e-03
23 4.509e-03, 6.641e+02, 8.856e-01, 9.467e-03, 5.750e-03
24 4.527e-03, 7.171e+02, 9.576e-01, 1.108e-02, 6.983e-03
25 4.545e-03, 7.742e+02, 1.035e+00, 1.288e-02, 8.409e-03
26 4.563e-03, 8.353e+02, 1.119e+00, 1.487e-02, 1.004e-02
27 4.581e-03, 9.000e+02, 1.207e+00, 1.706e-02, 1.190e-02
28 4.607e-03, 1.000e+03, 1.344e+00, 2.056e-02, 1.498e-02
29 4.633e-03, 1.106e+03, 1.489e+00, 2.443e-02, 1.858e-02
30 4.647e-03, 1.161e+03, 1.564e+00, 2.655e-02, 2.063e-02
31 4.660e-03, 1.216e+03, 1.641e+00, 2.874e-02, 2.284e-02
32 4.673e-03, 1.272e+03, 1.717e+00, 3.100e-02, 2.519e-02
33 4.686e-03, 1.327e+03, 1.793e+00, 3.329e-02, 2.770e-02
34 4.699e-03, 1.382e+03, 1.869e+00, 3.558e-02, 3.036e-02
35 4.712e-03, 1.435e+03, 1.943e+00, 3.785e-02, 3.316e-02
36 4.725e-03, 1.487e+03, 2.015e+00, 4.002e-02, 3.608e-02
37 4.738e-03, 1.536e+03, 2.083e+00, 4.206e-02, 3.912e-02
38 4.751e-03, 1.583e+03, 2.147e+00, 4.391e-02, 4.226e-02
39 4.764e-03, 1.625e+03, 2.206e+00, 4.551e-02, 4.547e-02
40 4.777e-03, 1.665e+03, 2.260e+00, 4.680e-02, 4.875e-02
41 4.791e-03, 1.699e+03, 2.308e+00, 4.774e-02, 5.206e-02
42 4.804e-03, 1.730e+03, 2.350e+00, 4.832e-02, 5.538e-02
43 4.817e-03, 1.757e+03, 2.386e+00, 4.853e-02, 5.869e-02
44 4.830e-03, 1.779e+03, 2.416e+00, 4.838e-02, 6.196e-02
45 4.843e-03, 1.798e+03, 2.441e+00, 4.791e-02, 6.517e-02
46 4.856e-03, 1.814e+03, 2.462e+00, 4.718e-02, 6.830e-02
47 4.869e-03, 1.827e+03, 2.479e+00, 4.623e-02, 7.132e-02
48 4.882e-03, 1.838e+03, 2.493e+00, 4.514e-02, 7.422e-02
49 4.895e-03, 1.847e+03, 2.504e+00, 4.396e-02, 7.699e-02
50 4.908e-03, 1.855e+03, 2.514e+00, 4.272e-02, 7.962e-02
51 4.921e-03, 1.862e+03, 2.522e+00, 4.149e-02, 8.210e-02
52 4.935e-03, 1.869e+03, 2.529e+00, 4.027e-02, 8.442e-02
53 4.948e-03, 1.875e+03, 2.535e+00, 3.909e-02, 8.660e-02
54 4.974e-03, 1.885e+03, 2.547e+00, 3.690e-02, 9.050e-02
55 5.000e-03, 1.894e+03, 2.557e+00, 3.497e-02, 9.388e-02
56 5.039e-03, 1.907e+03, 2.570e+00, 3.254e-02, 9.804e-02
57 5.078e-03, 1.918e+03, 2.582e+00, 3.058e-02, 1.014e-01
58 5.156e-03, 1.938e+03, 2.604e+00, 2.781e-02, 1.060e-01
59 5.312e-03, 1.969e+03, 2.640e+00, 2.485e-02, 1.109e-01
60 5.625e-03, 2.013e+03, 2.692e+00, 2.234e-02, 1.150e-01
61 5.938e-03, 2.046e+03, 2.730e+00, 2.083e-02, 1.174e-01
62 6.250e-03, 2.070e+03, 2.759e+00, 1.966e-02, 1.192e-01
63 6.875e-03, 2.103e+03, 2.797e+00, 1.792e-02, 1.220e-01
64 7.500e-03, 2.127e+03, 2.824e+00, 1.655e-02, 1.242e-01
65 8.750e-03, 2.156e+03, 2.857e+00, 1.469e-02, 1.271e-01
66 1.000e-02, 2.174e+03, 2.878e+00, 1.339e-02, 1.292e-01
67 1.250e-02, 2.195e+03, 2.900e+00, 1.185e-02, 1.316e-01
68 1.500e-02, 2.207e+03, 2.914e+00, 1.090e-02, 1.331e-01
69 2.000e-02, 2.218e+03, 2.926e+00, 1.002e-02, 1.345e-01
70 2.100e-02, 2.218e+03, 2.926e+00, 1.002e-02, 1.345e-01

View file

@ -0,0 +1,485 @@
Enter phi: 1 2225.32
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Mass Flux: 0.3368 kg/m^2/s
Temperature: 300 K
Mass Fractions:
O2 0.2201
CH4 0.05519
N2 0.7248
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> flame <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Pressure: 1.013e+05 Pa
-------------------------------------------------------------------------------
z u V T lambda H2
-------------------------------------------------------------------------------
0 0.3 0 300 0 0
0.005 0.9605 0 954.9 0 9.044e-05
0.01 1.621 0 1610 0 0.0001809
0.015 2.242 0 2225 0 0.0002659
0.02 2.242 0 2225 0 0.0002659
0.021 2.242 0 2225 0 0.0002659
-------------------------------------------------------------------------------
z H O O2 OH H2O
-------------------------------------------------------------------------------
0 0 0 0.2201 0 0
0.005 4.883e-06 4.252e-05 0.147 0.0006044 0.04099
0.01 9.765e-06 8.504e-05 0.07399 0.001209 0.08197
0.015 1.436e-05 0.000125 0.005339 0.001777 0.1205
0.02 1.436e-05 0.000125 0.005339 0.001777 0.1205
0.021 1.436e-05 0.000125 0.005339 0.001777 0.1205
-------------------------------------------------------------------------------
z HO2 H2O2 C CH CH2
-------------------------------------------------------------------------------
0 0 0 0 0 0
0.005 2.026e-07 1.918e-08 3.317e-18 5.463e-19 1.726e-18
0.01 4.051e-07 3.837e-08 6.634e-18 1.093e-18 3.451e-18
0.015 5.955e-07 5.64e-08 9.752e-18 1.606e-18 5.074e-18
0.02 5.955e-07 5.64e-08 9.752e-18 1.606e-18 5.074e-18
0.021 5.955e-07 5.64e-08 9.752e-18 1.606e-18 5.074e-18
-------------------------------------------------------------------------------
z CH2(S) CH3 CH4 CO CO2
-------------------------------------------------------------------------------
0 0 0 0.05519 0 0
0.005 1.046e-19 1.175e-17 0.03642 0.003132 0.04657
0.01 2.091e-19 2.35e-17 0.01764 0.006265 0.09315
0.015 3.074e-19 3.454e-17 1.802e-17 0.009209 0.1369
0.02 3.074e-19 3.454e-17 1.802e-17 0.009209 0.1369
0.021 3.074e-19 3.454e-17 1.802e-17 0.009209 0.1369
-------------------------------------------------------------------------------
z HCO CH2O CH2OH CH3O CH3OH
-------------------------------------------------------------------------------
0 0 0 0 0 0
0.005 2.873e-10 4.948e-12 1.597e-17 2.551e-19 1.403e-18
0.01 5.747e-10 9.895e-12 3.193e-17 5.102e-19 2.807e-18
0.015 8.447e-10 1.455e-11 4.694e-17 7.501e-19 4.126e-18
0.02 8.447e-10 1.455e-11 4.694e-17 7.501e-19 4.126e-18
0.021 8.447e-10 1.455e-11 4.694e-17 7.501e-19 4.126e-18
-------------------------------------------------------------------------------
z C2H C2H2 C2H3 C2H4 C2H5
-------------------------------------------------------------------------------
0 0 0 0 0 0
0.005 1.156e-24 3.007e-22 2.367e-27 2.573e-27 2.896e-32
0.01 2.312e-24 6.014e-22 4.734e-27 5.145e-27 5.791e-32
0.015 3.399e-24 8.84e-22 6.959e-27 7.563e-27 8.513e-32
0.02 3.399e-24 8.84e-22 6.959e-27 7.563e-27 8.513e-32
0.021 3.399e-24 8.84e-22 6.959e-27 7.563e-27 8.513e-32
-------------------------------------------------------------------------------
z C2H6 HCCO CH2CO HCCOH N
-------------------------------------------------------------------------------
0 0 0 0 0 0
0.005 2.182e-33 2.762e-20 3.758e-20 3.683e-23 2.469e-09
0.01 4.365e-33 5.523e-20 7.515e-20 7.365e-23 4.937e-09
0.015 6.416e-33 8.119e-20 1.105e-19 1.083e-22 7.258e-09
0.02 6.416e-33 8.119e-20 1.105e-19 1.083e-22 7.258e-09
0.021 6.416e-33 8.119e-20 1.105e-19 1.083e-22 7.258e-09
-------------------------------------------------------------------------------
z NH NH2 NH3 NNH NO
-------------------------------------------------------------------------------
0 0 0 0 0 0
0.005 4.394e-10 1.875e-10 5.707e-10 2.721e-10 0.0006988
0.01 8.789e-10 3.75e-10 1.141e-09 5.443e-10 0.001398
0.015 1.292e-09 5.512e-10 1.678e-09 8e-10 0.002055
0.02 1.292e-09 5.512e-10 1.678e-09 8e-10 0.002055
0.021 1.292e-09 5.512e-10 1.678e-09 8e-10 0.002055
-------------------------------------------------------------------------------
z NO2 N2O HNO CN HCN
-------------------------------------------------------------------------------
0 0 0 0 0 0
0.005 1.956e-07 5.439e-08 1.29e-08 2.198e-14 6.529e-12
0.01 3.911e-07 1.088e-07 2.58e-08 4.396e-14 1.306e-11
0.015 5.75e-07 1.599e-07 3.793e-08 6.462e-14 1.919e-11
0.02 5.75e-07 1.599e-07 3.793e-08 6.462e-14 1.919e-11
0.021 5.75e-07 1.599e-07 3.793e-08 6.462e-14 1.919e-11
-------------------------------------------------------------------------------
z H2CN HCNN HCNO HOCN HNCO
-------------------------------------------------------------------------------
0 0 0 0 0 0
0.005 1.924e-18 6.749e-22 5.464e-17 6.064e-13 2.073e-10
0.01 3.847e-18 1.35e-21 1.093e-16 1.213e-12 4.145e-10
0.015 5.656e-18 1.984e-21 1.606e-16 1.783e-12 6.094e-10
0.02 5.656e-18 1.984e-21 1.606e-16 1.783e-12 6.094e-10
0.021 5.656e-18 1.984e-21 1.606e-16 1.783e-12 6.094e-10
-------------------------------------------------------------------------------
z NCO N2 AR C3H7 C3H8
-------------------------------------------------------------------------------
0 0 0.7248 0 0 0
0.005 8.061e-12 0.7244 0 1.96e-47 1.38e-48
0.01 1.612e-11 0.7241 0 3.921e-47 2.76e-48
0.015 2.37e-11 0.7238 0 5.763e-47 4.057e-48
0.02 2.37e-11 0.7238 0 5.763e-47 4.057e-48
0.021 2.37e-11 0.7238 0 5.763e-47 4.057e-48
-------------------------------------------------------------------------------
z CH2CHO CH3CHO
-------------------------------------------------------------------------------
0 0 0
0.005 1.601e-25 3.258e-26
0.01 3.203e-25 6.517e-26
0.015 4.708e-25 9.58e-26
0.02 4.708e-25 9.58e-26
0.021 4.708e-25 9.58e-26
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-------------------------------------------------------------------------------
z outlet dummy
-------------------------------------------------------------------------------
0 0
T in between 300 and 954.871
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 1 timesteps 3.75e-06 2.669
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 2 timesteps 4.219e-06 1.819
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 5 timesteps 8.009e-06 1.453
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 10 timesteps 2.887e-05 1.36
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 10 timesteps 1.3e-05 2.469
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 10 timesteps 1.172e-05 2.477
..............................................................................
Attempt Newton solution of steady-state problem... success.
Problem solved on [7] point grid(s).
grid refinement disabled.
..............................................................................
Attempt Newton solution of steady-state problem... success.
Problem solved on [7] point grid(s).
##############################################################################
Refining grid in flame.
New points inserted after grid points 0 1 2 3
to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CN CO CO2 H H2 H2O H2O2 HCCO HCCOH HCN HCNO HCO HNCO HNO HO2 HOCN N N2O NCO NH NH2 NH3 NNH NO NO2 O O2 OH T point 0 point 2 u
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 1 timesteps 7.5e-06 6.312
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 2 timesteps 8.438e-06 5.874
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 5 timesteps 1.602e-05 5.367
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 10 timesteps 2.887e-05 6.143
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 10 timesteps 1.3e-05 5.96
..............................................................................
Attempt Newton solution of steady-state problem... success.
Problem solved on [11] point grid(s).
##############################################################################
Refining grid in flame.
New points inserted after grid points 0 1 2 3 4 5
to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CN CO CO2 H H2 H2O H2O2 HCCO HCCOH HCN HCNO HCO HNCO HNO HO2 HOCN N N2O NCO NH NH2 NH3 NNH NO NO2 O O2 OH T point 1 point 4 u
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 1 timesteps 9.753e-06 6.642
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 2 timesteps 1.097e-05 6.231
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 5 timesteps 5.207e-06 6.369
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 10 timesteps 4.692e-06 6.297
..............................................................................
Attempt Newton solution of steady-state problem... success.
Problem solved on [17] point grid(s).
##############################################################################
Refining grid in flame.
New points inserted after grid points 2 3 5 6 7 8 9
to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CN CO CO2 H H2 H2O H2O2 HCCO HCCOH HCN HCNN HCNO HCO HNCO HNO HO2 HOCN N N2O NCO NH NH2 NH3 NNH NO NO2 O O2 OH T point 3 point 8 u
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 1 timesteps 3.519e-06 6.98
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 2 timesteps 3.959e-06 6.734
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 5 timesteps 3.758e-06 6.646
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 10 timesteps 6.772e-06 6.115
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 10 timesteps 2.441e-05 5.613
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 10 timesteps 0.0001759 4.849
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 10 timesteps 0.0001585 4.722
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 10 timesteps 3.57e-05 5.598
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 10 timesteps 8.043e-06 6.731
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 10 timesteps 7.246e-06 6.466
..............................................................................
Attempt Newton solution of steady-state problem... success.
Problem solved on [24] point grid(s).
##############################################################################
Refining grid in flame.
New points inserted after grid points 4 5 6 7 8 9 10 11 12 13 14
to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CN CO H H2 H2CN H2O H2O2 HCCO HCCOH HCN HCNN HCNO HCO HNCO HNO HO2 HOCN N NCO NH NH2 NH3 NNH NO2 O O2 OH T point 13 u
..............................................................................
Attempt Newton solution of steady-state problem... success.
Problem solved on [35] point grid(s).
##############################################################################
Refining grid in flame.
New points inserted after grid points 6 7 8 9 10 11 12 13 14 15 16 17 18 19 22
to resolve C C2H C2H2 C2H3 C2H4 C2H5 C2H6 C3H7 C3H8 CH CH2 CH2(S) CH2CHO CH2CO CH2O CH2OH CH3 CH3CHO CH3O CH3OH CH4 CN CO H2 H2CN H2O H2O2 HCCO HCCOH HCN HCNN HCO HNCO HNO HO2 HOCN N NCO NH NH3 NO2 T point 22 u
..............................................................................
Attempt Newton solution of steady-state problem... success.
Problem solved on [50] point grid(s).
##############################################################################
Refining grid in flame.
New points inserted after grid points 7 8 9 12 13 36
to resolve C2H4 C2H5 C2H6 C3H7 C3H8 CH2CHO CH2O CH3 CH3CHO CH3O CH3OH CN CO H2O2 HO2 HOCN NCO NH NH3 NO2
..............................................................................
Attempt Newton solution of steady-state problem... success.
Problem solved on [56] point grid(s).
##############################################################################
Refining grid in flame.
New points inserted after grid points 9 10 11 12 41
to resolve C2H4 C2H6 C3H7 C3H8 CH2CHO CH2O CH3O CH3OH CN H2O2 HO2 NCO NO2
..............................................................................
Attempt Newton solution of steady-state problem... success.
Problem solved on [61] point grid(s).
##############################################################################
Refining grid in flame.
New points inserted after grid points 12 13 14 15 16
to resolve C3H8 CH2CHO CH3O NO2
..............................................................................
Attempt Newton solution of steady-state problem... success.
Problem solved on [66] point grid(s).
no new points needed in flame
Flame speed with mixture-averaged transport: 0.387255 m/s
..............................................................................
Attempt Newton solution of steady-state problem... failure.
..............................................................................
Take 1 timesteps 3.75e-06 5.758
..............................................................................
Attempt Newton solution of steady-state problem... success.
Problem solved on [66] point grid(s).
no new points needed in flame
Flame speed with multicomponent transport: 0.392151 m/s
..............................................................................
Attempt Newton solution of steady-state problem... success.
Problem solved on [66] point grid(s).
no new points needed in flame
Flame speed with multicomponent transport + Soret: 0.39215 m/s
z (m) T (K) U (m/s) Y(CO)
0.000000 300.000 0.392 0.00000
0.001145 300.000 0.392 0.00000
0.002291 300.002 0.392 0.00000
0.002863 300.015 0.392 0.00000
0.003436 300.158 0.393 0.00000
0.003722 300.765 0.394 0.00001
0.004008 304.365 0.399 0.00008
0.004152 312.675 0.411 0.00026
0.004223 324.053 0.426 0.00050
0.004295 347.691 0.458 0.00103
0.004331 368.328 0.486 0.00151
0.004366 398.192 0.526 0.00223
0.004402 439.859 0.582 0.00325
0.004420 466.246 0.618 0.00393
0.004438 496.834 0.659 0.00474
0.004456 531.832 0.707 0.00568
0.004474 571.364 0.760 0.00678
0.004492 615.466 0.820 0.00804
0.004509 664.081 0.886 0.00947
0.004527 717.075 0.958 0.01108
0.004545 774.239 1.035 0.01288
0.004563 835.315 1.119 0.01487
0.004581 900.000 1.207 0.01706
0.004607 1000.385 1.344 0.02056
0.004633 1106.461 1.489 0.02443
0.004647 1161.011 1.564 0.02655
0.004660 1216.241 1.641 0.02874
0.004673 1271.756 1.717 0.03100
0.004686 1327.105 1.793 0.03329
0.004699 1381.783 1.869 0.03558
0.004712 1435.243 1.943 0.03785
0.004725 1486.908 2.015 0.04002
0.004738 1536.197 2.083 0.04206
0.004751 1582.549 2.147 0.04391
0.004764 1625.459 2.206 0.04551
0.004777 1664.517 2.260 0.04680
0.004791 1699.443 2.308 0.04774
0.004804 1730.117 2.350 0.04832
0.004817 1756.596 2.386 0.04853
0.004830 1779.104 2.416 0.04838
0.004843 1798.010 2.441 0.04791
0.004856 1813.777 2.462 0.04718
0.004869 1826.914 2.479 0.04623
0.004882 1837.921 2.493 0.04514
0.004895 1847.254 2.504 0.04396
0.004908 1855.303 2.514 0.04272
0.004921 1862.379 2.522 0.04149
0.004935 1868.724 2.529 0.04027
0.004948 1874.519 2.535 0.03909
0.004974 1884.859 2.547 0.03690
0.005000 1894.157 2.557 0.03497
0.005039 1906.651 2.570 0.03254
0.005078 1917.968 2.582 0.03058
0.005156 1937.747 2.604 0.02781
0.005312 1969.272 2.640 0.02485
0.005625 2013.447 2.692 0.02234
0.005938 2045.633 2.730 0.02083
0.006250 2070.220 2.759 0.01966
0.006875 2103.487 2.797 0.01792
0.007500 2126.991 2.824 0.01655
0.008750 2155.560 2.857 0.01469
0.010000 2174.268 2.878 0.01339
0.012500 2194.717 2.900 0.01185
0.015000 2206.910 2.914 0.01090
0.020000 2218.182 2.926 0.01002
0.021000 2218.182 2.926 0.01002
Adiabatic flame temperature from equilibrium is: 2225.32
Flame speed for phi=1 is 0.39215 m/s.

View file

@ -0,0 +1,63 @@
#!/bin/sh
#
#
temp_success="1"
/bin/rm -f output_0.txt flamespeed.csv diff_csv.txt diff_out_0.txt
##########################################################################
prog=flamespeed
if test ! -x $prog ; then
echo $prog ' does not exist'
exit -1
fi
#################################################################
#
CANTERA_DATA=${CANTERA_DATA:=../../../data/inputs}; export CANTERA_DATA
CANTERA_BIN=${CANTERA_BIN:=../../../bin}
#################################################################
$prog > output_0.txt <<+
1.0
+
retnStat=$?
if [ $retnStat != "0" ]
then
temp_success="0"
echo "$prog returned with bad status, $retnStat, check output"
fi
diff -w output_0_blessed.txt output_0.txt > diff_out_0.txt
retnStat_0=$?
csvdiff -a 1.0E-50 flamespeed_blessed_0.csv flamespeed.csv > diff_csv.txt
retnStat_csv_0=$?
retnTotal=1
if test $retnStat_0 = "0"
then
retnTotal=0
fi
retnCSVTotal=1
if test $retnStat_csv_0 = "1"
then
retnCSVTotal=0
fi
if test $retnCSVTotal = "0"
then
echo "Successful test comparison on "`pwd`
if test $retnTotal = "1"
then
echo " But text files show differences see diff_out_0.txt"
fi
else
echo "Unsuccessful test comparison on "`pwd` " test"
if test $retnTotal != "0"
then
echo " files are different - see diff_test*.txt"
fi
fi

View file

@ -1,135 +0,0 @@
/////////////////////////////////////////////////////////////
//
// zero-dimensional kinetics example program
//
// $Author$
// $Revision$
// $Date$
//
// copyright California Institute of Technology 2002
//
/////////////////////////////////////////////////////////////
// turn off warnings under Windows
#ifdef WIN32
#pragma warning(disable:4786)
#pragma warning(disable:4503)
#endif
#include <cantera/Cantera.h>
#include <cantera/zerodim.h>
#include <cantera/IdealGasMix.h>
#include <cantera/numerics.h>
#include <time.h>
#include "example_utils.h"
int kinetics1(int np, void* p) {
cout << "Constant-pressure ignition of a "
<< "hydrogen/oxygen/nitrogen"
" mixture \nbeginning at T = 1001 K and P = 1 atm." << endl;
// create an ideal gas mixture that corresponds to GRI-Mech
// 3.0
IdealGasMix gas("gri30.cti", "gri30");
// set the state
gas.setState_TPX(1001.0, OneAtm, "H2:2.0, O2:1.0, N2:4.0");
int nsp = gas.nSpecies();
// create a reactor
Reactor r;
// create a reservoir to represent the environment
Reservoir env;
// 'insert' the gas into the reactor and environment. Note
// that it is ok to insert the same gas object into multiple
// reactors or reservoirs. All this means is that this object
// will be used to evaluate thermodynamic or kinetic
// quantities needed.
r.insert(gas);
env.insert(gas);
//r.addHomogenRxnSens(0);
// create a wall between the reactor and the environment
Wall w;
w.install(r,env);
// The wall "expansion rate coefficient" controls how fast it
// moves in response to a pressure difference. Set it to a
// large value to approach the constant-pressure limit, so
// that the wall moves to counteract even small pressure
// differences
w.setExpansionRateCoeff(1.e9);
// set the wall to have unit area (arbitrary)
w.setArea(1.0);
double tm;
double dt = 1.e-5; // interval at which output is written
int nsteps = 100; // number of intervals
// create a 2D array to hold the output variables,
// and store the values for the initial state
Array2D soln(nsp+4, 1);
saveSoln(0, 0.0, gas, soln);
// create a container object to run the simulation
// and add the reactor to it
ReactorNet sim;
sim.addReactor(&r);
// main loop
clock_t t0 = clock(); // save start time
for (int i = 1; i <= nsteps; i++) {
tm = i*dt;
sim.advance(tm);
cout << "time = " << tm << " s" << endl;
saveSoln(tm, gas, soln);
}
clock_t t1 = clock(); // save end time
// make a Tecplot data file and an Excel spreadsheet
string plotTitle = "kinetics example 1: constant-pressure ignition";
plotSoln("kin1.dat", "TEC", plotTitle, gas, soln);
plotSoln("kin1.csv", "XL", plotTitle, gas, soln);
// print final temperature and timing data
doublereal tmm = 1.0*(t1 - t0)/CLOCKS_PER_SEC;
cout << " Tfinal = " << r.temperature() << endl;
cout << " time = " << tmm << endl;
cout << " number of residual function evaluations = "
<< sim.integrator().nEvals() << endl;
cout << " time per evaluation = " << tmm/sim.integrator().nEvals()
<< endl << endl;
cout << "Output files:" << endl
<< " kin1.csv (Excel CSV file)" << endl
<< " kin1.dat (Tecplot data file)" << endl;
return 0;
}
#ifndef CXX_DEMO
int main() {
try {
return kinetics1(0, 0);
}
// handle exceptions thrown by Cantera
catch (CanteraError) {
showErrors(cout);
cout << " terminating... " << endl;
appdelete();
return -1;
}
}
#endif