示例#1
0
def reagent_geometries(rxn_info, thy_info, save_prefix):
    """ Identify the reaction and build the object

        :param rxn_info: reaction info object
        :type rxn_info: mechanalyzer.inf.rxn object
        :rtype: (tuple(automol.Reaction object), tuple(automol.zmat object))
    """

    # Check the save filesystem for the reactant and product geometries
    rct_info = rinfo.rgt_info(rxn_info, 'reacs')
    prd_info = rinfo.rgt_info(rxn_info, 'prods')
    _rcts_cnf_fs = filesys.rcts_cnf_fs(rct_info, thy_info, None, save_prefix)
    _prds_cnf_fs = filesys.rcts_cnf_fs(prd_info, thy_info, None, save_prefix)

    # If min cnfs found for all rcts and prds, read the geometries
    rct_geos, prd_geos = (), ()
    rct_paths, prd_paths = (), ()
    if (
        _rcts_cnf_fs.count(None) == 0 and _prds_cnf_fs.count(None) == 0
    ):
        for (_, cnf_save_fs, min_locs, _) in _rcts_cnf_fs:
            geo = cnf_save_fs[-1].file.geometry.read(min_locs)
            path = cnf_save_fs[-1].file.geometry.path(min_locs)
            rct_geos += (geo,)
            rct_paths += (path,)
        for (_, cnf_save_fs, min_locs, _) in _prds_cnf_fs:
            geo = cnf_save_fs[-1].file.geometry.read(min_locs)
            path = cnf_save_fs[-1].file.geometry.path(min_locs)
            prd_geos += (geo,)
            prd_paths += (path,)

    return rct_geos, prd_geos, rct_paths, prd_paths
