"platforms/opencl/src/OpenCLArray.cpp" did not exist on "6e434a02b299ed8abfcebda6eecf2e6aeea20c68"
Commit 443dceb8 authored by Robert McGibbon's avatar Robert McGibbon
Browse files

make testInstallation py2/3

parent 8f9f824e
from __future__ import print_function
# First make sure OpenMM is installed. # First make sure OpenMM is installed.
import sys import sys
try: try:
from simtk.openmm.app import * from simtk.openmm.app import *
from simtk.openmm import * from simtk.openmm import *
from simtk.unit import * from simtk.unit import *
except ImportError as err: except ImportError as err:
print "Failed to import OpenMM packages:", err.message print("Failed to import OpenMM packages:", err.message)
print "Make sure OpenMM is installed and the library path is set correctly." print("Make sure OpenMM is installed and the library path is set correctly.")
sys.exit() sys.exit()
# Create a System for the tests. # Create a System for the tests.
...@@ -19,28 +21,28 @@ system = forcefield.createSystem(pdb.topology, nonbondedMethod=PME, nonbondedCut ...@@ -19,28 +21,28 @@ system = forcefield.createSystem(pdb.topology, nonbondedMethod=PME, nonbondedCut
# List all installed platforms and compute forces with each one. # List all installed platforms and compute forces with each one.
numPlatforms = Platform.getNumPlatforms() numPlatforms = Platform.getNumPlatforms()
print "There are", numPlatforms, "Platforms available:" print("There are", numPlatforms, "Platforms available:")
print print()
forces = [None]*numPlatforms forces = [None]*numPlatforms
for i in range(numPlatforms): for i in range(numPlatforms):
platform = Platform.getPlatform(i) platform = Platform.getPlatform(i)
print i+1, platform.getName(), print(i+1, platform.getName(), end=" ")
integrator = LangevinIntegrator(300*kelvin, 1/picosecond, 0.002*picoseconds) integrator = LangevinIntegrator(300*kelvin, 1/picosecond, 0.002*picoseconds)
try: try:
simulation = Simulation(pdb.topology, system, integrator, platform) simulation = Simulation(pdb.topology, system, integrator, platform)
simulation.context.setPositions(pdb.positions) simulation.context.setPositions(pdb.positions)
forces[i] = simulation.context.getState(getForces=True).getForces() forces[i] = simulation.context.getState(getForces=True).getForces()
del simulation del simulation
print "- Successfully computed forces" print("- Successfully computed forces")
except: except:
print "- Error computing forces with", platform.getName(), "platform" print("- Error computing forces with", platform.getName(), "platform")
# See how well the platforms agree. # See how well the platforms agree.
if numPlatforms > 1: if numPlatforms > 1:
print print()
print "Median difference in forces between platforms:" print("Median difference in forces between platforms:")
print print()
for i in range(numPlatforms): for i in range(numPlatforms):
for j in range(i): for j in range(i):
if forces[i] is not None and forces[j] is not None: if forces[i] is not None and forces[j] is not None:
...@@ -49,4 +51,6 @@ if numPlatforms > 1: ...@@ -49,4 +51,6 @@ if numPlatforms > 1:
d = f1-f2 d = f1-f2
error = sqrt((d[0]*d[0]+d[1]*d[1]+d[2]*d[2])/(f1[0]*f1[0]+f1[1]*f1[1]+f1[2]*f1[2])) error = sqrt((d[0]*d[0]+d[1]*d[1]+d[2]*d[2])/(f1[0]*f1[0]+f1[1]*f1[1]+f1[2]*f1[2]))
errors.append(error) errors.append(error)
print "%s vs. %s: %g" % (Platform.getPlatform(j).getName(), Platform.getPlatform(i).getName(), sorted(errors)[len(errors)/2]) print("{} vs. {}: {:g}".format(Platform.getPlatform(j).getName(),
Platform.getPlatform(i).getName(),
sorted(errors)[len(errors)//2]))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment