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
  • of the file names can have wildcards (e.g. 'filename*.log) in them, (any) –
  • long as this resolves to a single path in the directory (as) –
  • NB (nbo population analysis must be run with the GFInput flag to ensure) –
  • is output to the log file (data) –
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_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:pd.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 (pandas.DataFrame) – a table of interactions
  • 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_optimisation_E(units='eV', final=True)[source]

return the SCF optimisation energy

Parameters:
  • units (str) – the unit type of the energy
  • final (bool) – return only the final optimised energy if True, else for all steps
Returns:

out – 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:

np.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

is_conformer(cutoff=0.0)[source]

False if any frequencies in the frequency analysis were negative

is_optimised()[source]

was the geometry optimised

plot_freq_analysis()[source]

plot frequency analysis

Returns:data – plotted frequency data
Return type:matplotlib.axes._subplots.AxesSubplot
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_optimisation_E(units='eV')[source]

plot SCF optimisation energy

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

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_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

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_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

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=True – 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]