CDTK.Tools.NormalCoordinates module

class CDTK.Tools.NormalCoordinates.Coordinate(massWeighted=False, massWeightedAu=False, angstrom=None, masses=None, coordinates=None, symbols=None)[source]

Bases: object

List of numbers representing a vector in Cartesian space It can represent a geometry, normal mode, or in general anything that can be represented by a set of coordinates. Can also contain the masses related to those coordinates. Uses numpy.array to store coordinates and other information. - Atributes: massWeighted – Boolean, tells if the coordinates are in mass weighted cartesians angstrom – Boolean, tells if the coordinates are in angstroms coordinates – array, the coordinates masses – masses corresponding to each coordinate, in AMU

getCoordinates()[source]

Return A COPY of the coordinates array

getMasses()[source]

Return A COPY of the masses array

getSymbols()[source]

Return A COPY of the list of atomic symbols

massFromGaussian(f)[source]

Get mass from a Gaussian log file. Store in self.mass f – full path to a gaussian log file

module()[source]

Return module of coordinates array

setAngstrom(m)[source]

Sets the angstrom attribute m – False or True

setCoordinates(x)[source]

Expects array o list. Stores it as the coordinates of mode x – array or list object

setMassWeighted(m)[source]

Sets the massWeighted attribute m – False or True

setMassWeightedAu(m)[source]

Sets the massWeighted attribute m – False or True

setMasses(x)[source]

Expects array o list. Stores it as the masses of mode x – array or list object

setSymbols(s)[source]

Set the list of atomic symbols

symbolsFromGaussian(f)[source]

Get the atomic symbols from a gaussian file, put them on list

toAngstroms()[source]

Coordinates from au to angstroms

toAu()[source]

Coordinates from angstroms to au

toMassWeighted(au=0)[source]

Transforms the coordinates to mass weighted au = 0, use AMU as units of mass au = 1, use au as units of mass, 1 AMU = 1822.89 au

unweightCoordinates()[source]

Transforms the coordinates from mass weighted to normal cartesian

class CDTK.Tools.NormalCoordinates.NormalMode(massWeighted=False, massWeightedAu=False, angstrom=None, masses=None, coordinates=None, symbols=None)[source]

Bases: Coordinate

Stores a normal mode and provides methods to interact with it. Uses numpy.array to store coordinates and other information.

getModeNumber()[source]

Return mode number

modeFromGaussian(file, i)[source]

Get the coordinates of a mode from a gaussian log file and stores them as an array them self.coordinates file – full path to the gaussian frequency file i – index of the normal mode to retrieve

modeReducedMass()[source]

Return the mode reduced mass in AMU, the same as given by Gaussian.

normalize()[source]

Normalizes the coordinates array to a length of 1

setModeNumber(i)[source]

Sets modenumber attribute

toMassWeighted()[source]

Transforms the coordinates to mass weighted. Specializes by also normalizing the mode.

unweightCoordinates()[source]

Transforms the coordinates from mass weighted to normal cartesian Specializes by also normalizing the mode.

class CDTK.Tools.NormalCoordinates.Projector(x=None)[source]

Bases: object

Define a projector, basically a matrix to be applied on the form D=P.M.P where P is the projector and M a matrix

conjugateSpace()[source]

Return a projector on the conjugate space of self Return 1-P where P is the projector in self and 1 is the identity

fromArray(x)[source]

Set the projector corresponding to an array as P=V.V+ where V is a column vector and V+ is a row vector

getMat()[source]

Return a copy of self.mat

setMat(m)[source]

Set the atribute self.mat with the given matrix m

class CDTK.Tools.NormalCoordinates.XYZGeometry(massWeighted=False, massWeightedAu=False, angstrom=None, masses=None, coordinates=None, symbols=None)[source]

Bases: Coordinate

Stores a geometry. Uses numpy.array

cartHessian(func, step=0.01)[source]

Return a matrix (array type) with the Hessian in mw coords

cartMassWeightHessian(func, step=0.1, au=0)[source]

Return a matrix (array type) with the Hessian in mw coords func – returns the potential step – step to take in the derivatives (bohr) au = 0, hessian is weighted in AMU (default) au = 1, hessian is weighted in au, 1 AMU = 1822.89 au

centerMolecule()[source]

Center the center of mass of the molecule to the origin

centerOfMass()[source]

Return a 3 components vector with the center of mass of the molecule

coordinatesToFile(f)[source]

Write the coordinates to a file in XYZ format

The coordinates are written always in angstroms

energy(func)[source]

Returns the energy corresponding to the current coordinates

Is resposibility of the caller to ensure that the XYZGeometry object has the coordinates in the correct units before calling the getEnergy method. func – function to be used in the evaluation of the energy

frequencyFromMode(func, mode, step=0.1)[source]

Frequency in cm-1 for a given mode at the current geometry

remember, this quantity is only menaniful in a stationary point func – function returning the energy mode – NormalMode specifying the direction to follow step – step for the numerical derivative

geomFromGaussian(file)[source]

Get the coordinates from a gaussian log file and stores them in Coordinate.coordinates file – full path to the gaussian frequency file

