openmm / openmm-ml

High level API for using machine learning models in OpenMM simulations
Other
80 stars 25 forks source link

Particle coordinate is NaN #43

Closed kexul closed 1 year ago

kexul commented 1 year ago

Hi developers: I'm trying to simulate a ligand in the solvent with the ML potential, but it fails immediately with the error Particle coordinate is NaN., the system runs fine under MM forcefield. Any idea? Thanks!

Code and input:

from sys import stdout
from openmmml import MLPotential
from openmm.app import *
from openmm import *
from openmm.unit import *
from openmm.unit import picosecond, picoseconds

prmtop = AmberPrmtopFile('box.prm7')
inpcrd = AmberInpcrdFile('box.rst7')

mm_system = prmtop.createSystem(nonbondedMethod=PME, nonbondedCutoff=1*nanometer, constraints=None)

res = list(prmtop.topology.residues())
ml_atoms = [atom.index for atom in res[0].atoms()]

potential = MLPotential('ani2x')
system = potential.createMixedSystem(prmtop.topology, mm_system, ml_atoms)

integrator = LangevinIntegrator(300*kelvin, 1/picosecond, 0.002*picoseconds)
simulation = Simulation(prmtop.topology, system, integrator)
simulation.context.setPositions(inpcrd.positions)
simulation.minimizeEnergy()
simulation.reporters.append(PDBReporter('output.pdb', 1000))
simulation.reporters.append(StateDataReporter(stdout, 1000, step=True, potentialEnergy=True, temperature=True))
simulation.step(300000)

temp.zip

Here is the full output:

Traceback (most recent call last):
File "test.py", line 40, in <module>
simulation.step(300000)
File "/root/mambaforge/envs/opm8/lib/python3.9/site-packages/openmm/app/simulation.py", line 141, in step
self._simulate(endStep=self.currentStep+steps)
File "/root/mambaforge/envs/opm8/lib/python3.9/site-packages/openmm/app/simulation.py", line 206, in _simulate
self.integrator.step(10) # Only take 10 steps at a time, to give Python more chances to respond to a control-c.
File "/root/mambaforge/envs/opm8/lib/python3.9/site-packages/openmm/openmm.py", line 12696, in step
return _openmm.LangevinIntegrator_step(self, steps)
openmm.OpenMMException: Particle coordinate is NaN. For more information, see https://github.com/openmm/openmm/wiki/Frequently-Asked-Questions#nan
kexul commented 1 year ago

Set 0.001 picosecond timestep solved it:

integrator = LangevinIntegrator(300*kelvin, 1/picosecond, 0.001*picoseconds)