Skip to content

Commit

Permalink
[YAML] Switch interfaces and examples to use YAML files
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanwweber authored and speth committed Jan 7, 2020
1 parent 54bb4c3 commit 1866e35
Show file tree
Hide file tree
Showing 75 changed files with 229 additions and 292 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import numpy as np
import matplotlib.pyplot as plt

all_species = ct.Species.listFromFile('gri30.xml')
all_species = ct.Species.listFromFile('gri30.yaml')
species = []

# Filter species
Expand All @@ -35,7 +35,7 @@
print('Species: {0}'.format(', '.join(S.name for S in species)))

# Filter reactions, keeping only those that only involve the selected species
all_reactions = ct.Reaction.listFromFile('gri30.xml')
all_reactions = ct.Reaction.listFromFile('gri30.yaml')
reactions = []

print('\nReactions:')
Expand All @@ -50,7 +50,7 @@
print(R.equation)
print('\n')

gas1 = ct.Solution('gri30.xml')
gas1 = ct.Solution('gri30.yaml')
gas2 = ct.Solution(thermo='IdealGas', kinetics='GasKinetics',
species=species, reactions=reactions)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import numpy as np
import matplotlib.pyplot as plt

gas = ct.Solution('gri30.xml')
gas = ct.Solution('gri30.yaml')
initial_state = 1200, 5 * ct.one_atm, 'CH4:0.35, O2:1.0, N2:3.76'

# Run a simulation with the full mechanism
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# these lines can be replaced by any commands that generate
# an object of a class derived from class Kinetics in some state.
gas = ct.Solution('gri30.xml')
gas = ct.Solution('gri30.yaml')
gas.TPX = 1300.0, ct.one_atm, 'CH4:0.4, O2:1, N2:3.76'
r = ct.IdealGasReactor(gas)
net = ct.ReactorNet([r])
Expand Down
4 changes: 2 additions & 2 deletions interfaces/cython/cantera/examples/multiphase/adiabatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
P = 101325.0

# phases
gas = ct.Solution('gri30.xml')
carbon = ct.Solution('graphite.xml')
gas = ct.Solution('gri30.yaml')
carbon = ct.Solution('graphite.yaml')

