Skip to content

Commit 6ae17c7

Browse files
committed
Add two features to stop short range failure:
1. hard core potential associated with Slater function 2. bounded dipole (use soft truncation)
1 parent 09a858c commit 6ae17c7

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

dmff/admp/pairwise.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,11 @@ def slater_sr_kernel(dr, m, ai, aj, bi, bj):
165165
br = b * dr
166166
br2 = br * br
167167
P = 1/3 * br2 + br + 1
168-
return a * P * jnp.exp(-br) * m
168+
# hard core potential
169+
x = 3.9/br
170+
x2 = x * x
171+
x4 = x2 * x2
172+
x8 = x4 * x4
173+
x14 = x8 * x2 * x4
174+
return a * (P * jnp.exp(-br) + x14) * m
169175

dmff/admp/pme.py

+11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@
3232

3333
DEFAULT_THOLE_WIDTH = 5.0
3434

35+
# variables used in soft dipole truncation
36+
MAX_DIP = 1.0
37+
TRUNCATION_HARDNESS = 25 # the smaller, the softer
38+
def SOFT_TRUNCATION(x):
39+
x2 = x * x
40+
x_abs = jnp.sqrt(x2 + 1e-6)
41+
val = -1/TRUNCATION_HARDNESS * jnp.log(1 + jnp.exp(-TRUNCATION_HARDNESS*(x_abs-MAX_DIP))) + MAX_DIP
42+
return val * x/x_abs
43+
3544

3645
class ADMPPmeForce:
3746
"""
@@ -416,6 +425,8 @@ def update_U(i, U):
416425
dScales,
417426
)
418427
U = U - field * pol[:, jnp.newaxis] / DIELECTRIC
428+
# soft truncation: stop polarization catastrophe
429+
U = SOFT_TRUNCATION(U)
419430
return U
420431

421432
U = jax.lax.fori_loop(0, steps_pol, update_U, U)

0 commit comments

Comments
 (0)