Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update damp function in qeq module #190

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 dmff/admp/qeq.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,20 @@ def E_sr(pos, box, pairs, q, eta, buffer_scales, pbc_flag):

@jit_condition(static_argnums=[6])
def E_sr2(pos, box, pairs, q, eta, buffer_scales, pbc_flag):
"""
eta: Gaussian width in angstrom
"""
# pairwise interaction
ds = ds_pairs(pos, box, pairs, pbc_flag)
etasqrt = jnp.sqrt(2 * (eta[pairs[:, 0]] ** 2 + eta[pairs[:, 1]] ** 2))
pre_pair = -eta_piecewise(etasqrt, ds) * DIELECTRIC
pre_self = etainv_piecewise(eta) / (jnp.sqrt(2 * jnp.pi)) * DIELECTRIC
e_sr_pair = pre_pair * q[pairs[:, 0]] * q[pairs[:, 1]] / ds * buffer_scales
e_sr_pair = mask_to_zero(e_sr_pair, buffer_scales)

# self interaction
pre_self = etainv_piecewise(eta) / (2 * jnp.sqrt(jnp.pi)) * DIELECTRIC
e_sr_self = pre_self * q * q

e_sr = jnp.sum(e_sr_pair) + jnp.sum(e_sr_self)
return e_sr

Expand Down
17 changes: 15 additions & 2 deletions dmff/common/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
import numpy as np
from scipy import constants

DIELECTRIC = 1389.35455846
SQRT_PI = np.sqrt(np.pi)
j2ev = constants.physical_constants["joule-electron volt relationship"][0]
# kJ/mol to eV/particle
energy_coeff = j2ev * constants.kilo / constants.Avogadro
# vacuum electric permittivity in eV^-1 * angstrom^-1
epsilon = constants.epsilon_0 / constants.elementary_charge * constants.angstrom
# qqrd2e = 1 / (4 * np.pi * epsilon)
# # eV
# dielectric = 1 / (4 * np.pi * epsilon)
# kJ/mol
DIELECTRIC = 1 / (4 * np.pi * epsilon) / energy_coeff
# DIELECTRIC = 1389.35455846
SQRT_PI = np.sqrt(np.pi)

__all__ = ["DIELECTRIC", "SQRT_PI"]
Loading