fix store/force + compute atom/molecule + fix ave/time = error:Segmentation fault

Dear LAMMPS users and developers,

sorry for the second e-mail today but I encountered another strange problem.

LAMMPS version : 26Nov2014 (patched compute_atom_molecule.cpp)

Previous case: I want to measure the force on a small molecule (“object”) before the application of a constrain that would eliminate the z-component of the force:

fix 1 object store/force #Calculate the forces on a per-atom array for the object
compute 1 object atom/molecule f_1[3] # Compute the z-force on the molecule based on the 3rd column of the array

New Problem:

If I do not print or calculate the compute, no problem appears and the system runs normally, but if I add:

fix 2 object ave/time 1 1 50 c_1[1] mode scalar file force_z.dat

or:

variable 1 equal c_1[1]

fix 3 all print 50 “${1}” file test.dat

I get the following error at step 50 (Nfrequency=50):

Step Temp PotEng TotEng Press Volume
0 0 28536.346 28536.346 -12426.98 299595.84
[SEMS-PHD-D1:27395] *** Process received signal ***
[SEMS-PHD-D1:27395] Signal: Segmentation fault (11)
[SEMS-PHD-D1:27395] Signal code: Address not mapped (1)
[SEMS-PHD-D1:27395] Failing at address: 0x149ed920820
[SEMS-PHD-D1:27395] [ 0] /lib/x86_64-linux-gnu/libpthread.so.0(+0x10340) [0x7fed3639c340]
[SEMS-PHD-D1:27395] [ 1] lammps() [0x491f51]
[SEMS-PHD-D1:27395] [ 2] lammps() [0x853c5d]
[SEMS-PHD-D1:27395] [ 3] lammps() [0x8514ac]
[SEMS-PHD-D1:27395] [ 4] lammps() [0x5f75cc]
[SEMS-PHD-D1:27395] [ 5] lammps() [0x5794ae]
[SEMS-PHD-D1:27395] [ 6] lammps() [0x61ddd8]
[SEMS-PHD-D1:27395] [ 7] lammps() [0x85c636]
[SEMS-PHD-D1:27395] [ 8] lammps() [0x832d42]
[SEMS-PHD-D1:27395] [ 9] lammps() [0x5ffb96]
[SEMS-PHD-D1:27395] [10] lammps() [0x5fe2a1]
[SEMS-PHD-D1:27395] [11] lammps() [0x5fecc5]
[SEMS-PHD-D1:27395] [12] lammps() [0x40f5b6]
[SEMS-PHD-D1:27395] [13] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7fed35fe7ec5]
[SEMS-PHD-D1:27395] [14] lammps() [0x4112ff]
[SEMS-PHD-D1:27395] *** End of error message ***

Dear LAMMPS users and developers,

sorry for the second e-mail today but I encountered another strange problem.

LAMMPS version : 26Nov2014 (patched compute_atom_molecule.cpp)

Previous case: I want to measure the force on a small molecule ("object")
before the application of a constrain that would eliminate the z-component
of the force:

fix 1 object store/force #Calculate the forces on a per-atom array for
the object
compute 1 object atom/molecule f_1[3] # Compute the z-force on the
molecule based on the 3rd column of the array

New Problem:

If I do not print or calculate the compute, no problem appears and the
system runs normally, but if I add:

fix 2 object ave/time 1 1 50 c_1[1] mode scalar file force_z.dat

or:

variable 1 equal c_1[1]

fix 3 all print 50 "${1}" file test.dat

I get the following error at step 50 (Nfrequency=50):

Step Temp PotEng TotEng Press Volume
       0 0 28536.346 28536.346 -12426.98 299595.84
[SEMS-PHD-D1:27395] *** Process received signal ***
[SEMS-PHD-D1:27395] Signal: Segmentation fault (11)

the code in the compute is only executed, if its data is used. hence
you get only a problem when you try to access the data.

[...]

Also for testing (without any constrain on the object yet), I calculate the
z-force as:

compute 1 object property/atom fz
compute 2 object atom/molecule c_1
fix 1 object ave/time 1 1 50 c_2[1] mode scalar file force_z.dat

and it works without any issues.

I would really appreciate any extra suggestions!

it looks like you stumbled over some more issues. i have made some
changes in LAMMPS-ICMS that should fix that as well (you need to
update compute.cpp and compute_atom_molecule.cpp again). this whole
thing starts looking more and more like something that we never
properly tested or used in a very different way and hence my changes
may break other uses. they are according to how things "should" be
done, though.

