|
50 | 50 | import yaml |
51 | 51 | from cantera import ck2yaml |
52 | 52 | from scipy.optimize import brute |
| 53 | +import cantera as ct |
53 | 54 |
|
54 | 55 | import rmgpy.util as util |
55 | 56 | from rmgpy.rmg.model import Species, CoreEdgeReactionModel |
@@ -1212,6 +1213,42 @@ def execute(self, initialize=True, **kwargs): |
1212 | 1213 | os.path.join(self.output_directory, "chemkin", "chem_annotated-gas.inp"), |
1213 | 1214 | surface_file=(os.path.join(self.output_directory, "chemkin", "chem_annotated-surface.inp")), |
1214 | 1215 | ) |
| 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 | + |
1215 | 1252 | else: # gas phase only |
1216 | 1253 | self.generate_cantera_files(os.path.join(self.output_directory, "chemkin", "chem.inp")) |
1217 | 1254 | self.generate_cantera_files(os.path.join(self.output_directory, "chemkin", "chem_annotated.inp")) |
|
0 commit comments