A problem with using "replicate"

Dear Lammps developers/users

I recently faced a problem with replicating a system (twice in z direction) after reading a restart file. I have been using these two commands for a long time and I never got this error.

Here is the error:
ERROR on proc 0: Bond atoms 14597 14598 missing on proc 0 at step 40500003 (neigh_bond.cpp:48)

I think some atoms get very close to each other after replicating and a very high potential energy and high negative pressure are resulted as seen in the first time step after replicating:

Step Temp Press PotEng TotEng Volume
40500000 282.56152 -1372940.3 39273652 39313352 1069283

while the pressure and potential energy at the last time step of the simulation from which the restart file is produced is usual:

40500000 282.56752 221.64594 -1031609.8 -1011759.8 534641.51

Even I tried another way to check that if it is related to using replicate just after reading restart. I did not replicate the system after read_restart and I allowed it to go for some time steps and then replicate it during simulations. The same problem arisen.

Also I need to mention that I have been using periodic boundary conditions in all directions. When I duplicate a simulation system, I do not expect to have very high pressure and potential energy because of periodic boundary condition.

Any help is appreciated in advance,

Dear Lammps developers/users

I recently faced a problem with replicating a system (twice in z direction)
after reading a restart file. I have been using these two commands for a
long time and I never got this error.

try inserting a "run 0" after reading the restart.

can you continue correctly after the restart without the replication?


Are you certain you started the simulation (before writing the restart
file) with
atoms having the correct image flags? If not, replicate can get confused
if bonds straddle the periodic boundary. See the replicate doc page
for details.


Thank you Axel and Steve,

try inserting a “run 0” after reading the restart.
I tried run 0, it gives the same initial line that I have already pasted in the first email:

Step Temp Press PotEng TotEng Volume
40500000 282.56152 -1372940.3 39273652 39313352 1069283
Loop time of 5.00679e-06 on 1 procs for 0 steps with 47136 atoms

Pair time () = 0 (0) Bond time () = 0 (0)
Neigh time () = 0 (0) Comm time () = 0 (0)
Outpt time () = 0 (0) Other time () = 5.00679e-06 (100)

Nlocal: 47136 ave 47136 max 47136 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost: 45279 ave 45279 max 45279 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs: 8.21788e+06 ave 8.21788e+06 max 8.21788e+06 min
Histogram: 1 0 0 0 0 0 0 0 0 0
FullNghs: 1.64358e+07 ave 1.64358e+07 max 1.64358e+07 min
Histogram: 1 0 0 0 0 0 0 0 0 0

Total # of neighbors = 16435764
Ave neighs/atom = 348.688
Ave special neighs/atom = 4.07332
Neighbor list builds = 0
Dangerous builds = 0

can you continue correctly after the restart without the replication?
It continues well when I do not replicate the system.

And also I checked the restrictions on using replicate command, my system does not have any rigid bodies. And I have done similar simulations including restart and replicate commands for similar systems and they all have worked well.

Could it be due to the change in the version of lammps. I had a very initial generated and run by 28Feb2012 version. Later, because the supercomputer center installed the 1Jul2012 version, I continued running very long simulations with this newer version. Now, when I try the 28Feb version it gives the above output and when I try 1Jul2012 version it gives the following error:

ERROR: Bond/angle/dihedral extent > half of periodic box length (domain.cpp:580)


ERROR: Bond/angle/dihedral extent > half of periodic box length (domain.cpp:580)

Again this is an indication that your image flags are not correct.
Thus the replicate
command cannot add bonds, angles, etc to the new system to connect the
proper atoms. If you started the initial simulation with bad image flags, then
they will persist. E.g. if in the initial system you had a bond straddling the
periodic boundary and the images flags of the 2 atoms were both 0.


Thanks Steve,
I never changed image flags during simulations. I do not how could that happen.

Anyway, based on your comment I tried command “set image” before replicating simulation box. I gave values of “0” and “2” with this command but the error still shows up. Do you know a way to fix this possible problem?


I'm just guessing here, but what you are trying to do is:

1st run:
read a data file
write a restart file

2nd run:
read the restart file
run some more

I am saying that the initial data flie was "wrong" in the sense
it had bad image flags. If that is the case there is nothing
simple you can do, b/c the restart file is also wrong. You would
have the same problem if you tried to replicate immediately
after reading the data file (in the 1st run). That is a good test
to try.

The solution is to fix your data file so that the image flags are correct.
Or you could convert the restart file to a data file, and fix the image
flags in that file.

From the replicate doc page:

Bonds and other topology interactions are created between pairs of new
atoms as well as between old and new atoms. This is done by using the
image flag for each atom to "unwrap" it out of the periodic box before
replicating it. This means that molecular bonds you specify in the
original data file that span the periodic box should be between two
atoms with image flags that differ by 1. This will allow them to be
unwrapped appropriately.


What Steve is saying is that your initial data was already flawed, but it did not show until the replication.

I think I found the problem but not the solution yet.

The simulation has had three steps like this:

1st run (version 28Feb):
read data file
write restart1

2nd run (version 1Jul)
read restart1
write restart2

3rd run
read restart2

To check what you suggested, at 3rd run, I started with restart1 by using both lammps versions. The 1Jul version gives the same error but the 28Feb version goes well. Therefore, b/c I have run the second step (which was a very long simulation) with the 1Jul version, replicating causes the problem. So, switching between versions is probably the problem. I need to mention that I did not define any image flag in my initial data file. So, all of them should be 0 by default.

With these information do you have any idea?

Thanks again,

Does your initial data file have any bonds that cross a periodic boundary?
If so, then all image flags = 0 is "incorrect", and will cause a problem
when you eventually replicate. If not, then there could be some change
in restart file formats between versions that I am not remembering.


