def AIT(x2,end_t):
   

    #comp = 'CH4:1.0, O2:2, N2:7.52'
    tempx = 980 
    gasx.set(T = tempx, P = OneAtm, X = x2)
    r = Reactor(gasx)
        
    try:
        sim = ReactorNet([r])
        sim.advance(time)       
    except:
        pass      
    t_x=r.temperature()
    print t_x-tempx
    return t_x-tempx
示例#2
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)
示例#3
0
print air_mdot,fuel_mdot 
# create and install the mass flow controllers
    
m1 = MassFlowController(upstream = fuel_in, downstream = combustor, mdot = fuel_mdot)
m2 = MassFlowController(upstream = air_in, downstream = combustor, mdot = air_mdot)
    
igniter_mdot = Gaussian(t0=1.0, FWHM = 0.04, A = 0.1)
m2 = MassFlowController(upstream = igniter, downstream = combustor, mdot = igniter_mdot)
    
v = Valve (upstream = combustor, downstream = exhaust, Kv = 0.5)
   
sim = ReactorNet([combustor])
    
tfinal = 6.0
tnow = 0.0

time_list=[]
temp_list=[]
temp_list3=[]

  
while tnow< tfinal:
    tnow = sim.step(tfinal)
    time_list.append(tnow)  
    #temp_list.append(combustor.density())
    temp_list.append(combustor.temperature())  
    
p.plot(list_to_array(time_list),list_to_array(temp_list))
p.xlabel('Zeit')
p.ylabel('Temperatur')
p.show()
示例#4
0
文件: mix1.py 项目: anujg1991/cantera
# create two mass flow controllers connecting the upstream reservoirs
# to the mixer, and set their mass flow rates to values corresponding
# to stoichiometric combustion.
mfc1 = MassFlowController(upstream = res_a, downstream = mixer,
                          mdot = rho_a*2.5/0.21)

mfc2 = MassFlowController(upstream = res_b, downstream = mixer,
                          mdot = rho_b*1.0)


# connect the mixer to the downstream reservoir with a valve.
outlet = Valve(upstream = mixer, downstream = downstream, Kv = 1.0)

sim = ReactorNet([mixer])

# Since the mixer is a reactor, we need to integrate in time to reach
# steady state. A few residence times should be enough.
t = 0.0
for n in range(30):
    tres = mixer.mass()/(mfc1.massFlowRate() + mfc2.massFlowRate())
    t += 0.5*tres
    sim.advance(t)
    print '%14.5g %14.5g %14.5g  %14.5g  %14.5g' % (t, mixer.temperature(),
                                                    mixer.enthalpy_mass(),
                                                    mixer.pressure(),
                                                    mixer.massFraction('CH4'))

# view the state of the gas in the mixer
print mixer.contents()
示例#5
0
# flow rates change or if there is chemistry occurring.
mixer = Reactor(gas_b)

# create two mass flow controllers connecting the upstream reservoirs
# to the mixer, and set their mass flow rates to values corresponding
# to stoichiometric combustion.
mfc1 = MassFlowController(upstream=res_a,
                          downstream=mixer,
                          mdot=rho_a * 2.5 / 0.21)

mfc2 = MassFlowController(upstream=res_b, downstream=mixer, mdot=rho_b * 1.0)

# connect the mixer to the downstream reservoir with a valve.
outlet = Valve(upstream=mixer, downstream=downstream, Kv=1.0)

sim = ReactorNet([mixer])

# Since the mixer is a reactor, we need to integrate in time to reach
# steady state. A few residence times should be enough.
t = 0.0
for n in range(30):
    tres = mixer.mass() / (mfc1.massFlowRate() + mfc2.massFlowRate())
    t += 0.5 * tres
    sim.advance(t)
    print '%14.5g %14.5g %14.5g  %14.5g  %14.5g' % (
        t, mixer.temperature(), mixer.enthalpy_mass(), mixer.pressure(),
        mixer.massFraction('CH4'))

# view the state of the gas in the mixer
print mixer.contents()
示例#6
0
NotOpenVent = False
for n in range(166000):
    time = (n+1)*0.00002


    area_valve = 5.E-5
    roh = r1.density()
    kappa = gas.cp_mole()/gas.cv_mole()
    
    nym_real = min(gas_sink.pressure()/r1.pressure(),((2./(kappa+1.))**(kappa/(kappa-1.))))
    #print nym_real,gas_sink.pressure()/r1.pressure(),((2./(kappa+1.))**(kappa/(kappa-1.)))
    
    Ausfluss = ( (kappa/(kappa-1.)) * (nym_real**(2./kappa))* (1.-(nym_real**((kappa-1.)/kappa)))**(1./2.))
    
    Kv = area_valve * 1. * Ausfluss * (2*gas_sink.pressure()*roh)**(1./2.) / roh
    print r1.density(),r1.temperature(),r1.pressure()
                 
    if (r1.pressure()/1E5)>1.5 or NotOpenVent:
        v1.setValveCoeff(Kv)
        NotOpenVent = True
        
    sim.advance(time)            
    time_list.append(time)
    temp_list.append(r1.pressure()/1E5)
    
    time_list2.append(time)
    temp_list2.append(Kv*10)
    
    time_list3.append(time)
    temp_list3.append(r1.temperature()/1000)
    #print time,0.000010*(r1.pressure()-gas_sink.pressure())
示例#7
0
# note that this connects two reactors with different reaction
# mechanisms and different numbers of species. Downstream and upstream
# species are matched by name.
m2 = MassFlowController(upstream = air_in,
                        downstream = combustor, mdot = air_mdot)

# The igniter will use a Gaussian 'functor' object to specify the
# time-dependent igniter mass flow rate.
igniter_mdot = Gaussian(t0 = 1.0, FWHM = 0.2, A = 0.1)
m3 = MassFlowController(upstream = igniter,
                        downstream = combustor, mdot = igniter_mdot)

# put a valve on the exhaust line to regulate the pressure
v = Valve(upstream = combustor, downstream = exhaust, Kv = 1.0)

# the simulation only contains one reactor
sim = ReactorNet([combustor])

# take single steps to 6 s, writing the results to a CSV file
# for later plotting.
tfinal = 6.0
tnow = 0.0
f = open('combustor.csv','w')
while tnow < tfinal:
    tnow = sim.step(tfinal)
    tres = combustor.mass()/v.massFlowRate()
    writeCSV(f, [tnow, combustor.temperature(), tres]
             +list(combustor.moleFractions()))
f.close()
示例#8
0
sim = ReactorNet([r])

# set the tolerances for the solution and for the sensitivity
# coefficients
sim.setTolerances(rtol = 1.0e-6, atol = 1.0e-15,
                  rtolsens = 1.0e-5, atolsens = 1.0e-5)
time = 0.0
np = 400
tim = zeros(np,'d')
data = zeros([np,6],'d')

for n in range(np):
    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))

示例#9
0
sim = ReactorNet([r1, r2])

# Now the problem is set up, and we're ready to solve it.
print 'finished setup, begin solution...'

time = 0.0
f = open('piston.csv','w')
writeCSV(f,['time (s)','T1 (K)','P1 (Bar)','V1 (m3)',
            'T2 (K)','P2 (Bar)','V2 (m3)'])
temp = zeros([300, 2], 'd')
pres = zeros([300, 2], 'd')
vol = zeros([300, 2], 'd')
tm = zeros(300,'d')
for n in range(300):
    time += 4.e-4
    print time, r2.temperature(),n
    sim.advance(time)
    tm[n] = time
    temp[n,:] = [r1.temperature(), r2.temperature()]
    pres[n,:] = [1.0e-5*r1.pressure(), 1.0e-5*r2.pressure()]
    vol[n,:] = [r1.volume(), r2.volume()]
    writeCSV(f, [tm[n], temp[n,0], pres[n,0], vol[n,0],
                 temp[n,1], pres[n,1], vol[n,1]])
f.close()
import os
print 'Output written to file piston.csv'
print 'Directory: '+os.getcwd()

args = sys.argv
if len(args) > 1 and args[1] == '-plot':
    try:    
示例#10
0
# Now the problem is set up, and we're ready to solve it.
print 'finished setup, begin solution...'

time = 0.0
f = open('piston.csv', 'w')
writeCSV(f, [
    'time (s)', 'T1 (K)', 'P1 (Bar)', 'V1 (m3)', 'T2 (K)', 'P2 (Bar)',
    'V2 (m3)'
])
temp = zeros([300, 2], 'd')
pres = zeros([300, 2], 'd')
vol = zeros([300, 2], 'd')
tm = zeros(300, 'd')
for n in range(300):
    time += 4.e-4
    print time, r2.temperature(), n
    sim.advance(time)
    tm[n] = time
    temp[n, :] = [r1.temperature(), r2.temperature()]
    pres[n, :] = [1.0e-5 * r1.pressure(), 1.0e-5 * r2.pressure()]
    vol[n, :] = [r1.volume(), r2.volume()]
    writeCSV(f, [
        tm[n], temp[n, 0], pres[n, 0], vol[n, 0], temp[n, 1], pres[n, 1],
        vol[n, 1]
    ])
f.close()
import os
print 'Output written to file piston.csv'
print 'Directory: ' + os.getcwd()

args = sys.argv
示例#11
0
# create two mass flow controllers connecting the upstream reservoirs
# to the mixer, and set their mass flow rates to values corresponding
# to stoichiometric combustion.
mfc1 = MassFlowController(upstream = res_a, downstream = mixer,
                          mdot = rho_a*2.5/0.21)

mfc2 = MassFlowController(upstream = res_b, downstream = mixer,
                          mdot = rho_b*1.0)


# connect the mixer to the downstream reservoir with a valve.
outlet = Valve(upstream = mixer, downstream = downstream, Kv = 1.0)

sim = ReactorNet([mixer])

# Since the mixer is a reactor, we need to integrate in time to reach
# steady state. A few residence times should be enough.
t = 0.0
for n in range(30):
    tres = mixer.mass()/(mfc1.massFlowRate() + mfc2.massFlowRate())
    t += 0.5*tres
    sim.advance(t)
    print '%14.5g %14.5g %14.5g  %14.5g  %14.5g' % (t, mixer.temperature(),
                                                    mixer.enthalpy_mass(),
                                                    mixer.pressure(),
                                                    mixer.massFraction('CH4'))

# view the state of the gas in the mixer
print mixer.contents()

示例#12
0
reactors = ReactorNet([r1, r2])

tim = []
t1 = []
t2 = []
v1 = []
v2 = []
v = []
xco = []
xh2 = []

for n in range(30):
    time = (n+1)*0.002
    reactors.advance(time)
    print fmt % (time, r1.temperature(), r2.temperature(),
                 r1.volume(), r2.volume(), r1.volume() + r2.volume(),
                 r2.moleFraction('CO'))

    tim.append(time)
    t1.append(r1.temperature())
    t2.append(r2.temperature())
    v1.append(r1.volume())
    v2.append(r2.volume())
    v.append(r1.volume() + r2.volume())
    xco.append(r2.moleFraction('CO'))  
    xh2.append(r1.moleFraction('H2'))

    
# plot the results if matplotlib is installed.
# see http://matplotlib.sourceforge.net to get it
示例#13
0
sim = ReactorNet([r])

# set the tolerances for the solution and for the sensitivity
# coefficients
sim.setTolerances(rtol=1.0e-6, atol=1.0e-15, rtolsens=1.0e-5, atolsens=1.0e-5)
time = 0.0
np = 400
tim = zeros(np, 'd')
data = zeros([np, 6], 'd')

for n in range(np):
    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.
示例#14
0
# make it flexible, so that the pressure in the reactor is held
# at the environment pressure.
w = Wall(r, env)
w.set(K=1.0e6)  # set expansion parameter. dV/dt = KA(P_1 - P_2)
w.set(A=1.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])
示例#15
0
# note that this connects two reactors with different reaction
# mechanisms and different numbers of species. Downstream and upstream
# species are matched by name.
m2 = MassFlowController(upstream = air_in,
                        downstream = combustor, mdot = air_mdot)

# The igniter will use a Guassiam 'functor' object to specify the
# time-dependent igniter mass flow rate.
igniter_mdot = Gaussian(t0 = 1.0, FWHM = 0.2, A = 0.1)
m3 = MassFlowController(upstream = igniter,
                        downstream = combustor, mdot = igniter_mdot)

# put a valve on the exhaust line to regulate the pressure
v = Valve(upstream = combustor, downstream = exhaust, Kv = 1.0)

# the simulation only contains one reactor
sim = ReactorNet([combustor])

# take single steps to 6 s, writing the results to a CSV file
# for later plotting.
tfinal = 6.0
tnow = 0.0
f = open('combustor.csv','w')
while tnow < tfinal:
    tnow = sim.step(tfinal)
    tres = combustor.mass()/v.massFlowRate()
    writeCSV(f, [tnow, combustor.temperature(), tres]
             +list(combustor.moleFractions()))
