Esempio n. 1
0
    time += 5.0e-6
    sim.advance(time)
    tim[n] = time
    data[n,0] = r.temperature()
    data[n,1] = r.moleFraction('OH') 
    data[n,2] = r.moleFraction('H')
    data[n,3] = r.moleFraction('CH4')
    
    # sensitivity of OH to reaction 2
    data[n,4] = sim.sensitivity('OH',2)
    
    # sensitivity of OH to reaction 3    
    data[n,5] = sim.sensitivity('OH',3)
    
    print '%10.3e %10.3f %10.3f %14.6e' % (sim.time(), r.temperature(), 
                                           r.pressure(), r.intEnergy_mass())
                                           #sim.sensitivity("OH",0))


# plot the results if matplotlib is installed.
# see http://matplotlib.sourceforge.net to get it
args = sys.argv
if 1==1:
    try:
        from matplotlib.pylab import *
        clf
        subplot(2,2,1)
        plot(tim,data[:,0])
        xlabel('Time (s)');
        ylabel('Temperature (K)');
        subplot(2,2,2)
Esempio n. 2
0
sim = ReactorNet([r])
time = 0.0
tim = zeros(100, 'd')
data = zeros([100, 5], 'd')

for n in range(100):
    time += 1.e-5
    sim.advance(time)
    tim[n] = time
    data[n, 0] = r.temperature()
    data[n, 1] = r.moleFraction('OH')
    data[n, 2] = r.moleFraction('H')
    data[n, 3] = r.moleFraction('H2')
    print '%10.3e %10.3f %10.3f %14.6e' % (sim.time(), r.temperature(),
                                           r.pressure(), r.intEnergy_mass())

# plot the results if matplotlib is installed.
# see http://matplotlib.sourceforge.net to get it
args = sys.argv
if len(args) > 1 and args[1] == '-plot':
    try:
        from matplotlib.pylab import *
        clf
        subplot(2, 2, 1)
        plot(tim, data[:, 0])
        xlabel('Time (s)')
        ylabel('Temperature (K)')
        subplot(2, 2, 2)
        plot(tim, data[:, 1])
        xlabel('Time (s)')
Esempio n. 3
0
    time += 5.0e-6
    sim.advance(time)
    tim[n] = time
    data[n,0] = r.temperature()
    data[n,1] = r.moleFraction('OH') 
    data[n,2] = r.moleFraction('H')
    data[n,3] = r.moleFraction('CH4')
    
    # sensitivity of OH to reaction 2
    data[n,4] = sim.sensitivity('OH',2)
    
    # sensitivity of OH to reaction 3    
    data[n,5] = sim.sensitivity('OH',3)
    
    print '%10.3e %10.3f %10.3f %14.6e %10.3f %10.3f' % (sim.time(), r.temperature(), 
                                           r.pressure(), r.intEnergy_mass(),  data[n,4],  data[n,5])


# plot the results if matplotlib is installed.
# see http://matplotlib.sourceforge.net to get it
args = sys.argv
if len(args) > 1 and args[1] == '-plot':
    try:
        from matplotlib.pylab import *
        clf
        subplot(2,2,1)
        plot(tim,data[:,0])
        xlabel('Time (s)');
        ylabel('Temperature (K)');
        subplot(2,2,2)
        plot(tim,data[:,1])
Esempio n. 4
0
c = (4.0-3.0*R)/(4.0*(1.0-R))
e = c/phi
d = 3.7*e
comp = 'CH4:0.5, H2:%(b)f, O2:%(e)f, N2:%(d)f'% vars()
print '#'+comp

gas = GRI30()

gas.set(T = T0, P = OneAtm, X = comp)
r   = Reactor(gas)

env = Reservoir(Air())

w = Wall(r,env)
w.set(K = 0)   # set expansion parameter. dV/dt = KA(P_1 - P_2)
w.set(A = 1.0)

sim = ReactorNet([r])
time = 0.0

#Told = r.temperature()
#print '%10.3e %10.3f %10.3f %14.6e' % (sim.time(), r.temperature(), r.pressure(), r.intEnergy_mass())

for n in range(36):
    time = (n+1)*0.0005   
    sim.advance(time)
    print '%10.3e %10.3f %10.3f %14.6e' % (sim.time(), r.temperature(), r.pressure(), r.intEnergy_mass())
#while time <= tFinal:
#    time = sim.step(tFinal)
#    print '%10.3e %10.3f %10.3f %14.6e' % (sim.time(), r.temperature(), 
#                                          r.pressure(), r.intEnergy_mass())#print MC_Gemisch(3,1)
Esempio n. 5
0
    time += 5.0e-6
    sim.advance(time)
    tim[n] = time
    data[n, 0] = r.temperature()
    data[n, 1] = r.moleFraction('OH')
    data[n, 2] = r.moleFraction('H')
    data[n, 3] = r.moleFraction('CH4')

    # sensitivity of OH to reaction 2
    data[n, 4] = sim.sensitivity('OH', 2)

    # sensitivity of OH to reaction 3
    data[n, 5] = sim.sensitivity('OH', 3)

    print '%10.3e %10.3f %10.3f %14.6e %10.3f %10.3f' % (
        sim.time(), r.temperature(), r.pressure(), r.intEnergy_mass(),
        data[n, 4], data[n, 5])

# plot the results if matplotlib is installed.
# see http://matplotlib.sourceforge.net to get it
args = sys.argv
if len(args) > 1 and args[1] == '-plot':
    try:
        from matplotlib.pylab import *
        clf
        subplot(2, 2, 1)
        plot(tim, data[:, 0])
        xlabel('Time (s)')
        ylabel('Temperature (K)')
        subplot(2, 2, 2)
        plot(tim, data[:, 1])