Fix store/state accumulating vs updating when storing a fix or compute

Dear lammps-users,

It seems like fix store/state doesn't update its values when it stores fixes every so many steps but rather adds them to a running total. See the script below for an example, where a compute reduce averages the per-atom kinetic energy periodically stored by a fix store/state. This average kinetic energy is converted to a temperature variable v_my_temp, which always increases rather than stabilizing when thermostatting the system.

In fix_store_state.cpp, I can see that for when which[m]==KEYWORD, the pack functions set rather than add, but when which[m]==COMPUTE or FIX, the values[i][m] array is always added to. I can only find a place where the values array is zeroed in the constructor.

-Ben

that’s a bug - just replace the 4 cases of “+=” with “=”.
that was code copied from somewhere else, hence
the bug. You’re probably the first person to use
fix store/state for a compute or fix - the normal usage
has been internally to store coords.

Bug fix will be in the next patch.

Thanks,
Steve