I am trying to simulate noble gas interactions based on the Lennar Jones Potential. And I ran into the problem that the interactions of the particles is apparently calculated in discrete steps so that the acceleration tends to either jump to unreasonably high values or doesn't change significantly when two particles approach each other. The detection algorithm that I'm using looks as follows:
def accerlation(self):
index = 0
for particle, particle2 in itertools.combinations(self.particles, 2):
index += 1
x_diff = (particle.r[0] - particle2.r[0])*S
y_diff = (particle.r[1] - particle2.r[1])*S
distance = np.sqrt(x_diff**2 + y_diff**2)
if distance < criticaldistance1 and distance> criticaldistance2:
print("Interaction")
particle.a[0] -= 1/(Particle().m) *(LennardJones_Force(x_diff))
particle.a[1] -= 1/Particle().m *(LennardJones_Force(y_diff))
print(particle.a)
(The print commands are for debugging)
The Lennard Jones Force is simply a function that returns (24*epsilon*sigma**6*(Distance**6 - 2*sigma**6))/Distance**13
, where epsilon and sigma are constant values.
If you can't spot a mistake there, the problem might also be in this part:
def Changeovertime(self):
self.Collision_Box() #elaxtic collsions with box
for particle in self.particles:
particle.r += self.dt * particle.v + self.dt**2*particle.a
particle.a_prior = particle.a
self.accerlation() #
particle.a = np.zeros(2) #
particle.v = (particle.v + self.dt/2 * (particle.a + particle.a_prior)) *self.scaling()
When I print the acceleration of a pair of particles during the animation it looks as follows:
[-3.21599405e-01 -1.05489024e-18]\
Interaction\
[-3.35299415e-14 2.61407475e-19]\
Interaction\
[-2.52825200e+31 -1.05489024e-07]\
Interaction\
[-6.70598831e-14 5.22814950e-19]\
Interaction\
[ 1.57188229e-01 -5.51566856e-19]\
Interaction\
[-6.70598831e-03 5.22814950e-08]\
Interaction\
[ 3.14376458e-01 -1.10313371e-18]\
Interaction\
[-3.35299416e-14 2.72195193e-19]\
Interaction\
[-6.70598831e-14 5.44390386e-19]\
(Note the jump from entry 2 to entry 3)