Skip to main content

geom.twist()

Rotate a group about a bond, e.g. a methyl or amine group.

Usage

Source

geom.twist(
    geo,
    keys,
    angle,
    *,
    degrees=False,
)

Everything on the side of atom j of the bond (i, j) rotates about the axis from i to j, by the right-hand rule (thumb from i to j). Bond lengths and angles are kept; only the dihedral angles about the bond change.

Parameters

geo: Geometry

Geometry.

keys: Sequence[int]

The bond, (i, j). The side of j moves.

angle: float

Angle to rotate by.

degrees: bool = False
If True, angle is in degrees instead of radians.

Returns

Geometry
The twisted geometry.

Raises

ValueError
If i and j aren’t bonded, or the bond is in a ring.

Examples

    >>> geo = Geometry(
    ...     symbols=["H", "O", "O", "H"],
    ...     coordinates=[[1, 0, 0], [0, 0, 0], [0, 0, 1.4], [1, 0, 1.4]],
    ...     charge=0,
    ...     spin=0,
    ... )
    >>> geo = twist(geo, (1, 2), 90, degrees=True)
    >>> round(dihedral(geo, [0, 1, 2, 3], degrees=True), 6)
90.0