def run(system, moves, run_type, run_length, temperature, **kwargs):

    # Check that the user has the Cassandra binary on their PATH
    # Also need library_setup.py on the PATH and python2
    py2, fraglib_setup, cassandra = detect_cassandra_binaries()

    # Sanity checks
    # TODO: Write more of these
    _check_system(system, moves)

    # Write MCF files
    write_mcfs(system)

    # Write starting configs (if needed)
    write_configs(system)

    # Write input file
    inp_file = write_input(system=system,
                           moves=moves,
                           run_type=run_type,
                           run_length=run_length,
                           temperature=temperature,
                           **kwargs)

    # Write pdb files (this step will be removed when frag generation
    # is incorporated into this workflow )
    for isp, top in enumerate(system.species_topologies):
        filename = "species{}.pdb".format(isp + 1)
        write_pdb(top, filename)

    log_file = "mosdef_cassandra_{}.log".format(
        datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S.%f"))

    # Run fragment generation (again, will be removed...)
    print("Generating fragment libraries...")
    successful_fraglib = _run_fraglib_setup(
        py2,
        fraglib_setup,
        cassandra,
        inp_file,
        log_file,
        len(system.species_topologies),
    )

    # Run simulation
    if successful_fraglib:
        print("Running Cassandra...")
        _run_cassandra(cassandra, inp_file, log_file)
    else:
        raise ValueError("Cassandra failed due to unsuccessful "
                         "fragment generation")
Beispiel #2
0
def run(system, moveset, run_type, run_length, temperature, **kwargs):
    """Run the Monte Carlo simulation with Cassandra

    The following steps are performed: write the molecular connectivity
    files for each species to disk, write the starting structures
    (if any) to disk, generate and write the Cassandra input file to disk,
    call Cassandra to generate the required fragment libraries, and
    call Cassandra to run the MC simulation.

    Parameters
    ----------
    system : mosdef_cassandra.System
        the System to simulate
    moveset : mosdef_cassandra.MoveSet
        the MoveSet to simulate
    run_type : "equilibration" or "production"
        the type of run; in "equilibration" mode, Cassandra adaptively changes
        the maximum translation, rotation, and volume move sizes to achieve
        an acceptance ratio of 0.5
    run_length : int
        length of the MC simulation
    temperature : float
        temperature at which to perform the MC simulation
    **kwargs : keyword arguments
        any other valid keyword arguments, see
        ``mosdef_cassandra.print_valid_kwargs()`` for details
    """

    # Check that the user has the Cassandra binary on their PATH
    # Also need library_setup.py on the PATH and python2
    py, fraglib_setup, cassandra = detect_cassandra_binaries()

    # Sanity checks
    # TODO: Write more of these
    _check_system(system, moveset)

    # Write MCF files
    if "angle_style" in kwargs:
        write_mcfs(system, angle_style=kwargs["angle_style"])
    else:
        write_mcfs(system)

    # Write starting configs (if needed)
    write_configs(system)

    # Write input file
    inp_file = write_input(
        system=system,
        moveset=moveset,
        run_type=run_type,
        run_length=run_length,
        temperature=temperature,
        **kwargs
    )

    # Write pdb files (this step will be removed when frag generation
    # is incorporated into this workflow )
    for isp, top in enumerate(system.species_topologies):
        filename = "species{}.pdb".format(isp + 1)
        write_pdb(top, filename)

    log_file = "mosdef_cassandra_{}.log".format(
        datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S.%f")
    )

    # Run fragment generation
    print("Generating fragment libraries...")
    _run_fraglib_setup(
        py,
        fraglib_setup,
        cassandra,
        inp_file,
        log_file,
        len(system.species_topologies),
    )

    # Run simulation
    print("Running Cassandra...")
    _run_cassandra(cassandra, inp_file, log_file)