random structure optimization stops after 3rd step

Dear Lammps users,

I am trying to optimise randomly generated structures with conjugate gradient method.

However, it stops after 3rd step and 38 force evaluation. Then, I tried again with the structure from the 3rd step it successfully optimised without stopping.

I wonder why lammps stop after a few number of step of optimisation and how to fix this stopping.

Here is the “log” file optimisation section:

Hello Kang, this is very difficult to say without knowing the details of the initial structure. Since it’s a 26-atom structure, it should be straightforward to dump the trajectory at every step and visualize it. This should inform you of what is the move that leads to the invalid configuration (quite likely, overlapping atomic positions).


The problem is due to using a (fully) random initial structure.

Most potentials have a divergence when atoms get too close and you get either too strong repulsive or attractive forces that cannot be represented with double precision floating point numbers. The fact that the divergence disappears when restarting is due to the conjugate gradient algorithm taking a different “path” to minimization after a restart and thus - by chance - avoiding the specific divergence in this specific input.

the solution is rather straightforward: don’t (initially) use a potential with a divergence when starting from random positions, but one that has a soft core and is purely repulsive, e.g the soft potential, to “unoverlap” your particles and then switch the pair style to the actual desired potential and continue your calculation.