Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
c32eede
Minor: Fix a Cython declaration in a Reaction method.
rwest Aug 2, 2024
d30d0c1
Save cantera files that were made from chemkin files to a separate fo…
rwest Jun 6, 2024
194d8d8
Rename yml to yaml_rms, because it was specific to RMS
Nora-Khalil Jun 15, 2022
20f9dfa
Enable Cantera-YAML writing.
Nora-Khalil Jun 13, 2022
34d9db8
Reworking the Elements blocks in cantera yaml writer.
rwest Aug 2, 2024
4a3f950
add yaml writer test to compare yaml file generated by RMG and the ya…
Mar 3, 2025
817d10d
Simplify species_to_dict for writing cantera yaml.
rwest Mar 21, 2024
ffe2683
Rename generate_cantera_files to generate_cantera_files_from_chemkin
rwest Feb 5, 2026
7685402
Add (or restore?) a TestCanteraOutputConversion test
rwest Feb 12, 2026
40387d9
Functional test comparing Cantera YAML outputs to Chemkin-converted YAML
rwest Feb 6, 2026
71156d4
YAML: Reaction comparison can do irreversible reactions
rwest Feb 6, 2026
4bf8118
Enhance reaction comparison by adding checks for reaction counts and …
rwest Feb 6, 2026
7f3aed3
Simplify CompareYaml and YamlAnalyst arguments
rwest Feb 6, 2026
bd75ba2
Move test_make_cantera_input_file into ..._from_ck and make a ..._dir…
rwest Feb 12, 2026
2b477ba
Tweak test_yaml
rwest Feb 6, 2026
7f71a8b
Update test_yaml.py to use new YAML test files for comparison
rwest Feb 6, 2026
8deae96
A stub cantera_yamlTest.py file for testing the cantera yaml features.
rwest Feb 7, 2026
30e6208
Work on the yaml_canteraTest.
rwest Feb 7, 2026
427fc84
Work on yaml_canteraTest.py. Check phases.
rwest Feb 8, 2026
707c14a
TEMP? mainTest functional test now copies the yaml files into the tes…
rwest Feb 8, 2026
468d466
[yaml_cantera] Make phase names mach ck2yaml version.
rwest Feb 8, 2026
eead630
[yaml_cantera] Fix where transport data comments are put
rwest Feb 8, 2026
32bf725
[yaml_canteraTest] More testing of phase definitions.
rwest Feb 8, 2026
0ceb3bc
[yaml_canteraTest] Test the Elements block
rwest Feb 8, 2026
f911429
[yaml_cantera] Outputs more condensed, with flow_style for some lists.
rwest Feb 8, 2026
f3ed3a6
Update the cantera yaml test data files.
rwest Feb 8, 2026
7a9941a
[yaml_cantera] Add test for species definition matching.
rwest Feb 10, 2026
025f9c7
[yaml_canteraTest] fix species test for NASA polynomial collapse.
rwest Feb 10, 2026
2cbca51
Converted cantera SI units to the units specified in write_cantera
LekiaAnonim Feb 11, 2026
d073a82
yaml comparer: Added a normalization method for equation with third-b…
LekiaAnonim Feb 11, 2026
90bb0af
yaml comparer: use cantera to compare rate
LekiaAnonim Feb 11, 2026
05391a8
Fix YAML serialization of Cantera objects by converting AnyMap to dict
rwest Feb 12, 2026
df01268
TEMP? Newly created yaml files for testing.
rwest Feb 12, 2026
977a183
Enhance compare_yaml_outputs
rwest Feb 13, 2026
0c1defa
yaml_canteraTest compares yaml files made in mainTest
rwest Feb 13, 2026
b9c6613
Making a new tool compare_cantera_yaml
rwest Feb 15, 2026
f04fd0f
Refactor Cantera YAML comparison tool with enhanced features
rwest Feb 16, 2026
54a9d75
The compare_cantera_yaml script now uses logging.
rwest Feb 16, 2026
145df22
At end of model generation, compare direct yaml and ck2yaml outputs.
rwest Feb 16, 2026
0619b4b
Added a Cantera writer module
alongd Dec 13, 2025
c8e241b
Move Alon's cantera writer to yaml_cantera2
rwest Feb 16, 2026
c2478be
Rename Alon's CanteraWriter class to CanteraWriter2
rwest Feb 16, 2026
b095139
Tests: Cantera writer
alongd Dec 13, 2025
61c4e5c
Rename (file and contents) Alon's yaml_cantera2Test
rwest Feb 16, 2026
1a97307
Add surface chemistry support to Cantera YAML export
alongd Jan 10, 2026
b9a855a
Updates output subdirectory name to 'cantera2'
rwest Feb 16, 2026
2669594
[yaml_cantera] makes a copy of the latest chem.yaml each iteration
rwest Feb 16, 2026
cacf459
Attach the CanteraWriter2
rwest Feb 16, 2026
7cb1611
compare_cantera_yaml copes with different reaction block specification
rwest Feb 16, 2026
0ab78a3
Correct units for transport properties in CanteraWriter2
rwest Feb 16, 2026
f5b3cff
Fix transport properties in CanteraWriter2
rwest Feb 16, 2026
fedf138
[CanteraWriter2] Write transport and thermo notes where they belong.
rwest Feb 16, 2026
25c6279
[CanteraWriter2] fix conversion of dipole monte into Debye
rwest Feb 16, 2026
8d305a6
Fix attempt for 'E' in atom dictionary
alongd Feb 19, 2026
2c0d9fd
Revert "Fix attempt for 'E' in atom dictionary"
rwest Feb 20, 2026
7c28a1e
[yaml_cantera2] Fixing 'E' electron count for charged species.
rwest Feb 20, 2026
55a264c
Rename 'yaml_cantera' to 'yaml_cantera1'.
rwest Feb 20, 2026
9b44057
[RMG/main] get_git_commit now returns strings not bytes
rwest Feb 20, 2026
32a39b8
[yaml_cantera2] Detailed logging of the yaml generator
rwest Feb 20, 2026
0b0e316
[yaml_cantera1] Detailed logging of the yaml generator
rwest Feb 20, 2026
5cda1d1
Revert "Converted cantera SI units to the units specified in write_ca…
rwest Feb 21, 2026
eeb232c
[yaml_cantera1] Report things in cantera default internal units.
rwest Feb 21, 2026
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
2 changes: 1 addition & 1 deletion rmgpy/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ def is_balanced(self):
from rmgpy.molecule.element import element_list
from rmgpy.molecule.fragment import CuttingLabel, Fragment

