initial import
This commit is contained in:
parent
080bff99a7
commit
191bd093d0
2 changed files with 37 additions and 11 deletions
20
Cantera/cxx/demos/Makefile
Normal file
20
Cantera/cxx/demos/Makefile
Normal file
|
|
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -34,8 +34,7 @@ int main() {
|
||||||
|
|
||||||
// create an ideal gas mixture that corresponds to GRI-Mech
|
// create an ideal gas mixture that corresponds to GRI-Mech
|
||||||
// 3.0
|
// 3.0
|
||||||
IdealGasMix* gg = new IdealGasMix("gri30.cti", "gri30");
|
IdealGasMix gas("gri30.cti", "gri30");
|
||||||
IdealGasMix& gas = *gg;
|
|
||||||
|
|
||||||
// set the state
|
// set the state
|
||||||
gas.setState_TPX(1001.0, OneAtm, "H2:2.0, O2:1.0, N2:4.0");
|
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
|
// create a reservoir to represent the environment
|
||||||
Reservoir env;
|
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);
|
r.insert(gas);
|
||||||
env.insert(gas);
|
env.insert(gas);
|
||||||
|
|
||||||
// create a flexible, insulating wall between the reactor and the
|
// create a wall between the reactor and the environment
|
||||||
// environment
|
|
||||||
Wall w;
|
Wall w;
|
||||||
w.install(r,env);
|
w.install(r,env);
|
||||||
|
|
||||||
// set the "expansion rate coefficient" to a large value, in order to
|
// The wall "expansion rate coefficient" controls how fast it
|
||||||
// approach the constant-pressure limit; see the documentation
|
// moves in response to a pressure difference. Set it to a
|
||||||
// for class Reactor
|
// large value to approach the constant-pressure limit, so
|
||||||
|
// that the wall moves to counteract even small pressure
|
||||||
|
// differences
|
||||||
w.setExpansionRateCoeff(1.e9);
|
w.setExpansionRateCoeff(1.e9);
|
||||||
|
|
||||||
|
// set the wall to have unit area (arbitrary)
|
||||||
w.setArea(1.0);
|
w.setArea(1.0);
|
||||||
|
|
||||||
double tm;
|
double tm;
|
||||||
|
|
@ -72,13 +78,14 @@ int main() {
|
||||||
saveSoln(0, 0.0, gas, soln);
|
saveSoln(0, 0.0, gas, soln);
|
||||||
|
|
||||||
// main loop
|
// main loop
|
||||||
clock_t t0 = clock();
|
clock_t t0 = clock(); // save start time
|
||||||
for (int i = 1; i <= nsteps; i++) {
|
for (int i = 1; i <= nsteps; i++) {
|
||||||
tm = i*dt;
|
tm = i*dt;
|
||||||
r.advance(tm);
|
r.advance(tm);
|
||||||
|
cout << "time = " << tm << " s" << endl;
|
||||||
saveSoln(tm, gas, soln);
|
saveSoln(tm, gas, soln);
|
||||||
}
|
}
|
||||||
clock_t t1 = clock();
|
clock_t t1 = clock(); // save end time
|
||||||
|
|
||||||
|
|
||||||
// make a Tecplot data file and an Excel spreadsheet
|
// make a Tecplot data file and an Excel spreadsheet
|
||||||
|
|
@ -99,7 +106,6 @@ int main() {
|
||||||
<< " kin1.csv (Excel CSV file)" << endl
|
<< " kin1.csv (Excel CSV file)" << endl
|
||||||
<< " kin1.dat (Tecplot data file)" << endl;
|
<< " kin1.dat (Tecplot data file)" << endl;
|
||||||
|
|
||||||
delete gg;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue