Esempio n. 1
0
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)
Esempio n. 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 = 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)
Esempio n. 3
0
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)
Esempio n. 4
0
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)
Esempio n. 5
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)
Esempio n. 6
0
def input_file(ranseed,
               nsamp,
               smin,
               smax,
               target_xyz_name,
               bath_xyz_name,
               spin_method=2):
    """ writes the 1dmin input file for each instance
    """

    assert isinstance(ranseed, int)  # check size of seed?
    assert isinstance(nsamp, int)
    assert target_xyz_name.endswith('.xyz')
    assert bath_xyz_name.endswith('.xyz')
    assert isinstance(smin, float)
    assert isinstance(smax, float)

    # Set the dictionary for the 1DMin input file
    inp_keys = {
        "ranseed": ranseed,
        "nsamples": nsamp,
        "target_xyz_name": target_xyz_name,
        "bath_xyz_name": bath_xyz_name,
        "smin": smin,
        "smax": smax,
        "spin_method": spin_method
    }

    return build_mako_str(template_file_name='onedmin_inp.mako',
                          template_src_path=TEMPLATE_PATH,
                          template_keys=inp_keys)
Esempio n. 7
0
def collision_frequency(eps1, eps2, sig1, sig2, mass1, mass2):
    """ Writes the energy transfer section of the MESS input file by
        formatting input information into strings a filling Mako template.

        :param eps1: A+A Lennard-Jones epsilon parameter of spc 1 (cm-1)
        :type eps1: float
        :param eps2: A+A Lennard-Jones epsilon parameter of spc 2 (cm-1)
        :type eps2: float
        :param sig1: A+A Lennard-Jones sigma parameter of spc 1 (Angstrom)
        :type sig1: float
        :param sig2: A+A Lennard-Jones sigma parameter of spc 2 (Angstrom)
        :type sig2: float
        :param mass1: mass of Species 1 (amu)
        :type mass1: float
        :param mass2: mass of Species 2 (amu)
        :type mass2: float
        :rtype: string
    """

    # Convert LJ units and format them into string
    eps_str = f'{eps1*phycon.EH2WAVEN:<10.3f} {eps2*phycon.EH2WAVEN:<10.3f}'
    sig_str = f'{sig1*phycon.BOHR2ANG:<10.3f} {sig2*phycon.BOHR2ANG:<10.3f}'
    mass_str = f'{mass1:<10.3f} {mass2:<10.3f}'

    # Create dictionary to fill template
    etrans_keys = {
        'epsilons': eps_str,
        'sigmas': sig_str,
        'masses': mass_str
    }

    return build_mako_str(
        template_file_name='collid_freq.mako',
        template_src_path=ENE_TRANS_PATH,
        template_keys=etrans_keys)
Esempio n. 8
0
def dummy(dummy_label, aux_id_label=None, zero_ene=None):
    """ Writes the string that defines the `Dummy` section,
        for dummy reaction products, for a MESS input file by
        formatting input information into strings a filling Mako template.

        :param dummy_label: label for dummy product used by MESS
        :type dummy_label: str
        :rtype: str
    """

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

    # Format energy string if needed
    if zero_ene is not None:
        zero_ene = f'{zero_ene:6.2f}'

    # Create dictionary to fill template
    dummy_keys = {
        'dummy_label': full_label,
        'aux_id_label': aux_id_label,
        'zero_ene': zero_ene
    }

    return build_mako_str(template_file_name='dummy.mako',
                          template_src_path=RXNCHAN_PATH,
                          template_keys=dummy_keys)
Esempio n. 9
0
def input_file(data_train, data_test, num_write, units, range_parameter,
               ref_energy, num_ranges, energy_ranges, num_atoms, symbols,
               atom_groups, read_basis, factor_order, total_order, imode,
               num_channels, fragment_groups):
    """ writes the PIPPy input file for each instance
    """

    # Set the dictionary for the PIPPy input file
    inp_keys = {
        'DataTrain': data_train,
        'DataTest': data_test,
        'NumWrite': num_write,
        'Units': units,
        'RangeParameter': range_parameter,
        'RefEnergy': ref_energy,
        'NumRanges': num_ranges,
        'EnergyRanges': energy_ranges,
        'NumAtoms': num_atoms,
        'Symbols': symbols,
        'AtomGroups': atom_groups,
        'ReadBasis': read_basis,
        'FactorOrder': factor_order,
        'TotalOrder': total_order,
        'IMode': imode,
        'NumChannels': num_channels,
        'FragmentGroups': fragment_groups
    }

    return build_mako_str(template_file_name='pippy_inp.mako',
                          template_src_path=TEMPLATE_PATH,
                          template_keys=inp_keys)
