Exemple #1
0
def configs_union(mol_data_strs, zero_enes, tunnel_strs=None):
    """ Writes the string that defines the `Union` section, containing
        multiple configurations for a given species, for a MESS input file by
        formatting input information into strings a filling Mako template.

        :param mol_data_strs: MESS strings with data for all configurations
        :type mol_data_strs: list(str)
        :rtype: str
    """

    # Build the zero energy strings and add them to the union strings
    union_data = ''
    for idx, (union_str, zero_ene) in enumerate(zip(mol_data_strs, zero_enes)):
        zero_ene_str = messformat.zero_energy_format(zero_ene)
        zero_ene_str = messformat.indent(zero_ene_str, 2)

        union_data += union_str
        union_data += zero_ene_str
        if tunnel_strs is not None:
            _tunnel_str = f'\n{tunnel_strs[idx]}\nEnd  ! Tunnel\n'
            union_data += messformat.indent(_tunnel_str, 2)
        union_data += '\n\n'
        union_data += f'End  ! Union{idx+1}\n'

    # Concatenate all of the molecule strings
    union_data = messformat.indent(union_data, 2)

    # Create dictionary to fill template
    union_keys = {'union_data': union_data}

    return build_mako_str(template_file_name='union.mako',
                          template_src_path=RXNCHAN_PATH,
                          template_keys=union_keys)
Exemple #2
0
def bimolecular(bimol_label, species1_label, species1_data, species2_label,
                species2_data, ground_energy):
    """ Writes a Bimolecular section.
    """

    # Indent the string containing all of data for each species
    species1_data = messformat.indent(species1_data, 4)
    species2_data = messformat.indent(species2_data, 4)

    # Determine if species is an atom
    isatom1 = messformat.is_atom_in_str(species1_data)
    isatom2 = messformat.is_atom_in_str(species2_data)

    # Format the precision of the ground energy
    ground_energy = '{0:<8.2f}'.format(ground_energy)

    # Create dictionary to fill template
    bimol_keys = {
        'bimolec_label': bimol_label,
        'species1_label': species1_label,
        'species1_data': species1_data,
        'isatom1': isatom1,
        'species2_label': species2_label,
        'species2_data': species2_data,
        'isatom2': isatom2,
        'ground_energy': ground_energy
    }

    return build_mako_str(template_file_name='bimolecular.mako',
                          template_src_path=RXNCHAN_PATH,
                          template_keys=bimol_keys)
Exemple #3
0
def ts_sadpt(ts_label,
             reac_label,
             prod_label,
             ts_data,
             aux_id_label=None,
             zero_ene=None,
             tunnel=''):
    """ Writes the string that defines the `Barrier` section for
        for a given transition state, modeled as a PES saddle point,
        for fixed transition state theory. MESS input file string built by
        formatting input information into strings a filling Mako template.

        :param ts_label: label for input TS used by MESS
        :type ts_label: str
        :param reac_label: label for reactant connected to TS used by MESS
        :type reac_label: str
        :param prod_label: label for product connected to TS used by MESS
        :type prod_label: str
        :param ts_data: MESS string with required electronic structure data
        :type ts_data: str
        :param aux_id_label: label for additional species ID information
        :type aux_id_label: str
        :param zero_ene: elec+zpve energy relative to PES reference
        :type zero_ene: float
        :param tunnel: `Tunnel` section MESS-string for TS
        :type tunnel: str
        :rtype: str
    """

    # Format the label
    rxn_label = f'{ts_label} {reac_label} {prod_label}'
    full_label = messformat.mess_label_format(rxn_label,
                                              aux_id_label=aux_id_label,
                                              calc_dens=False)

    # Indent the string containing all of data for the saddle point
    ts_data = messformat.indent(ts_data, 2)
    if tunnel != '':
        tunnel = messformat.indent(tunnel, 4)

    # Format the precision of the zero energy
    if zero_ene is not None:
        zero_ene = f'{zero_ene:<8.2f}'

    # Create dictionary to fill template
    ts_sadpt_keys = {
        'rxn_label': full_label,
        'ts_data': ts_data,
        'aux_id_label': aux_id_label,
        'zero_ene': zero_ene,
        'tunnel': tunnel
    }

    return build_mako_str(template_file_name='ts_sadpt.mako',
                          template_src_path=RXNCHAN_PATH,
                          template_keys=ts_sadpt_keys)
