예제 #1
0
def reagent_energies(save_prefix, rgt_ichs, rgt_chgs, rgt_muls, sp_thy_info,
                     geo_thy_info):
    """ reagent energies """

    enes = []
    for rgt_ich, rgt_chg, rgt_mul in zip(rgt_ichs, rgt_chgs, rgt_muls):

        # Set filesys
        spc_save_fs = autofile.fs.species(save_prefix)
        rgt_info = [rgt_ich, rgt_chg, rgt_mul]
        spc_save_path = spc_save_fs[-1].path(rgt_info)

        mod_geo_thy_info = modify_orb_restrict(rgt_info, geo_thy_info)
        mod_sp_thy_info = modify_orb_restrict(rgt_info, sp_thy_info)
        thy_save_fs = autofile.fs.theory(spc_save_path)
        thy_save_path = thy_save_fs[-1].path(mod_geo_thy_info[1:4])
        cnf_save_fs = autofile.fs.conformer(thy_save_path)
        min_cnf_locs, _ = min_energy_conformer_locators(
            cnf_save_fs, mod_geo_thy_info)

        # Read energy
        ene = None
        if min_cnf_locs:
            cnf_path = cnf_save_fs[-1].path(min_cnf_locs)
            sp_fs = autofile.fs.single_point(cnf_path)
            if sp_fs[-1].file.energy.exists(mod_sp_thy_info[1:4]):
                ene = sp_fs[-1].file.energy.read(mod_sp_thy_info[1:4])
        enes.append(ene)

    if any(ene is None for ene in enes):
        enes = None

    return enes
예제 #2
0
def set_model_filesys(spc_dct_i, level, run_prefix, save_prefix, saddle):
    """ Gets filesystem objects for reading many calculations
    """

    # Set the spc_info
    spc_info = finf.get_spc_info(spc_dct_i)
    # Set some path stuff
    if saddle:
        save_path = spc_dct_i['rxn_fs'][3]
        run_path = spc_dct_i['rxn_fs'][2]
    else:
        spc_save_fs = autofile.fs.species(save_prefix)
        spc_save_fs[-1].create(spc_info)
        save_path = spc_save_fs[-1].path(spc_info)
        spc_run_fs = autofile.fs.species(run_prefix)
        spc_run_fs[-1].create(spc_info)
        run_path = spc_run_fs[-1].path(spc_info)

    # Set theory filesystem used throughout
    thy_save_fs = autofile.fs.theory(save_path)
    thy_run_fs = autofile.fs.theory(run_path)

    # Set the level for the model
    levelp = finf.modify_orb_restrict(spc_info, level)

    # Get the save fileystem path
    save_path = thy_save_fs[-1].path(levelp[1:4])
    run_path = thy_run_fs[-1].path(levelp[1:4])
    thy_run_fs[-1].create(levelp[1:4])
    if saddle:
        save_fs = autofile.fs.transition_state(save_path)
        save_fs[0].create()
        save_path = save_fs[0].path()
        run_fs = autofile.fs.transition_state(run_path)
        run_fs[0].create()
        run_path = run_fs[0].path()

    # Get the fs object and the locs
    cnf_run_fs = autofile.fs.conformer(run_path)
    cnf_save_fs = autofile.fs.conformer(save_path)
    min_cnf_locs, cnf_save_path = mincnf.min_energy_conformer_locators(
        cnf_save_fs, levelp)

    # Get the save path for the conformers
    # if min_cnf_locs:
    #     cnf_save_path = cnf_save_fs[-1].path(min_cnf_locs)
    # else:
    #     cnf_save_path = ''

    return [cnf_save_fs, cnf_save_path, min_cnf_locs, save_path, cnf_run_fs]
예제 #3
0
def rpath_ref_idx(ts_dct, scn_vals, coord_name, scn_prefix,
                  ene_info1, ene_info2):
    """ Get the reference energy along a reaction path
    """

    # Set up the filesystem
    zma_fs = autofile.fs.manager(scn_prefix, 'ZMATRIX')
    zma_path = zma_fs[-1].path([0])
    scn_fs = autofile.fs.scan(zma_path)

    ene_info1 = ene_info1[1][0][1]
    ene_info2 = ene_info2[0]
    print('mod_eneinf1', ene_info1)
    print('mod_eneinf2', ene_info2)
    mod_ene_info1 = finf.modify_orb_restrict(
        finf.get_spc_info(ts_dct), ene_info1)
    mod_ene_info2 = finf.modify_orb_restrict(
        finf.get_spc_info(ts_dct), ene_info2)

    ene1, ene2, ref_val = None, None, None
    for val in reversed(scn_vals):
        locs = [[coord_name], [val]]
        path = scn_fs[-1].path(locs)
        hs_fs = autofile.fs.high_spin(path)
        if hs_fs[-1].file.energy.exists(mod_ene_info1[1:4]):
            ene1 = hs_fs[-1].file.energy.read(mod_ene_info1[1:4])
        if hs_fs[-1].file.energy.exists(mod_ene_info2[1:4]):
            ene2 = hs_fs[-1].file.energy.read(mod_ene_info2[1:4])
        if ene1 is not None and ene2 is not None:
            print('found', val)
            ref_val = val
            break

    if ref_val is not None:
        scn_idx = scn_vals.index(ref_val)

    return scn_idx, ene1, ene2
