コード例 #1
0
ファイル: _vtst.py プロジェクト: sjklipp/mechdriver
def _vtst_hess_ene(ts_info, coord_name, mod_thy_info, mod_vsp1_thy_info,
                   scn_save_fs, scn_run_fs, overwrite, **cas_kwargs):
    """ VTST Hessians and Energies
    """

    scn_locs = scn_save_fs[-1].existing([coord_name])

    ioprinter.running('Hessians and Gradients and Energies...', newline=1)
    hess_script_str, _, hess_kwargs, _ = qchem_params(*mod_thy_info[0:2])
    hess_kwargs.update(cas_kwargs)
    script_str, _, ene_kwargs, _ = qchem_params(*mod_vsp1_thy_info[0:2])
    ene_kwargs.update(cas_kwargs)
    for locs in scn_locs:
        geo_run_path = scn_run_fs[-1].path(locs)
        geo_save_path = scn_save_fs[-1].path(locs)
        scn_run_fs[-1].create(locs)
        zma, geo = filesys.inf.cnf_fs_zma_geo(scn_save_fs, locs)
        sp.run_hessian(zma, geo, ts_info, mod_thy_info, scn_save_fs,
                       geo_run_path, geo_save_path, locs, hess_script_str,
                       overwrite, **hess_kwargs)
        sp.run_gradient(zma, geo, ts_info, mod_thy_info, scn_save_fs,
                        geo_run_path, geo_save_path, locs, hess_script_str,
                        overwrite, **hess_kwargs)
        sp.run_energy(zma, geo, ts_info, mod_vsp1_thy_info, scn_save_fs,
                      geo_run_path, geo_save_path, locs, script_str, overwrite,
                      **ene_kwargs)
コード例 #2
0
ファイル: _vrctst.py プロジェクト: Auto-Mech/mechdriver
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
コード例 #3
0
def run_messrate_task(rate_paths_dct, pes_inf):
    """ Run the MESSRATE input file.

        First tries to run a well-extended file, then tries to
        run the base file if it exists.

        Need an overwrite task
    """
    path_dct = rate_paths_dct[pes_inf]
    for typ in ('wext', 'base'):
        path = path_dct[typ]
        mess_inp = os.path.join(path, 'mess.inp')
        mess_out = os.path.join(path, 'mess.out')
        if os.path.exists(mess_inp) and not os.path.exists(mess_out):
            ioprinter.obj('vspace')
            ioprinter.obj('line_dash')
            ioprinter.info_message(f'Found MESS input file at {path}')
            ioprinter.running('MESS input file')
            autorun.run_script(autorun.SCRIPT_DCT['messrate'], path)
            break
コード例 #4
0
ファイル: _vib.py プロジェクト: Auto-Mech/mechdriver
def ted(spc_dct_i, pf_filesystems, spc_mod_dct_i, run_prefix, zrxn=None):
    """ process to get freq
    """
    [cnf_fs, _, min_cnf_locs, _, _] = pf_filesystems['harm']

    if min_cnf_locs is not None:
        geo_exists = cnf_fs[-1].file.geometry.exists(min_cnf_locs)
        hess_exists = cnf_fs[-1].file.hessian.exists(min_cnf_locs)

        if not geo_exists:
            ioprinter.error_message(
                'No Reference geometry for harmonic frequencies at path',
                cnf_fs[-1].file.hessian.path(min_cnf_locs))
        if not hess_exists:
            ioprinter.error_message(
                'No Hessian available for harmonic frequencies at path',
                cnf_fs[-1].file.hessian.path(min_cnf_locs))
    else:
        geo_exists, hess_exists = False, False

    if geo_exists and hess_exists:

        geo = cnf_fs[-1].file.geometry.read(min_cnf_locs)
        hess = cnf_fs[-1].file.hessian.read(min_cnf_locs)

        geo_path = cnf_fs[-1].path(min_cnf_locs)
        zma_fs = autofile.fs.zmatrix(geo_path)
        zma = zma_fs[-1].file.zmatrix.read((0, ))

        fml_str = automol.geom.formula_string(geo)
        ted_path = job_path(run_prefix, 'INTDER', 'TED', fml_str)

        ioprinter.running(
            f'Reaction Coordinate Check with INTDER at {ted_path}')
        script_str = autorun.SCRIPT_DCT['intder']
        _ = autorun.intder.reaction_coordinate_check_idxs(
            script_str, ted_path, geo, zma, hess, zrxn)
コード例 #5
0
def run(pes_rlst, ktp_tsk_lst, spc_dct, glob_dct, thy_dct, pes_mod_dct,
        spc_mod_dct, run_prefix, save_prefix):
    """ main driver for generation of full set of rate constants on a single PES
    """

    # --------------------------------------- #
    # LOOP OVER ALL OF THE SUBPES in PES_RLST #
    # --------------------------------------- #

    for pes_inf, rxn_lst in pes_rlst.items():

        # ---------------------------------------------- #
        # PREPARE INFORMATION TO PASS TO KTPDRIVER TASKS #
        # ---------------------------------------------- #

        # Set objects
        pes_formula, pes_idx, subpes_idx = pes_inf
        label_dct = None

        # Print PES Channels that are being run
        ioprinter.runlst(pes_inf, rxn_lst)

        # Set paths where files will be written and read
        mess_path = job_path(run_prefix,
                             'MESS',
                             'RATE',
                             pes_formula,
                             locs_idx=subpes_idx)

        # --------------------------------- #
        # RUN THE REQUESTED KTPDRIVER TASKS #
        # --------------------------------- #

        # Write the MESS file
        write_rate_tsk = parser.run.extract_task('write_mess', ktp_tsk_lst)
        if write_rate_tsk is not None:

            # Get all the info for the task
            tsk_key_dct = write_rate_tsk[-1]
            pes_mod = tsk_key_dct['kin_model']
            spc_mod = tsk_key_dct['spc_model']

            spc_dct, rxn_lst, label_dct = _process(pes_idx, rxn_lst,
                                                   ktp_tsk_lst, spc_mod_dct,
                                                   spc_mod, thy_dct, spc_dct,
                                                   glob_dct, run_prefix,
                                                   save_prefix)

            ioprinter.messpf('write_header')

            mess_inp_str, dats = ktproutines.rates.make_messrate_str(
                pes_idx, rxn_lst, pes_mod, spc_mod, spc_dct, thy_dct,
                pes_mod_dct, spc_mod_dct, label_dct, mess_path, run_prefix,
                save_prefix)

            autorun.write_input(mess_path,
                                mess_inp_str,
                                aux_dct=dats,
                                input_name='mess.inp')

        # Run mess to produce rates (currently nothing from tsk lst keys used)
        run_rate_tsk = parser.run.extract_task('run_mess', ktp_tsk_lst)
        if run_rate_tsk is not None:

            ioprinter.obj('vspace')
            ioprinter.obj('line_dash')
            ioprinter.running('MESS for the input file', mess_path)
            autorun.run_script(autorun.SCRIPT_DCT['messrate'], mess_path)

        # Fit rate output to modified Arrhenius forms, print in ChemKin format
        run_fit_tsk = parser.run.extract_task('run_fits', ktp_tsk_lst)
        if run_fit_tsk is not None:

            # Get all the info for the task
            tsk_key_dct = run_fit_tsk[-1]
            spc_mod = tsk_key_dct['spc_model']
            pes_mod = tsk_key_dct['kin_model']
            ratefit_dct = pes_mod_dct[pes_mod]['rate_fit']

            if label_dct is None:
                spc_dct, rxn_lst, label_dct = _process(pes_idx, rxn_lst,
                                                       ktp_tsk_lst,
                                                       spc_mod_dct, spc_mod,
                                                       thy_dct, spc_dct,
                                                       run_prefix, save_prefix)

            ioprinter.obj('vspace')
            ioprinter.obj('line_dash')
            ioprinter.info_message(
                'Fitting Rate Constants for PES to Functional Forms',
                newline=1)

            # Read and fit rates; write to ckin string
            ratefit_dct = pes_mod_dct[pes_mod]['rate_fit']
            ckin_dct = ratefit.fit.fit_ktp_dct(
                mess_path=mess_path,
                inp_fit_method=ratefit_dct['fit_method'],
                pdep_dct=ratefit_dct['pdep_fit'],
                arrfit_dct=ratefit_dct['arrfit_fit'],
                chebfit_dct=ratefit_dct['chebfit_fit'],
                troefit_dct=ratefit_dct['troefit_fit'],
                label_dct=label_dct,
                fit_temps=pes_mod_dct[pes_mod]['rate_temps'],
                fit_pressures=pes_mod_dct[pes_mod]['pressures'],
                fit_tunit=pes_mod_dct[pes_mod]['temp_unit'],
                fit_punit=pes_mod_dct[pes_mod]['pressure_unit'])

            # Write the header part
            ckin_dct.update(
                {'header': writer.ckin.model_header((spc_mod, ), spc_mod_dct)})

            ckin_path = output_path('CKIN')
            writer.ckin.write_rxn_file(ckin_dct, pes_formula, ckin_path)
コード例 #6
0
ファイル: _old_amech.py プロジェクト: sjklipp/mechdriver
# Parse the theory input
ioprinter.reading('theory.dat...', newline=1)
THY_DCT = parser.theory.build_thy_dct(JOB_PATH)

