Skip to content

Commit

Permalink
[unittests] Add test for mechanism reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Aug 12, 2023
1 parent a923f84 commit 82d1487
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion test/python/test_kinetics.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def test_coverage_dependence_flags(self):
surf.net_rates_of_progress_ddCi

def test_electrochemistry_flags(self):
# Phases
# Phases
mech = "lithium_ion_battery.yaml"
anode, cathode, metal, electrolyte = ct.import_phases(
mech, ["anode", "cathode", "electron", "electrolyte"])
Expand All @@ -315,6 +315,29 @@ def test_electrochemistry_flags(self):
anode_int.derivative_settings = {"skip-electrochemistry": True}
anode_int.net_rates_of_progress_ddCi

def test_submechanism(self):
# Simplified samples/python/kinetics/extract_submechanism.py
gri30 = ct.Solution('gri30.yaml')
h2o2 = ct.Solution('h2o2.yaml')

reactions = []
dest_species = set(h2o2.species_names)
colliders = dest_species.union([None, "M"])
for R in gri30.reactions():
if all(S in dest_species for S in (R.reactants | R.products).keys()):
if R.third_body_collider in colliders:
reactions.append(R)

gas = ct.Solution(thermo='ideal-gas', kinetics='gas', species=h2o2.species(),
reactions=reactions)
assert gas.n_reactions == len(reactions)
assert gas.n_species == len(h2o2.species_names)

gas.write_yaml("reduced.yaml")
restored = ct.Solution("reduced.yaml")
assert gas.species_names == restored.species_names
assert gas.reaction_equations() == restored.reaction_equations()


class KineticsRepeatability(utilities.CanteraTest):
"""
Expand Down

0 comments on commit 82d1487

Please sign in to comment.