예제 #1
0
def test_fr15(spc_water_box, caplog):
    """FR15: Simulation input modification.

    * *gmx.modify_input produces new (tpr) simulation input in data flow operation*
      (requires interaction with library development)
    """
    try:
        from mpi4py import MPI
        current_rank = MPI.COMM_WORLD.Get_rank()
        ensemble_size = MPI.COMM_WORLD.Get_size()
    except ImportError:
        current_rank = 0
        ensemble_size = 1

    with caplog.at_level(logging.DEBUG):
        caplog.handler.setFormatter(formatter)
        with caplog.at_level(logging.WARNING, 'gmxapi'), \
                 caplog.at_level(logging.DEBUG, 'gmxapi.mdrun'), \
                 caplog.at_level(logging.DEBUG, 'gmxapi.modify_input'), \
                 caplog.at_level(logging.DEBUG, 'gmxapi.read_tpr'), \
                 caplog.at_level(logging.DEBUG, 'gmxapi.simulation'):

            initial_input = gmx.read_tpr(
                [spc_water_box for _ in range(ensemble_size)])
            parameters = list([{'ld-seed': i} for i in range(ensemble_size)])
            param_sweep = gmx.modify_input(input=initial_input,
                                           parameters=parameters)
            md = gmx.mdrun(param_sweep)
            # TODO: (#3179) Handle ensembles of size 1 more elegantly.
            if md.output.ensemble_width > 1:
                result_list = md.output.parameters['ld-seed'].result()
            else:
                result_list = [md.output.parameters['ld-seed'].result()]
            for expected, actual in zip(parameters, result_list):
                assert expected['ld-seed'] == actual
예제 #2
0
def test_run_from_modify_input_op(spc_water_box, caplog):
    with caplog.at_level(logging.DEBUG):

        simulation_input = gmx.read_tpr(spc_water_box)
        modified_input = gmx.modify_input(input=simulation_input,
                                          parameters={'nsteps': 4})
        md = gmx.mdrun(input=modified_input)

        md.run()
예제 #3
0
def test_fr15():
    """FR15: Simulation input modification.

    * *gmx.modify_input produces new (tpr) simulation input in data flow operation*
      (requires interaction with library development)
    * gmx.make_input dispatches appropriate preprocessing for file or in-memory simulation input.
    """
    initial_input = gmx.read_tpr([tpr_filename for _ in range(10)])
    tau_t = list([i / 10. for i in range(10)])
    param_sweep = gmx.modify_input(input=initial_input,
                                   parameters={'tau_t': tau_t})
    md = gmx.mdrun(param_sweep)
    for tau_expected, tau_actual in zip(tau_t,
                                        md.output.params['tau_t'].extract()):
        assert tau_expected == tau_actual
예제 #4
0
def test_fr15():
    """FR15: Simulation input modification.

    * *gmx.modify_input produces new (tpr) simulation input in data flow operation*
      (requires interaction with library development)
    * gmx.make_input dispatches appropriate preprocessing for file or in-memory simulation input.
    """
    initial_input = gmx.read_tpr([tpr_filename for _ in range(10)])
    tau_t = list([i/10. for i in range(10)])
    param_sweep = gmx.modify_input(input=initial_input,
                                   parameters={
                                       'tau_t': tau_t
                                   }
                                   )
    md = gmx.mdrun(param_sweep)
    for tau_expected, tau_actual in zip(tau_t, md.output.params['tau_t'].extract()):
        assert tau_expected == tau_actual
예제 #5
0
def test_fr4():
    """FR4: Dimensionality and typing of named data causes generation of correct work topologies."""
    N = 10
    simulation_input = gmx.read_tpr(initial_tpr)

    # Array inputs imply array outputs.
    input_array = gmx.modify_input(
        simulation_input, params={'tau-t': [t / 10.0 for t in range(N)]})

    md = gmx.mdrun(input_array)  # An array of simulations

    rmsf = gmx.commandline_operation(
        'gmx',
        'rmsf',
        input={
            '-f': md.output.trajectory,
            '-s': initial_tpr
        },
        output={'-o': gmx.FileName(suffix='.xvg')})
예제 #6
0
def test_fr4():
    """FR4: Dimensionality and typing of named data causes generation of correct work topologies."""
    N = 10
    simulation_input = gmx.read_tpr(initial_tpr)

    # Array inputs imply array outputs.
    input_array = gmx.modify_input(
        simulation_input, params={'tau-t': [t / 10.0 for t in range(N)]})

    md = gmx.mdrun(input_array)  # An array of simulations

    rmsf = gmx.commandline_operation(
        'gmx',
        'rmsf',
        input={
            '-f': md.output.trajectory,
            '-s': initial_tpr
        },
        output={'-o': gmx.FileName(suffix='.xvg')})
예제 #7
0
def test_fr10():
    """FR10: 10: fused operations for use in looping constructs

    * gmx.subgraph fuses operations
    * gmx.while creates an operation wrapping a dynamic number of iterations of a subgraph
    """
    train = gmx.subgraph(variables={'conformation': initial_input})
    with train:
        myplugin.training_restraint(label='training_potential',
                                    params=my_dict_params)
        modified_input = gmx.modify_input(input=initial_input,
                                          structure=train.conformation)
        md = gmx.mdrun(input=modified_input,
                       potential=train.training_potential)
        # Alternate syntax to facilitate adding multiple potentials:
        # md.interface.potential.add(train.training_potential)
        brer_tools.training_analyzer(
            label='is_converged', params=train.training_potential.output.alpha)
        train.conformation = md.output.conformation

    train_loop = gmx.while_loop(operation=train,
                                condition=gmx.logical_not(train.is_converged))
예제 #8
0
def test_fr10():
    """FR10: 10: fused operations for use in looping constructs

    * gmx.subgraph fuses operations
    * gmx.while creates an operation wrapping a dynamic number of iterations of a subgraph
    """
    train = gmx.subgraph(variables={'conformation': initial_input})
    with train:
        myplugin.training_restraint(
            label='training_potential',
            params=my_dict_params)
        modified_input = gmx.modify_input(
            input=initial_input, structure=train.conformation)
        md = gmx.mdrun(input=modified_input, potential=train.training_potential)
        # Alternate syntax to facilitate adding multiple potentials:
        # md.interface.potential.add(train.training_potential)
        brer_tools.training_analyzer(
            label='is_converged',
            params=train.training_potential.output.alpha)
        train.conformation = md.output.conformation

    train_loop = gmx.while_loop(
        operation=train,
        condition=gmx.logical_not(train.is_converged))