Skip to content

Commit 2978f17

Browse files
committed
Merge branch 'devel'
2 parents 6a7ec8b + 035a33a commit 2978f17

File tree

307 files changed

+77592
-23904
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

307 files changed

+77592
-23904
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: OpenMM DMFF Plugin tests.
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: [3.9]
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install Dependencies
20+
run: |
21+
source $CONDA/bin/activate
22+
conda create -n dmff_omm -y python=${{ matrix.python-version }} numpy openmm=7.7 -c conda-forge
23+
conda activate dmff_omm
24+
conda install -y libtensorflow_cc=2.9.1 -c conda-forge
25+
pip install setuptools==59.5.0
26+
mkdir /tmp/omm_dmff_working_dir
27+
cd /tmp/omm_dmff_working_dir
28+
wget https://github.com/tensorflow/tensorflow/archive/refs/tags/v2.9.1.tar.gz
29+
tar -xvf v2.9.1.tar.gz
30+
cp -r tensorflow-2.9.1/tensorflow/c ${CONDA_PREFIX}/include/tensorflow/
31+
git clone https://github.com/serizba/cppflow.git
32+
cd cppflow
33+
git apply ${GITHUB_WORKSPACE}/backend/openmm_dmff_plugin/tests/cppflow_empty_constructor.patch
34+
mkdir ${CONDA_PREFIX}/include/cppflow
35+
cp -r include/cppflow ${CONDA_PREFIX}/include/
36+
- name: Install OpenMM DMFF Plugin
37+
run: |
38+
source $CONDA/bin/activate dmff_omm
39+
cd ${GITHUB_WORKSPACE}/backend/openmm_dmff_plugin
40+
mkdir build && cd build
41+
export OPENMM_INSTALLED_DIR=$CONDA_PREFIX
42+
export CPPFLOW_INSTALLED_DIR=$CONDA_PREFIX
43+
export LIBTENSORFLOW_INSTALLED_DIR=$CONDA_PREFIX
44+
cmake .. -DOPENMM_DIR=${OPENMM_INSTALLED_DIR} -DCPPFLOW_DIR=${CPPFLOW_INSTALLED_DIR} -DTENSORFLOW_DIR=${LIBTENSORFLOW_INSTALLED_DIR} -DUSE_HIGH_PRECISION=OFF
45+
make && make install
46+
make PythonInstall
47+
- name: Run Tests
48+
run: |
49+
source $CONDA/bin/activate dmff_omm
50+
cd ${GITHUB_WORKSPACE}/backend/
51+
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

.github/workflows/ut.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
python-version: [3.8]
12+
python-version: [3.9]
1313
steps:
1414
- uses: actions/checkout@v2
1515
- name: Set up Python ${{ matrix.python-version }}
@@ -19,17 +19,19 @@ jobs:
1919
- name: Install Dependencies
2020
run: |
2121
source $CONDA/bin/activate
22-
$CONDA/bin/conda update -n base -c defaults conda
23-
conda install pip
24-
conda update pip
25-
conda install numpy openmm pytest rdkit biopandas openbabel -c conda-forge
26-
pip install jax jax_md
27-
pip install mdtraj==1.9.7 pymbar==4.0.1
22+
conda create -n dmff -y python=${{ matrix.python-version }} numpy openmm==7.7.0 pytest rdkit openbabel mdtraj ambertools -c conda-forge
23+
conda activate dmff
24+
pip install --upgrade pip
25+
pip install jax jaxlib jaxopt networkx parmed pymbar==4.0.1 optax tqdm
2826
- name: Install DMFF
2927
run: |
30-
source $CONDA/bin/activate
31-
pip install .
28+
source $CONDA/bin/activate dmff && pip install .
3229
- name: Run Tests
3330
run: |
34-
source $CONDA/bin/activate
35-
pytest -vs tests/
31+
source $CONDA/bin/activate dmff
32+
pytest -vs tests/test_classical/test_*
33+
pytest -vs tests/test_common/test_*
34+
pytest -vs tests/test_admp/test_*
35+
pytest -vs tests/test_utils.py
36+
pytest -vs tests/test_mbar/test_*
37+
pytest -vs tests/test_sgnn/test_*

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,4 +784,11 @@ FodyWeavers.xsd
784784
*/_version.py
785785

