def get_grid(sysname, temperature, timestep, langevin_timestep, groups, steps_per_hmc=100, extra_chances=5):

    integrators = OrderedDict()

    for timestep in [1.0 * langevin_timestep, 4.0 * langevin_timestep]:
        collision_rate = 1.0 / u.picoseconds
        integrator = mm.LangevinIntegrator(temperature, collision_rate, timestep)
        itype = type(integrator).__name__
        prms = dict(sysname=sysname, itype=itype, timestep=timestep / u.femtoseconds, collision=lb_loader.fixunits(collision_rate))
        fmt_string = lb_loader.format_name(prms)
        integrators[fmt_string] = integrator

    collision_rate = None
    for timestep in [timestep, 20 * u.femtoseconds]:
        integrator = hmc_integrators.GHMCIntegrator(temperature=temperature, steps_per_hmc=steps_per_hmc, timestep=timestep, collision_rate=collision_rate)
        itype = type(integrator).__name__
        prms = dict(sysname=sysname, itype=itype, timestep=timestep / u.femtoseconds, collision=lb_loader.fixunits(collision_rate))
        fmt_string = lb_loader.format_name(prms)
        integrators[fmt_string] = integrator

    collision_rate = None
    for timestep in [timestep]:
        integrator = hmc_integrators.XCGHMCIntegrator(temperature=temperature, steps_per_hmc=steps_per_hmc, timestep=timestep, extra_chances=extra_chances, collision_rate=collision_rate)
        itype = type(integrator).__name__
        prms = dict(sysname=sysname, itype=itype, timestep=timestep / u.femtoseconds, collision=lb_loader.fixunits(collision_rate))
        fmt_string = lb_loader.format_name(prms)
        integrators[fmt_string] = integrator


    xcghmc_parms = dict(timestep=32.235339 * u.femtoseconds, steps_per_hmc=16, extra_chances=1, collision_rate=None)
    integrator = hmc_integrators.XCGHMCIntegrator(temperature=temperature, **xcghmc_parms)
    itype = type(integrator).__name__
    prms = dict(sysname=sysname, itype=itype, timestep=integrator.timestep / u.femtoseconds, collision=lb_loader.fixunits(None))
    fmt_string = lb_loader.format_name(prms)
    integrators[fmt_string] = integrator

    return integrators
Exemplo n.º 2
0
def inner_objective(args):
    steps_per_hmc, timestep, extra_chances = args
    print("*" * 80)
    print("steps=%d, timestep=%f, extra_chances=%d" %
          (steps_per_hmc, timestep, extra_chances))
    current_timestep = timestep * u.femtoseconds
    extra_chances = int(extra_chances)
    steps_per_hmc = int(steps_per_hmc)
    integrator = hmc_integrators.XCGHMCIntegrator(temperature,
                                                  steps_per_hmc=steps_per_hmc,
                                                  timestep=current_timestep,
                                                  extra_chances=extra_chances)
    simulation = lb_loader.build(testsystem,
                                 integrator,
                                 temperature,
                                 precision=precision,
                                 platform_name=platform_name)
    simulation.integrator.step(n_steps)
    return integrator, simulation  # Have to pass simulation to keep it from being garbage collected
Exemplo n.º 3
0
def kw_to_int(**kwargs):
    steps_per_hmc = kwargs["steps_per_hmc"]
    timestep = kwargs["timestep"]
    group0_iterations = kwargs["group0_iterations"]
    temperature = kwargs["temperature"]
    print("*" * 80)
    print("steps=%d, timestep=%f, extra_chances=%d, group0_iterations=%d" %
          (steps_per_hmc, timestep, 0, group0_iterations))
    timestep = timestep * u.femtoseconds
    steps_per_hmc = int(steps_per_hmc)
    group0_iterations = int(group0_iterations)
    n_groups = max(
        kwargs["groups"]
    ) + 1  # 1 group means group number = 0, assumes zero index and ordering
    groups = num_to_groups(group0_iterations, n_groups)
    print(n_groups)
    print(groups)

    if kwargs["group0_iterations"] == 0 and kwargs["extra_chances"] == 0:
        integrator = hmc_integrators.GHMCIntegrator(
            temperature, steps_per_hmc=steps_per_hmc, timestep=timestep)
    elif kwargs["group0_iterations"] > 0 and kwargs["extra_chances"] > 0:
        integrator = hmc_integrators.XCGHMCRESPAIntegrator(
            temperature,
            steps_per_hmc=steps_per_hmc,
            timestep=timestep,
            groups=groups)
    elif kwargs["group0_iterations"] > 0 and kwargs["extra_chances"] == 0:
        integrator = hmc_integrators.GHMCRESPAIntegrator(
            temperature,
            steps_per_hmc=steps_per_hmc,
            timestep=timestep,
            groups=groups)
    elif kwargs["group0_iterations"] == 0 and kwargs["extra_chances"] > 0:
        integrator = hmc_integrators.XCGHMCIntegrator(
            temperature,
            steps_per_hmc=steps_per_hmc,
            timestep=timestep,
            groups=groups)

    return integrator
