LAMMPS (2 Apr 2025) Incorrect number of atoms in the output file.

I have been using lammps relaxation script for carbon diamond, but for whatever reason the scripts seems to be writing the wrong number of atoms in the output data file, and it does not open in ovito. Namely, the number of atoms in the first lines of the data files does not match the number of lines with atoms’ positions and velocities. Am I doing something wrong? Similar relaxation script with a different pair_style works perfectly fine for silicon diamond relaxation. Below is the script I have used.
LAMMPS (2 Apr 2025)


units 		    metal
boundary	    p p p

read_data	    simulations/data/carbondata


timestep 0.002

pair_style tersoff/zbl
pair_coeff * * simulations/potentials/C.trsf C


compute         ep all pe/atom

thermo 10
thermo_modify lost warn flush yes

region          interior block INF INF INF INF $(zlo) $(zlo+2.0) side out
region          border block INF INF INF INF $(zlo) $(zlo+2.0)

min_style 	cg
min_modify dmax 0.001

## MINIMIZATION ##
fix 1 all box/relax iso 0.0 vmax 0.01
minimize 1.0e-6 1.0e-7 100000 1000000
unfix 1



## RELAXATION BULK ROOM TEMP 0 PRESS ##
velocity all create 300.0 4928459 rot yes dist gaussian loop local

fix 1 all npt iso 0.0 0.0 $(1000.0*dt) temp 300 300 $(100.0*dt)
run 10000
unfix 1

## OPEN SURFACE IN Z DIRECTION. FREEZE BOTTOM LAYER AND RELAX ##
change_box all z delta 0.0 5.0 boundary p p f 

group           border_atoms region border
group           interior_atoms region interior

velocity        border_atoms set 0.0 0.0 0.0
fix             freeze border_atoms setforce 0.0 0.0 0.0

fix 1 interior_atoms nvt temp 300 300 $(100.0*dt)

dump 1 all custom 100 simulations/movies/movierelax.carbon.lammpstrj id type x y z vx vy vz fx fy fz c_ep


dump_modify 1 sort id
run 10000
write_data simulations/data/relaxdata.carbon.debug```

What happens when you comment out the thermo_modify command?

The script ran as usual, and the output data is exactly the same.

Please provide the complete input deck with all files.

As a new user I cannot attach files yet. The input file is 216000-atom carbon diamond cell with the following dimensions:
0.0 107.01 xlo xhi
0.0 107.01 ylo yhi
0.0 107.01 zlo zhi
The potential used is # Parameters for N-C interactions from CITATION: J. Tersoff, Phys. Rev. B 39, 5566 (1989)

Then put an archive on Google drive or Dropbox or similar and provide a shareable link to it.

https://drive.google.com/drive/folders/1Aky0wzQFnbuT3gS1cW6kbaPq69P32OrH?usp=sharing

Thanks for the files. The problem originates from the command

change_box all z delta 0.0 5.0 boundary p p f

If you split this into two commands, you will get an inconsistent atom count error and LAMMPS will refuse to write the data file.

As far as I can find out, the reason is that due to the “boundary” options all image flags are set to zero in z-direction. You are seeing a warning about that, because some atoms have moved beyond the upper periodic box and now are wrapped back to z=0.0 or even a little under zero.

You should have seen a lost atoms error, but somehow this didn’t happen.

A simple workaround would be to extend the box to negative z a little bit.
Another, more invasive but physically meaningful approach would be to do the relaxation already with non-periodic z and relax only in x- and y-direction and keep the lower Z atoms immobile.

1 Like