cython.declare(reactant_elements=dict, product_elements=dict, molecule=Graph, atom=Vertex, element=Element,
cython.declare(reactant_elements=dict, product_elements=dict, molecule=Molecule, atom=Atom, element=Element,
reactants_net_charge=cython.int, products_net_charge=cython.int)

reactant_elements = {}
Expand Down
47 changes: 35 additions & 12 deletions rmgpy/rmg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@
from rmgpy.stats import ExecutionStatsWriter
from rmgpy.thermo.thermoengine import submit
from rmgpy.tools.plot import plot_sensitivity
from rmgpy.tools.compare_cantera_yaml import compare_yaml_files, compare_yaml_files_and_report
from rmgpy.tools.uncertainty import Uncertainty, process_local_results
from rmgpy.yml import RMSWriter
from rmgpy.yaml_rms import RMSWriter
from rmgpy.yaml_cantera1 import CanteraWriter1
from rmgpy.yaml_cantera2 import CanteraWriter2

################################################################################

Expand Down Expand Up @@ -771,7 +774,8 @@ def register_listeners(self, requires_rms=False):
self.attach(ChemkinWriter(self.output_directory))

self.attach(RMSWriter(self.output_directory))

self.attach(CanteraWriter1(self.output_directory))
self.attach(CanteraWriter2(self.output_directory))
if self.generate_output_html:
self.attach(OutputHTMLWriter(self.output_directory))

Expand Down Expand Up @@ -1219,20 +1223,36 @@ def execute(self, initialize=True, **kwargs):

self.run_model_analysis()

# generate Cantera files chem.yaml & chem_annotated.yaml in a designated `cantera` output folder
# generate Cantera files chem.yaml & chem_annotated.yaml in designated Cantera output folders
try:
logging.info("Translating final chemkin file into Cantera yaml.")
translated_cantera_file = None
if any([s.contains_surface_site() for s in self.reaction_model.core.species]):
self.generate_cantera_files(
translated_cantera_file = self.generate_cantera_files_from_chemkin(
os.path.join(self.output_directory, "chemkin", "chem-gas.inp"),
surface_file=(os.path.join(self.output_directory, "chemkin", "chem-surface.inp")),
)
self.generate_cantera_files(
self.generate_cantera_files_from_chemkin(
os.path.join(self.output_directory, "chemkin", "chem_annotated-gas.inp"),
surface_file=(os.path.join(self.output_directory, "chemkin", "chem_annotated-surface.inp")),
)
else: # gas phase only
self.generate_cantera_files(os.path.join(self.output_directory, "chemkin", "chem.inp"))
self.generate_cantera_files(os.path.join(self.output_directory, "chemkin", "chem_annotated.inp"))
translated_cantera_file = self.generate_cantera_files_from_chemkin(
os.path.join(self.output_directory, "chemkin", "chem.inp")
)
self.generate_cantera_files_from_chemkin(
os.path.join(self.output_directory, "chemkin", "chem_annotated.inp")
)

# Compare translated Cantera files and directly generated Cantera files

compare_yaml_files_and_report(translated_cantera_file,
os.path.join(self.output_directory, "cantera1", "chem.yaml"),
output=os.path.join(self.output_directory, "cantera1", "comparison_report.txt"))
compare_yaml_files_and_report(translated_cantera_file,
os.path.join(self.output_directory, "cantera2", "chem.yaml"),
output=os.path.join(self.output_directory, "cantera2", "comparison_report.txt"))

except EnvironmentError:
logging.exception("Could not generate Cantera files due to EnvironmentError. Check read\\write privileges in output directory.")
except Exception:
Expand Down Expand Up @@ -1803,14 +1823,15 @@ def process_reactions_to_species(self, obj):
raise TypeError("improper call, obj input was incorrect")
return potential_spcs

def generate_cantera_files(self, chemkin_file, **kwargs):
def generate_cantera_files_from_chemkin(self, chemkin_file, **kwargs):
"""
Convert a chemkin mechanism chem.inp file to a cantera mechanism file chem.yaml
and save it in the cantera directory
and save it in the cantera directory.
Returns the path to the generated cantera file.
"""
transport_file = os.path.join(os.path.dirname(chemkin_file), "tran.dat")
file_name = os.path.splitext(os.path.basename(chemkin_file))[0] + ".yaml"
out_name = os.path.join(self.output_directory, "cantera", file_name)
out_name = os.path.join(self.output_directory, "cantera_from_ck", file_name)
if "surface_file" in kwargs:
out_name = out_name.replace("-gas.", ".")
cantera_dir = os.path.dirname(out_name)
Expand All @@ -1828,6 +1849,7 @@ def generate_cantera_files(self, chemkin_file, **kwargs):
logging.exception("Error converting to Cantera format.")
logging.info("Trying again without transport data file.")
parser.convert_mech(chemkin_file, out_name=out_name, quiet=True, permissive=True, **kwargs)
return out_name

def initialize_reaction_threshold_and_react_flags(self):
num_core_species = len(self.reaction_model.core.species)
Expand Down Expand Up @@ -2115,8 +2137,9 @@ def get_git_commit(self, module_path):

if os.path.exists(os.path.join(module_path, "..", ".git")):
try:
return subprocess.check_output(["git", "log", "--format=%H%n%cd", "-1"], cwd=module_path).splitlines()
except:
head, date = subprocess.check_output(["git", "log", "--format=%H%n%cd", "-1"], cwd=module_path).splitlines()
return head.decode(), date.decode()
except (subprocess.CalledProcessError, OSError):
return "", ""
else:
return "", ""
Expand Down
Loading
Loading