예제 #4
0
def get_geos(spcs, spc_dct, ini_thy_info, save_prefix, run_prefix,
             kickoff_size, kickoff_backward):
    """get geos for reactants and products using the initial level of theory
    """
    spc_geos = []
    cnf_save_fs_lst = []
    for spc in spcs:
        spc_info = [
            spc_dct[spc]['inchi'], spc_dct[spc]['charge'], spc_dct[spc]['mult']
        ]
        ini_thy_lvl = modify_orb_restrict(spc_info, ini_thy_info)
        spc_save_fs = autofile.fs.species(save_prefix)
        spc_save_fs[-1].create(spc_info)
        spc_save_path = spc_save_fs[-1].path(spc_info)
        ini_thy_save_fs = autofile.fs.theory(spc_save_path)
        ini_thy_save_path = ini_thy_save_fs[-1].path(ini_thy_lvl[1:4])
        cnf_save_fs = autofile.fs.conformer(ini_thy_save_path)
        cnf_save_fs_lst.append(cnf_save_fs)
        min_cnf_locs, _ = min_energy_conformer_locators(
            cnf_save_fs, ini_thy_lvl)
        # print('min_cnf_locs test:', min_cnf_locs)
        if min_cnf_locs:
            geo = cnf_save_fs[-1].file.geometry.read(min_cnf_locs)
            # else:
            #     spc_run_fs = autofile.fs.species(run_prefix)
            #     spc_run_fs[-1].create(spc_info)
            #     spc_run_path = spc_run_fs[-1].path(spc_info)
            #     ini_thy_run_fs = autofile.fs.theory(spc_run_path)
            #     ini_thy_run_path = ini_thy_run_fs[-1].path(ini_thy_lvl[1:4])
            #     cnf_run_fs = autofile.fs.conformer(ini_thy_run_path)
            #     run_fs = autofile.fs.run(ini_thy_run_path)
            #     run_fs[0].create()
            #     geo = geom.reference_geometry(
            #         spc_dct[spc], spc_info,
            #         ini_thy_lvl, ini_thy_lvl,
            #         ini_thy_run_fs, ini_thy_save_fs,
            #         ini_thy_save_fs,
            #         cnf_run_fs, cnf_save_fs,
            #         run_fs,
            #         opt_script_str, overwrite,
            #         kickoff_size=kickoff_size,
            #         kickoff_backward=kickoff_backward)
            spc_geos.append(geo)
    return spc_geos, cnf_save_fs_lst
예제 #5
0
def electronic_energy(spc_dct_i, pf_filesystems, pf_levels):
    """ get high level energy at low level optimized geometry
    """

    print('- Calculating electronic energy')

    # spc_dct_i = spc_dct[spc_name]
    spc_info = finf.get_spc_info(spc_dct_i)

    # Get the harmonic filesys information
    [_, cnf_path, _, _, _] = pf_filesystems['harm']

    # Get the electronic energy levels
    ene_levels = pf_levels['ene'][1]

    # Read the energies from the filesystem
    e_elec = None
    if os.path.exists(cnf_path):

        e_elec = 0.0
        # print('lvls', ene_levels)
        for (coeff, level) in ene_levels:
            # Build SP filesys
            mod_thy_info = finf.modify_orb_restrict(spc_info, level)
            sp_save_fs = autofile.fs.single_point(cnf_path)
            sp_save_fs[-1].create(mod_thy_info[1:4])
            # Read the energy
            sp_path = sp_save_fs[-1].path(mod_thy_info[1:4])
            if os.path.exists(sp_path):
                print('Energy read from path {}'.format(sp_path))
                ene = sp_save_fs[-1].file.energy.read(mod_thy_info[1:4])
                e_elec += (coeff * ene)
            else:
                print('No energy at path')
                e_elec = None
                break
    else:
        print('No conformer to calculate the energy')

    return e_elec
예제 #6
0
def set_rpath_filesys(ts_dct, level):
    """ Gets filesystem objects for reading many calculations
    """

    # Set the spc_info
    spc_info = finf.get_spc_info(ts_dct)

    # Set some path stuff
    save_path = ts_dct['rxn_fs'][3]
    run_path = ts_dct['rxn_fs'][2]

    # Set theory filesystem used throughout
    thy_save_fs = autofile.fs.theory(save_path)
    thy_run_fs = autofile.fs.theory(run_path)

    levelp = finf.modify_orb_restrict(spc_info, level[1])

    # Get the save fileystem path
    print('level', levelp)
    save_path = thy_save_fs[-1].path(levelp[1:4])
    run_path = thy_run_fs[-1].path(levelp[1:4])

    thy_save_fs[-1].create(levelp[1:4])
    thy_run_fs[-1].create(levelp[1:4])

    thy_save_path = thy_save_fs[-1].path(levelp[1:4])
    thy_run_path = thy_run_fs[-1].path(levelp[1:4])

    ts_save_fs = autofile.fs.transition_state(thy_save_path)
    ts_save_fs[0].create()
    ts_save_path = ts_save_fs[0].path()
    ts_run_fs = autofile.fs.transition_state(thy_run_path)
    ts_run_fs[0].create()
    ts_run_path = ts_run_fs[0].path()

    return ts_run_path, ts_save_path, thy_run_path, thy_save_path