Пример #1
0
def run_energy(zma,
               geo,
               spc_info,
               thy_info,
               geo_run_fs,
               geo_save_fs,
               locs,
               run_prefix,
               script_str,
               overwrite,
               zrxn=None,
               retryfail=True,
               method_dct=None,
               highspin=False,
               ref_val=None,
               **kwargs):
    """ Assesses if an electronic energy exists in the CONFS/SP/THY layer
        of the save filesys for a species at the specified level of theory.
        If an energy does not exist, or if a user requests overwrite,
        the appropriate electronic struture calculation is set-up, launched,
        and then parsed within the run filesys, then that the energy and
        job input is written into the save filesys.

        :param zma: Z-Matrix for molecular structure to perform calculation
        :type zma: automol.zmat object
        :param geo: goemetry for molecular structure to perform calculation
        :type geo: automol.geom object
        :param spc_info:
        :type spc_info:
        :param thy_info:
        :type thy_info:
        :geo_run_fs: filesystem object for layer where structure is in RUN
        :geo_run_fs: autofile.fs object
        :geo_save_fs: filesystem object for layer where structure is in SAVE
        :geo_save_fs: autofile.fs object
        :param script_str: shell script for executing electronic structure job
        :type script_str: str
        :param overwrite:
    """

    # Set unneeded vals to
    _, _, _, _ = zrxn, method_dct, ref_val, run_prefix

    geo_run_path = geo_run_fs[-1].path(locs)
    geo_save_path = geo_save_fs[-1].path(locs)

    # Prepare unique filesystem since many energies may be under same directory
    if not highspin:
        sp_run_fs = autofile.fs.single_point(geo_run_path)
        sp_save_fs = autofile.fs.single_point(geo_save_path)
    else:
        sp_run_fs = autofile.fs.high_spin(geo_run_path)
        sp_save_fs = autofile.fs.high_spin(geo_save_path)

    sp_run_path = sp_run_fs[-1].path(thy_info[1:4])
    sp_save_path = sp_save_fs[-1].path(thy_info[1:4])

    # Set input geom
    if geo is not None:
        job_geo = geo
    else:
        job_geo = zma

    exists = sp_save_fs[-1].file.energy.exists(thy_info[1:4])
    if not exists:
        ioprinter.info_message(
            'No energy found in save filesys. Running energy...')
        _run = True
    elif overwrite:
        ioprinter.info_message(
            'User specified to overwrite energy with new run...')
        _run = True
    else:
        _run = False

    if _run:

        # Add options matrix for energy runs for molpro
        _kwargs = copy.deepcopy(kwargs)
        if thy_info[0] == 'molpro2015':
            errs, optmat = es_runner.molpro_opts_mat(spc_info, geo)
            _kwargs.update({'errors': errs, 'options_mat': optmat})

        sp_run_fs[-1].create(thy_info[1:4])
        run_fs = autofile.fs.run(sp_run_path)

        success, ret = es_runner.execute_job(
            job=elstruct.Job.ENERGY,
            script_str=script_str,
            run_fs=run_fs,
            geo=job_geo,
            spc_info=spc_info,
            thy_info=thy_info,
            zrxn=zrxn,
            overwrite=overwrite,
            retryfail=retryfail,
            **_kwargs,
        )

        if success:
            inf_obj, inp_str, out_str = ret

            ioprinter.info_message(" - Reading energy from output...")
            ene = elstruct.reader.energy(inf_obj.prog, inf_obj.method, out_str)

            ioprinter.energy(ene)
            sp_save_fs[-1].create(thy_info[1:4])
            sp_save_fs[-1].file.input.write(inp_str, thy_info[1:4])
            sp_save_fs[-1].file.info.write(inf_obj, thy_info[1:4])
            sp_save_fs[-1].file.energy.write(ene, thy_info[1:4])
            ioprinter.save_energy(sp_save_path)

    else:
        ioprinter.existing_path('Energy', sp_save_path)
        ene = sp_save_fs[-1].file.energy.read(thy_info[1:4])
        ioprinter.energy(ene)
        ioprinter.info_message('')
