Skip to content

Commit 03c94e9

Browse files
committed
Write thermo coverage dependent data to Cantera yaml file
1 parent 645928c commit 03c94e9

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

rmgpy/rmg/main.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import yaml
5151
from cantera import ck2yaml
5252
from scipy.optimize import brute
53+
import cantera as ct
5354

5455
import rmgpy.util as util
5556
from rmgpy.rmg.model import Species, CoreEdgeReactionModel
@@ -1179,6 +1180,42 @@ def execute(self, initialize=True, **kwargs):
11791180
os.path.join(self.output_directory, "chemkin", "chem_annotated-gas.inp"),
11801181
surface_file=(os.path.join(self.output_directory, "chemkin", "chem_annotated-surface.inp")),
11811182
)
1183+
if self.thermo_coverage_dependence:
1184+
# add thermo coverage dependence to Cantera files
1185+
chem_yaml_path = os.path.join(self.output_directory, "cantera", "chem.yaml")
1186+
gas = ct.Solution(chem_yaml_path, "gas")
1187+
surf = ct.Interface(chem_yaml_path, "surface1", [gas])
1188+
with open(chem_yaml_path, 'r') as f:
1189+
content = yaml.load(f, Loader=yaml.FullLoader)
1190+
1191+
content['phases'][1]['reference-state-coverage'] = 0.11
1192+
content['phases'][1]['thermo'] = 'coverage-dependent-surface'
1193+
1194+
for s in self.reaction_model.core.species:
1195+
if s.contains_surface_site() and s.thermo.thermo_coverage_dependence:
1196+
for dep_sp, parameters in s.thermo.thermo_coverage_dependence.items():
1197+
mol = Molecule().from_adjacency_list(dep_sp)
1198+
for sp in self.reaction_model.core.species:
1199+
if sp.is_isomorphic(mol, strict=False):
1200+
try:
1201+
parameters['units'] = {'energy':'J', 'quantity':'mol'}
1202+
content["species"][surf.species_index(sp.label)]['coverage-dependencies'][sp.label] = parameters
1203+
except KeyError:
1204+
content["species"][surf.species_index(sp.label)]['coverage-dependencies'] = {sp.label: parameters}
1205+
1206+
annotated_yaml_path = os.path.join(self.output_directory, "cantera", "chem_annotated.yaml")
1207+
with open(annotated_yaml_path, 'r') as f:
1208+
annotated_content = yaml.load(f, Loader=yaml.FullLoader)
1209+
1210+
annotated_content['phases'] = content['phases']
1211+
annotated_content['species'] = content['species']
1212+
1213+
with open(chem_yaml_path, 'w') as output_f:
1214+
yaml.dump(content, output_f, sort_keys=False)
1215+
1216+
with open(annotated_yaml_path, 'w') as output_f:
1217+
yaml.dump(annotated_content, output_f, sort_keys=False)
1218+
11821219
else: # gas phase only
11831220
self.generate_cantera_files(os.path.join(self.output_directory, "chemkin", "chem.inp"))
11841221
self.generate_cantera_files(os.path.join(self.output_directory, "chemkin", "chem_annotated.inp"))

0 commit comments

Comments
 (0)