Merge pull request #2367 from ndtrung81/rigid-langevin

Fixed a bug in computing the langevin torques applied to rigid bodies
This commit is contained in:
Axel Kohlmeyer
2020-09-16 22:36:04 -04:00
committed by GitHub
2 changed files with 34 additions and 8 deletions

View File

@ -970,7 +970,7 @@ void FixRigid::apply_langevin_thermostat()
{
if (me == 0) {
double gamma1,gamma2;
double wbody[3],tbody[3];
double delta = update->ntimestep - update->beginstep;
if (delta != 0.0) delta /= update->endstep - update->beginstep;
t_target = t_start + delta * (t_stop-t_start);
@ -991,12 +991,23 @@ void FixRigid::apply_langevin_thermostat()
gamma1 = -1.0 / t_period / ftm2v;
gamma2 = tsqrt * sqrt(24.0*boltz/t_period/dt/mvv2e) / ftm2v;
langextra[i][3] = inertia[i][0]*gamma1*omega[i][0] +
// convert omega from space frame to body frame
MathExtra::transpose_matvec(ex_space[i],ey_space[i],ez_space[i],omega[i],wbody);
// compute langevin torques in the body frame
tbody[0] = inertia[i][0]*gamma1*wbody[0] +
sqrt(inertia[i][0])*gamma2*(random->uniform()-0.5);
langextra[i][4] = inertia[i][1]*gamma1*omega[i][1] +
tbody[1] = inertia[i][1]*gamma1*wbody[1] +
sqrt(inertia[i][1])*gamma2*(random->uniform()-0.5);
langextra[i][5] = inertia[i][2]*gamma1*omega[i][2] +
tbody[2] = inertia[i][2]*gamma1*wbody[2] +
sqrt(inertia[i][2])*gamma2*(random->uniform()-0.5);
// convert langevin torques from body frame back to space frame
MathExtra::matvec(ex_space[i],ey_space[i],ez_space[i],tbody,&langextra[i][3]);
}
}