Skip to content

Commit

Permalink
Added RMG thermo and kinetics scripts
Browse files Browse the repository at this point in the history
to run RMG as standalone in its own env to get thermo and kinetics for comparisons
  • Loading branch information
alongd committed Dec 28, 2024
1 parent 83725df commit a2920e9
Show file tree
Hide file tree
Showing 5 changed files with 502 additions and 0 deletions.
1 change: 1 addition & 0 deletions arc/scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import common
90 changes: 90 additions & 0 deletions arc/scripts/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"""
This module contains functions which are shared across multiple ARC modules.
As such, it should not import any other ARC module (specifically ones that use the logger defined here)
to avoid circular imports.
VERSION is the full ARC version, using `semantic versioning <https://semver.org/>`_.
"""

import argparse
import os
import yaml
from typing import Union


def parse_command_line_arguments(command_line_args=None):
"""
Parse command-line arguments.
Args:
command_line_args: The command line arguments.
Returns:
The parsed command-line arguments by keywords.
"""
parser = argparse.ArgumentParser(description='Automatic Rate Calculator (ARC)')
parser.add_argument('file', metavar='FILE', type=str, nargs=1, help='a file with input information')
args = parser.parse_args(command_line_args)
args.file = args.file[0]
return args


def read_yaml_file(path: str) -> Union[dict, list]:
"""
Read a YAML file (usually an input / restart file, but also conformers file)
and return the parameters as python variables.
Args:
path (str): The YAML file path to read.
Returns: Union[dict, list]
The content read from the file.
"""
if not isinstance(path, str):
raise ValueError(f'path must be a string, got {path} which is a {type(path)}')
if not os.path.isfile(path):
raise ValueError(f'Could not find the YAML file {path}')
with open(path, 'r') as f:
content = yaml.load(stream=f, Loader=yaml.FullLoader)
return content


def save_yaml_file(path: str, content: Union[list, dict]) -> None:
"""
Save a YAML file (usually an input / restart file, but also conformers file).
Args:
path (str): The YAML file path to save.
content (list, dict): The content to save.
"""
if not isinstance(path, str):
raise ValueError(f'path must be a string, got {path} which is a {type(path)}')
yaml_str = to_yaml(py_content=content)
if '/' in path and os.path.dirname(path) and not os.path.exists(os.path.dirname(path)):
os.makedirs(os.path.dirname(path))
with open(path, 'w') as f:
f.write(yaml_str)


def to_yaml(py_content: Union[list, dict]) -> str:
"""
Convert a Python list or dictionary to a YAML string format.
Args:
py_content (list, dict): The Python content to save.
Returns: str
The corresponding YAML representation.
"""
yaml.add_representer(str, string_representer)
yaml_str = yaml.dump(data=py_content)
return yaml_str


def string_representer(dumper, data):
"""
Add a custom string representer to use block literals for multiline strings.
"""
if len(data.splitlines()) > 1:
return dumper.represent_scalar(tag='tag:yaml.org,2002:str', value=data, style='|')
return dumper.represent_scalar(tag='tag:yaml.org,2002:str', value=data)
58 changes: 58 additions & 0 deletions arc/scripts/libraries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
thermo:
- primaryThermoLibrary
- BurkeH2O2
- Spiekermann_refining_elementary_reactions
- thermo_DFT_CCSDTF12_BAC
- DFT_QCI_thermo
- CBS_QB3_1dHR
- NH3
- NitrogenCurran
- CHON_G4
- CN
- NOx2018
- FFCM1(-)
- Butadiene_Dimerization
- C10H11
- s3_5_7_ane
- Fulvene_H
- naphthalene_H
- vinylCPD_H
- Lai_Hexylbenzene
- Narayanaswamy
- SABIC_aromatics_1dHR_extended
- SABIC_aromatics_1dHR
- SABIC_aromatics
- heavy_oil_ccsdtf12_1dHR
- bio_oil
- Chernov
- CurranPentane
- Klippenstein_Glarborg2016
kinetics:
- primaryH2O2
- primaryNitrogenLibrary
- Ethylamine
- primarySulfurLibrary
- Sulfur/DMDS
- Sulfur/DMS
- FFCM1(-)
- 2006_Joshi_OH_CO
- 2005_Senosiain_OH_C2H2
- NOx2018
- 2001_Tokmakov_H_Toluene_to_CH3_Benzene
- 2003_Miller_Propargyl_Recomb_High_P
- 2009_Sharma_C5H5_CH3_highP
- 2015_Buras_C2H3_C4H6_highP
- Butadiene_Dimerization
- C10H11
- C12H11_pdep
- C2H2_init
- C6H5_C4H4_Mebel
- Fulvene_H
- Mebel_Naphthyl
- Mebel_C6H5_C2H2
- biCPD_H_shift
- c-C5H5_CH3_Sharma
- fascella
- kislovB
- naphthalene_H
- vinylCPD_H
Loading

0 comments on commit a2920e9

Please sign in to comment.