Exemple #4
0
def ts_variational(ts_label,
                   reac_label,
                   prod_label,
                   rpath_strs,
                   zero_enes=None,
                   tunnel=''):
    """ Writes the string that defines the `Barrier` section for
        for a given transition state, modeled using points along reaction path,
        for varational transition state theory. MESS input file string built by
        formatting input information into strings a filling Mako template.

        :param ts_label: label for input TS used by MESS
        :type ts_label: str
        :param reac_label: label for reactant connected to TS used by MESS
        :type reac_label: str
        :param prod_label: label for product connected to TS used by MESS
        :type prod_label: str
        :param rpath_pt_strs: MESS strings for each point on reaction path
        :type rpath_pt_strs: list(str)
        :param tunnel: `Tunnel` section MESS-string for TS
        :type tunnel: str
        :rtype: str
    """

    assert len(rpath_strs) == len(zero_enes), (
        'Number of rpath strings ({})'.format(len(rpath_strs)),
        'and zero energies ({}) do not match'.format(len(zero_enes)))

    # Build the zero energy strings and add them to the rpath strings
    full_rpath_str = ''
    for rpath_str, zero_ene in zip(rpath_strs, zero_enes):
        zero_ene_str = messformat.zero_energy_format(zero_ene)
        zero_ene_str = messformat.indent(zero_ene_str, 2)

        full_rpath_str += rpath_str
        full_rpath_str += zero_ene_str
        full_rpath_str += '\n\n'
        full_rpath_str += 'End  ! RPATH PT\n'

    # Concatenate all of the variational point strings and indent them
    ts_data = messformat.indent(full_rpath_str, 4)
    if tunnel != '':
        tunnel = messformat.indent(tunnel, 4)

    # Create dictionary to fill template
    var_keys = {
        'ts_label': ts_label,
        'reac_label': reac_label,
        'prod_label': prod_label,
        'ts_data': ts_data,
        'tunnel': tunnel
    }

    return build_mako_str(template_file_name='ts_var.mako',
                          template_src_path=RXNCHAN_PATH,
                          template_keys=var_keys)
Exemple #5
0
def bimolecular(bimol_label,
                spc1_label,
                spc1_data,
                spc2_label,
                spc2_data,
                ground_ene,
                auxbimol_id_label=None,
                aux1_id_label=None,
                aux2_id_label=None,
                calc_spc1_density=False,
                calc_spc2_density=False):
    """ Writes a Bimolecular section.
    """

    # Format the labels
    full_bimol_label = messformat.mess_label_format(
        bimol_label, aux_id_label=auxbimol_id_label, calc_dens=False)
    full_spc1_label = messformat.mess_label_format(spc1_label,
                                                   aux_id_label=aux1_id_label,
                                                   calc_dens=calc_spc1_density)
    full_spc2_label = messformat.mess_label_format(spc2_label,
                                                   aux_id_label=aux2_id_label,
                                                   calc_dens=calc_spc2_density)

    # Indent the string containing all of data for each species
    spc1_data = messformat.indent(spc1_data, 4)
    spc2_data = messformat.indent(spc2_data, 4)

    # Determine if species is an atom
    isatom1 = messformat.is_atom_in_str(spc1_data)
    isatom2 = messformat.is_atom_in_str(spc2_data)

    # Format the precision of the ground energy
    ground_ene = f'{ground_ene:<8.2f}'

    # Create dictionary to fill template
    bimol_keys = {
        'bimolec_label': full_bimol_label,
        'spc1_label': full_spc1_label,
        'spc1_data': spc1_data,
        'isatom1': isatom1,
        'spc2_label': full_spc2_label,
        'spc2_data': spc2_data,
        'isatom2': isatom2,
        'ground_ene': ground_ene
    }

    return build_mako_str(template_file_name='bimolecular.mako',
                          template_src_path=RXNCHAN_PATH,
                          template_keys=bimol_keys)
