Commit ce6af5fd authored by Peter Eastman's avatar Peter Eastman
Browse files

Minor improvements to test script

parent dc8625a0
...@@ -24,7 +24,7 @@ print ...@@ -24,7 +24,7 @@ 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, platform.getName(), print i+1, platform.getName(),
integrator = LangevinIntegrator(300*kelvin, 1/picosecond, 0.002*picoseconds) integrator = LangevinIntegrator(300*kelvin, 1/picosecond, 0.002*picoseconds)
simulation = Simulation(pdb.topology, system, integrator, platform) simulation = Simulation(pdb.topology, system, integrator, platform)
simulation.context.setPositions(pdb.positions) simulation.context.setPositions(pdb.positions)
...@@ -36,15 +36,16 @@ for i in range(numPlatforms): ...@@ -36,15 +36,16 @@ for i in range(numPlatforms):
# See how well the platforms agree. # See how well the platforms agree.
print if numPlatforms > 1:
print "Maximum difference in forces between platforms:" print
print print "Median difference in forces between platforms:"
for i in range(numPlatforms): print
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:
maxError = 0.0 errors = []
for f1, f2 in zip(forces[i], forces[j]): for f1, f2 in zip(forces[i], forces[j]):
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]))
maxError = max(maxError, error) errors.append(error)
print "%s vs. %s: %g" % (Platform.getPlatform(j).getName(), Platform.getPlatform(i).getName(), maxError) print "%s vs. %s: %g" % (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