Esempio n. 10
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)
Esempio n. 11
0
def fluxional_mode(atom_indices, span=360.0):
    """ Writes the string that defines the `FluxionalMode` section for a
        single fluxional mode (torsion) of a species for a MESS input file by
        formatting input information into strings a filling Mako template.

        :param atom_idxs: idxs of atoms involved in fluxional mode
        :type atom_indices: list(int)
        :param span: range from 0.0 to value that mode was sampled over (deg.)
        :type span: float
        :rtype: str
    """

    # Format the aotm indices string
    atom_indices = util.format_flux_mode_indices(atom_indices)

    # Create dictionary to fill template
    flux_mode_keys = {
        'atom_indices': atom_indices,
        'span': span,
    }

    return build_mako_str(
        template_file_name='fluxional_mode.mako',
        template_src_path=MONTE_CARLO_PATH,
        template_keys=flux_mode_keys)
Esempio n. 12
0
def rotor_bundle(enegrid_step=5.0,
                 enegrid_max=50.0,
                 quantm_st_max=100.0,
                 mc_samp_size=2000.0):
    """ Write a HinderedRotor Bundle string

        :param gride_step: (cm-1)
        :type gride_step: float
        :param gride_max: (kcal/mol)
        :type gride_max: float
        :param quantm_st_max: (kcal/mol)
        :type quantm_st_max: float
        :param mc_samp_size: ??
        :type mc_samp_size: ??
        :param grid
    """

    # Set the Monte Carlo List (just num of flux modes?)
    mc_modes_lst = []

    # Create dictionary to fill template
    rotor_keys = {
        'enegrid_step': enegrid_step,
        'enegrid_max': enegrid_max,
        'quantm_st_max': quantm_st_max,
        'mc_mods_lst': mc_modes_lst,
        'mc_samp_size': mc_samp_size
    }

    return build_mako_str(template_file_name='rotor_bundle.mako',
                          template_src_path=SPEC_INFO_PATH,
                          template_keys=rotor_keys)
Esempio n. 13
0
def tunnel_read(imag_freq, tunnel_file, cutoff_energy=2500.0):
    """ Writes the string that defines the 'Tunneling' section for a
        small curvature tunneling model for a transition state
        for a MESS input file by formatting input information into
        strings a filling Mako template. Currently requires an additional
        auxiliary data file for transmission probabilities generated by
        ProjRot code.

        :param imag_freq: imaginary frequency of the TS
        :type imag_freq: float
        :param tunnel_file: name of data file with transmission probabilities
        :type tunnel_file: str
        :param cutoff_energy: energy to include tunneling density (kcal.mol-1)
        :type cutoff_energy: float
        :rtype: str
    """

    # Format the imaginary frequency value
    imag_freq = f'{imag_freq:<8.0f}'

    # Create dictionary to fill template
    tunnel_keys = {
        'imag_freq': imag_freq,
        'cutoff_energy': cutoff_energy,
        'tunnel_file': tunnel_file
    }

    return build_mako_str(
        template_file_name='tunnel_read.mako',
        template_src_path=SPEC_INFO_PATH,
        template_keys=tunnel_keys)
