mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
yaml2ck: Check if third body is in species list
Does not write the third body efficiencies for species that are not in the solution's species list Fixed #1683
This commit is contained in:
parent
06b3500a31
commit
f8fdb8e508
@ -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.
|
Create the reaction definition section of this file.
|
||||||
|
|
||||||
@ -346,6 +346,8 @@ def build_reactions_text(reactions: Iterable[ct.Reaction]):
|
|||||||
.. versionadded:: 3.0
|
.. versionadded:: 3.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
species_names = [spec.name for spec in species]
|
||||||
|
|
||||||
# Note: Cantera converts explicit reverse rate coefficients given by the ``REV``
|
# Note: Cantera converts explicit reverse rate coefficients given by the ``REV``
|
||||||
# keyword into two independent irreversible reactions. Therefore, there's no need to
|
# keyword into two independent irreversible reactions. Therefore, there's no need to
|
||||||
# handle the ``REV`` keyword in this function.
|
# handle the ``REV`` keyword in this function.
|
||||||
@ -478,6 +480,7 @@ def build_reactions_text(reactions: Iterable[ct.Reaction]):
|
|||||||
" ".join(
|
" ".join(
|
||||||
f"{spec}/{value:.3E}/"
|
f"{spec}/{value:.3E}/"
|
||||||
for spec, value in reac.third_body.efficiencies.items()
|
for spec, value in reac.third_body.efficiencies.items()
|
||||||
|
if spec in species_names
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -701,7 +704,7 @@ def convert(
|
|||||||
|
|
||||||
# TODO: Handle phases without reactions
|
# TODO: Handle phases without reactions
|
||||||
all_reactions = solution.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:
|
if transport_path is None and transport_exists:
|
||||||
mechanism_text.append(build_transport_text(all_species, separate_file=False))
|
mechanism_text.append(build_transport_text(all_species, separate_file=False))
|
||||||
|
Loading…
Reference in New Issue
Block a user