please update and let us know.

thanks,
     axel.

Dear LAMMPS users and developers,

sorry for the second e-mail today but I encountered another strange problem.

LAMMPS version : 26Nov2014 (patched compute_atom_molecule.cpp)

Previous case: I want to measure the force on a small molecule ("object")
before the application of a constrain that would eliminate the z-component
of the force:

fix 1 object store/force #Calculate the forces on a per-atom array for
the object
compute 1 object atom/molecule f_1[3] # Compute the z-force on the
molecule based on the 3rd column of the array

New Problem:

If I do not print or calculate the compute, no problem appears and the
system runs normally, but if I add:

fix 2 object ave/time 1 1 50 c_1[1] mode scalar file force_z.dat

or:

variable 1 equal c_1[1]

fix 3 all print 50 "${1}" file test.dat

I get the following error at step 50 (Nfrequency=50):

Step Temp PotEng TotEng Press Volume
       0 0 28536.346 28536.346 -12426.98 299595.84
[SEMS-PHD-D1:27395] *** Process received signal ***
[SEMS-PHD-D1:27395] Signal: Segmentation fault (11)

the code in the compute is only executed, if its data is used. hence
you get only a problem when you try to access the data.

[...]

yes, yes indeed. I only mentioned it to make clear that this was the
actual source of the error.

Also for testing (without any constrain on the object yet), I calculate the
z-force as:

compute 1 object property/atom fz
compute 2 object atom/molecule c_1
fix 1 object ave/time 1 1 50 c_2[1] mode scalar file force_z.dat

and it works without any issues.

I would really appreciate any extra suggestions!

it looks like you stumbled over some more issues. i have made some
changes in LAMMPS-ICMS that should fix that as well (you need to
update compute.cpp and compute_atom_molecule.cpp again). this whole
thing starts looking more and more like something that we never
properly tested or used in a very different way and hence my changes
may break other uses. they are according to how things "should" be
done, though.

please update and let us know.

I recompiled LAMMPS with the corrected files and ran several
combinations. So far everything works as expected! Tomorrow, I will run
the actual production simulations but I believe no extra problems will
arise.

Thank you VERY much Axel for the prompt corrections on both problems.

Best regards,
Michalis

Hi developers,

I want to write an new pair style via modifying the lj/cut.cpp。

In the new style, the interaction was confined by two pariticle orentation (via using the dipole style), i.e. if the angle between two particle orentation is smaller than a value, the interaction was calculated. The Lj expressions does not changed.

I have modified the function of PairLJCut::compute() for my target. However, I do not know whether the PairLJCut::single() should be modified. It just do calculate the interaction between i and j particles without cutoff. I wonder its function. Why not the judgement of cutoff distance. Is there relationship between single() and compute()?

///////////////////////////

double PairLJCut::single(int i, int j, int itype, int jtype, double rsq,
double factor_coul, double factor_lj,
double &fforce)
{
double r2inv,r6inv,forcelj,philj;

r2inv = 1.0/rsq;
r6inv = r2invr2invr2inv;
forcelj = r6inv * (lj1[itype][jtype]r6inv - lj2[itype][jtype]);
fforce = factor_lj
forcelj*r2inv;

philj = r6inv*(lj3[itype][jtype]r6inv-lj4[itype][jtype]) -
offset[itype][jtype];
return factor_lj
philj;
}

Thanks in advance,

Wade

from China

Hi developers,

I want to write an new pair style via modifying the lj/cut.cpp。

In the new style, the interaction was confined by two pariticle orentation
(via using the dipole style), i.e. if the angle between two particle
orentation is smaller than a value, the interaction was calculated. The Lj
expressions does not changed. ‍

I have modified the function of PairLJCut::compute() for my target. However,
I do not know whether the PairLJCut::single() should be modified. It just
do calculate the interaction between i and j particles without cutoff. I
wonder its function. Why not the judgement‍ of cutoff distance. Is there
relationship between single() and compute()?‍‍

PairXX::compute() is used during time integration to compute forces,
energies and stress as needed and determined by the neighbor lists.
PairXX::single() is called by modules in LAMMPS like the group/group
compute that need force/energy information for specific pairs or lists
of pairs.
you can skip the implmentation of the PairXX:single() method, but then
you have to set the variable single_enable in the constructor to 0.

axel

Also the other commands/classes that call the single()

function check the cutoff before calling it. Thus it will
not be called if the I,J pair of atoms are further apart
than the cutoff for those 2 atom types.

Steve