Skip to content

Commit

Permalink
set reference potential for rxns based on temp conditions in reaction…
Browse files Browse the repository at this point in the history
… system
  • Loading branch information
davidfarinajr committed Jan 28, 2021
1 parent 1460e09 commit e17bdef
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
35 changes: 29 additions & 6 deletions rmgpy/rmg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,16 @@ def execute(self, initialize=True, **kwargs):
self.rmg_memories.append(RMG_Memory(reaction_system, self.balance_species))
self.rmg_memories[index].generate_cond()
log_conditions(self.rmg_memories, index)
conditions = self.rmg_memories[index].get_cond()
temperature = potential = None
if isinstance(reaction_system, ElectrodeReactor):
if conditions:
potential = conditions.get('potential')
temperature = conditions.get('T')
if not potential:
potential = reaction_system.potential.value_si
if not temperature:
temperature = reaction_system.T.value_si

# Update react flags
if self.filter_reactions:
Expand All @@ -721,7 +731,7 @@ def execute(self, initialize=True, **kwargs):
atol=self.simulator_settings_list[0].atol,
rtol=self.simulator_settings_list[0].rtol,
filter_reactions=True,
conditions=self.rmg_memories[index].get_cond(),
conditions=conditions,
)

self.update_reaction_threshold_and_react_flags(
Expand All @@ -742,7 +752,9 @@ def execute(self, initialize=True, **kwargs):
self.reaction_model.enlarge(react_edge=True,
unimolecular_react=self.unimolecular_react,
bimolecular_react=self.bimolecular_react,
trimolecular_react=self.trimolecular_react)
trimolecular_react=self.trimolecular_react,
temperature=temperature,
potential=potential)

if not np.isinf(self.model_settings_list[0].thermo_tol_keep_spc_in_edge):
self.reaction_model.set_thermodynamic_filtering_parameters(
Expand Down Expand Up @@ -802,7 +814,16 @@ def execute(self, initialize=True, **kwargs):
reactor_done = True
objects_to_enlarge = []

conditions = self.rmg_memories[index].get_cond()

if isinstance(reaction_system, ElectrodeReactor):
if conditions:
potential = conditions.get('potential')
temperature = conditions.get('T')
if not potential:
potential = reaction_system.potential.value_si
if not temperature:
temperature = reaction_system.T.value_si

if conditions and self.solvent:
T = conditions['T']
# Set solvent viscosity
Expand Down Expand Up @@ -832,7 +853,7 @@ def execute(self, initialize=True, **kwargs):
prune=prune,
model_settings=model_settings,
simulator_settings=simulator_settings,
conditions=self.rmg_memories[index].get_cond()
conditions=conditions
)
except:
logging.error("Model core reactions:")
Expand Down Expand Up @@ -932,7 +953,9 @@ def execute(self, initialize=True, **kwargs):
self.reaction_model.enlarge(react_edge=True,
unimolecular_react=self.unimolecular_react,
bimolecular_react=self.bimolecular_react,
trimolecular_react=self.trimolecular_react)
trimolecular_react=self.trimolecular_react,
potential=potential,
temperature=temperature)

if old_edge_size != len(self.reaction_model.edge.reactions) or old_core_size != len(
self.reaction_model.core.reactions):
Expand Down Expand Up @@ -2340,7 +2363,7 @@ def obj(y):
if 'P' in list(new_cond.keys()):
new_cond['P'] = np.exp(new_cond['P'])
if 'potential' in list(new_cond.keys()):
new_cond['potential'] = np.exp(new_cond['potential'])
new_cond['potential'] = new_cond['potential']

if hasattr(self, 'initial_mole_fractions'):
for key in self.initial_mole_fractions.keys():
Expand Down
7 changes: 5 additions & 2 deletions rmgpy/rmg/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ def make_new_pdep_reaction(self, forward):
return forward

def enlarge(self, new_object=None, react_edge=False,
unimolecular_react=None, bimolecular_react=None, trimolecular_react=None):
unimolecular_react=None, bimolecular_react=None, trimolecular_react=None,
temperature=None, potential=None):
"""
Enlarge a reaction model by processing the objects in the list `new_object`.
If `new_object` is a
Expand Down Expand Up @@ -636,7 +637,9 @@ def enlarge(self, new_object=None, react_edge=False,
reaction.kinetics = reaction.kinetics.to_arrhenius()

if isinstance(reaction.kinetics, SurfaceChargeTransfer):
reaction.set_reference_potential(298)
reaction.set_reference_potential(temperature)
# reaction.kinetics.change_v0(0.0)

else:
# correct barrier heights of estimated kinetics
if isinstance(reaction, TemplateReaction) or isinstance(reaction,
Expand Down

0 comments on commit e17bdef

Please sign in to comment.