def test_hmc(timestep, steps_per_hmc, collision_rate):
    timestep = timestep * u.femtoseconds
    integrator = hmc_integrators.GHMC2(temperature, steps_per_hmc, timestep,
                                       collision_rate / u.picoseconds)
    context = mm.Context(system, integrator)
    context.setPositions(positions)
    context.setVelocitiesToTemperature(temperature)
    integrator.step(n_steps)
    return integrator.acceptance_rate
Example #2
0
def hmc_inner(system, positions, params):
    integrator = hmc_integrators.GHMC2(temperature, params["steps_per_hmc"],
                                       params["timestep"] * u.femtoseconds)
    context = mm.Context(system, integrator)
    context.setPositions(positions)
    context.setVelocitiesToTemperature(temperature)
    integrator.step(1)  # timings will not accumulate on first step
    integrator.step(n_steps)
    d = integrator.summary
    d.update(params)
    print(pd.Series(d))
    return d
Example #3
0


integrator = hmc_integrators.VelocityVerletIntegrator(timestep)
context = mm.Context(system, integrator)
context.setPositions(positions)
context.setVelocitiesToTemperature(temperature)

integrator.step(2)
%timeit integrator.step(200)





integrator = hmc_integrators.GHMC2(temperature, 100, timestep)
context = mm.Context(system, integrator)
context.setPositions(positions)
context.setVelocitiesToTemperature(temperature)

integrator.step(2)
%timeit integrator.step(2)


integrator = hmc_integrators.GHMC2(temperature, 50, timestep)
integrator.getNumComputations()
context = mm.Context(system, integrator)
context.setPositions(positions)
context.setVelocitiesToTemperature(temperature)

integrator.step(1)
Example #4
0
testsystem = testsystems.WaterBox(box_edge=3.18 * u.nanometers)  # Around 1060 molecules of water
system, positions = testsystem.system, testsystem.positions

rho = 0.71 ** (1 / 3.)

for box_factor in [rho ** 0, rho ** 1, rho ** 2, rho ** 3]:
    testsystem = testsystems.WaterBox(box_edge=6.0 * u.nanometers * box_factor)
    system, positions = testsystem.system, testsystem.positions
    print(system.getNumParticles())

    integrator = mm.LangevinIntegrator(temperature, 1.0 / u.picoseconds, 0.25 * u.femtoseconds)
    context = mm.Context(system, integrator)
    context.setPositions(positions)
    context.setVelocitiesToTemperature(temperature)
    integrator.step(10000)
    positions = context.getState(getPositions=True).getPositions()

    collision_rate = 1.0 / u.picoseconds
    timestep = 2.5 * u.femtoseconds
    steps_per_hmc = 12
    k_max = 3

    integrator = hmc_integrators.GHMC2(temperature, steps_per_hmc, timestep)
    context = mm.Context(system, integrator)
    context.setPositions(positions)
    context.setVelocitiesToTemperature(temperature)

    integrator.step(1)
    integrator.step(2500)
    data = integrator.vstep(5)
timestep = 2.0 * u.femtoseconds
steps_per_hmc = 12
k_max = 2

testsystem = testsystems.WaterBox(
    box_edge=3.18 * u.nanometers)  # Around 1060 molecules of water
system = testsystem.system
positions = testsystem.positions

integrator = mm.LangevinIntegrator(temperature, 1.0 / u.picoseconds,
                                   0.25 * u.femtoseconds)
context = mm.Context(testsystem.system, integrator)
context.setPositions(testsystem.positions)
context.setVelocitiesToTemperature(temperature)
integrator.step(5000)
positions = context.getState(getPositions=True).getPositions()

integrator = hmc_integrators.GHMC2(temperature, steps_per_hmc, timestep,
                                   collision_rate)
context = mm.Context(system, integrator)
context.setPositions(positions)
context.setVelocitiesToTemperature(temperature)

for i in range(1000):
    data = []
    for j in range(10):
        integrator.step(1)
        data.append(integrator.summary())
    data = pd.DataFrame(data)
    print(data)