This is a plugin for OpenMM that implements a custom many-particle
force called a "ContinuityForce". This force aims to ensure that all particles in a set
remain continuously connected in space. More precisely, if we imagine the particles as
nodes of a network and draw an edge between particles that are closer than a cutoff distance (
ContinuityForce achieves this by classifying particles into components on the fly and adding
an attractive force between pairs of particles belonging to different components. The particles
are chosen each dynamics step as the closest possible pairs between the two components. The
attractive force is of the form
This was originally designed to aid FlexibleTopology simulations (paper). This plugin was made using the "OpenMMExamplePlugin" template.
Use a CONDA environment for easy installation. Before installing this plugin, you should create this environment and install openmm:
conda install -c conda-forge openmm=8.1 cudatoolkit=11.8
Note: explicitly installing the cudatoolkit is now necessary for newer openmm versions. At this point you can also check if openmm can communicate with your GPU:
python -m openmm.testInstallation
where you should see that CUDA successfully computes forces.
You will also need swig:
conda install swig
And if you need to install cmake this can also be done using CONDA:
conda install cmake
To build and install openmmcontinuityforce
, follow these steps:
-
Clone this repository to your own machine.
-
Create a directory in which to build the plugin, e.g.
openmmcontinuityforce/build
. -
Change to the build directory, and run cmake:
cmake ..
and open ccmake:ccmake ..
-
Set OPENMM_DIR to point to the directory where OpenMM is installed. This is needed to locate the OpenMM header files and libraries. If you are using CONDA, this directory will be something like:
/your/path/to/anaconda/envs/env_name
. -
Set CMAKE_INSTALL_PREFIX to the same directory.
-
If you plan to build the CUDA platform, make sure that CUDA_TOOLKIT_ROOT_DIR is set correctly and that BUILD_CUDA_LIB is selected.
-
Press "Configure" again if necessary, then press "Generate".
-
Type
make install
, followed bymake PythonInstall
. Note: there will likely be many warnings for PythonInstall related toOpenMMSwigHeaders.i
. These can be safely ignored and as long as the build reaches 100%.
To run all the test cases build the "test" target by typing make test
.
You can use the plugin in your Python scripts:
from openmmcontinuityforce import ContinuityForce
force = ContinuityForce()
For an illustrative example, check out LJ_test.py
in the examples
folder.