From 191bd093d0d47cf317495fcfeda59b67bdd4e3ac Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Sun, 11 Jan 2004 12:57:13 +0000 Subject: [PATCH] initial import --- Cantera/cxx/demos/Makefile | 20 ++++++++++++++++++++ Cantera/cxx/demos/kinetics1.cpp | 28 +++++++++++++++++----------- 2 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 Cantera/cxx/demos/Makefile diff --git a/Cantera/cxx/demos/Makefile b/Cantera/cxx/demos/Makefile new file mode 100644 index 000000000..ae251d3ba --- /dev/null +++ b/Cantera/cxx/demos/Makefile @@ -0,0 +1,20 @@ + +SRCS = kinetics1.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: + make $*.mak; make -f $*.mak; mv $* $*.x + @echo type '$*.x' to run the program + +clean: + rm -f $(OBJS) $(EXES) $(MKS) + + diff --git a/Cantera/cxx/demos/kinetics1.cpp b/Cantera/cxx/demos/kinetics1.cpp index fec8d59b8..5c0094efa 100644 --- a/Cantera/cxx/demos/kinetics1.cpp +++ b/Cantera/cxx/demos/kinetics1.cpp @@ -34,8 +34,7 @@ int main() { // create an ideal gas mixture that corresponds to GRI-Mech // 3.0 - IdealGasMix* gg = new IdealGasMix("gri30.cti", "gri30"); - IdealGasMix& gas = *gg; + IdealGasMix gas("gri30.cti", "gri30"); // set the state gas.setState_TPX(1001.0, OneAtm, "H2:2.0, O2:1.0, N2:4.0"); @@ -47,19 +46,26 @@ int main() { // create a reservoir to represent the environment Reservoir env; - // specify the thermodynamic property and kinetics managers + // '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); - // create a flexible, insulating wall between the reactor and the - // environment + // create a wall between the reactor and the environment Wall w; w.install(r,env); - // set the "expansion rate coefficient" to a large value, in order to - // approach the constant-pressure limit; see the documentation - // for class Reactor + // 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; @@ -72,13 +78,14 @@ int main() { saveSoln(0, 0.0, gas, soln); // main loop - clock_t t0 = clock(); + clock_t t0 = clock(); // save start time for (int i = 1; i <= nsteps; i++) { tm = i*dt; r.advance(tm); + cout << "time = " << tm << " s" << endl; saveSoln(tm, gas, soln); } - clock_t t1 = clock(); + clock_t t1 = clock(); // save end time // make a Tecplot data file and an Excel spreadsheet @@ -99,7 +106,6 @@ int main() { << " kin1.csv (Excel CSV file)" << endl << " kin1.dat (Tecplot data file)" << endl; - delete gg; return 0; }