[lammps-users] none style for bonding interaction


The current release of lammps does not support the "none" sub-style in a 'hybrid' style.
E.g. "dihedral_style hybrid harmonic none" will lead to an error "Dihedral style hybrid cannot have none as an argument".
This is not a problem in early version like may08. The documents and the source indicate that
"none" style can still be defined by dihedral_coeff command even it's not allowed in dihedral_style hybrid command.
I did this (with several dihedral angles defined with none style) but got "segmentation fault" on Linux.
Then I tried to debug the problem and found in "dihedral_hybrid.cpp" when a dihedral angel is defined
as none, in DihedralHybrid::coeff function I found this
  // set setflag and which type maps to which sub-style
  // if sub-style is none: set hybrid setflag, wipe out map

  for (int i = ilo; i <= ihi; i++) {
    if (none) {
      setflag[i] = 1;
      map[i] = -1;
    } else {
      setflag[i] = styles[m]->setflag[i];
      map[i] = m;
The 'map' array elements are set to '-1'. But later in DihedralHybrid::compute where the
actual computation of energy is executed, the 'map' array is used in this way

    for (i = 0; i < ndihedrallist_orig; i++) {
      m = map[dihedrallist_orig[i][4]];
      n = ndihedrallist[m];
      dihedrallist[m][n][0] = dihedrallist_orig[i][0];
      dihedrallist[m][n][1] = dihedrallist_orig[i][1];
      dihedrallist[m][n][2] = dihedrallist_orig[i][2];
      dihedrallist[m][n][3] = dihedrallist_orig[i][3];
      dihedrallist[m][n][4] = dihedrallist_orig[i][4];

Note the 2nd line in above code snippet, m is -1 when a dihedral_coeff none is issued,
add in the following statements m is used as array index, which causes the memory usage violation.
(similar issue can also be found at line 77 in that file)

I would like to understand the followings:
1. why was the 'none' style support removed from 'dihedral_style hybrid'? Is there some reason?
I think it's more reasonable to include it IMHO.
2. Did I use the commands incorrectly? Could you please point me out the correct way to use 'none'
style in the current version? (I had not problem with the early version)
3. In case it's a bug, similar issues exist for bond_style hybrid, angle_style hybrid too.

Hope to get an answer or solution soon! Thanks!


Posted a patch for this bug today.