Beispiel #1
0
def main() -> None:
    """
    Use the command line argument to resume a dumped run of the JeLLyFysh application.

    First the command line arguments are parsed, and then the logging is set up. The dumping file specified in the
    argument strings is then read using dill.
    Based on the dumping file, the setting package is initialized, the mediator is restored and the state of the random
    module is set.
    The run method of the mediator is executed until an EndOfRun exception is raised. This invokes the post_run method
    of the mediator and ends the resumed run of the application.
    """
    print_start_message()

    args = parse_options(sys.argv[1:])
    logger = set_up_logging(args)

    logger.info("Resuming run based on the dumping file {0}.".format(
        args.dumping_file))
    with open(args.dumping_file, "rb") as file:
        mediator, dumped_setting, dumped_uuid, dumped_random_state = dill.load(
            file)
    mediator.update_logging()
    setting.__dict__.update(dumped_setting.__dict__)
    uuid.__dict__.update(dumped_uuid.__dict__)
    random.setstate(dumped_random_state)

    logger.info("Run identification hash: {0}".format(uuid.get_uuid()))
    logger.info(
        "Underlying platform (determined via platform.platform(aliased=True): {0}"
        .format(platform.platform(aliased=True)))

    if args.no_output:
        logger.info("Deactivating output.")
        mediator.deactivate_output()

    logger.info("Resuming the event-chain Monte Carlo simulation.")
    start_time = time.time()
    try:
        mediator.run()
    except EndOfRun:
        logger.info("EndOfRun exception has been raised.")
    end_time = time.time()

    logger.info("Running the post_run method.")
    mediator.post_run()
    logger.info("Runtime of the resumed simulation: --- %s seconds ---" %
                (end_time - start_time))
Beispiel #2
0
def main() -> None:
    """
    Correct the trajectory of an ECMC simulation given in the command line arguments for ECMC's non-vanishing average
    movement and store the corrected trajectory in {old_filename}_corrected.{old_file_suffix}.
    """
    run.print_start_message()
    args = parse_options(sys.argv[1:])
    universe = MDAnalysis.Universe(args.topology_file, args.trajectory_file)
    new_trajectory_filename = "{0}_corrected{1}".format(
        *path.splitext(args.trajectory_file))
    print(f"Writing corrected trajectory to {new_trajectory_filename}.")
    first_center = universe.atoms.center_of_geometry()
    with universe.trajectory.Writer(new_trajectory_filename) as writer:
        for index, _ in enumerate(universe.trajectory):
            difference = universe.atoms.center_of_geometry() - first_center
            for atom in universe.atoms:
                atom.position -= difference
            assert all(
                abs(d) < 1.0e-6
                for d in universe.atoms.center_of_geometry() - first_center)
            writer.write(universe.atoms)
            if index % 10 == 0:
                print(f"Finished {index} timesteps.")
Beispiel #3
0
def main() -> None:
    """
    Copy the exemplary configuration files of the JeLLyFysh application into the jellyfysh-examples directory that will
    be created in the current working directory.

    The command line arguments set the the logging level and the logging file, and further determine whether only the
    version or help window should be printed.
    The data files are accessed using the resource management API of setuptools.
    """
    print_start_message()

    args = parse_options(sys.argv[1:])
    logger = set_up_logging(args)

    logger.info(
        "Underlying platform (determined via platform.platform(aliased=True): {0}"
        .format(platform.platform(aliased=True)))

    print("Creating directory jellyfysh-examples.")
    mkdir("jellyfysh-examples")

    config_files_directory = resource_filename(__name__, "config_files")
    logger.debug("Detected path of the config_files directory: {0}".format(
        config_files_directory))
    print(
        "Copying the configuration files into the directory jellyfysh-examples/config_files."
    )
    copytree(config_files_directory, "jellyfysh-examples/config_files")

    output_directory = resource_filename(__name__, "output")
    logger.debug(
        "Detected path of the output directory: {0}".format(output_directory))
    print(
        "Copying the reference data and plotting scripts into the directory jellyfysh-examples/output."
    )
    copytree(output_directory, "jellyfysh-examples/output")
Beispiel #4
0
    data_plots += plotting_functions.plot_histogram(
        axes,
        "SamplesOfBonds_SingleMolecule_Length.dat",
        'JellyFysh',
        bins,
        "config_files/2018_JCP_149_064113/water/single_molecule.ini",
        linestyle='--',
        **line_properties)

    plotting_functions.add_legend(axes,
                                  reference_plots + data_plots,
                                  loc='upper left')
    plt.xlabel(r"$\left|\boldsymbol{r}_{\mathrm{OH}}\right|$",
               **label_properties)
    plt.ylabel(
        r"$\pi\left(\left|\boldsymbol{r}_{\mathrm{OH}}\right|\right)$ (cumulative)",
        **label_properties)
    plt.tight_layout(pad=0.1)
    plt.savefig("single_molecule_length.pdf")


if __name__ == '__main__':
    run.print_start_message()
    if matplotlib.__version__ != '3.1.0':
        warnings.warn(
            "The used version of matplotlib is {0}. Note that the plotting parameters are optimized for "
            "version 3.1.0. Please check if all elements are displayed.".
            format(matplotlib.__version__))
    plot_angle()
    plot_length()