示例#2
0
文件: _ts.py 项目: sjklipp/mechdriver
def _set_thy_inf_dcts(tsname,
                      ts_dct,
                      thy_dct,
                      es_keyword_dct,
                      run_prefix,
                      save_prefix,
                      zma_locs=(0, )):
    """ set the theory
    """

    rxn_info = ts_dct['rxn_info']
    ts_info = rinfo.ts_info(rxn_info)
    rct_info = rinfo.rgt_info(rxn_info, 'reacs')
    rxn_info = rinfo.sort(rxn_info)

    ts_locs = (int(tsname.split('_')[-1]), )

    high_mult = rinfo.ts_mult(rxn_info, rxn_mul='high')

    # Set the hs info
    hs_info = (ts_info[0], ts_info[1], high_mult)

    # Initialize the theory objects
    ini_thy_info, mod_ini_thy_info = None, None
    thy_info, mod_thy_info = None, None
    vscnlvl_thy_info, mod_vscnlvl_thy_info = None, None
    vsp1lvl_thy_info, mod_vsp1lvl_thy_info = None, None
    vsp2lvl_thy_info, mod_vsp2lvl_thy_info = None, None
    hs_vscnlvl_thy_info = None
    hs_vsp1lvl_thy_info = None
    hs_vsp2lvl_thy_info = None
    hs_thy_info = None

    # Initialize the necessary run filesystem
    runlvl_ts_run_fs = None
    runlvl_scn_run_fs = None
    runlvl_cscn_run_fs = None
    vscnlvl_ts_run_fs = None
    vscnlvl_scn_run_fs = None
    vscnlvl_cscn_run_fs = None
    vrctst_run_fs = None

    # Initialize the necessary save filesystem
    ini_zma_save_fs = None
    runlvl_ts_save_fs = None
    runlvl_scn_save_fs = None  # above cnf filesys, for search scans
    runlvl_cscn_save_fs = None  # above cnf filesys, for search scans
    runlvl_cnf_save_fs = None
    vscnlvl_thy_save_fs = None
    vscnlvl_ts_save_fs = None
    vscnlvl_scn_save_fs = None
    vscnlvl_cscn_save_fs = None
    vrctst_save_fs = None
    runlvl_ts_zma_fs = None

    if es_keyword_dct.get('inplvl', None) is not None:

        ini_method_dct = thy_dct.get(es_keyword_dct['inplvl'])
        ini_thy_info = tinfo.from_dct(ini_method_dct)
        mod_ini_thy_info = tinfo.modify_orb_label(ini_thy_info, ts_info)

        ini_cnf_run_fs, ini_cnf_save_fs = build_fs(
            run_prefix,
            save_prefix,
            'CONFORMER',
            rxn_locs=rxn_info,
            ts_locs=ts_locs,
            thy_locs=mod_ini_thy_info[1:])

        ini_loc_info = filesys.mincnf.min_energy_conformer_locators(
            ini_cnf_save_fs, mod_ini_thy_info)
        ini_min_cnf_locs, ini_path = ini_loc_info

        if ini_path:
            ini_zma_save_fs = autofile.fs.zmatrix(
                ini_cnf_save_fs[-1].path(ini_min_cnf_locs))

    if es_keyword_dct.get('runlvl', None) is not None:

        method_dct = thy_dct.get(es_keyword_dct['runlvl'])
        thy_info = tinfo.from_dct(method_dct)
        mod_thy_info = tinfo.modify_orb_label(thy_info, ts_info)
        hs_thy_info = tinfo.modify_orb_label(thy_info, hs_info)

        runlvl_cnf_run_fs, runlvl_cnf_save_fs = build_fs(
            run_prefix,
            save_prefix,
            'CONFORMER',
            rxn_locs=rxn_info,
            ts_locs=ts_locs,
            thy_locs=mod_thy_info[1:])

        _, runlvl_ts_zma_save_fs = build_fs(run_prefix,
                                            save_prefix,
                                            'ZMATRIX',
                                            rxn_locs=rxn_info,
                                            ts_locs=ts_locs,
                                            thy_locs=mod_thy_info[1:])

        runlvl_loc_info = filesys.mincnf.min_energy_conformer_locators(
            runlvl_cnf_save_fs, mod_thy_info)
        runlvl_min_cnf_locs, _ = runlvl_loc_info
        runlvl_cnf_save_fs = (runlvl_cnf_save_fs, runlvl_min_cnf_locs)

        runlvl_scn_run_fs, runlvl_scn_save_fs = build_fs(
            run_prefix,
            save_prefix,
            'SCAN',
            rxn_locs=rxn_info,
            ts_locs=ts_locs,
            thy_locs=mod_thy_info[1:],
            zma_locs=(0, ))

        runlvl_cscn_run_fs, runlvl_cscn_save_fs = build_fs(
            run_prefix,
            save_prefix,
            'CSCAN',
            rxn_locs=rxn_info,
            ts_locs=ts_locs,
            thy_locs=mod_thy_info[1:],
            zma_locs=(0, ))

    if es_keyword_dct.get('var_scnlvl', None) is not None:

        method_dct = thy_dct.get(es_keyword_dct['var_scnlvl'])
        vscnlvl_thy_info = tinfo.from_dct(method_dct)
        mod_vscnlvl_thy_info = tinfo.modify_orb_label(vscnlvl_thy_info,
                                                      ts_info)
        hs_vscnlvl_thy_info = tinfo.modify_orb_label(vscnlvl_thy_info, hs_info)

        vscnlvl_scn_run_fs, vscnlvl_scn_save_fs = build_fs(
            run_prefix,
            save_prefix,
            'SCAN',
            rxn_locs=rxn_info,
            ts_locs=ts_locs,
            thy_locs=mod_thy_info[1:],
            zma_locs=(0, ))

        vscnlvl_cscn_run_fs, vscnlvl_cscn_save_fs = build_fs(
            run_prefix,
            save_prefix,
            'CSCAN',
            rxn_locs=rxn_info,
            ts_locs=ts_locs,
            thy_locs=mod_thy_info[1:],
            zma_locs=(0, ))

        vrctst_run_fs, vrctst_save_fs = build_fs(run_prefix,
                                                 save_prefix,
                                                 'VRCTST',
                                                 rxn_locs=rxn_info,
                                                 ts_locs=ts_locs,
                                                 thy_locs=mod_thy_info[1:])

        if es_keyword_dct.get('var_splvl1', None) is not None:

            method_dct = thy_dct.get(es_keyword_dct['var_scnlvl1'])
            vsplvl1_thy_info = tinfo.from_dct(method_dct)
            mod_vsplvl1_thy_info = tinfo.modify_orb_label(
                vsplvl1_thy_info, ts_info)
            hs_vsplvl1_thy_info = tinfo.modify_orb_label(
                vsplvl1_thy_info, hs_info)

        if es_keyword_dct.get('var_splvl2', None) is not None:

            method_dct = thy_dct.get(es_keyword_dct['var_scnlvl2'])
            vsplvl2_thy_info = tinfo.from_dct(method_dct)
            mod_vsplvl2_thy_info = tinfo.modify_orb_label(
                vsplvl2_thy_info, ts_info)
            hs_vsplvl2_thy_info = tinfo.modify_orb_label(
                vsplvl2_thy_info, hs_info)

    # Get the conformer filesys for the reactants
    _rcts_cnf_fs = rcts_cnf_fs(rct_info, thy_dct, es_keyword_dct, run_prefix,
                               save_prefix)

    thy_inf_dct = {
        'inplvl': ini_thy_info,
        'runlvl': thy_info,
        'var_scnlvl': vscnlvl_thy_info,
        'var_splvl1': vsp1lvl_thy_info,
        'var_splvl2': vsp2lvl_thy_info,
        'mod_inplvl': mod_ini_thy_info,
        'mod_runlvl': mod_thy_info,
        'mod_var_scnlvl': mod_vscnlvl_thy_info,
        'mod_var_splvl1': mod_vsp1lvl_thy_info,
        'mod_var_splvl2': mod_vsp2lvl_thy_info,
        'hs_var_scnlvl': hs_vscnlvl_thy_info,
        'hs_var_splvl1': hs_vsp1lvl_thy_info,
        'hs_var_splvl2': hs_vsp2lvl_thy_info,
        'hs_runlvl': hs_thy_info
    }

    runfs_dct = {
        'runlvl_scn_fs': runlvl_scn_run_fs,
        'runlvl_cscn_fs': runlvl_cscn_run_fs,
        'runlvl_cnf_fs': runlvl_cnf_run_fs,
        'vscnlvl_ts_fs': vscnlvl_ts_run_fs,
        'vscnlvl_scn_fs': vscnlvl_scn_run_fs,
        'vscnlvl_cscn_fs': vscnlvl_cscn_run_fs,
        'vrctst_fs': vrctst_run_fs,
    }

    savefs_dct = {
        'inilvl_zma_fs': ini_zma_save_fs,
        'runlvl_scn_fs': runlvl_scn_save_fs,
        'runlvl_cscn_fs': runlvl_cscn_save_fs,
        'runlvl_cnf_fs': runlvl_cnf_save_fs,
        'vscnlvl_scn_fs': vscnlvl_scn_save_fs,
        'vscnlvl_cscn_fs': vscnlvl_cscn_save_fs,
        'vrctst_fs': vrctst_save_fs,
        'rcts_cnf_fs': _rcts_cnf_fs,
        'runlvl_ts_zma_fs': runlvl_ts_zma_save_fs
    }

    return thy_inf_dct, runfs_dct, savefs_dct
