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 = util.indent(species1_data, 4) species2_data = util.indent(species2_data, 4) # Determine if species is an atom isatom1 = util.is_atom_in_str(species1_data) isatom2 = util.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)
def ts_variational(ts_label, reac_label, prod_label, irc_pt_strs, tunnel=''): """ Writes a TS section containing variational information """ # Concatenate all of the variational point strings and indent them ts_data = '\n'.join(irc_pt_strs) ts_data = util.indent(ts_data, 4) if tunnel != '': tunnel = util.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 } # Set template name and path for a TS with an variational template_file_name = 'ts_var.mako' template_file_path = os.path.join(RXNCHAN_PATH, template_file_name) # Build transition state with variational string var_str = Template(filename=template_file_path).render(**var_keys) return var_str
def ts_sadpt(ts_label, reac_label, prod_label, ts_data, zero_energy, tunnel=''): """ Writes a TS section containing only a saddle point """ # Indent the string containing all of data for the saddle point ts_data = util.indent(ts_data, 2) if tunnel != '': tunnel = util.indent(tunnel, 4) # Format the precision of the zero energy zero_energy = '{0:<8.2f}'.format(zero_energy) # Create dictionary to fill template ts_sadpt_keys = { 'ts_label': ts_label, 'reac_label': reac_label, 'prod_label': prod_label, 'ts_data': ts_data, 'zero_energy': zero_energy, 'tunnel': tunnel } # Set template name and path for a TS with only a single saddle point template_file_name = 'ts_sadpt.mako' template_file_path = os.path.join(RXNCHAN_PATH, template_file_name) # Build saddle point string sadpt_str = Template(filename=template_file_path).render(**ts_sadpt_keys) return sadpt_str
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 = util.zero_energy_format(zero_ene) zero_ene_str = util.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\n' # Concatenate all of the variational point strings and indent them ts_data = util.indent(full_rpath_str, 4) if tunnel != '': tunnel = util.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)
def ts_sadpt(ts_label, reac_label, prod_label, ts_data, zero_energy=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 zero_energy: elec+zpve energy relative to PES reference :type zero_energy: float :param tunnel: `Tunnel` section MESS-string for TS :type tunnel: str :rtype: str """ # Indent the string containing all of data for the saddle point ts_data = util.indent(ts_data, 2) if tunnel != '': tunnel = util.indent(tunnel, 4) # Format the precision of the zero energy if zero_energy is not None: zero_energy = '{0:<8.2f}'.format(zero_energy) # Create dictionary to fill template ts_sadpt_keys = { 'ts_label': ts_label, 'reac_label': reac_label, 'prod_label': prod_label, 'ts_data': ts_data, 'zero_energy': zero_energy, 'tunnel': tunnel } return build_mako_str(template_file_name='ts_sadpt.mako', template_src_path=RXNCHAN_PATH, template_keys=ts_sadpt_keys)
def species(spc_label, spc_data, zero_energy): """ 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_energy: elec+zpve energy relative to PES reference :rtype: str """ # Indent the string containing all of data for the well spc_data = util.indent(spc_data, 2) # Format the precision of the zero energy zero_energy = '{0:<8.2f}'.format(zero_energy) # Create dictionary to fill template spc_keys = { 'spc_label': spc_label, 'spc_data': spc_data, 'zero_energy': zero_energy } return build_mako_str(template_file_name='species.mako', template_src_path=RXNCHAN_PATH, template_keys=spc_keys)
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)
def well(well_label, well_data, zero_energy=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_energy: elec+zpve energy relative to PES reference :rtype: str """ # Indent the string containing all of data for the well well_data = util.indent(well_data, 4) # Format the precision of the zero energy if zero_energy is not None: zero_energy = '{0:<8.2f}'.format(zero_energy) # Create dictionary to fill template well_keys = { 'well_label': well_label, 'well_data': well_data, 'zero_energy': zero_energy } return build_mako_str(template_file_name='well.mako', template_src_path=RXNCHAN_PATH, template_keys=well_keys)
def well(well_label, well_data, zero_energy): """ Writes a well section. """ # Indent the string containing all of data for the well well_data = util.indent(well_data, 4) # Format the precision of the zero energy zero_energy = '{0:<8.2f}'.format(zero_energy) # Create dictionary to fill template well_keys = { 'well_label': well_label, 'well_data': well_data, 'zero_energy': zero_energy } # Set template name and path for a well template_file_name = 'well.mako' template_file_path = os.path.join(RXNCHAN_PATH, template_file_name) # Build well section string well_str = Template(filename=template_file_path).render(**well_keys) return well_str
def species(species_label, species_data, zero_energy): """ Writes a species section. """ # Indent the string containing all of data for the well species_data = util.indent(species_data, 2) # Format the precision of the zero energy zero_energy = '{0:<8.2f}'.format(zero_energy) # Create dictionary to fill template species_keys = { 'species_label': species_label, 'species_data': species_data, 'zero_energy': zero_energy } # Set template name and path for a species template_file_name = 'species.mako' template_file_path = os.path.join(RXNCHAN_PATH, template_file_name) # Build species section string species_str = Template(filename=template_file_path).render(**species_keys) return species_str
def monte_carlo(geom, formula, flux_mode_str, data_file_name, ground_energy, reference_energy): """ Writes a monte carlo species section """ # Format the molecule specification section natoms, atom_list = util.molec_spec_format(geom) # Indent various strings string if needed flux_mode_str = util.indent(flux_mode_str, 4) # Create dictionary to fill template monte_carlo_keys = { 'formula': formula, 'natoms': natoms, 'atom_list': atom_list, 'flux_mode_str': flux_mode_str, 'data_file_name': data_file_name, 'ground_energy': ground_energy, 'reference_energy': reference_energy } # Set template name and path for a monte carlo species section template_file_name = 'monte_carlo.mako' template_file_path = os.path.join(MONTE_CARLO_PATH, template_file_name) # Build monte carlo section string mc_str = Template(filename=template_file_path).render(**monte_carlo_keys) return mc_str
def configs_union(mol_data_strs): """ 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 """ # Add 'End' statment to each of the data strings mol_data_strs = [string + 'End' 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 = util.indent(union_data, 2) # Add the tunneling string (seems tunneling goes for all TSs in union) # if tunnel != '': # tunnel = util.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 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 = util.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 = util.indent(edown_str, 4) if collid_freq_str is not None: collid_freq_str = util.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)
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
def ts_variational(ts_label, reac_label, prod_label, rpath_pt_strs, 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 """ # Concatenate all of the variational point strings and indent them ts_data = '\n'.join(rpath_pt_strs) ts_data = util.indent(ts_data, 4) if tunnel != '': tunnel = util.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)
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 = util.indent(species1_data, 4) species2_data = util.indent(species2_data, 4) # Determine if species is an atom isatom1 = util.is_atom_in_str(species1_data) isatom2 = util.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 } # Set template name and path for a bimolecular set template_file_name = 'bimolecular.mako' template_file_path = os.path.join(RXNCHAN_PATH, template_file_name) # Build bimolecular section string bimol_str = Template(filename=template_file_path).render(**bimol_keys) return bimol_str
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)
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)