Example #1
0
def mc_species(geom, elec_levels,
               flux_mode_str, data_file_name,
               ground_energy, reference_energy,
               freqs=(), no_qc_corr=False, use_cm_shift=False):
    """ Writes a monte carlo species section

        :param core: `MonteCarlo` section string in MESS format
        :type core: str
        :param freqs: vibrational frequencies without fluxional mode (cm-1)
        :type freqs: list(float)
        :param elec_levels: energy and degeneracy of atom's electronic states
        :type elec_levels: list(float)
        :param hind_rot: string of MESS-format `Rotor` sections for all rotors
        :type hind_rot: str
        :param ground_energy: energy relative to reference (kcal.mol-1)
        :type ground_energy: float
        :param reference_energy: reference energy (kcal.mol-1)
        :type reference_energy: float
        :param freqs: vibrational frequencies (cm-1)
        :type freqs: list(float)
        :param no_qc_corr: signal to preclude quantum correction
        :type no_qc_corr: bool
        :param use_cm_chift: signal to include a CM shift
        :type use_cm_shift: bool
        :rtype: str
    """

    # Format the molecule specification section
    atom_list = util.molec_spec_format(geom)

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

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

    # Create dictionary to fill template
    monte_carlo_keys = {
        'atom_list': atom_list,
        'flux_mode_str': flux_mode_str,
        'data_file_name': data_file_name,
        'ground_energy': ground_energy,
        'nlevels': nlevels,
        'levels': levels,
        'nfreqs': nfreqs,
        'freqs': freqs,
        'reference_energy': reference_energy,
        'no_qc_corr': no_qc_corr,
        '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)
Example #2
0
def atom(mass, elec_levels):
    """ Writes the atom section of a MESS input file.
        :param int mass: mass of the atom (of desired isotope)
        :param list float elec_levels: energy and degeneracy of
                                       the atom's electronic states
        :return atom_str: String for the atom section
        :rtype: string
    """

    # Build a formatted elec levels string
    nlevels, levels = util.elec_levels_format(elec_levels)

    # Create dictionary to fill template
    atom_keys = {
        'mass': mass,
        'nlevels': nlevels,
        'levels': levels
    }

    # Set template name and path for an atom
    template_file_name = 'atom.mako'
    template_file_path = os.path.join(SPECIES_PATH, template_file_name)

    # Build atom string
    atom_str = Template(filename=template_file_path).render(**atom_keys)

    return atom_str
Example #3
0
def molecule(core, freqs, elec_levels,
             hind_rot='',
             xmat=None, rovib_coups='', rot_dists=''):
    """ Writes the molecule section of a MESS input file
        :param str core: string for the "Core" section written
                         by another mess_io function
        :param list freqs: vibrational frequencies for the molecule
        :param list float elec_levels: energy and degeneracy of
                                       the molecule's electronic states
        :return atom_str: String for the atom section
        :rtype: string
    """

    # Build a formatted frequencies and elec levels string
    nfreqs, freqs = util.freqs_format(freqs)
    nlevels, levels = util.elec_levels_format(elec_levels)

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

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

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

    # Set template name and path for a molecule
    template_file_name = 'molecule.mako'
    template_file_path = os.path.join(SPECIES_PATH, template_file_name)

    # Build molecule string
    molecule_str = Template(filename=template_file_path).render(**molec_keys)

    return molecule_str
Example #4
0
def atom(mass, elec_levels):
    """ Writes the string that defines the `Species` section
        for an atom for a MESS input file by
        formatting input information into strings and filling Mako template.

        :param mass: mass of the atom (of desired isotope)
        :type mass: int
        :param elec_levels: energy and degeneracy of atom's electronic states
        :type elec_levels: list(float)
        :rtype: str
    """

    # Build a formatted elec levels string
    nlevels, levels = util.elec_levels_format(elec_levels)

    # Create dictionary to fill template
    atom_keys = {'mass': mass, 'nlevels': nlevels, 'levels': levels}

    return build_mako_str(template_file_name='atom.mako',
                          template_src_path=SPECIES_PATH,
                          template_keys=atom_keys)
Example #5
0
def molecule(core,
             freqs,
             elec_levels,
             hind_rot='',
             xmat=(),
             rovib_coups=(),
             rot_dists=()):
    """ 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 freqs: vibrational frequencies
        :type freqs: list(float)
        :param elec_levels: energy and degeneracy of atom's electronic states
        :type elec_levels: list(float)
        :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 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 a formatted frequencies and elec levels string
    nfreqs, freqs = util.freqs_format(freqs)
    nlevels, levels = util.elec_levels_format(elec_levels)

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

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

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

    return build_mako_str(template_file_name='molecule.mako',
                          template_src_path=SPECIES_PATH,
                          template_keys=molec_keys)
Example #6
0
def mc_species(geom,
               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 core: `MonteCarlo` section string in MESS format
        :type core: str
        :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 = util.molec_spec_format(geom)

    # Build a formatted frequencies and elec levels string
    nlevels, levels = util.elec_levels_format(elec_levels)
    levels = indent(levels, 2)
    if freqs:
        nfreqs, freqs = util.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 = util.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)