Dear LAMMPS developers,

Hi, I ran into a bug in dist uniform of velocity command. When I ran a simulation with heterogeneous system such as water with membrane, water and membrane had non-zero momentum after velocity create all.

I have looked into the file ‘velocity.cpp’ and found that it makes net momentum of the group specified in velocity command to zero, but groups of specific element still have non-zero momentum.

vx = random->uniform()

factor = 1.0/sqrt(mass[type[m]]);

v[m][0] = vx * factor;

if (momentum_flag) zero_momentum();

rescale(t, t_desired);

Here’s a part of the code. It generates uniform distribution and scale it by mass factor, zero the total momentum and rescale it by temperature factor. But random->uniform() generates uniform distribution from 0 to 1. Therefore, for example, after multiplying mass factor, the group of hydrogens will have vx of 0 to 10 and the group of silicons will have vx of 0 to 1. Zeroing total momentum would bring vx of hydrogens to something like -1 to 9, silicons to -1 to 0.

I think the initial distribution generated should be symmetric like -1 to 1, or zeroing momentum should be performed before multiplying factors.

Regards,

Dongsun