Skip to content

Commit 10bd3a0

Browse files
committed
Fix the bug for calculating thermo coverage dependent correct values
1 parent 3129969 commit 10bd3a0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

rmgpy/solver/surface.pyx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,7 @@ cdef class SurfaceReactor(ReactionSystem):
205205
for sp, sp_index in self.species_index.items():
206206
if sp.contains_surface_site():
207207
if self.thermo_coverage_dependence and sp.thermo.thermo_coverage_dependence:
208-
# think about the data structure of thermo coverage dependence
209-
# should not be a list, a dictionary would be better
210-
for spec, parameters in sp.thermo.coverage_dependence.items():
208+
for spec, parameters in sp.thermo.thermo_coverage_dependence.items():
211209
species_index = self.species_index[spec]
212210
try:
213211
list_of_thermo_coverage_deps = self.thermo_coverage_dependencies[species_index]
@@ -216,6 +214,10 @@ cdef class SurfaceReactor(ReactionSystem):
216214
self.thermo_coverage_dependencies[sp_index] = list_of_thermo_coverage_deps
217215
# need to specify the entropy and enthalpy models
218216
# linear, piecewise linear, polynomial, interpolative models
217+
if parameters['model'] == "polynomial":
218+
# for the case of polynomial, we need to insert a 0 for the constant term
219+
parameters['enthalpy-coefficients'] = [0]+[x.value_si for x in parameters['enthalpy-coefficients']]
220+
parameters['entropy-coefficients'] = [0]+[x.value_si for x in parameters['entropy-coefficients']]
219221
list_of_thermo_coverage_deps.append((sp_index, parameters))
220222

221223
"""
@@ -478,14 +480,14 @@ cdef class SurfaceReactor(ReactionSystem):
478480
if parameters['model'] == "linear":
479481
pass
480482
elif parameters['model'] == "polynomial":
481-
enthalpy_cov_correction = np.polynomial.polynomial.polyval(surface_site_fraction, parameters['enthalpy-coefficients'].insert(0,0)) # insert 0 for the constant term
482-
entropy_cov_correction = np.polynomial.polynomial.polyval(surface_site_fraction, parameters['entropy-coefficients'].insert(0,0))
483+
enthalpy_cov_correction = np.polynomial.polynomial.polyval(surface_site_fraction, parameters['enthalpy-coefficients']) # insert 0 for the constant term
484+
entropy_cov_correction = np.polynomial.polynomial.polyval(surface_site_fraction, parameters['entropy-coefficients'])
483485
free_energy_coverage_corrections[j] += enthalpy_cov_correction - self.T.value_si * entropy_cov_correction
484486
elif parameters['model'] == "piecewise-linear":
485487
pass
486488
elif parameters['model'] == "interpolative":
487489
pass
488-
corrected_K_eq = copy.deepcopy(self.K_eq)
490+
corrected_K_eq = copy.deepcopy(self.Keq)
489491
# correct the K_eq
490492
for j in range(ir.shape[0]):
491493
if ir[j, 0] >= num_core_species or ir[j, 1] >= num_core_species or ir[j, 2] >= num_core_species:

0 commit comments

Comments
 (0)