$ cat EthyleneTest.py
import cantera as ct
# Set the timestep and total simulation time
dt = 0.001
ttotal = 2.0
# Use GRI Mech 3.0
g = ct.Solution('gri30.xml')
# Set the initial state of the gas
g.TPX = 298.15 + 900, ct.one_atm, "CH4:4.0, O2:1.0, N2:3.762, H:0.00001"
# Create a reactor, and a reactor network to simulate it.
r = ct.Reactor(g)
n = ct.ReactorNet([r])
# This loop advances the reactor until we've reached the final time.
c = 0
t = dt
time_data = []
temp_data = []
while True:
n.advance(t)
time_data.append(t)
temp_data.append(r.T)
t = t + dt
if(c % 10==0):
print "Current reactor time:",t
if t > ttotal:
break
import matplotlib.pyplot as plt
plt.plot(time_data,temp_data)
plt.draw()
plt.show()