|
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 |
@@ -1179,6 +1180,42 @@ def execute(self, initialize=True, **kwargs): |
1179 | 1180 | os.path.join(self.output_directory, "chemkin", "chem_annotated-gas.inp"), |
1180 | 1181 | surface_file=(os.path.join(self.output_directory, "chemkin", "chem_annotated-surface.inp")), |
1181 | 1182 | ) |
| 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 | + |
1182 | 1219 | else: # gas phase only |
1183 | 1220 | self.generate_cantera_files(os.path.join(self.output_directory, "chemkin", "chem.inp")) |
1184 | 1221 | self.generate_cantera_files(os.path.join(self.output_directory, "chemkin", "chem_annotated.inp")) |
|
0 commit comments