Skip to content

Commit

Permalink
fixup! several potential related changes in reaction.py
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfarinajr committed Aug 8, 2020
1 parent e771940 commit 4cbd3c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions rmgpy/reaction.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ cdef class Reaction:

cpdef double get_entropy_of_reaction(self, double T)

cpdef double get_free_energy_of_reaction(self, double T, potential=?)
cpdef double get_free_energy_of_reaction(self, double T, double potential=?)

cpdef double get_equilibrium_constant(self, double T, potential=?, str type=?)
cpdef double get_equilibrium_constant(self, double T, double potential=?, str type=?)

cpdef np.ndarray get_enthalpies_of_reaction(self, np.ndarray Tlist)

Expand Down
12 changes: 6 additions & 6 deletions rmgpy/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ def get_entropy_of_reaction(self, T):
dSrxn += product.get_entropy(T)
return dSrxn

def get_free_energy_of_reaction(self, T, potential=None):
def get_free_energy_of_reaction(self, T, potential=0):
"""
Return the Gibbs free energy of reaction in J/mol evaluated at
temperature `T` in K and potential in Volts (if applicable)
Expand All @@ -573,7 +573,7 @@ def get_free_energy_of_reaction(self, T, potential=None):
dGrxn = 0.0

if self.is_charge_transfer_reaction() and self.V0:
dGrxn = -1 * abs(self.ne) * constants.F * self.V0.value_si # G = -nFE0 in J/mol
dGrxn = -1 * abs(self.ne) * constants.F * self.V0.value_si # G = -nFE0 in J/mol, not sure about sign
else:
for reactant in self.reactants:
if not reactant.is_electron():
Expand All @@ -590,12 +590,12 @@ def get_free_energy_of_reaction(self, T, potential=None):
logging.error("Problem with product {!r} in reaction {!s}".format(reactant, self))
raise

if self.is_charge_transfer_reaction() and potential is not None:
dGrxn += (dGrxn - self.ne * constants.F * potential) # Not sure about sign here or equation G = -nFE0 + nF(V0-V)
# where nF(V0-V) is from applied potential
if self.is_charge_transfer_reaction() and potential != 0:
dGrxn -= self.ne * constants.F * potential # Not sure about sign here

return dGrxn

def get_equilibrium_constant(self, T, potential=None, type='Kc'):
def get_equilibrium_constant(self, T, potential=0, type='Kc'):
"""
Return the equilibrium constant for the reaction at the specified
temperature `T` in K and (electrochemical) potential in volts (if applicable).
Expand Down

0 comments on commit 4cbd3c4

Please sign in to comment.