Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
WangXinyan940 committed Nov 9, 2023
2 parents 6a7ec8b + 035a33a commit 2978f17
Show file tree
Hide file tree
Showing 307 changed files with 77,592 additions and 23,904 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/test_openmm_dmff_plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: OpenMM DMFF Plugin tests.

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
source $CONDA/bin/activate
conda create -n dmff_omm -y python=${{ matrix.python-version }} numpy openmm=7.7 -c conda-forge
conda activate dmff_omm
conda install -y libtensorflow_cc=2.9.1 -c conda-forge
pip install setuptools==59.5.0
mkdir /tmp/omm_dmff_working_dir
cd /tmp/omm_dmff_working_dir
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/
git clone https://github.com/serizba/cppflow.git
cd cppflow
git apply ${GITHUB_WORKSPACE}/backend/openmm_dmff_plugin/tests/cppflow_empty_constructor.patch
mkdir ${CONDA_PREFIX}/include/cppflow
cp -r include/cppflow ${CONDA_PREFIX}/include/
- name: Install OpenMM DMFF Plugin
run: |
source $CONDA/bin/activate dmff_omm
cd ${GITHUB_WORKSPACE}/backend/openmm_dmff_plugin
mkdir build && cd build
export OPENMM_INSTALLED_DIR=$CONDA_PREFIX
export CPPFLOW_INSTALLED_DIR=$CONDA_PREFIX
export LIBTENSORFLOW_INSTALLED_DIR=$CONDA_PREFIX
cmake .. -DOPENMM_DIR=${OPENMM_INSTALLED_DIR} -DCPPFLOW_DIR=${CPPFLOW_INSTALLED_DIR} -DTENSORFLOW_DIR=${LIBTENSORFLOW_INSTALLED_DIR} -DUSE_HIGH_PRECISION=OFF
make && make install
make PythonInstall
- name: Run Tests
run: |
source $CONDA/bin/activate dmff_omm
cd ${GITHUB_WORKSPACE}/backend/
python -m OpenMMDMFFPlugin.tests.test_dmff_plugin_nve -n 100 --pdb ../examples/water_fullpol/water_dimer.pdb --model ./openmm_dmff_plugin/python/OpenMMDMFFPlugin/data/admp_water_dimer_aux --has_aux True
24 changes: 13 additions & 11 deletions .github/workflows/ut.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: [3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -19,17 +19,19 @@ jobs:
- name: Install Dependencies
run: |
source $CONDA/bin/activate
$CONDA/bin/conda update -n base -c defaults conda
conda install pip
conda update pip
conda install numpy openmm pytest rdkit biopandas openbabel -c conda-forge
pip install jax jax_md
pip install mdtraj==1.9.7 pymbar==4.0.1
conda create -n dmff -y python=${{ matrix.python-version }} numpy openmm==7.7.0 pytest rdkit openbabel mdtraj ambertools -c conda-forge
conda activate dmff
pip install --upgrade pip
pip install jax jaxlib jaxopt networkx parmed pymbar==4.0.1 optax tqdm
- name: Install DMFF
run: |
source $CONDA/bin/activate
pip install .
source $CONDA/bin/activate dmff && pip install .
- name: Run Tests
run: |
source $CONDA/bin/activate
pytest -vs tests/
source $CONDA/bin/activate dmff
pytest -vs tests/test_classical/test_*
pytest -vs tests/test_common/test_*
pytest -vs tests/test_admp/test_*
pytest -vs tests/test_utils.py
pytest -vs tests/test_mbar/test_*
pytest -vs tests/test_sgnn/test_*
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -784,4 +784,11 @@ FodyWeavers.xsd
*/_version.py

# hmtff cache
*.hmtff/
*.hmtff/

# debugging ipynb
debug.ipynb
test.xml

# PyCharm Cache
.idea/
36 changes: 25 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DMFF

[![doi:10.26434/chemrxiv-2022-2c7gv](https://img.shields.io/badge/DOI-10.26434%2Fchemrxiv--2022--2c7gv-blue)](https://doi.org/10.26434/chemrxiv-2022-2c7gv)
[![DOI: 10.1021/acs.jctc.2c01297](https://img.shields.io/badge/DOI-10.1021%2Facs.jctc.2c01297-blue)](https://pubs.acs.org/doi/10.1021/acs.jctc.2c01297)

## About DMFF

Expand All @@ -10,24 +10,34 @@ The behavior of organic molecular systems (e.g., protein folding, polymer struct

### License and credits

The project DMFF is licensed under [GNU LGPL v3.0](LICENSE). If you use this code in any future publications, please cite this using `Wang X, Li J, Yang L, Chen F, Wang Y, Chang J, et al. DMFF: An Open-Source Automatic
Differentiable Platform for Molecular Force Field
Development and Molecular Dynamics
Simulation. ChemRxiv. Cambridge: Cambridge Open Engage; 2022; This content is a preprint and has not been peer-reviewed.`
The project DMFF is licensed under [GNU LGPL v3.0](LICENSE). If you use this code in any future publications, please cite this using `Xinyan Wang, Jichen Li, Lan Yang, Feiyang Chen, Yingze Wang, Junhan Chang, Junmin Chen, Wei Feng, Linfeng Zhang, and Kuang Yu
Journal of Chemical Theory and Computation 2023 19 (17), 5897-5909
DOI: 10.1021/acs.jctc.2c01297`

## User Guide

+ [1. Introduction](docs/user_guide/introduction.md)
+ [2. Installation](docs/user_guide/installation.md)
+ [3. Basic usage](docs/user_guide/usage.md)
+ [4. XML format force field](docs/user_guide/xml_spec.md)
+ [5. Theory](docs/user_guide/theory.md)
+ [1. Introduction](docs/user_guide/1.introduction.md)
+ [2. Installation](docs/user_guide/2.installation.md)
+ [3. Basic Usage](docs/user_guide/3.usage.md)
+ [4. Modules](docs/user_guide/4.modules.md)
+ [Classical](docs/user_guide/4.1classical.md)
+ [ADMP](docs/user_guide/4.2ADMPPmeForce.md)
+ [Qeq](docs/user_guide/4.3ADMPQeqForce.md)
+ [Machine Learning](docs/user_guide/4.4MLForce.md)
+ [Optimization](docs/user_guide/4.5Optimization.md)
+ [Mbar Estimator](docs/user_guide/4.6MBAR.md)
+ [OpenMM Plugin](docs/user_guide/4.7OpenMMplugin.md)
+ [5. Advanced examples](docs/user_guide/DMFF_example.ipynb)
+ [And here is a tutorial notebook of the basic usage of DMFF. Welcome to read it and get started with DMFF!](docs/user_guide/test.ipynb)

[And here is a tutorial notebook, which would tell you some basic usage of DMFF. Welcome to read it and get started witn DMFF!](docs/user_guide/test.ipynb)

## Developer Guide
+ [1. Introduction](docs/dev_guide/introduction.md)
+ [2. Software architecture](docs/dev_guide/arch.md)
+ [3. Coding conventions](docs/dev_guide/convention.md)
+ [4. Document writing](docs/dev_guide/write_docs.md)
+ [5. An example for developing: how to write a generator?](docs/dev_guide/generator.ipynb)

## Code Structure

Expand All @@ -38,11 +48,15 @@ The code is organized as follows:
+ `package`: files for constructing packages or images, such as conda recipe and docker files.
+ `tests`: unit tests.
+ `dmff`: DMFF python codes
+ `dmff/api`: source code of application programming interface of DMFF.
+ `dmff/admp`: source code of automatic differentiable multipolar polarizable (ADMP) force field module.
+ `dmff/classical`: source code of classical force field module.
+ `dmff/common`: source code of common functions, such as neighbor list.
+ `dmff/generators`: source code of force generators.
+ `dmff/sgnn`: source of subgragh neural network force field model.
+ `dmff/eann`: source of embedded atom neural network force field model.
+ `dmff/generators`: source code of force generators.
+ `dmff/operators`: source code of operators.


## Support and Contribution

Expand Down
Empty file added backend/c_api/CMakeLists.txt
Empty file.
Empty file added backend/cpp_api/CMakeLists.txt
Empty file.
6 changes: 6 additions & 0 deletions backend/openmm_dmff_plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/build
**/.vscode
**/__pycache__
*.dcd
**/output
**/.devcontainer
149 changes: 149 additions & 0 deletions backend/openmm_dmff_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
#---------------------------------------------------
# OpenMM DMFF Plugin
#----------------------------------------------------

CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
SET(CMAKE_VERBOSE_MAKEFILE OFF)

project(OpenMMDMFF)

# We need to know where OpenMM is installed so we can access the headers and libraries.
SET(OPENMM_DIR "/usr/local/openmm" CACHE PATH "Where OpenMM is installed")
INCLUDE_DIRECTORIES("${OPENMM_DIR}/include")
LINK_DIRECTORIES("${OPENMM_DIR}/lib" "${OPENMM_DIR}/lib/plugins")


# Include the cppflow
SET(CPPFLOW_DIR "/usr/local/cppflow/" CACHE PATH "Where cppflow is installed")
INCLUDE_DIRECTORIES("${CPPFLOW_DIR}/include")
LINK_DIRECTORIES("${CPPFLOW_DIR}/lib")

# Include the tensorflow
SET(TENSORFLOW_DIR "/usr/local/tensorflow/" CACHE PATH "Where libtensorflow is installed")
INCLUDE_DIRECTORIES("${TENSORFLOW_DIR}/include")
LINK_DIRECTORIES("${TENSORFLOW_DIR}/lib")

# Specify the C++ version we are building for.
SET (CMAKE_CXX_STANDARD 17)

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-ignored-attributes -Wl,--allow-multiple-definition -Wl,--no-as-needed")

# Set if high precision (double) is used. By default, it is off.
OPTION(USE_HIGH_PRECISION "Use high precision (double) for calculations" OFF)

IF(USE_HIGH_PRECISION)
message(STATUS "USE_HIGH_PRECISION is enabled")
ADD_DEFINITIONS(-DUSE_HIGH_PRECISION)
endif ()

if (USE_HIGH_PRECISION)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHIGH_PRECISION")
else ()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif ()

# Select where to install
IF(${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT})
IF(WIN32)
SET(CMAKE_INSTALL_PREFIX "$ENV{ProgramFiles}/OpenMM" CACHE PATH "Where to install the plugin" FORCE)
ELSE(WIN32)
SET(CMAKE_INSTALL_PREFIX "${OPENMM_DIR}" CACHE PATH "Where to install the plugin" FORCE)
ENDIF(WIN32)
ENDIF(${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT})

# Put all the tests and libraries in a single output directory.
IF(NOT EXECUTABLE_OUTPUT_PATH)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}
CACHE INTERNAL "Single output directory for building all executables.")
ENDIF()
IF(NOT LIBRARY_OUTPUT_PATH)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}
CACHE INTERNAL "Single output directory for building all libraries.")
ENDIF()
SET(${PROJECT_NAME}_EXECUTABLE_DIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
SET(${PROJECT_NAME}_LIBRARY_DIR ${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})

# The source is organized into subdirectories, but we handle them all from
# this CMakeLists file rather than letting CMake visit them as SUBDIRS.
SET(DMFF_PLUGIN_SOURCE_SUBDIRS openmmapi serialization)

# Set the library name
SET(DMFF_LIBRARY_NAME OpenMMDMFF)
SET(SHARED_DMFF_TARGET ${DMFF_LIBRARY_NAME})

# These are all the places to search for header files that are to be part of the API.
SET(API_INCLUDE_DIRS "openmmapi/include" "openmmapi/include/internal")

# Locate header files.
SET(API_INCLUDE_FILES)
FOREACH(dir ${API_INCLUDE_DIRS})
FILE(GLOB fullpaths ${dir}/*.h)
SET(API_INCLUDE_FILES ${API_INCLUDE_FILES} ${fullpaths})
ENDFOREACH(dir)

# Collect source files
SET(SOURCE_FILES) # empty
SET(SOURCE_INCLUDE_FILES)
FOREACH(subdir ${DMFF_PLUGIN_SOURCE_SUBDIRS})
FILE(GLOB src_files ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/src/*.cpp)
FILE(GLOB incl_files ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/src/*.h)
SET(SOURCE_FILES ${SOURCE_FILES} ${src_files}) #append
SET(SOURCE_INCLUDE_FILES ${SOURCE_INCLUDE_FILES} ${incl_files})

## Make sure we find these locally before looking in OpenMM/include if
## OpenMM was previously installed there.
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/include)
ENDFOREACH(subdir)

# Create the library.

ADD_LIBRARY(${SHARED_DMFF_TARGET} SHARED ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ${API_INCLUDE_FILES})
SET_TARGET_PROPERTIES(${SHARED_DMFF_TARGET}
PROPERTIES COMPILE_FLAGS "-DDMFF_BUILDING_SHARED_LIBRARY ${EXTRA_COMPILE_FLAGS}"
LINK_FLAGS "${EXTRA_COMPILE_FLAGS}")
TARGET_LINK_LIBRARIES(${SHARED_DMFF_TARGET} OpenMM)
TARGET_LINK_LIBRARIES(${SHARED_DMFF_TARGET} tensorflow_cc)

INSTALL_TARGETS(/lib RUNTIME_DIRECTORY /lib ${SHARED_DMFF_TARGET})

# install headers
FILE(GLOB API_ONLY_INCLUDE_FILES "openmmapi/include/*.h")
INSTALL (FILES ${API_ONLY_INCLUDE_FILES} DESTINATION include)
FILE(GLOB API_ONLY_INCLUDE_FILES_INTERNAL "openmmapi/include/internal/*.h")
INSTALL (FILES ${API_ONLY_INCLUDE_FILES_INTERNAL} DESTINATION include/internal)

# Enable testing
# Set no testing here.
ENABLE_TESTING()
ADD_SUBDIRECTORY(serialization/tests)

# Use reference platform default.
ADD_SUBDIRECTORY(platforms/reference)

FIND_PACKAGE(CUDA QUIET)
IF(CUDA_FOUND)
message(STATUS "CUDA found, building CUDA implementation")
SET(PLUGIN_BUILD_CUDA_LIB ON CACHE BOOL "Build implementation for CUDA: ON")
ELSE(CUDA_FOUND)
message(STATUS "CUDA not found, not building CUDA implementation")
SET(PLUGIN_BUILD_CUDA_LIB OFF CACHE BOOL "Build implementation for CUDA: OFF")
ENDIF(CUDA_FOUND)
IF(PLUGIN_BUILD_CUDA_LIB)
ADD_SUBDIRECTORY(platforms/cuda)
ENDIF(PLUGIN_BUILD_CUDA_LIB)


# Build the Python API
FIND_PROGRAM(PYTHON_EXECUTABLE python)
FIND_PROGRAM(SWIG_EXECUTABLE swig)
IF(PYTHON_EXECUTABLE AND SWIG_EXECUTABLE)
message(STATUS "Python and SWIG found, building Python wrappers")
SET(PLUGIN_BUILD_PYTHON_WRAPPERS ON CACHE BOOL "Build wrappers for Python")
ELSE(PYTHON_EXECUTABLE AND SWIG_EXECUTABLE)
message(FATAL_ERROR "Python or SWIG not found, not building Python wrappers")
SET(PLUGIN_BUILD_PYTHON_WRAPPERS OFF CACHE BOOL "Build wrappers for Python")
ENDIF(PYTHON_EXECUTABLE AND SWIG_EXECUTABLE)
IF(PLUGIN_BUILD_PYTHON_WRAPPERS)
ADD_SUBDIRECTORY(python)
ENDIF(PLUGIN_BUILD_PYTHON_WRAPPERS)

Loading

0 comments on commit 2978f17

Please sign in to comment.