Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
eaee2ff
Merge pull request #3 from deepmodeling/master
Ericwang6 Feb 21, 2022
edea830
fix bug: Distinguish the usages of parseElement and createForce, unfo…
Feb 23, 2022
7311672
Fix the following bugs in pme.py:
KuangYu Feb 24, 2022
209e2f5
Merge pull request #5 from KuangYu/devel
KuangYu Feb 24, 2022
54038be
Add the SGNN module (for intramolecular bonding interactions)
KuangYu Feb 24, 2022
d807015
feat(classical): Create API for Bond and Angle
WangXinyan940 Feb 28, 2022
74f77fb
Merge branch 'pr/1' into devel
WangXinyan940 Feb 28, 2022
624cdbc
feat (classical): create harmonic bond & angle generators
WangXinyan940 Feb 28, 2022
87f9610
Merge pull request #1 from WangXinyan940/master
Roy-Kid Feb 28, 2022
bb1e736
restructure api.py; ERROR: GPU OOM
Feb 28, 2022
ea2e727
Merge branch 'devel' of github.com:deepmodeling/DMFF into devel
Feb 28, 2022
96d7bc3
fix conflict
Feb 28, 2022
0b90796
some changes for debug
Mar 1, 2022
d2c3b37
fix conflict with classic ff
Mar 1, 2022
4bd1066
fix(classical): fix import relationship
WangXinyan940 Mar 1, 2022
c3916bc
Update
WangXinyan940 Mar 1, 2022
12012ba
feat(classical): make HarmonicBond and HarmonicAngle the same as GAFF
WangXinyan940 Mar 2, 2022
db37d2e
fix OOM bug; api.py:302: add default polarity; api.py:420: move pol&t…
Mar 2, 2022
084913c
fix conflict with oom
Mar 2, 2022
0146984
change default ethresh value to 5e-4, which keep consistent with elec…
Mar 3, 2022
f7ae72b
Merge pull request #6 from Roy-Kid/devel
KuangYu Mar 3, 2022
e60867e
Add new examples for:
KuangYu Mar 3, 2022
d5ae60c
Merge branch 'devel' of github.com:deepmodeling/DMFF into devel
KuangYu Mar 3, 2022
cefc1f1
Fix a bug in qq damping calculation in pairwise.py
KuangYu Mar 3, 2022
7b47ac7
Merge pull request #7 from KuangYu/devel
KuangYu Mar 3, 2022
99cbb5d
ADMP PME api improved
KuangYu Mar 3, 2022
fa59513
Merge pull request #8 from KuangYu/devel
KuangYu Mar 3, 2022
356a2e5
feat(classical): Support torsion force
WangXinyan940 Mar 6, 2022
906bd27
fix(classical): use two attributes to save proper/improper dihedral s…
WangXinyan940 Mar 6, 2022
ac5b212
fix(classical): Jax the parameters when creating forces
WangXinyan940 Mar 6, 2022
dfb81ee
fix(classical): fix a typo
WangXinyan940 Mar 6, 2022
e463ac7
fix(classical): use ndarray to save indexes
WangXinyan940 Mar 6, 2022
971f7bc
fix(classical): return sum of energies for torsion
WangXinyan940 Mar 6, 2022
cbd6f4c
feat(classical): support 4th order for torsion
WangXinyan940 Mar 6, 2022
7180f34
feat(classical): Add UT for classical forcefields
WangXinyan940 Mar 7, 2022
e900404
fix(classical): Update PDB structures needed by test cases
WangXinyan940 Mar 7, 2022
3d4604e
fix(classical): Change atomtypes to be consistent with residues
WangXinyan940 Mar 7, 2022
dc71b5d
feat(classical): add reference energies for test cases
WangXinyan940 Mar 7, 2022
9388bb9
fix(classical): decrease the decimal for energy comparision
WangXinyan940 Mar 7, 2022
a06501c
feat(classical): Use the same way of openmm for dihedral typification
WangXinyan940 Mar 7, 2022
53afbd2
fix(classical): remove unused import
WangXinyan940 Mar 7, 2022
8b31953
fix(classical): add order for impropers
WangXinyan940 Mar 7, 2022
17bc59f
fix(classical): use ndarray instead of list for index saving
WangXinyan940 Mar 7, 2022
f87f21d
fix(classical): Add import element
WangXinyan940 Mar 7, 2022
fb34251
fix(classical): fix misusing between torsion.periodicity and torsion.…
WangXinyan940 Mar 7, 2022
0e37099
fix(classical): misusing between periodicity and phase
WangXinyan940 Mar 7, 2022
0f97ba5
fix(classical): Correct bond connection in unit test pdb files
WangXinyan940 Mar 7, 2022
8e0159d
Fix pdb files in unittest
WangXinyan940 Mar 7, 2022
1ec8035
Update proper1.pdb
WangXinyan940 Mar 7, 2022
1a476b3
feat(classical): update reference energy for improper test
WangXinyan940 Mar 7, 2022
827f384
Update api.py
WangXinyan940 Mar 7, 2022
9984974
feat(classical): Add wildcard testcase for improper
WangXinyan940 Mar 7, 2022
8c480a4
Merge pull request #2 from Roy-Kid/devel
WangXinyan940 Mar 7, 2022
4d69d61
Merge pull request #2 from WangXinyan940/devel
Roy-Kid Mar 7, 2022
1173882
Merge branch 'devel' of github.com:Roy-Kid/DMFF into devel
Mar 7, 2022
c6bfede
set up LennardJones framework
Mar 8, 2022
8535aed
feat(classical): Add test case for multiple dihedrals in one molecule
WangXinyan940 Mar 10, 2022
8f5852b
Modified api.py, change the way axis_type and axis_index are specified
KuangYu Mar 10, 2022
7665420
Remove the old set_axis_type function, which is now redundant
KuangYu Mar 10, 2022
27b8bde
Merge pull request #10 from KuangYu/devel
KuangYu Mar 10, 2022
78dce12
fix(classical): change the way of dihedral calculation
WangXinyan940 Mar 10, 2022
f7b45d9
Merge pull request #3 from WangXinyan940/devel
Roy-Kid Mar 10, 2022
53db236
Merge pull request #3 from Roy-Kid/devel
WangXinyan940 Mar 10, 2022
8cafed0
start to write LJ potential
Mar 11, 2022
58dd46a
Merge branch 'devel' of github.com:Roy-Kid/DMFF into devel
Mar 11, 2022
bd01946
fix conflict with kuang
Mar 11, 2022
3c0fc22
Merge pull request #5 from Roy-Kid/devel
WangXinyan940 Mar 11, 2022
76228c4
feat(classical): Implement 12-6 potential without exclusion
WangXinyan940 Mar 13, 2022
b24f0a7
feat(classical): Add exclusion pairs for LJ force
WangXinyan940 Mar 13, 2022
5be3af1
feat(classical): add simple test for LennardJonesForce
WangXinyan940 Mar 13, 2022
47336ba
fix(classical): fix imp of nbfix
WangXinyan940 Mar 13, 2022
a36f3b9
fix(classical): use more reasonable test case
WangXinyan940 Mar 13, 2022
b88519e
fix(classical): add reference energy
WangXinyan940 Mar 13, 2022
1f40648
Add Slater-ISA style short range damping and exchange terms
KuangYu Mar 13, 2022
70756cd
Merge pull request #4 from WangXinyan940/devel
Roy-Kid Mar 13, 2022
cb2f177
draft for dev lj potential
Mar 13, 2022
aa92a1e
Merge branch 'devel' of github.com:Roy-Kid/DMFF into devel
Mar 13, 2022
6044b9e
fix Zonly typo in api.py:332 which not consistent with line 475
Mar 13, 2022
e4aa292
reduce PME force to point charge calculation
Mar 13, 2022
21d6d08
Remove (commented) redundant code in disp_pme
KuangYu Mar 14, 2022
117dd6c
Fix the aij = sqrt(ai*aj) bug. (NOTE it should be aij = ai * aj
KuangYu Mar 14, 2022
d4e45b2
get a preliminary result of point charge pme caclulation
Mar 16, 2022
9802546
Merge pull request #6 from Roy-Kid/devel
WangXinyan940 Mar 17, 2022
c36db90
feat(classical): support loading charge from residue card and Nonbond…
WangXinyan940 Mar 19, 2022
e8cd925
correct gradient of coul
Mar 19, 2022
3c02a0e
Merge pull request #5 from WangXinyan940/devel
Roy-Kid Mar 19, 2022
dfe9db4
Merge branch 'devel' of github.com:Roy-Kid/DMFF into devel
Mar 19, 2022
60bd78b
Merge pull request #7 from Roy-Kid/devel
WangXinyan940 Mar 20, 2022
9c75220
feat(classical): Add setting for force switching
WangXinyan940 Mar 20, 2022
43a0d7e
feat(classical): Add noPBC support on LJ potential
WangXinyan940 Mar 20, 2022
e682f25
Merge pull request #6 from WangXinyan940/devel
WangXinyan940 Mar 20, 2022
5c3cb0c
review api.py code
Mar 20, 2022
0a4633d
add covalent_map support in lj and coul
Mar 20, 2022
76526c8
feat(classical): Use covalent map to generate exclusions
WangXinyan940 Mar 20, 2022
526dd17
feat(classical): Call LJ in API
WangXinyan940 Mar 20, 2022
e828858
Merge pull request #7 from WangXinyan940/devel
WangXinyan940 Mar 20, 2022
c4af1ec
Merge branch 'devel' of github.com:Roy-Kid/DMFF into devel
Mar 21, 2022
b96f4f2
fix(classical): bug fix on misusing list and jnp.array
WangXinyan940 Mar 21, 2022
b3baf1a
fix(classical): correctly support NoCutoff
WangXinyan940 Mar 21, 2022
2cdef5c
Merge pull request #8 from WangXinyan940/devel
WangXinyan940 Mar 21, 2022
5648706
fix(classical): fix misusing variables
WangXinyan940 Mar 21, 2022
85d04ba
feat(classical): add a testcase for two LJ molecules
WangXinyan940 Mar 21, 2022
c11b493
fix(classical): correct setting of LJ case
WangXinyan940 Mar 21, 2022
6df767f
feat(classical): add a testcase for large molecule (including 1-4) in…
WangXinyan940 Mar 21, 2022
dac3b8a
feat(classical): Add support for reaction-field and no-cutoff in Coul…
WangXinyan940 Mar 27, 2022
075b615
feat(classical): Support more Coulomb potentials (#9)
WangXinyan940 Mar 27, 2022
6eed9e7
imporve colvalent_map support
Mar 27, 2022
fa20c0e
add coulombforce support in api.py
Mar 27, 2022
be425d6
Merge branch 'devel' into devel
WangXinyan940 Mar 27, 2022
ed1d47f
Update PME code (#8)
WangXinyan940 Mar 27, 2022
19ecdbb
feat(classical): add testcases for NoCutoff Coulomb potential and a l…
WangXinyan940 Mar 27, 2022
abda90f
feat(classical): Support differentiable 1-4 scale
WangXinyan940 Mar 27, 2022
d46576e
Merge branch 'devel' into devel
WangXinyan940 Mar 27, 2022
9baf1a6
Devel (#9)
WangXinyan940 Mar 28, 2022
42eb719
feat(classical): add more GAFF2 test cases.
WangXinyan940 Mar 28, 2022
4255097
Add Slater-type short range forces (sr_es, sr_disp, sr_pol, sr_ex, dh…
KuangYu Mar 31, 2022
b39cb31
Add the PEG slater-type short range fitting example
KuangYu Mar 31, 2022
82ead47
fix(classical): remove unnecessary lines
WangXinyan940 Apr 1, 2022
5d42dcf
Changing the why how pair buffers are handled, now it is easier to jit
KuangYu Apr 4, 2022
a93205b
Remove jit for energy_disp_pme, which cause issues
KuangYu Apr 4, 2022
4337a5c
Fix bug in pair buffer treatment.
KuangYu Apr 6, 2022
c6696d7
Add mbpol_intra module in admp, to compute the intramolecular energy
KuangYu Apr 7, 2022
d8f9a18
Fix bug: previous versions does not update U-ind when steps_pol are set
KuangYu Apr 7, 2022
2c434d7
Modify covalent_map in dmff/api.py, making it a jnp object (for jit p…
KuangYu Apr 7, 2022
5ba5aa0
Differentiable classical force field support (#12)
WangXinyan940 Apr 10, 2022
97055e1
Differentiable classical force field support (#12) (#10)
WangXinyan940 Apr 11, 2022
22321d4
fix(classical): use another way to calc exclusion to increase precision
WangXinyan940 Apr 11, 2022
790e6b0
fix(classical): typo
WangXinyan940 Apr 11, 2022
a491217
fix(classical): bug fix on 14scale
WangXinyan940 Apr 11, 2022
2934358
Update inter.py
WangXinyan940 Apr 11, 2022
528bcec
Update inter.py
WangXinyan940 Apr 11, 2022
77ecfc5
feat(classical): Use more robust 1-4 scale method
WangXinyan940 Apr 11, 2022
423fa0d
feat(render): initialize render method
WangXinyan940 Apr 11, 2022
33691fd
Merge remote-tracking branch 'upstream/devel' into devel
WangXinyan940 Apr 11, 2022
73cc5a3
Merge pull request #13 from WangXinyan940/devel
KuangYu Apr 13, 2022
7dd9457
Commit before pull from upstream
KuangYu Apr 13, 2022
ad126a9
Merge remote-tracking branch 'upstream/devel' into devel
KuangYu Apr 13, 2022
ce52667
Merge pull request #14 from KuangYu/devel
KuangYu Apr 13, 2022
b9386e0
checkout new branch for docs only
Apr 18, 2022
d3a1d56
move installation to index page
Apr 18, 2022
c36bf57
refactor(doc): make the doc structure clearer
Ericwang6 Apr 24, 2022
e55b7d6
change(doc): "documentation" -> "Manual"
Ericwang6 Apr 24, 2022
a0114aa
Add convert_harm2cart in multipole.py
KuangYu Apr 25, 2022
eec3325
Merge branch 'deepmodeling:devel' into devel
KuangYu Apr 25, 2022
c84d63f
Merge pull request #18 from KuangYu/devel
KuangYu Apr 25, 2022
369f391
Update README.md
KuangYu May 2, 2022
29cdd68
Update theory.md
KuangYu May 2, 2022
6966290
Went over docs, first pass
KuangYu May 4, 2022
c62b90c
Modify README.md and index.md
KuangYu May 5, 2022
31f1b87
Merge pull request #16 from Roy-Kid/docs
KuangYu May 5, 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
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

# temporary
err
out
sub.sh
*.npy

### C++ ###
# Prerequisites
*.d
Expand Down Expand Up @@ -463,7 +470,6 @@ StyleCopReport.xml
*.ilk
*.meta
*.iobj
*.pdb
*.ipdb
*.pgc
*.pgd
Expand Down Expand Up @@ -769,3 +775,4 @@ FodyWeavers.xsd

### VisualStudio Patch ###
# Additional files built by Visual Studio
.vscode/**
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
# DMFF
Differentiable Molecular Force Field

**DMFF** (**D**ifferentiable **M**olecular **F**orce **F**ield) is a Jax-based python package that provides a full differentiable implementation of molecular force field models. This project aims to establish an extensible codebase to minimize the efforts in force field parameterization, and to ease the force and virial tensor evaluations for advanced complicated potentials (e.g., polarizable models with geometry-dependent atomic parameters). Currently, this project mainly focuses on the molecular systems such as: water, biological macromolecules (peptides, proteins, nucleic acids), organic polymers, and small organic molecules (organic electrolyte, drug-like molecules) etc. We support both the conventional point charge models (OPLS and AMBER like) and multipolar polarizable models (AMOEBA and MPID like). The entire project is backed by the XLA technique in JAX, thus can be "jitted" and run in GPU devices much more efficiently compared to normal python codes.

The behavior of organic molecular systems (e.g., protein folding, polymer structure, etc.) is often determined by a complex effect of many different types of interactions. The existing organic molecular force fields are mainly empirically fitted and their performance relies heavily on error cancellation. Therefore, the transferability and the prediction power of these force fields are insufficient. For new molecules, the parameter fitting process requires essential manual intervention and can be quite cumbersome. In order to automate the parametrization process and increase the robustness of the model, it is necessary to apply modern AI techniques in conventional force field development. This project serves for this purpose by utilizing the automatic differentiable programming technique to develop a codebase, which allows a more convenient incorporation of modern AI optimization techniques. It also helps the realization of many exciting functions including (but not limited to): hybrid machine learning/force field models and parameter optimization based on trajectory.

## User Guide

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

## Developer Guide
+ [1. Introduction](dev_guide/introduction.md)
+ [2. Architecture](dev_guide/arch.md)
+ [3. Convention](dev_guide/convention.md)

## Modules
+ [1. ADMP](modules/admp.md)


## Support and Contribution

Please visit our repository on [GitHub](https://github.com/deepmodeling/DMFF) for the library source code. Any issues or bugs may be reported at our issue tracker. All contributions to DMFF are welcomed via pull requests!
147 changes: 41 additions & 106 deletions dmff/admp/disp_pme.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import jax.numpy as jnp
from jax import vmap, value_and_grad
from dmff.utils import jit_condition
from dmff.utils import jit_condition, regularize_pairs, pair_buffer_scales
from dmff.admp.spatial import pbc_shift
from dmff.admp.pme import setup_ewald_parameters
from dmff.admp.recip import generate_pme_recip, Ck_6, Ck_8, Ck_10
Expand All @@ -14,17 +14,24 @@ class ADMPDispPmeForce:
The so called "environment paramters" means parameters that do not need to be differentiable
'''

def __init__(self, box, covalent_map, rc, ethresh, pmax):
def __init__(self, box, covalent_map, rc, ethresh, pmax, lpme=True):
self.covalent_map = covalent_map
self.rc = rc
self.ethresh = ethresh
self.pmax = pmax
# Need a different function for dispersion ??? Need tests
kappa, K1, K2, K3 = setup_ewald_parameters(rc, ethresh, box)
self.kappa = kappa
self.K1 = K1
self.K2 = K2
self.K3 = K3
self.lpme = lpme
if lpme:
kappa, K1, K2, K3 = setup_ewald_parameters(rc, ethresh, box)
self.kappa = kappa
self.K1 = K1
self.K2 = K2
self.K3 = K3
else:
self.kappa = 0.0
self.K1 = 0
self.K2 = 0
self.K3 = 0
self.pme_order = 6
# setup calculators
self.refresh_calculators()
Expand All @@ -36,7 +43,7 @@ def get_energy(positions, box, pairs, c_list, mScales):
return energy_disp_pme(positions, box, pairs,
c_list, mScales, self.covalent_map,
self.kappa, self.K1, self.K2, self.K3, self.pmax,
self.d6_recip, self.d8_recip, self.d10_recip)
self.d6_recip, self.d8_recip, self.d10_recip, lpme=self.lpme)
return get_energy


Expand Down Expand Up @@ -70,7 +77,7 @@ def refresh_calculators(self):
def energy_disp_pme(positions, box, pairs,
c_list, mScales, covalent_map,
kappa, K1, K2, K3, pmax,
recip_fn6, recip_fn8, recip_fn10):
recip_fn6, recip_fn8, recip_fn10, lpme=True):
'''
Top level wrapper for dispersion pme

Expand All @@ -95,22 +102,29 @@ def energy_disp_pme(positions, box, pairs,
int: max K for reciprocal calculations
pmax:
int array: maximal exponents (p) to compute, e.g., (6, 8, 10)
lpme:
bool: whether do pme or not, useful when doing cluster calculations

Output:
energy: total dispersion pme energy
'''

ene_real = disp_pme_real(positions, box, pairs, c_list, mScales, covalent_map, kappa, pmax)
if lpme is False:
kappa = 0

ene_recip = recip_fn6(positions, box, c_list[:, 0, jnp.newaxis])
if pmax >= 8:
ene_recip += recip_fn8(positions, box, c_list[:, 1, jnp.newaxis])
if pmax >= 10:
ene_recip += recip_fn10(positions, box, c_list[:, 2, jnp.newaxis])
ene_real = disp_pme_real(positions, box, pairs, c_list, mScales, covalent_map, kappa, pmax)

ene_self = disp_pme_self(c_list, kappa, pmax)
if lpme:
ene_recip = recip_fn6(positions, box, c_list[:, 0, jnp.newaxis])
if pmax >= 8:
ene_recip += recip_fn8(positions, box, c_list[:, 1, jnp.newaxis])
if pmax >= 10:
ene_recip += recip_fn10(positions, box, c_list[:, 2, jnp.newaxis])
ene_self = disp_pme_self(c_list, kappa, pmax)
return ene_real + ene_recip + ene_self

return ene_real + ene_recip + ene_self
else:
return ene_real


def disp_pme_real(positions, box, pairs,
Expand Down Expand Up @@ -144,24 +158,26 @@ def disp_pme_real(positions, box, pairs,
'''

# expand pairwise parameters
pairs = pairs[pairs[:, 0] < pairs[:, 1]]
# pairs = pairs[pairs[:, 0] < pairs[:, 1]]
pairs = regularize_pairs(pairs)

box_inv = jnp.linalg.inv(box)

ri = distribute_v3(positions, pairs[:, 0])
rj = distribute_v3(positions, pairs[:, 1])
# ri = positions[pairs[:, 0]]
# rj = positions[pairs[:, 1]]
nbonds = covalent_map[pairs[:, 0], pairs[:, 1]]
mscales = distribute_scalar(mScales, nbonds-1)
# mscales = mScales[nbonds-1]

buffer_scales = pair_buffer_scales(pairs)
mscales = mscales * buffer_scales

ci = distribute_dispcoeff(c_list, pairs[:, 0])
cj = distribute_dispcoeff(c_list, pairs[:, 1])
# ci = c_list[pairs[:, 0], :]
# cj = c_list[pairs[:, 1], :]

ene_real = jnp.sum(disp_pme_real_kernel(ri, rj, ci, cj, box, box_inv, mscales, kappa, pmax))
ene_real = jnp.sum(
disp_pme_real_kernel(ri, rj, ci, cj, box, box_inv, mscales, kappa, pmax)
* buffer_scales
)

return jnp.sum(ene_real)

Expand Down Expand Up @@ -193,6 +209,7 @@ def disp_pme_real_kernel(ri, rj, ci, cj, box, box_inv, mscales, kappa, pmax):
dr = ri - rj
dr = pbc_shift(dr, box, box_inv)
dr2 = jnp.dot(dr, dr)

x2 = kappa * kappa * dr2
g = g_p(x2, pmax)
dr6 = dr2 * dr2 * dr2
Expand Down Expand Up @@ -269,85 +286,3 @@ def disp_pme_self(c_list, kappa, pmax):
return E


# 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))
# nmol=int(n_atoms/3)
# for i in range(nmol):
# a = i*3
# b = i*3+1
# c = i*3+2
# c_list[0][a]=37.19677405
# 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
# c_list = jnp.array(c_list.T)


# # Finish data preparation
# # -------------------------------------------------------------------------------------
# # pme_order = 6
# # d6_recip = generate_pme_recip(Ck_6, kappa, True, pme_order, K1, K2, K3, 0)
# # d8_recip = generate_pme_recip(Ck_8, kappa, True, pme_order, K1, K2, K3, 0)
# # d10_recip = generate_pme_recip(Ck_10, kappa, True, pme_order, K1, K2, K3, 0)
# # disp_pme_recip_fns = [d6_recip, d8_recip, d10_recip]
# # energy_force_disp_pme = value_and_grad(energy_disp_pme)
# # e, f = energy_force_disp_pme(positions, box, pairs, c_list, mScales, covalent_map, kappa, K1, K2, K3, pmax, *disp_pme_recip_fns)
# # print('ok')
# # e, f = energy_force_disp_pme(positions, box, pairs, c_list, mScales, covalent_map, kappa, K1, K2, K3, pmax, *disp_pme_recip_fns)
# # print(e)

# disp_pme_force = ADMPDispPmeForce(box, covalent_map, rc, ethresh, pmax)
# disp_pme_force.update_env('kappa', 0.657065221219616)

# print(c_list[:4])
# E, F = disp_pme_force.get_forces(positions, box, pairs, c_list, mScales)
# print('ok')
# E, F = disp_pme_force.get_forces(positions, box, pairs, c_list, mScales)
# print(E)
# return


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