Esempio n. 14
0
def elec_struct(exe_path, lib_path, base_name, npot,
                dummy_name='dummy_corr_', lib_name='libcorrpot.so',
                geom_ptt='GEOMETRY_HERE', ene_ptt='molpro_energy'):
    """ Writes the electronic structure code input file for VaReCoF
        Currently code only runs with Molpro
        :rtype: string
    """

    # Write the correction potential strings
    pot_path = os.path.join(lib_path, lib_name)
    pot_params_str = ''
    for i in range(npot):
        pot_params_str += '{0:<42s}{1:<8d}\n'.format(base_name+'_corr_', 1)
        pot_params_str += '{0:<42s}{1:<8d}\n'.format('ParameterInteger', i+1)
    pot_params_str += '{0:<42s}{1:<8d}\n'.format(dummy_name, 1)

    # Create dictionary to fill template
    els_keys = {
        'exe_path': exe_path,
        'geom_ptt': geom_ptt,
        'ene_ptt': ene_ptt,
        'base_name': base_name,
        'pot_path': pot_path,
        'pot_params_str': pot_params_str
    }

    return build_mako_str(
        template_file_name='els.mako',
        template_src_path=TEMPLATE_PATH,
        template_keys=els_keys)
Esempio n. 15
0
def core_rigidrotor(geo, sym_factor, interp_emax=None):
    """ Writes the string that defines the 'Core' section for a
        rigid-rotor model of a species for a MESS input file by
        formatting input information into strings a filling Mako template.

        :param geo: geometry of species
        :type geo: list
        :param sym_factor: symmetry factor of species
        :type sym_factor: float
        :param interp_emax: max energy to calculate num. of states (kcal.mol-1)
        :type interp_emax: float
        :rtype: str
    """

    # Format the geometry section
    natom, geo = messformat.geometry_format(geo)

    # Create dictionary to fill template
    core_keys = {
        'sym_factor': sym_factor,
        'natom': natom,
        'geo': geo,
        'interp_emax': interp_emax
    }

    return build_mako_str(
        template_file_name='core_rigidrotor.mako',
        template_src_path=SPEC_INFO_PATH,
        template_keys=core_keys)
Esempio n. 16
0
def tunnel_eckart(imag_freq, well_depth1, well_depth2):
    """ Writes the string that defines the 'Tunneling' section for a
        Eckart tunneling model for a transition state for a MESS input file by
        formatting input information into strings a filling Mako template.

        :param imag_freq: imaginary frequency of the TS
        :type imag_freq: float
        :param well_depth1: energy difference: E[TS] - E[reactant well]
        :type well_depth1: float
        :param well_depth2: energy difference: E[TS] - E[product well]
        :type well_depth2: float
        :rtype: str
    """

    # Format the imaginary frequency and well-depth values
    imag_freq = f'{imag_freq:<8.0f}'
    well_depth1 = f'{well_depth1:<8.2f}'
    well_depth2 = f'{well_depth2:<8.2f}'

    # Create dictionary to fill template
    tunnel_keys = {
        'imag_freq': imag_freq,
        'well_depth1': well_depth1,
        'well_depth2': well_depth2
    }

    return build_mako_str(
        template_file_name='tunnel_eckart.mako',
        template_src_path=SPEC_INFO_PATH,
        template_keys=tunnel_keys)
Esempio n. 17
0
def submission_script(njobs, run_dir, exe_path):
    """ Writes a special BASH submission script for launching
        parallel instances of OneDMin.

        :param njobs: number of OneDMin processes to run
        :type njobs: int
        :param run_dir: directory to run each OneDMin process
        :type run_dir: str
        :param exe_path: full path to the OneDMin executable
        :type exe_path: str
        :rtype: str
    """

    # Write the string for running all of the job lines
    # job_lines = 'mkdir -p {0}/run1\n'.format(run_dir)
    job_lines = 'cd {0}/run1\n'.format(run_dir)
    job_lines += 'time $ONEDMINEXE < input.dat > output.dat &\n'
    for i in range(njobs - 1):
        # job_lines += 'mkdir -p ../run{0}\n'.format(str(i+2))
        job_lines += 'cd ../run{0}\n'.format(str(i + 2))
        job_lines += 'time $ONEDMINEXE < input.dat > output.dat &\n'
    job_lines += 'wait\n'

    # Set the dictionary for the 1DMin input file
    exe_keys = {"exe_path": exe_path, "job_lines": job_lines}

    return build_mako_str(template_file_name='onedmin_sub.mako',
                          template_src_path=TEMPLATE_PATH,
                          template_keys=exe_keys)
Esempio n. 18
0
def core_rotd(sym_factor, flux_file_name, stoich):
    """ Writes the string that defines the `Core` section for a
        variational reaction-coordinate transition-state theory model of a
        transition state for a MESS input file by
        formatting input information into strings a filling Mako template.

        :param sym_factor: symmetry factor of transition state
        :type sym_factor: float
        :param flux_file_name:
        :type flux_file_name: str
        :param stoich: combined stoichiometry of dissociation species 1 and 2
        :type stoich: str
        :rtype: str
    """

    # Create dictionary to fill template
    core_keys = {
        'sym_factor': sym_factor,
        'flux_file_name': flux_file_name,
        'stoich': stoich
    }

    return build_mako_str(
        template_file_name='core_rotd.mako',
        template_src_path=SPEC_INFO_PATH,
        template_keys=core_keys)
Esempio n. 19
0
def collision_frequency(eps1, eps2, sig1, sig2, mass1, mass2):
    """ Writes the energy transfer section of the MESS input file by
        formatting input information into strings a filling Mako template.

        :param eps1: A+A Lennard-Jones epsilon parameter of spc 1 (cm-1)
        :type eps1: float
        :param eps2: A+A Lennard-Jones epsilon parameter of spc 2 (cm-1)
        :type eps2: float
        :param sig1: A+A Lennard-Jones sigma parameter of spc 1 (Angstrom)
        :type sig1: float
        :param sig2: A+A Lennard-Jones sigma parameter of spc 2 (Angstrom)
        :type sig2: float
        :param mass1: mass of Species 1 (amu)
        :type mass1: float
        :param mass2: mass of Species 2 (amu)
        :type mass2: float
        :rtype: string
    """

    # Put the values into a string
    epsilon_str = '{0:<10.3f} {1:<10.3f}'.format(eps1, eps2)
    sigma_str = '{0:<10.3f} {1:<10.3f}'.format(sig1, sig2)
    mass_str = '{0:<10.3f} {1:<10.3f}'.format(mass1, mass2)

    # Create dictionary to fill template
    etrans_keys = {
        'epsilons': epsilon_str,
        'sigmas': sigma_str,
        'masses': mass_str
    }

    return build_mako_str(template_file_name='collid_freq.mako',
                          template_src_path=ENE_TRANS_PATH,
                          template_keys=etrans_keys)
Esempio n. 20
0
def rpht_input(geoms, grads, hessians,
               saddle_idx=1,
               rotors_str='',
               coord_proj='cartesian',
               proj_rxn_coord=False):
    """ Writes a string for the input file for ProjRot.

        :param geoms: geometry for single species or along a reaction path
        :type geoms: list(list(float))
        :param grads: gradient for single species or along a reaction path
        :type grads: list(list(float))
        :param hessians: Hessian for single species or along a reaction path
        :type hessians: list(list(float))
        :param saddle_idx: idx denoting the saddle point along a reaction path
        :type saddle_idx: int
        :param rotors_str: ProjRot-format string with all the rotor definitions
        :type rotors_str: str
        :param coord_proj: choice of coordinate system to perform projections
        :type coord_proj: str
        :param proj_rxn_coord: whether to project out reaction coordinate
        :type proj_rxn_coord: bool
        :rtype: str
    """

    # Format the molecule info
    data_str = util.write_data_str(geoms, grads, hessians)
    natoms = len(geoms[0])
    # nsteps = len(geoms)
    nrotors = rotors_str.count('pivotA')

    # Check input into the function (really fix calls to not have this)
    if not isinstance(geoms, list):
        geoms = [geoms]
    if not isinstance(grads, list):
        grads = [grads]
    if not isinstance(hessians, list):
        hessians = [hessians]

    nsteps = len(geoms)
    assert nsteps == len(hessians)
    if len(grads) != 0:
        assert len(grads) == nsteps
    assert coord_proj in ('cartesian', 'internal')

    # Create a fill value dictionary
    rpht_keys = {
        'natoms': natoms,
        'nsteps': nsteps,
        'saddle_idx': saddle_idx,
        'coord_proj': coord_proj,
        'proj_rxn_coord': proj_rxn_coord,
        'nrotors': nrotors,
        'rotors_str': rotors_str,
        'data_str': data_str
    }

    return build_mako_str(
        template_file_name='rpht_input.mako',
        template_src_path=TEMPLATE_PATH,
        template_keys=rpht_keys)
