diff --git a/dmff/api/topology.py b/dmff/api/topology.py index 0d44affb3..bc8c459a6 100644 --- a/dmff/api/topology.py +++ b/dmff/api/topology.py @@ -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 diff --git a/dmff/generators/admp.py b/dmff/generators/admp.py index 541e8146f..bcfeef236 100644 --- a/dmff/generators/admp.py +++ b/dmff/generators/admp.py @@ -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 @@ -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()