Possible Bug in read_data.cpp

One of my colleagues is running into a weird issue where their simulation box size increases when subsequent data files (with no simulation box data) are read in. Here’s the procedure:

  1. Read in the first data file with box length data
  2. Read in four more data files which contain ONLY bond, angle, dihedral, and improper types. There are no atoms or box data.
  3. Run with fix bond/react

The LAMMPS version is Feb 18, 2020.

Here is the output from reading in the data files:

read_data ed1_98_npt_fixed.dat extra/atom/types 5 extra/bond/types 60 extra/angle/types 101 extra/dihedral/types 128 extra/improper/types 67 extra/special/per/atom 20 extra/bond/per/atom 10 extra/angle/per/atom 20 extra/dihedral/per/atom 50 extra/improper/per/atom 20
Reading data file …
orthogonal box = (91.42 65.3325 -10.5939) to (148.58 114.667 40.5939)
2 by 1 by 1 MPI processor grid
reading atoms …
14218 atoms
reading velocities …
14218 velocities
scanning bonds …
14 = max bonds/atom
scanning angles …
26 = max angles/atom
scanning dihedrals …
62 = max dihedrals/atom
scanning impropers …
24 = max impropers/atom
reading bonds …
14998 bonds
reading angles …
26612 angles
reading dihedrals …
35784 dihedrals
reading impropers …
13144 impropers
Finding 1-2 1-3 1-4 neighbors …
special bond factors lj: 0 0 1
special bond factors coul: 0 0 1
4 = max # of 1-2 neighbors
7 = max # of 1-3 neighbors
30 = max # of special neighbors
special bonds CPU = 0.0036246 secs
read_data CPU = 0.239546 secs

read_data pre1.data add append offset 12 19 33 40 25
Reading data file …
orthogonal box = (-0.5 -0.5 -10.5939) to (148.58 114.667 40.5939)
2 by 1 by 1 MPI processor grid
Finding 1-2 1-3 1-4 neighbors …
special bond factors lj: 0 0 1
special bond factors coul: 0 0 1
4 = max # of 1-2 neighbors
7 = max # of 1-3 neighbors
30 = max # of special neighbors
special bonds CPU = 0.002668 secs
read_data CPU = 0.0335797 secs
read_data post1.data add append offset 12 31 53 64 39
Reading data file …
orthogonal box = (-0.5 -0.5 -10.5939) to (148.58 114.667 40.5939)
2 by 1 by 1 MPI processor grid
Finding 1-2 1-3 1-4 neighbors …
special bond factors lj: 0 0 1
special bond factors coul: 0 0 1
4 = max # of 1-2 neighbors
7 = max # of 1-3 neighbors
30 = max # of special neighbors
special bonds CPU = 0.0035382 secs
read_data CPU = 0.0064647 secs
read_data pre2.data add append offset 16 46 77 94 54
Reading data file …
orthogonal box = (-0.5 -0.5 -10.5939) to (148.58 114.667 40.5939)
2 by 1 by 1 MPI processor grid
Finding 1-2 1-3 1-4 neighbors …
special bond factors lj: 0 0 1
special bond factors coul: 0 0 1
4 = max # of 1-2 neighbors
7 = max # of 1-3 neighbors
30 = max # of special neighbors
special bonds CPU = 0.0027499 secs
read_data CPU = 0.0054057 secs
read_data post2.data add append offset 16 65 111 139 77
Reading data file …
orthogonal box = (-0.5 -0.5 -10.5939) to (148.58 114.667 40.5939)
2 by 1 by 1 MPI processor grid
Finding 1-2 1-3 1-4 neighbors …
special bond factors lj: 0 0 1
special bond factors coul: 0 0 1
4 = max # of 1-2 neighbors
7 = max # of 1-3 neighbors
30 = max # of special neighbors
special bonds CPU = 0.0034218 secs
read_data CPU = 0.0050224 secs

The reason I think this is a bug in read_data.cpp is because I looked through read_data.cpp to see how it was setting the box lengths and noticed an interesting match. You may notice that the subsequent data reads show that the orthogonal box goes from -0.5 -0.5 z to the highs of the original data file. Well, -0.5 looks like the default value that is set in line 404 of read_data.cpp. Setting x and y to -0.5 makes sense because read_data only expands the simulation box. This isn’t the desired behavior, but it makes sense.

If there isn’t any box data in a subsequent data file, shouldn’t read_data leave the original box data alone?

Is this indeed a bug? Or something else?

Thanks!
Will

will,

this is the documented behavior. if the box is not provided -0.5 0.5 is used and if you use read_data a second time, box information is “merged” i.e. the minimum of the lower values and the maximum of the higher values is taken. there is no way for LAMMPS to detect whether you do not want to use the default box or not.

so if you do not want the box to be changed, you have to copy the same box data to all data files.

Axel,

Thank you for the clarification. We appreciate the help!

Thanks,
Will

In case anyone else runs into this issue in the future, you can also get around this by changing your box dimensions to -l/2 to l/2 immediately after the first read_data command. As long as your initial box lengths are greater than -0.5 to 0.5, it’ll be fine.

Put this command after your first read_data command:
change_box all x final -(lx/2) (lx/2) y final -(ly/2) (ly/2) z final -(lz/2) (lz/2) remap

Thanks again for the help, Axel!

Thanks so much, guys, Axel thanks for getting back to us on a Sunday, we really appreciate it!!