Hi everyone,
I think i encountered a problem with fix temp/csld (FKA temp/csvr) when using biasing.
Let me explain the issue by the example of using compute temp/com. The desired behavior is that the fix group will have the same com velocity components before and after application of the thermostat. Other dof are thermostatted.
What happens in the code is that, when mixing old velocities (stored in the vhold array) with the new ones (v), remove_bias is first called on vhold, and afterwards, restore_bias is applied to the final combined velocities (in v). However: this approach doesn’t work.
In the case of temp/com, the bias that is removed and added again is the com velocity. This property is only calculated when compute_scalar() is called. The last time it was called in this scenario, however, is when the v array already was holding the new (unscaled) velocities.
When using temp/partial, this isn’t an issue. However, the current implementation still modifies the velocity component that should be untouched, because the bias in the new, random, velocity distribution is left untouched. Similarly, regions that should no be thermostatted according to temp/region still have their velocities changed (because the corresponding velocities in the random distribution are left untouched, whereas they should have their removed).
Sorry for the long explanation, but I tried to sketch the problem as clearly as possible. I’ve attached a patch that should fix these issues, which it does by changing the order of events a bit:
- Call compute_scalar()
- Calculate mixing factors
- Remove bias from v
- Copy a v*c1 to vhold
- Restore bias on vhold
… - Calculate scaling factor for new distribution (calling compute_scalar() again)
- Remove bias from v
- Combine v and vhold
The patch seems to work, but I’m not sure whether it accurately covers all possible cases. Or maybe I’ve misinterpreted the desired behavior of the biasing handling.
Kristof
csld_bias.diff (3.36 KB)