786786
# hmtff cache
787-
*.hmtff/
787+
*.hmtff/
788+
789+
# debugging ipynb
790+
debug.ipynb
791+
test.xml
792+
793+
# PyCharm Cache
794+
.idea/

README.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# DMFF
22

3-
[![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)
3+
[![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)
44

55
## About DMFF
66

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

1111
### License and credits
1212

13-
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
14-
Differentiable Platform for Molecular Force Field
15-
Development and Molecular Dynamics
16-
Simulation. ChemRxiv. Cambridge: Cambridge Open Engage; 2022; This content is a preprint and has not been peer-reviewed.`
13+
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
14+
Journal of Chemical Theory and Computation 2023 19 (17), 5897-5909
15+
DOI: 10.1021/acs.jctc.2c01297`
1716

1817
## User Guide
1918

20-
+ [1. Introduction](docs/user_guide/introduction.md)
21-
+ [2. Installation](docs/user_guide/installation.md)
22-
+ [3. Basic usage](docs/user_guide/usage.md)
23-
+ [4. XML format force field](docs/user_guide/xml_spec.md)
24-
+ [5. Theory](docs/user_guide/theory.md)
19+
+ [1. Introduction](docs/user_guide/1.introduction.md)
20+
+ [2. Installation](docs/user_guide/2.installation.md)
21+
+ [3. Basic Usage](docs/user_guide/3.usage.md)
22+
+ [4. Modules](docs/user_guide/4.modules.md)
23+
+ [Classical](docs/user_guide/4.1classical.md)
24+
+ [ADMP](docs/user_guide/4.2ADMPPmeForce.md)
25+
+ [Qeq](docs/user_guide/4.3ADMPQeqForce.md)
26+
+ [Machine Learning](docs/user_guide/4.4MLForce.md)
27+
+ [Optimization](docs/user_guide/4.5Optimization.md)
28+
+ [Mbar Estimator](docs/user_guide/4.6MBAR.md)
29+
+ [OpenMM Plugin](docs/user_guide/4.7OpenMMplugin.md)
30+
+ [5. Advanced examples](docs/user_guide/DMFF_example.ipynb)
31+
+ [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)
32+
33+
[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)
2534

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

3242
## Code Structure
3343

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

4761
## Support and Contribution
4862

backend/c_api/CMakeLists.txt

Whitespace-only changes.

backend/cpp_api/CMakeLists.txt

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
**/build
2+
**/.vscode
3+
**/__pycache__
4+
*.dcd
5+
**/output
6+
**/.devcontainer
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
#---------------------------------------------------
2+
# OpenMM DMFF Plugin
3+
#----------------------------------------------------
4+
5+
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
6+
SET(CMAKE_VERBOSE_MAKEFILE OFF)
7+
8+
project(OpenMMDMFF)
9+
10+
# We need to know where OpenMM is installed so we can access the headers and libraries.
11+
SET(OPENMM_DIR "/usr/local/openmm" CACHE PATH "Where OpenMM is installed")
12+
INCLUDE_DIRECTORIES("${OPENMM_DIR}/include")
13+
LINK_DIRECTORIES("${OPENMM_DIR}/lib" "${OPENMM_DIR}/lib/plugins")
14+
15+
16+
# Include the cppflow
17+
SET(CPPFLOW_DIR "/usr/local/cppflow/" CACHE PATH "Where cppflow is installed")
18+
INCLUDE_DIRECTORIES("${CPPFLOW_DIR}/include")
19+
LINK_DIRECTORIES("${CPPFLOW_DIR}/lib")
20+
21+
# Include the tensorflow
22+
SET(TENSORFLOW_DIR "/usr/local/tensorflow/" CACHE PATH "Where libtensorflow is installed")
23+
INCLUDE_DIRECTORIES("${TENSORFLOW_DIR}/include")
24+
LINK_DIRECTORIES("${TENSORFLOW_DIR}/lib")
25+
26+
# Specify the C++ version we are building for.
27+
SET (CMAKE_CXX_STANDARD 17)
28+
29+
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-ignored-attributes -Wl,--allow-multiple-definition -Wl,--no-as-needed")
30+
31+
# Set if high precision (double) is used. By default, it is off.
32+
OPTION(USE_HIGH_PRECISION "Use high precision (double) for calculations" OFF)
33+
34+
IF(USE_HIGH_PRECISION)
35+
message(STATUS "USE_HIGH_PRECISION is enabled")
36+
ADD_DEFINITIONS(-DUSE_HIGH_PRECISION)
37+
endif ()
38+
39+
if (USE_HIGH_PRECISION)
40+
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHIGH_PRECISION")
41+
else ()
42+
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
43+
endif ()
44+
45+
# Select where to install
46+
IF(${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT})
47+
IF(WIN32)
48+
SET(CMAKE_INSTALL_PREFIX "$ENV{ProgramFiles}/OpenMM" CACHE PATH "Where to install the plugin" FORCE)
49+
ELSE(WIN32)
50+
SET(CMAKE_INSTALL_PREFIX "${OPENMM_DIR}" CACHE PATH "Where to install the plugin" FORCE)
51+
ENDIF(WIN32)
52+
ENDIF(${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT})
53+
54+
# Put all the tests and libraries in a single output directory.
55+
IF(NOT EXECUTABLE_OUTPUT_PATH)
56+
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}
57+
CACHE INTERNAL "Single output directory for building all executables.")
58+
ENDIF()
59+
IF(NOT LIBRARY_OUTPUT_PATH)
60+
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}
61+
CACHE INTERNAL "Single output directory for building all libraries.")
62+
ENDIF()
63+
SET(${PROJECT_NAME}_EXECUTABLE_DIR ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
64+
SET(${PROJECT_NAME}_LIBRARY_DIR ${LIBRARY_OUTPUT_PATH}/${CMAKE_CFG_INTDIR})
65+
66+
# The source is organized into subdirectories, but we handle them all from
67+
# this CMakeLists file rather than letting CMake visit them as SUBDIRS.
68+
SET(DMFF_PLUGIN_SOURCE_SUBDIRS openmmapi serialization)
69+
70+
# Set the library name
71+
SET(DMFF_LIBRARY_NAME OpenMMDMFF)
72+
SET(SHARED_DMFF_TARGET ${DMFF_LIBRARY_NAME})
73+
74+
# These are all the places to search for header files that are to be part of the API.
75+
SET(API_INCLUDE_DIRS "openmmapi/include" "openmmapi/include/internal")
76+
77+
# Locate header files.
78+
SET(API_INCLUDE_FILES)
79+
FOREACH(dir ${API_INCLUDE_DIRS})
80+
FILE(GLOB fullpaths ${dir}/*.h)
81+
SET(API_INCLUDE_FILES ${API_INCLUDE_FILES} ${fullpaths})
82+
ENDFOREACH(dir)
83+
84+
# Collect source files
85+
SET(SOURCE_FILES) # empty
86+
SET(SOURCE_INCLUDE_FILES)
87+
FOREACH(subdir ${DMFF_PLUGIN_SOURCE_SUBDIRS})
88+
FILE(GLOB src_files ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/src/*.cpp)
89+
FILE(GLOB incl_files ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/src/*.h)
90+
SET(SOURCE_FILES ${SOURCE_FILES} ${src_files}) #append
91+
SET(SOURCE_INCLUDE_FILES ${SOURCE_INCLUDE_FILES} ${incl_files})
92+
93+
## Make sure we find these locally before looking in OpenMM/include if
94+
## OpenMM was previously installed there.
95+
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/include)
96+
ENDFOREACH(subdir)
97+
98+
# Create the library.
99+
100+
ADD_LIBRARY(${SHARED_DMFF_TARGET} SHARED ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ${API_INCLUDE_FILES})
101+
SET_TARGET_PROPERTIES(${SHARED_DMFF_TARGET}
102+
PROPERTIES COMPILE_FLAGS "-DDMFF_BUILDING_SHARED_LIBRARY ${EXTRA_COMPILE_FLAGS}"
103+
LINK_FLAGS "${EXTRA_COMPILE_FLAGS}")
104+
TARGET_LINK_LIBRARIES(${SHARED_DMFF_TARGET} OpenMM)
105+
TARGET_LINK_LIBRARIES(${SHARED_DMFF_TARGET} tensorflow_cc)
106+
107+
INSTALL_TARGETS(/lib RUNTIME_DIRECTORY /lib ${SHARED_DMFF_TARGET})
108+
109+
# install headers
110+
FILE(GLOB API_ONLY_INCLUDE_FILES "openmmapi/include/*.h")
111+
INSTALL (FILES ${API_ONLY_INCLUDE_FILES} DESTINATION include)
112+
FILE(GLOB API_ONLY_INCLUDE_FILES_INTERNAL "openmmapi/include/internal/*.h")
113+
INSTALL (FILES ${API_ONLY_INCLUDE_FILES_INTERNAL} DESTINATION include/internal)
114+
115+
# Enable testing
116+
# Set no testing here.
117+
ENABLE_TESTING()
118+
ADD_SUBDIRECTORY(serialization/tests)
119+
120+
# Use reference platform default.
121+
ADD_SUBDIRECTORY(platforms/reference)
122+
123+
FIND_PACKAGE(CUDA QUIET)
124+
IF(CUDA_FOUND)
125+
message(STATUS "CUDA found, building CUDA implementation")
126+
SET(PLUGIN_BUILD_CUDA_LIB ON CACHE BOOL "Build implementation for CUDA: ON")
127+
ELSE(CUDA_FOUND)
128+
message(STATUS "CUDA not found, not building CUDA implementation")
129+
SET(PLUGIN_BUILD_CUDA_LIB OFF CACHE BOOL "Build implementation for CUDA: OFF")
130+
ENDIF(CUDA_FOUND)
131+
IF(PLUGIN_BUILD_CUDA_LIB)
132+
ADD_SUBDIRECTORY(platforms/cuda)
133+
ENDIF(PLUGIN_BUILD_CUDA_LIB)
134+
135+
136+
# Build the Python API
137+
FIND_PROGRAM(PYTHON_EXECUTABLE python)
138+
FIND_PROGRAM(SWIG_EXECUTABLE swig)
139+
IF(PYTHON_EXECUTABLE AND SWIG_EXECUTABLE)
140+
message(STATUS "Python and SWIG found, building Python wrappers")
141+
SET(PLUGIN_BUILD_PYTHON_WRAPPERS ON CACHE BOOL "Build wrappers for Python")
142+
ELSE(PYTHON_EXECUTABLE AND SWIG_EXECUTABLE)
143+
message(FATAL_ERROR "Python or SWIG not found, not building Python wrappers")
144+
SET(PLUGIN_BUILD_PYTHON_WRAPPERS OFF CACHE BOOL "Build wrappers for Python")
145+
ENDIF(PYTHON_EXECUTABLE AND SWIG_EXECUTABLE)
146+
IF(PLUGIN_BUILD_PYTHON_WRAPPERS)
147+
ADD_SUBDIRECTORY(python)
148+
ENDIF(PLUGIN_BUILD_PYTHON_WRAPPERS)
149+

0 commit comments

Comments
 (0)