hoomd-blue
hoomd-blue copied to clipboard
Implement brute force overlap search for SDF compute
Description
This PR implements a brute force search for finding overlaps in hpmc.compute.SDF. In contrast to the binary search algorithm that is currently in place, the "first" overlap for a pair of particles is found by iteratively scaling down the vector connecting their centers and checking for overlaps at each scale value. The compute also weights the points added to the histogram by a factor that is a function of the change in energy upon overlap, where we now have a notion of "soft overlaps" that result from a change in the interaction energy for a pair of particles in addition to the "hard overlaps" that are a standard HPMC concept. By considering soft overlaps, we can accurately calculate the pressure in systems of patchy particles.
The user-facing API is unaffected by these changes. The binary search is valid for athermal systems of convex particles, and is much faster than the brute force method in that case. Therefore, upon computation of the SDF, we check if there is a patch energy evaluator and only use the brute force method if there is. Otherwise, we use the binary search method.
Motivation and context
This change is needed to calculate the pressure in systems with discontinuous pair potentials where the change in the energy for a pair of particles can be a nonmonotonic function of their separation (e.g., patchy particles or non-convex hard particles).
How has this been tested?
I have done fairly extensive tests for systems of patchy hexagons. I ran a series of NPT simulations at several pressures and temperatures and constructed equations of state isotherms. I then ran NVT systems at the same temperatures and the mean densities from the NPT simulations. The two sets of isotherms (obtained from NPT simulations and obtained from NVT simulations) overlap well within error bars. Pressures measured in NVT simulations are generally accurate to within 2 decimals places of the pressure that gave the corresponding density in NPT simulations.
I plan on doing similar tests (probably not as comprehensive but several state points) for several different systems that span dimensionality (2D vs 3D), shape (e.g., polygons, polyhedra, spheres), and density.
Change log
- Enable pressure measurement via hpmc.compute.SDF for systems with pair potentials
Checklist:
- [ ] I have reviewed the Contributor Guidelines.
- [ ] I agree with the terms of the HOOMD-blue Contributor Agreement.
- [ ] My name is on the list of contributors (
sphinx-doc/credits.rst) in the pull request source branch.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
@tcmoore3 Let us know if you have any questions.
This is ready for another set of reviews. It especially needs a careful review of whether I correctly account for the patch cutoff when building the AABB around particle i in the AABB tree search.
I addressed Brandon's last round of suggestions, so I think this is good to go now.
Thanks!