[Python] Add example demonstrating use of class Quantity

This commit is contained in:
Ray Speth 2015-08-05 17:14:08 -04:00
parent 032537710f
commit 8299646059
2 changed files with 38 additions and 0 deletions

View file

@ -11,6 +11,9 @@ mechanism, species are matched by name. If the upstream reactor contains a
species that is not present in the downstream reaction mechanism, it will be
ignored. In general, reaction mechanisms for downstream reactors should
contain all species that might be present in any upstream reactor.
Compare this approach for the transient problem to the method used for the
steady-state problem in thermo/mixing.py.
"""
import cantera as ct

View file

@ -0,0 +1,35 @@
"""
Mixing two streams using `Quantity` objects.
In this example, air and methane are mixed in stoichiometric proportions. This
is a simpler, steady-state version of the example ``reactors/mix1.py``.
Since the goal is to simulate a continuous flow system, the mixing takes place
at constant enthalpy and pressure.
"""
import cantera as ct
gas = ct.Solution('gri30.xml')
# Stream A (air)
A = ct.Quantity(gas, constant='HP')
A.TPX = 300.0, ct.one_atm, 'O2:0.21, N2:0.78, AR:0.01'
# Stream B (methane)
B = ct.Quantity(gas, constant='HP')
B.TPX = 300.0, ct.one_atm, 'CH4:1'
# Set the molar flow rates corresponding to stoichiometric reaction,
# CH4 + 2 O2 -> CO2 + 2 H2O
A.moles = 1
nO2 = A.X[A.species_index('O2')]
B.moles = nO2 * 0.5
# Compute the mixed state
M = A + B
print(M.report())
# Show that this state corresponds to stoichiometric combustion
M.equilibrate('TP')
print(M.report())