httk.atomistic.symmetry¶
Submodules¶
- httk.atomistic.symmetry.affine_operation
- httk.atomistic.symmetry.canonical
- httk.atomistic.symmetry.lift
- httk.atomistic.symmetry.paths
- httk.atomistic.symmetry.primitive
- httk.atomistic.symmetry.recognition
- httk.atomistic.symmetry.setting_transform
- httk.atomistic.symmetry.spacegroup
- httk.atomistic.symmetry.standardization
- httk.atomistic.symmetry.subgroups
- httk.atomistic.symmetry.symop_key
- httk.atomistic.symmetry.wyckoff
- httk.atomistic.symmetry.xyz
Classes¶
Represent an exact affine map |
|
Represent an exact rational change of basis from the IT standard setting. |
|
Represent a tabulated space-group setting from the vendored symmetry data. |
|
Represent one member of a Wyckoff orbit as an affine parameter map. |
|
Represent a Wyckoff position of one space-group setting. |
Functions¶
|
Map standard-setting Wyckoff letters to their names in another setting. |
|
Build the Wyckoff positions of a setting record, most specific first. |
|
Parse an exact three-coordinate crystallographic operation. |
|
Parse an exact magnetic operation and return its time-reversal flag. |
|
Parse one superspace linear expression into integer coefficients and a translation. |
Package Contents¶
- class httk.atomistic.symmetry.AffineOperation(matrix, vector=(0, 0, 0))[source]¶
Represent 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.- Parameters:
matrix (Any) – The 3x3 rotation part in the column-vector convention, or a comma-separated
"x,y,z"operation string (as emitted byto_xyz()andrepr), in which casevectoris ignored.vector (Any) – The translation part in fractional coordinates.
- classmethod identity()[source]¶
Return the identity operation.
- Returns:
The identity affine operation.
- Return type:
Self
- classmethod from_record(record)[source]¶
Build an operation from either vendored affine-record shape.
The record’s
matrixandvectorhold exact rational strings ("1/2","-1"), which embed exactly.- Parameters:
record (collections.abc.Mapping[str, Any]) – The affine record, or a mapping containing one under
"affine_transformation".- Returns:
The corresponding affine operation.
- Return type:
Self
- property matrix: httk.core.FracVector¶
Return the 3x3 rotation part
Win the column-vector convention.- Returns:
The exact rotation matrix.
- Return type:
- property vector: httk.core.FracVector¶
Return the translation part
w.- Returns:
The exact translation vector.
- Return type:
- determinant()[source]¶
Return 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.- Returns:
The exact determinant.
- Return type:
- is_identity()[source]¶
Report whether this operation is the identity.
- Returns:
Whether the matrix and translation are both identity values.
- Return type:
- apply(coords)[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().- Parameters:
coords (Any) – A single reduced coordinate or a block of reduced coordinates.
- Returns:
The transformed coordinates with the same shape as
coords.- Raises:
ValueError – If
coordsis neither a length-three coordinate nor an(N, 3)block.- Return type:
- apply_wrapped(coords)[source]¶
Map coordinates and wrap every component into
[0, 1).- Parameters:
coords (Any) – A single reduced coordinate or a block of reduced coordinates.
- Returns:
The transformed and wrapped coordinates.
- Raises:
ValueError – If
coordshas an unsupported shape.- Return type:
- inverse()[source]¶
Return the inverse map exactly.
- Returns:
The inverse affine operation.
- Raises:
ZeroDivisionError – If the rotation part is singular.
- Return type:
- conjugated_by(change)[source]¶
Rewrite this operation through a change of basis.
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.- Parameters:
change (AffineOperation) – The affine operation defining the coordinate change.
- Returns:
This operation conjugated by
change.- Return type:
- wrapped()[source]¶
Return this 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.
- Returns:
An operation with a normalized translation.
- Return type:
- class httk.atomistic.symmetry.SettingTransform(matrix, vector=(0, 0, 0), *, hall_entry=None)[source]¶
Represent an exact rational change of basis from the IT standard setting.
Wraps an
AffineOperationand gives it the standard-to-own reading described in the module docstring, plus the cell-basis and symmetry-operation transformations that follow from it.- Parameters:
matrix (Any) – The 3x3 matrix
Mmapping standard coordinates to the own setting.vector (Any) – The origin shift
vin the own setting.hall_entry (str | None) – The normalized Hall entry associated with a tabulated transform, if known.
- classmethod identity()[source]¶
Return the transform of a structure already in its IT standard setting.
- Returns:
The identity setting transform.
- Return type:
Self
- classmethod from_hall_entry(hall_entry)[source]¶
Return the tabulated transform for one of the 527 known settings.
hall_entryis the normalized Hall symbol of the setting, which names it unambiguously — symbol, axes, and origin choice together.
- property operation: httk.atomistic.symmetry.affine_operation.AffineOperation¶
Return the underlying affine map from standard to own setting.
- Returns:
The underlying affine operation.
- Return type:
- property matrix: httk.core.FracVector¶
Return the 3x3 rotation part
M.- Returns:
The exact change-of-basis matrix.
- Return type:
- property vector: httk.core.FracVector¶
Return the origin shift
v.- Returns:
The exact origin-shift vector.
- Return type:
- property hall_entry: str | None¶
Return the Hall entry used to look up this transform, if any.
- Returns:
The normalized Hall entry, or
Nonefor a caller-supplied transform.- Return type:
str | None
- determinant()[source]¶
Return the signed inverse volume factor
det M.Its magnitude satisfies
abs(det M) = V_standard / V_own; the sign records orientation reversal.1for 520 of the 527 tabulated settings. The exceptions are the seven rhombohedral-axes settings (IT numbers 146, 148, 155, 160, 161, 166, 167) where it is3, because the standard hexagonal cell holds three primitive rhombohedral cells. A caller-supplied transform may have any non-zero value.- Returns:
The exact determinant of
M.- Return type:
- is_identity()[source]¶
Report whether the transform is the identity.
- Returns:
Whether the matrix and origin shift leave the standard setting unchanged.
- Return type:
- to_setting(coords)[source]¶
Map standard-setting reduced coordinates into this setting without wrapping.
- Parameters:
coords (Any) – A reduced coordinate or block of reduced coordinates in the standard setting.
- Returns:
The corresponding coordinates in the own setting.
- Return type:
- to_standard(coords)[source]¶
Map own-setting reduced coordinates into the standard setting without wrapping.
- Parameters:
coords (Any) – A reduced coordinate or block of reduced coordinates in the own setting.
- Returns:
The corresponding coordinates in the standard setting.
- Return type:
- symop_to_setting(operation)[source]¶
Rewrite a standard-setting symmetry operation in this setting.
- Parameters:
operation (httk.atomistic.symmetry.affine_operation.AffineOperation) – The symmetry operation expressed in the standard setting.
- Returns:
The conjugated symmetry operation in the own setting.
- Return type:
- symop_to_standard(operation)[source]¶
Rewrite an own-setting symmetry operation in the standard setting.
- Parameters:
operation (httk.atomistic.symmetry.affine_operation.AffineOperation) – The symmetry operation expressed in the own setting.
- Returns:
The conjugated symmetry operation in the standard setting.
- Return type:
- basis_to_setting(basis)[source]¶
Map a standard-setting cell basis into this setting.
Follows from coordinate invariance: if
f_own = f_std * M.T()thenB_own = inv(M).T() * B_std, so thatf * Bis the same Cartesian point either way. The transform is rational, so an exact basis stays exact — a hexagonal cell keeps itssqrt(3).- Parameters:
basis (Any) – The standard-setting cell basis with lattice vectors as rows.
- Returns:
The own-setting cell basis with lattice vectors as rows.
- Return type:
- basis_to_standard(basis)[source]¶
Map this setting’s cell basis into the standard setting.
- Parameters:
basis (Any) – The own-setting cell basis with lattice vectors as rows.
- Returns:
The standard-setting cell basis with lattice vectors as rows.
- Return type:
- lattice_cosets()[source]¶
Return the translations of this setting’s cell that are standard-lattice translations.
Expanding an orbit generates points from the standard setting’s symmetry operations, which carry the standard lattice’s periodicity. When this setting’s cell is larger than the standard one, that is not enough: points related by a standard lattice translation are genuinely distinct sites here, and the missing ones are recovered by also applying each translation returned by this method.
The result is the finite subgroup of
(Q/Z)^3generated by the columns ofMreduced modulo 1, always including the zero translation. It is trivial (just zero) wheneverMis an integer matrix, which covers all 527 tabulated settings — including the seven withdet M == 3, where this setting’s cell is smaller and the surplus points collapse under wrapping instead. So this only ever does work for a caller-supplied transform to a supercell setting.- Returns:
The normalized finite set of translations, including zero.
- Return type:
tuple[httk.core.FracVector, Ellipsis]
- class httk.atomistic.symmetry.Spacegroup(record)[source]¶
Represent a tabulated space-group setting from the vendored symmetry data.
- Parameters:
record (collections.abc.Mapping[str, Any]) – The read-only vendored mapping describing one space-group setting.
- classmethod standard(it_number)[source]¶
Return the IT standard setting for a space-group number.
- Parameters:
it_number (int) – The International Tables space-group number.
- Returns:
The IT standard setting for
it_number.- Return type:
Self
- classmethod from_hall_entry(hall_entry)[source]¶
Return the setting named by a normalized Hall symbol.
For example,
"-c_2yc"names one setting.- Parameters:
hall_entry (str) – The normalized Hall symbol naming the setting.
- Returns:
The corresponding space-group setting.
- Return type:
Self
- classmethod from_setting(setting_it_nc)[source]¶
Return the setting named by an IT number and coordinate-system code.
For example,
"15:c1"names one setting.- Parameters:
setting_it_nc (str) – The IT setting identifier.
- Returns:
The corresponding space-group setting.
- Return type:
Self
- classmethod from_hm_entry(hm_entry)[source]¶
Return the setting named by a Hermann-Mauguin entry.
For example,
"C 1 2/c 1"names one setting.- Parameters:
hm_entry (str) – The Hermann-Mauguin symbol naming the setting.
- Returns:
The corresponding space-group setting.
- Return type:
Self
- property record: collections.abc.Mapping[str, Any]¶
Return the raw vendored record for fields this class does not model.
- Returns:
The source record for this setting.
- Return type:
collections.abc.Mapping[str, Any]
- property it_number: int¶
Return the International Tables space-group number.
- Returns:
The space-group number from 1 through 230.
- Return type:
- property setting: str¶
Return the setting name, such as
"15:c1".- Returns:
The IT number and coordinate-system code.
- Return type:
- property hall_entry: str¶
Return the normalized Hall symbol naming the setting unambiguously.
- Returns:
The normalized Hall symbol.
- Return type:
- property hall_symbol: str¶
Return the Hall symbol as conventionally written.
- Returns:
The conventional Hall symbol.
- Return type:
- property hermann_mauguin: str¶
Return the short Hermann-Mauguin symbol for this setting.
- Returns:
The short Hermann-Mauguin symbol.
- Return type:
- property hermann_mauguin_full: str¶
Return the full Hermann-Mauguin symbol for this setting.
- Returns:
The full Hermann-Mauguin symbol.
- Return type:
- property crystal_system: str¶
Return the crystal system, such as
"monoclinic".- Returns:
The crystal-system name.
- Return type:
- property centring_type: str¶
Return the lattice centring letter, such as
"P","C", or"F".- Returns:
The centring letter.
- Return type:
- property is_standard_setting: bool¶
Report whether this is the IT standard setting for its space-group number.
- Returns:
Whether this setting is the IT reference setting.
- Return type:
- property symmetry_operations: tuple[httk.atomistic.symmetry.affine_operation.AffineOperation, Ellipsis]¶
Return every symmetry operation of the group in this setting’s coordinates.
The full set with centring translations already folded in, so its length is the group order and no separate centring pass is needed.
- Returns:
The complete tuple of symmetry operations.
- Return type:
tuple[httk.atomistic.symmetry.affine_operation.AffineOperation, Ellipsis]
- property centering_translations: tuple[httk.core.FracVector, Ellipsis]¶
Return the lattice centring translations, including zero.
- Returns:
The centring translations in this setting.
- Return type:
tuple[httk.core.FracVector, Ellipsis]
- property wyckoff: tuple[httk.atomistic.symmetry.wyckoff.WyckoffPosition, Ellipsis]¶
Return the Wyckoff positions ordered most specific first.
Sorted by
(free_count, multiplicity, letter), so identifying a coordinate by walking this order returns the most specific position it lies on.- Returns:
The ordered Wyckoff positions for this setting.
- Return type:
tuple[httk.atomistic.symmetry.wyckoff.WyckoffPosition, Ellipsis]
- wyckoff_position(letter)[source]¶
Return the Wyckoff position with the given letter.
For example,
"e"selects the position with lettere.
- identify_wyckoff(coordinate)[source]¶
Identify the most specific Wyckoff position holding an exact coordinate.
Returns
Nonewhen the coordinate lies on no position, which for a complete table means the input was not an exact rational site of this group. Matching is exact: an approximate coordinate must be snapped first (seeASUStructure’s recognition path), never passed here in the hope that it lands.- Parameters:
coordinate (Any) – The exact reduced coordinate to identify.
- Returns:
The matching position and free parameters, or
Nonewhen no position matches exactly.- Return type:
tuple[httk.atomistic.symmetry.wyckoff.WyckoffPosition, httk.core.FracVector] | None
- property transform_from_standard: httk.atomistic.symmetry.setting_transform.SettingTransform¶
Return the change of basis from the IT standard setting to this one.
The identity exactly when this is the standard setting.
- Returns:
The stored standard-to-own setting transform.
- Return type:
- httk.atomistic.symmetry.wyckoff_letter_map(standard, target)[source]¶
Map standard-setting Wyckoff letters to their names in another setting.
Almost always the identity — but not always, and the exception is silent. Across all 3210 non-reference
(setting, letter)pairs in the vendored tables, exactly one setting permutes letters: in224:1the standard setting’sjis that setting’siand vice versa. So a CIF that declares site24iin setting224:1does not mean standard-setting letteri, and taking the letter at face value across a setting boundary produces the wrong structure with no error.Computed rather than hard-coded, so it survives a data refresh: each standard position is evaluated at generic parameters, mapped through the setting transform, and identified in the target’s own Wyckoff table.
- Parameters:
standard (Spacegroup) – The IT standard setting whose letters are being mapped.
target (Spacegroup) – The setting receiving the mapped letters.
- Returns:
A mapping from standard-setting letters to target-setting letters.
- Raises:
ValueError – If the settings belong to different space groups or the mapping is not bijective.
- Return type:
- class httk.atomistic.symmetry.WyckoffBranch(operation, free)[source]¶
Represent one member of a Wyckoff orbit as an affine parameter map.
A position of multiplicity m has m branches. The representative branch is the first, but a coordinate may lie on any of them, which is why
WyckoffPosition.parameters_of()tries them all.- Parameters:
operation (httk.atomistic.symmetry.affine_operation.AffineOperation) – The affine map for this orbit branch.
free (collections.abc.Sequence[int]) – The indices of the free parameters in
(x, y, z).
- property operation: httk.atomistic.symmetry.affine_operation.AffineOperation¶
Return the affine map from
(x, y, z)to this branch’s coordinate.- Returns:
The branch’s affine operation.
- Return type:
- property free: tuple[int, Ellipsis]¶
Return the ascending indices of the free parameters in
(x, y, z).
- coordinate(parameters)[source]¶
Compute the coordinate this branch places at given free-parameter values.
parametershas one entry per free parameter. Because the non-free columns of the matrix are zero, the values placed at the non-free positions are irrelevant.- Parameters:
parameters (Any) – The free-parameter values for this branch.
- Returns:
The exact reduced coordinate generated by the branch.
- Raises:
ValueError – If the number of parameters does not match the branch.
- Return type:
- parameters_of(coordinate)[source]¶
Recover the free parameters putting this branch on
coordinate, if possible.Nonemeans the coordinate does not lie on this branch — for any lattice translation, not merely the one given. That completeness is what the row-Hermite form buys: withUunimodular over the integers,A t = d (mod Z^3)holds iffU A t = U d (mod Z^3), and the zero rows ofU Aturn the lattice-membership question into “are these components integers?” with no search over translations.The returned parameters are reduced into
[0, 1), which is canonical: the pivot block has determinant±1throughout the vendored tables, so the solution is unique modulo one. The result is verified by re-evaluating the branch, so a table that ever violated that assumption would yield a clean miss rather than a wrong answer.- Parameters:
coordinate (Any) – The exact reduced coordinate to match.
- Returns:
The normalized free parameters, or
Nonewhen the coordinate is not on this branch.- Return type:
httk.core.FracVector | None
- nearest_parameters(coordinate)[source]¶
Compute free parameters that put this branch as close to
coordinateas possible.Unlike
parameters_of()this always returns a value: the free directions are solved exactly and any discrepancy is left in the fixed directions, where the branch’s own coordinates win. It is the projection used when recognizing a measured structure, whose coordinates carry rounding and do not lie exactly on any position.The projection is taken along the branch’s own lattice basis rather than being minimised in the cell metric, so for a strongly oblique cell it is a near-optimal rather than provably optimal choice. That is safe because the caller measures the resulting Cartesian displacement and rejects anything beyond its tolerance — the method can cost a match, never grant a wrong one.
- Parameters:
coordinate (Any) – The reduced coordinate to approximate.
- Returns:
The normalized free parameters for the nearest branch point.
- Return type:
- nearest_parameters_float(coordinate)[source]¶
Project a coordinate onto this branch in floating point for screening.
This deliberately mirrors
nearest_parameters()without its exact verification. It is only a candidate-screening aid; callers must calculate and compare the final distance with the exact methods before accepting a match.- Parameters:
coordinate (collections.abc.Sequence[float]) – A reduced coordinate as three floating-point values.
- Returns:
The normalized floating-point free parameters.
- Return type:
- coordinate_float(parameters)[source]¶
Evaluate this branch in floating point for candidate screening.
- Parameters:
parameters (collections.abc.Sequence[float]) – One floating-point value for every free parameter.
- Returns:
The unwrapped floating-point reduced coordinate.
- Raises:
ValueError – If the parameter count is wrong.
- Return type:
- class httk.atomistic.symmetry.WyckoffPosition(record)[source]¶
Represent a Wyckoff position of one space-group setting.
- Parameters:
record (collections.abc.Mapping[str, Any]) – The vendored record describing the Wyckoff position.
- classmethod from_record(record)[source]¶
Build a Wyckoff position from a vendored record.
- Parameters:
record (collections.abc.Mapping[str, Any]) – The vendored Wyckoff-position record.
- Returns:
The corresponding Wyckoff position.
- Return type:
Self
- property letter: str¶
Return the bare Wyckoff letter, such as
"e".- Returns:
The Wyckoff letter without a multiplicity prefix.
- Return type:
- property multiplicity: int¶
Return the number of sites generated by one parameter set.
- Returns:
The position multiplicity in the unit cell.
- Return type:
- property site_symmetry: str¶
Return the site-symmetry group in Hermann-Mauguin notation.
- Returns:
The site-symmetry symbol.
- Return type:
- property free_count: int¶
Return the number of degrees of freedom of the position.
- Returns:
The number of free parameters, from zero through three.
- Return type:
- property branches: tuple[WyckoffBranch, Ellipsis]¶
Return the complete, deduplicated orbit branches.
- Returns:
One branch for each equivalent site.
- Return type:
tuple[WyckoffBranch, Ellipsis]
- property representative: WyckoffBranch¶
Return the first orbit member printed as
first_orbitin the tables.- Returns:
The representative orbit branch.
- Return type:
- coordinates(parameters)[source]¶
Compute every coordinate of the orbit as an exact
(multiplicity, 3)block.Not wrapped and not deduplicated: within one setting the tabulated orbit is already distinct, so wrapping is the caller’s business (and matters only once a setting transform enters).
- Parameters:
parameters (Any) – The free-parameter values for the position.
- Returns:
The unwrapped coordinates of all orbit branches.
- Raises:
ValueError – If the number of parameters does not match a branch.
- Return type:
- parameters_of(coordinate)[source]¶
Recover free parameters placing some branch on
coordinate, if possible.Tries every branch, not only the representative. That matters: across the vendored tables, 11673 of the 20639 non-representative orbit members lie on a different branch than the representative, so a matcher that only tested
first_orbitwould reject a majority of legitimate orbit points.- Parameters:
coordinate (Any) – The exact reduced coordinate to match.
- Returns:
The normalized free parameters, or
Nonewhen no branch matches.- Return type:
httk.core.FracVector | None
- httk.atomistic.symmetry.wyckoff_positions(record)[source]¶
Build the Wyckoff positions of a setting record, most specific first.
Ordered by
(free_count, multiplicity, letter)so that the first match found when identifying a coordinate is the most specific position it lies on. Ties do not arise: positions are affine subspaces, so a coordinate on two distinct positions of the same dimension also lies on their lower-dimensional intersection, which is covered by an earlier entry.- Parameters:
record (collections.abc.Mapping[str, Any]) – The vendored space-group setting record.
- Returns:
The setting’s ordered Wyckoff positions.
- Return type:
tuple[WyckoffPosition, Ellipsis]
- httk.atomistic.symmetry.operation_from_xyz(operation)[source]¶
Parse an exact three-coordinate crystallographic operation.
- Parameters:
operation (str) – The comma-separated
x,y,zoperation string.- Returns:
The exact affine operation.
- Raises:
ValueError – If the operation does not contain three valid coordinate expressions.
- Return type:
- httk.atomistic.symmetry.operation_from_xyzt(operation)[source]¶
Parse an exact magnetic operation and return its time-reversal flag.
The first three comma-separated fields use crystallographic
x,y,zgrammar; the fourth field must be+1or-1.- Parameters:
operation (str) – The comma-separated
x,y,z,time-reversaloperation string.- Returns:
The affine operation and its time-reversal sign.
- Raises:
ValueError – If the operation does not contain three coordinate expressions and a valid time-reversal flag.
- Return type:
tuple[httk.atomistic.symmetry.affine_operation.AffineOperation, int]
- httk.atomistic.symmetry.parse_linear_expression(expression, allowed_vars=_SUPERSPACE_VARS)[source]¶
Parse one superspace linear expression into integer coefficients and a translation.
The parser accepts the six superspace variables
x1throughx6by default and preserves an exact rational translation.- Parameters:
expression (str) – The linear expression to parse.
allowed_vars (collections.abc.Sequence[str]) – The variable names accepted in
expression.
- Returns:
The integer coefficients in
allowed_varsand the exact translation.- Raises:
ValueError – If the expression is empty, malformed, or has a non-integer variable coefficient.
- Return type:
tuple[tuple[int, Ellipsis], fractions.Fraction]