Beispiel #1
0
def set_model_filesys(spc_dct_i, level,
                      run_prefix, save_prefix, saddle, name=None, rings='all'):
    """ Gets filesystem objects for reading many calculations
    """

    # Set the spc_info
    if saddle:
        rxn_info = spc_dct_i['rxn_info']
        spc_info = rinfo.ts_info(rxn_info)
    else:
        spc_info = sinfo.from_dct(spc_dct_i)

    print('level', level)
    levelp = tinfo.modify_orb_label(level, spc_info)

    _root = root_locs(spc_dct_i, saddle=saddle, name=name)
    cnf_run_fs, cnf_save_fs = build_fs(
        run_prefix, save_prefix, 'CONFORMER',
        thy_locs=levelp[1:],
        **_root)

    if rings == 'min':
        min_rngs_locs, min_rngs_path = mincnf.min_energy_conformer_locators(
            cnf_save_fs, levelp)
        cnf_run_fs[-1].create(min_rngs_locs)
    else:
        min_rngs_locs, min_rngs_path = mincnf.conformer_locators(
             cnf_save_fs, levelp, cnf_range='r100')
        for min_locs in min_rngs_locs:
            cnf_run_fs[-1].create(min_locs)

    print('model filesys', min_rngs_locs, min_rngs_path)
    # Create run fs if that directory has been deleted to run the jobs

    return [cnf_save_fs, min_rngs_path, min_rngs_locs, '', cnf_run_fs]
Beispiel #2
0
def reactions(rxn_info, ini_thy_info, zma_locs, save_prefix):
    """ Check if reaction exists in the filesystem and has been identified
    """

    zrxns, zmas = (), ()

    sort_rxn_info = rinfo.sort(rxn_info, scheme='autofile')
    ts_info = rinfo.ts_info(rxn_info)
    mod_ini_thy_info = tinfo.modify_orb_label(ini_thy_info, ts_info)

    rxn_fs = autofile.fs.reaction(save_prefix)
    if rxn_fs[-1].exists(sort_rxn_info):
        _, ts_save_fs = build_fs(save_prefix,
                                 save_prefix,
                                 'TRANSITION STATE',
                                 rxn_locs=sort_rxn_info,
                                 thy_locs=mod_ini_thy_info[1:])
        for ts_locs in ts_save_fs[-1].existing():
            zrxn, zma = reaction(rxn_info,
                                 ini_thy_info,
                                 zma_locs,
                                 save_prefix,
                                 ts_locs=ts_locs)
            if zrxn is not None:
                zrxns += (zrxn, )
                zmas += (zma, )

    if not zrxns:
        zrxns, zmas = None, None

    return zrxns, zmas
Beispiel #3
0
def calc_vrctst_flux(ts_dct,
                     thy_inf_dct, thy_method_dct, mref_params,
                     es_keyword_dct,
                     runfs_dct, savefs_dct):
    """ Set up n VRC-TST calculations to get the flux file
    """

    # Build VRC-TST stuff
    vrc_fs = runfs_dct['vrctst']
    vrc_path = vrc_fs[-1].create((0,))
    vrc_path = vrc_fs[-1].path((0,))
    vrc_dct = autorun.varecof.VRC_DCT  # need code to input one
    machine_dct = {'bxxx': 10}  # how to do this when on a node

    # Get a bunch of info that describes the grid
    scan_inf_dct = _scan_inf_dct(ts_dct, savefs_dct)

    # Calculate the correction potential along the MEP
    inf_sep_ene, npot, zma_for_inp = _build_correction_potential(
        ts_dct, scan_inf_dct,
        thy_inf_dct, thy_method_dct, mref_params,
        es_keyword_dct,
        runfs_dct, savefs_dct,
        vrc_dct, vrc_path)

    # Write the VaReCoF input files
    inp_strs = autorun.varecof.write_input(
        vrc_path,
        zma_for_inp, scan_inf_dct['rct_zmas'],
        npot, scan_inf_dct['rxn_bond_keys'],
        machine_dct, vrc_dct)

    rxn_info = ts_dct['rxn_info']
    ts_info = rinfo.ts_info(rxn_info)
    mod_var_sp1_thy_info = thy_inf_dct['mod_var_splvl1']
    cas_kwargs = mref_params['var_scnlvl']
    molp_tmpl_str = varecof_io.writer.molpro_template(
        ts_info, mod_var_sp1_thy_info, inf_sep_ene, cas_kwargs)

    inp_strs.update({'run.tml': molp_tmpl_str})

    # Run VaReCoF to generate flux file
    running(f'VaReCoF at {vrc_path}')
    flux_str = autorun.varecof.flux_file(
        autorun.SCRIPT_DCT['varecof'], autorun.SCRIPT_DCT['mcflux'],
        vrc_path, inp_strs)

    # Read the corr pot file to send to save
    pot_corr_str = ioformat.pathtools.read_file(
        vrc_path, 'run_corr.f')

    # Save the flux file
    if flux_str is not None:
        filesys.save.flux(flux_str, pot_corr_str, inp_strs,
                          savefs_dct['vrctst'], vrc_locs=(0,))
        success = True
    else:
        success = False

    return success
Beispiel #4
0
def set_model_filesys(spc_dct_i,
                      level,
                      run_prefix,
                      save_prefix,
                      saddle,
                      name=None,
                      cnf_range='min',
                      spc_locs=None,
                      nprocs=1):
    """ Gets filesystem objects for reading many calculations
    """

    # Set the spc_info
    if saddle:
        rxn_info = spc_dct_i['rxn_info']
        spc_info = rinfo.ts_info(rxn_info)
    else:
        spc_info = sinfo.from_dct(spc_dct_i)

    levelp = tinfo.modify_orb_label(level, spc_info)

    _root = root_locs(spc_dct_i, saddle=saddle, name=name)
    cnf_run_fs, cnf_save_fs = build_fs(run_prefix,
                                       save_prefix,
                                       'CONFORMER',
                                       thy_locs=levelp[1:],
                                       **_root)

    hbond_cutoffs = spc_dct_i['hbond_cutoffs']
    if cnf_range == 'specified':
        min_rngs_locs = spc_locs
        min_rngs_path = cnf_save_fs[-1].path(min_rngs_locs)
        cnf_run_fs[-1].create(min_rngs_locs)
    elif cnf_range == 'min':
        min_rngs_locs, min_rngs_path = min_energy_conformer_locators(
            cnf_save_fs, levelp, hbond_cutoffs=hbond_cutoffs)
        cnf_run_fs[-1].create(min_rngs_locs)
    else:
        min_rngs_locs_lst, min_rngs_path_lst = conformer_locators(
            cnf_save_fs,
            levelp,
            cnf_range=cnf_range,
            hbond_cutoffs=hbond_cutoffs,
            nprocs=nprocs)
        for min_locs in min_rngs_locs_lst:
            cnf_run_fs[-1].create(min_locs)
        min_rngs_locs = min_rngs_locs_lst[0]
        min_rngs_path = min_rngs_path_lst[0]
        ioprinter.warning_message('Only returning first location in this list')
    # Create run fs if that directory has been deleted to run the jobs

    return [cnf_save_fs, min_rngs_path, min_rngs_locs, '', cnf_run_fs]
Beispiel #5
0
def search(ini_zma, spc_dct, tsname, thy_inf_dct, thy_method_dct, mref_dct,
           es_keyword_dct, runfs_dct, savefs_dct):
    """ Attempt to locate and optimize a proper transition state.
    """
    # CHECK
    _ = thy_inf_dct

    # Initialize success variable to False
    success = False

    # Build ts dct for functions
    ts_dct = spc_dct[tsname]

    if ini_zma is not None:
        # Use the zma from the ini level as a guess
        guess_zmas = (ini_zma, )
    else:
        # Generate a guess zma by scanning along rxncoord and finding max
        guess_zmas = rpath.internal_coordinates_scan(
            ts_zma=ts_dct['zma'],
            zrxn=ts_dct['zrxn'],
            ts_info=rinfo.ts_info(ts_dct['rxn_info']),
            rxn_class=ts_dct['class'],
            method_dct=thy_method_dct['runlvl'],
            mref_params=mref_dct['runlvl'],
            scn_run_fs=runfs_dct['runlvl_scn'],
            scn_save_fs=savefs_dct['runlvl_scn'],
            es_keyword_dct=es_keyword_dct)

    # Optimize guess and check if saddle point good to save
    if guess_zmas is not None:

        cnf_locs = (autofile.schema.generate_new_ring_id(),
                    autofile.schema.generate_new_conformer_id())

        opt_ret, hess_ret = optimize_saddle_point(guess_zmas, ts_dct,
                                                  thy_method_dct['runlvl'],
                                                  mref_dct['runlvl'],
                                                  runfs_dct, es_keyword_dct,
                                                  cnf_locs)

        status = assess_saddle_point(opt_ret, hess_ret, ts_dct, runfs_dct,
                                     cnf_locs)
        if status == 'save':
            save_saddle_point(opt_ret, hess_ret, ts_dct,
                              thy_method_dct['runlvl'], savefs_dct, cnf_locs)
            success = True
            # print the saddle point

    return success
Beispiel #6
0
def electronic_energy(spc_dct_i, pf_filesystems, spc_model_dct_i, conf=None):
    """ get high level energy at low level optimized geometry
    """

    ioprinter.info_message('- Calculating electronic energy')

    # spc_dct_i = spc_dct[spc_name]
    rxn_info = spc_dct_i.get('rxn_info', None)
    if rxn_info is not None:
        spc_info = rinfo.ts_info(rxn_info)
    else:
        spc_info = sinfo.from_dct(spc_dct_i)

    # Get the harmonic filesys information
    if conf:
        cnf_path = conf[1]
    else:
        [_, cnf_path, _, _, _] = pf_filesystems['harm']

    # Get the electronic energy levels
    ene_levels = tuple(val[1] for key, val in spc_model_dct_i['ene'].items()
                       if 'lvl' in key)
    print('ene levels', ene_levels)

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

        e_elec = 0.0
        # ioprinter.info_message('lvls', ene_levels)
        for (coeff, level) in ene_levels:
            # Build SP filesys
            mod_thy_info = tinfo.modify_orb_label(level, spc_info)
            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):
                ioprinter.reading('Energy', sp_path)
                ene = sp_save_fs[-1].file.energy.read(mod_thy_info[1:4])
                e_elec += (coeff * ene)
            else:
                ioprinter.warning_message('No energy at path')
                e_elec = None
                break
    else:
        ioprinter.warning_message('No conformer to calculate the energy')

    return e_elec
Beispiel #7
0
def reaction(rxn_info,
             ini_thy_info,
             zma_locs,
             save_prefix,
             ts_locs=(0, ),
             hbond_cutoffs=None):
    """ Check if reaction exists in the filesystem and has been identified
    """

    zrxn, zma = None, None

    sort_rxn_info = rinfo.sort(rxn_info, scheme='autofile')
    ts_info = rinfo.ts_info(rxn_info)
    mod_ini_thy_info = tinfo.modify_orb_label(ini_thy_info, ts_info)

    rxn_fs = autofile.fs.reaction(save_prefix)
    if rxn_fs[-1].exists(sort_rxn_info):
        _, cnf_save_fs = build_fs(save_prefix,
                                  save_prefix,
                                  'CONFORMER',
                                  rxn_locs=sort_rxn_info,
                                  thy_locs=mod_ini_thy_info[1:],
                                  ts_locs=ts_locs)

        _, ini_min_cnf_path = min_energy_conformer_locators(
            cnf_save_fs, mod_ini_thy_info, hbond_cutoffs=hbond_cutoffs)
        if ini_min_cnf_path:
            zma_fs = autofile.fs.zmatrix(ini_min_cnf_path)
            if zma_fs[-1].file.reaction.exists(zma_locs):
                zrxn = zma_fs[-1].file.reaction.read(zma_locs)
                zma = zma_fs[-1].file.zmatrix.read(zma_locs)

        # For barrierless reactions with no conformer
        if zrxn is None:
            _, zma_fs = build_fs(save_prefix,
                                 save_prefix,
                                 'ZMATRIX',
                                 rxn_locs=sort_rxn_info,
                                 ts_locs=ts_locs,
                                 thy_locs=mod_ini_thy_info[1:])

            if zma_fs[-1].file.reaction.exists(zma_locs):
                zrxn = zma_fs[-1].file.reaction.read(zma_locs)
                zma = zma_fs[-1].file.zmatrix.read(zma_locs)

    return zrxn, zma
Beispiel #8
0
def _read_from_filesys(rxn_info, ini_thy_info, zma_locs, save_prefix):
    """ Check if reaction exists in the filesystem and has been identified
    """

    zrxn, zma = None, None

    sort_rxn_info = rinfo.sort(rxn_info, scheme='autofile')
    ts_info = rinfo.ts_info(rxn_info)
    mod_ini_thy_info = tinfo.modify_orb_label(ini_thy_info, ts_info)

    rxn_fs = autofile.fs.reaction(save_prefix)
    if rxn_fs[-1].exists(sort_rxn_info):
        _, cnf_save_fs = build_fs(
            save_prefix,
            save_prefix,
            'CONFORMER',
            rxn_locs=sort_rxn_info,
            thy_locs=mod_ini_thy_info[1:],
            # this needs to be fixed for any case with more than one TS
            ts_locs=(0, ))

        _, ini_min_cnf_path = filesys.mincnf.min_energy_conformer_locators(
            cnf_save_fs, mod_ini_thy_info)
        if ini_min_cnf_path:
            zma_fs = autofile.fs.zmatrix(ini_min_cnf_path)
            if zma_fs[-1].file.reaction.exists(zma_locs):
                zrxn = zma_fs[-1].file.reaction.read(zma_locs)
                zma = zma_fs[-1].file.zmatrix.read(zma_locs)

        ts_locs = (0, )
        if zrxn is None:
            _, zma_fs = build_fs('',
                                 save_prefix,
                                 'ZMATRIX',
                                 rxn_locs=sort_rxn_info,
                                 ts_locs=ts_locs,
                                 thy_locs=mod_ini_thy_info[1:])

            if zma_fs[-1].file.reaction.exists(zma_locs):
                zrxn = zma_fs[-1].file.reaction.read(zma_locs)
                zma = zma_fs[-1].file.zmatrix.read(zma_locs)

    return zrxn, zma
Beispiel #9
0
def save_saddle_point(opt_ret, hess_ret, ts_dct, method_dct, savefs_dct,
                      cnf_locs):
    """ Given the saddle point guess structure, obtain a
        proper saddle point
    """

    # Pull info from the dictionaries to save
    zrxn = ts_dct['zrxn']
    runlvl_cnf_save_fs, _ = savefs_dct['runlvl_cnf_tuple']
    ts_info = rinfo.ts_info(ts_dct['rxn_info'])
    mod_thy_info = tinfo.modify_orb_label(tinfo.from_dct(method_dct), ts_info)

    # Save initial saddle point conformer
    filesys.save.conformer(opt_ret,
                           hess_ret,
                           runlvl_cnf_save_fs,
                           mod_thy_info[1:],
                           zrxn=zrxn,
                           rng_locs=(cnf_locs[0], ),
                           tors_locs=(cnf_locs[1], ),
                           zma_locs=None)
Beispiel #10
0
def _build_correction_potential(ts_dct, scan_inf_dct,
                                thy_inf_dct, thy_method_dct, mref_params,
                                es_keyword_dct,
                                runfs_dct, savefs_dct,
                                vrc_dct, vrc_path):
    """  use the MEP potentials to compile the correction potential .so file
    """
    rxn_info = ts_dct['rxn_info']
    ts_info = rinfo.ts_info(rxn_info)

    # Run the constrained and full opt potential scans
    _run_potentials(ts_info, scan_inf_dct,
                    thy_inf_dct, thy_method_dct, mref_params,
                    es_keyword_dct, runfs_dct, savefs_dct)

    # Obtain the energy at infinite separation
    inf_sep_ene = rpath.inf_sep_ene(
        ts_dct, thy_inf_dct, thy_method_dct, mref_params,
        savefs_dct, runfs_dct, es_keyword_dct)

    # Read the values for the correction potential from filesystem
    potentials, pot_labels, zma_for_inp = _read_potentials(
        scan_inf_dct, thy_inf_dct, savefs_dct)

    # Build correction potential .so file used by VaReCoF
    autorun.varecof.compile_potentials(
        vrc_path, scan_inf_dct['full_grid'], potentials,
        scan_inf_dct['rxn_bond_keys'], vrc_dct['fortran_compiler'],
        dist_restrict_idxs=(),
        pot_labels=pot_labels,
        pot_file_names=[vrc_dct['spc_name']],
        spc_name=vrc_dct['spc_name'])

    # Set zma if needed
    if zma_for_inp is None:
        zma_for_inp = ts_dct['zma']

    return inf_sep_ene, len(potentials), zma_for_inp
Beispiel #11
0
def _get_prop_fs(spc_model_dct_i,
                 spc_dct_i,
                 prop,
                 sort_info_lst,
                 run_prefix,
                 save_prefix,
                 saddle=False,
                 name=None):
    """ Get filesystem info for a property in the spc model dct
    """
    if saddle:
        rxn_info = spc_dct_i['rxn_info']
        spc_info = rinfo.ts_info(rxn_info)
    else:
        spc_info = sinfo.from_dct(spc_dct_i)

    level = spc_model_dct_i[prop]['geolvl'][1][1]
    levelp = tinfo.modify_orb_label(level, spc_info)
    mod_info_lst = []
    if sort_info_lst is not None:
        for info in sort_info_lst[:2]:
            if info is not None:
                mod_info_lst.append(tinfo.modify_orb_label(info, spc_info))
            else:
                mod_info_lst.append(info)
        for info in sort_info_lst[2:]:
            mod_info_lst.append(info)

    _root = root_locs(spc_dct_i, saddle=saddle, name=name)
    cnf_run_fs, cnf_save_fs = build_fs(run_prefix,
                                       save_prefix,
                                       'CONFORMER',
                                       thy_locs=levelp[1:],
                                       **_root)

    return cnf_run_fs, cnf_save_fs, levelp, mod_info_lst
Beispiel #12
0
def inf_sep_ene(ts_dct, thy_inf_dct, thy_method_dct, mref_params, savefs_dct,
                runfs_dct, es_keyword_dct):
    """ Determine the total electronic energy of two reacting species that
        at infinite separation.
    """

    ioprinter.info_message('Calculating the Infinite Separation Energy...')
    ioprinter.info_message('')

    # Get info from the reactants
    rct_info = thy_inf_dct['rct_info']
    overwrite = es_keyword_dct['overwrite']

    # Get thy_inf_dct stuff
    thy_info = thy_inf_dct['runlvl']
    var_scn_thy_info = thy_inf_dct['var_scnlvl']
    var_sp1_thy_info = thy_inf_dct['var_splvl1']
    var_sp2_thy_info = thy_inf_dct['var_splvl2']
    hs_var_sp1_thy_info = thy_inf_dct['hs_var_splvl1']
    hs_var_sp2_thy_info = thy_inf_dct['hs_var_splvl2']
    vscn_method_dct = thy_method_dct['var_scnlvl']
    var_sp1_method_dct = thy_method_dct['var_splvl1']
    var_sp2_method_dct = thy_method_dct['var_splvl2']

    # Get the filesys stuff
    rcts_cnf_fs = savefs_dct['rcts_cnf']
    vscnlvl_scn_run_fs = runfs_dct['vscnlvl_scn']
    vscnlvl_scn_save_fs = savefs_dct['vscnlvl_scn']
    run_prefix = runfs_dct['prefix']

    # Get kwargs for the calculation
    rxn_class = ts_dct['class']
    var = (automol.par.is_radrad(rxn_class)
           and automol.par.is_low_spin(rxn_class))
    if var:
        ts_zma, zrxn = ts_dct['zma'], ts_dct['zrxn']
        rxn_info = ts_dct['rxn_info']

        ts_info = rinfo.ts_info(rxn_info)
        high_mult = rinfo.ts_mult(rxn_info, rxn_mul='high')
        hs_ts_info = (ts_info[0], ts_info[1], high_mult)

        # Build grid and names appropriate for reaction type
        names, _, grids, _ = automol.reac.build_scan_info(zrxn,
                                                          ts_zma,
                                                          var=var)
        inf_locs = (names, (grids[1][-1], ))

        cas_kwargs = mref_params['var_scnlvl']

        _inf_sep_ene = _multiref_inf_sep_ene(hs_ts_info,
                                             ts_zma,
                                             rct_info,
                                             rcts_cnf_fs,
                                             run_prefix,
                                             thy_info,
                                             var_scn_thy_info,
                                             var_sp1_thy_info,
                                             var_sp2_thy_info,
                                             hs_var_sp1_thy_info,
                                             hs_var_sp2_thy_info,
                                             var_sp1_method_dct,
                                             var_sp2_method_dct,
                                             vscnlvl_scn_run_fs,
                                             vscnlvl_scn_save_fs,
                                             inf_locs,
                                             overwrite=overwrite,
                                             **cas_kwargs)
    else:
        vscn_thy_info = thy_inf_dct['var_scnlvl']
        _inf_sep_ene = _singleref_inf_sep_ene(rct_info, thy_info,
                                              vscn_thy_info, rcts_cnf_fs,
                                              run_prefix, vscn_method_dct,
                                              overwrite)

    if _inf_sep_ene is not None:
        ioprinter.energy(_inf_sep_ene)
    else:
        ioprinter.warning_message('Infinite separation ene not computed')

    return _inf_sep_ene
Beispiel #13
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)
Beispiel #14
0
def conformer_tsk(job, spc_dct, spc_name, thy_dct, es_keyword_dct, run_prefix,
                  save_prefix):
    """ Launch tasks associated with conformers.
        Scan: Generate a set of conformer geometries and energies via
              random sampling over torsional coordinates
              following by optimization
        SP: Calculate ene, grad, ..
    """

    saddle = bool('ts_' in spc_name)

    spc_dct_i = spc_dct[spc_name]

    # Set the spc_info
    if not saddle:
        spc_info = sinfo.from_dct(spc_dct_i)
    else:
        spc_info = rinfo.ts_info(spc_dct_i['rxn_info'])
    zrxn = spc_dct_i.get('zrxn', None)

    overwrite = es_keyword_dct['overwrite']
    retryfail = es_keyword_dct['retryfail']

    # Modify the theory
    method_dct = thy_dct.get(es_keyword_dct['runlvl'])
    ini_method_dct = thy_dct.get(es_keyword_dct['inplvl'])
    thy_info = tinfo.from_dct(method_dct)
    ini_thy_info = tinfo.from_dct(ini_method_dct)
    mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info)
    mod_ini_thy_info = tinfo.modify_orb_label(ini_thy_info, spc_info)

    # New filesystem objects
    _root = root_locs(spc_dct_i, saddle=saddle, name=spc_name)
    ini_cnf_run_fs, ini_cnf_save_fs = build_fs(run_prefix,
                                               save_prefix,
                                               'CONFORMER',
                                               thy_locs=mod_ini_thy_info[1:],
                                               **_root)
    cnf_run_fs, cnf_save_fs = build_fs(run_prefix,
                                       save_prefix,
                                       'CONFORMER',
                                       thy_locs=mod_thy_info[1:],
                                       **_root)

    if job == 'samp':

        # Build the ini zma filesys
        ini_loc_info = filesys.mincnf.min_energy_conformer_locators(
            ini_cnf_save_fs, mod_ini_thy_info)
        ini_locs, ini_min_cnf_path = ini_loc_info
        ini_min_rid, ini_min_cid = ini_locs

        ini_zma_save_fs = autofile.fs.zmatrix(ini_min_cnf_path)

        # Set up the run scripts
        script_str, kwargs = qchem_params(method_dct,
                                          elstruct.Job.OPTIMIZATION)

        # Set variables if it is a saddle
        two_stage = saddle
        mc_nsamp = spc_dct_i['mc_nsamp']
        resave = es_keyword_dct['resave']

        # Read the geometry and zma from the ini file system
        geo = ini_cnf_save_fs[-1].file.geometry.read(ini_locs)
        zma = ini_zma_save_fs[-1].file.zmatrix.read([0])

        # Read the torsions from the ini file sys
        if ini_zma_save_fs[-1].file.torsions.exists([0]):
            tors_dct = ini_zma_save_fs[-1].file.torsions.read([0])
            rotors = automol.rotor.from_data(zma, tors_dct)
            tors_names = automol.rotor.names(rotors, flat=True)
        else:
            tors_names = ()

        geo_path = ini_cnf_save_fs[-1].path(ini_locs)
        ioprinter.initial_geom_path('Sampling started', geo_path)

        # Check runsystem for equal ring CONF make conf_fs
        # Else make new ring conf directory
        rid = conformer.rng_loc_for_geo(geo, cnf_run_fs, cnf_save_fs)

        if rid is None:
            conformer.single_conformer(zma,
                                       spc_info,
                                       mod_thy_info,
                                       cnf_run_fs,
                                       cnf_save_fs,
                                       script_str,
                                       overwrite,
                                       retryfail=retryfail,
                                       zrxn=zrxn,
                                       **kwargs)

            rid = conformer.rng_loc_for_geo(geo, cnf_run_fs, cnf_save_fs)

        # Run the sampling
        conformer.conformer_sampling(zma,
                                     spc_info,
                                     mod_thy_info,
                                     cnf_run_fs,
                                     cnf_save_fs,
                                     rid,
                                     script_str,
                                     overwrite,
                                     nsamp_par=mc_nsamp,
                                     tors_names=tors_names,
                                     zrxn=zrxn,
                                     two_stage=two_stage,
                                     retryfail=retryfail,
                                     resave=resave,
                                     **kwargs)

    elif job == 'pucker':

        # Build the ini zma filesys
        ini_loc_info = filesys.mincnf.min_energy_conformer_locators(
            ini_cnf_save_fs, mod_ini_thy_info)
        ini_min_locs, ini_min_cnf_path = ini_loc_info
        ini_min_rid, ini_min_cid = ini_min_locs
        ini_zma_save_fs = autofile.fs.zmatrix(ini_min_cnf_path)

        # Set up the run scripts
        script_str, kwargs = qchem_params(method_dct,
                                          elstruct.Job.OPTIMIZATION)

        # Set variables if it is a saddle
        two_stage = saddle
        mc_nsamp = spc_dct_i['mc_nsamp']

        # Read the geometry and zma from the ini file system
        geo = ini_cnf_save_fs[-1].file.geometry.read(ini_min_locs)
        zma = ini_zma_save_fs[-1].file.zmatrix.read([0])

        # Read the torsions from the ini file sys
        if ini_zma_save_fs[-1].file.ring_torsions.exists([0]):
            ring_tors_dct = ini_zma_save_fs[-1].file.ring_torsions.read([0])
        else:
            ring_tors_dct = {}

        geo_path = ini_cnf_save_fs[-1].path(ini_min_locs)
        ioprinter.initial_geom_path('Sampling started', geo_path)

        # Run the sampling
        conformer.ring_conformer_sampling(zma,
                                          spc_info,
                                          mod_thy_info,
                                          cnf_run_fs,
                                          cnf_save_fs,
                                          script_str,
                                          overwrite,
                                          nsamp_par=mc_nsamp,
                                          ring_tors_dct=ring_tors_dct,
                                          zrxn=zrxn,
                                          two_stage=two_stage,
                                          retryfail=retryfail,
                                          **kwargs)

    elif job == 'opt':

        cnf_range = es_keyword_dct['cnf_range']
        ioprinter.debug_message('range', cnf_range)

        # Set up the run scripts
        script_str, kwargs = qchem_params(method_dct,
                                          elstruct.Job.OPTIMIZATION)

        ini_loc_info = filesys.mincnf.min_energy_conformer_locators(
            ini_cnf_save_fs, mod_ini_thy_info)
        ini_min_locs, ini_min_cnf_path = ini_loc_info
        ini_min_rid, ini_min_cid = ini_min_locs

        rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators(
            cnf_save_fs, mod_thy_info, cnf_range='all')

        ini_rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators(
            ini_cnf_save_fs, mod_ini_thy_info, cnf_range=cnf_range)

        # Truncate the list of the ini confs
        uni_rng_locs_lst, uni_cnf_locs_lst = conformer.unique_fs_ring_confs(
            cnf_save_fs, rng_cnf_locs_lst, ini_cnf_save_fs,
            ini_rng_cnf_locs_lst)
        ioprinter.debug_message('uni lst that has no similar ring',
                                uni_rng_locs_lst)
        ioprinter.debug_message('uni lst that has similar ring',
                                uni_cnf_locs_lst)

        for locs in uni_rng_locs_lst:
            rid, cid = locs
            # Obtain the zma from ini loc
            ini_cnf_save_path = ini_cnf_save_fs[-1].path(locs)
            ini_zma_save_fs = autofile.fs.zmatrix(ini_cnf_save_path)
            zma = ini_zma_save_fs[-1].file.zmatrix.read((0, ))

            # Make the ring filesystem
            conformer.single_conformer(zma,
                                       spc_info,
                                       mod_thy_info,
                                       cnf_run_fs,
                                       cnf_save_fs,
                                       script_str,
                                       overwrite,
                                       retryfail=retryfail,
                                       zrxn=zrxn,
                                       use_locs=locs,
                                       **kwargs)

        for locs in uni_cnf_locs_lst:
            ini_locs, rid = locs
            ini_rid, ini_cid = ini_locs
            # Obtain the zma from ini loc
            ini_cnf_save_path = ini_cnf_save_fs[-1].path(ini_locs)
            ini_zma_save_fs = autofile.fs.zmatrix(ini_cnf_save_path)
            zma = ini_zma_save_fs[-1].file.zmatrix.read((0, ))
            # obtain conformer filesystem associated with the ring at the runlevel
            cid = autofile.schema.generate_new_conformer_id()
            conformer.single_conformer(zma,
                                       spc_info,
                                       mod_thy_info,
                                       cnf_run_fs,
                                       cnf_save_fs,
                                       script_str,
                                       overwrite,
                                       retryfail=retryfail,
                                       zrxn=zrxn,
                                       use_locs=(rid, cid),
                                       **kwargs)

        rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators(
            cnf_save_fs, mod_thy_info, cnf_range=cnf_range)
        for locs in rng_cnf_locs_lst:
            geo = cnf_save_fs[-1].file.geometry.read(locs)
            ioprinter.geometry(geo)

    elif job in ('energy', 'grad', 'hess', 'vpt2', 'prop'):

        cnf_range = es_keyword_dct['cnf_range']

        ini_rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators(
            ini_cnf_save_fs, mod_ini_thy_info, cnf_range=cnf_range)

        # Check if locs exist, kill if it doesn't
        if not ini_rng_cnf_locs_lst:
            ioprinter.error_message('No min-energy conformer found for level:')
            sys.exit()

        # Set up the run scripts
        script_str, kwargs = qchem_params(method_dct)

        # Run the job over all the conformers requested by the user
        for ini_locs in ini_rng_cnf_locs_lst:
            ini_rid, ini_cid = ini_locs
            ioprinter.running('task for conformer: ', ini_locs, newline=2)
            ini_cnf_run_fs[-1].create(ini_locs)
            geo_run_path = ini_cnf_run_fs[-1].path(ini_locs)
            geo_save_path = ini_cnf_save_fs[-1].path(ini_locs)
            ini_zma_save_fs = autofile.fs.zmatrix(geo_save_path)
            ioprinter.debug_message('reading geometry from ', geo_save_path)
            geo = ini_cnf_save_fs[-1].file.geometry.read(ini_locs)
            zma = ini_zma_save_fs[-1].file.zmatrix.read((0, ))
            ES_TSKS[job](zma,
                         geo,
                         spc_info,
                         mod_thy_info,
                         ini_cnf_save_fs,
                         geo_run_path,
                         geo_save_path,
                         ini_locs,
                         script_str,
                         overwrite,
                         retryfail=retryfail,
                         **kwargs)
Beispiel #15
0
def optimize_saddle_point(guess_zmas, ts_dct, method_dct, mref_kwargs,
                          runfs_dct, es_keyword_dct, cnf_locs):
    """ Optimize the transition state structure obtained from the grid search
    """

    # Get info (move later)
    ts_info = rinfo.ts_info(ts_dct['rxn_info'])
    mod_thy_info = tinfo.modify_orb_label(tinfo.from_dct(method_dct), ts_info)

    overwrite = es_keyword_dct['overwrite']
    ts_info = rinfo.ts_info(ts_dct['rxn_info'])

    runlvl_cnf_run_fs = runfs_dct['runlvl_cnf']
    runlvl_cnf_run_fs[-1].create(cnf_locs)
    run_fs = autofile.fs.run(runlvl_cnf_run_fs[-1].path(cnf_locs))

    ioprinter.info_message(
        f'There are {len(guess_zmas)} guess Z-Matrices'
        'to attempt to find saddle point.',
        newline=1)

    # Loop over all the guess zmas to find a TS
    opt_ret, hess_ret = None, None
    for idx, zma in enumerate(guess_zmas):
        ioprinter.info_message(f'\nOptimizing guess Z-Matrix {idx+1}...')

        # Run the transition state optimization
        script_str, kwargs = qchem_params(method_dct,
                                          job=elstruct.Job.OPTIMIZATION)
        kwargs.update(mref_kwargs)

        opt_success, opt_ret = es_runner.execute_job(
            job='optimization',
            script_str=script_str,
            run_fs=run_fs,
            geo=zma,
            spc_info=ts_info,
            thy_info=mod_thy_info,
            saddle=True,
            overwrite=overwrite,
            **kwargs,
        )

        if opt_success:
            break

    if opt_success:
        script_str, kwargs = qchem_params(method_dct)

        # Obtain geometry from optimization
        opt_inf_obj, _, opt_out_str = opt_ret
        opt_prog = opt_inf_obj.prog
        geo = elstruct.reader.opt_geometry(opt_prog, opt_out_str)

        # Run a Hessian
        _, hess_ret = es_runner.execute_job(
            job='hessian',
            script_str=script_str,
            run_fs=run_fs,
            geo=geo,
            spc_info=ts_info,
            thy_info=mod_thy_info,
            overwrite=overwrite,
            **kwargs,
        )

    return opt_ret, hess_ret
Beispiel #16
0
def scan_for_guess(ts_dct, method_dct, runfs_dct, savefs_dct, es_keyword_dct):
    """ saddle point scan code
    """

    print(' - No Z-Matrix is found in save filesys.')
    print('\nRunning scan to generate guess Z-Matrix for opt...')

    # Get es keyword info
    overwrite = es_keyword_dct['overwrite']
    retryfail = es_keyword_dct['retryfail']

    # Get info from the dct
    ts_zma = ts_dct['zma']
    zrxn = ts_dct['zrxn']  # convert to zrxn
    ts_info = rinfo.ts_info(ts_dct['rxn_info'])

    scn_save_fs = savefs_dct['runlvl_scn_fs']

    # Build grid and names appropriate for reaction type
    scan_inf = automol.reac.build_scan_info(zrxn, ts_zma)
    coord_names, constraint_dct, coord_grids, update_guess = scan_inf

    # Get filesystem information
    if constraint_dct is None:
        scn_run_fs = runfs_dct['runlvl_scn_fs']
        scn_save_fs = savefs_dct['runlvl_scn_fs']
    else:
        scn_run_fs = runfs_dct['runlvl_cscn_fs']
        scn_save_fs = savefs_dct['runlvl_cscn_fs']

    # Set up script string and kwargs
    mod_thy_info = tinfo.modify_orb_label(tinfo.from_dct(method_dct), ts_info)
    script_str, kwargs = qchem_params(method_dct,
                                      job=elstruct.Job.OPTIMIZATION)

    es_runner.scan.execute_scan(
        zma=ts_zma,
        spc_info=ts_info,
        mod_thy_info=mod_thy_info,
        coord_names=coord_names,
        coord_grids=coord_grids,
        scn_run_fs=scn_run_fs,
        scn_save_fs=scn_save_fs,
        scn_typ='relaxed',
        script_str=script_str,
        overwrite=overwrite,
        zrxn=zrxn,
        update_guess=update_guess,
        reverse_sweep=False,
        saddle=False,
        constraint_dct=constraint_dct,
        retryfail=retryfail,
        **kwargs,
    )

    guess_zmas = rxngrid.grid_maximum_zmatrices(zrxn.class_, ts_zma,
                                                coord_grids, coord_names,
                                                scn_save_fs, mod_thy_info,
                                                constraint_dct)

    return guess_zmas
def parse_user_reaction(insert_dct):
    smis = insert_dct['smiles']
    ichs = insert_dct['inchi']
    mults = insert_dct['mult']
    chgs = insert_dct['charge']
    rxn_class = insert_dct['rxn_class']
    # zrxn_file = insert_dct['zrxn_file']
    if ichs is None:
        ichs = [[], []]
        for smi in smis[0]:
            ichs[0].append(automol.smiles.inchi(smi))
        for smi in smis[1]:
            ichs[1].append(automol.smiles.inchi(smi))
    for idx, ich in enumerate(ichs[0]):
        if not automol.inchi.is_complete(ich):
            ich = automol.inchi.add_stereo(ich)
            ichs[0][idx] = ich
    for idx, ich in enumerate(ichs[1]):
        if not automol.inchi.is_complete(ich):
            ich = automol.inchi.add_stereo(ich)
            ichs[1][idx] = ich
    if mults is None:
        print('Error: user did not specify mults in input')
        sys.exit()
    if chgs is None:
        print('Error: user did not specify charges in input')
        sys.exit()
    flat_ichs = sum(ichs, [])
    if len(flat_ichs) != len(mults):
        print('Error: number of species does not match number of mults')
        sys.exit()
    if len(flat_ichs) != len(chgs):
        print('Error: number of species does not match number of charges')
        sys.exit()
    idx = 0
    rxn_muls = [[], []]
    rxn_chgs = [[], []]
    for ich in ichs[0]:
        mults_allowed = automol.graph.possible_spin_multiplicities(
            automol.inchi.graph(ich, stereo=False))
        if mults[idx] not in mults_allowed:
            print('user specified mult of {}'.format(mults[idx]) +
                  'is not an allowed multiplicty for inchi {}'.format(ich))
            sys.exit()
        rxn_muls[0].append(mults[idx])
        rxn_chgs[0].append(chgs[idx])
        idx += 1
    for ich in ichs[1]:
        mults_allowed = automol.graph.possible_spin_multiplicities(
            automol.inchi.graph(ich, stereo=False))
        if mults[idx] not in mults_allowed:
            print('user specified mult of {}'.format(mults[idx]) +
                  'is not an allowed multiplicty for inchi {}'.format(ich))
            sys.exit()
        rxn_muls[1].append(mults[idx])
        rxn_chgs[1].append(chgs[idx])
        idx += 1
    ts_mult = insert_dct['ts_mult']
    if ts_mult is None:
        print('Error: user did not specify ts_mul')
        sys.exit()
    rxn_info = rinfo.sort((ichs, rxn_chgs, rxn_muls, ts_mult))
    ts_info = rinfo.ts_info(rxn_info)
    # if zrxn_file is not None:
    #     zrxn_str = autofile.io_.read_file(zrxn_file)
    #     zrxns = [automol.reac.from_string(zrxn_str)]
    # else:
    #     zrxns, _ = _id_reaction(rxn_info)
    if rxn_class is None:
        print('Error: user did not specify rxn_class')
        sys.exit()
    return rxn_info, ts_info, rxn_class
Beispiel #18
0
def rpath_tsk(job, spc_dct, spc_name,
              thy_inf_dct, thy_method_dct, mref_dct, es_keyword_dct,
              runfs_dct, savefs_dct):
    """ run a scan over the specified torsional coordinate

        :param job:
        :type job:
        :param spc_dct:
        :type spc_dct:
        :param spc_name:
        :type spc_name:
        :param thy_dct:
        :type thy_dct:
        :param es_keyword_dct: keyword-value pairs for electronic structure tsk
        :type es_keyword_dct: dict[str:str]
        :param run_prefix: root-path to the run-filesystem
        :type run_prefix: str
        :param save_prefix: root-path to the save-filesystem
        :type save_prefix: str
    """

    # Get dct for specific species task is run for
    ts_dct = spc_dct[spc_name]
    ts_info = rinfo.ts_info(ts_dct['rxn_info'])

    # # Build various thy and filesystem objects
    # thy_inf_dct, thy_method_dct, mref_dct, runfs_dct, savefs_dct = thy_dcts(
    #     spc_name, spc_dct[spc_name], thy_dct, es_keyword_dct,
    #     run_prefix, save_prefix)

    mod_thy_info = thy_inf_dct['mod_runlvl']
    mod_ini_thy_info = thy_inf_dct['mod_inplvl']
    method_dct = thy_method_dct['runlvl']
    ini_method_dct = thy_method_dct['inplvl']
    mref_params = mref_dct['runlvl']

    # Build filesys objects
    scn_alg, scn_fs, cnf_fs, cnf_locs = rpath_fs(
        ts_dct, spc_name,
        mod_ini_thy_info,
        es_keyword_dct,
        runfs_dct['prefix'], savefs_dct['prefix'])
    print('alg set test', scn_alg)

    # Run job
    if job == 'scan':
        if 'irc' in scn_alg:
            zmas = irc.launch_point_zmatrices(
                ts_dct, mod_thy_info, scn_alg,
                scn_fs, cnf_fs, cnf_locs)
            for zma in zmas:
                success = irc.execute_irc(
                    zma, ts_info,
                    mod_ini_thy_info, ini_method_dct,
                    scn_fs[0], scn_fs[1],
                    es_keyword_dct)
                if success:
                    break
        else:
            zma, zrxn, rclass, = ts_dct['zma'], ts_dct['zrxn'], ts_dct['class']
            _ = rpath.internal_coordinates_scan(
                zma, zrxn,
                ts_info, rclass,
                method_dct, mref_params,
                scn_fs[0], scn_fs[1],
                es_keyword_dct)
    elif job in ('energy', 'grad', 'hess'):
        # Set run-time options
        overwrite = es_keyword_dct['overwrite']
        script_str, kwargs = qchem_params(method_dct)

        # Run along the scan and calculate desired quantities
        ini_scn_run_fs, ini_scn_save_fs = scn_fs
        for locs in ini_scn_save_fs[-1].existing():
            geo = ini_scn_save_fs[-1].file.geometry.read(locs)
            ini_scn_run_fs[-1].create(locs)
            ES_TSKS[job](
                None, geo, ts_info, mod_thy_info,
                ini_scn_run_fs, ini_scn_save_fs, locs,
                script_str, overwrite, **kwargs)
            ioprinter.obj('vspace')
    elif job == 'infene':
        rpath.inf_sep_ene(
            ts_dct, thy_inf_dct, mref_dct,
            savefs_dct, runfs_dct, es_keyword_dct)
Beispiel #19
0
def hr_tsk(job, spc_dct, spc_name, thy_dct, es_keyword_dct, run_prefix,
           save_prefix):
    """ Prepares and executes all electronic structure tasks that
        generate information for points along hindered-rotor coordinate
        scans which are launched from some conformer in the save filesystem.

        For species and transition state conformers.

        This includes scanning procedures to generate geometries
        (relaxed) or energies (rigid) points along
        conformer structures, as well as __ calculations using some
        saved conformer as input.

        :param job:
        :type job:
        :param spc_dct:
        :type spc_dct:
        :param spc_name:
        :type spc_name:
        :param thy_dct:
        :type thy_dct:
        :param es_keyword_dct: keyword-val pairs for electronic structure task
        :type es_keyword_dct: dict[str:str]
        :param run_prefix: root-path to the run-filesystem
        :type run_prefix: str
        :param save_prefix: root-path to the save-filesystem
        :type save_prefix: str
    """

    spc_dct_i = spc_dct[spc_name]
    saddle = bool('ts_' in spc_name)
    # Set the spc_info
    if not saddle:
        spc_info = sinfo.from_dct(spc_dct_i)
    else:
        spc_info = rinfo.ts_info(spc_dct_i['rxn_info'])

    # Get options from the dct or es options lst
    overwrite = es_keyword_dct['overwrite']
    retryfail = es_keyword_dct['retryfail']
    tors_model = es_keyword_dct['tors_model']
    # nprocs = es_keyword_dct['nprocs']
    nprocs = 1
    # Modify the theory
    method_dct = thy_dct.get(es_keyword_dct['runlvl'])
    ini_method_dct = thy_dct.get(es_keyword_dct['inplvl'])
    thy_info = tinfo.from_dct(method_dct)
    ini_thy_info = tinfo.from_dct(ini_method_dct)
    mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info)
    mod_ini_thy_info = tinfo.modify_orb_label(ini_thy_info, spc_info)

    # Set the filesystem objects
    _root = root_locs(spc_dct_i, saddle=saddle, name=spc_name)
    _, ini_cnf_save_fs = build_fs(run_prefix,
                                  save_prefix,
                                  'CONFORMER',
                                  thy_locs=mod_ini_thy_info[1:],
                                  **_root)
    cnf_run_fs, cnf_save_fs = build_fs(run_prefix,
                                       save_prefix,
                                       'CONFORMER',
                                       thy_locs=mod_thy_info[1:],
                                       **_root)

    cnf_range = es_keyword_dct['cnf_range']
    hbond_cutoffs = spc_dct_i['hbond_cutoffs']

    user_conf_ids = spc_dct_i.get('conf_id')
    if user_conf_ids is None:
        cnf_sort_info_lst = _sort_info_lst(es_keyword_dct['sort'], thy_dct,
                                           spc_info)
        ini_min_locs_lst, ini_path_lst = filesys.mincnf.conformer_locators(
            ini_cnf_save_fs,
            mod_ini_thy_info,
            cnf_range=cnf_range,
            sort_info_lst=cnf_sort_info_lst,
            hbond_cutoffs=hbond_cutoffs,
            print_enes=True,
            nprocs=nprocs)
    else:
        ini_min_locs_lst = (user_conf_ids, )
        ini_path_lst = (ini_cnf_save_fs[-1].path(user_conf_ids), )

    all_run_cnf_locs_lst, _ = filesys.mincnf.conformer_locators(
        cnf_save_fs, mod_thy_info, cnf_range='all', nprocs=nprocs)
    ini_to_run_locs_dct = filesys.mincnf.fs_confs_dict(cnf_save_fs,
                                                       all_run_cnf_locs_lst,
                                                       ini_cnf_save_fs,
                                                       ini_min_locs_lst)

    for ini_min_locs, ini_cnf_save_path in zip(ini_min_locs_lst, ini_path_lst):

        # Read zma, geo, and torsions
        ini_zma_save_fs = autofile.fs.zmatrix(ini_cnf_save_path)
        geo = ini_cnf_save_fs[-1].file.geometry.read(ini_min_locs)
        zma = ini_zma_save_fs[-1].file.zmatrix.read((0, ))
        if ini_zma_save_fs[-1].file.torsions.exists([0]):
            tors_dct = ini_zma_save_fs[-1].file.torsions.read([0])
            torsions = automol.rotor.from_data(
                zma,
                tors_dct,
            )
        else:
            torsions = ()

        zrxn = spc_dct_i.get('zrxn', None)
        # Run the task if any torsions exist
        if any(torsions):
            # Find equivalent conformer in the run filesys, if it doesn't exist
            # run a single conformer to generate it
            min_locs = ini_to_run_locs_dct[tuple(ini_min_locs)]
            if min_locs is None:
                script_str, kwargs = qchem_params(method_dct,
                                                  elstruct.Job.OPTIMIZATION)
                rid = conformer.rng_loc_for_geo(geo, cnf_save_fs)
                if rid is None:
                    new_rid = autofile.schema.generate_new_ring_id()
                    new_cid = autofile.schema.generate_new_conformer_id()
                    conformer.single_conformer(zma,
                                               spc_info,
                                               mod_thy_info,
                                               cnf_run_fs,
                                               cnf_save_fs,
                                               script_str,
                                               overwrite,
                                               retryfail=retryfail,
                                               zrxn=zrxn,
                                               use_locs=(new_rid, new_cid),
                                               **kwargs)
                    min_locs = (new_rid, new_cid)
                else:
                    new_cid = autofile.schema.generate_new_conformer_id()
                    conformer.single_conformer(zma,
                                               spc_info,
                                               mod_thy_info,
                                               cnf_run_fs,
                                               cnf_save_fs,
                                               script_str,
                                               overwrite,
                                               retryfail=retryfail,
                                               zrxn=zrxn,
                                               use_locs=(rid, new_cid),
                                               **kwargs)
                    min_locs = (rid, new_cid)
                    save_locs = cnf_save_fs[-1].existing()
                    if min_locs not in save_locs:
                        locinf = filesys.mincnf.this_conformer_was_run_in_run(
                            zma, cnf_run_fs)
                        _, sym_locs_lst = locinf
                        for sym_locs in sym_locs_lst:
                            if sym_locs in save_locs:
                                min_locs = sym_locs
            cnf_save_path = cnf_save_fs[-1].path(min_locs)
            ioprinter.info_message(
                f'Same conformer saved at {ini_cnf_save_path} '
                f'and {cnf_save_path}')

            # Create run fs if that directory has been deleted to run the jobs
            # ini_cnf_run_fs[-1].create(ini_min_locs)
            # ini_cnf_run_path = ini_cnf_run_fs[-1].path(ini_min_locs)
            cnf_run_fs[-1].create(min_locs)
            cnf_run_path = cnf_run_fs[-1].path(min_locs)

            # Get the runlvl zma and torsion info
            zma_save_fs = autofile.fs.zmatrix(cnf_save_path)
            geo = cnf_save_fs[-1].file.geometry.read(min_locs)
            zma = zma_save_fs[-1].file.zmatrix.read((0, ))
            if zma_save_fs[-1].file.torsions.exists([0]):
                tors_dct = zma_save_fs[-1].file.torsions.read([0])
                torsions = automol.rotor.from_data(
                    zma,
                    tors_dct,
                )
            else:
                torsions = ()

            if 'fa' in tors_model:
                scn = 'CSCAN'
            elif 'f' in tors_model:
                if len(torsions) > 1:
                    scn = 'CSCAN'
                else:
                    scn = 'SCAN'
            else:
                scn = 'SCAN'
            # ini_scn_run_fs, ini_scn_save_fs = build_fs(
            #     ini_cnf_run_path, ini_cnf_save_path, scn,
            #     zma_locs=(0,))
            scn_run_fs, scn_save_fs = build_fs(cnf_run_path,
                                               cnf_save_path,
                                               scn,
                                               zma_locs=(0, ))

            if job == 'scan':

                increment = spc_dct_i.get('hind_inc', 30.0 * phycon.DEG2RAD)
                hr.hindered_rotor_scans(zma,
                                        spc_info,
                                        mod_thy_info,
                                        scn_run_fs,
                                        scn_save_fs,
                                        torsions,
                                        tors_model,
                                        method_dct,
                                        overwrite,
                                        zrxn=zrxn,
                                        saddle=saddle,
                                        increment=increment,
                                        retryfail=retryfail)

            elif job == 'reopt':

                script_str, kwargs = qchem_params(method_dct,
                                                  elstruct.Job.OPTIMIZATION)

                # pull stuff from dcts
                ethresh = es_keyword_dct['hrthresh']
                increment = spc_dct_i.get('hind_inc', 30.0 * phycon.DEG2RAD)

                zrxn = spc_dct_i.get('zrxn', None)

                run_tors_names = automol.rotor.names(torsions)
                run_tors_grids = automol.rotor.grids(torsions,
                                                     increment=increment)

                # Set constraints
                const_names = automol.zmat.set_constraint_names(
                    zma, run_tors_names, tors_model)

                # Read and print the potential
                sp_fs = autofile.fs.single_point(cnf_save_path)
                ref_ene = sp_fs[-1].file.energy.read(mod_thy_info[1:4])
                tors_pots, tors_zmas, tors_paths = {}, {}, {}
                for tors_names, tors_grids in zip(run_tors_names,
                                                  run_tors_grids):
                    constraint_dct = automol.zmat.constraint_dct(
                        zma, const_names, tors_names)
                    pot, _, _, _, zmas, paths = filesys.read.potential(
                        tors_names,
                        tors_grids,
                        cnf_save_path,
                        mod_thy_info,
                        ref_ene,
                        constraint_dct,
                        read_zma=True)
                    tors_pots[tors_names] = pot
                    tors_zmas[tors_names] = zmas
                    tors_paths[tors_names] = paths

                # Check for new minimum conformer
                new_min_zma = hr.check_hr_pot(tors_pots,
                                              tors_zmas,
                                              tors_paths,
                                              emax=ethresh)

                if new_min_zma is not None:
                    ioprinter.info_message(
                        'Finding new low energy conformer...', newline=1)
                    new_min_geo = automol.zmat.geometry(new_min_zma)
                    rid = conformer.rng_loc_for_geo(new_min_geo, cnf_save_fs)
                    if rid is None:
                        new_locs = None
                    else:
                        cid = autofile.schema.generate_new_conformer_id()
                        new_locs = (rid, cid)
                    conformer.single_conformer(new_min_zma,
                                               spc_info,
                                               mod_thy_info,
                                               cnf_run_fs,
                                               cnf_save_fs,
                                               script_str,
                                               overwrite,
                                               retryfail=retryfail,
                                               zrxn=zrxn,
                                               use_locs=new_locs,
                                               **kwargs)

            elif job in ('energy', 'grad', 'hess', 'vpt2'):

                # Script (add energy script call)
                script_str, kwargs = qchem_params(method_dct)

                run_tors_names = automol.rotor.names(torsions, flat=True)
                for tors_names in run_tors_names:

                    # Set the constraint dct and filesys for the scan
                    const_names = automol.zmat.set_constraint_names(
                        zma, run_tors_names, tors_model)
                    constraint_dct = automol.zmat.constraint_dct(
                        zma, const_names, tors_names)

                    # get the scn_locs, maybe get a function?
                    _, scn_locs = scan.scan_locs(scn_save_fs,
                                                 tors_names,
                                                 constraint_dct=constraint_dct)
                    for locs in scn_locs:
                        geo = scn_save_fs[-1].file.geometry.read(locs)
                        zma = scn_save_fs[-1].file.zmatrix.read(locs)
                        scn_run_fs[-1].create(locs)
                        ES_TSKS[job](zma,
                                     geo,
                                     spc_info,
                                     mod_thy_info,
                                     scn_run_fs,
                                     scn_save_fs,
                                     locs,
                                     run_prefix,
                                     script_str,
                                     overwrite,
                                     zrxn=zrxn,
                                     retryfail=retryfail,
                                     **kwargs)
                        ioprinter.obj('vspace')
        else:
            ioprinter.info_message('No torsional modes in the species')
Beispiel #20
0
def hr_tsk(job, spc_dct, spc_name, thy_dct, es_keyword_dct, run_prefix,
           save_prefix):
    """ run a scan over the specified torsional coordinates
    """

    spc_dct_i = spc_dct[spc_name]
    saddle = bool('ts_' in spc_name)
    # Set the spc_info
    if not saddle:
        spc_info = sinfo.from_dct(spc_dct_i)
    else:
        spc_info = rinfo.ts_info(spc_dct_i['rxn_info'])

    # Modify the theory
    method_dct = thy_dct.get(es_keyword_dct['runlvl'])
    ini_method_dct = thy_dct.get(es_keyword_dct['inplvl'])
    thy_info = tinfo.from_dct(method_dct)
    ini_thy_info = tinfo.from_dct(ini_method_dct)
    mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info)
    mod_ini_thy_info = tinfo.modify_orb_label(ini_thy_info, spc_info)

    # Set the filesystem objects
    _root = root_locs(spc_dct_i, saddle=saddle, name=spc_name)
    ini_cnf_run_fs, ini_cnf_save_fs = build_fs(run_prefix,
                                               save_prefix,
                                               'CONFORMER',
                                               thy_locs=mod_ini_thy_info[1:],
                                               **_root)
    cnf_run_fs, cnf_save_fs = build_fs(run_prefix,
                                       save_prefix,
                                       'CONFORMER',
                                       thy_locs=mod_thy_info[1:],
                                       **_root)
    instab_save_fs = ()

    ini_loc_info = filesys.mincnf.min_energy_conformer_locators(
        ini_cnf_save_fs, mod_ini_thy_info)
    ini_min_locs, ini_cnf_save_path = ini_loc_info
    # ini_min_rng_locs, ini_min_cnf_locs = ini_min_cnf_locs
    # ini_min_rng_path, ini_min_cnf_path = ini_min_cnf_path

    # Create run fs if that directory has been deleted to run the jobs
    ini_cnf_run_fs[-1].create(ini_min_locs)
    ini_cnf_run_path = ini_cnf_run_fs[-1].path(ini_min_locs)

    # Get options from the dct or es options lst
    overwrite = es_keyword_dct['overwrite']
    retryfail = es_keyword_dct['retryfail']
    tors_model = es_keyword_dct['tors_model']

    # Read zma, geo, and torsions
    ini_zma_save_fs = autofile.fs.zmatrix(ini_cnf_save_path)
    geo = ini_cnf_save_fs[-1].file.geometry.read(ini_min_locs)
    zma = ini_zma_save_fs[-1].file.zmatrix.read((0, ))
    if ini_zma_save_fs[-1].file.torsions.exists([0]):
        tors_dct = ini_zma_save_fs[-1].file.torsions.read([0])
        torsions = automol.rotor.from_data(
            zma,
            tors_dct,
        )
    else:
        torsions = ()

    # Run the task if any torsions exist
    if any(torsions):

        scn = 'SCAN' if 'fa' not in tors_model else 'CSCAN'
        ini_scn_run_fs, ini_scn_save_fs = build_fs(ini_cnf_run_path,
                                                   ini_cnf_save_path,
                                                   scn,
                                                   zma_locs=(0, ))

        if job == 'scan':

            increment = spc_dct_i.get('hind_inc', 30.0 * phycon.DEG2RAD)
            hr.hindered_rotor_scans(zma,
                                    spc_info,
                                    mod_thy_info,
                                    instab_save_fs,
                                    ini_scn_run_fs,
                                    ini_scn_save_fs,
                                    torsions,
                                    tors_model,
                                    method_dct,
                                    overwrite,
                                    saddle=saddle,
                                    increment=increment,
                                    retryfail=retryfail)

        # elif job == 'reopt':

        #     # pull stuff from dcts
        #     two_stage = saddle
        #     rxn_class = spc_dct_i['class'] if saddle else ''
        #     mc_nsamp = spc_dct_i['mc_nsamp']
        #     ethresh = es_keyword_dct['hrthresh']

        #     # Read and print the potential
        #     sp_fs = autofile.fs.single_point(ini_cnf_save_path)
        #     ref_ene = sp_fs[-1].file.energy.read(mod_ini_thy_info[1:4])
        #     # ref_ene = ini_cnf_save_fs[-1].file.energy.read(ini_min_cnf_locs)
        #     tors_pots, tors_zmas, tors_paths = {}, {}, {}
        #     for tors_names, tors_grids in zip(run_tors_names, run_tors_grids):
        #         constraint_dct = automol.zmat.build_constraint_dct(
        #             zma, const_names, tors_names)
        #         pot, _, _, _, zmas, paths = filesys.read.potential(
        #             tors_names, tors_grids,
        #             ini_cnf_save_path,
        #             mod_ini_thy_info, ref_ene,
        #             constraint_dct,
        #             read_zma=True)
        #         tors_pots[tors_names] = pot
        #         tors_zmas[tors_names] = zmas
        #         tors_paths[tors_names] = paths

        #     # Check for new minimum conformer
        #     new_min_zma = __.check_hr_pot(
        #         tors_pots, tors_zmas, tors_paths, emax=ethresh)

        #     if new_min_zma is not None:
        #         ioprinter.info_message(
        #             'Finding new low energy conformer...', newline=1)
        #         conformer.single_conformer(
        #             zma, spc_info, mod_thy_info,
        #             ini_cnf_run_fs, ini_cnf_save_fs,
        #             script_str, overwrite,
        #             retryfail=retryfail, rxn=rxn, **kwargs)

        elif job in ('energy', 'grad', 'hess', 'vpt2'):

            # Script (add energy script call)
            script_str, kwargs = qchem_params(method_dct)

            run_tors_names = automol.rotor.names(torsions, flat=True)
            for tors_names in run_tors_names:

                # Set the constraint dct and filesys for the scan
                const_names = automol.zmat.set_constraint_names(
                    zma, run_tors_names, tors_model)
                constraint_dct = automol.zmat.build_constraint_dct(
                    zma, const_names, tors_names)

                # get the scn_locs, maybe get a function?
                scn_locs = ()
                for locs in scn_locs:
                    geo_run_path = ini_scn_run_fs[-1].path(locs)
                    geo_save_path = ini_scn_save_fs[-1].path(locs)
                    geo = ini_scn_save_fs[-1].file.geometry.read(locs)
                    zma = ini_scn_save_fs[-1].file.zmatrix.read(locs)
                    ini_scn_run_fs[-1].create(locs)
                    ES_TSKS[job](zma,
                                 geo,
                                 spc_info,
                                 mod_thy_info,
                                 ini_scn_save_fs,
                                 geo_run_path,
                                 geo_save_path,
                                 locs,
                                 script_str,
                                 overwrite,
                                 retryfail=retryfail,
                                 **kwargs)
                    ioprinter.obj('vspace')
    else:
        ioprinter.info_message('No torsional modes in the species')
Beispiel #21
0
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
Beispiel #22
0
def conformer_tsk(job,
                  spc_dct,
                  spc_name,
                  thy_dct,
                  es_keyword_dct,
                  run_prefix,
                  save_prefix,
                  print_debug=False):
    """ Prepares and executes all electronic structure tasks that
        generate information for species and transition state conformers.
        This includes sampling and optimization procedures to generate
        conformer structures, as well as __ calculations using some
        saved conformer as input.

        :param job(subtask): calculatiion(s) to perform for conformer
        :type job: str
        :param spc_dct:
        :type spc_dct:
        :param spc_name: name of species
        :type spc_name: str
        :param thy_dct:
        :type thy_dct:
        :param es_keyword_dct: keyword-values for electronic structure task
        :type es_keyword_dct: dict[str:str]
        :param run_prefix: root-path to the run-filesystem
        :type run_prefix: str
        :param save_prefix: root-path to the save-filesystem
        :type save_prefix: str
    """

    saddle = bool('ts_' in spc_name)

    spc_dct_i = spc_dct[spc_name]

    # Set the spc_info
    if not saddle:
        spc_info = sinfo.from_dct(spc_dct_i)
    else:
        spc_info = rinfo.ts_info(spc_dct_i['rxn_info'])
    zrxn = spc_dct_i.get('zrxn', None)

    overwrite = es_keyword_dct['overwrite']
    retryfail = es_keyword_dct['retryfail']
    nprocs = 1
    # Modify the theory
    method_dct = thy_dct.get(es_keyword_dct['runlvl'])
    ini_method_dct = thy_dct.get(es_keyword_dct['inplvl'])
    thy_info = tinfo.from_dct(method_dct)
    ini_thy_info = tinfo.from_dct(ini_method_dct)
    mod_thy_info = tinfo.modify_orb_label(thy_info, spc_info)
    mod_ini_thy_info = tinfo.modify_orb_label(ini_thy_info, spc_info)

    # New filesystem objects
    _root = root_locs(spc_dct_i, saddle=saddle, name=spc_name)
    ini_cnf_run_fs, ini_cnf_save_fs = build_fs(run_prefix,
                                               save_prefix,
                                               'CONFORMER',
                                               thy_locs=mod_ini_thy_info[1:],
                                               **_root)
    cnf_run_fs, cnf_save_fs = build_fs(run_prefix,
                                       save_prefix,
                                       'CONFORMER',
                                       thy_locs=mod_thy_info[1:],
                                       **_root)

    if job == 'samp':

        # Build the ini zma filesys
        user_conf_ids = spc_dct_i.get('conf_id')
        if user_conf_ids is None:
            ini_loc_info = filesys.mincnf.min_energy_conformer_locators(
                ini_cnf_save_fs, mod_ini_thy_info)
            ini_locs, ini_min_cnf_path = ini_loc_info
        else:
            print(f'Using user specified conformer IDs: {user_conf_ids}')
            ini_locs = user_conf_ids

        if any(ini_locs):
            ini_zma_save_fs = autofile.fs.zmatrix(ini_min_cnf_path)

            # Set up the run scripts
            script_str, kwargs = qchem_params(method_dct,
                                              elstruct.Job.OPTIMIZATION)

            # Set variables if it is a saddle
            two_stage = saddle
            mc_nsamp = spc_dct_i['mc_nsamp']
            resave = es_keyword_dct['resave']

            # Read the geometry and zma from the ini file system
            geo = ini_cnf_save_fs[-1].file.geometry.read(ini_locs)
            zma = ini_zma_save_fs[-1].file.zmatrix.read([0])

            # Read the torsions from the ini file sys
            if ini_zma_save_fs[-1].file.torsions.exists([0]):
                tors_dct = ini_zma_save_fs[-1].file.torsions.read([0])
                rotors = automol.rotor.from_data(zma, tors_dct)
                tors_names = automol.rotor.names(rotors, flat=True)
            else:
                tors_names = ()

            geo_path = ini_cnf_save_fs[-1].path(ini_locs)
            ioprinter.initial_geom_path('Sampling started', geo_path)

            # Check runsystem for equal ring CONF make conf_fs
            # Else make new ring conf directory
            rid = conformer.rng_loc_for_geo(geo, cnf_save_fs)

            if rid is None:
                conformer.single_conformer(zma,
                                           spc_info,
                                           mod_thy_info,
                                           cnf_run_fs,
                                           cnf_save_fs,
                                           script_str,
                                           overwrite,
                                           retryfail=retryfail,
                                           zrxn=zrxn,
                                           **kwargs)

                rid = conformer.rng_loc_for_geo(geo, cnf_save_fs)

            # Run the sampling
            conformer.conformer_sampling(zma,
                                         spc_info,
                                         mod_thy_info,
                                         cnf_run_fs,
                                         cnf_save_fs,
                                         rid,
                                         script_str,
                                         overwrite,
                                         nsamp_par=mc_nsamp,
                                         tors_names=tors_names,
                                         zrxn=zrxn,
                                         two_stage=two_stage,
                                         retryfail=retryfail,
                                         resave=resave,
                                         repulsion_thresh=40.0,
                                         print_debug=print_debug,
                                         **kwargs)
        else:
            ioprinter.info_message('Missing conformers. Skipping task...')

    elif job == 'pucker':

        # Build the ini zma filesys
        ini_loc_info = filesys.mincnf.min_energy_conformer_locators(
            ini_cnf_save_fs, mod_ini_thy_info)
        ini_min_locs, ini_min_cnf_path = ini_loc_info
        ini_zma_save_fs = autofile.fs.zmatrix(ini_min_cnf_path)

        # Set up the run scripts
        script_str, kwargs = qchem_params(method_dct,
                                          elstruct.Job.OPTIMIZATION)

        # Set variables if it is a saddle
        two_stage = saddle
        mc_nsamp = spc_dct_i['mc_nsamp']

        # Read the geometry and zma from the ini file system
        geo = ini_cnf_save_fs[-1].file.geometry.read(ini_min_locs)
        zma = ini_zma_save_fs[-1].file.zmatrix.read([0])

        # Read the torsions from the ini file sys
        if ini_zma_save_fs[-1].file.ring_torsions.exists([0]):
            ring_tors_dct = ini_zma_save_fs[-1].file.ring_torsions.read([0])
        else:
            ring_tors_dct = {}

        geo_path = ini_cnf_save_fs[-1].path(ini_min_locs)
        ioprinter.initial_geom_path('Sampling started', geo_path)

        # Run the sampling
        conformer.ring_conformer_sampling(zma,
                                          spc_info,
                                          mod_thy_info,
                                          cnf_run_fs,
                                          cnf_save_fs,
                                          script_str,
                                          overwrite,
                                          nsamp_par=mc_nsamp,
                                          ring_tors_dct=ring_tors_dct,
                                          zrxn=zrxn,
                                          two_stage=two_stage,
                                          retryfail=retryfail,
                                          **kwargs)

    elif job == 'opt':

        cnf_range = es_keyword_dct['cnf_range']
        hbond_cutoffs = spc_dct_i['hbond_cutoffs']
        cnf_sort_info_lst = _sort_info_lst(es_keyword_dct['sort'], thy_dct,
                                           spc_info)

        # Set up the run scripts
        script_str, kwargs = qchem_params(method_dct,
                                          elstruct.Job.OPTIMIZATION)

        rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators(
            cnf_save_fs, mod_thy_info, cnf_range='all', nprocs=nprocs)

        ini_rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators(
            ini_cnf_save_fs,
            mod_ini_thy_info,
            cnf_range=cnf_range,
            sort_info_lst=cnf_sort_info_lst,
            hbond_cutoffs=hbond_cutoffs,
            print_enes=True,
            nprocs=nprocs)

        # Truncate the list of the ini confs
        uni_rng_locs_lst, uni_cnf_locs_lst = conformer.unique_fs_ring_confs(
            cnf_save_fs, rng_cnf_locs_lst, ini_cnf_save_fs,
            ini_rng_cnf_locs_lst)
        # ioprinter.debug_message(
        #    'uni lst that has no similar ring', uni_rng_locs_lst)
        # ioprinter.debug_message(
        #    'uni lst that has similar ring', uni_cnf_locs_lst)

        for locs in uni_rng_locs_lst:
            rid, cid = locs
            # Obtain the zma from ini loc
            ini_cnf_save_path = ini_cnf_save_fs[-1].path(locs)
            ini_zma_save_fs = autofile.fs.zmatrix(ini_cnf_save_path)
            zma = ini_zma_save_fs[-1].file.zmatrix.read((0, ))

            # Make the ring filesystem
            conformer.single_conformer(zma,
                                       spc_info,
                                       mod_thy_info,
                                       cnf_run_fs,
                                       cnf_save_fs,
                                       script_str,
                                       overwrite,
                                       retryfail=retryfail,
                                       zrxn=zrxn,
                                       use_locs=locs,
                                       **kwargs)

        for locs in uni_cnf_locs_lst:
            ini_locs, rid = locs
            # Obtain the zma from ini loc
            ini_cnf_save_path = ini_cnf_save_fs[-1].path(ini_locs)
            ini_zma_save_fs = autofile.fs.zmatrix(ini_cnf_save_path)
            zma = ini_zma_save_fs[-1].file.zmatrix.read((0, ))
            # obtain conformer filesys associated with ring at the runlevel
            cid = autofile.schema.generate_new_conformer_id()
            conformer.single_conformer(zma,
                                       spc_info,
                                       mod_thy_info,
                                       cnf_run_fs,
                                       cnf_save_fs,
                                       script_str,
                                       overwrite,
                                       retryfail=retryfail,
                                       zrxn=zrxn,
                                       use_locs=(rid, cid),
                                       **kwargs)

        # print all geometres within cnfrange
        rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators(
            cnf_save_fs,
            mod_thy_info,
            cnf_range=cnf_range,
            sort_info_lst=cnf_sort_info_lst,
            hbond_cutoffs=hbond_cutoffs,
            nprocs=nprocs)
        for locs in rng_cnf_locs_lst:
            geo = cnf_save_fs[-1].file.geometry.read(locs)
            ioprinter.geometry(geo)

    elif job in ('energy', 'grad', 'hess', 'vpt2', 'prop'):

        cnf_range = es_keyword_dct['cnf_range']
        hbond_cutoffs = spc_dct_i['hbond_cutoffs']
        cnf_sort_info_lst = _sort_info_lst(es_keyword_dct['sort'], thy_dct,
                                           spc_info)

        user_conf_ids = spc_dct_i.get('conf_id')
        if user_conf_ids is None:
            ini_rng_cnf_locs_lst, _ = filesys.mincnf.conformer_locators(
                ini_cnf_save_fs,
                mod_ini_thy_info,
                cnf_range=cnf_range,
                sort_info_lst=cnf_sort_info_lst,
                hbond_cutoffs=hbond_cutoffs,
                print_enes=True,
                nprocs=nprocs)
        else:
            print(f'Using user specified conformer IDs: {user_conf_ids}')
            ini_rng_cnf_locs_lst = (user_conf_ids, )

        # Check if locs exist, kill if it doesn't
        if not ini_rng_cnf_locs_lst:
            ioprinter.error_message('No min-energy conformer found for level:')

        else:

            # Set up the run scripts
            script_str, kwargs = qchem_params(method_dct)

            # Grab frequencies for the reference, print ref freqs
            if job == 'hess':
                if ini_cnf_save_fs[-1].file.harmonic_frequencies.exists(
                        ini_rng_cnf_locs_lst[0]):
                    frq = ini_cnf_save_fs[-1].file.harmonic_frequencies.read(
                        ini_rng_cnf_locs_lst[0])
                    ref_val = frq
                else:
                    ref_val = None
                if ref_val is not None and zrxn is not None:
                    ref_path = cnf_save_fs[-1].path(ini_rng_cnf_locs_lst[0])
                    print('Found reference frequencies for saddle-point '
                          f'checks for conformer at\n {ref_path}')
                    ioprinter.frequencies(ref_val)
            else:
                ref_val = None

            # Run the job over all the conformers requested by the user
            print('Going over all requested conformers for task...\n')
            for ini_locs in ini_rng_cnf_locs_lst:
                ini_cnf_run_fs[-1].create(ini_locs)
                geo_save_path = ini_cnf_save_fs[-1].path(ini_locs)
                ini_zma_save_fs = autofile.fs.zmatrix(geo_save_path)
                print('Running task for geometry at ', geo_save_path)
                geo = ini_cnf_save_fs[-1].file.geometry.read(ini_locs)
                zma = ini_zma_save_fs[-1].file.zmatrix.read((0, ))
                ES_TSKS[job](zma,
                             geo,
                             spc_info,
                             mod_thy_info,
                             ini_cnf_run_fs,
                             ini_cnf_save_fs,
                             ini_locs,
                             run_prefix,
                             script_str,
                             overwrite,
                             zrxn=zrxn,
                             retryfail=retryfail,
                             method_dct=method_dct,
                             ref_val=ref_val,
                             **kwargs)
                print('\n === FINISHED CONF ===\n')
Beispiel #23
0
def obtain_saddle_point(guess_zmas, ts_dct, method_dct, runfs_dct, savefs_dct,
                        es_keyword_dct):
    """ Given the saddle point guess structure, obtain a
        proper saddle point
    """

    # Get info (move later)
    ts_info = rinfo.ts_info(ts_dct['rxn_info'])
    mod_thy_info = tinfo.modify_orb_label(tinfo.from_dct(method_dct), ts_info)
    script_str, kwargs = qchem_params(method_dct,
                                      job=elstruct.Job.OPTIMIZATION)

    overwrite = es_keyword_dct['overwrite']
    ts_info = rinfo.ts_info(ts_dct['rxn_info'])
    zrxn = ts_dct['zrxn']

    # runlvl_cnf_run_fs = runfs_dct['runlvl_cnf_fs']
    # cid = [autofile.schema.generate_new_conformer_id()]
    # run_fs = autofile.fs.run(runlvl_cnf_run_fs[-1].path(cid))

    run_prefix = runfs_dct['prefix']
    runlvl_cnf_run_fs = runfs_dct['runlvl_cnf_fs']
    rid = autofile.schema.generate_new_ring_id()
    cid = autofile.schema.generate_new_conformer_id()
    locs = (rid, cid)
    runlvl_cnf_run_fs[-1].create(locs)
    run_fs = autofile.fs.run(runlvl_cnf_run_fs[-1].path(locs))

    # Optimize the saddle point
    script_str, kwargs = qchem_params(method_dct)
    opt_ret = optimize_saddle_point(guess_zmas, ts_info, mod_thy_info, run_fs,
                                    script_str, overwrite, **kwargs)

    # Calculate the Hessian for the optimized structure
    if opt_ret is not None:
        # Get the Hessian and check the saddle point
        # (maybe just have remove imag do this?)
        hess_ret, _, imags = saddle_point_hessian(opt_ret, ts_info, method_dct,
                                                  run_fs, run_prefix,
                                                  overwrite)

        sadpt_status = saddle_point_checker(imags)
        # ted_status = ted_coordinate_check(opt_ret, hess_ret, ts_dct, run_fs)
        # remove ted_status check for now since it was crashing
        # ted_status = True

        # Assess saddle point, save it if viable
        # if sadpt_status == 'kickoff':
        #     opt_inf_obj, _, opt_out_str = opt_ret
        #     opt_prog = opt_inf_obj.prog
        #     geo = elstruct.reader.opt_geometry(opt_prog, opt_out_str)

        #     # Need to return an opt_ret
        #     geo, _ = geom.remove_imag(
        #         geo, ts_info, mod_thy_info, ts_run_fs, run_fs,
        #         kickoff_size=0.1, kickoff_backward=False, kickoff_mode=1,
        #         overwrite=False)

        #     sadpt_status = saddle_point_checker(imags)

        if sadpt_status == 'success':
            runlvl_cnf_save_fs, _ = savefs_dct['runlvl_cnf_fs']
            filesys.save.conformer(opt_ret,
                                   hess_ret,
                                   runlvl_cnf_save_fs,
                                   mod_thy_info[1:],
                                   zrxn=zrxn,
                                   rng_locs=(rid, ),
                                   tors_locs=(cid, ),
                                   zma_locs=None)
    else:
        ioprinter.warning_message(
            '\n TS optimization failed. No geom to check and save.')