Hessians#

Hessian diagonalisation and projection routines. See autode/common/hessians.pdf for mathematical background

class autode.hessians.Hessian(input_array: ~numpy.ndarray, units: ~autode.units.Unit | str = Unit(Ha Å^-2), atoms: Atoms | None = None, functional: ~autode.wrappers.keywords.keywords.Functional | None = None)#
copy(order='C')#

Return a copy of the array.

Parameters:

order ({'C', 'F', 'A', 'K'}, optional) – Controls the memory layout of the copy. ‘C’ means C-order, ‘F’ means F-order, ‘A’ means ‘F’ if a is Fortran contiguous, ‘C’ otherwise. ‘K’ means match the layout of a as closely as possible. (Note that this function and numpy.copy() are very similar but have different default values for their order= arguments, and this function always passes sub-classes through.)

See also

numpy.copy

Similar function with different default behavior

numpy.copyto

Notes

This function is the preferred method for creating an array copy. The function numpy.copy() is similar, but it defaults to using order ‘K’, and will not pass sub-classes through by default.

Examples

>>> x = np.array([[1,2,3],[4,5,6]], order='F')
>>> y = x.copy()
>>> x.fill(0)
>>> x
array([[0, 0, 0],
       [0, 0, 0]])
>>> y
array([[1, 2, 3],
       [4, 5, 6]])
>>> y.flags['C_CONTIGUOUS']
True

For arrays containing Python objects (e.g. dtype=object), the copy is a shallow one. The new array will contain the same object which may lead to surprises if that object can be modified (is mutable):

>>> a = np.array([1, 'm', [2, 3, 4]], dtype=object)
>>> b = a.copy()
>>> b[2][0] = 10
>>> a
array([1, 'm', list([10, 3, 4])], dtype=object)

To ensure all elements within an object array are copied, use copy.deepcopy:

>>> import copy
>>> a = np.array([1, 'm', [2, 3, 4]], dtype=object)
>>> c = copy.deepcopy(a)
>>> c[2][0] = 10
>>> c
array([1, 'm', list([10, 3, 4])], dtype=object)
>>> a
array([1, 'm', list([2, 3, 4])], dtype=object)
property frequencies: List[Frequency]#

Calculate the normal mode frequencies from the eigenvalues of the Hessian matrix

Raises:

(ValueError) – Without atoms set

property frequencies_proj: List[Frequency]#

Frequencies with rotation and translation projected out

Raises:

(ValueError) – Without atoms set

implemented_units: List[Unit] = [Unit(Ha Å^-2), Unit(Ha a0^-2), Unit(J m^-2), Unit(J ang^-2), Unit(J m^-2 kg^-1)]#
property n_tr: int#

5 for a linear molecule and 6 otherwise (3 rotation, 3 translation)

Raises:

(ValueError) – Without atoms set

property n_v: int#

3N-6 for a non-linear molecule with N atoms

Raises:

(ValueError) – Without atoms set

property normal_modes: List[Coordinates]#

Calculate the normal modes as the eigenvectors of the Hessian matrix

Raises:

(ValueError) – If atoms are not set

property normal_modes_proj: List[Coordinates]#

Normal modes from the projected Hessian without rotation or translation

class autode.hessians.HybridHessianCalculator(species: Species, idxs: Sequence[int], shift: Distance, lmethod: Method | None = None, hmethod: Method | None = None, n_cores: int | None = None)#

Calculator for a numerical Hessian evaluated at two levels of theory. One fast low level method to generate an estimate of the full Hessian, then one slow method used to evaluate numerical derivatives for only a few atoms. For example,

>>> import autode as ade
>>>
>>> water = ade.Molecule(smiles='O')
>>> dx = ade.values.Distance(0.001, units='Å')
>>> calculator = ade.hessians.HybridHessianCalculator(water,
                                                      idxs=(0,),
                                                      shift=dx)
>>> calculator.calculate()
__init__(species: Species, idxs: Sequence[int], shift: Distance, lmethod: Method | None = None, hmethod: Method | None = None, n_cores: int | None = None)#

Initialise a two-level numerical Hessian calculation using a low-level method (lmethod) and a high-level method (hmethod) for only some atoms, with indexes (idxs)

using the high-level method

Parameters:
  • shift – Numerical shift in used in the finite differences

  • lmethod – Low-level method

  • hmethod – High-level method

  • n_cores – Number of cores to use, defaults to Config.n_cores

calculate() None#

Calculate the partial numerical Hessian

class autode.hessians.NumericalHessianCalculator(species: Species, method: Method, keywords: GradientKeywords, do_c_diff: bool, shift: Distance, n_cores: int | None = None)#
__init__(species: Species, method: Method, keywords: GradientKeywords, do_c_diff: bool, shift: Distance, n_cores: int | None = None)#
calculate() None#

Calculate the Hessian

property hessian: Hessian#

Hessian matrix of {d^2E/dX_ij^2}. Must be symmetric