Exemple #1
0
    def setUp(self):
        self.gas = ct.importPhase('h2o2.cti')

        # create a reservoir for the fuel inlet, and set to pure methane.
        self.gas.set(T=300.0, P=ct.OneAtm, X='H2:1.0')
        fuel_in = reactors.Reservoir(self.gas)
        fuel_mw = self.gas.meanMolarMass()

        # Oxidizer inlet
        self.gas.set(T=300.0, P=ct.OneAtm, X='O2:1.0, AR:3.0')
        oxidizer_in = reactors.Reservoir(self.gas)
        oxidizer_mw = self.gas.meanMolarMass()

        # to ignite the fuel/air mixture, we'll introduce a pulse of radicals.
        # The steady-state behavior is independent of how we do this, so we'll
        # just use a stream of pure atomic hydrogen.
        self.gas.set(T=300.0, P=ct.OneAtm, X='H:1.0')
        self.igniter = reactors.Reservoir(self.gas)

        # create the combustor, and fill it in initially with a diluent
        self.gas.set(T=300.0, P=ct.OneAtm, X='AR:1.0')
        self.combustor = reactors.Reactor(contents=self.gas, volume=1.0)

        # create a reservoir for the exhaust
        self.exhaust = reactors.Reservoir(self.gas)

        # compute fuel and air mass flow rates
        factor = 0.1
        oxidizer_mdot = 4 * factor * oxidizer_mw
        fuel_mdot = factor * fuel_mw

        # create and install the mass flow controllers. Controllers
        # m1 and m2 provide constant mass flow rates, and m3 provides
        # a short Gaussian pulse only to ignite the mixture
        m1 = reactors.MassFlowController(upstream=fuel_in,
                                         downstream=self.combustor,
                                         mdot=fuel_mdot)

        m2 = reactors.MassFlowController(upstream=oxidizer_in,
                                         downstream=self.combustor,
                                         mdot=oxidizer_mdot)

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

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

        # the simulation only contains one reactor
        self.sim = reactors.ReactorNet([self.combustor])
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
Exemple #3
0
    def setUp(self):
        # reservoir to represent the environment
        self.gas0 = ct.importPhase('air.cti')
        self.gas0.set(T=300, P=ct.OneAtm)
        self.env = reactors.Reservoir(self.gas0)

        # reactor to represent the side filled with Argon
        self.gas1 = ct.importPhase('air.cti')
        self.gas1.set(T=1000.0, P=30 * ct.OneAtm, X='AR:1.0')
        self.r1 = reactors.Reactor(self.gas1)

        # reactor to represent the combustible mixture
        self.gas2 = ct.importPhase('h2o2.cti')
        self.gas2.set(T=500.0, P=1.5 * ct.OneAtm, X='H2:0.5, O2:1.0, AR:10.0')
        self.r2 = reactors.Reactor(self.gas2)

        # Wall between the two reactors
        self.w1 = reactors.Wall(self.r2, self.r1)
        self.w1.set(area=1.0, K=2e-4, U=400.0)

        # Wall to represent heat loss to the environment
        self.w2 = reactors.Wall(self.r2, self.env)
        self.w2.set(area=1.0, U=2000.0)

        # Create the reactor network
        self.sim = reactors.ReactorNet([self.r1, self.r2])
Exemple #4
0
gas.set(T=300, P = ct.OneAtm, X='CH4:0.9, H2:0.1')
fuel_in = Reservoir(gas)
fuel_mw = gas.meanMolarMass()
    
    #create a reservoir of H atoms to use to ignite the mixture
gas.set(T=300, P=ct.OneAtm, X = 'H:1.0')
igniter = Reservoir(gas)
    
    # use predefined Air for the air inlet
gas.set(T=300, P=ct.OneAtm, X = 'N2:70,O2:20')
air = Reservoir(gas)
air_in = Reservoir(gas)
air_mw = gas.meanMolarMass()
   
gas.set(T=300, P=ct.OneAtm, X = 'N2:1')
combustor = Reactor(contents = gas, volume =1.0)
    
exhaust = Reservoir(gas)
    
equiv_ration = 0.6
    
factor = 0.1
air_mdot = factor * 9.52 * air_mw
fuel_mdot = factor * equiv_ration * fuel_mw
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)
Exemple #5
0
rho_b = gas_b.density()

