Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml2ck: Check if third body is in species list #1696

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions interfaces/cython/cantera/yaml2ck.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def build_thermodynamics_text(
)


def build_reactions_text(reactions: Iterable[ct.Reaction]):
def build_reactions_text(reactions: Iterable[ct.Reaction], species: Iterable[ct.Species]):
"""
Create the reaction definition section of this file.

Expand All @@ -346,6 +346,8 @@ def build_reactions_text(reactions: Iterable[ct.Reaction]):
.. versionadded:: 3.0
"""

species_names = [spec.name for spec in species]

# Note: Cantera converts explicit reverse rate coefficients given by the ``REV``
# keyword into two independent irreversible reactions. Therefore, there's no need to
# handle the ``REV`` keyword in this function.
Expand Down Expand Up @@ -478,6 +480,7 @@ def build_reactions_text(reactions: Iterable[ct.Reaction]):
" ".join(
f"{spec}/{value:.3E}/"
for spec, value in reac.third_body.efficiencies.items()
if spec in species_names
)
)

Expand Down Expand Up @@ -701,7 +704,7 @@ def convert(

# TODO: Handle phases without reactions
all_reactions = solution.reactions()
mechanism_text.append(build_reactions_text(all_reactions))
mechanism_text.append(build_reactions_text(all_reactions, all_species))

if transport_path is None and transport_exists:
mechanism_text.append(build_transport_text(all_species, separate_file=False))
Expand Down
Loading