Write_data records the atoms incorrectly

LAMMPS version: LAMMPS (11 Feb 2026 - Development - patch_11Feb2026-27-g608fd4e569-modified)

When using write_data in combination with the simulation box changing command the number of atoms recorded at the end of the simulation differs from the actual number written by write_data. As a consequence, there are less atoms in the body of the data file than those specified in the header.

I only add what I think is the relevant section of the script. If needed I can submit more files.

change_box all z delta 0.0 5.0 boundary p p f

fix 2 all npt temp ${T} ${T} $(100.0*dt) x 0.0 0.0 $(1000.0*dt) y 0.0 0.0 $(1000.0*dt)


fix 3 all recenter INIT INIT INIT
run 3#0000

write_data start.lammps

Perhaps, the low number of steps makes that the number of atoms is not counted properly. Has anyone encountered a similar issue ?

I know this is done with good intentions, but it is useless and it is rather annoying to have to tell this to people all the time. But just think about it: if you don’t know what is causing the issue, how can you know that these are the relevant parts of the input?

If you want to help tracking this down, you should instead construct a custom minimal input that has only the essential commands required to reproduce the issue with the smallest possible number of atoms and the fewest timesteps required. Sometimes, already constructing this kind of test example can help to understand the problem. But only with such a minimal example is it relatively easy to spot the issue.

Without sufficient information, one can only guess. I would say the most likely situation is that you have lost atoms, but didn’t have a thermo output or some other step where LAMMPS is checking for it. The check is not done all the time to reduce the overhead it causes.

As @akohlmey said, these combination of commands is rather useless on its own.

Note that since you use fixed non-periodic boundary conditions in the same axis, it can expected that some atoms go beyond the z limits during xy constant pressure simulation since compression in the xy plane will lead to hydrostatic pressure and momentum flux along the z axis.

Try using other settings such as s or m and see what output this gives you.

Hi @akohlmey and @Germain . Thank you for your inputs. I am sorry that the provided information made spotting the bug more difficult.

In any case, increasing the number of steps led to an update of the thermo output and the number of atoms now matches the number of written atoms. That resolved the issue. Thank you

Can I suggest that the write_data command triggers a thermo output update as a first step?

@Germain s and m do not lead to atoms vanishing, therefore I imagine that the number of atoms always matches the written information.