Register to reply

[MD] Lennard Jones

Share this thread:
Dec24-13, 09:34 AM
P: 48

For a simulation regarding Lennard Jones fluids I'm getting divergences.
I have particles in a fixed volume.
I calculate distances between these particles to find the force.

However in the first iteration I already get divergences (NaN values in matlab).
I use [tex]F_x^{ij} = 24\varepsilon \left( 2r_{ij}^{-14}-r_{ij}^{-8}\right)\cdot \Delta x_{ij}[/tex]
Where the i,j have to do with the particles I'm viewing. For each direction I get such a force.
But some of the particles get so close that this force and hence the acceleration effectively become infinity. My simulation obviously breaks down at this point.

I tried changing the timestep, this doesn't do anything.
It worked at some point but I don't recall changing anything after that. Except adding the thermostat code which I can turn off. The divergence remains.

You can find my (messy) code in this pastebin
I've been looking at it for hours already yet I can't find any solution.


I had divergences before. Those were caused by an error in applying the periodic boundary conditions. I forgot using the nearest image convention at that time.
Phys.Org News Partner Physics news on
X-ray stroboscope offers new insights into biomolecular dynamics
Ordinary materials, fantastic opportunities
A metallic alloy that is tough and ductile at cryogenic temperatures
Dec25-13, 06:50 PM
P: 48
I found the mistake.
In my initialization of the cubic lattice, I had a break off variable g.
I initialized this one as g = 1. Which caused the last point to to coincide with my first point and so I got immediate divergences.

At least 4 hours to waste :S

Dec25-13, 06:53 PM
P: 3,091
You may have wasted 4 hours on this, but it took you 20+ years to get to this point...

Register to reply

Related Discussions
Lennard-Jones 6-12 potential Introductory Physics Homework 1
Lennard Jones Potential Advanced Physics Homework 0
Lennard-Jones Potential Advanced Physics Homework 3
Lennard-Jones Parameters Materials & Chemical Engineering 0
Computing Lennard-Jones potentials for molecules Atomic, Solid State, Comp. Physics 4