[Python/Examples] Rename 'gri3' to more generic 'gas'

This commit is contained in:
Ray Speth 2016-07-01 22:26:17 -04:00
parent 001b7e91eb
commit b4f2f82fe3
3 changed files with 15 additions and 15 deletions

View file

@ -7,13 +7,13 @@ import numpy as np
import cantera as ct
gri3 = ct.Solution('gri30.xml')
gri3.TPX = 1001.0, ct.one_atm, 'H2:2,O2:1,N2:4'
r = ct.IdealGasConstPressureReactor(gri3)
gas = ct.Solution('gri30.xml')
gas.TPX = 1001.0, ct.one_atm, 'H2:2,O2:1,N2:4'
r = ct.IdealGasConstPressureReactor(gas)
sim = ct.ReactorNet([r])
time = 0.0
states = ct.SolutionArray(gri3, extra=['t'])
states = ct.SolutionArray(gas, extra=['t'])
print('%10s %10s %10s %14s' % ('t [s]','T [K]','P [Pa]','u [J/kg]'))
for n in range(100):
@ -33,15 +33,15 @@ if '--plot' in sys.argv[1:]:
plt.xlabel('Time (ms)')
plt.ylabel('Temperature (K)')
plt.subplot(2, 2, 2)
plt.plot(states.t, states.X[:,gri3.species_index('OH')])
plt.plot(states.t, states.X[:,gas.species_index('OH')])
plt.xlabel('Time (ms)')
plt.ylabel('OH Mole Fraction')
plt.subplot(2, 2, 3)
plt.plot(states.t, states.X[:,gri3.species_index('H')])
plt.plot(states.t, states.X[:,gas.species_index('H')])
plt.xlabel('Time (ms)')
plt.ylabel('H Mole Fraction')
plt.subplot(2, 2, 4)
plt.plot(states.t, states.X[:,gri3.species_index('H2')])
plt.plot(states.t, states.X[:,gas.species_index('H2')])
plt.xlabel('Time (ms)')
plt.ylabel('H2 Mole Fraction')
plt.tight_layout()

View file

@ -36,12 +36,12 @@ r1 = ct.IdealGasReactor(ar)
env = ct.Reservoir(ct.Solution('air.xml'))
# use GRI-Mech 3.0 for the methane/air mixture, and set its initial state
gri3 = ct.Solution('gri30.xml')
gri3.TP = 500.0, 0.2 * ct.one_atm
gri3.set_equivalence_ratio(1.1, 'CH4:1.0', 'O2:2, N2:7.52')
gas = ct.Solution('gri30.xml')
gas.TP = 500.0, 0.2 * ct.one_atm
gas.set_equivalence_ratio(1.1, 'CH4:1.0', 'O2:2, N2:7.52')
# create a reactor for the methane/air side
r2 = ct.IdealGasReactor(gri3)
r2 = ct.IdealGasReactor(gas)
#-----------------------------------------------------------------------------
# Now couple the reactors by defining common walls that may move (a piston) or
@ -68,7 +68,7 @@ csvfile = csv.writer(outfile)
csvfile.writerow(['time (s)','T1 (K)','P1 (Bar)','V1 (m3)',
'T2 (K)','P2 (Bar)','V2 (m3)'])
states1 = ct.SolutionArray(ar, extra=['t', 'V'])
states2 = ct.SolutionArray(gri3, extra=['t', 'V'])
states2 = ct.SolutionArray(gas, extra=['t', 'V'])
for n in range(n_steps):
time += 4.e-4

View file

@ -7,12 +7,12 @@ import numpy as np
import cantera as ct
gri3 = ct.Solution('gri30.xml')
gas = ct.Solution('gri30.xml')
temp = 1500.0
pres = ct.one_atm
gri3.TPX = temp, pres, 'CH4:0.1, O2:2, N2:7.52'
r = ct.IdealGasConstPressureReactor(gri3, name='R1')
gas.TPX = temp, pres, 'CH4:0.1, O2:2, N2:7.52'
r = ct.IdealGasConstPressureReactor(gas, name='R1')
sim = ct.ReactorNet([r])
# enable sensitivity with respect to the rates of the first 10