openmm / openmmforcefields

CHARMM and AMBER forcefields for OpenMM (with small molecule support)
http://openmm.org
Other
249 stars 80 forks source link

GPU acceleration #103

Open tarungog opened 4 years ago

tarungog commented 4 years ago

Can AMBER be accelerated by GPU in the openmm environment? or no

peastman commented 4 years ago

Yes. All calculations are supported on GPUs.

jchodera commented 4 years ago

Do you want to bring AMBER input files from the AMBER ecosystem, or do you want to apply AMBER parameters to a PDB file within the OpenMM ecosystem?

tarungog commented 4 years ago

I would like to use gpu GAFF on an RDKit small molecule @jchodera . Do you have any guidelines or starter code for how I might implement this?

jchodera commented 4 years ago

Sure! You can use this example, and just preface it with code to convert your RDKit molecule (let's call it rdmol) to an Open Force Field Molecule:

from openforcefield.topology import Molecule
molecule = Molecule.from_rdkit(rdmol)

The rest of the code is the same as in the example!

tarungog commented 4 years ago

awesome @jchodera. I'm assuming there's a similar to_rdkit function to get the minimized conformer(s) back?

tarungog commented 4 years ago

Getting an error, wondering if you know anything about it.

Edit: @jchodera still struggling with the same problem, wondering if you have any insight.

AllChem.EmbedMultipleConfs(molOrig)
Chem.rdmolops.AssignAtomChiralTagsFromStructure(molOrig)
from openforcefield.topology import Molecule
molecule = Molecule.from_rdkit(molOrig)

forcefield_kwargs = { 'constraints' : app.HBonds, 'rigidWater' : True, 'removeCMMotion' : False, 'hydrogenMass' : 4*unit.amu }
# Initialize a SystemGenerator using GAFF
from openmmforcefields.generators import SystemGenerator
system_generator = SystemGenerator(forcefields=['amber/ff14SB.xml', 'amber/tip3p_standard.xml'], small_molecule_forcefield='gaff-2.11', forcefield_kwargs=forcefield_kwargs, cache='db.json')
# Create an OpenMM System from an Open Force Field toolkit Topology object
system = system_generator.create_system(molecule.to_topology())

Produces error:

AttributeError                            Traceback (most recent call last)
<ipython-input-17-f0ca2e3ce49f> in <module>
      4 system_generator = SystemGenerator(forcefields=['amber/ff14SB.xml', 'amber/tip3p_standard.xml'], small_molecule_forcefield='gaff-2.11', forcefield_kwargs=forcefield_kwargs, cache='db.json')
      5 # Create an OpenMM System from an Open Force Field toolkit Topology object
----> 6 system = system_generator.create_system(molecule.to_topology())
      7 
      8 

~/.conda/envs/my-rdkit-env/lib/python3.6/site-packages/openmmforcefields/generators/system_generators.py in create_system(self, topology, molecules)
    299         import copy
    300         forcefield_kwargs = copy.deepcopy(self.forcefield_kwargs)
--> 301         if topology.getPeriodicBoxVectors() is None:
    302             forcefield_kwargs.update(self.nonperiodic_forcefield_kwargs)
    303         else:

AttributeError: 'Topology' object has no attribute 'getPeriodicBoxVectors'

Using openmm topology produces a different error:

image

It looks like it's expecting a protein, but I am trying to use GAFF for small molecules.

tarungog commented 4 years ago

Also dealing with a separate error if I do not EmbedMolecules into 3d in RDKit before I convert to openff topology:

78624515-d046a500-7857-11ea-8ef3-c8bb021658f5