# Create reservoirs for the two inlet streams and for the outlet
# stream.  The upsteam reservoirs could be replaced by reactors, which
# might themselves be connected to reactors further upstream. The
# outlet reservoir could be replaced with a reactor with no outlet, if
# it is desired to integrate the composition leaving the mixer in
# time, or by an arbitrary network of downstream reactors.
res_a = Reservoir(gas_a)
res_b = Reservoir(gas_b)
downstream = Reservoir(gas_b)

# Create a reactor for the mixer. A reactor is required instead of a
# reservoir, since the state will change with time if the inlet mass
# 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])
Exemple #6
0
    """
    return N.array(data)


gas2 = GRI30()

# Umwelt definieren
gas2.set(T=290, P=OneAtm, X="N2:1")
env = Reservoir(gas2)
# Reaktorgemisch vorlegen // 1m3
# gas2.set(T=400+273.75, P=OneAtm/1.3, X='CO:20, CO2:60, O2:4.2, N2:15.8')
# 24.334 0.7311988
# 25.215 0.5627019
gas2.set(T=25.215 + 273.15, P=56270, X="O2:21.6, N2:79.1")
# gas2.set(T=900, P=OneAtm, X='CO:20, CO2:60, N2:15.8 , O2:4.2')
r2 = Reactor(gas2, volume=0.025)

heatrate = Polynomial([-64.0e-1, 0.0, 0.0])
wall = Wall(left=r2, right=env)

# in Joule
print " Heizrate in MW ", heatrate(1) / 1000
print " Heizrate in MW/m3 ", heatrate(1) / r2.volume() / 1000
wall.set(Q=heatrate)

sim = ReactorNet([r2])
print "H20", r2.moleFraction("H2O")
print "CH4", r2.moleFraction("CH4")
print "CO2", r2.moleFraction("CO2")
print "CO", r2.moleFraction("CO")
print "O2", r2.moleFraction("O2")
Exemple #7
0
# use predefined function Air() for the air inlet
air = Air()
air_in = Reservoir(air)
air_mw = air.meanMolarMass()

# to ignite the fuel/air mixture, we'll introduce a pulse of radicals.
# The steady-state behavior is independent of how we do this, so we'll
# just use a stream of pure atomic hydrogen.
gas.set(T = 300.0, P = OneAtm, X = 'H:1.0')
igniter = Reservoir(gas)


# create the combustor, and fill it in initially with N2
gas.set(T = 300.0, P = OneAtm, X = 'N2:1.0')
combustor = Reactor(contents = gas, volume = 1.0)

# create a reservoir for the exhaust
exhaust = Reservoir(gas)

# lean combustion, phi = 0.5
equiv_ratio = 0.5

# compute fuel and air mass flow rates
factor = 0.1
air_mdot = factor*9.52*air_mw
fuel_mdot = factor*equiv_ratio*fuel_mw

# create and install the mass flow controllers. Controllers
# m1 and m2 provide constant mass flow rates, and m3 provides
# a short Gaussian pulse only to ignite the mixture
Exemple #8
0
from matplotlib.mlab import normpdf

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


gas = importPhase('h2o2.cti')
gas.set(T = 300, P=OneAtm, X='H2:10, AR:70, O2:16')

gas2 = GRI30()
gas2.set(T=300, P=OneAtm, X='N2:80, O2=20')

r1 = Reactor(gas,volume = 1 )
r2 = Reactor(gas2,volume = 0.05 )

gas.set(T = 300, P = OneAtm, X = 'H:1.0')
igniter = Reservoir(gas)

gas_sink = Reservoir(gas2)


igniter_mdot= Gaussian(t0=2.0, FWHM = 0.04, A=0.02)


m3 = MassFlowController (upstream = igniter, downstream = r1, mdot = igniter_mdot) 
v1=Valve(r1,gas_sink) 
v1.setValveCoeff(0)
Exemple #9
0
# Create reservoirs for the two inlet streams and for the outlet
# stream.  The upsteam reservoirs could be replaced by reactors, which
# might themselves be connected to reactors further upstream. The
# outlet reservoir could be replaced with a reactor with no outlet, if
# it is desired to integrate the composition leaving the mixer in
# time, or by an arbitrary network of downstream reactors.
res_a = Reservoir(gas_a)
res_b = Reservoir(gas_b)
downstream   = Reservoir(gas_b)

# Create a reactor for the mixer. A reactor is required instead of a
# reservoir, since the state will change with time if the inlet mass
# flow rates change or if there is chemistry occurring.
gas_b.set(T = 300.0, P = OneAtm, X = 'N2:0.78, AR:0.01')
mixer = Reactor(gas_b,volume = 0.125)


# 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 = 720*rho_a)

#CO_Peak = Gaussian(t0 = 1, FWHM = 0.32, A=0.05)
mfc2 = MassFlowController(upstream = res_b,
                          downstream = mixer,
                          mdot = 0)

Exemple #10
0
  Constant-pressure, adiabatic kinetics simulation with sensitivity analysis

"""
import sys

