Energy becoming 'nan' after 1000 iterations

Hello LAMMPS users,

I am using the LAMMPS version 23Jun2022. I am currently trying to simulate Kinetic Monte Carlo diffusion of atoms in an Inconel/Nickel Composite. For that, I am using PyLAMMPS. My simulation runs properly until the 1000th Monte Carlo iteration, at which the energy values become ‘nan’. I tried to rectify it by using the following lines:

nan_iteration = 999
nan_increment = 1000
L.variable(“n_iteration equal 1000”)
L.variable(“n_increment equal 1000”)
L.write_dump(“all custom Inc-Ni-diffused.xyz id type x y z”)

if (i == nan_iteration):
    L.clear
    L.read_dump("Inc-Ni-diffused.xyz ${n_iteration} x y z")
    L.command("run 0")
    nan_iteration += nan_increment
    L.variable("n_iteration equal ${n_iteration}+${n_increment}")

This enabled me to get to 2000 iterations successfully, after which it the energy values become ‘nan’ again. Is there any way to circumvent this?

Regards,
Rajesh

This is a nice opportunity to quote one of my favorite jokes:

Patient: Doctor, doctor. It hurts a lot when I do this.
Doctor: Well, just don’t do it, then!

Translated to computer simulations this means, that you are doing things that bring your system into a bad state, e.g. by moving atoms too close or even on top of each other. This is ultimately a flaw in either your settings or your monte carlo implementation. Your “solution” is not really a solution. You are trying to ignore the flaw and that will - of course - not be a viable and permanent solution.

Thank you for the response, Dr. Kohlmeyer. I am merely performing the MC exchange of atoms (two atoms exchanged with each per iteration) based on the Metropolis criterion for the energy. But it gives me ‘nan’ values for the energy only at the 1000th iteration or at iterations that are multiples of 1000.

You get NaN energies when you feed LAMMPS a bad geometry or bad parameters. LAMMPS doesn’t just do it just to spite you. Thus, the logical consequence is that the flaw must be somewhere in your implementation. You will have to debug it.