Esempio n. 21
0
def structure(geo1, geo2):
    """ Writes the structure input file for VaReCoF
        :param list geo1: geometry of fragment 1
        :param list geo2: geometry of fragment 2
        :rtype: string
    """

    # Determine linearity of molecule
    struct_type1 = util.determine_struct_type(geo1)
    struct_type2 = util.determine_struct_type(geo2)

    # Format the coordinates of the geoetry
    natoms1, coords1 = util.format_coords(geo1)
    natoms2, coords2 = util.format_coords(geo2)

    # Create dictionary to fill template
    struct_keys = {
        'struct_type1': struct_type1,
        'natoms1': natoms1,
        'coords1': coords1,
        'struct_type2': struct_type2,
        'natoms2': natoms2,
        'coords2': coords2,
    }

    return build_mako_str(template_file_name='struct.mako',
                          template_src_path=TEMPLATE_PATH,
                          template_keys=struct_keys)
Esempio n. 22
0
def energy_down(exp_factor, exp_power, exp_cutoff):
    """ Writes the energy transfer section of the MESS input file by
        formatting input information into strings a filling Mako template.

        :param exp_factor: 300 K energy-down value for collision model (cm-1)
        :type exp_factor: float
        :param exp_power: n, for [energy-down * (T/300K)^n] for collision model
        :type exp_power: float
        :param exp_cutoff: cutoff for assuming transition probability is zero
        :type exp_cutoff: float
        :rtype: string
    """

    # Put the values into a string
    exp_factor_str = '{0:<10.3f}'.format(exp_factor)
    exp_power_str = '{0:<10.3f}'.format(exp_power)
    exp_cutoff_str = '{0:<10.3f}'.format(exp_cutoff)

    # Create dictionary to fill template
    etrans_keys = {
        'exp_factor': exp_factor_str,
        'exp_power': exp_power_str,
        'exp_cutoff': exp_cutoff_str
    }

    return build_mako_str(template_file_name='edown.mako',
                          template_src_path=ENE_TRANS_PATH,
                          template_keys=etrans_keys)
Esempio n. 23
0
def makefile(fortran_compiler, pot_file_names=()):
    """ Writes string for a makefile to compile correction potentials.

        :param fortran_compiler: name of compiler to build potentials
        :type fortran_compiler: str
        :param pot_file_names: names of files with various potentials
        :type: pot_file_names: list(str)
        :return: string for the makefile
        :rtype: string
    """

    # Set species name
    corr_potential_names = ''
    if pot_file_names:
        for potential in pot_file_names:
            corr_potential_names += f'{potential}_corr.f '

    # Create dictionary to fill template
    make_keys = {
        'fc': fortran_compiler,
        'corr_potential_names': corr_potential_names
    }

    return build_mako_str(template_file_name='makefile.mako',
                          template_src_path=TEMPLATE_PATH,
                          template_keys=make_keys)
Esempio n. 24
0
def tml(memory, basis, wfn, method, inf_sep_energy):
    """ writes the tml file used as the template for the electronic structure
        calculation
        currently, we assume the use of molpro
        in particular: method and wfn assume molpro input card structure
    """

    # convert the memory
    memory_mw = int(memory * (1024.0 / 8.0))

    # make the infinite seperation energy positive
    inf_sep_energy *= -1.0

    # Create dictionary to fill template
    tml_keys = {
        'memory': memory_mw,
        'basis': basis,
        'method': method,
        'wfn': wfn,
        'inf_sep_energy': inf_sep_energy
    }

    return build_mako_str(
        template_file_name='tml.mako',
        template_src_path=TEMPLATE_PATH,
        template_keys=tml_keys)
Esempio n. 25
0
def tst(nsamp_max,
        nsamp_min,
        flux_err,
        pes_size,
        faces=(0, ),
        faces_symm=1,
        ener_grid=(),
        amom_grid=()):
    """ Writes the tst.inp file for VaReCoF
        :param nsamp_max: maximum number of samples
        :type nsamp_max: int
        :param nsamp_min: minimum number of samples
        :type nsamp_min: int
        :param flux_err: allowed error in flux during sampling
        :type flux_err: float
        :param pes_size: number of PESs in the calculation ?
        :type pes_size: int
        :param faces: inde ?
        :type fascs: list(int)
        :param faces_symm: indices noting symmetry of face
        :type faces_symm: list(int)
        :param list ener_grid:
        :type ener_grid: list(float)
        :param amom_grid:
        :type amom_grid: list(float)
        :rtype: str
    """

    # Set the energy and angular momentum grids
    if not ener_grid:
        ener_grid = [0, 10, 1.05, 179]
    else:
        assert len(ener_grid) == 4
    if not amom_grid:
        amom_grid = [0, 4, 1.10, 40]
    else:
        assert len(amom_grid) == 4
    ener_grid = util.format_grids_string(ener_grid, 'ener', 'Kelvin')
    amom_grid = util.format_grids_string(amom_grid, 'amom', 'Kelvin')

    # Set the faces
    print(faces)
    faces = util.format_faces_string(faces)

    # Create dictionary to fill template
    tst_keys = {
        'ener_grid': ener_grid,
        'amom_grid': amom_grid,
        'nsamp_max': nsamp_max,
        'nsamp_min': nsamp_min,
        'flux_err': flux_err,
        'pes_size': pes_size,
        'faces': faces,
        'faces_symm': faces_symm
    }

    return build_mako_str(template_file_name='tst.mako',
                          template_src_path=TEMPLATE_PATH,
                          template_keys=tst_keys)
Esempio n. 26
0
def input_file(job_type,
               geo,
               zero_ene,
               ene_grid=100.0,
               ene_max=50000.0,
               ang_grid=6,
               ang_max=300,
               h_so=20.0,
               qe_scale_factor=3.0,
               cuts=False,
               comment=None):
    """ Writes a string for the input file for NST.

        :param geo: guess geometry for a NST TS
        :type geo: automol.geom object
        :param job_type: NST job to run
        :type job_type: str
        :param geo: geometry of transition state
        :type geo: automol.geom object
        :param zero_ene: energy at infinite separation (in Hartrees)
        :type zero_ene: float
        :param ene_gro: Energy grid spacing (cm-1)
        :param ene_max: maximum grid energy (cm-1)
        :param so_coup: Spin-orbit coupling in cm-1
        :param so_scale: scaling factor for state counts in output
        :param cuts: cuts along vibrational modes (only for HESSC and HESSR)
        :param comment: comment line at top of file
        :rtype: str
    """

    # Format the molecule info
    natoms, geo_str, mass_str = format_geometry(geo)

    # Format flags
    cuts_flag = 'T' if cuts else 'F'

    # Format comment line
    comment = comment if comment is not None else 'NST Run'

    # Create a fill value dictionary
    inp_keys = {
        'comment': comment,
        'job_type': job_type,
        'natoms': natoms,
        'geo_str': geo_str,
        'mass_str': mass_str,
        'zero_ene': zero_ene,
        'ene_grid': ene_grid,
        'ene_max': ene_max,
        'ang_grid': ang_grid,
        'ang_max': ang_max,
        'h_so': h_so,
        'qe_scale_factor': qe_scale_factor,
        'cuts_flag': cuts_flag,
    }

    return build_mako_str(template_file_name='input.mako',
                          template_src_path=TEMPLATE_PATH,
                          template_keys=inp_keys)
