Skip to content

Commit

Permalink
[Cython/Examples] Fix extract_submechanism example
Browse files Browse the repository at this point in the history
When loading reactions from a YAML file, an instance of a Kinetics
object is required so that the species associated with the reactions are
available. The required object is now constructed from the already
loaded species definitions.

Fixes #821, problem introduced in 1866e35
  • Loading branch information
bryanwweber authored and speth committed Aug 21, 2020
1 parent a9a3a4a commit dc15136
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import cantera as ct
import matplotlib.pyplot as plt

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

# Filter species
Expand All @@ -36,7 +37,8 @@
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.yaml')
ref_phase = ct.Solution(thermo='ideal-gas', kinetics='gas', species=all_species)
all_reactions = ct.Reaction.listFromFile(input_file, ref_phase)
reactions = []

print('\nReactions:')
Expand All @@ -51,8 +53,8 @@
print(R.equation)
print('\n')

gas1 = ct.Solution('gri30.yaml')
gas2 = ct.Solution(thermo='IdealGas', kinetics='GasKinetics',
gas1 = ct.Solution(input_file)
gas2 = ct.Solution(thermo='ideal-gas', kinetics='gas',
species=species, reactions=reactions)


Expand Down

0 comments on commit dc15136

Please sign in to comment.