# Parse the model input
ioprinter.reading('model.dat...', newline=1)
PES_MODEL_DCT, SPC_MODEL_DCT = parser.model.read_models_sections(JOB_PATH)

# Parse the species input to get a dct with ALL species in mechanism
ioprinter.reading('species.csv...', newline=1)
SPC_DCT = parser.species.build_spc_dct(JOB_PATH, 'csv')

# Parse mechanism input and get a dct with info on PESs user request to run
if RUN_OBJ_DCT['pes']:
    ioprinter.running(
        'Calculations for PESs. Need input for mechanism.', newline=1)
    ioprinter.reading('mechanism.dat...', newline=1)
    RUN_PES_DCT = parser.mechanism.build_pes_dct(
        JOB_PATH,
        RUN_INP_DCT['mech'],
        SPC_DCT,
        RUN_OBJ_DCT['pes'],
        sort_rxns=True
    )
elif RUN_OBJ_DCT['spc']:
    RUN_PES_DCT = {}
    RUN_SPC_LST_DCT = parser.species.build_run_spc_dct(SPC_DCT, RUN_OBJ_DCT)
else:
    ioprinter.error_message('No Proper Run object specified')
    sys.exit()
コード例 #7
0
ファイル: ktpdriver.py プロジェクト: kevinmooreiii/mechdriver
def run(pes_rlst, ktp_tsk_lst, spc_dct, glob_dct, pes_mod_dct, spc_mod_dct,
        run_prefix, save_prefix):
    """ Executes all kinetics tasks.

        :param pes_rlst: species from PESs to run
            [(PES formula, PES idx, SUP-PES idx)
            (CHANNEL idx, (REACS, PRODS))
        :type pes_rlst: tuple(dict[str: dict])
        :param spc_rlst: lst of species to run
        :type spc_rlst: tuple(dict[str: dict])
        :param es_tsk_lst: list of the electronic structure tasks
            tuple(tuple(obj, tsk, keyword_dict))
        :type es_tsk_lst: tuple(tuple(str, str, dict))
        :param spc_dct: species information
            dict[spc_name: spc_information]
        :type spc_dct: dict[str:dict]
        :param glob_dct: global information for all species
            dict[spc_name: spc_information]
        :type glob_dct: dict[str: dict]
        :param thy_dct: all of the theory information
            dict[thy name: inf]
        :type thy_dct: dict[str:dict]
        :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
    """

    # --------------------------------------- #
    # LOOP OVER ALL OF THE SUBPES in PES_RLST #
    # --------------------------------------- #

    for pes_inf, rxn_lst in pes_rlst.items():

        # ---------------------------------------------- #
        # PREPARE INFORMATION TO PASS TO KTPDRIVER TASKS #
        # ---------------------------------------------- #

        # Set objects
        pes_formula, pes_idx, subpes_idx = pes_inf
        label_dct = None

        # Print PES Channels that are being run
        ioprinter.runlst(pes_inf, rxn_lst)

        # Set paths where files will be written and read
        mess_path = job_path(run_prefix,
                             'MESS',
                             'RATE',
                             pes_formula,
                             locs_idx=subpes_idx)

        # --------------------------------- #
        # RUN THE REQUESTED KTPDRIVER TASKS #
        # --------------------------------- #

        # Write the MESS file
        write_rate_tsk = parser.run.extract_task('write_mess', ktp_tsk_lst)
        if write_rate_tsk is not None:

            # Get all the info for the task
            tsk_key_dct = write_rate_tsk[-1]
            pes_mod = tsk_key_dct['kin_model']
            spc_mod = tsk_key_dct['spc_model']

            spc_dct, rxn_lst, instab_chnls, label_dct = _process(
                pes_idx, rxn_lst, ktp_tsk_lst, spc_mod_dct, spc_mod, spc_dct,
                glob_dct, run_prefix, save_prefix)

            ioprinter.messpf('write_header')

            # Doesn't give full string
            mess_inp_str, dats = ktproutines.rates.make_messrate_str(
                pes_idx,
                rxn_lst,
                pes_mod,
                spc_mod,
                spc_dct,
                pes_mod_dct,
                spc_mod_dct,
                instab_chnls,
                label_dct,
                mess_path,
                run_prefix,
                save_prefix,
                make_lump_well_inp=tsk_key_dct['lump_wells'])

            autorun.write_input(mess_path,
                                mess_inp_str,
                                aux_dct=dats,
                                input_name='mess.inp')

        # Run mess to produce rates (currently nothing from tsk lst keys used)
        run_rate_tsk = parser.run.extract_task('run_mess', ktp_tsk_lst)
        if run_rate_tsk is not None:

            ioprinter.obj('vspace')
            ioprinter.obj('line_dash')
            ioprinter.running('MESS for the input file', mess_path)
            autorun.run_script(autorun.SCRIPT_DCT['messrate'], mess_path)

        # Fit rate output to modified Arrhenius forms, print in ChemKin format
        run_fit_tsk = parser.run.extract_task('run_fits', ktp_tsk_lst)
        if run_fit_tsk is not None:

            # Get all the info for the task
            tsk_key_dct = run_fit_tsk[-1]
            spc_mod = tsk_key_dct['spc_model']
            pes_mod = tsk_key_dct['kin_model']
            ratefit_dct = pes_mod_dct[pes_mod]['rate_fit']

            if label_dct is None:
                spc_dct, rxn_lst, _, label_dct = _process(
                    pes_idx, rxn_lst, ktp_tsk_lst, spc_mod_dct, spc_mod,
                    spc_dct, glob_dct, run_prefix, save_prefix)

            ioprinter.obj('vspace')
            ioprinter.obj('line_dash')
            ioprinter.info_message(
                'Fitting Rate Constants for PES to Functional Forms',
                newline=1)

            # Read and fit rates; write to ckin string
            ratefit_dct = pes_mod_dct[pes_mod]['rate_fit']
            ckin_dct = ratefit.fit.fit_ktp_dct(
                mess_path=mess_path,
                inp_fit_method=ratefit_dct['fit_method'],
                pdep_dct=ratefit_dct['pdep_fit'],
                arrfit_dct=ratefit_dct['arrfit_fit'],
                chebfit_dct=ratefit_dct['chebfit_fit'],
                troefit_dct=ratefit_dct['troefit_fit'],
                label_dct=label_dct,
                fit_temps=pes_mod_dct[pes_mod]['rate_temps'],
                fit_pressures=pes_mod_dct[pes_mod]['pressures'],
                fit_tunit=pes_mod_dct[pes_mod]['temp_unit'],
                fit_punit=pes_mod_dct[pes_mod]['pressure_unit'])

            # Write the header part
            ckin_dct.update(
                {'header': writer.ckin.model_header((spc_mod, ), spc_mod_dct)})

            ckin_path = output_path('CKIN')
            writer.ckin.write_rxn_file(ckin_dct, pes_formula, ckin_path)
コード例 #8
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)
コード例 #9
0
ファイル: _vtst.py プロジェクト: sjklipp/mechdriver
def molrad_scan(ts_zma,
                ts_info,
                rct_info,
                rcts_cnf_fs,
                rcts_gra,
                grid1,
                grid2,
                coord_name,
                frm_bnd_keys,
                thy_info,
                vsp1_thy_info,
                thy_save_fs,
                ts_save_fs,
                scn_run_fs,
                scn_save_fs,
                overwrite,
                update_guess,
                retryfail,
                zma_locs=(0, )):
    """ Run the scan for VTST calculations
    """

    # Set the thy info objects appropriately
    if vsp1_thy_info is not None:
        inf_thy_info = vsp1_thy_info
    else:
        inf_thy_info = thy_info
    mod_thy_info = filesys.inf.modify_orb_restrict(ts_info, thy_info)
    mod_vsp1_thy_info = filesys.inf.modify_orb_restrict(ts_info, vsp1_thy_info)

    # Set script
    _, opt_script_str, _, opt_kwargs = qchem_params(*mod_thy_info[0:2])

    # Setup and run the first part of the scan to shorte
    scan.run_two_way_scan(
        ts_zma,
        ts_info,
        mod_thy_info,
        grid1,
        grid2,
        coord_name,
        thy_save_fs,
        scn_run_fs,
        scn_save_fs,
        opt_script_str,
        overwrite,
        update_guess=update_guess,
        reverse_sweep=False,
        saddle=False,  # opts along scan are min, not sadpt opts
        constraint_dct=None,
        retryfail=retryfail,
        **opt_kwargs)

    # Infinite seperation energy calculation
    ioprinter.info_message('Calculating infinite separation energy...',
                           newline=1)
    ioprinter.debug_message('inf_thy_info', inf_thy_info)
    _ = scan.molrad_inf_sep_ene(rct_info, rcts_cnf_fs, inf_thy_info, overwrite)

    # Save the vmatrix for use in reading
    _save_traj(ts_zma, frm_bnd_keys, rcts_gra, ts_save_fs, zma_locs=zma_locs)

    ioprinter.running('Hessians and energies...', newline=1)
    _vtst_hess_ene(ts_info, coord_name, mod_thy_info, mod_vsp1_thy_info,
                   scn_save_fs, scn_run_fs, overwrite, **{})