No, all bonds were inside simulation box. And as I explained in the last email, replicating the restart1 file did not cause any problem. It shows that that restart file had correct image flags.


Then my guess is, it is some incompatibility between the restart files from
different versions. There was one change to image flags over that time
period to allow for larger image flags, but it should only be an issue
if you compile with
-DLAMMPS_BIGBIG, which is not the default.


I extracted a data file out of the last restart file and tried to use that data file. I turned all image flags to “0” and in another attempt just deleted the image flags (The flag values were like -511,512, etc.). Both give the same error upon replication. I was thinking that by using the data file that image flags issue might be solved. Do you have any idea about editing the data file or the way of producing it in order to overcome the problem?


I've had issues with restart files before. Of coarse, if you have
a data file file ("orig_file.data" in the example below) which has the
correct number of atoms and bonds in it, then you can overwrite the
coordinates of the atoms in this data file with the coordinates from
the last frame of your dump file. You can use the new data file
("new_file.data" in the example) to start your simulations. This way
you can bypass your corrupted restart file. (You can probably do this
in pizza.py.)
   Alternately, I don't know if this helps but I attached a python
program which can do this. It is called "dumpy2data.py" and the
syntax is the following:

./dump2data.py -atom-style "full" orig_file.data \
                        < dump.lammpstrj > new_file.data

orig_file.data is your old DATA file. This extracts coordinates from
the last frame of the trajectory file (named "dump.lammpstrj" in this
example), and saves the resulting data file to "new_file.data".
If you don't want to use the last frame of the dump file, you can
invoke it this way:

./dump2data.py -time 350000 -atomstyle "full" orig.data \
                        < dump.lammpstrj > new_file.data

...for example.
I can't remember if this python program works with all dump styles. (I
know it does not like scaled coordinates). However I think it works
with the other common styles. Try it and see. (If it does not work,
it will crash, so you don't have to worry about strange things

This might not solve your problem, but at least you can find out if
there is a problem with your restart file.

Good luck.

dump2data.py (42.9 KB)

Can I ask one simple question, Hasan?

Is your system periodically bonded such as (CNT, Graphene)? Think of it as highly crosslinked system with no end atoms. I have had problems replicating such systems irrespective of what images flags I used. The non bonded energy will scale as it should but bonded energy terms increased drastically. After giving it lot of unsuccessful tries, I had to write my own code (which I did not want to) and assign bonds, angle, dihedrals, impropers etc. (It was few years ago).


If the image flags were -511,512 in the data file then that is an error.
There was a glitch in the restart2data tool a few months back when
we changed the format of image flags in main LAMMPS, that was doing
something like that. The current version should be fixed.

If you start with a data file with no image flags, there should be no
problem in replicating with it. If this is not the case, please post
your data file and input script (with the replicate command) to illustrate
the problem.


In your first email, you said "I think some atoms get very close to
each other after replicating and a very high potential energy and high
negative pressure are resulted as seen in the first time step after

The best way to figure out what is going on is to visualize your
system. What does the system look like? Now that you have a data
file, you can look at it in VMD. In case you don't know, I'm sending
some instructions how to use topotools in VMD to look at your data
This requires VMD 1.8.7 or later and topotools 1.2 or later. (Older
versions, like VMD 1.8.6, don't support this.)


a) Start VMD
b) Menu Extensions->Tk Console
c) Enter:

topo readlammpsdata MY_FILE.data full

(I assume that the the DATA file is called "MY_FILE.data", and that
you are using "atom_style full". You can create a PSF file, which is
useful for looking at trajectories later using: "animate write psf

You should check if your periodic boundary conditions are too small.
    To do that:
       select Graphics->Representations menu option
       click on the "Periodic" tab, and
       click on the "+x", "-x", "+y", "-y", "+z", "-z" checkboxes.

If atoms are overlapping, it should be visible at this time.


  It may be easier to see what went wrong if you wrap coordinates of
each molecule so that they appear in the same unit cell. Try this:

a) Start VMD
b) Menu Extensions->Tk Console
c) Enter:

    pbc box
    pbc wrap -compound res -all

Is your system periodically bonded such as (CNT, Graphene)?

If by this, you mean a system that is infinitely bonded, then the replicate
command is not smart enough to deal with it. The simplest example
is a linear polymer chain that bonds to itself at the periodic box boundary,
so it is really a loop.

For this kind of system it is impossible
to create a set of consistent image flags, so replicate gets confused. What
it would have to do is break the loop, insert new bonds, and close the loop
again for the larger replicated box. It has no logic to do something that

But the original post on this says he has no bonds overlapping the periodic
boundaries at all.


My system includes graphene sheets and octadecane chains as solvent. Actually I have done crystallization of such a system. I replicate the crystallized system in the direction perpendicular to the graphene sheets. So the problem is not due to the bonds in graphene sheets. In the restart file some bonds (in octadecane molecules) are crossing boundaries but in the original data file they do not. It happens after some time steps simulations. I have attached an image before replication.

These are some points I found out after different attempts:

  • The produced data file from the restart file and deleting image flags works well without replication but not with replication.
  • As the image shows, some bond are crossing the boundaries.
  • I re-started the simulations with the 28 Feb version. I took the resulted restart file after some time steps and the problem with replication does not show up.

The produced data file and my input file are also attached. In this data file, I switched the flags to “0”. I have just removed all unnecessary command lines in my input file to be read easier.



data.octgr (5.28 MB)

in.graphene (1.67 KB)

In third point, just for clarification, I mean I re-started from the initial restart file at stage 1(before crystallization).