Example #1
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()
Example #2
0
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()
Example #3
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()