def runOneTest(testName, options): """Perform a single benchmarking simulation.""" explicit = (testName in ('rf', 'pme', 'amoebapme')) amoeba = (testName in ('amoebagk', 'amoebapme')) apoa1 = testName.startswith('apoa1') hydrogenMass = None print() if amoeba: print('Test: %s (epsilon=%g)' % (testName, options.epsilon)) elif testName == 'pme': print('Test: pme (cutoff=%g)' % options.cutoff) else: print('Test: %s' % testName) platform = mm.Platform.getPlatformByName(options.platform) # Create the System. if amoeba: constraints = None epsilon = float(options.epsilon) if explicit: ff = app.ForceField('amoeba2009.xml') pdb = app.PDBFile('5dfr_solv-cube_equil.pdb') cutoff = 0.7 * unit.nanometers vdwCutoff = 0.9 * unit.nanometers system = ff.createSystem(pdb.topology, nonbondedMethod=app.PME, nonbondedCutoff=cutoff, vdwCutoff=vdwCutoff, constraints=constraints, ewaldErrorTolerance=0.00075, mutualInducedTargetEpsilon=epsilon, polarization=options.polarization) else: ff = app.ForceField('amoeba2009.xml', 'amoeba2009_gk.xml') pdb = app.PDBFile('5dfr_minimized.pdb') cutoff = 2.0 * unit.nanometers vdwCutoff = 1.2 * unit.nanometers system = ff.createSystem(pdb.topology, nonbondedMethod=app.NoCutoff, constraints=constraints, mutualInducedTargetEpsilon=epsilon, polarization=options.polarization) for f in system.getForces(): if isinstance(f, mm.AmoebaMultipoleForce) or isinstance( f, mm.AmoebaVdwForce) or isinstance( f, mm.AmoebaGeneralizedKirkwoodForce) or isinstance( f, mm.AmoebaWcaDispersionForce): f.setForceGroup(1) dt = 0.002 * unit.picoseconds integ = mm.MTSIntegrator(dt, [(0, 2), (1, 1)]) else: if apoa1: ff = app.ForceField('amber14/protein.ff14SB.xml', 'amber14/lipid17.xml', 'amber14/tip3p.xml') pdb = app.PDBFile('apoa1.pdb') if testName == 'apoa1pme': method = app.PME cutoff = options.cutoff elif testName == 'apoa1ljpme': method = app.LJPME cutoff = options.cutoff else: method = app.CutoffPeriodic cutoff = 1 * unit.nanometers friction = 1 * (1 / unit.picoseconds) hydrogenMass = 1.5 * unit.amu elif explicit: ff = app.ForceField('amber99sb.xml', 'tip3p.xml') pdb = app.PDBFile('5dfr_solv-cube_equil.pdb') if testName == 'pme': method = app.PME cutoff = options.cutoff else: method = app.CutoffPeriodic cutoff = 1 * unit.nanometers friction = 1 * (1 / unit.picoseconds) else: ff = app.ForceField('amber99sb.xml', 'amber99_obc.xml') pdb = app.PDBFile('5dfr_minimized.pdb') method = app.CutoffNonPeriodic cutoff = 2 * unit.nanometers friction = 91 * (1 / unit.picoseconds) if options.heavy: dt = 0.005 * unit.picoseconds constraints = app.AllBonds hydrogenMass = 4 * unit.amu integ = mm.LangevinIntegrator(300 * unit.kelvin, friction, dt) else: dt = 0.004 * unit.picoseconds constraints = app.HBonds integ = mm.LangevinMiddleIntegrator(300 * unit.kelvin, friction, dt) system = ff.createSystem(pdb.topology, nonbondedMethod=method, nonbondedCutoff=cutoff, constraints=constraints, hydrogenMass=hydrogenMass) print('Step Size: %g fs' % dt.value_in_unit(unit.femtoseconds)) properties = {} initialSteps = 5 if options.device is not None and platform.getName() in ('CUDA', 'OpenCL'): properties['DeviceIndex'] = options.device if ',' in options.device or ' ' in options.device: initialSteps = 250 if options.precision is not None and platform.getName() in ('CUDA', 'OpenCL'): properties['Precision'] = options.precision # Run the simulation. integ.setConstraintTolerance(1e-5) if len(properties) > 0: context = mm.Context(system, integ, platform, properties) else: context = mm.Context(system, integ, platform) context.setPositions(pdb.positions) context.setVelocitiesToTemperature(300 * unit.kelvin) steps = 20 while True: time = timeIntegration(context, steps, initialSteps) if time >= 0.5 * options.seconds: break if time < 0.5: steps = int( steps * 1.0 / time ) # Integrate enough steps to get a reasonable estimate for how many we'll need. else: steps = int(steps * options.seconds / time) print('Integrated %d steps in %g seconds' % (steps, time)) print('%g ns/day' % (dt * steps * 86400 / time).value_in_unit(unit.nanoseconds))
platform = mm.Platform.getPlatformByName('CUDA') properties = {'CudaPrecision': "single"} temperature = 1 * u.kelvin timestep = 1.0 * u.femtoseconds steps = 5000 #hmc_integrators.guess_force_groups(system, nonbonded=0, others=1, fft=0) #groups = [(0, 1), (1, 4)] hmc_integrators.guess_force_groups(system, nonbonded=0, others=0, fft=0) groups = [(0, 1)] integrator = mm.MTSIntegrator(timestep, groups) simulation = app.Simulation(topology, system, integrator, platform=platform, platformProperties=properties) simulation.context.setPositions(positions) simulation.context.setVelocitiesToTemperature(temperature) integrator.step(1) t0 = time.time() integrator.step(steps) dt = time.time() - t0 outer_per_day = steps / dt * 60 * 60 * 24 outer_per_sec = steps / dt inner_per_sec = outer_per_sec * groups[-1][1] ns_per_day = (timestep / u.nanoseconds) * outer_per_day
for force in system.getForces(): if isinstance(force, slow): found_slow = True force.setForceGroup(1) else: force.setForceGroup(0) if not found_slow: raise ValueError('No slow AMOEBA forces found for MTS integrator!') # The list given to MTSIntegrator defining the time steps and force # decompositions is a list of 2-element tuples where the first element is # a force group and the second element is how many times to evaluate that # force group each "outer" time-step. So [(0, opt.nrespa), (1, 1)] means # force group 0 is executed nrespa times each time step and force group 1 is # executed only once. The slow forces are defined above as force group 1 and # all others as force group 0. integrator = mm.MTSIntegrator(opt.timestep*u.femtoseconds, [(0, opt.nrespa), (1, 1)]) print('RESPA MTS Integrator: %8.2f fs outer time-step with %d inner steps' % (opt.timestep, opt.nrespa)) else: integrator = mm.VerletIntegrator(opt.timestep*u.femtoseconds) print('Verlet: %8.2f fs' % opt.timestep ) sim = app.Simulation(pdb.topology, system, integrator, mm.Platform.getPlatformByName('CUDA'), dict(CudaPrecision='mixed') ) if opt.hawkeye: # Watch every step... slow! sim.reporters.append(ErrorDetectionReporter(groups_and_names)) sim.reporters.append( pmd.openmm.StateDataReporter(opt.output, reportInterval=opt.interval,
steps=equil_steps, minimize=True, use_hmc=False, precision=precision, platform_name=platform_name) n_iter = 1000 n_steps = 25 temperature = 300. * u.kelvin timestep = 1.0 * u.femtoseconds x = [] integrators = [ mm.VerletIntegrator(timestep), # 0 mm.MTSIntegrator(timestep, groups=((0, 1), (1, 1))), # 1 mm.MTSIntegrator(timestep, groups=((0, 2), (1, 1))), # 2 mm.MTSIntegrator(timestep, groups=((0, 3), (1, 1))), # 3 mm.MTSIntegrator(timestep, groups=((0, 4), (1, 1))), # 4 mm.MTSIntegrator(timestep, groups=((0, 5), (1, 1))), # 5 mm.MTSIntegrator(timestep, groups=((1, 1), (0, 1))), # 6 mm.MTSIntegrator(timestep, groups=((1, 3), (0, 1))), # 7 mm.MTSIntegrator(timestep, groups=((1, 2), (0, 1))), # 8 mm.MTSIntegrator(timestep, groups=((1, 4), (0, 1))), # 9 mm.MTSIntegrator(timestep, groups=((1, 5), (0, 1))), # 10 ] for (i, integrator) in enumerate(integrators): print("*" * 80) simulation = lb_loader.build(testsystem, integrator, temperature,
def runOneTest(testName, options): """Perform a single benchmarking simulation.""" explicit = (testName not in ('gbsa', 'amoebagk')) amoeba = (testName in ('amoebagk', 'amoebapme')) apoa1 = testName.startswith('apoa1') amber = (testName.startswith('amber')) hydrogenMass = None print() if amoeba: print('Test: %s (epsilon=%g)' % (testName, options.epsilon)) elif testName == 'pme': print('Test: pme (cutoff=%g)' % options.cutoff) else: print('Test: %s' % testName) print('Ensemble: %s' % options.ensemble) platform = mm.Platform.getPlatformByName(options.platform) # Create the System. temperature = 300 * unit.kelvin if explicit: friction = 1 * (1 / unit.picoseconds) else: friction = 91 * (1 / unit.picoseconds) if amoeba: constraints = None epsilon = float(options.epsilon) if explicit: ff = app.ForceField('amoeba2009.xml') pdb = app.PDBFile('5dfr_solv-cube_equil.pdb') cutoff = 0.7 * unit.nanometers vdwCutoff = 0.9 * unit.nanometers system = ff.createSystem(pdb.topology, nonbondedMethod=app.PME, nonbondedCutoff=cutoff, vdwCutoff=vdwCutoff, constraints=constraints, ewaldErrorTolerance=0.00075, mutualInducedTargetEpsilon=epsilon, polarization=options.polarization) else: ff = app.ForceField('amoeba2009.xml', 'amoeba2009_gk.xml') pdb = app.PDBFile('5dfr_minimized.pdb') cutoff = 2.0 * unit.nanometers vdwCutoff = 1.2 * unit.nanometers system = ff.createSystem(pdb.topology, nonbondedMethod=app.NoCutoff, constraints=constraints, mutualInducedTargetEpsilon=epsilon, polarization=options.polarization) for f in system.getForces(): if isinstance(f, mm.AmoebaMultipoleForce) or isinstance( f, mm.AmoebaVdwForce) or isinstance( f, mm.AmoebaGeneralizedKirkwoodForce) or isinstance( f, mm.AmoebaWcaDispersionForce): f.setForceGroup(1) dt = 0.002 * unit.picoseconds if options.ensemble == 'NVE': integ = mm.MTSIntegrator(dt, [(0, 2), (1, 1)]) else: integ = mm.MTSLangevinIntegrator(temperature, friction, dt, [(0, 2), (1, 1)]) positions = pdb.positions elif amber: dirname = downloadAmberSuite() names = { 'amber20-dhfr': 'JAC', 'amber20-factorix': 'FactorIX', 'amber20-cellulose': 'Cellulose', 'amber20-stmv': 'STMV' } fileName = names[testName] prmtop = app.AmberPrmtopFile( os.path.join(dirname, f'PME/Topologies/{fileName}.prmtop')) inpcrd = app.AmberInpcrdFile( os.path.join(dirname, f'PME/Coordinates/{fileName}.inpcrd')) topology = prmtop.topology positions = inpcrd.positions dt = 0.004 * unit.picoseconds method = app.PME cutoff = options.cutoff constraints = app.HBonds system = prmtop.createSystem(nonbondedMethod=method, nonbondedCutoff=cutoff, constraints=constraints) if options.ensemble == 'NVE': integ = mm.VerletIntegrator(dt) else: integ = mm.LangevinMiddleIntegrator(temperature, friction, dt) else: if apoa1: ff = app.ForceField('amber14/protein.ff14SB.xml', 'amber14/lipid17.xml', 'amber14/tip3p.xml') pdb = app.PDBFile('apoa1.pdb') if testName == 'apoa1pme': method = app.PME cutoff = options.cutoff elif testName == 'apoa1ljpme': method = app.LJPME cutoff = options.cutoff else: method = app.CutoffPeriodic cutoff = 1 * unit.nanometers hydrogenMass = 1.5 * unit.amu elif explicit: ff = app.ForceField('amber99sb.xml', 'tip3p.xml') pdb = app.PDBFile('5dfr_solv-cube_equil.pdb') if testName == 'pme': method = app.PME cutoff = options.cutoff else: method = app.CutoffPeriodic cutoff = 1 * unit.nanometers else: ff = app.ForceField('amber99sb.xml', 'amber99_obc.xml') pdb = app.PDBFile('5dfr_minimized.pdb') method = app.CutoffNonPeriodic cutoff = 2 * unit.nanometers if options.heavy: dt = 0.005 * unit.picoseconds constraints = app.AllBonds hydrogenMass = 4 * unit.amu if options.ensemble == 'NVE': integ = mm.VerletIntegrator(dt) else: integ = mm.LangevinIntegrator(temperature, friction, dt) else: dt = 0.004 * unit.picoseconds constraints = app.HBonds if options.ensemble == 'NVE': integ = mm.VerletIntegrator(dt) else: integ = mm.LangevinMiddleIntegrator(temperature, friction, dt) positions = pdb.positions system = ff.createSystem(pdb.topology, nonbondedMethod=method, nonbondedCutoff=cutoff, constraints=constraints, hydrogenMass=hydrogenMass) if options.ensemble == 'NPT': system.addForce(mm.MonteCarloBarostat(1 * unit.bar, temperature, 100)) print('Step Size: %g fs' % dt.value_in_unit(unit.femtoseconds)) properties = {} initialSteps = 5 if options.device is not None and platform.getName() in ('CUDA', 'OpenCL'): properties['DeviceIndex'] = options.device if ',' in options.device or ' ' in options.device: initialSteps = 250 if options.precision is not None and platform.getName() in ('CUDA', 'OpenCL'): properties['Precision'] = options.precision # Run the simulation. integ.setConstraintTolerance(1e-5) if len(properties) > 0: context = mm.Context(system, integ, platform, properties) else: context = mm.Context(system, integ, platform) context.setPositions(positions) if amber: if inpcrd.boxVectors is not None: context.setPeriodicBoxVectors(*inpcrd.boxVectors) mm.LocalEnergyMinimizer.minimize( context, 100 * unit.kilojoules_per_mole / unit.nanometer) context.setVelocitiesToTemperature(temperature) steps = 20 while True: time = timeIntegration(context, steps, initialSteps) if time >= 0.5 * options.seconds: break if time < 0.5: steps = int( steps * 1.0 / time ) # Integrate enough steps to get a reasonable estimate for how many we'll need. else: steps = int(steps * options.seconds / time) print('Integrated %d steps in %g seconds' % (steps, time)) print('%g ns/day' % (dt * steps * 86400 / time).value_in_unit(unit.nanoseconds))
def runOneTest(testName, options): """Perform a single benchmarking simulation.""" explicit = (testName in ('rf', 'pme', 'amoebapme')) amoeba = (testName in ('amoebagk', 'amoebapme')) hydrogenMass = None print() if amoeba: print('Test: %s (epsilon=%g)' % (testName, options.epsilon)) elif testName == 'pme': print('Test: pme (cutoff=%g)' % options.cutoff) else: print('Test: %s' % testName) platform = mm.Platform.getPlatformByName(options.platform) # Create the System. if amoeba: constraints = None epsilon = float(options.epsilon) if explicit: ff = app.ForceField('amoeba2009.xml') pdb = app.PDBFile('5dfr_solv-cube_equil.pdb') cutoff = 0.7*unit.nanometers vdwCutoff = 0.9*unit.nanometers system = ff.createSystem(pdb.topology, nonbondedMethod=app.PME, nonbondedCutoff=cutoff, vdwCutoff=vdwCutoff, constraints=constraints, ewaldErrorTolerance=0.00075, mutualInducedTargetEpsilon=epsilon, polarization=options.polarization) else: ff = app.ForceField('amoeba2009.xml', 'amoeba2009_gk.xml') pdb = app.PDBFile('5dfr_minimized.pdb') cutoff = 2.0*unit.nanometers vdwCutoff = 1.2*unit.nanometers system = ff.createSystem(pdb.topology, nonbondedMethod=app.NoCutoff, constraints=constraints, mutualInducedTargetEpsilon=epsilon, polarization=options.polarization) for f in system.getForces(): if isinstance(f, mm.AmoebaMultipoleForce) or isinstance(f, mm.AmoebaVdwForce) or isinstance(f, mm.AmoebaGeneralizedKirkwoodForce) or isinstance(f, mm.AmoebaWcaDispersionForce): f.setForceGroup(1) dt = 0.002*unit.picoseconds if options.timestep: dt = options.timestep * unit.femtoseconds integ = mm.MTSIntegrator(dt, [(0,2), (1,1)]) else: if explicit: ff = app.ForceField('amber99sb.xml', 'tip3p.xml') pdb = app.PDBFile('5dfr_solv-cube_equil.pdb') if testName == 'pme': method = app.PME cutoff = options.cutoff else: method = app.CutoffPeriodic cutoff = 1*unit.nanometers else: ff = app.ForceField('amber99sb.xml', 'amber99_obc.xml') pdb = app.PDBFile('5dfr_minimized.pdb') method = app.CutoffNonPeriodic cutoff = 2*unit.nanometers if options.heavy: dt = 0.005*unit.picoseconds if options.timestep: dt = options.timestep * unit.femtoseconds constraints = app.AllBonds hydrogenMass = 4*unit.amu else: dt = 0.002*unit.picoseconds if options.timestep: dt = options.timestep * unit.femtoseconds constraints = app.HBonds hydrogenMass = None system = ff.createSystem(pdb.topology, nonbondedMethod=method, nonbondedCutoff=cutoff, constraints=constraints, hydrogenMass=hydrogenMass) integ = mm.LangevinIntegrator(300*unit.kelvin, 91*(1/unit.picoseconds), dt) print('Step Size: %g fs' % dt.value_in_unit(unit.femtoseconds)) properties = {} initialSteps = 5 if options.device is not None and platform.getName() in ('CUDA', 'OpenCL'): properties['DeviceIndex'] = options.device if ',' in options.device or ' ' in options.device: initialSteps = 250 if options.precision is not None and platform.getName() in ('CUDA', 'OpenCL'): properties['CudaPrecision'] = options.precision # Use switching function switch_width = 2.0 * unit.angstroms for force in system.getForces(): if isinstance(force, mm.NonbondedForce): force.setUseSwitchingFunction(True) cutoff = force.getCutoffDistance() force.setSwitchingDistance(cutoff - switch_width) force.setReactionFieldDielectric(1e10) force.setEwaldErrorTolerance(1.0e-7) # Run the simulation. integ.setConstraintTolerance(1e-8) if len(properties) > 0: context = mm.Context(system, integ, platform, properties) else: context = mm.Context(system, integ, platform) context.setPositions(pdb.positions) context.setVelocitiesToTemperature(300*unit.kelvin) steps = 20 while True: time = timeIntegration(context, steps, initialSteps) if time >= 0.5*options.seconds: break if time < 0.5: steps = int(steps*1.0/time) # Integrate enough steps to get a reasonable estimate for how many we'll need. else: steps = int(steps*options.seconds/time) print('Integrated %d steps in %g seconds' % (steps, time)) print('%g ns/day' % (dt*steps*86400/time).value_in_unit(unit.nanoseconds)) if options.drift is not None: print('Measuring drift with Verlet integrator') state = context.getState(getPositions=True, getVelocities=True) positions = state.getPositions() velocities = state.getVelocities() box_vectors = state.getPeriodicBoxVectors() del context, integ integ = mm.VerletIntegrator(dt) print('Step Size: %g fs' % dt.value_in_unit(unit.femtoseconds)) initialSteps = 500 integ.setConstraintTolerance(1e-8) print('Integrator tolerance: %f' % integ.getConstraintTolerance()) if len(properties) > 0: context = mm.Context(system, integ, platform, properties) else: context = mm.Context(system, integ, platform) context.setPeriodicBoxVectors(*box_vectors) context.setPositions(positions) context.setVelocities(velocities) measureDrift(context, steps, initialSteps, filename=options.drift, name=options.test)
def run_benchmark(test_name, options, stream=None): """Perform a single benchmarking simulation.""" if stream is None: stream = sys.stdout benchmark_data_dir = os.path.join(os.path.dirname(__file__), "data") explicit = any([x in test_name for x in ["rf", "pme", "amoebapme"]]) amoeba = any([x in test_name for x in ["amoebagk", "amoebapme"]]) hydrogenMass = None if amoeba: stream.write('Test: %s (epsilon=%g)\n' % (test_name, options.amoeba_target_epsilon)) elif test_name == 'pme': stream.write('Test: pme (cutoff=%g)\n' % options.cutoff) else: stream.write('Test: %s\n' % test_name) # Create the System. if amoeba: constraints = None epsilon = float(options.amoeba_target_epsilon) if explicit: ff = app.ForceField('amoeba2009.xml') pdb = app.PDBFile(os.path.join(benchmark_data_dir, '5dfr_solv-cube_equil.pdb')) cutoff = 0.7 * unit.nanometers vdwCutoff = 0.9 * unit.nanometers system = ff.createSystem(pdb.topology, nonbondedMethod=app.PME, nonbondedCutoff=cutoff, vdwCutoff=vdwCutoff, constraints=constraints, ewaldErrorTolerance=0.00075, mutualInducedTargetEpsilon=epsilon, polarization=options.polarization) else: ff = app.ForceField( 'amoeba2009.xml', 'amoeba2009_gk.xml' ) pdb = app.PDBFile(os.path.join(benchmark_data_dir, '5dfr_minimized.pdb')) cutoff = 2.0 * unit.nanometers vdwCutoff = 1.2 * unit.nanometers system = ff.createSystem(pdb.topology, nonbondedMethod=app.NoCutoff, constraints=constraints, mutualInducedTargetEpsilon=epsilon, polarization=options.polarization) for f in system.getForces(): if isinstance(f, mm.AmoebaMultipoleForce) or isinstance(f, mm.AmoebaVdwForce) or isinstance(f, mm.AmoebaGeneralizedKirkwoodForce) or isinstance(f, mm.AmoebaWcaDispersionForce): f.setForceGroup(1) dt = 0.002 * unit.picoseconds integ = mm.MTSIntegrator(dt, [(0, 2), (1, 1)]) else: if explicit: ff = app.ForceField('amber99sb.xml', 'tip3p.xml') pdb = app.PDBFile(os.path.join(benchmark_data_dir, '5dfr_solv-cube_equil.pdb')) if 'pme' in test_name: method = app.PME cutoff = options.cutoff else: method = app.CutoffPeriodic cutoff = 1 * unit.nanometers friction = 1 * (1 / unit.picoseconds) else: ff = app.ForceField( 'amber99sb.xml', 'amber99_obc.xml' ) pdb = app.PDBFile(os.path.join(benchmark_data_dir, '5dfr_minimized.pdb')) method = app.CutoffNonPeriodic cutoff = 2 * unit.nanometers friction = 91 * (1 / unit.picoseconds) if options.use_heavy_hydrogens: dt = 0.005 * unit.picoseconds constraints = app.AllBonds hydrogenMass = 4 * unit.amu else: dt = 0.002 * unit.picoseconds constraints = app.HBonds hydrogenMass = None system = ff.createSystem(pdb.topology, nonbondedMethod=method, nonbondedCutoff=cutoff, constraints=constraints, hydrogenMass=hydrogenMass) integ = mm.LangevinIntegrator(300 * unit.kelvin, friction, dt) stream.write('Step Size: %g fs\n' % dt.value_in_unit(unit.femtoseconds)) properties = {} initialSteps = 5 if options.precision is not None and options.platform.getName() in ('CUDA', 'OpenCL'): properties['Precision'] = options.precision # Run the simulation. integ.setConstraintTolerance(1e-5) try: if len(properties) > 0: context = mm.Context(system, integ, options.platform, properties) else: context = mm.Context(system, integ, options.platform) except Exception as e: stream.write("Unable to Benchmark '{}'\n".format(test_name)) stream.write("ERROR: {}\n".format(str(e))) return context.setPositions(pdb.positions) context.setVelocitiesToTemperature(300 * unit.kelvin) steps = 20 while True: time = timeIntegration(context, steps, initialSteps) if time >= 0.5 * options.seconds: break if time < 0.5: steps = int(steps * 1.0 / time) # Integrate enough steps to get a reasonable estimate for how many we'll need. else: steps = int(steps * options.seconds / time) stream.write('Integrated %d steps in %g seconds\n' % (steps, time)) stream.write('%g ns/day\n' % (dt * steps * 86400 / time).value_in_unit(unit.nanoseconds))
import simtk.openmm.app as app import simtk.openmm as mm from simtk import unit as u from openmmtools import testsystems f = lambda x: (x.getPotentialEnergy(), x.getKineticEnergy(), x.getKineticEnergy() + x.getPotentialEnergy()) temperature = 300. * u.kelvin testsystem = testsystems.LennardJonesFluid(nparticles=2048) timestep = 0.1 * u.femtoseconds nsteps = 50 for platform_name in ["CUDA", "OpenCL", "CPU"]: platform = mm.Platform.getPlatformByName(platform_name) integrators = [mm.VerletIntegrator(timestep), mm.MTSIntegrator(timestep, groups=[(0, 1)])] for integrator in integrators: print(platform_name, integrator) simulation = app.Simulation(testsystem.topology, testsystem.system, integrator, platform=platform) simulation.context.setPositions(testsystem.positions) simulation.context.setVelocitiesToTemperature(temperature) integrator.step(nsteps) # Do a single step first to apply constraints before we run tests. state1a = simulation.context.getState(getPositions=True, getParameters=True, getEnergy=True, getVelocities=True) old = f(state1a) print("PE, KE, TOTAL") print(old) integrator.step(nsteps) state1b = simulation.context.getState(getPositions=True, getParameters=True, getEnergy=True, getVelocities=True) new = f(state1b)