Closed noeblassel closed 2 years ago
Thanks for spotting this and describing it clearly, I pushed a fix.
Definitely interested in the spline cutoff PR if you have time.
I found your repo at https://github.com/noeblassel/MolecularDynamicsJulia and it looks interesting. Sorry if the Molly interface has been changing a lot recently, but I think the changes are better in the long term. In particular I am going to write all future simulators in a vectorised way so they work with GPU and AD, I just removed the in-place version of VelocityVerlet
yesterday.
Thanks! I posted a pull request with the spline cutoff yesterday, didn't find the time to give a thorough explanation of the proposed changes yet.
I believe there is a sign mistake in function
potential_cutoff(cutoff::ShiftedForceCutoff, r2, inter, params)
at cutoffs.jl at line 92,potential(inter, r2, invr2, params) - (r - rc) * fc - potential(inter, cutoff.sqdist_cutoff, cutoff.inv_sqdist_cutoff, params)
should readpotential(inter, r2, invr2, params) + (r - rc) * fc - potential(inter, cutoff.sqdist_cutoff, cutoff.inv_sqdist_cutoff, params)
. Indeed the correction should subtract the derivative of the potential, not the force. The (exagerated) effect can be seen on the following pictures (the "linear correction" curves):Current version![cutoffs_original_exagerated](https://user-images.githubusercontent.com/62473139/155312189-7f04ee79-edf5-4ec6-bdee-451748004a11.png)
Correct version![cutoffs_exagerated](https://user-images.githubusercontent.com/62473139/155312352-f3fcd274-2925-4a11-90e9-dc3fece1f219.png)
I also implemented a spline interpolating cutoff, I can open a PR for it if you are interested.