httk.atomistic.affine_operation

Exact rational affine maps on fractional coordinates.

An AffineOperation is a rotation part and a translation part held exactly as FracVector values. The same object serves for the two things this package does with affine maps — a crystallographic symmetry operation, and a change-of-basis between space-group settings — because they are the same algebra; only their interpretation differs (see SettingTransform for the latter).

Everything here is closed over the rationals: composing, inverting, conjugating, and applying an operation to reduced coordinates all stay exact. That is the whole reason the ASU machinery needs no tolerance.

Convention. The stored matrix is written for column vectors, matching how crystallographic tables print an operation (x' = W x + w, i.e. -x+1/2,y,-z). httk holds coordinates as rows, so AffineOperation.apply() evaluates coords * matrix.T() + vector. Both spellings describe the same map; only one of them is ever written out in code here.

Classes

AffineOperation

An exact affine map x -> W x + w on fractional coordinates.

Module Contents

class httk.atomistic.affine_operation.AffineOperation(matrix: Any, vector: Any = (0, 0, 0))[source]

An exact affine map x -> W x + w on fractional coordinates.

Two operations compare equal when their matrix and translation are exactly equal. Equality is not modulo lattice translations — use wrapped() first when comparing symmetry operations as members of a space group, since x+1/2 and x+3/2 are the same operation there but different objects here.

classmethod identity() Self[source]

The identity operation.

classmethod from_record(record: dict[str, Any]) Self[source]

Build from a vendored affine_transformation record.

The record’s matrix and vector hold exact rational strings ("1/2", "-1"), which embed exactly.

classmethod from_symop_record(record: dict[str, Any]) Self[source]

Build from a vendored symops entry (which nests its affine part).

property matrix: httk.core.FracVector[source]

The 3x3 rotation part W, in the column-vector convention.

property vector: httk.core.FracVector[source]

The translation part w.

determinant() fractions.Fraction[source]

The determinant of the rotation part, exactly.

For a symmetry operation this is +1 (proper) or -1 (improper). For a change of basis it is the ratio of cell volumes, so a value other than ±1 means the operation changes the lattice.

is_identity() bool[source]
apply(coords: Any) httk.core.FracVector[source]

Map reduced coordinates through this operation, exactly.

coords is a single (3,) coordinate or an (N, 3) block of them; the result has the same shape. No wrapping is applied — see apply_wrapped().

apply_wrapped(coords: Any) httk.core.FracVector[source]

apply(), then wrap every component into [0, 1).

inverse() AffineOperation[source]

The inverse map, exactly. Raises ZeroDivisionError if singular.

conjugated_by(change: AffineOperation) AffineOperation[source]

This operation seen through a change of basis: change * self * change^-1.

If self is a symmetry operation expressed in one setting and change maps that setting’s coordinates into another, the result is the same symmetry operation expressed in the other setting.

wrapped() AffineOperation[source]

The same operation with its translation reduced into [0, 1).

Two symmetry operations of a space group are the same element modulo lattice translations exactly when their wrapped forms are equal, which is what makes symop sets comparable.

to_xyz() str[source]

The operation in x,y,z notation, e.g. "-x+1/2,y,-z+1/2".