Skip to content

Commit a681ed5

Browse files
committed
Write thermo coverage dependent data to Cantera yaml file
1 parent dbb218f commit a681ed5

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
@@ -1212,6 +1213,42 @@ def execute(self, initialize=True, **kwargs):
12121213
os.path.join(self.output_directory, "chemkin", "chem_annotated-gas.inp"),
12131214
surface_file=(os.path.join(self.output_directory, "chemkin", "chem_annotated-surface.inp")),
12141215
)
1216+
if self.thermo_coverage_dependence:
1217+
# add thermo coverage dependence to Cantera files
1218+
chem_yaml_path = os.path.join(self.output_directory, "cantera", "chem.yaml")
1219+
gas = ct.Solution(chem_yaml_path, "gas")
1220+
surf = ct.Interface(chem_yaml_path, "surface1", [gas])
1221+
with open(chem_yaml_path, 'r') as f:
1222+
content = yaml.load(f, Loader=yaml.FullLoader)
1223+
1224+
content['phases'][1]['reference-state-coverage'] = 0.11
1225+
content['phases'][1]['thermo'] = 'coverage-dependent-surface'
1226+
1227+
for s in self.reaction_model.core.species:
1228+
if s.contains_surface_site() and s.thermo.thermo_coverage_dependence:
1229+
for dep_sp, parameters in s.thermo.thermo_coverage_dependence.items():
1230+
mol = Molecule().from_adjacency_list(dep_sp)
1231+
for sp in self.reaction_model.core.species:
1232+
if sp.is_isomorphic(mol, strict=False):
1233+
try:
1234+
parameters['units'] = {'energy':'J', 'quantity':'mol'}
1235+
content["species"][surf.species_index(sp.label)]['coverage-dependencies'][sp.label] = parameters
1236+
except KeyError:
1237+
content["species"][surf.species_index(sp.label)]['coverage-dependencies'] = {sp.label: parameters}
1238+
1239+
annotated_yaml_path = os.path.join(self.output_directory, "cantera", "chem_annotated.yaml")
1240+
with open(annotated_yaml_path, 'r') as f:
1241+
annotated_content = yaml.load(f, Loader=yaml.FullLoader)
1242+
1243+
annotated_content['phases'] = content['phases']
1244+
annotated_content['species'] = content['species']
1245+
1246+
with open(chem_yaml_path, 'w') as output_f:
1247+
yaml.dump(content, output_f, sort_keys=False)
1248+
1249+
with open(annotated_yaml_path, 'w') as output_f:
1250+
yaml.dump(annotated_content, output_f, sort_keys=False)
1251+
12151252
else: # gas phase only
12161253
self.generate_cantera_files(os.path.join(self.output_directory, "chemkin", "chem.inp"))
12171254
self.generate_cantera_files(os.path.join(self.output_directory, "chemkin", "chem_annotated.inp"))

0 commit comments

Comments
 (0)