Exemple #6
0
def species(spc_label, spc_data, zero_ene=None):
    """ Writes the string that defines the `Species` section for
        for a given species for a MESS input file by
        formatting input information into strings a filling Mako template.

        :param spc_label: label for input species used by MESS
        :type spc_label: str
        :param spc_data: MESS string with required electronic structure data
        :type spc_data: str
        :param zero_ene: elec+zpve energy relative to PES reference
        :rtype: str
    """

    # Indent the string containing all of data for the well
    spc_data = messformat.indent(spc_data, 2)

    # Format the precision of the zero energy
    if zero_ene is not None:
        zero_ene = '{0:<8.2f}'.format(zero_ene)

    # Create dictionary to fill template
    spc_keys = {
        'spc_label': spc_label,
        'spc_data': spc_data,
        'zero_ene': zero_ene
    }

    return build_mako_str(template_file_name='species.mako',
                          template_src_path=RXNCHAN_PATH,
                          template_keys=spc_keys)
Exemple #7
0
def well(well_label,
         well_data,
         zero_ene=None,
         edown_str=None,
         collid_freq_str=None):
    """ Writes the string that defines the `Well` section for
        for a given species for a MESS input file by
        formatting input information into strings a filling Mako template.

        :param well_label: label for input well used by MESS
        :type well_label: str
        :param well_data: MESS string with required electronic structure data
        :type well_data: str
        :param zero_ene: elec+zpve energy relative to PES reference
        :param edown_str: String for the energy down parameters
        :type edown_str: str
        :param collid_freq_str: String for the collisional freq parameters
        :type collid_freq_str: str
        :rtype: str
    """

    # Indent the string containing all of data for the well
    well_data = messformat.indent(well_data, 4)

    # Format the precision of the zero energy
    if zero_ene is not None:
        zero_ene = '{0:<8.2f}'.format(zero_ene)

    # Indent the energy transfer parameter strings if needed
    if edown_str is not None:
        edown_str = messformat.indent(edown_str, 4)
    if collid_freq_str is not None:
        collid_freq_str = messformat.indent(collid_freq_str, 4)

    # Create dictionary to fill template
    well_keys = {
        'well_label': well_label,
        'well_data': well_data,
        'zero_ene': zero_ene,
        'edown_str': edown_str,
        'collid_freq_str': collid_freq_str
    }

    return build_mako_str(template_file_name='well.mako',
                          template_src_path=RXNCHAN_PATH,
                          template_keys=well_keys)
Exemple #8
0
def configs_union(mol_data_strs, zero_enes, tunnel_strs=None):
    """ Writes the string that defines the `Union` section, containing
        multiple configurations for a given species, for a MESS input file by
        formatting input information into strings a filling Mako template.

        :param mol_data_strs: MESS strings with data for all configurations
        :type mol_data_strs: list(str)
        :rtype: str
    """

    # Build the zero energy strings and add them to the union strings
    union_data = ''
    for idx, (union_str, zero_ene) in enumerate(zip(mol_data_strs, zero_enes)):
        zero_ene_str = messformat.zero_energy_format(zero_ene)
        zero_ene_str = messformat.indent(zero_ene_str, 2)

        union_data += union_str
        union_data += zero_ene_str
        if tunnel_strs is not None:
            union_data += '\n' + tunnel_strs[idx] + '\n'
        union_data += '\n\n'
        union_data += 'End  ! Union1\nEnd  ! Union2\n'

    # Add 'End' statment to each of the data strings
    # mol_data_strs = [string+'End  ! UnionN' for string in mol_data_strs]
    # mol_data_strs[-1] += '\n'

    # Concatenate all of the molecule strings
    # union_data = '\n'.join(mol_data_strs)
    union_data = messformat.indent(union_data, 2)

    # Add the tunneling string (seems tunneling goes for all TSs in union)
    # if tunnel != '':
    #     tunnel = messformat.indent(tunnel, 4)

    # Create dictionary to fill template
    union_keys = {'union_data': union_data}

    return build_mako_str(template_file_name='union.mako',
                          template_src_path=RXNCHAN_PATH,
                          template_keys=union_keys)
