# Algorithm¶

The optimization algorithm implemented in PyBerny loosely follows the “standard method” (SM) described in the appendix of [BirkholzTCA16]. What follows is a summary of that method, more detailed specification when necessary, and description of any deviations.

Todo

Make the algorithm fully conform to the SM.

## Sketch of the algorithm¶

1. Form a diagonal Hessian guess [SwartIJQC06].

2. Obtain energy and Cartesian gradients for the current geometry.

3. Form the Wilson B matrix and its generalized inverse.

4. Update the Hessian using the BFGS scheme.

5. Update trust region (Eq. 5.1.6 of [Fletcher00]).

6. Perform linear search (Gaussian website, section Examples, “If a minimum is sought…”). (Not in the SM.)

7. Project to a nonredundant subspace [PengJCC96].

8. Perform a quadratic RFO step [BanerjeeJPC85].

9. Transform back to Cartesian coordinates [PengJCC96].

10. If convergence is not reached (criteria from the SM), go to 3.

## Redundant internal coordinates¶

1. All bonds shorter than 1.3 times the sum of covalent radii are created [PengJCC96].

2. If there are unconnected fragments, all bonds between unconnected fragments shorter than the sum of van der Waals radii plus d are created, with d starting at 0 and increasing by 1 angstrom, until all fragments are connected (custom scheme by JH).

3. All angles greater than 45° are created.

4. All dihedrals with 1–2–3, 2–3–4 angles both greater than 45° are created. If one of the angles is zero, so that three atoms lie on a line, they are used as a new base for a dihedral. This process is recursively repeated [PengJCC96].

5. In the case of a crystal, just the internal coordinate closest to the original unit cell is retained from all its periodic images.

Todo

Implement linear bends.

## Generalized inverse¶

The Wilson B matrix, which relates differences in the internal redundant coordinates to differences in the Cartesian coordinates, is in general non-square and non-invertible. Its generalized inverse is obtained from the pseudoinverse of $$\mathbf B\mathbf B^\mathrm T$$ (singular), which is in turn obtained via singular value decomposition and inversion of only the nonzero singular values. For invertible matrices, this procedure is equivalent to an ordinary inverse. In practice, the zero values are in fact nonzero but several orders of magnitude smaller than the true nonzero values.