Пример #2
0
def run_energy(zma,
               geo,
               spc_info,
               thy_info,
               geo_save_fs,
               geo_run_path,
               geo_save_path,
               locs,
               script_str,
               overwrite,
               retryfail=True,
               highspin=False,
               **kwargs):
    """ Assesses if an electronic energy exists in the CONFS/SP/THY layer
        of the save filesys for a species at the specified level of theory.
        If an energy does not exist, or if a user requests overwrite,
        the appropriate electronic struture calculation is set-up, launched,
        and then parsed within the run filesys, then that the energy and
        job input is written into the save filesys.

        :param zma: Z-Matrix for species/TS conformer
        :type zma: automol Z-Matrix data structure
    """

    # geo_save_fs and locs unneeded for this
    _, _ = geo_save_fs, locs

    # Prepare unique filesystem since many energies may be under same directory
    if not highspin:
        sp_run_fs = autofile.fs.single_point(geo_run_path)
        sp_save_fs = autofile.fs.single_point(geo_save_path)
    else:
        sp_run_fs = autofile.fs.high_spin(geo_run_path)
        sp_save_fs = autofile.fs.high_spin(geo_save_path)

    sp_run_fs[-1].create(thy_info[1:4])
    sp_run_path = sp_run_fs[-1].path(thy_info[1:4])
    sp_save_fs[-1].create(thy_info[1:4])
    sp_save_path = sp_save_fs[-1].path(thy_info[1:4])
    run_fs = autofile.fs.run(sp_run_path)

    # Set input geom
    if geo is not None:
        job_geo = geo
    else:
        job_geo = zma

    exists = sp_save_fs[-1].file.energy.exists(thy_info[1:4])
    # _run = need_job((exists, 'energy'), overwrite)
    if not exists:
        ioprinter.info_message(
            'No energy found in save filesys. Running energy...')
        _run = True
    elif overwrite:
        ioprinter.info_message(
            'User specified to overwrite energy with new run...')
        _run = True
    else:
        _run = False

    if _run:

        # Add options matrix for energy runs for molpro
        if thy_info[0] == 'molpro2015':
            errs, optmat = es_runner.molpro_opts_mat(spc_info, geo)
        else:
            errs = ()
            optmat = ()

        success, ret = es_runner.execute_job(
            job=elstruct.Job.ENERGY,
            script_str=script_str,
            run_fs=run_fs,
            geo=job_geo,
            spc_info=spc_info,
            thy_info=thy_info,
            errors=errs,
            options_mat=optmat,
            overwrite=overwrite,
            retryfail=retryfail,
            **kwargs,
        )

        if success:
            inf_obj, inp_str, out_str = ret

            ioprinter.info_message(" - Reading energy from output...")
            ene = elstruct.reader.energy(inf_obj.prog, inf_obj.method, out_str)

            ioprinter.energy(ene)
            sp_save_fs[-1].file.input.write(inp_str, thy_info[1:4])
            sp_save_fs[-1].file.info.write(inf_obj, thy_info[1:4])
            sp_save_fs[-1].file.energy.write(ene, thy_info[1:4])
            ioprinter.save_energy(sp_save_path)

    else:
        ioprinter.existing_path('Energy', sp_save_path)
        ene = sp_save_fs[-1].file.energy.read(thy_info[1:4])
        ioprinter.energy(ene)
Пример #3
0
def save_tau(tau_run_fs, tau_save_fs, mod_thy_info):
    """ save the tau dependent geometries that have been found so far
    """
    # db_style = 'jsondb'
    db_style = 'directory'
    if db_style == 'jsondb':
        saved_locs = tau_save_fs[-1].json_existing()
        saved_geos = tau_save_fs[-1].json.geometry.read_all(saved_locs)
    elif db_style == 'directory':
        saved_geos = [tau_save_fs[-1].file.geometry.read(locs)
                      for locs in tau_save_fs[-1].existing()]
    if not tau_run_fs[0].exists():
        ioprinter.info_message("No tau geometries to save. Skipping...")
    else:
        if db_style == 'jsondb':
            save_info = [[], [], [], [], []]
            sp_save_info = [[], [], [], [], []]
        for locs in tau_run_fs[-1].existing():
            run_path = tau_run_fs[-1].path(locs)
            run_fs = autofile.fs.run(run_path)
            save_path = tau_save_fs[-1].root.path()

            ioprinter.reading("tau run", run_path)

            success, ret = es_runner.read_job(
                job=elstruct.Job.OPTIMIZATION, run_fs=run_fs)
            if success:
                inf_obj, inp_str, out_str = ret
                prog = inf_obj.prog
                method = inf_obj.method
                ene = elstruct.reader.energy(prog, method, out_str)

                geo = elstruct.reader.opt_geometry(prog, out_str)
                if db_style == 'directory':
                    ioprinter.save_geo(save_path)
                    tau_save_fs[-1].create(locs)
                    tau_save_fs[-1].file.geometry_info.write(inf_obj, locs)
                    tau_save_fs[-1].file.geometry_input.write(inp_str, locs)
                    tau_save_fs[-1].file.energy.write(ene, locs)
                    tau_save_fs[-1].file.geometry.write(geo, locs)
                    # Saving the energy to a SP filesystem
                    save_path = tau_save_fs[-1].path(locs)
                    ioprinter.save_energy(save_path)
                    sp_save_fs = autofile.fs.single_point(save_path)
                    sp_save_fs[-1].create(mod_thy_info[1:4])
                    sp_save_fs[-1].file.input.write(inp_str, mod_thy_info[1:4])
                    sp_save_fs[-1].file.info.write(inf_obj, mod_thy_info[1:4])
                    sp_save_fs[-1].file.energy.write(ene, mod_thy_info[1:4])
                elif db_style == 'jsondb':
                    # tau_save_fs[-1].json.geometry_info.write(inf_obj, locs)
                    # tau_save_fs[-1].json.geometry_input.write(inp_str, locs)
                    # tau_save_fs[-1].json.energy.write(ene, locs)
                    # tau_save_fs[-1].json.geometry.write(geo, locs)
                    ioprinter.info_message(
                        " - Saving energy and geo of unique geometry...")
                    save_info[0].append(locs)
                    save_info[1].append(inf_obj)
                    save_info[2].append(inp_str)
                    save_info[3].append(ene)
                    save_info[4].append(geo)

                    sp_save_fs = autofile.fs.single_point(
                        save_path, json_layer=locs)
                    sp_save_info[0].append(sp_save_fs)
                    sp_save_info[1].append(mod_thy_info[1:4])
                    sp_save_info[2].append(inp_str)
                    sp_save_info[3].append(inf_obj)
                    sp_save_info[4].append(ene)
                    sp_save_fs[-1].json.input.write(inp_str, mod_thy_info[1:4])
                    sp_save_fs[-1].json.info.write(inf_obj, mod_thy_info[1:4])
                    sp_save_fs[-1].json.energy.write(ene, mod_thy_info[1:4])

                saved_geos.append(geo)

        if db_style == 'jsondb':
            tau_save_fs[-1].json_create()
            tau_save_fs[-1].json.geometry_info.write_all(
                save_info[1], save_info[0])
            tau_save_fs[-1].json.geometry_input.write_all(
                save_info[2], save_info[0])
            tau_save_fs[-1].json.energy.write_all(
                save_info[3], save_info[0])
            tau_save_fs[-1].json.geometry.write_all(
                save_info[4], save_info[0])

            for i, sp_save_fs_i in enumerate(sp_save_info[0]):
                sp_save_fs_i[-1].json.input.write(
                    sp_save_info[2][i], sp_save_info[1][i])
                sp_save_fs_i[-1].json.info.write(
                    sp_save_info[3][i], sp_save_info[1][i])
                sp_save_fs_i[-1].json.energy.write(
                    sp_save_info[4][i], sp_save_info[1][i])

        # update the tau trajectory file
        filesys.mincnf.traj_sort(tau_save_fs, mod_thy_info)