from Cantera import *
from Cantera.Reactor import *
from Cantera.Func import *

gri3 = GRI30()
temp = 1500.0
pres = OneAtm

gri3.set(T = temp, P = pres, X = 'CH4:0.1, O2:2, N2:7.52')
r   = Reactor(gri3)

air = Air()
air.set(T = temp, P = pres)
env = Reservoir(air)

# Define a wall between the reactor and the environment, and
# 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)

# enable sensitivity with respect to the rates of the first 10
# reactions (reactions 0 through 9)
r.addSensitivityReaction(reactions = range(10))
Exemple #11
0
file2 = open('results.csv', 'w')
speciesandtemp = range(num_species + 1)
speciesandtemp = ['Time (s)'] + ['Temp (K)'] + ['Pressure (Pa)'] + species
writeCSV(file2, speciesandtemp)

## Define a two-dimensional array to hold mole-fractions and temps of each species at all time steps
#Changed to + 3 to add pressure into the mix ...
num_speciesplusthree = num_species + 3  # + 1 for time and  + 1 for temp and + 1 for pressure
for i in range(Ntimesteps):
    mf_species[i] = range(0, num_speciesplusthree)

## set initial conditions!
gas.set(T=Tini, P=P1, X="%s" % (initialcomposition))

######################### SET UP THE REACTOR
r = Reactor(gas, energy="off")

gas_b = Air()
gas_b.set(P=P1)
env = Reservoir(gas_b)

# Define a wall between the reactor and the environment, and
# 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)
######################### SET UP THE REACTOR

sim = ReactorNet([r])
time = 0.0
Exemple #12
0
p0 = 101325.

tFinal = 100.0

R = 0.60 # Hydrogen-fuel ratio.
b = R/(2.0*(1.0-R))
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   
Exemple #13
0
"""

  Constant-pressure, adiabatic kinetics simulation.

"""
import sys

from Cantera import *
from Cantera.Reactor import *
from Cantera.Func import *
from Cantera import rxnpath

gri3 = GRI30()

gri3.set(T = 1001.0, P = OneAtm, X = 'H2:2,O2:1,N2:4')
r   = Reactor(gri3)

env = Reservoir(Air())

# Define a wall between the reactor and the environment, and
# 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')
Exemple #14
0
from Cantera import *
from Cantera.Reactor import *
import sys

fmt = '%10.3f  %10.1f  %10.4f  %10.4g  %10.4g  %10.4g  %10.4g'
print '%10s  %10s  %10s  %10s  %10s  %10s %10s' % ('time [s]','T1 [K]','T2 [K]',
                                              'V1 [m^3]', 'V2 [m^3]',
                                              'V1+V2 [m^3]','X(CO)')

gas1 = importPhase('h2o2.cti')
gas1.set(T = 900.0, P = OneAtm, X = 'H2:2, O2:1, AR:20')

gas2 = GRI30()
gas2.set(T = 900.0, P = OneAtm, X = 'CO:2, H2O:0.01, O2:5')

r1 = Reactor(gas1, volume = 0.5)
r2 = Reactor(gas2, volume = 0.1)
w = Wall(left = r1, right = r2, K = 1.0e3)

reactors = ReactorNet([r1, r2])

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

for n in range(30):
Exemple #15
0
  Constant-pressure, adiabatic kinetics simulation with sensitivity analysis