Esempio n. 27
0
def rotor_hindered(group,
                   axis,
                   symmetry,
                   potential,
                   remdummy=None,
                   geom=None,
                   use_quantum_weight=False,
                   rotor_id=''):
    """ Writes the string that defines the `Rotor` section for a
        single hindered rotor of a species for a MESS input file by
        formatting input information into strings a filling Mako template.

        :param group: idxs for the atoms of one of the rotational groups
        :type group: list(int)
        :param axis: idxs for the atoms that make up the rotational axis
        :type axis: list(int)
        :param symmetry: overall symmetry of the torsional motion (potential)
        :type symmetry: int
        :param potential: value of the potential along torsion (kcal.mol-1)
        :type potential: list(float)
        :param remdummy: list of idxs of dummy atoms for shifting values
        :type remdummy: list(int)
        :param geom: geometry of the species the rotor exists for
        :type geom: list
        :param use_quantum_weight: toggle weigthing of quantum effects
        :type use_quantum_weight: bool
        :param rotor_id: name associated with the rotor
        :type rotor_id: str
        :rtype: str
    """

    # Format the rotor sections
    rotor_group = util.format_rotor_key_defs(group, remdummy)
    rotor_axis = util.format_rotor_key_defs(axis, remdummy)
    rotor_npotential, rotor_potential = util.format_rotor_potential(potential)

    # Format the geom
    natom = 1
    if geom is not None:
        natom, geom = util.geom_format(geom)
        geom = indent(geom, 4)

    # Create dictionary to fill template
    rotor_keys = {
        'group': rotor_group,
        'axis': rotor_axis,
        'symmetry': symmetry,
        'npotential': rotor_npotential,
        'potential': rotor_potential,
        'natom': natom,
        'geom': geom,
        'use_quantum_weight': use_quantum_weight,
        'rotor_id': rotor_id
    }

    return build_mako_str(template_file_name='rotor_hindered.mako',
                          template_src_path=SPEC_INFO_PATH,
                          template_keys=rotor_keys)
Esempio n. 28
0
def core_phasespace(geom1,
                    geom2,
                    sym_factor,
                    stoich,
                    pot_prefactor=10.0,
                    pot_exp=6.0,
                    tstlvl='e'):
    """ Writes the string that defines the `Core` section for a
        phase space theory model of a transition state for a MESS input file by
        formatting input information into strings a filling Mako template.

        :param geom1: geometry of the dissociation species 1
        :type geom1: list
        :param geom2: geometry of the dissociation species 2
        :type geom2: list
        :param sym_factor: symmetry factor of transition state
        :type sym_factor: float
        :param stoich: combined stoichiometry of dissociation species 1 and 2
        :type stoich: str
        :param pot_prefator: factor C0 in potential expression V = -C0/R^n (au)
        :type pot_prefactor: float
        :param pot_exp: power n in potential expression V = -C0/R^n (au)
        :type pot_exp: float
        :param tstlvl: level to resolve the rate constant
        :type tstlvl: str
        :rtype: str
    """

    assert tstlvl in ('e', 'ej', 't')

    # Format the geometry section of each fragment
    natom1, geom1 = util.geom_format(geom1)
    natom2, geom2 = util.geom_format(geom2)

    # Indent the geometry strings
    geom1 = indent(geom1, 2)
    geom2 = indent(geom2, 2)

    # Format the tstlvl string
    assert tstlvl in ('e', 'ej', 't')
    tstlvl = tstlvl.upper()

    # Create dictionary to fill template
    core_keys = {
        'sym_factor': sym_factor,
        'natom1': natom1,
        'geom1': geom1,
        'natom2': natom2,
        'geom2': geom2,
        'stoich': stoich,
        'pot_prefactor': pot_prefactor,
        'pot_exp': pot_exp,
        'tstlvl': tstlvl
    }

    return build_mako_str(template_file_name='core_phasespace.mako',
                          template_src_path=SPEC_INFO_PATH,
                          template_keys=core_keys)
Esempio n. 29
0
def dummy():
    """ Writes string for the dummy correction potential Fortran file.

        :rtype: string
    """

    return build_mako_str(template_file_name='dummy_corr.mako',
                          template_src_path=TEMPLATE_PATH,
                          template_keys={})
Esempio n. 30
0
def auxiliary():
    """ Writes string for the potential auxiliary functions Fortran file.

        :rtype: string
    """

    return build_mako_str(template_file_name='pot_aux.mako',
                          template_src_path=TEMPLATE_PATH,
                          template_keys={})