Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
49172d6
Merge pull request #22 from KuangYu/devel
KuangYu May 5, 2022
9cb01be
add nblist wrapper and its docs
May 9, 2022
e0c03e9
Merge pull request #23 from Roy-Kid/nblist
KuangYu May 10, 2022
a47f5ff
fix(generator): existing jax bond/angle generators
Ericwang6 May 11, 2022
2c688f2
fix: LJ bug; all classical code can be jitted; bug at test_gaff2_force
May 14, 2022
ad46c6b
fix test_gaff2_force bug
May 14, 2022
c2bfb1c
fix: non-differentiable error, move args check in the api.py
May 17, 2022
9afbba2
fix: remove redundancy `box=jnp.array(box)`; confirm isinstance_jnp i…
May 18, 2022
ecd85e8
Merge pull request #24 from Roy-Kid/feat-classical-jit
KuangYu May 18, 2022
9dda816
refine(pme): code prettify
Ericwang6 May 19, 2022
637e859
refine(utils): code prettify
Ericwang6 May 19, 2022
87e79ce
add(nblist): add jit and auto update nblist
Ericwang6 May 19, 2022
a1721a9
refine(classical): rm unused import
Ericwang6 May 19, 2022
ab17cf2
refactor(classical): add dispCorr
Ericwang6 May 19, 2022
622d3fb
add(classical): add free energy support
Ericwang6 May 19, 2022
940cdd8
refactor renderXML with clean commits (#25)
Roy-Kid Jun 4, 2022
89ee1db
refine(fep): rm debugging codes
Ericwang6 Jun 4, 2022
3e3e2c8
Merge branch 'devel' of https://github.com/deepmodeling/DMFF into wan…
Ericwang6 Jun 4, 2022
711b793
add(cicd): CI/CD workflows
Ericwang6 Jun 4, 2022
10b35fc
add(ut): ut for regularize_pairs and buffer_scales
Ericwang6 Jun 4, 2022
78816eb
fix(CI/CD): activate conda env
Ericwang6 Jun 4, 2022
a0cc75c
fix(CI/CD): wrong number in test_nblist
Ericwang6 Jun 4, 2022
078a191
add(requirement): add dependencies list
Ericwang6 Jun 4, 2022
35b5131
add(CI/CD): unittest workflows
Ericwang6 Jun 4, 2022
4af913c
add(requirements): dependencies list
Ericwang6 Jun 4, 2022
f5eb2d5
add test_utils.py
Jun 5, 2022
af99d07
Merge branch 'devel' of github.com:deepmodeling/DMFF into devel
Jun 5, 2022
fa27e1d
fix: modified unit test results
Jun 5, 2022
ba16e3b
add `r` to avoid latex being recognized as an escape character
Jun 5, 2022
57b65d4
fix(ut): wrong number in test_nblist
Ericwang6 Jun 5, 2022
bdd702e
Fix unit test related problems (#27)
Roy-Kid Jun 5, 2022
918de59
Merge branch 'devel' of https://github.com/deepmodeling/DMFF into cicd
Ericwang6 Jun 5, 2022
2b04192
refine(ut): code prettify in test_nblist
Ericwang6 Jun 5, 2022
396abd0
Add CI/CD Workflows (#26)
Ericwang6 Jun 5, 2022
2df4712
Merge branch 'devel' of https://github.com/deepmodeling/DMFF into wan…
Ericwang6 Jun 5, 2022
91f0083
update(api): switch default dispcorr to False
Ericwang6 Jun 5, 2022
234d1dd
Chore: clean admp module up
Jun 5, 2022
38ff0e5
chore: clean up classical and api.py
Jun 5, 2022
2abaf68
Merge branch 'devel' of github.com:Roy-Kid/DMFF into devel
Jun 5, 2022
8a86946
fix(ut): withdraw last commit about fix wrong number in test_nblist
Jun 5, 2022
e23ec64
Merge branch 'cicd' of github.com:deepmodeling/DMFF into cicd
Jun 5, 2022
354105a
update(api): fix dispcorr countmat bugs
Ericwang6 Jun 5, 2022
a7ac5fb
update(pme): code prettify & gmx ewald coeff determine
Ericwang6 Jun 5, 2022
72a191e
add(constants): module to control constants
Ericwang6 Jun 5, 2022
c189135
add(unittest): fep ut
Ericwang6 Jun 5, 2022
fd2ff8c
update(test_nblist): unused imports
Ericwang6 Jun 5, 2022
c362cab
update(gitignore): acpype cache
Ericwang6 Jun 5, 2022
27d9576
refactor(test_classical): split to several files
Ericwang6 Jun 5, 2022
2f94d81
refactor(test_classical): rename test_classical
Ericwang6 Jun 5, 2022
f2732fd
fix(inter): PME in classical forcefield
Ericwang6 Jun 5, 2022
85f1498
update(fep): use dmff.common.constants
Ericwang6 Jun 5, 2022
5f57aed
update(pme): default args in setup_ewald_parameters
Ericwang6 Jun 5, 2022
43824ac
Merge pull request #28 from deepmodeling/wangyz/devel
KuangYu Jun 9, 2022
69293ca
Fix the nb list description in doc
KuangYu Jun 9, 2022
7c71961
update mkdocs.yml and a simple test of api generator
Jun 9, 2022
05f19cd
Merge pull request #29 from KuangYu/devel
KuangYu Jun 9, 2022
b86e81a
fix: add step_pol arg in ADMPPmeForce __init__ to fix it can not be j…
Jun 9, 2022
1ffe521
Merge branch 'devel' of github.com:deepmodeling/DMFF into origin/devel
Jun 9, 2022
919439c
add step_pol arg in ADMPPmeForce __init__ to fix it can not be jitted…
Jun 9, 2022
c69ce7b
Improve docstrings in sgnn
KuangYu Jun 9, 2022
feeb13c
Merge pull request #30 from Roy-Kid/devel
KuangYu Jun 9, 2022
0d94a48
add read_input_info in dmff.admp.parse.py to deal with info in pdb an…
LanYang430 Jun 10, 2022
0132950
Update some examples and ref_outs
KuangYu Jun 11, 2022
4687b1a
Merge branch 'devel' of github.com:deepmodeling/DMFF into devel
KuangYu Jun 11, 2022
9cd3b53
feat: auto gen docs refs
Jun 11, 2022
f13d763
Merge branch 'devel' into cicd
Jun 11, 2022
f4fec8f
fix: typo in requirements.txt
Jun 11, 2022
cf4bd96
add change leading terms in api.py
LanYang430 Jun 12, 2022
5f37a77
add fluctuated leading term computation in dmff.api
LanYang430 Jun 12, 2022
3b3798e
add fluctuated leading term compute in dmff.api
LanYang430 Jun 12, 2022
69d81a7
use dmff.api to deal with input ; wrap admp_calculator to change fixe…
LanYang430 Jun 12, 2022
0db001b
wrap compute leading term in run.py
LanYang430 Jun 13, 2022
dac14f4
add a markdown and a generate_calculator outside admp_calculator func…
LanYang430 Jun 13, 2022
32af5d8
feat(classical): Hamiltonian can create total energy function now. (#33)
WangXinyan940 Jun 13, 2022
b2c71c3
Docs refine (#34)
Ericwang6 Jun 13, 2022
2a4894f
Improve the fluctuating charge jupyter notebook demo
KuangYu Jun 14, 2022
24ad9a6
Delete parser_bk.py
KuangYu Jun 14, 2022
00571b4
Merge pull request #31 from Humourist/fluctuated_water_FF
KuangYu Jun 14, 2022
6c4b96b
Merge branch 'deepmodeling:devel' into devel
KuangYu Jun 14, 2022
eba716e
Fix the fluctuating atom charge demo
KuangYu Jun 14, 2022
d3ce2e6
Merge pull request #35 from KuangYu/devel
KuangYu Jun 14, 2022
d2ed3a6
merge docs from cicd branch
Jun 14, 2022
f376733
feat: update docs configs
Jun 14, 2022
5f35e79
fix: fix test_nblist bug
Jun 14, 2022
2495943
update: license in docs
Jun 14, 2022
d3854c4
fix: import missing in api.py (may caused by formatter)
Jun 14, 2022
3317d41
Merge pull request #36 from Roy-Kid/devel
Roy-Kid Jun 14, 2022
acc10f2
FIX: wrong links in docs and add requirements (#37)
Ericwang6 Jun 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/ut.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: DMFF's python tests.

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
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/bin/conda update -n base -c defaults conda
conda install pip
conda update pip
conda install numpy openmm pytest -c conda-forge
pip install jax jax_md
- name: Install DMFF
run: |
source $CONDA/bin/activate
pip install .
- name: Run Tests
run: |
source $CONDA/bin/activate
pytest -vs tests/
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -775,4 +775,7 @@ FodyWeavers.xsd

### VisualStudio Patch ###
# Additional files built by Visual Studio
.vscode/**
.vscode/**

# acpype cache
*.acpype/
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ The behavior of organic molecular systems (e.g., protein folding, polymer struct

+ [1. Introduction](docs/user_guide/introduction.md)
+ [2. Installation](docs/user_guide/installation.md)
+ [3. Compute energy and forces](docs/user_guide/compute.md)
+ [4. Compute gradients with auto differentiable framework](docs/user_guide/auto_diff.md)
+ [5. Theories](docs/user_guide/theory.md)
+ [6. Introduction to force field xml files](docs/user_guide/xml_spec.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)

## Developer Guide
+ [1. Introduction](docs/dev_guide/introduction.md)
+ [2. Architecture](docs/dev_guide/arch.md)
+ [3. Convention](docs/dev_guide/convention.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)

## Modules
+ [1. ADMP](docs/modules/admp.md)
Expand Down
4 changes: 3 additions & 1 deletion dmff/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
import dmff.settings
from .settings import *
from .common.nblist import NeighborList
from .api import Hamiltonian
15 changes: 9 additions & 6 deletions dmff/admp/disp_pme.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from functools import partial

import jax.numpy as jnp
from jax import vmap, value_and_grad
from dmff.utils import jit_condition, regularize_pairs, pair_buffer_scales
from dmff.admp.spatial import pbc_shift
from dmff.admp.pairwise import (distribute_dispcoeff, distribute_scalar,
distribute_v3)
from dmff.admp.pme import setup_ewald_parameters
from dmff.admp.recip import generate_pme_recip, Ck_6, Ck_8, Ck_10
from dmff.admp.pairwise import distribute_scalar, distribute_v3, distribute_dispcoeff
from functools import partial
from dmff.admp.recip import Ck_6, Ck_8, Ck_10, generate_pme_recip
from dmff.admp.spatial import pbc_shift
from dmff.utils import jit_condition, pair_buffer_scales, regularize_pairs
from jax import value_and_grad, vmap


class ADMPDispPmeForce:
'''
Expand Down
76 changes: 16 additions & 60 deletions dmff/admp/mbpol_intra.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@

import sys
import numpy as np
import jax.numpy as jnp
from jax import grad, value_and_grad
from dmff.settings import DO_JIT
from dmff.utils import jit_condition
import numpy as np
from dmff.admp.spatial import v_pbc_shift
from dmff.admp.pme import ADMPPmeForce
from dmff.admp.parser import *
from dmff.utils import jit_condition
from jax import vmap
import time
#from admp.multipole import convert_cart2harm
#from jax_md import partition, space

#const
f5z = 0.999677885
fbasis = 0.15860145369897
fcore = -1.6351695982132
frest = 1.0
reoh = 0.958649;
thetae = 104.3475;
b1 = 2.0;
roh = 0.9519607159623009;
alphaoh = 2.587949757553683;
deohA = 42290.92019288289;
phh1A = 16.94879431193463;
phh2 = 12.66426998162947;
reoh = 0.958649
thetae = 104.3475
b1 = 2.0
roh = 0.9519607159623009
alphaoh = 2.587949757553683
deohA = 42290.92019288289
phh1A = 16.94879431193463
phh2 = 12.66426998162947

c5zA = jnp.array([4.2278462684916e+04, 4.5859382909906e-02, 9.4804986183058e+03,
7.5485566680955e+02, 1.9865052511496e+03, 4.3768071560862e+02,
Expand Down Expand Up @@ -467,12 +460,14 @@ def onebodyenergy(positions, box):

@vmap
@jit_condition(static_argnums={})
def onebody_kernel(x1, x2, x3, Va, Vb, efac):
def onebody_kernel(x1, x2, x3, Va, Vb, efac):
a = jnp.arange(-1,15)
a = a.at[0].set(0)
const = jnp.array([0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
CONST = jnp.array([const,const,const])
list1 = jnp.array([x1**i for i in range(-1, 15)])
list2 = jnp.array([x2**i for i in range(-1, 15)])
list3 = jnp.array([x3**i for i in range(-1, 15)])
list1 = jnp.array([x1**i for i in a])
list2 = jnp.array([x2**i for i in a])
list3 = jnp.array([x3**i for i in a])
fmat = jnp.array([list1, list2, list3])
fmat *= CONST
F1 = jnp.sum(fmat[0].T * matrix1, axis=1) # fmat[0][inI] 1*245
Expand All @@ -488,42 +483,3 @@ def onebody_kernel(x1, x2, x3, Va, Vb, efac):
e1 *= cm1_kcalmol
e1 *= cal2joule # conver cal 2 j
return e1


def validation(pdb):
xml = 'mpidwater.xml'
pdbinfo = read_pdb(pdb)
serials = pdbinfo['serials']
names = pdbinfo['names']
resNames = pdbinfo['resNames']
resSeqs = pdbinfo['resSeqs']
positions = pdbinfo['positions']
box = pdbinfo['box'] # a, b, c, α, β, γ
charges = pdbinfo['charges']
positions = jnp.asarray(positions)
lx, ly, lz, _, _, _ = box
box = jnp.eye(3)*jnp.array([lx, ly, lz])

mScales = jnp.array([0.0, 0.0, 0.0, 1.0, 1.0])
pScales = jnp.array([0.0, 0.0, 0.0, 1.0, 1.0])
dScales = jnp.array([0.0, 0.0, 0.0, 1.0, 1.0])

rc = 4 # in Angstrom
ethresh = 1e-4

n_atoms = len(serials)

# compute intra


grad_E1 = value_and_grad(onebodyenergy,argnums=(0))
ene, force = grad_E1(positions, box)
print(ene,force)
return


# below is the validation code
if __name__ == '__main__':
validation(sys.argv[1])


10 changes: 5 additions & 5 deletions dmff/admp/multipole.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys
from functools import partial

import jax.numpy as jnp
from jax import vmap
from dmff.utils import jit_condition
from functools import partial
from jax import vmap

# This module deals with the transformations and rotations of multipoles

Expand Down Expand Up @@ -48,7 +48,7 @@ def convert_cart2harm(Theta, lmax):
n * (l+1)^2, stores the spherical multipoles
'''
if lmax > 2:
sys.exit('l > 2 (beyond quadrupole) not supported')
raise ValueError('l > 2 (beyond quadrupole) not supported')

Q_mono = Theta[0:1]

Expand Down Expand Up @@ -90,7 +90,7 @@ def convert_harm2cart(Q, lmax):
'''

if lmax > 2:
sys.exit('l > 2 (beyond quadrupole) not supported')
raise ValueError('l > 2 (beyond quadrupole) not supported')

T_mono = Q[0:1]

Expand Down
116 changes: 8 additions & 108 deletions dmff/admp/pairwise.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import sys
from jax import vmap
from functools import partial

import jax.numpy as jnp
from dmff.utils import jit_condition, regularize_pairs, pair_buffer_scales
from dmff.admp.spatial import v_pbc_shift
from functools import partial
from dmff.utils import jit_condition, pair_buffer_scales, regularize_pairs
from jax import vmap

DIELECTRIC = 1389.35455846

Expand Down Expand Up @@ -40,6 +40,9 @@ def distribute_multipoles(multipoles, index):
def distribute_dispcoeff(c_list, index):
return c_list[index]

@jit_condition(static_argnums=())
def distribute_matrix(multipoles,index1,index2):
return multipoles[index1,index2]

def generate_pairwise_interaction(pair_int_kernel, covalent_map, static_args):
'''
Expand Down Expand Up @@ -130,7 +133,7 @@ def TT_damping_qq_kernel(dr, m, bi, bj, qi, qj):
@vmap
@jit_condition(static_argnums=())
def slater_disp_damping_kernel(dr, m, bi, bj, c6i, c6j, c8i, c8j, c10i, c10j):
'''
r'''
Slater-ISA type damping for dispersion:
f(x) = -e^{-x} * \sum_{k} x^k/k!
x = Br - \frac{2*(Br)^2 + 3Br}{(Br)^2 + 3*Br + 3}
Expand Down Expand Up @@ -167,106 +170,3 @@ def slater_sr_kernel(dr, m, ai, aj, bi, bj):
P = 1/3 * br2 + br + 1
return a * P * jnp.exp(-br) * m


def validation(pdb):
xml = 'mpidwater.xml'
pdbinfo = read_pdb(pdb)
serials = pdbinfo['serials']
names = pdbinfo['names']
resNames = pdbinfo['resNames']
resSeqs = pdbinfo['resSeqs']
positions = pdbinfo['positions']
box = pdbinfo['box'] # a, b, c, α, β, γ
charges = pdbinfo['charges']
positions = jnp.asarray(positions)
lx, ly, lz, _, _, _ = box
box = jnp.eye(3)*jnp.array([lx, ly, lz])

mScales = jnp.array([0.0, 0.0, 0.0, 1.0, 1.0])
pScales = jnp.array([0.0, 0.0, 0.0, 1.0, 1.0])
dScales = jnp.array([0.0, 0.0, 0.0, 1.0, 1.0])

rc = 4 # in Angstrom
ethresh = 1e-4

n_atoms = len(serials)

atomTemplate, residueTemplate = read_xml(xml)
atomDicts, residueDicts = init_residues(serials, names, resNames, resSeqs, positions, charges, atomTemplate, residueTemplate)

covalent_map = assemble_covalent(residueDicts, n_atoms)
displacement_fn, shift_fn = space.periodic_general(box, fractional_coordinates=False)
neighbor_list_fn = partition.neighbor_list(displacement_fn, box, rc, 0, format=partition.OrderedSparse)
nbr = neighbor_list_fn.allocate(positions)
pairs = nbr.idx.T

pmax = 10
kappa, K1, K2, K3 = setup_ewald_parameters(rc, ethresh, box)
kappa = 0.657065221219616

# construct the C list
c_list = np.zeros((3, n_atoms))
a_list = np.zeros(n_atoms)
q_list = np.zeros(n_atoms)
b_list = np.zeros(n_atoms)
nmol=int(n_atoms/3)
for i in range(nmol):
a = i*3
b = i*3+1
c = i*3+2
# dispersion coeff
c_list[0][a]=37.199677405
c_list[0][b]=7.6111103
c_list[0][c]=7.6111103
c_list[1][a]=85.26810658
c_list[1][b]=11.90220148
c_list[1][c]=11.90220148
c_list[2][a]=134.44874488
c_list[2][b]=15.05074749
c_list[2][c]=15.05074749
# q
q_list[a] = -0.741706
q_list[b] = 0.370853
q_list[c] = 0.370853
# b, Bohr^-1
b_list[a] = 2.00095977
b_list[b] = 1.999519942
b_list[c] = 1.999519942
# a, Hartree
a_list[a] = 458.3777
a_list[b] = 0.0317
a_list[c] = 0.0317


c_list = jnp.array(c_list)

# @partial(vmap, in_axes=(0, 0, 0, 0), out_axes=(0))
# @jit_condition(static_argnums=())
# def disp6_pme_real_kernel(dr, m, ci, cj):
# # unpack static arguments
# kappa = static_args['kappa']
# # calculate distance
# dr2 = dr ** 2
# dr6 = dr2 ** 3
# # do calculation
# x2 = kappa**2 * dr2
# exp_x2 = jnp.exp(-x2)
# x4 = x2 * x2
# g = (1 + x2 + 0.5*x4) * exp_x2
# return (m + g - 1) * ci * cj / dr6

# static_args = {'kappa': kappa}
# disp6_pme_real = generate_pairwise_interaction(disp6_pme_real_kernel, covalent_map, static_args)
# print(disp6_pme_real(positions, box, pairs, mScales, c_list[0, :]))

TT_damping_qq_c6 = generate_pairwise_interaction(TT_damping_qq_c6_kernel, covalent_map, static_args={})

TT_damping_qq_c6(positions, box, pairs, mScales, a_list, b_list, q_list, c_list[0])
print('ok')
print(TT_damping_qq_c6(positions, box, pairs, mScales, a_list, b_list, q_list, c_list[0]))
return


# below is the validation code
if __name__ == '__main__':
validation(sys.argv[1])
7 changes: 5 additions & 2 deletions dmff/admp/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import numpy as np
import warnings
from collections import defaultdict
import jax.numpy as jnp
from dmff.admp.multipole import convert_cart2harm

def read_atom_line(line_full):
"""
Expand Down Expand Up @@ -326,7 +328,8 @@ def read_xml(fileobj):
set_axis_type(atomTemplates)

return atomTemplates, residueTemplates



class Atom:

def __init__(self, serial, name, resName, resSeq, position, charge, ) -> None:
Expand Down Expand Up @@ -474,4 +477,4 @@ def assemble_covalent(residueDicts, natoms):
covalent_map[c][pp] = dr

return covalent_map

Loading