# the phases that will be included in the calculation, and their initial moles
mix_phases = [(gas, 1.0), (carbon, 0.0)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

# create objects representing the gas phase and the condensed phases. The gas
# is a mixture of multiple species, and the condensed phases are all modeled
# as incompressible stoichiometric substances. See file KOH.cti for more
# as incompressible stoichiometric substances. See file KOH.yaml for more
# information.
phases = ct.import_phases('KOH.cti', ['K_solid', 'K_liquid', 'KOH_a', 'KOH_b',
phases = ct.import_phases('KOH.yaml', ['K_solid', 'K_liquid', 'KOH_a', 'KOH_b',
'KOH_liquid', 'K2O2_solid', 'K2O_solid',
'KO2_solid', 'ice', 'liquid_water',
'KOH_plasma'])
Expand Down
4 changes: 2 additions & 2 deletions interfaces/cython/cantera/examples/onedim/adiabatic_flame.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
width = 0.03 # m
loglevel = 1 # amount of diagnostic output (0 to 8)

# IdealGasMix object used to compute mixture properties, set to the state of the
# Solution object used to compute mixture properties, set to the state of the
# upstream fuel-air mixture
gas = ct.Solution('h2o2.xml')
gas = ct.Solution('h2o2.yaml')
gas.TPX = Tin, p, reactants

# Set up flame object
Expand Down
2 changes: 1 addition & 1 deletion interfaces/cython/cantera/examples/onedim/burner_flame.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
width = 0.5 # m
loglevel = 1 # amount of diagnostic output (0 to 5)

gas = ct.Solution('h2o2.xml')
gas = ct.Solution('h2o2.yaml')
gas.TPX = tburner, p, reactants

f = ct.BurnerFlame(gas, width=width)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
width = 0.5 # m
loglevel = 1 # amount of diagnostic output (0 to 5)

gas = ct.Solution('gri30_ion.cti')
gas = ct.Solution('gri30_ion.yaml')
gas.TPX = tburner, p, reactants
mdot = 0.15 * gas.density

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# Create the gas object used to evaluate all thermodynamic, kinetic, and
# transport properties.
gas = ct.Solution('gri30.xml', 'gri30_mix')
gas = ct.Solution('gri30.yaml')
gas.TP = gas.T, p

# Create an object representing the counterflow flame configuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FlameExtinguished(Exception):
# Set up an initial hydrogen-oxygen counterflow flame at 1 bar and low strain
# rate (maximum axial velocity gradient = 2414 1/s)

reaction_mechanism = 'h2o2.xml'
reaction_mechanism = 'h2o2.yaml'
gas = ct.Solution(reaction_mechanism)
width = 18e-3 # 18mm wide
f = ct.CounterflowDiffusionFlame(gas, width=width)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Set up an initial hydrogen-oxygen counterflow flame at 1 bar and low strain
# rate (maximum axial velocity gradient = 2414 1/s)

reaction_mechanism = 'h2o2.xml'
reaction_mechanism = 'h2o2.yaml'
gas = ct.Solution(reaction_mechanism)
width = 18.e-3 # 18mm wide
f = ct.CounterflowDiffusionFlame(gas, width=width)
Expand Down
2 changes: 1 addition & 1 deletion interfaces/cython/cantera/examples/onedim/flame_fixed_T.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# transport properties. It is created with two transport managers, to enable
# switching from mixture-averaged to multicomponent transport on the last
# solution.
gas = ct.Solution('gri30.xml', 'gri30_mix')
gas = ct.Solution('gri30.yaml')

# set its state to that of the unburned gas at the burner
gas.TPX = tburner, p, comp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

width = 0.03 # m

# IdealGasMix object used to compute mixture properties
gas = ct.Solution('gri30.xml', 'gri30_mix')
# Solution object used to compute mixture properties
gas = ct.Solution('gri30.yaml')
gas.TPX = Tin, p, reactants

# Flame object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
width = 0.5 # m
loglevel = 1 # amount of diagnostic output (0 to 5)

gas = ct.Solution('gri30_ion.cti')
gas = ct.Solution('gri30_ion.yaml')
gas.TPX = tburner, p, reactants
mdot = 0.15 * gas.density

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# IdealGasMix object used to compute mixture properties, set to the state of the
# upstream fuel-air mixture
gas = ct.Solution('gri30_ion.xml')
gas = ct.Solution('gri30_ion.yaml')
gas.TPX = Tin, p, reactants

# Set up flame object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
T_in = 373.0 # inlet temperature
mdot_reactants = 0.12 # kg/m^2/s
mdot_products = 0.06 # kg/m^2/s
rxnmech = 'h2o2.cti' # reaction mechanism file
rxnmech = 'h2o2.yaml' # reaction mechanism file
comp = 'H2:1.6, O2:1, AR:7' # premixed gas composition

width = 0.2 # m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def solveOpposedFlame(oppFlame, massFlux=0.12, loglevel=1,
return np.max(oppFlame.T), K, strainRatePoint

# Select the reaction mechanism
gas = ct.Solution('gri30.cti')
gas = ct.Solution('gri30.yaml')

# Create a CH4/Air premixed mixture with equivalence ratio=0.75, and at room
# temperature and pressure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# then that solution will be used for the next mdot
mdot = [0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12] # kg/m^2/s

rxnmech = 'h2o2.cti' # reaction mechanism file
rxnmech = 'h2o2.yaml' # reaction mechanism file
comp = 'H2:1.8, O2:1, AR:7' # premixed gas composition

# The solution domain is chosen to be 20 cm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def ignitionDelay(states, species):
# Real gas IDT calculation

# Load the real gas mechanism:
real_gas = ct.Solution('nDodecane_Reitz.cti','nDodecane_RK')
real_gas = ct.Solution('nDodecane_Reitz.yaml', 'nDodecane_RK')

# Set the state of the gas object:
real_gas.TP = reactorTemperature, reactorPressure
Expand Down Expand Up @@ -109,7 +109,7 @@ def ignitionDelay(states, species):

# Ideal gas IDT calculation
# Create the ideal gas object:
ideal_gas = ct.Solution('nDodecane_Reitz.cti','nDodecane_IG')
ideal_gas = ct.Solution('nDodecane_Reitz.yaml', 'nDodecane_IG')

# Set the state of the gas object:
ideal_gas.TP = reactorTemperature, reactorPressure
Expand Down
5 changes: 3 additions & 2 deletions interfaces/cython/cantera/examples/reactors/combustor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
import matplotlib.pyplot as plt
import cantera as ct

# Use reaction mechanism GRI-Mech 3.0
gas = ct.Solution('gri30.xml')
# Use reaction mechanism GRI-Mech 3.0. For 0-D simulations,
# no transport model is necessary.
gas = ct.Solution('gri30.yaml')

# Create a Reservoir for the inlet, set to a methane/air mixture at a specified
# equivalence ratio
Expand Down
2 changes: 1 addition & 1 deletion interfaces/cython/cantera/examples/reactors/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __call__(self, t, y):
return np.hstack((dTdt, dYdt))


gas = ct.Solution('gri30.xml')
gas = ct.Solution('gri30.yaml')

# Initial condition
P = ct.one_atm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import cantera as ct

# Use a reduced n-dodecane mechanism with PAH formation pathways
gas = ct.Solution('nDodecane_Reitz.cti', 'nDodecane_IG')
gas = ct.Solution('nDodecane_Reitz.yaml', 'nDodecane_IG')

# Create a Reservoir for the fuel inlet, set to pure dodecane
gas.TPX = 300, 20*ct.one_atm, 'c12h26:1.0'
Expand Down
2 changes: 1 addition & 1 deletion interfaces/cython/cantera/examples/reactors/ic_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#########################################################################

# reaction mechanism, kinetics type and compositions
reaction_mechanism = 'nDodecane_Reitz.xml'
reaction_mechanism = 'nDodecane_Reitz.yaml'
phase_name = 'nDodecane_IG'
comp_air = 'o2:1, n2:3.76'
comp_fuel = 'c12h26:1'
Expand Down
4 changes: 2 additions & 2 deletions interfaces/cython/cantera/examples/reactors/mix1.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
import cantera as ct

# Use air for stream a.
gas_a = ct.Solution('air.xml')
gas_a = ct.Solution('air.yaml')
gas_a.TPX = 300.0, ct.one_atm, 'O2:0.21, N2:0.78, AR:0.01'
rho_a = gas_a.density


# Use GRI-Mech 3.0 for stream b (methane) and for the mixer. If it is desired
# to have a pure mixer, with no chemistry, use instead a reaction mechanism
# for gas_b that has no reactions.
gas_b = ct.Solution('gri30.xml')
gas_b = ct.Solution('gri30.yaml')
gas_b.TPX = 300.0, ct.one_atm, 'CH4:1'
rho_b = gas_b.density

Expand Down
4 changes: 2 additions & 2 deletions interfaces/cython/cantera/examples/reactors/periodic_cstr.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
as soon as a significant amount of water is produced the reaction stops. After
enough time has passed that the water is exhausted from the reactor, the mixture
explodes again and the process repeats. This explanation can be verified by
decreasing the rate for reaction 7 in file 'h2o2.cti' and re-running the
decreasing the rate for reaction 7 in file h2o2.yaml and re-running the
example.
Acknowledgments: The idea for this example and an estimate of the conditions
Expand All @@ -22,7 +22,7 @@
import numpy as np

# create the gas mixture
gas = ct.Solution('h2o2.cti')
gas = ct.Solution('h2o2.yaml')

# pressure = 60 Torr, T = 770 K
p = 60.0*133.3
Expand Down
2 changes: 1 addition & 1 deletion interfaces/cython/cantera/examples/reactors/pfr.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
area = 1.e-4 # cross-sectional area [m**2]

# input file containing the reaction mechanism
reaction_mechanism = 'h2o2.xml'
reaction_mechanism = 'h2o2.yaml'

# Resolution: The PFR will be simulated by 'n_steps' time steps or by a chain
# of 'n_steps' stirred reactors.
Expand Down
4 changes: 2 additions & 2 deletions interfaces/cython/cantera/examples/reactors/piston.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
'V1 [m^3]', 'V2 [m^3]',
'V1+V2 [m^3]','X(CO)'))

gas1 = ct.Solution('h2o2.cti')
gas1 = ct.Solution('h2o2.yaml')
gas1.TPX = 900.0, ct.one_atm, 'H2:2, O2:1, AR:20'

gas2 = ct.Solution('gri30.xml')
gas2 = ct.Solution('gri30.yaml')
gas2.TPX = 900.0, ct.one_atm, 'CO:2, H2O:0.01, O2:5'

r1 = ct.IdealGasReactor(gas1)
Expand Down
2 changes: 1 addition & 1 deletion interfaces/cython/cantera/examples/reactors/reactor1.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import cantera as ct

gas = ct.Solution('gri30.xml')
gas = ct.Solution('gri30.yaml')
gas.TPX = 1001.0, ct.one_atm, 'H2:2,O2:1,N2:4'
r = ct.IdealGasConstPressureReactor(gas)

Expand Down
6 changes: 3 additions & 3 deletions interfaces/cython/cantera/examples/reactors/reactor2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
#-----------------------------------------------------------------------

# create an argon gas object and set its state
ar = ct.Solution('argon.xml')
ar = ct.Solution('argon.yaml')
ar.TP = 1000.0, 20.0 * ct.one_atm

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

# create a reservoir for the environment, and fill it with air.
env = ct.Reservoir(ct.Solution('air.xml'))
env = ct.Reservoir(ct.Solution('air.yaml'))

# use GRI-Mech 3.0 for the methane/air mixture, and set its initial state
gas = ct.Solution('gri30.xml')
gas = ct.Solution('gri30.yaml')
gas.TP = 500.0, 0.2 * ct.one_atm
gas.set_equivalence_ratio(1.1, 'CH4:1.0', 'O2:2, N2:7.52')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import cantera as ct

gas = ct.Solution('gri30.xml')
gas = ct.Solution('gri30.yaml')
temp = 1500.0
pres = ct.one_atm

Expand Down
6 changes: 3 additions & 3 deletions interfaces/cython/cantera/examples/reactors/surf_pfr.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
porosity = 0.3 # Catalyst bed porosity

# input file containing the surface reaction mechanism
cti_file = 'methane_pox_on_pt.cti'
yaml_file = 'methane_pox_on_pt.yaml'

output_filename = 'surf_pfr_output.csv'

Expand All @@ -37,11 +37,11 @@
t = tc + 273.15 # convert to Kelvin

# import the gas model and set the initial conditions
gas = ct.Solution(cti_file, 'gas')
gas = ct.Solution(yaml_file, 'gas')
gas.TPX = t, ct.one_atm, 'CH4:1, O2:1.5, AR:0.1'

# import the surface model
surf = ct.Interface(cti_file,'Pt_surf', [gas])
surf = ct.Interface(yaml_file, 'Pt_surf', [gas])
surf.TP = t, ct.one_atm

rlen = length/(NReactors-1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@
#
# This object will be used to evaluate all thermodynamic, kinetic, and
# transport properties. The gas phase will be taken from the definition of
# phase 'gas' in input file 'ptcombust.cti,' which is a stripped-down version
# phase 'gas' in input file 'ptcombust.yaml,' which is a stripped-down version
# of GRI-Mech 3.0.
gas = ct.Solution('ptcombust.cti', 'gas')
gas = ct.Solution('ptcombust.yaml', 'gas', transport_model=transport)
gas.TPX = tinlet, p, comp1

################ create the interface object ##################
#
# This object will be used to evaluate all surface chemical production rates.
# It will be created from the interface definition 'Pt_surf' in input file
# 'ptcombust.cti,' which implements the reaction mechanism of Deutschmann et
# 'ptcombust.yaml,' which implements the reaction mechanism of Deutschmann et
# al., 1995 for catalytic combustion on platinum.
#
surf_phase = ct.Interface('ptcombust.cti', 'Pt_surf', [gas])
surf_phase = ct.Interface('ptcombust.yaml', 'Pt_surf', [gas])
surf_phase.TP = tsurf, p

# integrate the coverage equations in time for 1 s, holding the gas
Expand Down
Loading

0 comments on commit 1866e35

Please sign in to comment.