This is a plugin for OpenMM that used the trained JAX model by DMFF as an independent Force class for dynamics.
To use it, you need to save your DMFF model with the script in DMFF/backend/save_dmff2tf.py
.
Install the python, openmm and cudatoolkit.
mkdir omm_dmff_working_dir && cd omm_dmff_working_dir
conda create -n dmff_omm -c conda-forge python=3.9 openmm cudatoolkit=11.6
conda activate dmff_omm
Install the precompiled libtensorflow_cc library from conda.
conda install -y libtensorflow_cc=2.9.1 -c conda-forge
Download the tensorflow sources file. Copy the c
direcotry in source code to installed header files of tensorflow library, since it's needed by package cppflow
.
wget https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.9.1.tar.gz
tar -xvf v2.9.1.tar.gz
cp -r tensorflow-2.9.1/tensorflow/c ${CONDA_PREFIX}/include/tensorflow/
Download cppflow
and move the headers library to environment path.
git clone https://github.com/serizba/cppflow.git
cd cppflow
git apply DMFF/backend/openmm_dmff_plugin/tests/cppflow_empty_constructor.patch
mkdir ${CONDA_PREFIX}/include/cppflow
cp -r include/cppflow ${CONDA_PREFIX}/include/
Compile the plugin from the source with the following steps.
-
Set up environment variables.
export OPENMM_INSTALLED_DIR=$CONDA_PREFIX export CPPFLOW_INSTALLED_DIR=$CONDA_PREFIX export LIBTENSORFLOW_INSTALLED_DIR=$CONDA_PREFIX cd DMFF/backend/openmm_dmff_plugin/ mkdir build && cd build
-
Run
cmake
command with the required parameters.cmake .. -DOPENMM_DIR=${OPENMM_INSTALLED_DIR} -DCPPFLOW_DIR=${CPPFLOW_INSTALLED_DIR} -DTENSORFLOW_DIR=${LIBTENSORFLOW_INSTALLED_DIR} make && make install make PythonInstall
-
Test the plugin in Python interface, reference platform.
python -m OpenMMDMFFPlugin.tests.test_dmff_plugin_nve -n 100 python -m OpenMMDMFFPlugin.tests.test_dmff_plugin_nvt -n 100 --platform CUDA
Add the following lines to your Python script to use the plugin.
More details can refer to the script in python/OpenMMDMFFPlugin/tests/test_dmff_plugin_nve.py
.
from OpenMMDMFFPlugin import DMFFModel
# Set up the dmff_system with the dmff_model.
dmff_model = DMFFModel(dp_model)
dmff_model.setUnitTransformCoefficients(1, 1, 1)
dmff_system = dmff_model.createSystem(topology)