Skip to content

Commit bb89c11

Browse files
committed
use isomorphic check to check if thermo coverage dependent species are in the model
1 parent 9c8e827 commit bb89c11

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

rmgpy/solver/surface.pyx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ from rmgpy.quantity import Quantity
4444
from rmgpy.quantity cimport ScalarQuantity
4545
from rmgpy.solver.base cimport ReactionSystem
4646
import copy
47+
from rmgpy.molecule import Molecule
4748

4849
cdef class SurfaceReactor(ReactionSystem):
4950
"""
@@ -178,7 +179,6 @@ cdef class SurfaceReactor(ReactionSystem):
178179
cdef np.ndarray thermo_coeff_matrix = np.zeros((len(self.species_index), len(self.species_index), 6), dtype=np.float64)
179180
cdef np.ndarray stoi_matrix = np.zeros((self.reactant_indices.shape[0], len(self.species_index)), dtype=np.float64)
180181
self.thermo_coeff_matrix = thermo_coeff_matrix
181-
self.stoi_matrix = stoi_matrix
182182
#: 1 if it's on a surface, 0 if it's in the gas phase
183183
reactions_on_surface = np.zeros((self.num_core_reactions + self.num_edge_reactions), int)
184184
species_on_surface = np.zeros((self.num_core_species), int)
@@ -212,13 +212,14 @@ cdef class SurfaceReactor(ReactionSystem):
212212
if sp.contains_surface_site():
213213
if self.thermo_coverage_dependence and sp.thermo.thermo_coverage_dependence:
214214
for spec, parameters in sp.thermo.thermo_coverage_dependence.items():
215-
try:
216-
species_index = self.species_index[spec]
217-
thermo_polynomials = parameters['enthalpy-coefficients'] + parameters['entropy-coefficients']
218-
self.thermo_coeff_matrix[sp_index, species_index] = [x.value_si for x in thermo_polynomials]
219-
except KeyError:
220-
logging.warning("Species {} is not in the species list yet, skip the thermodynamic coverage effect estimation!".format(spec))
221-
215+
molecule = Molecule().from_adjacency_list(spec)
216+
for species in self.species_index.keys():
217+
if species.is_isomorphic(molecule, strict=False):
218+
species_index = self.species_index[species]
219+
thermo_polynomials = parameters['enthalpy-coefficients'] + parameters['entropy-coefficients']
220+
self.thermo_coeff_matrix[sp_index, species_index] = [x.value_si for x in thermo_polynomials]
221+
# create a stoichiometry matrix for reaction enthalpy and entropy correction
222+
# due to thermodynamic coverage dependence
222223
if self.thermo_coverage_dependence:
223224
ir = self.reactant_indices
224225
ip = self.product_indices

0 commit comments

Comments
 (0)