f.close()

示例#16
0
def list_to_array(data):
    '''
    Wandelt die Liste in Numpyarray um und schneidet erste Datensatz ab
    '''
    return N.array(data)


from string import *

time = 10.0
gas = GRI30()


comp = 'CH4:1.0, O2:2, N2:7.52'
for n in range(45):
    t = 800.0 + 2.0*n
    gas.setState_TPX(t, OneAtm, comp)
    r = Reactor(gas)
    
    sim = ReactorNet([r])
    sim.setTolerances(rtol=1E-12, atol=1E-22, rtolsens=-1, atolsens=-1)
    while sim.time()<time:
        sim.step(1)
        dt = r.temperature() - t
        print t-273.15, dt,sim.time()
        if dt > 600.0:
            print '!!'
            break
    if dt > 600.0:
            print '!!'
            break
示例#17
0
文件: mix2.py 项目: minhbau/Cantera
gas_c.set(T=300.0, P=OneAtm, X='H:1')
igniter = Reactor(gas_c)

mfc3 = MassFlowController(upstream=igniter, downstream=mixer, mdot=0.05)

# connect the mixer to the downstream reservoir with a valve.
outlet = Valve(upstream=mixer, downstream=downstream, Kv=1.0)

sim = ReactorNet([mixer])

# Since the mixer is a reactor, we need to integrate in time to reach
# steady state. A few residence times should be enough.
t = 0.0
for n in range(30):
    tres = mixer.mass() / (mfc1.massFlowRate() + mfc2.massFlowRate())
    t += 0.5 * tres
    sim.advance(t)

    # if ignited, turn the igniter off.
    # We also need to restart the integration in this case.
    if mixer.temperature() > 1200.0:
        mfc3.set(mdot=0.0)
        sim.setInitialTime(t)

    print '%14.5g %14.5g %14.5g  %14.5g  %14.5g' % (
        t, mixer.temperature(), mixer.enthalpy_mass(), mixer.pressure(),
        mixer.massFraction('CH4'))

# view the state of the gas in the mixer
print mixer.contents()
示例#18
0
reactors = ReactorNet([r1, r2])

tim = []
t1 = []
t2 = []
v1 = []
v2 = []
v = []
xco = []
xh2 = []

for n in range(30):
    time = (n+1)*0.002
    reactors.advance(time)
    print fmt % (time, r1.temperature(), r2.temperature(),
                 r1.volume(), r2.volume(), r1.volume() + r2.volume(),
                 r2.moleFraction('CO'))

    tim.append(time)
    t1.append(r1.temperature())
    t2.append(r2.temperature())
    v1.append(r1.volume())
    v2.append(r2.volume())
    v.append(r1.volume() + r2.volume())
    xco.append(r2.moleFraction('CO'))
    xh2.append(r1.moleFraction('H2'))


# plot the results if matplotlib is installed.
# see http://matplotlib.sourceforge.net to get it
示例#19
0
    def PSRCalc(self, volume, tfinal):
        initial_gas = self.InitialGas()

        gas = self._gas1
        NoGas = 0  ## Ignition isn't provided if NoGas = 0
        mass_flow = 0

        upstreams = numpy.empty(self._code, dtype=object)
        ms = numpy.empty(self._code, dtype=object)

        reactor = Reactor(initial_gas, volume=volume, energy='on')

        ControllerCount = 0
        for code in range(0, self._argslength, 2):
            upstreams[ControllerCount] = Reservoir(self._args[code])
            ms[ControllerCount] = MassFlowController()
            ms[ControllerCount].install(upstreams[ControllerCount], reactor)
            ms[ControllerCount].set(self._args[code + 1])
            mass_flow += self._args[code + 1]
            ControllerCount += 1

        exhaust = Reservoir(gas)

        v = Valve()
        v.install(reactor, exhaust)
        v.setValveCoeff(Kv=0.5)  #Change made from 1.0 to 0.5

        sim = ReactorNet([reactor])

        tnow = 0.0

        tracker = datetime.now()
        LoopCounter = 0
        while (tnow < tfinal):
            LoopCounter += 1
            tnow = sim.step(tfinal)
            tres = reactor.mass() / mass_flow
            currenttime = datetime.now()
            d = reactor.massFractions()

            IndexCounter = 0
            for item in d:
                if item > 1:
                    badguy = 1
                    baditem = item
                    break
                else:
                    badguy = 0
                IndexCounter += 1
            if badguy:
                break

            b = (currenttime.time().minute - tracker.time().minute)
            if (b > 2):
                break

        if (IndexCounter >= gas.nSpecies()):
            badSpecie = 'No Bad Species present'
            baditem = 'None'
        else:
            badSpecie = gas.speciesName(IndexCounter)

        tres = reactor.mass() / v.massFlowRate()
        T = reactor.temperature()
        P = reactor.pressure()
        reactor = Reactor(initial_gas)
        x = reactor.contents().moleFractions()
        initial_gas.setState_TPX(T, P, x)

        return initial_gas, mass_flow, tres
