espressomd / espresso

The ESPResSo package
https://espressomd.org
GNU General Public License v3.0
224 stars 183 forks source link

Do we need a Brownian Dynamics (BD) integrator ? #1360

Closed bogdan-tanygin closed 4 years ago

bogdan-tanygin commented 7 years ago

Dear ESPResSo team,

My team always had been using the BD integrators for ferrofluid research: regular magnetite ferrofluid, conventional parameters, nothing special. We just need more particles and larger in silico durations.

Main question: are other users requesting this integrator? I'm asking because the SD and BD has been removed: https://github.com/espressomd/espresso/pull/1094

Hence, before moving forward, I've decided to ask an opinion.

pros: at least, in case of the magnetite ferrofluid, BD provides 10-100 times speed up of in silico timeframes which could be simulated compare to Velocity Verlet Langevin Dynamics (VV LD). Stability is also much improved. The reason is simple: BD does not have anymore the restriction time_step < mass / gamma. Also, it is worth to mention, that if we are using real friction coefficients, i.e. gamma_trans and gamma_rot which are calculated according to the translational and rotational Stokes' law and the parameters are real material parameters (not ones selected for a simulation optimization) then VV LD usually is spending most part of computational resources to either translation or rotational motion while keeping an overall computational problem to be not well balanced. The BD does not have these issues.

cons: BD requires just position updates. Velocities are already analytically integrated. Hence, this approach does not organically fits to Velocity Verlet integrator. I've integrated BD directly into ESPResSo VV integrator for my personal usage. Architecturally it looks a bit artificial even though it is well theoretically derived. I could show my branch if it is of interest. Another cons: due to larger time_step and significant particle rotations, BD is not fully compatible with ESPResSo quaternion rotation mechanics. Again, I've integrated it a bit artificially to the existing architecture and all tests are passed.

Yours faithfully, Dr. Theo Tanygin

hmenke commented 7 years ago

You are correct that both, SD and BD, were removed in #1094. While the removal of SD was deliberate, the removal of BD was a mere consequence of the interwoven nature of implementation of the two methods.

In a past ESPResSo team meeting we discussed that we would want to keep BD, so if you have a proper implementation which does not do nonsensical things like duplicating the integration loop, as the removed variant did, we are happy to receive your pull request.

Regarding the conflicting features you mentioned, it is all about documentation in my opinion. If it is properly documented that quaternions cannot be used with BD and a user decides to ignore that note, well, bad luck.

mkuron commented 7 years ago

We would certainly like to have BD. It was removed only for technical reasons; we had intended to reimplement BD. The old BD/SD had essentially duplicated integrate.cpp, which made them unmaintainable. If you can provide a minimally-invasive version inside the existing integrate_vv function (even if it looks artificial) and provide tests and documentation as required, I think nobody would object.

RudolfWeeber commented 7 years ago

Brownian dynamics would be a great addition, not only for dipolar systems. What I find important is that we do not duplicate the main integration loop. It is already quite complex and it will be near impossible to keep two copies in sync.

bogdan-tanygin commented 7 years ago

Thanks for your feedback! OK, I will prepare a pull request. Pure BD does not require a real noisy velocity, hence, it fundamentally does not match the VV loop. However, our team has found a workaround and all TCL and Python tests have been passed. I know how to include it via an analytical derivation of BD from stochastic equations. In this case, BD matches the VV loops precisely with a heat velocity and required BD position random walk. Maybe, this approach is even closer to the explicit solvent implications (to be validated further).

bogdan-tanygin commented 6 years ago

The BD PR is almost ready. I've added some tests (see the linked references) which validate both VV-LD and BD and confirm the future BD functions, its kinematics / fluctuation–dissipation routines accuracy. These tests are useful even for VV-LD alone, hence, it is probably logically to separate corresponding PRs from the BD and to suggest ones before in a test-driven way.

bogdan-tanygin commented 6 years ago

The PR has been opened.