Skip to content

Commit

Permalink
Explicit support nopbc calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
WangXinyan940 committed Oct 24, 2023
1 parent 919bef2 commit 6de2f47
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions dmff/api/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,8 @@ def getEquivalentAtoms(self):
return eqv_atoms

def getPeriodicBoxVectors(self, use_jax=True):
if self.cell is None:
return None
if use_jax:
return jnp.array(self.cell)
return self.cell
Expand Down
21 changes: 14 additions & 7 deletions dmff/generators/admp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,12 +1115,13 @@ def createPotential(
):
methodMap = {
app.CutoffPeriodic: "CutoffPeriodic",
app.CutoffNonPeriodic, "CutoffNonPeriodic",
app.NoCutoff: "NoCutoff",
app.PME: "PME",
}
if nonbondedMethod not in methodMap:
raise ValueError("Illegal nonbonded method for ADMPPmeForce")
if nonbondedMethod is app.CutoffPeriodic:
if nonbondedMethod in [app.CutoffPeriodic, app.NoCutoff, app.CutoffNonPeriodic]:
lpme = False
else:
lpme = True
Expand All @@ -1139,15 +1140,21 @@ def createPotential(
map_poltype[i] = self._find_polarize_key_index(atype)

# here box is only used to setup ewald parameters, no need to be differentiable
if lpme:
box = topdata.getPeriodicBoxVectors() * 10
box = topdata.getPeriodicBoxVectors()
if box is not None:
noPBC = False
box = jnp.array(box) * 10.0
else:
box = jnp.ones((3, 3))
noPBC = True
box = jnp.eye(3) * 1.0e6
# get the admp calculator
if unit.is_quantity(nonbondedCutoff):
rc = nonbondedCutoff.value_in_unit(unit.angstrom)
if noPBC:
rc = 10000.0
else:
rc = nonbondedCutoff * 10.0
if unit.is_quantity(nonbondedCutoff):
rc = nonbondedCutoff.value_in_unit(unit.angstrom)
else:
rc = nonbondedCutoff * 10.0

# build covalent map
covalent_map = topdata.buildCovMat()
Expand Down

0 comments on commit 6de2f47

Please sign in to comment.