How to wrap atoms into simulation box with read_data

Hello,

I have a script that generates molecule files that can be read into LAMMPS using read_data. My problem is that this file can generate molecules that lie outside of the simulation box. When reading into a periodic boundary system this is not a problem, but trying to read into a fixed boundary box causes an error. What is the best way to reposition the atoms when reading the data file?

Here the relevant part of the LAMMPS script:

 \# Initialization
 units        real
 boundary    f f f
 atom\_style    molecular
 log         log\.$\{simname\}\.txt
 read\_data    $\{fname\}

This causes an error as the atoms are outside of the box defined in the atom data file.

I found a way around this, basically I change the atom images and box boundary conditions after loading the data file.

 \# Initialization
 units        real
 boundary    p p p
 atom\_style    molecular
 log         log\.$\{simname\}\.txt
 read\_data    $\{fname\}
 set atom \* image 0 0 0
 change\_box all boundary f f f

But I was wondering is a better way?

Thanks

Hello,

I have a script that generates molecule files that can be read into LAMMPS
using read_data. My problem is that this file can generate molecules that
lie outside of the simulation box. When reading into a periodic boundary
system this is not a problem, but trying to read into a fixed boundary box
causes an error. What is the best way to reposition the atoms when reading
the data file?

​this is a bug in your script. if atoms are outside the box with fixed
boundaries, then either your script is not properly checking where atoms
are placed or your box dimensions are incorrect.
LAMMPS does the only meaningful thing and discards atoms that are outside
the box. after all, *you* request the box dimensions.​

Here the relevant part of the LAMMPS script:

    # Initialization
    units real
    boundary f f f
    atom_style molecular
    log log.\{simname\}\.txt     read\_data {fname}

This causes an error as the atoms are outside of the box defined in the
atom data file.

I found a way around this, basically I change the atom images and box
boundary conditions after loading the data file.

    # Initialization
    units real
    boundary p p p
    atom_style molecular
    log log.\{simname\}\.txt     read\_data {fname}
    set atom * image 0 0 0
    change_box all boundary f f f

But I was wondering is a better way?

​what if part of a molecule is outside the box? with this "hack" different
parts of the same molecule will end up on different ends of ​the box.

fix your script to produce valid data files and there are no problems.

axel.