示例#20
0
                if ratio < 0.0: ratio = -ratio
                if ratio > 1.0e-9 or time < 10*dt:
                    alldone = 0
		    
            if alldone: break

	# set the gas object state to that of this reactor, in
	# preparation for the simulation of the next reactor
	# downstream, where this object will set the inlet conditions
        gas = r.contents()

        dist = n*rlen * 1.0e3   # distance in mm

	# write the gas mole fractions and surface coverages
	# vs. distance
        writeCSV(f, [dist, r.temperature() - 273.15,
		     r.pressure()/OneAtm] + list(gas.moleFractions())
                 + list(surf.coverages()))

f.close()

# make a reaction path diagram tracing carbon. This diagram will show
# the pathways by the carbon entering the bed in methane is convered
# into CO and CO2. The diagram will be specifically for the exit of
# the bed; if the pathways are desired at some interior point, then
# put this statement inside the above loop.
#
# To process this diagram, give the command on the command line
# after running this script:
# dot -Tps < carbon_pathways.dot > carbon_pathways.ps
# This will generate the diagram in Postscript.
示例#21
0
    def PFR(self, volume, NReactors):
        initial_gas = self.InitialGas()
        gas = self._gas1
        T = gas.temperature()
        P = gas.pressure()
        x = gas.moleFractions()
        initial_gas.setState_TPX(T, P, x)

        upstreams = numpy.empty(self._code - 1, dtype=object)
        ms = numpy.empty(self._code - 1, dtype=object)

        mass_flow = self._args[1]

        TOL = 1.0E-10
        Niter = 20

        nsp = gas.nSpecies()

        wdot = [''] * nsp
        wold = [''] * nsp

        volume_n = volume / NReactors

        tres = 0.0

        for i in range(0, NReactors):
            reactor = Reactor(initial_gas, volume=volume_n, energy='on')

            upstream = Reservoir(initial_gas)
            downstream = Reservoir(initial_gas)

            m = MassFlowController()
            m.install(upstream, reactor)
            m.set(mass_flow)

            if (i == 0):
                ControllerCount = 0
                for code in range(2, self._argslength, 2):
                    upstreams[ControllerCount] = Reservoir(self._args[code])
                    ms[ControllerCount] = MassFlowController()
                    ms[ControllerCount].install(upstreams[ControllerCount],
                                                reactor)
                    ms[ControllerCount].set(self._args[code + 1])
                    mass_flow += self._args[code + 1]
                    ControllerCount += 1

            v = Valve()
            v.install(reactor, downstream)
            v.setValveCoeff(Kv=0.1)

            sim = ReactorNet([reactor])

            dt = reactor.mass() / mass_flow

            tnow = 0.0
            wold = initial_gas.netProductionRates()

            while (tnow < Niter * dt):
                tnow += dt
                sim.advance(tnow)

                max_change = 0.0
                wdot = initial_gas.netProductionRates()

                for k in range(0, nsp):
                    max_change = max(math.fabs(wdot[k] - wold[k]), max_change)
                    wold[k] = wdot[k]

                if (max_change < TOL):
                    break

            tres += reactor.mass() / mass_flow

            T = reactor.temperature()
            P = reactor.pressure()
            reactor = Reactor(initial_gas)
            x = reactor.contents().moleFractions()
            initial_gas.setState_TPX(T, P, x)

        f = self.FuelMassAnalyzer(initial_gas, mass_flow)

        return initial_gas, mass_flow, tres, f
示例#22
0
            if ratio < 0.0: ratio = -ratio
            if ratio > 1.0e-9 or time < 10 * dt:
                alldone = 0

        if alldone: break

