Skip to content

Commit

Permalink
fixing buckingham to work for mixing
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdolan authored and maxdolan committed Jul 25, 2024
1 parent 265ce47 commit 974f23f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pylj/forcefields.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class lennard_jones_sigma_epsilon(object):
def __init__(self, constants):
self.sigma = constants[0]
self.epsilon = constants[1]
self.point_size = 1.3e10 * self.sigma*(2**(1/6))
self.point_size = 1.3e10 * (self.sigma*(2**(1/6)))

def energy(self, dr):
r"""Calculate the energy for a pair of particles using the
Expand Down Expand Up @@ -134,6 +134,7 @@ def __init__(self, constants):
self.a = constants[0]
self.b = constants[1]
self.c = constants[2]
self.point_size = 8 # Needs better solution relevant to constants

def energy(self, dr):
r"""Calculate the energy for a pair of particles using the
Expand All @@ -151,7 +152,11 @@ def energy(self, dr):
float: array_like
The potential energy between the particles.
"""
self.energy = self.a * np.exp(- np.multiply(self.b, dr)) - self.c / np.power(dr, 6)
energy = self.a * np.exp(- np.multiply(self.b, dr)) - self.c / np.power(dr, 6)
# Cut out infinite values where r = 0
energy[energy > 10e300] = 0
energy[energy < -10e300] = 0
self.energy = energy
return self.energy

def force(self, dr):
Expand All @@ -170,7 +175,11 @@ def force(self, dr):
float: array_like
The force between the particles.
"""
self.force = self.a * self.b * np.exp(- np.multiply(self.b, dr)) - 6 * self.c / np.power(dr, 7)
force = self.a * self.b * np.exp(- np.multiply(self.b, dr)) - 6 * self.c / np.power(dr, 7)
# Cut out infinite values where r = 0
force[force > 10e300] = 0
force[force < -10e300] = 0
self.force = force
return self.force

def mixing(self, constants2):
Expand Down Expand Up @@ -210,6 +219,7 @@ def __init__(self, constants, max_val=np.inf):
self.sigma = constants[1]
self.lamda = constants[2] #Spelling as lamda not lambda to avoid calling python lambda function
self.max_val = max_val
self.point_size = 10

def energy(self, dr):
r'''Calculate the energy for a pair of particles using a
Expand Down

0 comments on commit 974f23f

Please sign in to comment.