Merging data-files -> numeric index out of bounds

Hi all,

I ran into an issue when i tried to merge 2 different data-files (all-atom representation,class2-forcefield) using lammps version 27-jul-2015.
My input-script looks as follows:

General

units real
atom_style full
dimension 3
#newton on
boundary p p p

Styles

pair_style lj/class2 9.0
pair_modify shift no mix sixthpower
bond_style class2
angle_style class2
dihedral_style class2
improper_style class2
special_bonds lj 0 0 1 coul 0 0 1

read_data pa6small.data

#extra keywords dont make a difference
#extra/atom/types 1000 extra/bond/types 1000 extra/dihedral/types 1000 extra/improper/types 1000

read_data eprsmall.data add append

thermo 1
thermo_style multi
timestep 0.005

minimize 1e-12 1e-12 5000 10000

I try to attach the data-files to this mail.

Running lammps, i get “ERROR: Numeric index is out of bounds (…/force.cpp:760)” and the last line reported in my log-file is the second read_data command. However, i have no clue what exactly produces this error…

any hints?

regards,
frank.

eprsmall.data (270 KB)

pa6small.data (640 KB)

Hi all,

I ran into an issue when i tried to merge 2 different data-files (all-atom
representation,class2-forcefield) using lammps version 27-jul-2015.
My input-script looks as follows:

# General
units real
atom_style full
dimension 3
#newton on
boundary p p p

# Styles
pair_style lj/class2 9.0
pair_modify shift no mix sixthpower
bond_style class2
angle_style class2
dihedral_style class2
improper_style class2
special_bonds lj 0 0 1 coul 0 0 1

read_data pa6small.data

#extra keywords dont make a difference
#extra/atom/types 1000 extra/bond/types 1000 extra/dihedral/types 1000
extra/improper/types 1000

read_data eprsmall.data add append

thermo 1
thermo_style multi
timestep 0.005

minimize 1e-12 1e-12 5000 10000

I try to attach the data-files to this mail.

Running lammps, i get "ERROR: Numeric index is out of bounds
(../force.cpp:760)" and the last line reported in my log-file is the second
read_data command. However, i have no clue what exactly produces this
error...

any hints?

​as i already told you on the VMD mailing list, you have to make sure that
the types in your data file​s are consistent. this is clearly not the case
in your input. you have more angle, dihedral, and improper types listed in
the second input file. thus LAMMPS doesn't know where to put those.

in LAMMPS the number of atom/bond/angle/dihedral/improper types is locked
in as soon as the simulation box is created, which happens when reading the
first data file. consequently, the number of types in the header section of
the second file is completely ignored. if the types have the corresponding
numbers in the second data file, this is not a problem. if they are
different, you have to properly adjust the numbers in the first data file
and use the corresponding offsets when reading the second data file. please
have a closer look at the documentation of the read_data command and all
the flags and options related to appending a second data file.

as i already noted in the previous e-mail, LAMMPS cannot now from the file
alone what your intentions are, so you have to make them explicit. that is
true for both, processing data files and topology information in VMD and in
LAMMPS. the software simply cannot know it.

axel.

i should probably add the comment, that appending data files is a very new feature and that there are likely some rough edges and bugs looming, particularly with large complex data files, as is the nature of all new core features in program packages as big and complex as LAMMPS.

axel.

Another thing to keep in mind that if the two data files contain
different types of molecules, AND if you use pair_coeff, bond_coeff,
angle_coeff, dihedral_coeff, and improper_coeff commands in an INPUT
script (instead of putting the force-field information in the DATA
file), then you will have to modify the atom-type, bond-type,
angle-type, dihedral-type, and improper-type number which appear in
these commands.

   If the two data files contain completely different kinds of
molecules with no overlap, then you can use the LAMMPS read_data
command with the add, offset, shift, extra, keywords.

   The difficult case is when the two data files share some (but not
all) of the bond, angle, dihedral, and improper types. (Such as would
be the case when the two data files have some molecules or chemical
groups in common.)

Andrew

P.S.
   If your data files do contain overlapping atom, bond, or angle
types, etc..., the conventional way to overcome this problem would be
to manually extract the text from the Angles, Dihedrals, and Improper
sections of the second data file, and carefully change some of the
numbers in the second column of these sections so that they are
compatible. (I suggest using "awk", writing your own simple script,
or using a spreadsheet.) You can probably fix these issues in
topotools as well, and there are other ways to do this.

--- moltemplate ---

   Alternately, the "moltemplate" program has a simple way to get
around these problems. (Please download the newest version from
www.moltemplate.org. I apologize in advance. Nearly all of my posts
here somehow seem to end up being advertisements for my "moltemplate"
program. However in the process of replying to your post, I
discovered and fixed a new moltemplate bug today, so I guess it's a
good thing.)

   Anyway, suppose you have two data files "file1.data", and
"file2.data", and two input scripts ("file1.in", and "file2.in")

ltemplify.py -name Subsystem1 file1.in file1.data > file1.lt
ltemplify.py -name Subsystem2 file2.in file2.data > file2.lt

   Comment: As you can see from the example, you need to supply a
LAMMPS input script(s). The input script should contain an
"atom_style" command which tells "ltemplify.py" how to interpret your
LAMMPS data file. It's okay if it contains only one line:

atom_style full

If you don't have any input scripts, then just create a new file and
put that line in it.
(If your input script also contains "pair_coeff", "bond_coeff",
"angle_coeff", etc... commands for your molecules, then the
"ltemplify.py" will keep track of them, and convert the
atom,bond,angle,... type numbers accordingly, making sure they don't
overlap, etc...)

    Then create a new file "system.lt"

--- system.lt ---
import file1.lt
import file2.lt

subsystem1 = new Subsystem1
subsystem2 = new Subsystem2.move(0,0,50.0)
# The .move() and .rot() commands are useful to prevent overlap
--- end of system.lt ---

    Finally run moltemplate

moltemplate system.lt
or
moltemplate system.lt -vmd # this will display your new system

By default, this will create a new data file named "system.data" where
every atom-type, bond-type, angle-type, dihedral-type, and
improper-type is unique.

Atom types, dihedral types and improper types, will appear in your
file1.lt and file2.lt files as:

@atom:type7
@dihedral:type47
@improper:type13

Now if you want several of the atom types (or angle types), etc to be
shared between the same molecules, (for example "@atom:type7" from
"file1.lt" and "@atom:3" from "file2.lt", corresponding to atom types
7 and 3 from your original file1.data and file2.data files)... THEN
you would replace these with something like:

@atom:../shared_type1

Do this replacement everywhere that "@atom:type7" appears in
"file1.lt" and "@atom:type3" appears in "file2.lt". (You can have
multiple shared atom types. Just make sure they have unique names,
and they are preceeded by "../") Similarly, for angle-types,
bond-types, dihedral_types and improper types use something like this:
@bond:../shared_type1
@angle:../shared_type1
@dihedral:../shared_type1
@improper:../shared_type1

Final comment:
By default, moltemplate will put all of your force-field information
in a lammps input script file named "system.in.settings". If you
prefer to keep all the force-field information in your DATA file
("Coeffs" sections), then run ltemplify.py this way:

ltemplify.py -datacoeffs -name Subsystem1 file1.in file1.data > file1.lt
ltemplify.py -datacoeffs -name Subsystem2 file2.in file2.data > file2.lt

Cheers

Andrew

If you need more information, Appendix B of the moltemplate manual
explains all the boring details regarding how to use ltemplify.py
http://moltemplate.org/doc/moltemplate_manual.pdf