"""
import sys

from Cantera import *
from Cantera.Reactor import *
from Cantera.Func import *

gri3 = GRI30()
temp = 1500.0
pres = OneAtm

gri3.set(T=temp, P=pres, X='CH4:0.1, O2:2, N2:7.52')
r = Reactor(gri3)

air = Air()
air.set(T=temp, P=pres)
env = Reservoir(air)

# Define a wall between the reactor and the environment, and
# 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)

# enable sensitivity with respect to the rates of the first 10
# reactions (reactions 0 through 9)
r.addSensitivityReaction(reactions=range(10))
Exemple #16
0
# First create each gas needed, and a reactor or reservoir for each one.
# -----------------------------------------------------------------------

# create an argon gas object and set its state. This function is
# defined in module Cantera.gases, as are functions 'Air()', and
# 'GRI30()'

ar = Argon()
ar.set(T=800.0, P=0.5 * OneAtm)
""" Tiegelraum gefuellt mit Argon
    800K , 51mbar Druck
"""


# create a reactor to represent the side of the cylinder filled with argon
r1 = Reactor(ar, volume=0.150, name="Tiegelraum")

# create a reservoir for the environment, and fill it with air.
env = Reservoir(Air())


# use GRI-Mech 3.0 for the methane/air mixture, and set its initial state
h2o = importPhase("liquidvapor.cti", "water")
h2o.set(T=300.0, P=OneAtm, X="H2O:1")

# create a reactor for the methane/air side
r2 = Reactor(h2o, volume=0.50, name="Wassermenge")


# ---------------------------------------------------------------------
# Now couple the reactors by defining common walls that may move (a piston)
Exemple #17
0
@author: rened
"""
from Cantera import *
from Cantera.Reactor import *
from Cantera.Func import *

# Luftdefinition
air = Air()
air_in = Reservoir(air)
air_out = Reservoir(air)
air_mw = air.meanMolarMass()

# Der Ofen hat ein Volumen von 125 L
gas = GRI30()
gas.set(T=300.0, P = OneAtm, X ='N2:1.0,CO:0.0000001') 
ofen = Reactor(contents = gas, volume = 0.125)

# Zwei weitere Reaktor stellen das Rohr da.
rohr1 = Reactor(contents = gas, volume = 0.025)
rohr2 = Reactor(contents = gas, volume = 0.025)

# CO Quelle
gas.set(T=300.0, P = OneAtm, X ='CO:1.0') 
CO_Quelle = Reactor(contents = gas, volume = 0.025)

ZuGabe_CO = Gaussian(t0=1.0, FWHM = 0.4, A = 0.1)
m1 = MassFlowController(upstream = CO_Quelle, downstream = ofen, mdot = ZuGabe_CO)

air_mdot = 1
m2 = MassFlowController(upstream = air_in, downstream = ofen, mdot = air_mdot)
m3 = Valve(upstream = ofen,   downstream = rohr1, Kv=10.0)
Exemple #18
0

def list_to_array(data):
    """
    Wandelt die Liste in Numpyarray um und schneidet erste Datensatz ab
    """
    return N.array(data)


gas = importPhase("h2o2.cti")
gas.set(T=300, P=OneAtm, X="H2:7, AR:70, O2:8")

gas2 = GRI30()
gas2.set(T=300, P=OneAtm, X="N2:80, O2=20")

r1 = Reactor(gas, volume=1)
r2 = Reactor(gas2, volume=0.3)

gas.set(T=300, P=OneAtm, X="H:1.0")
igniter = Reservoir(gas)


igniter_mdot = Gaussian(t0=2.0, FWHM=0.05, A=0.05)
m3 = MassFlowController(upstream=igniter, downstream=r1, mdot=igniter_mdot)
wall = Wall(left=r1, right=r2, K=1.0e3)
sim = ReactorNet([r1, r2])

time_list = []
temp_list = []

time_list2 = []
Exemple #19
0
from Cantera.Reactor import *
from Cantera.Func import *

#-----------------------------------------------------------------------
# First create each gas needed, and a reactor or reservoir for each one.
#-----------------------------------------------------------------------

# create an argon gas object and set its state. This function is
# defined in module Cantera.gases, as are functions 'Air()', and
# 'GRI30()'

ar = Argon()
ar.set(T=1000.0, P=20.0 * OneAtm, X='AR:1')

# create a reactor to represent the side of the cylinder filled with argon
r1 = Reactor(ar)

# create a reservoir for the environment, and fill it with air.
env = Reservoir(Air())

# use GRI-Mech 3.0 for the methane/air mixture, and set its initial state
gri3 = GRI30()

gri3.set(T=500.0, P=0.2 * OneAtm, X='CH4:1.1, O2:2, N2:7.52')

# create a reactor for the methane/air side
r2 = Reactor(gri3)

