pygauss.molecule module

Created on Fri May 01 21:24:31 2015

@author: chris

class pygauss.molecule.Molecule(folderpath='', init_fname=False, opt_fname=False, freq_fname=False, nbo_fname=False, pes_fname=False, fail_silently=False, atom_groups={}, alignto=[], server=None, username=None, passwrd=None, folder_obj=None)[source]

Bases: object

a class to analyse gaussian input/output of a single molecular geometry

Parameters:
  • folderpath (str) – the folder path
  • init_fname (str) – the intial geometry (.com) file
  • opt_fname (str or list of str) – the optimisation log file
  • freq_fname (str) – the frequency analysis log file
  • nbo_fname (str) – the population analysis logfile
  • pes_fname (str) – the potential energy scan logfile
  • fail_silently (bool) – whether to raise an error if a file read fails (if True can use get_init_read_errors to see errors)
  • atom_groups ({str:[int, ...]}) – groups of atoms that can be selected as a subset
  • alignto ([int, int, int]) – the atom numbers to align the geometry to

Notes

any of the file names can have wildcards (e.g. ‘filename*.log) in them, as long as this resolves to a single path in the directory

NB: nbo population analysis must be run with the GFInput flag to ensure data is output to the log file

add_frequency(file_name)[source]
add_initialgeom(file_name)[source]
add_nbo_analysis(file_name)[source]
add_optimisation(file_name)[source]
add_pes_analysis(file_names)[source]
calc_2plane_angle(p1, p2, optimisation=True)[source]

return angle of planes

calc_bond_angle(indxs, optimisation=True, mol=None)[source]

Returns the angle in degrees between three points

calc_dihedral_angle(indxs, optimisation=True, mol=None)[source]

Returns the angle in degrees between four points

calc_hbond_energy(atom_groups=[], eunits='kJmol-1')[source]
calc_min_dist(idx_list1, idx_list2, optimisation=True, units='nm', ignore_missing=True)[source]

indexes start at 1

calc_nbo_charge(atoms=[])[source]

returns total charge of the atoms

calc_nbo_charge_center(p1, p2, p3, positive=True, units='nm', atoms=[])[source]

returns the distance r amd angles theta, phi of the positive/negative charge center to the circumcenter of the plane formed by [p1, p2, p3]

the plane formed will have;
x-axis along p1, y-axis anticlock-wise towards p2, z-axis normal to the plane

theta (azimuth) is the in-plane angle from the x-axis towards the y-axis phi (inclination) is the out-of-plane angle from the x-axis towards the z-axis

calc_opt_trajectory(atom, plane=[])[source]

calculate the trajectory of an atom as it is optimised, relative to a plane of three atoms

calc_polar_coords_from_plane(p1, p2, p3, c, optimisation=True, units='nm')[source]

returns the distance r and angles theta, phi of atom c to the circumcenter of the plane formed by [p1, p2, p3]

the plane formed will have;
x-axis along p1, y-axis anticlock-wise towards p2, z-axis normal to the plane

theta (azimuth) is the in-plane angle from the x-axis towards the y-axis phi (inclination) is the out-of-plane angle from the x-axis towards the z-axis

calc_sopt_energy(atom_groups=[], eunits='kJmol-1', no_hbonds=False)[source]

calculate total energy of interactions between “filled” (donor) Lewis-type Natural Bonding Orbitals (NBOs) and “empty” (acceptor) non-Lewis NBOs, using Second Order Perturbation Theory

Parameters:
  • eunits (str) – the units of energy to return
  • atom_groups ([list or str, list or str]) – restrict interactions to between two lists (or identifiers) of atom indexes
  • no_hbonds (bool) – whether to ignore H-Bonds in the calculation
Returns:

analysis – a table of interactions

Return type:

pandas.DataFrame

combine_molecules(other_mol, self_atoms=False, other_atoms=False, self_rotation=[0, 0, 0], other_rotation=[0, 0, 0], self_transpose=[0, 0, 0], other_transpose=[0, 0, 0], self_opt=True, other_opt=True, charge=None, multiplicity=None, out_name=False, descript='', overwrite=False, active=False, represent='ball_stick', rotations=[[0.0, 0.0, 0.0]], zoom=1.0, width=300, height=300, axis_length=0, ipyimg=True, folder_obj=None)[source]

transpose in nanometers

get_atom_group(group)[source]

return list of atoms in group

get_basis_descript()[source]
get_basis_funcs()[source]
get_folder()[source]

return the Folder instance

get_freq_analysis()[source]

return frequency analysis

Returns:data – frequency data
Return type:pandas.DataFrame
get_hbond_analysis(min_energy=0.0, atom_groups=[], eunits='kJmol-1')[source]

EXPERIMENTAL! hydrogen bond analysis (DH—A), using Second Order Bond Perturbation Theiry

Parameters:
  • min_energy (float) – the minimum interaction energy to report
  • eunits (str) – the units of energy to return
  • atom_groups ([list or str, list or str]) – restrict interactions to between two lists (or identifiers) of atom indexes
Returns:

analysis – a table of interactions

Return type:

pandas.DataFrame

Notes

uses a strict definition of a hydrogen bond as: interactions between “filled” (donor) Lewis-type Lone Pair (LP) NBOs and “empty” (acceptor) non-Lewis Bonding (BD) NBOs

get_init_read_errors()[source]

get read errors, recorded if fail_silently was set to True on initialise

get_opt_energy(units='eV', final=True, zpe_correct=False)[source]

return the SCF optimisation energy(s)

Parameters:
  • units (str) – the unit type of the energy
  • final (bool) – return only the final optimised energy if True, else for all steps
  • zpe_correct (bool) – apply zero-point energy correction (found in frequency log) to final optimised energy
Returns:

energy – dependant on final

Return type:

float or list of floats

get_orbital_count()[source]

return number of orbitals

get_orbital_energies(orbitals, eunits='eV')[source]

the orbital energies for listed orbitals

Parameters:
  • orbitals (int or iterable of ints) – the orbital(s) to return energies for (starting at 1)
  • eunits (str) – the units of energy
Returns:

moenergies – energy for each orbital

Return type:

numpy.array

get_orbital_homo_lumo()[source]

return orbital numbers of homo and lumo

get_run_error(rtype='opt')[source]

True if there were errors in the computation, else False

get_sopt_analysis(eunits='kJmol-1', atom_groups=[], charge_info=False)[source]

interactions between “filled” (donor) Lewis-type Natural Bonding Orbitals (NBOs) and “empty” (acceptor) non-Lewis NBOs, using Second Order Perturbation Theory (SOPT)

Parameters:
  • eunits (str) – the units of energy to return
  • atom_groups ([list or str, list or str]) – restrict interactions to between two lists (or identifiers) of atom indexes
  • charge_info (bool) – include charge info for atoms (under headings ‘A_Charges’ and ‘D_Charges’)
Returns:

analysis – a table of interactions

Return type:

pandas.DataFrame

get_zeropt_energy(units='eV')[source]

return the zero-point energy correction

Parameters:units (str) – the unit type of the energy
Returns:energy – zero-point energy correction
Return type:float
is_conformer(cutoff=0.0)[source]

False if any frequencies in the frequency analysis were negative

is_optimised()[source]

was the geometry optimised

plot_dos(eunits='eV', per_energy=1.0, lbound=None, ubound=None, color_homo='g', color_lumo='r', homo_lumo_lines=True, homo_lumo_values=True, band_gap_value=True, legend_size=10, ax=None)[source]

plot Density of States and HOMO/LUMO gap

Parameters:
  • eunits (str) – unit of energy
  • per_energy (float) – energy interval to group states by
  • lbound (float) – lower bound energy
  • ubound (float) – upper bound energy
  • color_homo (matplotlib.colors) – color of homo in matplotlib format
  • color_lumo (matplotlib.colors) – color of lumo in matplotlib format
  • homo_lumo_lines (bool) – draw lines at HOMO and LUMO energies
  • homo_lumo_values (bool) – annotate HOMO and LUMO lines with exact energy values
  • band_gap_value (bool) – annotate inbetween HOMO and LUMO lines with band gap value
  • legend_size (int) – the font size (in pts) for the legend
  • ax (matplotlib.Axes) – an existing axes to plot the data on
Returns:

plot – plotted optimisation data

Return type:

matplotlib.axes.Axes

plot_freq_analysis(color='blue', alpha=1, marker_size=20, ax=None)[source]

plot frequency analysis

Returns:data – plotted frequency data
Return type:matplotlib.axes.Axes
plot_opt_energy(units='eV', linecolor='blue', ax=None)[source]

plot SCF optimisation energy

Returns:data – plotted optimisation data
Return type:matplotlib.axes.Axes
plot_opt_trajectory(atom, plane=[], ax_lims=None, ax_labels=False)[source]

plot the trajectory of an atom as it is optimised, relative to a plane of three atoms

plot_pes_scans(fixed_atoms, eunits='kJmol-1', img_pos='', rotation=[0.0, 0.0, 0.0], zoom=1, order=1)[source]

plot Potential Energy Scan

Parameters:
  • img_pos (<’‘,’local_mins’,’local_maxs’,’global_min’,’global_max’>) – position image(s) of molecule conformation(s) on plot
  • rotation ([float, float, float]) – rotation of molecule image(s)
remove_alignment_atoms()[source]
set_alignment_atoms(idx1, idx2, idx3)[source]
show_active_orbital(orbital, iso_value=0.03, alpha=0.5, bond_color=(255, 0, 0), antibond_color=(0, 255, 0), gbonds=True)[source]

get interactive representation of orbital

Parameters:
  • orbital (int) – the orbital to show (in range 1 to number of orbitals)
  • iso_value (float) – The value for which the function should be constant.
  • alpha – alpha value of iso-surface
  • bond_color – color of bonding orbital surface in RGB format
  • antibond_color – color of anti-bonding orbital surface in RGB format
  • gbonds (bool) – guess bonds between atoms (via distance)
