Beispiel #1
0
def run_rates(header_str, energy_trans_str, well_str, bim_str, ts_str, tsdct,
              rxn_save_path, model_dct, thy_dct, run_model):
    """ Generate k(T,P) by first compiling all the MESS strings
        and then running MESS
    """
    pf_levels = lmech.set_es_model_info(model_dct['es'], thy_dct)[0]

    ts_info = (tsdct['ich'], tsdct['chg'], tsdct['mul'])
    orb_restr = fsorb.orbital_restriction(ts_info, thy_info)
    ref_level = thy_info[1:3]
    ref_level.append(orb_restr)
    print('ref level test:', ref_level)
    thy_save_fs = autofile.fs.theory(rxn_save_path)
    thy_save_fs.leaf.create(ref_level)
    thy_save_path = thy_save_fs.leaf.path(ref_level)

    mess_inp_str = '\n'.join(
        [header_str, energy_trans_str, well_str, bim_str, ts_str])

    print('mess input file')
    print(mess_inp_str)

    bld_locs = ['MESS', 0]
    bld_save_fs = autofile.fs.build(thy_save_path)
    bld_save_fs.leaf.create(bld_locs)
    mess_path = bld_save_fs.leaf.path(bld_locs)
    print('Build Path for MESS rate files:')
    print(mess_path)
    with open(os.path.join(mess_path, 'mess.inp'), 'w') as mess_file:
        mess_file.write(mess_inp_str)
    script.run_script(script.MESSRATE, mess_path)
    return mess_path
Beispiel #2
0
def projrot_freqs_2(save_path, pot=False, saddle=False):
    """ Get ProjRot frequencies via ProjRot 2
    """

    bld_locs = ['PROJROT', 0]
    bld_save_fs = autofile.fs.build(save_path)
    bld_save_fs.leaf.create(bld_locs)
    path = bld_save_fs.leaf.path(bld_locs)

    projrot_script_str2 = ("#!/usr/bin/env bash\n" "RPHt.exe >& /dev/null")
    script.run_script(projrot_script_str2, path)

    zpe_har_no_tors_2 = 0.0
    freqs_2 = []
    if pot:
        rthrproj_freqs_2, _ = projrot_io.reader.rpht_output(path +
                                                            '/hrproj_freq.dat')
        freqs_2 = rthrproj_freqs_2
        zpe_har_no_tors_2 = sum(freqs_2) * phycon.WAVEN2KCAL / 2.
    rtproj_freqs, imag_freq_2 = projrot_io.reader.rpht_output(
        path + '/RTproj_freq.dat')
    har_zpe = sum(rtproj_freqs) * phycon.WAVEN2KCAL / 2.
    if not freqs_2:
        freqs_2 = rtproj_freqs
    if saddle:
        if imag_freq_2:
            imag_freq_2 = imag_freq_2[0]
        else:
            imag_freq_2 = freqs_2[-1]
            freqs_2 = freqs_2[:-1]

    return freqs_2, imag_freq_2, har_zpe, zpe_har_no_tors_2
Beispiel #3
0
def calc_tors_freqs_zpe(tors_geo, sym_factor, elec_levels, hind_rot_str,
                        tors_save_path):
    """ Calculate the frequencies and ZPVES of the hindered rotors
        create a messpf input and run messpf to get tors_freqs and tors_zpes
    """
    dummy_freqs = [1000.]
    dummy_zpe = 0.0
    core = mess_io.writer.core_rigidrotor(tors_geo, sym_factor)
    spc_str = mess_io.writer.molecule(
        core,
        dummy_freqs,
        elec_levels,
        hind_rot=hind_rot_str,
    )
    temp_step = 100.
    ntemps = 5
    zpe_str = '{0:<8.2f}\n'.format(dummy_zpe)
    zpe_str = ' ZeroEnergy[kcal/mol] ' + zpe_str
    zpe_str += 'End\n'
    global_pf_str = mess_io.writer.global_pf([],
                                             temp_step,
                                             ntemps,
                                             rel_temp_inc=0.001,
                                             atom_dist_min=0.6)
    spc_head_str = 'Species ' + ' Tmp'
    pf_inp_str = '\n'.join([global_pf_str, spc_head_str, spc_str, zpe_str])

    bld_locs = ['PF', 0]
    bld_save_fs = autofile.fs.build(tors_save_path)
    bld_save_fs.leaf.create(bld_locs)
    pf_path = bld_save_fs.leaf.path(bld_locs)

    # run messpf
    with open(os.path.join(pf_path, 'pf.inp'), 'w') as pf_file:
        pf_file.write(pf_inp_str)
    pf_script_str = ("#!/usr/bin/env bash\n"
                     "export OMP_NUM_THREADS=10\n"
                     "messpf pf.inp pf.out >> stdout.log &> stderr.log")

    script.run_script(pf_script_str, pf_path)

    with open(os.path.join(pf_path, 'pf.log'), 'r') as mess_file:
        output_string = mess_file.read()

    # Read the freqs and zpes
    # tors_freqs = mess_io.reader.tors.freqs(output_string)
    tors_zpes = mess_io.reader.tors.zpves(output_string)

    # Calculate the torsional zpe
    tors_zpe = sum(tors_zpes) if tors_zpes else 0.0
    # tors_zpe_cor = 0.0
    # tors_zpe = 0.0
    # for (tors_freq, tors_1dhr_zpe) in zip(tors_freqs, tors_zpes):
    #     tors_zpe_cor += tors_1dhr_zpe - tors_freq*phycon.WAVEN2KCAL/2
    #     tors_zpe += tors_1dhr_zpe

    return tors_zpe