def mc_species(geo,
               sym_factor,
               elec_levels,
               flux_mode_str,
               data_file_name,
               ref_config_file_name='',
               ground_ene=None,
               reference_ene=None,
               freqs=(),
               use_cm_shift=False):
    """ Writes a monte carlo species section

        :param geo: geometry of species
        :type geo: list
        :param sym_factor: symmetry factor of species
        :type sym_factor: float
        :param elec_levels: energy and degeneracy of atom's electronic states
        :type elec_levels: list(float)
        :param flux_mode_str: MESS-format `FluxionalMode` sections for rotors
        :type flux_mode_str: str
        :param data_file_name: Name of data file with molecular info
        :type data_file_name: str
        :param ground_ene: energy relative to reference n PES (kcal.mol-1)
        :type ground_ene: float
        :param reference_ene: harmonic ZPVE used for MC PF (kcal.mol-1)
        :type reference_ene: float
        :param freqs: vibrational frequencies (cm-1)
        :type freqs: list(float)
        :param use_cm_chift: signal to include a CM shift
        :type use_cm_shift: bool
        :rtype: str
    """

    # Format the molecule specification section
    atom_list = messformat.molec_spec_format(geo)

    # Build a formatted frequencies and elec levels string
    nlevels, levels = messformat.elec_levels_format(elec_levels)
    levels = indent(levels, 2)
    if freqs:
        nfreqs, freqs = messformat.freqs_format(freqs)
    else:
        nfreqs = 0

    # Check if reference config name is present
    if nfreqs > 0:
        assert ref_config_file_name, (
            'Must provide a reference configuration file if no Hessians given')

    # Indent various strings string if needed
    flux_mode_str = messformat.indent(flux_mode_str, 4)

    # Create dictionary to fill template
    monte_carlo_keys = {
        'atom_list': atom_list,
        'sym_factor': sym_factor,
        'flux_mode_str': flux_mode_str,
        'data_file_name': data_file_name,
        'ref_config_file_name': ref_config_file_name,
        'reference_ene': reference_ene,
        'ground_ene': ground_ene,
        'nlevels': nlevels,
        'levels': levels,
        'nfreqs': nfreqs,
        'freqs': freqs,
        'use_cm_shift': use_cm_shift
    }

    return build_mako_str(template_file_name='monte_carlo.mako',
                          template_src_path=MONTE_CARLO_PATH,
                          template_keys=monte_carlo_keys)
Exemple #10
0
def molecule(core,
             elec_levels,
             freqs=(),
             hind_rot='',
             xmat=(),
             rovib_coups=(),
             rot_dists=(),
             inf_intens=(),
             freq_scale_factor=None,
             use_harmfreqs_key=False):
    """ Writes the string that defines the `Species` section
        for a molecule for a MESS input file by
        formatting input information into strings and filling Mako template.

        :param core: `Core` section string in MESS format
        :type core: str
        :param elec_levels: energy and degeneracy of atom's electronic states
        :type elec_levels: list(float)
        :param freqs: Harmonic/Anharmonic vibrational frequencies
        :type freqs: list(float)
        :param elec_levels: energy and degeneracy of atom's electronic states
        :param hind_rot: string of MESS-format `Rotor` sections for all rotors
        :type hind_rot: str
        :param xmat: anharmonicity matrix (cm-1)
        :type xmat: list(list(float))
        :param inf_intens: Harmonic Infrared Intensities for vibrational modes
        :type inf_intens: list(float)
        :param rovib_coups: rovibrational coupling matrix
        :type rovib_coups: numpy.ndarray
        :param rot_dists: rotational distortion constants: [['aaa'], [val]]
        :type rot_dists: list(list(str), list(float))
        :rtype: str
    """

    # Add in infrared intensities at some point

    # Build formatted frequencies, infrared intensities and elec levels string
    nfreqs, freqs = messformat.freqs_format(freqs)
    nintens, intens = messformat.intensities_format(inf_intens)
    nlevels, levels = messformat.elec_levels_format(elec_levels)

    # Format the rovib couplings and rotational distortions if needed
    if rovib_coups:
        rovib_coups = messformat.format_rovib_coups(rovib_coups)
    else:
        rovib_coups = ''
    if rot_dists:
        rot_dists = messformat.format_rot_dist_consts(rot_dists)
    else:
        rot_dists = ''
    if xmat:
        anharm = messformat.format_xmat(xmat)
    else:
        anharm = ''

    # Indent various strings string if needed
    if hind_rot != '':
        hind_rot = messformat.indent(hind_rot, 2)

    # Create dictionary to fill template
    molec_keys = {
        'core': core,
        'nlevels': nlevels,
        'levels': levels,
        'nfreqs': nfreqs,
        'freqs': freqs,
        'hind_rot': hind_rot,
        'anharm': anharm,
        'nintens': nintens,
        'intens': intens,
        'rovib_coups': rovib_coups,
        'rot_dists': rot_dists,
        'freq_scale_factor': freq_scale_factor,
        'use_harmfreqs_key': use_harmfreqs_key
    }

    return build_mako_str(template_file_name='molecule.mako',
                          template_src_path=SPECIES_PATH,
                          template_keys=molec_keys)
Exemple #11
0
def well(well_label,
         well_data,
         aux_id_label=None,
         zero_ene=None,
         well_cap=None,
         edown_str=None,
         collid_freq_str=None):
    """ Writes the string that defines the `Well` section for
        for a given species for a MESS input file by
        formatting input information into strings a filling Mako template.

        :param well_label: label for input well used by MESS
        :type well_label: str
        :param well_data: MESS string with required electronic structure data
        :type well_data: str
        :param aux_id_label: label for additional species ID information
        :type aux_id_label: str
        :param zero_ene: elec+zpve energy relative to PES reference
        :type zero_ene: float
        :param well_cap: value for the well extension cap keyword
        :type well_cap: float
        :param edown_str: String for the energy down parameters
        :type edown_str: str
        :param collid_freq_str: String for the collisional freq parameters
        :type collid_freq_str: str
        :rtype: str
    """

    # Format the label
    full_label = messformat.mess_label_format(well_label,
                                              aux_id_label=aux_id_label,
                                              calc_dens=False)

    # Indent the string containing all of data for the well
    well_data = messformat.indent(well_data, 4)

    # Format the precision of the zero energy and well extension cap
    if zero_ene is not None:
        zero_ene = f'{zero_ene:<8.2f}'
    if well_cap is not None:
        well_cap = f'{well_cap:<8.2f}'

    # Indent the energy transfer parameter strings, if needed
    if edown_str is not None:
        edown_str = messformat.indent(edown_str, 4)
    if collid_freq_str is not None:
        collid_freq_str = messformat.indent(collid_freq_str, 4)

    # Create dictionary to fill template
    well_keys = {
        'well_label': full_label,
        'well_data': well_data,
        'zero_ene': zero_ene,
        'well_cap': well_cap,
        'edown_str': edown_str,
        'collid_freq_str': collid_freq_str
    }

    return build_mako_str(template_file_name='well.mako',
                          template_src_path=RXNCHAN_PATH,
                          template_keys=well_keys)