glotzerlab / hoomd-blue

Molecular dynamics and Monte Carlo soft matter simulation on GPUs.
http://glotzerlab.engin.umich.edu/hoomd-blue
BSD 3-Clause "New" or "Revised" License
335 stars 131 forks source link

Sphere geometry and basic rejection sampling framework for MPCD virtual particles #1822

Closed mphoward closed 2 months ago

mphoward commented 3 months ago

Description

This PR adds support for generating MPCD virtual particles for a geometry using rejection sampling. Particles are drawn everywhere in space, but only the ones outside the geometry are kept. This can be inefficient but isn't usually a bottleneck for most simulations (main limitation is the extra memory). We plan to refine this approach in the future.

While working on this, I realized that the way the virtual particle fillers were getting seeded had some variation between classes and CPU vs. GPU. This PR fixes that.

To be able to test the filler, I needed a geometry that doesn't have its own filler already. I added a spherical confinement that we had available from another project.

Motivation and context

This type of sampling is required for some geometries where it's impossible to mathematically define the volume to sample virtual particles in (see #1737 for more discussion).

How has this been tested?

I added a C++ test checking the statistics of drawn particles are roughly right. Python tests were also added for mpcd.geometry.Sphere, including for the filler.

Change log

* `mpcd.geometry.Sphere` for spherical confinement.

Checklist: