Skip to content

Instantly share code, notes, and snippets.

@rmcgibbo
Created April 6, 2014 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmcgibbo/10003050 to your computer and use it in GitHub Desktop.
Save rmcgibbo/10003050 to your computer and use it in GitHub Desktop.
Two interacting point charges.
from simtk.openmm import *
from pylab import *
system = System()
system.addParticle(0)
system.addParticle(0)
system.setDefaultPeriodicBoxVectors([10,0,0], [0, 10, 0], [0, 0, 10])
force = NonbondedForce()
force.setNonbondedMethod(NonbondedForce.PME)
force.addParticle(1.0, 1.0, 0.0)
force.addParticle(-1.0, 1.0, 0.0)
force.setCutoffDistance(5.0)
system.addForce(force)
context = Context(system, VerletIntegrator(0))
displacements = linspace(0.5, 2, 1000)
energies = []
for r in displacements:
context.setPositions([[0,0,0], [r,0,0]])
energies.append(context.getState(getEnergy=True).getPotentialEnergy()._value)
plot(displacements, energies, 'bx-')
title('PME Interaction Energy. Platform=%s' % context.getPlatform().getName())
xlabel('Displacement')
ylabel('Energy')
show()
@schwancr
Copy link

schwancr commented Apr 6, 2014

woo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment