fix store/force and compute atom/molecule -- per-atom values

Dear LAMMPS users and developers,

I hope you are all well.

I encountered a strange problem while using the fix store/force and compute atom/molecule commands (LAMMPS version 26Nov2014).

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

However this yields the error:
ERROR: Compute atom/molecule fix does not calculate per-atom values (…/compute_atom_molecule.cpp:110)

In the documentation of store/force however says “This fix produces a per-atom array…”, so I am really confused on how to calculate the per-molecule z-force.

Nevertheless, I have spent several hours trying to debug my script and I would be interested to know if whether has any idea on how to overcome this?

Thanks a lot in advance,

Michalis

Dear LAMMPS users and developers,

I hope you are all well.

I encountered a strange problem while using the fix store/force and compute
atom/molecule commands (LAMMPS version 26Nov2014).

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

However this yields the error:
ERROR: Compute atom/molecule fix does not calculate per-atom values
(../compute_atom_molecule.cpp:110)

In the documentation of store/force however says "This fix produces a
per-atom array...", so I am really confused on how to calculate the
per-molecule z-force.

Nevertheless, I have spent several hours trying to debug my script and I
would be interested to know if whether has any idea on how to overcome this?

it would have been better to spend some of the time reading the source code. :wink:
you have discovered a bug and need to change compule atom_molecule.cpp
as follows.

diff --git a/src/compute_atom_molecule.cpp b/src/compute_atom_molecule.cpp
index 4442a72..891f083 100644
--- a/src/compute_atom_molecule.cpp
+++ b/src/compute_atom_molecule.cpp
@@ -106,7 +106,7 @@ ComputeAtomMolecule(LAMMPS *lmp, int narg, char **arg) :
       int ifix = modify->find_fix(ids[i]);
       if (ifix < 0)
         error->all(FLERR,"Fix ID for compute atom/molecule does not exist");
- if (modify->fix[ifix]->peratom_flag)
+ if (modify->fix[ifix]->peratom_flag == 0)
         error->all(FLERR,"Compute atom/molecule fix does not "
                    "calculate per-atom values");
       if (argindex[i] == 0 &&

Thanks Axel for the prompt response. :slight_smile:

I am afraid I am not familiar with this way of updating the source code (yet!) and because a manual attempt did not really work, would it be possible, when you have the time, to send me the corrected .cpp? If not, there is no problem, I will just wait until the release of the next LAMMPS version.

Best regards,
Michalis

Thanks Axel for the prompt response. :slight_smile:

I am afraid I am not familiar with this way of updating the source code (yet!) and because a manual attempt did not really work, would it be possible, when you have the time, to send me the corrected .cpp? If not, there is no problem, I will just wait until the release of the next LAMMPS version.

the change is published in the LAMMPS-ICMS git repository:

http://git.lammps.org/git/?p=lammps-icms.git;a=blob;f=src/compute_atom_molecule.cpp;hb=HEAD

axel.

And will be in the next LAMMPS patch - thanks for finding and fixing this.

Steve