示例#3
0
def thy_dcts(tsname, ts_dct, thy_dct, es_keyword_dct,
             run_prefix, save_prefix):
    """ set the theory
    """

    # Get transition state info
    ts_zma = ts_dct['zma']
    aspace = ts_dct['active']

    # Set reaction info
    rxn_info = ts_dct['rxn_info']
    ts_info = rinfo.ts_info(rxn_info)
    rct_info = rinfo.rgt_info(rxn_info, 'reacs')
    rxn_info_sort = rinfo.sort(rxn_info)

    # Set the high-sping ts info
    high_mult = rinfo.ts_mult(rxn_info, rxn_mul='high')
    hs_info = (ts_info[0], ts_info[1], high_mult)

    # Set the filesystem locs
    ts_locs = (int(tsname.split('_')[-1]),)
    zma_locs = (ts_dct.get('zma_idx', 0),)

    # Initialize the theory objects
    ini_thy_info, mod_ini_thy_info = None, None
    thy_info, mod_thy_info = None, None
    vscnlvl_thy_info, mod_vscnlvl_thy_info = None, None
    vsp1lvl_thy_info, mod_vsp1lvl_thy_info = None, None
    vsp2lvl_thy_info, mod_vsp2lvl_thy_info = None, None
    hs_vscnlvl_thy_info = None
    hs_vsp1lvl_thy_info = None
    hs_vsp2lvl_thy_info = None
    hs_thy_info = None

    # Method dicts
    ini_method_dct = None
    run_method_dct = None
    vscn_method_dct = None
    vsp1_method_dct = None
    vsp2_method_dct = None

    # Multireference Params
    inplvl_mref_params = {}
    runlvl_mref_params = {}
    vscn_mref_params = {}
    vsp1_mref_params = {}
    vsp2_mref_params = {}

    # Initialize the necessary run filesystem
    runlvl_scn_run_fs = None
    runlvl_cscn_run_fs = None
    vscnlvl_ts_run_fs = None
    vscnlvl_scn_run_fs = None
    vscnlvl_cscn_run_fs = None
    vrctst_run_fs = None

    # Initialize the necessary save filesystem
    inplvl_cnf_save_fs = None
    runlvl_scn_save_fs = None   # above cnf filesys, for search scans
    runlvl_cscn_save_fs = None   # above cnf filesys, for search scans
    runlvl_cnf_save_fs = None
    vscnlvl_scn_save_fs = None
    vscnlvl_cscn_save_fs = None
    vrctst_save_fs = None

    if es_keyword_dct.get('inplvl', None) is not None:

        ini_method_dct = thy_dct.get(es_keyword_dct['inplvl'])
        ini_thy_info = tinfo.from_dct(ini_method_dct)
        mod_ini_thy_info = tinfo.modify_orb_label(
            ini_thy_info, ts_info)

        # Conformer Layer for saddle point structures
        _, inplvl_cnf_save_fs = build_fs(
            run_prefix, save_prefix, 'CONFORMER',
            rxn_locs=rxn_info_sort, ts_locs=ts_locs,
            thy_locs=mod_ini_thy_info[1:])

        inplvl_loc_info = filesys.mincnf.min_energy_conformer_locators(
            inplvl_cnf_save_fs, mod_thy_info)
        inplvl_min_cnf_locs, _ = inplvl_loc_info
        inplvl_cnf_save_tuple = (inplvl_cnf_save_fs, inplvl_min_cnf_locs)

        if elstruct.par.Method.is_multiref(ini_thy_info[1]):
            inplvl_mref_params = multireference_calculation_parameters(
                ts_zma, ts_info, hs_info,
                aspace, mod_ini_thy_info, rxn_info=rxn_info)

    if es_keyword_dct.get('runlvl', None) is not None:

        run_method_dct = thy_dct.get(es_keyword_dct['runlvl'])
        thy_info = tinfo.from_dct(run_method_dct)
        mod_thy_info = tinfo.modify_orb_label(
            thy_info, ts_info)
        hs_thy_info = tinfo.modify_orb_label(
            thy_info, hs_info)

        # Conformer Layer for saddle point structures
        runlvl_cnf_run_fs, runlvl_cnf_save_fs = build_fs(
            run_prefix, save_prefix, 'CONFORMER',
            rxn_locs=rxn_info_sort, ts_locs=ts_locs,
            thy_locs=mod_thy_info[1:])

        runlvl_loc_info = filesys.mincnf.min_energy_conformer_locators(
            runlvl_cnf_save_fs, mod_thy_info)
        runlvl_min_cnf_locs, _ = runlvl_loc_info
        runlvl_cnf_save_tuple = (runlvl_cnf_save_fs, runlvl_min_cnf_locs)

        # TS/IDX/Z Layer used for coordinate scans (perhaps for guesses)
        _, runlvl_z_save_fs = build_fs(
            run_prefix, save_prefix, 'ZMATRIX',
            rxn_locs=rxn_info_sort, ts_locs=ts_locs,
            thy_locs=mod_thy_info[1:])

        runlvl_scn_run_fs, runlvl_scn_save_fs = build_fs(
            run_prefix, save_prefix, 'SCAN',
            rxn_locs=rxn_info_sort, ts_locs=ts_locs,
            thy_locs=mod_thy_info[1:], zma_locs=zma_locs)

        runlvl_cscn_run_fs, runlvl_cscn_save_fs = build_fs(
            run_prefix, save_prefix, 'CSCAN',
            rxn_locs=rxn_info_sort, ts_locs=ts_locs,
            thy_locs=mod_thy_info[1:], zma_locs=zma_locs)

        if elstruct.par.Method.is_multiref(thy_info[1]):
            runlvl_mref_params = multireference_calculation_parameters(
                ts_zma, ts_info, hs_info,
                aspace, mod_thy_info, rxn_info=rxn_info)

    if es_keyword_dct.get('var_scnlvl', None) is not None:

        vscn_method_dct = thy_dct.get(es_keyword_dct['var_scnlvl'])
        vscnlvl_thy_info = tinfo.from_dct(vscn_method_dct)
        mod_vscnlvl_thy_info = tinfo.modify_orb_label(
            vscnlvl_thy_info, ts_info)
        hs_vscnlvl_thy_info = tinfo.modify_orb_label(
            vscnlvl_thy_info, hs_info)

        vscnlvl_scn_run_fs, vscnlvl_scn_save_fs = build_fs(
            run_prefix, save_prefix, 'SCAN',
            rxn_locs=rxn_info_sort, ts_locs=ts_locs,
            thy_locs=mod_vscnlvl_thy_info[1:], zma_locs=zma_locs)

        vscnlvl_cscn_run_fs, vscnlvl_cscn_save_fs = build_fs(
            run_prefix, save_prefix, 'CSCAN',
            rxn_locs=rxn_info_sort, ts_locs=ts_locs,
            thy_locs=mod_vscnlvl_thy_info[1:], zma_locs=zma_locs)

        vrctst_run_fs, vrctst_save_fs = build_fs(
            run_prefix, save_prefix, 'VRCTST',
            rxn_locs=rxn_info_sort, ts_locs=ts_locs,
            thy_locs=mod_vscnlvl_thy_info[1:])

        if elstruct.par.Method.is_multiref(vscnlvl_thy_info[1]):
            vscn_mref_params = multireference_calculation_parameters(
                ts_zma, ts_info, hs_info,
                aspace, mod_vscnlvl_thy_info, rxn_info=rxn_info)

    if es_keyword_dct.get('var_splvl1', None) is not None:

        vsp1_method_dct = thy_dct.get(es_keyword_dct['var_splvl1'])
        vsp1lvl_thy_info = tinfo.from_dct(vsp1_method_dct)
        mod_vsp1lvl_thy_info = tinfo.modify_orb_label(
            vsp1lvl_thy_info, ts_info)
        hs_vsp1lvl_thy_info = tinfo.modify_orb_label(
            vsp1lvl_thy_info, hs_info)

        if elstruct.par.Method.is_multiref(vsp1lvl_thy_info[1]):
            vsp1_mref_params = multireference_calculation_parameters(
                ts_zma, ts_info, hs_info,
                aspace, mod_vsp1lvl_thy_info, rxn_info=rxn_info)

    if es_keyword_dct.get('var_splvl2', None) is not None:

        vsp2_method_dct = thy_dct.get(es_keyword_dct['var_splvl2'])
        vsp2lvl_thy_info = tinfo.from_dct(vsp2_method_dct)
        mod_vsp2lvl_thy_info = tinfo.modify_orb_label(
            vsp2lvl_thy_info, ts_info)
        hs_vsp2lvl_thy_info = tinfo.modify_orb_label(
            vsp2lvl_thy_info, hs_info)

        if elstruct.par.Method.is_multiref(vsp2lvl_thy_info[1]):
            vsp2_mref_params = multireference_calculation_parameters(
                ts_zma, ts_info, hs_info,
                aspace, mod_vsp2lvl_thy_info, rxn_info=rxn_info)

    # Get the conformer filesys for the reactants
    _rcts_cnf_fs = rcts_cnf_fs(rct_info, ini_thy_info, run_prefix, save_prefix)
    if _rcts_cnf_fs is None:
        _rcts_cnf_fs = rcts_cnf_fs(rct_info, thy_info, run_prefix, save_prefix)

    thy_inf_dct = {
        'inplvl': ini_thy_info,
        'runlvl': thy_info,
        'var_scnlvl': vscnlvl_thy_info,
        'var_splvl1': vsp1lvl_thy_info,
        'var_splvl2': vsp2lvl_thy_info,
        'mod_inplvl': mod_ini_thy_info,
        'mod_runlvl': mod_thy_info,
        'mod_var_scnlvl': mod_vscnlvl_thy_info,
        'mod_var_splvl1': mod_vsp1lvl_thy_info,
        'mod_var_splvl2': mod_vsp2lvl_thy_info,
        'hs_var_scnlvl': hs_vscnlvl_thy_info,
        'hs_var_splvl1': hs_vsp1lvl_thy_info,
        'hs_var_splvl2': hs_vsp2lvl_thy_info,
        'hs_runlvl': hs_thy_info,
        'rct_info': rct_info
    }

    thy_method_dct = {
        'inplvl': ini_method_dct,
        'runlvl': run_method_dct,
        'var_scnlvl': vscn_method_dct,
        'var_splvl1': vsp1_method_dct,
        'var_splvl2': vsp2_method_dct,
    }

    mref_params_dct = {
        'inplvl': inplvl_mref_params,
        'runlvl': runlvl_mref_params,
        'var_scnlvl': vscn_mref_params,
        'var_splvl1': vsp1_mref_params,
        'var_splvl2': vsp2_mref_params,
    }

    runfs_dct = {
        'runlvl_scn': runlvl_scn_run_fs,
        'runlvl_cscn': runlvl_cscn_run_fs,
        'runlvl_cnf': runlvl_cnf_run_fs,
        'vscnlvl_ts': vscnlvl_ts_run_fs,
        'vscnlvl_scn': vscnlvl_scn_run_fs,
        'vscnlvl_cscn': vscnlvl_cscn_run_fs,
        'vrctst': vrctst_run_fs,
        'prefix': run_prefix
    }

    savefs_dct = {
        'runlvl_scn': runlvl_scn_save_fs,
        'runlvl_cscn': runlvl_cscn_save_fs,
        'runlvl_ts_zma': runlvl_z_save_fs,
        'inplvl_cnf_tuple': inplvl_cnf_save_tuple,
        'runlvl_cnf_tuple': runlvl_cnf_save_tuple,
        'vscnlvl_scn': vscnlvl_scn_save_fs,
        'vscnlvl_cscn': vscnlvl_cscn_save_fs,
        'vrctst': vrctst_save_fs,
        'rcts_cnf': _rcts_cnf_fs,
        'prefix': save_prefix
    }

    return (thy_inf_dct, thy_method_dct,
            mref_params_dct,
            runfs_dct, savefs_dct)