Пример #4
0
def run_energy(zma,
               geo,
               spc_info,
               thy_info,
               geo_save_fs,
               geo_run_path,
               geo_save_path,
               locs,
               script_str,
               overwrite,
               retryfail=True,
               highspin=False,
               **kwargs):
    """ Find the energy for the given structure
    """

    # geo_save_fs and locs unneeded for this
    _, _ = geo_save_fs, locs

    # Prepare unique filesystem since many energies may be under same directory
    if not highspin:
        sp_run_fs = autofile.fs.single_point(geo_run_path)
        sp_save_fs = autofile.fs.single_point(geo_save_path)
    else:
        sp_run_fs = autofile.fs.high_spin(geo_run_path)
        sp_save_fs = autofile.fs.high_spin(geo_save_path)

    sp_run_fs[-1].create(thy_info[1:4])
    sp_run_path = sp_run_fs[-1].path(thy_info[1:4])
    sp_save_fs[-1].create(thy_info[1:4])
    sp_save_path = sp_save_fs[-1].path(thy_info[1:4])
    run_fs = autofile.fs.run(sp_run_path)

    # Set input geom
    if geo is not None:
        job_geo = geo
    else:
        job_geo = zma

    exists = sp_save_fs[-1].file.energy.exists(thy_info[1:4])
    # _run = need_job((exists, 'energy'), overwrite)
    if not exists:
        ioprinter.info_message(
            'No energy found in save filesys. Running energy...')
        _run = True
    elif overwrite:
        ioprinter.info_message(
            'User specified to overwrite energy with new run...')
        _run = True
    else:
        _run = False

    if _run:

        # Add options matrix for energy runs for molpro
        if thy_info[0] == 'molpro2015':
            errs, optmat = es_runner.molpro_opts_mat(spc_info, geo)
        else:
            errs = ()
            optmat = ()

        success, ret = es_runner.execute_job(
            job='energy',
            script_str=script_str,
            run_fs=run_fs,
            geo=job_geo,
            spc_info=spc_info,
            thy_info=thy_info,
            errors=errs,
            options_mat=optmat,
            overwrite=overwrite,
            retryfail=retryfail,
            **kwargs,
        )

        if success:
            inf_obj, inp_str, out_str = ret

            ioprinter.info_message(" - Reading energy from output...")
            ene = elstruct.reader.energy(inf_obj.prog, inf_obj.method, out_str)

            ioprinter.energy(ene)
            sp_save_fs[-1].file.input.write(inp_str, thy_info[1:4])
            sp_save_fs[-1].file.info.write(inf_obj, thy_info[1:4])
            sp_save_fs[-1].file.energy.write(ene, thy_info[1:4])
            ioprinter.save_energy(sp_save_path)

    else:
        ioprinter.existing_path('Energy', sp_save_path)
        ene = sp_save_fs[-1].file.energy.read(thy_info[1:4])
        ioprinter.energy(ene)