[lammps-users] Question about fix_wall_region routine

Hello,

I am creating a class based on the fix_wall_region class.
There is something i do not understand in this class.

After calculating the Energy contribution and resulting force of a
wall-atom interaction, the resulting scalar force is multiplied by the
vector separating the wall and the atom. (Lines 235-241 of
fix_wall_region.cpp)

        ewall[0] += eng;
        fx = fwall * region->contact[m].delx;
        fy = fwall * region->contact[m].dely;
        fz = fwall * region->contact[m].delz;
        f[i][0] += fx;
        f[i][1] += fy;
        f[i][2] += fz;

Where region->contact[m].delx , y or z are the components of the
shortest vector between the atom and a wall (if I have correctly
understood the region class).

I understand the conversion from a scalar force to a vectorial form of
the force.
However, the scalar expression of the force should be multiplied with a
normed vector and not with a distance.
In the latter case we calculate an energy and not the force itself.

Can someone explain me why the scalar force is multiplied by a distance ?

Thanks in advance.

Dear Rémi,

If I remember correctly, this is because for efficiency reasons fwall
is defined as:

fwall = (1/r)(dE/dr).

Therefore fx = (dE/dx) = (dE/dr)(dr/dx) = (x/r)(dE/dr) = x*fwall.

Best,
Laurent

Dear Laurent,

Many thanks for your answer.
My problem is solved.

Best.

Rémi

I think you were correct - the 1/r factor in force is missing
in fix wall/region. This was copied code from fix wall which
didn't need it since those forces were always in a single
dimension.

I've posted a patch for this, 6Feb11.
Let me know if you disagree.

Steve

Hello Steve,

I agree with your corrections and the difference between the previous
fix wall and fix wall region classes.

I applied the patch and corrected my own fix.

All seems to work well now.

Many thanks for your answers.