Skip to content

Instantly share code, notes, and snippets.

@tjlane
Created June 14, 2013 04:37
Show Gist options
  • Save tjlane/5779491 to your computer and use it in GitHub Desktop.
Save tjlane/5779491 to your computer and use it in GitHub Desktop.
TJ's attempt to run Lee-Ping's water model in OpenMM 5.1
#!/usr/bin/env python
"""
Run a simple water simulation.
"""
from __future__ import print_function
from simtk.openmm.app import *
from simtk.openmm import *
from simtk.unit import *
from sys import stdout
pdb = PDBFile('water512_mod.pdb')
forcefield = ForceField('iamoeba.xml')
#forcefield = ForceField('tip3p.xml')
system = forcefield.createSystem(pdb.topology, nonbondedMethod=PME,
nonbondedCutoff=0.7*nanometers, vdwCutoff=0.9*nanometer,
constraints=None, rigidWater=False) #,
#polarization='direct', useDispersionCorrection=True)
integrator = LangevinIntegrator(300*kelvin, 1.0/picoseconds, 0.5*femtoseconds)
integrator.setConstraintTolerance(0.00001)
platform = Platform.getPlatformByName('CUDA')
properties = {'CudaPrecision': 'mixed', 'CudaDeviceIndex': '2'}
simulation = Simulation(pdb.topology, system, integrator, platform, properties)
simulation.context.setPositions(pdb.positions)
print('Minimizing...')
simulation.minimizeEnergy()
simulation.context.setVelocitiesToTemperature(300*kelvin)
print('Equilibrating...')
simulation.step(100)
simulation.reporters.append(DCDReporter('output.dcd', 1000))
simulation.reporters.append(StateDataReporter(stdout, 1000, step=True,
potentialEnergy=True, temperature=True))
print('Running Production...')
simulation.step(1000)
print('Done!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment