choderalab / alchemy

Alchemical tools for OpenMM
9 stars 3 forks source link

Direct-space PME contribution incorrect if alpha_ewald = 0 #45

Closed jchodera closed 8 years ago

jchodera commented 8 years ago

If the reference System object does not manually specify alpha_ewald for PME, it appears that the direct-space PME contribution is incorrect. The logic in this block does not work as intended, instead skipping the if alpha_ewald == 0.0 clause (since alpha_ewald has units of 1/nm) and using a value of 0 in the calculation of the electrostatic energy expression.

If alpha_ewald is not manually set, it will be determined automatically from the PME tolerance upon Context creation. This is thankfully standardized in NonbondedForceImpl:

    double tol = force.getEwaldErrorTolerance();
    alpha = (1.0/force.getCutoffDistance())*std::sqrt(-log(2.0*tol));