Reset array from fix

Submitted by jagan1mohan on Fri, 12/11/2020 - 13:51

Hello friends, I created an array in hooke model to dump vdw force components. The values are accumulating over time. Let us say, I have two particles that are coming closer, colliding, and moving away in 10 steps. Here are a few details.

step fvdw fc
1 0 0
2 0 0
3 non-zero 0
4 non-zero non-zero // Collision
5 non-zero non-zero // Collision
6 non-zero non-zero // Collision
7 non-zero 0
8 non-zero 0
9 non-zero 0
10 0 0

To check the implemented math, I have hand calculated all the values in the above list. What I observe is
A. When I plot variables (fx or fy or fz) which are default, they show the instantaneous value in that time step.
B. When I plot variables (fvdw[1 -3]), they are accumulating value with time. That is, at step 10, it should be zero but is equal to the sum of all forces in the 9 steps above.

I have coded following statements to take values into this new dump variables.
vdwDump_i[0] += -Fn_vdw*sidata.en[0];
vdwDump_i[1] += -Fn_vdw*sidata.en[1];
vdwDump_i[2] += -Fn_vdw*sidata.en[2];
vdwDump_j[0] += Fn_vdw*sidata.en[0];
vdwDump_j[1] += Fn_vdw*sidata.en[1];
vdwDump_j[2] += Fn_vdw*sidata.en[2];

C. Should I not use += in the above statements? I think this is needed to take account of multiple interactions occurring at the same time on a given particle.

D. The fix definition is as follows.
if(!fix_vdw_)
{
const char* fixarg[11]; // An array of 11 entries starting from 0.
fixarg[0] = "vdw";
fixarg[1] = "all";
fixarg[2] = "property/atom";
fixarg[3] = "vdw";
fixarg[4] = "vector"; // 1 vector per particle is registered
fixarg[5] = "no"; // Restart
fixarg[6] = "yes"; // Communicate ghost
fixarg[7] = "no"; // Communicate rev
fixarg[8] = "0.0";
fixarg[9] = "0.0";
fixarg[10] = "0.0";
fix_vdw_ = modify->add_fix_property_atom(11, const_cast(fixarg), "normal_model hooke");
}
I tried changing fixarg[5] and/or fixarg[6] to "yes" and "no" combinations but the behavior did not change. How to address this situation? Can we reset this array to 0 every time the timestep begins.

Thank you,
Jagan Mohan.

jagan1mohan | Sat, 12/12/2020 - 17:59

I tried with the " = " operator instead of " += " in the above post.
It works well only when there are 2 particles in the entire domain.

We know that "a += b" in C++ expands into "a  = a + b" and this is needed. When there is a multi-part interaction, the vdw variable stores only the force from the last interaction tracked rather sum of all the forces acting from all its interactions in that time step. I have tested this using a three-particle test setup.

We have to zero this vector, in every time-step and continue to use " += " operator. I tried changing fixarg[5] and/or fixarg[6] to "yes" and "no" combinations but the behavior did not change. I have come across " fix ->set_all(0.0) " method defined in fix_property_atom.h but not sure where to place this inside the source code for my fix.

Does anyone know how to fix this?

Thank you,
Jagan Mohan.

Mateus Kostka | Wed, 04/14/2021 - 09:43

Hello everybody,

can anybody explain me please what is the meaning of the variable sidata.en?

Best regards and thank you

Mateus Kostka