#---------------------------------------------------------------------
# Now couple the reactors by defining common walls that may move (a piston)
# or conduct heat
Exemple #20
0
"""

  Constant-pressure, adiabatic kinetics simulation.

"""
import sys

from Cantera import *
from Cantera.Reactor import *
from Cantera.Func import *
from Cantera import rxnpath

gri3 = GRI30()

gri3.set(T=1001.0, P=OneAtm, X='H2:2,O2:1,N2:4')
r = Reactor(gri3)

env = Reservoir(Air())

# Define a wall between the reactor and the environment, and
# 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')
Exemple #21
0
from Cantera.Reactor import *
from Cantera.Func import *

#-----------------------------------------------------------------------
# First create each gas needed, and a reactor or reservoir for each one.
#-----------------------------------------------------------------------

# create an argon gas object and set its state. This function is
# defined in module Cantera.gases, as are functions 'Air()', and
# 'GRI30()'

ar = Argon()
ar.set(T = 1000.0, P = 20.0*OneAtm, X = 'AR:1')

# create a reactor to represent the side of the cylinder filled with argon
r1   = Reactor(ar)


# create a reservoir for the environment, and fill it with air.
env = Reservoir(Air())


# use GRI-Mech 3.0 for the methane/air mixture, and set its initial state
gri3 = GRI30()

gri3.set(T = 500.0, P = 0.2*OneAtm, X = 'CH4:1.1, O2:2, N2:7.52')

# create a reactor for the methane/air side
r2 = Reactor(gri3)

Exemple #22
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
# use predefined function Air() for the air inlet
air = Air()
air_in = Reservoir(air)
air_mw = air.meanMolarMass()

# to ignite the fuel/air mixture, we'll introduce a pulse of radicals.
# The steady-state behavior is independent of how we do this, so we'll
# just use a stream of pure atomic hydrogen.
gas.set(T = 300.0, P = OneAtm, X = 'H:1.0')
igniter = Reservoir(gas)


# create the combustor, and fill it in initially with N2
gas.set(T = 300.0, P = OneAtm, X = 'N2:1.0')
combustor = Reactor(contents = gas, volume = 1.0)

# create a reservoir for the exhaust
exhaust = Reservoir(gas)

# lean combustion, phi = 0.5
equiv_ratio = 0.5

# compute fuel and air mass flow rates
factor = 0.1
air_mdot = factor*9.52*air_mw
fuel_mdot = factor*equiv_ratio*fuel_mw

# create and install the mass flow controllers. Controllers
# m1 and m2 provide constant mass flow rates, and m3 provides
# a short Gaussian pulse only to ignite the mixture
Exemple #24
0
from Cantera import *
from Cantera.Reactor import *
import sys

fmt = '%10.3f  %10.1f  %10.4f  %10.4g  %10.4g  %10.4g  %10.4g'
print '%10s  %10s  %10s  %10s  %10s  %10s %10s' % ('time [s]','T1 [K]','T2 [K]',
                                              'V1 [m^3]', 'V2 [m^3]',
                                              'V1+V2 [m^3]','X(CO)')

gas1 = importPhase('h2o2.cti')
gas1.set(T = 900.0, P = OneAtm, X = 'H2:2, O2:1, AR:20')

gas2 = GRI30()
gas2.set(T = 900.0, P = OneAtm, X = 'CO:2, H2O:0.01, O2:5')

r1 = Reactor(gas1, volume = 0.5)
r2 = Reactor(gas2, volume = 0.1)
w = Wall(left = r1, right = r2, K = 1.0e3)

reactors = ReactorNet([r1, r2])

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

for n in range(30):
Exemple #25
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
Exemple #26
0
mass_flow_rate = velocity * rho0 * area

# The plug flow reactor is represented by a linear chain of
# zero-dimensional reactors. The gas at the inlet to the first one has
# the specified inlet composition, and for all others the inlet
# composition is fixed at the composition of the reactor immediately
# upstream. Since in a PFR model there is no diffusion, the upstream
# reactors are not affected by any downstream reactors, and therefore
# the problem may be solved by simply marching from the first to last
# reactor, integrating each one to steady state.