simulation.context.setVelocitiesToTemperature(temperature)

hmc_integrators.guess_force_groups(system, nonbonded=1, others=0, fft=2)
del simulation, integrator
timestep = 2.0 * u.femtoseconds
#integrator = mm.LangevinIntegrator(temperature, 2.0 / u.picoseconds, timestep)
#integrator = mm.VerletIntegrator(timestep)
total_steps = 3000
extra_chances = 3
steps_per_hmc = 100
steps = total_steps

steps = total_steps / steps_per_hmc
#integrator = hmc_integrators.GHMCIntegrator(temperature, steps_per_hmc=steps_per_hmc, timestep=timestep)
integrator = hmc_integrators.XCGHMCIntegrator(temperature,
                                              steps_per_hmc=steps_per_hmc,
                                              timestep=timestep,
                                              extra_chances=extra_chances)
#integrator = integrators.VelocityVerletIntegrator(2.0 * u.femtoseconds)
simulation = lb_loader.build(testsystem,
                             integrator,
                             temperature,
                             precision=precision)

integrator.reset_time()
import time
t0 = time.time()
integrator.step(steps)
dt = time.time() - t0
ns_per_day = (timestep / u.nanoseconds) * total_steps / dt * 60 * 60 * 24
dt, ns_per_day
integrator.ns_per_day
Exemplo n.º 5
0
                                         steps=equil_steps,
                                         minimize=True)
collision_rate = None

timestep = 30. * u.femtoseconds
extra_chances = 10
steps_per_hmc = 50
output_frequency = 1

groups = [(0, 1), (1, 2)]
hmc_integrators.guess_force_groups(system, nonbonded=0, others=1, fft=0)
#integrator = hmc_integrators.XCGHMCRESPAIntegrator(temperature=temperature, steps_per_hmc=steps_per_hmc, timestep=timestep, extra_chances=extra_chances, groups=groups, collision_rate=fixed(collision_rate))
#integrator = hmc_integrators.MJHMCIntegrator(temperature=temperature, steps_per_hmc=steps_per_hmc, timestep=timestep)
integrator = hmc_integrators.XCGHMCIntegrator(temperature=temperature,
                                              steps_per_hmc=steps_per_hmc,
                                              timestep=timestep,
                                              extra_chances=extra_chances,
                                              collision_rate=collision_rate)

itype = type(integrator).__name__

simulation = lb_loader.build(testsystem, integrator, temperature)
integrator.reset_time()
simulation.step(100)
#print(timestep, integrator.acceptance_rate, integrator.effective_timestep)

prms = dict(sysname=sysname,
            itype=itype,
            timestep=timestep / u.femtoseconds,
            collision=lb_loader.fixunits(collision_rate))
Exemplo n.º 6
0
extra_chances = 1


integrator = hmc_integrators.HMCIntegrator(temperature, steps_per_hmc=10, timestep=timestep)
context = lb_loader.build(system, integrator, positions, temperature)
integrator.step(40)
output = integrator.vstep(10)
integrator.effective_timestep

integrator = hmc_integrators.GHMCIntegrator(temperature, steps_per_hmc=10, timestep=timestep, collision_rate=1.0 / u.picoseconds)
context = lb_loader.build(system, integrator, positions, temperature)
integrator.step(40)
output = integrator.vstep(10)
integrator.effective_timestep

integrator = hmc_integrators.XCGHMCIntegrator(temperature, steps_per_hmc=10, timestep=timestep, collision_rate=1.0 / u.picoseconds, extra_chances=extra_chances, take_debug_steps=False)
context = lb_loader.build(system, integrator, positions, temperature)
integrator.step(40)
output = integrator.vstep(10)
integrator.effective_timestep