Beispiel #4
0
def projrot_freqs_1(tors_geo,
                    hess,
                    proj_rotors_str,
                    save_path,
                    pot=False,
                    saddle=False):
    """ Get frequencies from one version of ProjRot
    """
    coord_proj = 'cartesian'
    grad = ''
    # Write the string for the ProjRot input
    projrot_inp_str = projrot_io.writer.rpht_input(tors_geo,
                                                   grad,
                                                   hess,
                                                   rotors_str=proj_rotors_str,
                                                   coord_proj=coord_proj)

    bld_locs = ['PROJROT', 0]
    bld_save_fs = autofile.fs.build(save_path)
    bld_save_fs.leaf.create(bld_locs)
    path = bld_save_fs.leaf.path(bld_locs)
    print('Build Path for Partition Functions in species block')
    print(path)
    proj_file_path = os.path.join(path, 'RPHt_input_data.dat')
    with open(proj_file_path, 'w') as proj_file:
        proj_file.write(projrot_inp_str)

    script.run_script(script.PROJROT, path)

    freqs = []
    zpe_har_no_tors = 0.
    # har_zpe = 0.
    if pot:
        rthrproj_freqs, _ = projrot_io.reader.rpht_output(path +
                                                          '/hrproj_freq.dat')
        freqs = rthrproj_freqs
        zpe_har_no_tors = sum(freqs) * phycon.WAVEN2KCAL / 2.
    rtproj_freqs, imag_freq = projrot_io.reader.rpht_output(path +
                                                            '/RTproj_freq.dat')
    # har_zpe = sum(rtproj_freqs)*phycon.WAVEN2KCAL/2.
    if not freqs:
        freqs = rtproj_freqs
    if saddle:
        if imag_freq:
            imag_freq = imag_freq[0]
        else:
            imag_freq = freqs[-1]
            freqs = freqs[:-1]

    return freqs, imag_freq, zpe_har_no_tors
Beispiel #5
0
def projrot_frequencies(geo, hess, thy_level, thy_run_fs):
    """ Get the projected frequencies from projrot code
    """
    projrot_script_str = script.PROJROT

    # Write the string for the ProjRot input
    thy_run_fs.leaf.create(thy_level[1:4])
    thy_run_path = thy_run_fs.leaf.path(thy_level[1:4])

    coord_proj = 'cartesian'
    grad = ''
    rotors_str = ''
    projrot_inp_str = projrot_io.writer.rpht_input(geo,
                                                   grad,
                                                   hess,
                                                   rotors_str=rotors_str,
                                                   coord_proj=coord_proj)

    bld_locs = ['PROJROT', 0]
    bld_run_fs = autofile.fs.build(thy_run_path)
    bld_run_fs.leaf.create(bld_locs)
    projrot_path = bld_run_fs.leaf.path(bld_locs)

    proj_file_path = os.path.join(projrot_path, 'RPHt_input_data.dat')
    with open(proj_file_path, 'w') as proj_file:
        proj_file.write(projrot_inp_str)

    script.run_script(projrot_script_str, projrot_path)

    imag_freq = ''
    if os.path.exists(projrot_path + '/hrproj_freq.dat'):
        rthrproj_freqs, imag_freq = projrot_io.reader.rpht_output(
            projrot_path + '/hrproj_freq.dat')
        proj_freqs = rthrproj_freqs
    else:
        rtproj_freqs, imag_freq = projrot_io.reader.rpht_output(
            projrot_path + '/RTproj_freq.dat')
        proj_freqs = rtproj_freqs
    print(proj_freqs)
    return proj_freqs, imag_freq
Beispiel #6
0
def run_pf(pf_path, pf_script_str=script.MESSPF):
    """ run messpf
    """
    script.run_script(pf_script_str, pf_path)