Created
April 6, 2014 08:23
-
-
Save rmcgibbo/10003050 to your computer and use it in GitHub Desktop.
Two interacting point charges.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
woo!