Problem with "cutlj" not re-initialized when restart file used and pair is deleted and not reallocated at same address.

Problem with "cutlj" not re-initialized when restart file used and pair is deleted and not reallocated at same address.

I'm not a real LAMMPS user myself, but I helped debug a LAMMPS issue
using a proprietary test case and encountered the following problem.
(The test case is proprietary, so I'm unable to supply it.)

The version of LAMMPS being used was "24 Apr 2010". I also tried
with the newer "20 Oct 2011" version of LAMMPS, but the existing restart
file was not compatible with the newer version of LAMMPS, so I can't
comment on whether the issue has been fixed or not.

The test case used the following pair_style...
  pair_style airebo 2.871323 1 0
... which results in the "cutlj" field of PairAIREBO (of pair_airebo.h)
to be set to 2.871323.

However, when reading the restart file, ReadRestart::force_fields()
(of read_restart.cpp) calls force->create_pair() (of force.cpp) which deletes
the existing pair and creates a new one.

If the newly create pair is allocated in the same space as the original pair,
then the previous "cutlj" is reused and all appears well, but if the new pair
is allocated in a different location, then "cutlj" can take on a garbage value
since "cutlj" is never initialized again and incorrect result are obtained.

Is this somehow a user error?

Or a problem with the restart file that doesn't result in "cutlj" being
initialized when the restart file is used?

Or simply a LAMMPS coding error regarding the initialization of "cutlj" when
a restart file is used?

hi donald,

Problem with "cutlj" not re-initialized when restart file used and pair is deleted and not reallocated at same address.

[...]

If the newly create pair is allocated in the same space as the original pair,
then the previous "cutlj" is reused and all appears well, but if the new pair
is allocated in a different location, then "cutlj" can take on a garbage value
since "cutlj" is never initialized again and incorrect result are obtained.

Is this somehow a user error?

yes. here is the corresponding entry from the documentation:

These pair styles do not write their information to binary restart
files, since it is stored in potential files. Thus, you need to
re-specify the pair_style and pair_coeff commands in an input script
that reads a restart file.

cheers,
    axel.

This is a bug, but your input script must be using the pair styles
in an odd way. Several pair styles do not store restart info,
so you have to re-specify them in your restart input script or
you will get an error message. For AIREBO you need something
like this

pair_style airebo 3.0 1 1
pair_coeff * * ../potentials/CH.airebo C H

in your restart script, after you read the restart file,
else you will get an error message:

ERROR: All pair coeffs are not set (pair.cpp:142)

But if you comment out the pair_style line, you would
see the bug you mention. Only a couple pair styles
have this problem - I'll fix them.

So the solution for you, is list both the pair_style and pair_coeff
lines in your restart input script (after you read the restart file).

Thanks,
Steve