Skip to content

Commit

Permalink
Refactor CalcCoulombVir for more accurate results
Browse files Browse the repository at this point in the history
  • Loading branch information
LSchwiebert committed Sep 24, 2024
1 parent 5c99b6d commit 8c67339
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/FFParticle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ inline double FFParticle::CalcCoulombVir(const double distSq,
if (forcefield.ewald) {
// M_2_SQRTPI is 2/sqrt(PI)
double alphaValue = forcefield.alpha[b] * M_2_SQRTPI;
alphaValue *= std::exp(-forcefield.alphaSq[b] * distSq);
alphaValue += std::erfc(forcefield.alpha[b] * dist) / dist;
return qi_qj * alphaValue / distSq;
double expValue = std::exp(-forcefield.alphaSq[b] * distSq);
double erfcValue = std::erfc(forcefield.alpha[b] * dist) / dist;
return qi_qj * (alphaValue * expValue + erfcValue) / distSq;
} else {
return qi_qj / (distSq * dist);
}
Expand Down

0 comments on commit 8c67339

Please sign in to comment.