Skip to content

Commit

Permalink
Improved accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
craabreu committed May 9, 2024
1 parent 66353c5 commit 03de33c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cvpack/shortest_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import typing as t

import numpy as np
import openmm
from openmm import unit as mmunit

Expand All @@ -27,17 +28,17 @@ class ShortestDistance(CollectiveVariable, openmm.CustomCVForce):
.. math::
S_{rw}({\bf r}) = r_c +
S_{rw}({\bf r}) = r_c e^{-\beta} +
\sum_{i \in {\bf g}_1} \sum_{j \in {\bf g}_2 \atop r_{ij} < r_c}
r_{ij} e^{\beta \left(1-\frac{r_{ij}}{r_c}\right)}
r_{ij} e^{-\beta \frac{r_{ij}}{r_c}}
and
.. math::
S_w({\bf r}) = 1 +
S_w({\bf r}) = e^{-\beta} +
\sum_{i \in {\bf g}_1} \sum_{j \in {\bf g}_2 \atop r_{ij} < r_c}
e^{\beta \left(1-\frac{r_{ij}}{r_c}\right)}
r_{ij} e^{-\beta \frac{r_{ij}}{r_c}}
where :math:`r_{ij} = \|{\bf r}_j - {\bf r}_i\|` is the distance between atoms
:math:`i` and :math:`j`, :math:`{\bf g}_1` and :math:`{\bf g}_2` are the sets of
Expand Down Expand Up @@ -118,12 +119,12 @@ def __init__(
rc = cutoffDistance
if mmunit.is_quantity(rc):
rc = rc.value_in_unit(mmunit.nanometers)
weight = f"exp({beta}*(1-r/{rc}))"
weight = f"exp(-{beta/rc}*r)"
forces = {
"wrsum": openmm.CustomNonbondedForce(f"{weight}*r"),
"wsum": openmm.CustomNonbondedForce(weight),
}
super().__init__(f"({rc}+wrsum)/(1+wsum)")
super().__init__(f"({rc*np.exp(-beta)}+wrsum)/({np.exp(-beta)}+wsum)")
for cv, force in forces.items():
force.setNonbondedMethod(
force.CutoffPeriodic if pbc else force.CutoffNonPeriodic
Expand Down

0 comments on commit 03de33c

Please sign in to comment.