show_hbond_analysis(min_energy=0.0, atom_groups=[], cutoff_energy=0.0, eunits='kJmol-1', bondwidth=5, gbonds=True, active=False, represent='ball_stick', rotations=[[0.0, 0.0, 0.0]], zoom=1.0, width=300, height=300, axis_length=0, lines=[], relative=False, minval=-1, maxval=1, alpha=0.5, transparent=True, ipyimg=True)[source]

EXPERIMENTAL! hydrogen bond analysis DH—A

For a hydrogen bond to occur there must be both a hydrogen donor and an acceptor present. The donor in a hydrogen bond is the atom to which the hydrogen atom participating in the hydrogen bond is covalently bonded, and is usually a strongly electronegative atom such as N, O, or F. The hydrogen acceptor is the neighboring electronegative ion or molecule, and must posses a lone electron pair in order to form a hydrogen bond.

Since the hydrogen donor is strongly electronegative, it pulls the covalently bonded electron pair closer to its nucleus, and away from the hydrogen atom. The hydrogen atom is then left with a partial positive charge, creating a dipole-dipole attraction between the hydrogen atom bonded to the donor, and the lone electron pair on the acceptor.

show_highlight_atoms(atomlists, transparent=False, alpha=0.7, gbonds=True, active=False, optimised=True, represent='vdw', rotations=[[0.0, 0.0, 0.0]], zoom=1.0, width=300, height=300, axis_length=0, lines=[], ipyimg=True)[source]

show optimised geometry of molecule with certain atoms highlighted

show_initial(gbonds=True, active=False, represent='vdw', rotations=[[0.0, 0.0, 0.0]], zoom=1.0, width=300, height=300, axis_length=0, lines=[], ipyimg=True)[source]

show initial geometry (before optimisation) of molecule coloured by atom type

show_nbo_charges(gbonds=True, active=False, relative=False, minval=-1, maxval=1, represent='vdw', rotations=[[0.0, 0.0, 0.0]], zoom=1.0, width=300, height=300, axis_length=0, lines=[], ipyimg=True)[source]

show optimised geometry coloured by charge from nbo analysis

show_optimisation(opt_step=False, gbonds=True, active=False, represent='vdw', rotations=[[0.0, 0.0, 0.0]], zoom=1.0, width=300, height=300, axis_length=0, lines=[], ipyimg=True)[source]

show optimised geometry of molecule coloured by atom type

show_sopt_bonds(min_energy=20.0, cutoff_energy=0.0, atom_groups=[], bondwidth=5, eunits='kJmol-1', no_hbonds=False, gbonds=True, active=False, represent='ball_stick', rotations=[[0.0, 0.0, 0.0]], zoom=1.0, width=300, height=300, axis_length=0, lines=[], relative=False, minval=-1, maxval=1, alpha=0.5, transparent=True, ipyimg=True)[source]

visualisation of interactions between “filled” (donor) Lewis-type Natural Bonding Orbitals (NBOs) and “empty” (acceptor) non-Lewis NBOs, using Second Order Perturbation Theory

yield_orbital_images(orbitals, iso_value=0.02, extents=(2, 2, 2), transparent=True, alpha=0.5, wireframe=True, bond_color=(255, 0, 0), antibond_color=(0, 255, 0), resolution=100, gbonds=True, represent='ball_stick', rotations=[[0.0, 0.0, 0.0]], zoom=1.0, width=300, height=300, axis_length=0, lines=[], ipyimg=True)[source]

yield orbital images

Parameters:
  • orbitals (int or list of ints) – the orbitals to show (in range 1 to number of orbitals)
  • iso_value (float) – The value for which the function should be constant.
  • extents ((float, float, float)) – +/- x,y,z to extend the molecule geometrty when constructing the surface
  • transparent (bool) – whether iso-surface should be transparent (based on alpha value)
  • alpha – alpha value of iso-surface
  • wireframe – whether iso-surface should be wireframe (or solid)
  • bond_color – color of bonding orbital surface in RGB format
  • antibond_color – color of anti-bonding orbital surface in RGB format
  • resolution (int) – The number of grid point to use for the surface. An high value will give better quality but lower performance.
  • gbonds (bool) – guess bonds between atoms (via distance)
  • represent (str) – representation of molecule (‘none’, ‘wire’, ‘vdw’ or ‘ball_stick’)
  • zoom (float) – zoom level of images
  • width (int) – width of original images
  • height (int) – height of original images (although width takes precedent)
  • axis_length (float) – length of x,y,z axes in negative and positive directions
  • lines ([start_coord, end_coord, start_color, end_color, width, dashed]) – lines to add to image
  • ipyimg (bool) – whether to return an IPython image, PIL image otherwise
Returns:

mol – an image of the molecule in the format specified by ipyimg

Return type:

IPython.display.Image or PIL.Image

pygauss.molecule.orbit_z(self, angle)[source]