gradient(func, modes, step=0.1)[source]

Return a list with the numerical derivatives in the directions of the modes stored in the list modes

func – function returning the energy modes – list of NormalMode specifying the directions to follow step – step for the numerical derivative

gradientElement(func, mode, step=0.1)[source]

Return the derivative in the direction of the given normal mode

func – function returning the energy mode – NormalMode specifying the direction to follow step – step for the numerical derivative

hessian(func, modes, step=0.1)[source]

Return a list of lists with the crossed derivatives with respect to all the modes in the list modes

func – function returning the energy modes – list of NormalMode specifying the directions to follow step – step for the numerical derivative

hessianElement(func, mode1, mode2, step=0.1)[source]

Return the second crossed derivative of a function with respect to two modes (Hessian matrix element).

func – function returning the energy mode1 – NormalMode specifying the direction to follow mode2 – NormalMode specifying the direction to follow step – step for the numerical derivative

momentsOfInertia()[source]

Return a 3x3 matrix where the vectors v[:,i] are the moments of inertia that diagonalize the inertia tensor

projectionToModeS(xref, modes)[source]

Return an array with the projection of the current geometry into the given normal modes

xref – XYZGeometry object or array with the reference geometry modes – list of the normal modes to be projected

projectorRot()[source]

Return a projector to eliminate rotations

projectorTrans()[source]

Return a projector to eliminate translations

projectorTransRot()[source]

Return a projector to eliminate rotations and translations

translate(vec)[source]

Translate the system according to the given 3D vector

CDTK.Tools.NormalCoordinates.aunits2wavenumber(d, mu=1.0)[source]

Transform a second derivative in atomic units to the corresponding vibrational frequency in cm-1

CDTK.Tools.NormalCoordinates.centerOfMass(xs, m)[source]

Return 3D array with the center of mass

xs – list or array of 3D arrays with the positions of the atoms m – list or array with the mass of each atom in xs note: units are arbitrary

CDTK.Tools.NormalCoordinates.closeListOfFiles(filelist)[source]

Closes all the files in a list of file objects

filelist can be a single file or a nested structure of lists of lists of files down to any depth

CDTK.Tools.NormalCoordinates.inertiaTensor(x, m)[source]

Return a 3x3 matrix with the inertia tensor corresponding to the configuration x and masses m

CDTK.Tools.NormalCoordinates.modesOrthonormalization(modes)[source]

Given a list of normal mode objects, orthonormalize them

CDTK.Tools.NormalCoordinates.openOutputFileList0(name, modes, access='w')[source]

Return a file name – basename to use to name the files modes – modes with respect to which gradients and hessians will be evaluated

CDTK.Tools.NormalCoordinates.openOutputFileList1(name, modes, access='w')[source]

Return list of files, one for each mode, ex. to store gradients name – basename to use to name the files modes – modes with respect to which gradients and hessians will be evaluated

CDTK.Tools.NormalCoordinates.openOutputFiles(name, modes, access='w')[source]

Return 3 lists with the energy, gradient, and hessian file objects name – basename to use to name the files modes – modes with respect to which gradients and hessians will be evaluated

CDTK.Tools.NormalCoordinates.openOutputFilesProd(name, modes, access='w')[source]

Return 4 lists with the energy, hessian, hessian*q and q*hessian*q file objects name – basename to use to name the files modes – modes with respect to which gradients and hessians will be evaluated

CDTK.Tools.NormalCoordinates.outputEnerToFiles(coords, ener, file)[source]

Prints energy to file

CDTK.Tools.NormalCoordinates.outputGradToFiles(coords, grad, file)[source]

Print derivative with respect to all modes to the corresponding files

CDTK.Tools.NormalCoordinates.outputHessToFiles(coords, hess, file)[source]

Print crossed derivative with respect to each pair of mode to files

CDTK.Tools.NormalCoordinates.rangeOfModesFromGaussian(f, i, j)[source]

Return a list of normalMode objects

f – full path to the file containing the modes i – integer, first mode to retrieve j – integer, last mode to retrieve

Beware of the index conventions in Python, the last index in a range(i,j) is not considered part of the sequence. This is not so in this function.

CDTK.Tools.NormalCoordinates.rangeOfModesFromMatrix(h, m=None, freqs=0, omegas=0, mw=0, minnum=1)[source]

From a matrix diagonalize and get the normal modes Assume that h is a mass weighted hessian, diagonalize it and return the corresponding normal modes as normalized cartesian displacements (the same thing as gaussian does) h – hessian matrix m – masses of the system, necessary to transform from normal modes to cartesian displacements freqs = 0, do not return the list of frequencies freqs = 1, return as the second argument the list of frequencies in cm-1 omegas = 0, default omegas = 1, return a list with the square roots of the eigenvalues minnum = int, the mode from which ascendent numbering is assigned, minmum = 7 means that 6 modes are not numbered mw = 1, the normal modes are returned in mass-weighted coordinates

CDTK.Tools.NormalCoordinates.stringToFiles(string, filelist)[source]

Write string to all the files found in filelist

filelist can be a single file or a nested structure of lists of lists of files down to any depth