lumol-org / lumol

Universal extensible molecular simulation engine
http://lumol.org/
BSD 3-Clause "New" or "Revised" License
190 stars 18 forks source link

Add WCA #234

Closed gjepson closed 4 years ago

gjepson commented 6 years ago

New WCA code examples, pair potentials. All tests passed.

g-bauer commented 6 years ago

Hey! Thanks for the PR, I'll have a look at it later today.

g-bauer commented 6 years ago

Small nitpick: Not sure if rust does this for us, but you could replace f64::powi(s6, 2) with s6 * s6 within the energy and force computation.

I'm not sure I understand the correction terms. Would it make sense to use the regular formulation of tail corrections but using 2^1/6 sigma as upper limit instead of infinity (see here)? We could use such a correction when rc < 2^1/6 sigma and zero if rc > 2^1/6 sigma, or am I missing something?

Do you need help making the potential accessible from input files?

gjepson commented 6 years ago

s6 * s6 works fine as well. I used f64::powi(s6, 2) because it was used in the Lennard-Jones potential implementation. Is there a benefit to using one over the other?

Regarding the cutoffs, I added a new commit which should correct the correction terms. If I'm thinking of this correctly, WCA converges, so this should yield 0 if the cutoff is beyond 2^1/6 sigma, and panic otherwise.

I'll check through the documentation regarding potential accessibility from input files and let you know if I have any questions.

Travis hasn't passed at the time of commenting, so it this may well be moot if it doesn't pass.

Luthaf commented 6 years ago

s6 * s6 works fine as well. I used f64::powi(s6, 2) because it was used in the Lennard-Jones potential implementation. Is there a benefit to using one over the other?

s6 * s6 should be faster, as powi might call a function in libm. Expect from that, there should be no difference.

Luthaf commented 6 years ago

So what is missing here? I'd like to get this to go forward =)

I think this could be merged with some additional regressions tests; something like this:

https://github.com/lumol-org/lumol/blob/0f6efbd38b0bf132af2f912c0b233e5a8829bf02/src/core/src/energy/functions.rs#L643-L658

Testing some specific values for energy and forces, and checking that the force is indeed the derivative of the energy using finite differences.

Support for WCA in input can come later.

Luthaf commented 4 years ago

Closing this due to inactivity. Feel free to create a new PR if you are still interested!