Commit fb3f0677 authored by peastman's avatar peastman
Browse files

Workaround for limitations of NamedTemporaryFile on Windows

parent 0a214970
...@@ -5,6 +5,7 @@ from simtk.openmm import * ...@@ -5,6 +5,7 @@ from simtk.openmm import *
from simtk.unit import * from simtk.unit import *
import simtk.openmm.app.element as elem import simtk.openmm.app.element as elem
import math import math
import os
import tempfile import tempfile
import warnings import warnings
if sys.version_info >= (3,0): if sys.version_info >= (3,0):
...@@ -337,10 +338,11 @@ class TestCharmmFiles(unittest.TestCase): ...@@ -337,10 +338,11 @@ class TestCharmmFiles(unittest.TestCase):
# The following values were computed with CHARMM. # The following values were computed with CHARMM.
modeEnergy = {0: 754318.20507, 1: 754318.20507, 2: 908.35224, 3: 59.65279, 4: -241.12856, 5: 39.13169} modeEnergy = {0: 754318.20507, 1: 754318.20507, 2: 908.35224, 3: 59.65279, 4: -241.12856, 5: 39.13169}
for nbxmod in range(-5, 6): for nbxmod in range(-5, 6):
with tempfile.NamedTemporaryFile(suffix='.par', mode='w') as parfile: with tempfile.NamedTemporaryFile(suffix='.par', mode='w', delete=False) as parfile:
parfile.write(par.replace('nbxmod 5', 'nbxmod %d' % nbxmod)) parfile.write(par.replace('nbxmod 5', 'nbxmod %d' % nbxmod))
parfile.flush() parfile.close()
params = CharmmParameterSet('systems/charmm22.rtf', parfile.name) params = CharmmParameterSet('systems/charmm22.rtf', parfile.name)
os.remove(parfile.name)
system = self.psf_c.createSystem(params, nonbondedMethod=NoCutoff) system = self.psf_c.createSystem(params, nonbondedMethod=NoCutoff)
context = Context(system, VerletIntegrator(1*femtoseconds), Platform.getPlatformByName('Reference')) context = Context(system, VerletIntegrator(1*femtoseconds), Platform.getPlatformByName('Reference'))
context.setPositions(crd.positions) context.setPositions(crd.positions)
......
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