Beispiel #1
0
def make_pes_mess_str(spc_dct, rxn_lst, pes_idx,
                      run_prefix, save_prefix, label_dct,
                      pes_model_dct_i, spc_model_dct_i,
                      spc_model, thy_dct):
    """ Write all the MESS input file strings for the reaction channels
    """

    ioprinter.messpf('channel_section')

    # Initialize empty MESS strings
    full_well_str, full_bi_str, full_ts_str = '', '', ''
    full_dat_str_dct = {}
    pes_ene_dct = {}
    conn_lst = tuple()

    # Set the energy and model for the first reference species
    ioprinter.info_message('\nCalculating reference energy for PES')
    ref_ene = set_reference_ene(
        rxn_lst, spc_dct, thy_dct,
        pes_model_dct_i, spc_model_dct_i,
        run_prefix, save_prefix, ref_idx=0)

    # Loop over all the channels and write the MESS strings
    written_labels = []
    basis_energy_dct = {}
    for rxn in rxn_lst:

        chnl_idx, (reacs, prods) = rxn

        ioprinter.obj('vspace')
        ioprinter.reading('PES electrion structure data')
        ioprinter.channel(chnl_idx, reacs, prods)

        # Set the TS name and channel model
        tsname = 'ts_{:g}_{:g}'.format(pes_idx+1, chnl_idx+1)

        # Obtain all of the species data
        if spc_model not in basis_energy_dct:
            basis_energy_dct[spc_model] = {}

        # Pass in full ts class
        chnl_infs, chn_basis_ene_dct = get_channel_data(
            reacs, prods, tsname,
            spc_dct, basis_energy_dct[spc_model],
            pes_model_dct_i, spc_model_dct_i,
            run_prefix, save_prefix)

        basis_energy_dct[spc_model].update(chn_basis_ene_dct)

        # Calculate the relative energies of all spc on the channel
        chnl_enes = sum_channel_enes(chnl_infs, ref_ene)

        # Write the mess strings for all spc on the channel
        mess_strs, dat_str_dct, written_labels = _make_channel_mess_strs(
            tsname, reacs, prods, spc_dct, label_dct, written_labels,
            chnl_infs, chnl_enes, spc_model_dct_i)

        # Append to full MESS strings
        [well_str, bi_str, ts_str] = mess_strs
        full_well_str += well_str
        full_bi_str += bi_str
        full_ts_str += ts_str
        full_dat_str_dct.update(dat_str_dct)

        ioprinter.debug_message('rxn', rxn)
        ioprinter.debug_message('enes', chnl_enes)
        ioprinter.debug_message('label dct', label_dct)
        ioprinter.debug_message('written labels', written_labels)

    # Combine all the reaction channel strings
    rxn_chan_str = '\n'.join([full_well_str, full_bi_str, full_ts_str])

    return rxn_chan_str, full_dat_str_dct, pes_ene_dct, conn_lst
Beispiel #2
0
def make_pes_mess_str(spc_dct, rxn_lst, pes_idx, pesgrp_num, unstable_chnls,
                      run_prefix, save_prefix, label_dct, tsk_key_dct,
                      pes_param_dct, thy_dct, pes_model_dct_i, spc_model_dct_i,
                      spc_model):
    """ Write all the MESS input file strings for the reaction channels
    """

    ioprinter.messpf('channel_section')

    # Initialize data carrying objects and empty MESS strings
    basis_energy_dct = {}
    basis_energy_dct[spc_model] = {}

    full_well_str, full_bi_str, full_ts_str = '', '', ''
    full_dat_str_dct = {}

    # Set the energy and model for the first reference species
    ioprinter.info_message('\nCalculating reference energy for PES')
    ref_ene, model_basis_energy_dct = set_reference_ene(
        rxn_lst,
        spc_dct,
        tsk_key_dct,
        basis_energy_dct[spc_model],
        thy_dct,
        pes_model_dct_i,
        spc_model_dct_i,
        run_prefix,
        save_prefix,
        ref_idx=0)
    basis_energy_dct[spc_model].update(model_basis_energy_dct)

    print('basis energy dct')
    print(basis_energy_dct)

    # Loop over all the channels and write the MESS strings
    written_labels = []
    for rxn in rxn_lst:

        chnl_idx, (reacs, prods) = rxn

        ioprinter.obj('vspace')
        ioprinter.reading('PES electronic structure data')
        ioprinter.channel(chnl_idx + 1, reacs, prods)

        # Get the names for all of the configurations of the TS
        tsname = base_tsname(pes_idx, chnl_idx)
        tsname_allconfigs = tsnames_in_dct(pes_idx, chnl_idx, spc_dct)

        # Pass in full ts class
        chnl_infs, chn_basis_ene_dct = get_channel_data(
            reacs, prods, tsname_allconfigs, spc_dct, tsk_key_dct,
            basis_energy_dct[spc_model], thy_dct, pes_model_dct_i,
            spc_model_dct_i, run_prefix, save_prefix)

        basis_energy_dct[spc_model].update(chn_basis_ene_dct)

        # Calculate the relative energies of all spc on the channel
        chnl_enes = sum_channel_enes(chnl_infs, ref_ene)

        # Set the hot energies using the relative enes that will be
        # written into the global key section of MESS input later
        hot_enes_dct = set_hot_enes(pesgrp_num,
                                    reacs,
                                    prods,
                                    chnl_enes,
                                    pes_param_dct,
                                    ene_range=None)

        # Write the mess strings for all spc on the channel
        mess_strs, dat_str_dct, written_labels = _make_channel_mess_strs(
            tsname,
            reacs,
            prods,
            pesgrp_num,
            spc_dct,
            label_dct,
            written_labels,
            pes_param_dct,
            chnl_infs,
            chnl_enes,
            spc_model_dct_i,
            unstable_chnl=(chnl_idx in unstable_chnls))

        # Append to full MESS strings
        [well_str, bi_str, ts_str] = mess_strs
        full_well_str += well_str
        full_bi_str += bi_str
        full_ts_str += ts_str
        full_dat_str_dct.update(dat_str_dct)

    # Combine all the reaction channel strings; remove empty lines
    rxn_chan_str = '\n'.join([full_well_str, full_bi_str, full_ts_str])
    rxn_chan_str = ioformat.remove_empty_lines(rxn_chan_str)

    return rxn_chan_str, full_dat_str_dct, hot_enes_dct
Beispiel #3
0
# ESDriver
if RUN_ES:

    ioprinter.program_header('es')

    # Build the elec struct tsk lst
    ES_TSK_LST = parser.tsks.es_tsk_lst(ES_TSK_STR, THY_DCT)

    # Call ESDriver for spc in each PES or SPC
    if RUN_OBJ_DCT['pes']:
        for (formula, pes_idx, sub_pes_idx), rxn_lst in RUN_PES_DCT.items():

            # Print PES form and SUB PES Channels
            ioprinter.pes(pes_idx, formula, sub_pes_idx)
            for rxn in rxn_lst:
                ioprinter.channel(rxn['chn_idx'], rxn['reacs'], rxn['prods'])

            esdriver.run(
                pes_idx,
                rxn_lst,
                SPC_DCT,
                ES_TSK_LST,
                THY_DCT,
                RUN_INP_DCT
            )
    else:
        PES_IDX = 0
        esdriver.run(
            PES_IDX,
            RUN_SPC_LST_DCT,
            SPC_DCT,