Skip to content

Commit

Permalink
[Cython/Examples] Fix extract_submechanism example
Browse files Browse the repository at this point in the history
The Reaction.listFromFile() method requires a Kinetics instance when
reading a YAML file. In this case, the appropriate Kinetics instance
could be created by Solution('gri30.yaml'). Since we'd have to create
that object anyways to be able to use Reaction.listFromFile(), we might
as well use the Solution.reactions() method, which returns the same
list as Reaction.listFromFile() for this case where the species
definitions are in the same file as the reaction definitions.

Fixes Cantera#821, problem introduced in 1866e35
  • Loading branch information
bryanwweber committed Jul 27, 2020
1 parent ba13c65 commit 0488907
Showing 1 changed file with 4 additions and 3 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,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.yaml')
all_reactions = ct.Solution(input_file).reactions()
reactions = []

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

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

Expand Down

0 comments on commit 0488907

Please sign in to comment.