integrator = hmc_integrators.XCGHMCRESPAIntegrator(temperature, steps_per_hmc=10, timestep=timestep, collision_rate=1.0 / u.picoseconds, extra_chances=extra_chances, groups=groups)
context = lb_loader.build(system, integrator, positions, temperature)
integrator.step(40)
output = integrator.vstep(10)
integrator.effective_timestep

integrator = hmc_integrators.XCHMCIntegrator(temperature, steps_per_hmc=10, timestep=timestep, extra_chances=extra_chances, take_debug_steps=False)
context = lb_loader.build(system, integrator, positions, temperature)
integrator.step(40)
output = integrator.vstep(10)
Exemplo n.º 7
0
def enumerate_experiments():
    experiments = OrderedDict()
    ############################################################################
    sysname = "switchedljbox"
    system, positions, groups, temperature, timestep, langevin_timestep, testsystem, equil_steps, steps_per_hmc = lb_loader.load(
        sysname)
    ############################################################################
    for timestep in [2.5 * u.femtoseconds, 5.0 * u.femtoseconds]:
        collision_rate = 1.0 / u.picoseconds
        integrator = mm.LangevinIntegrator(temperature, collision_rate,
                                           timestep)
        prms = dict(sysname=sysname,
                    timestep=timestep / u.femtoseconds,
                    collision=lb_loader.fixunits(collision_rate))
        expt = Experiment(integrator=integrator, sysname=sysname, prms=prms)

    collision_rate = None
    for timestep in [20.0 * u.femtoseconds]:
        integrator = hmc_integrators.GHMCIntegrator(
            temperature=temperature,
            steps_per_hmc=steps_per_hmc,
            timestep=timestep,
            collision_rate=collision_rate)
        prms = dict(sysname=sysname,
                    timestep=timestep / u.femtoseconds,
                    collision=lb_loader.fixunits(collision_rate))
        expt = Experiment(integrator=integrator, sysname=sysname, prms=prms)

    timestep = 35.0 * u.femtoseconds
    extra_chances = 2
    collision_rate = 1.0 / u.picoseconds

    integrator = hmc_integrators.XCGHMCIntegrator(
        temperature=temperature,
        steps_per_hmc=steps_per_hmc,
        timestep=timestep,
        extra_chances=extra_chances,
        collision_rate=collision_rate)
    itype = type(integrator).__name__
    prms = dict(sysname=sysname,
                itype=itype,
                timestep=timestep / u.femtoseconds,
                collision=lb_loader.fixunits(collision_rate))
    expt = Experiment(integrator=integrator, sysname=sysname, prms=prms)

    return

    collision_rate = None
    for timestep in []:  # [2.0 * u.femtoseconds]:
        integrator = hmc_integrators.XCGHMCIntegrator(
            temperature=temperature,
            steps_per_hmc=steps_per_hmc,
            timestep=timestep,
            extra_chances=extra_chances,
            collision_rate=collision_rate)
        itype = type(integrator).__name__
        prms = dict(sysname=sysname,
                    itype=itype,
                    timestep=timestep / u.femtoseconds,
                    collision=lb_loader.fixunits(collision_rate))
        int_string = lb_loader.format_int_name(prms)
        key = (sysname, int_string)
        experiments[key] = integrator

    ############################################################################
    sysname = "switchedaccurateflexiblewater"
    system, positions, groups, temperature, timestep, langevin_timestep, testsystem, equil_steps, steps_per_hmc = lb_loader.load(
        sysname)
    ############################################################################

    for timestep in [
            0.10 * u.femtoseconds, 0.15 * u.femtoseconds, 0.5 * u.femtoseconds
    ]:
        collision_rate = 1.0 / u.picoseconds
        integrator = mm.LangevinIntegrator(temperature, collision_rate,
                                           timestep)
        itype = type(integrator).__name__
        prms = dict(sysname=sysname,
                    itype=itype,
                    timestep=timestep / u.femtoseconds,
                    collision=lb_loader.fixunits(collision_rate))
        int_string = lb_loader.format_int_name(prms)
        key = (sysname, int_string)
        experiments[key] = integrator

    xcghmc_parms = dict(timestep=0.668 * u.femtoseconds,
                        steps_per_hmc=10,
                        extra_chances=1,
                        collision_rate=None)
    integrator = hmc_integrators.XCGHMCIntegrator(temperature=temperature,
                                                  **xcghmc_parms)
    itype = type(integrator).__name__
    prms = dict(sysname=sysname,
                itype=itype,
                timestep=integrator.timestep / u.femtoseconds,
                collision=lb_loader.fixunits(None))
    int_string = lb_loader.format_int_name(prms)
    key = (sysname, int_string)
    experiments[key] = integrator

    # hyperopt determined optimal settings obtain ~113 effective ns / day
    xcghmc_parms = dict(timestep=1.1868 * u.femtoseconds,
                        steps_per_hmc=23,
                        collision_rate=None,
                        groups=((0, 1), (1, 4)))
    integrator = hmc_integrators.GHMCRESPAIntegrator(temperature=temperature,
                                                     **xcghmc_parms)
    itype = type(integrator).__name__
    prms = dict(sysname=sysname,
                itype=itype,
                timestep=integrator.timestep / u.femtoseconds,
                collision=lb_loader.fixunits(None))
    int_string = lb_loader.format_int_name(prms)
    key = (sysname, int_string)
    experiments[key] = integrator

    # Obtained by taking hyperopt optimal GHMCRespa parameters and adding 2 extra chances
    xcghmc_parms = dict(timestep=1.1868 * u.femtoseconds,
                        steps_per_hmc=23,
                        collision_rate=None,
                        extra_chances=2,
                        groups=((0, 1), (1, 4)))
    integrator = hmc_integrators.XCGHMCRESPAIntegrator(temperature=temperature,
                                                       **xcghmc_parms)
    itype = type(integrator).__name__
    prms = dict(sysname=sysname,
                itype=itype,
                timestep=integrator.timestep / u.femtoseconds,
                collision=lb_loader.fixunits(None))
    int_string = lb_loader.format_int_name(prms)
    key = (sysname, int_string)
    experiments[key] = integrator

    # hyperopt determined optimal settings obtain ~79.8 effective ns/day
    xcghmc_parms = dict(timestep=0.6791 * u.femtoseconds,
                        steps_per_hmc=20,
                        collision_rate=None)
    integrator = hmc_integrators.GHMCIntegrator(temperature=temperature,
                                                **xcghmc_parms)
    itype = type(integrator).__name__
    prms = dict(sysname=sysname,
                itype=itype,
                timestep=integrator.timestep / u.femtoseconds,
                collision=lb_loader.fixunits(None))
    int_string = lb_loader.format_int_name(prms)
    key = (sysname, int_string)
    experiments[key] = integrator

    xcghmc_parms = dict(timestep=0.6791 * u.femtoseconds,
                        steps_per_hmc=20,
                        collision_rate=None)
    xcghmc_parms.update(dict())
    integrator = hmc_integrators.XCGHMCIntegrator(temperature=temperature,
                                                  **xcghmc_parms)
    itype = type(integrator).__name__
    prms = dict(sysname=sysname,
                itype=itype,
                timestep=timestep / u.femtoseconds,
                collision=lb_loader.fixunits(collision_rate))
    int_string = lb_loader.format_int_name(prms)
    key = (sysname, int_string)
    experiments[key] = integrator

    ############################################################################
    sysname = "switchedaccuratebigflexiblewater"
    system, positions, groups, temperature, timestep, langevin_timestep, testsystem, equil_steps, steps_per_hmc = lb_loader.load(
        sysname)
    ############################################################################

    experiments = OrderedDict()

    # hyperopt determined optimal settings obtain ~113 effective ns / day
    xcghmc_parms = dict(timestep=0.256927 * u.femtoseconds,
                        steps_per_hmc=24,
                        collision_rate=None,
                        groups=((0, 4), (1, 1)))
    integrator = hmc_integrators.GHMCRESPAIntegrator(temperature=temperature,
                                                     **xcghmc_parms)
    itype = type(integrator).__name__
    prms = dict(sysname=sysname,
                itype=itype,
                timestep=integrator.timestep / u.femtoseconds,
                collision=lb_loader.fixunits(None))
    int_string = lb_loader.format_int_name(prms)
    key = (sysname, int_string)
    experiments[key] = integrator