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¶
An exact affine map |
Module Contents¶
- class httk.atomistic.affine_operation.AffineOperation(matrix: Any, vector: Any = (0, 0, 0))[source]¶
An exact affine map
x -> W x + won 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, sincex+1/2andx+3/2are the same operation there but different objects here.- classmethod from_record(record: dict[str, Any]) Self[source]¶
Build from a vendored
affine_transformationrecord.The record’s
matrixandvectorhold exact rational strings ("1/2","-1"), which embed exactly.
- classmethod from_symop_record(record: dict[str, Any]) Self[source]¶
Build from a vendored
symopsentry (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±1means the operation changes the lattice.
- apply(coords: Any) httk.core.FracVector[source]¶
Map reduced coordinates through this operation, exactly.
coordsis a single(3,)coordinate or an(N, 3)block of them; the result has the same shape. No wrapping is applied — seeapply_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
ZeroDivisionErrorif singular.
- conjugated_by(change: AffineOperation) AffineOperation[source]¶
This operation seen through a change of basis:
change * self * change^-1.If
selfis a symmetry operation expressed in one setting andchangemaps 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.