for n in range(NReactors):
    
        # create a new reactor 
        r = Reactor(contents = gas, energy = 'off', volume = rvol)

        # create a reservoir to represent the reactor immediately
        # upstream. Note that the gas object is set already to the
        # state of the upstream reactor
        upstream = Reservoir(gas, name = 'upstream')

        # create a reservoir for the reactor to exhaust into. The
        # composition of this reservoir is irrelevant.
        downstream = Reservoir(gas, name = 'downstream')

        # use a 'Wall' object to implement the reacting surface in the
        # reactor.  Since walls have to be installed between two
        # reactors/reserviors, we'll install it between the upstream
        # reservoir and the reactor.  The area is set to the desired
        # catalyst area in the reactor, and surface reactions are
Exemple #27
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
Exemple #28
0
mass_flow_rate = velocity * rho0 * area

# The plug flow reactor is represented by a linear chain of
# zero-dimensional reactors. The gas at the inlet to the first one has
# the specified inlet composition, and for all others the inlet
# composition is fixed at the composition of the reactor immediately
# upstream. Since in a PFR model there is no diffusion, the upstream
# reactors are not affected by any downstream reactors, and therefore
# the problem may be solved by simply marching from the first to last
# reactor, integrating each one to steady state.

for n in range(NReactors):

    # create a new reactor
    r = Reactor(contents=gas, energy='off', volume=rvol)

    # create a reservoir to represent the reactor immediately
    # upstream. Note that the gas object is set already to the
    # state of the upstream reactor
    upstream = Reservoir(gas, name='upstream')

    # create a reservoir for the reactor to exhaust into. The
    # composition of this reservoir is irrelevant.
    downstream = Reservoir(gas, name='downstream')

    # use a 'Wall' object to implement the reacting surface in the
    # reactor.  Since walls have to be installed between two
    # reactors/reserviors, we'll install it between the upstream
    # reservoir and the reactor.  The area is set to the desired
    # catalyst area in the reactor, and surface reactions are
Exemple #29
0
# Create reservoirs for the two inlet streams and for the outlet
# stream.  The upsteam reservoirs could be replaced by reactors, which
# might themselves be connected to reactors further upstream. The
# outlet reservoir could be replaced with a reactor with no outlet, if
# it is desired to integrate the composition leaving the mixer in
# time, or by an arbitrary network of downstream reactors.
res_a = Reservoir(gas_a)
res_b = Reservoir(gas_b)
downstream   = Reservoir(gas_b)


# Create a reactor for the mixer. A reactor is required instead of a
# reservoir, since the state will change with time if the inlet mass
# 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)


# add an igniter to ignite the mixture. The 'igniter' consists of a
Exemple #30
0
# Create reservoirs for the two inlet streams and for the outlet
# stream.  The upsteam reservoirs could be replaced by reactors, which
# might themselves be connected to reactors further upstream. The
# outlet reservoir could be replaced with a reactor with no outlet, if
# it is desired to integrate the composition leaving the mixer in
# time, or by an arbitrary network of downstream reactors.
res_a = Reservoir(gas_a)
res_b = Reservoir(gas_b)
downstream   = Reservoir(gas_b)


# Create a reactor for the mixer. A reactor is required instead of a
# reservoir, since the state will change with time if the inlet mass
# 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)


# add an igniter to ignite the mixture. The 'igniter' consists of a
Exemple #31
0
def list_to_array(data):
    '''
    Wandelt die Liste in Numpyarray um und schneidet erste Datensatz ab
    '''
    return N.array(data)

# Luftdefinition
air = Air()
air_in = Reservoir(air)
air_out = Reservoir(air)
air_mw = air.meanMolarMass()

# Der Ofen hat ein Volumen von 125 L
gas = GRI30()
gas.set(T=300.0, P = OneAtm, X ='N2:1.0,CO:0.0000001') 
ofen = Reactor(contents = gas, volume = 0.125)

# Zwei weitere Reaktor stellen das Rohr da.
rohr1 = Reactor(contents = gas, volume = 0.025)
rohr2 = Reactor(contents = gas, volume = 0.025)

# CO Quelle
gas.set(T=300.0, P = OneAtm, X ='CO:1.0') 
CO_Quelle = Reactor(contents = gas, volume = 0.025)

ZuGabe_CO = Gaussian(t0=1.0, FWHM = 0.3, A = 0.1)
m1 = MassFlowController(upstream = CO_Quelle, downstream = ofen, mdot = ZuGabe_CO)

air_mdot = 2
m2 = MassFlowController(upstream = air_in, downstream = ofen, mdot = air_mdot)
m3 = Valve(upstream = ofen,   downstream = rohr1, Kv=10.0)