# set the gas object state to that of this reactor, in
# preparation for the simulation of the next reactor
# downstream, where this object will set the inlet conditions
    gas = r.contents()

    dist = n * rlen * 1.0e3  # distance in mm

    # write the gas mole fractions and surface coverages
    # vs. distance
    writeCSV(f, [dist, r.temperature() - 273.15,
                 r.pressure() / OneAtm] + list(gas.moleFractions()) +
             list(surf.coverages()))

f.close()

# make a reaction path diagram tracing carbon. This diagram will show
# the pathways by the carbon entering the bed in methane is convered
# into CO and CO2. The diagram will be specifically for the exit of
# the bed; if the pathways are desired at some interior point, then
# put this statement inside the above loop.
#
# To process this diagram, give the command on the command line
# after running this script:
# dot -Tps < carbon_pathways.dot > carbon_pathways.ps
# This will generate the diagram in Postscript.
示例#23
0
                          mdot = 0.05)


# connect the mixer to the downstream reservoir with a valve.
outlet = Valve(upstream = mixer, downstream = downstream, Kv = 1.0)

sim = ReactorNet([mixer])

# Since the mixer is a reactor, we need to integrate in time to reach
# steady state. A few residence times should be enough.
t = 0.0
for n in range(30):
    tres = mixer.mass()/(mfc1.massFlowRate() + mfc2.massFlowRate())
    t += 0.5*tres
    sim.advance(t)

    # if ignited, turn the igniter off.
    # We also need to restart the integration in this case.
    if mixer.temperature() > 1200.0:
        mfc3.set(mdot = 0.0)
        sim.setInitialTime(t)
        
    print '%14.5g %14.5g %14.5g  %14.5g  %14.5g' % (t, mixer.temperature(),
                                                    mixer.enthalpy_mass(),
                                                    mixer.pressure(),
                                                    mixer.massFraction('CH4'))

# view the state of the gas in the mixer
print mixer.contents()

示例#24
0
文件: mix2.py 项目: anujg1991/cantera
mfc3 = MassFlowController(upstream = igniter, downstream = mixer,
                          mdot = 0.05)


# connect the mixer to the downstream reservoir with a valve.
outlet = Valve(upstream = mixer, downstream = downstream, Kv = 1.0)

sim = ReactorNet([mixer])

# Since the mixer is a reactor, we need to integrate in time to reach
# steady state. A few residence times should be enough.
t = 0.0
for n in range(30):
    tres = mixer.mass()/(mfc1.massFlowRate() + mfc2.massFlowRate())
    t += 0.5*tres
    sim.advance(t)

    # if ignited, turn the igniter off.
    # We also need to restart the integration in this case.
    if mixer.temperature() > 1200.0:
        mfc3.set(mdot = 0.0)
        sim.setInitialTime(t)

    print '%14.5g %14.5g %14.5g  %14.5g  %14.5g' % (t, mixer.temperature(),
                                                    mixer.enthalpy_mass(),
                                                    mixer.pressure(),
                                                    mixer.massFraction('CH4'))

# view the state of the gas in the mixer
print mixer.contents()
示例#25
0
time_list = []
temp_list = []
temp_list3 = []

# Abbruchkriterium haelfte des Sauerstoffs ist Verbraucht.
O2_Start = r2.moleFraction("O2")
csvfile = "adiabatic.csv"
f = open(csvfile, "w")
writeCSV(f, ["Temp", "Pressure"])
for n in range(15):
    time = (n) * 30.0 + 0.015
    sim.advance(time)
    time_list.append(time)
    # time_list2.append(1000./r2.temperature())
    temp_list.append(r2.pressure())
    temp_list3.append((r2.temperature() - 273.15))

    writeCSV(f, [(r2.temperature() - 273.15), r2.pressure() / 1e5])

    # temp_list3.append(r2.enthalpy_mass())

    # if r2.temperature()>2500:
#     break
# if O2_Start/40.>r2.moleFraction('O2'):
#    print time_list[-20],temp_list[-20],temp_list3[-20]
#    print time_list[-12],temp_list[-12],temp_list3[-12]
#    print time_list[-1],temp_list[-1],temp_list3[-1]
#    break
# print time,0.000010*(r1.pressure()-gas_sink.pressure())

# print peakdetect(list_to_array(time_list),list_to_array(temp_list3),lookahead = 50,delta = 5)