fix_langevin tally and output energy - crash at zeroth step

Dear lammps users,
Lammps crashes when trying to do MPI_Allreduce in compute_scalar method in fix_langevin.cpp. This occurs only when the energy is to be computed at the zeroth step of simulation. Starting from a restart file is free of this problem. The temporary workaround is to disable MPI_Allreduce at step 0. That is, putting ‘if’ conditional at the end of compute_scalar method, like this:

if(update->ntimestep>0)
{
double energy_all;
MPI_Allreduce(&energy_me,&energy_all,1,MPI_DOUBLE,MPI_SUM,world);
return -energy_all;
}
else return 0.;

solves the problem. Not sure whether this solution is optimal but works.

Another reservation concerning thermostating rotational degrees of freedom. I saw the discussion concerning the 10/3 factor which was found necessary to put in omega_thermostat method in the variable gamma1. This factor comes from some difference between friction forces acting on translation 6 Pi eta r and rotation 8 Pi eta r^3. So, upon incorporation of the factor 10/3 everything is OK in omega_thermostat method including the rotational diffusion. However, the same factor has been incorporated to angmom_thermostat. This is definitely incorrect. In case of nonspherical particles the friction forces are not isotropic and not of the form 8 Pi eta r^3. I think that it would be better to get rid of this factor in angmon_thermostat and mention in the manual that fix_langevin does not properly handle the rotational diffusion in the case of nonspherical particles. Of course, thermostating will work well with or without this factor.

Regards
Tomasz

I’m not seeing the first problem. I presume you
are using the current version of LAMMPS and lines
like this in your input script:

fix 2 all langevin 1.0 1.0 10.0 904297 tally yes
fix_modify 2 energy yes

I don’t see any issues with valgrind running on 1 or 2 procs.
The output on step 0 is often 0.0, but that is fine.
Can you send a script that causes the problem?

Re: the 10/3 factor, I’ll review my notes. I recall that
we were ambiguous on the angmom effect, but decided
it was a reasonable approximation. You may be right,
however, that it is better just to do nothing and document
that we don’t.

Steve