Example #1
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
Example #2
0
def inner_objective(args):
    steps_per_hmc, timestep, extra_chances = args
    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.XCGHMCRESPAIntegrator(
        temperature,
        steps_per_hmc=steps_per_hmc,
        timestep=current_timestep,
        extra_chances=extra_chances,
        groups=groups)
    simulation = lb_loader.build(testsystem,
                                 integrator,
                                 temperature,
                                 precision=precision,
                                 platform_name=platform_name)
    integrator.reset_time()
    integrator.step(n_steps)
    return integrator, simulation  # Have to pass simulation to keep it from being garbage collected
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)
integrator.effective_timestep

integrator = hmc_integrators.XCHMCRESPAIntegrator(temperature, steps_per_hmc=10, timestep=timestep, extra_chances=extra_chances, groups=groups)
context = lb_loader.build(system, integrator, positions, temperature)
integrator.step(40)
output = integrator.vstep(10)
Example #4
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