pair::settings() member function only intended for pairs of unlike atom types?

Dear LAMMPS-developers,

I have a question concerning the settings member function as defined in many of the available pair styles, like pair_lj_cut.cpp. As far as I’ve seen, these functions reset the cutoffs for atom type pairs that have been explicitly set. And, I wanted to use them for that. However, the settings functions only loops over pairs of unlike atom types. Is that the intended behavior? I would have thought it to be quite useful to be able to change, e.g., the cutoff for all atom type pairs. Is that maybe possible in another, (more or less) straightforward way from, e.g., a compute class?

Any help appreciated. Thanks and cheers,

Frank

In all the pair styles (not just lj/cut), the settings() method is

what is called when you use a “pair_style” command in your

input script. The coeff() method is called when you

use a “pair_coeff” command.

You’re allowed to invoke pair_style lj/cut a 2nd time,

after coeffs are defined, to change the global cutoff. From

the pair_style doc page (not the pair lj/cut doc page):

Typically, the global cutoff value can be overridden for a specific pair of atom types by the pair_coeff command. The pair style settings (including global cutoffs) can be changed by a subsequent pair_style command using the same style. This will reset the cutoffs for all atom type pairs, including those previously set explicitly by a pair_coeff command. The exceptions to this are that pair_style table and hybrid settings cannot be reset. A new pair_style command for these styles will wipe out all previously specified pair_coeff values.

So that is why these lines are in settings():

// reset cutoffs that have been explicitly set

if (allocated) {
int i,j;
for (i = 1; i <= atom->ntypes; i++)
for (j = i+1; j <= atom->ntypes; j++)
if (setflag[i][j]) cut[i][j] = cut_global;
}
}

But I don’t know why it is not j = i, instead of j = i+1.

Seems like a bug, but probably uncommonly encountered

since most users likely never re-use a pair_style

command (for the same style), and even more rarely

to override a I,I coeff set by the pair coeff command.

Maybe Axel will see something with that logic

that I don’t …

Steve

In all the pair styles (not just lj/cut), the settings() method is
what is called when you use a "pair_style" command in your
input script. The coeff() method is called when you
use a "pair_coeff" command.

You're allowed to invoke pair_style lj/cut a 2nd time,
after coeffs are defined, to change the global cutoff. From
the pair_style doc page (not the pair lj/cut doc page):

Typically, the global cutoff value can be overridden for a specific pair
of atom types by the *pair_coeff*
<http://lammps.sandia.gov/doc/pair_coeff.html> command. The pair style
settings (including global cutoffs) can be changed by a subsequent
pair_style command using the same style. This will reset the cutoffs for
all atom type pairs, including those previously set explicitly by a
*pair_coeff* <http://lammps.sandia.gov/doc/pair_coeff.html> command. The
exceptions to this are that pair_style *table* and *hybrid* settings
cannot be reset. A new pair_style command for these styles will wipe out
all previously specified pair_coeff values.

So that is why these lines are in settings():

  // reset cutoffs that have been explicitly set

  if (allocated) {
    int i,j;
    for (i = 1; i <= atom->ntypes; i++)
      for (j = i+1; j <= atom->ntypes; j++)
        if (setflag[i][j]) cut[i][j] = cut_global;
  }
}

But I don't know why it is not j = i, instead of j = i+1.
Seems like a bug, but probably uncommonly encountered
since most users likely never re-use a pair_style
command (for the same style), and even more rarely
to override a I,I coeff set by the pair coeff command.

Maybe Axel will see something with that logic
that I don't ...

​it is a bug and it has been present in the LAMMPS sources since the
beginning of time (aka the start of the subversion repository) about 11
years ago, so it is probably even older. to achieve the documented behavior
of the pair_style command, the loop has to be changed. here is a small
input, where this can be tested by looking at the PairIJCoeff sections of
the data files.

region box block 0 1 0 1 0 1
create_box 3 box


mass * 1.0

pair_style lj/cut 5.0
pair_coeff 1 1 1.0 1.0 4.0
pair_coeff 2 2 2.0 1.0
pair_coeff 3 3 1.0 1.0 2.0


write_data test1.data pair ij

pair_style lj/cut 6.0
pair_coeff 2 2 2.0 1.0 3

write_data test2.data pair ij

this will apply to more pair styles... i'll take a look and create a pull
request.

axel.

pull request is filed as #485 https://github.com/lammps/lammps/pull/485

axel.

Ok, thanks for the clarification and fixing. I’ll try to use it to my advantage and come back to you if I encounter further issues.

Frank