oqp.library.oqp_coords
Coordinate systems for the oqp OpenQP geometry optimizer.
This module is intentionally backend-agnostic: it depends only on NumPy and can
be unit-tested without the compiled OQP electronic-structure core. It provides
* :class:`RedundantInternalCoordinates` -- bonds, angles and dihedrals built
from covalent connectivity, with the Wilson B-matrix, gradient/Hessian
transforms and an iterative Cartesian back-transformation
(Pulay/Fogarasi natural internals; Peng, Ayala, Schlegel, Frisch,
J. Comput. Chem. 17, 49 (1996)); and
* :class:`CartesianCoordinates` -- a trivial fall-back used when the internal
set fails to span the 3N-6 non-redundant space (e.g. linear molecules) or the
back-transformation diverges.
Both classes share the same small interface consumed by
``oqp_engine.OQPEngine``::
coords.q(x) -> internal/Cartesian coordinate vector
coords.b_matrix(x) -> dq/dx (n_q, 3N)
coords.grad_to_q(x, gx) -> gradient in working coordinates
coords.guess_hessian(x) -> diagonal model Hessian (n_q, n_q)
coords.q_displacement(q2,q1)-> q2 - q1 with dihedral wrapping
coords.back_transform(x, dq)-> new Cartesian geometry for a step dq
coords.cart_rmsd(x, x_new) -> RMS Cartesian displacement (Bohr)
All quantities are in atomic units (Bohr, radian, Hartree/Bohr ...).
Attributes
Classes
Functions
|
|
|
Module Contents
- BOHR_TO_ANGSTROM = 0.52917721092
- ANGSTROM_TO_BOHR = 1.8897261245650618
- covalent_radius_bohr(z: int) float
Covalent radius of element ``z`` in Bohr (1.5 A fallback for heavy Z).
- class TranslationComponent(atoms, axis)
One Cartesian centroid component of a fragment (analytic, constant B).
- kind = 'translation'
- frag
- axis
- n
- value(x)
- derivatives(x)
- class RotationComponent(atoms, axis, reference_xyz)
One exp-map rotation component of a fragment relative to a reference. The value is evaluated analytically (Kabsch); the B-matrix row is taken by a central finite difference of that value -- exact to ~1e-9 and free of the intricate quaternion-derivative algebra, at negligible cost for the small systems these optimizations target.
- kind = 'rotation'
- frag
- axis
- ref
- value(x)
- derivatives(x, h=1e-05)
- class RedundantInternalCoordinates(primitives, natom)
Redundant internal coordinate system (bonds, angles, dihedrals).
- primitives
- natom
- ndim
- classmethod from_geometry(atoms, x, bond_factor=1.3)
Build internals from atomic numbers ``atoms`` and geometry ``x``. Returns ``None`` when fewer than two atoms are present (nothing to do) or when the constructed set is rank-deficient (caller falls back to Cartesians).
- q(x)
- b_matrix(x)
- spans_internal_space(x, eig_tol=1e-06)
- grad_to_q(x, gx)
- guess_hessian(x)
- q_displacement(q2, q1)
- back_transform(x, dq, tol=1e-06, maxiter=50)
Iteratively realise an internal-coordinate step ``dq`` in Cartesians. Returns ``(x_new, ok)``; ``ok`` is False if the iteration diverged, in which case the caller should shrink the step or fall back.
- cart_rmsd(x, x_new)
- class DelocalizedInternalCoordinates(ric, u, q_ref)
Delocalized internal coordinates (Baker, JCP 105, 192 (1996)). Non-redundant linear combinations of a redundant primitive set: the active subspace ``U`` is the eigenvectors of G = B B^T with non-zero eigenvalue, fixed at construction. Coordinates are measured as displacements from the construction geometry, so G_dlc is well conditioned and the transforms use a plain solve instead of a pseudo-inverse.
- ric
- U
- q_ref
- natom
- ndim
- primitives
- classmethod from_ric(ric, x, eig_tol=1e-06)
- q(x)
- b_matrix(x)
- grad_to_q(x, gx)
- guess_hessian(x)
- q_displacement(q2, q1)
- back_transform(x, dq, tol=1e-06, maxiter=50)
- cart_rmsd(x, x_new)
- class CartesianCoordinates(natom)
Trivial Cartesian coordinate system (identity B-matrix).
- natom
- ndim
- primitives = []
- q(x)
- b_matrix(x)
- grad_to_q(x, gx)
- guess_hessian(x)
- q_displacement(q2, q1)
- back_transform(x, dq, **_)
- cart_rmsd(x, x_new)
- build_coordinates(atoms, x, coordsys='tric')
Return a coordinate system for ``atoms``/``x``. ``coordsys`` selects the working coordinates: * ``tric`` (default) / ``auto`` -- translation-rotation internal coordinates; * ``dlc`` -- delocalized internal coordinates; * ``ric`` / ``internal`` -- redundant internal coordinates; * ``cart`` / ``cartesian`` -- Cartesians. All internal systems fall back to redundant internals and then Cartesians when their set is unavailable or rank-deficient (e.g. linear species), so the optimizer always has a usable coordinate system.