httk.atomistic.symmetry.wyckoff =============================== .. py:module:: httk.atomistic.symmetry.wyckoff .. autoapi-nested-parse:: Exact rational Wyckoff-position algebra. A Wyckoff position is a family of symmetry-equivalent sites parameterised by a few free coordinates: SG 15 letter ``e`` is ``0,y,1/4``, so one free parameter ``y`` places four symmetry-equivalent atoms. This module goes both ways between free parameters and coordinates, entirely over the rationals. Two properties of the vendored tables make this much simpler than it looks, both asserted in ``tests/test_symmetry_data.py``: * Each Wyckoff position's ``orbit`` is already the **complete, deduplicated** list of affine maps, of length exactly ``multiplicity``, with centering translations folded in. Generating an orbit is therefore a plain loop with no coincidence testing and no tolerance. * ``hasfreedom`` marks which of ``x``, ``y``, ``z`` are free, and the columns of every orbit matrix for the non-free variables are identically zero, with ``sum(hasfreedom) == rank``. So the free parameters are read straight off, and the ``first_orbit`` strings (``"1/8,y,-y+1/4"``) never need parsing — the same information is already present as an exact affine map. Everything is expressed in the coordinates of whichever setting the record came from. Classes ------- .. autoapisummary:: httk.atomistic.symmetry.wyckoff.WyckoffBranch httk.atomistic.symmetry.wyckoff.WyckoffPosition Functions --------- .. autoapisummary:: httk.atomistic.symmetry.wyckoff.wyckoff_positions Module Contents --------------- .. py:class:: WyckoffBranch(operation, free) 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 :meth:`WyckoffPosition.parameters_of` tries them all. :param operation: The affine map for this orbit branch. :param free: The indices of the free parameters in ``(x, y, z)``. .. py:property:: operation :type: httk.atomistic.symmetry.affine_operation.AffineOperation Return the affine map from ``(x, y, z)`` to this branch's coordinate. :return: The branch's affine operation. .. py:property:: free :type: tuple[int, Ellipsis] Return the ascending indices of the free parameters in ``(x, y, z)``. :return: The free-parameter indices. .. py:method:: coordinate(parameters) Compute the coordinate this branch places at given free-parameter values. ``parameters`` has 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. :param parameters: The free-parameter values for this branch. :return: The exact reduced coordinate generated by the branch. :raises ValueError: If the number of parameters does not match the branch. .. py:method:: parameters_of(coordinate) Recover the free parameters putting this branch on ``coordinate``, if possible. ``None`` means 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: with ``U`` unimodular over the integers, ``A t = d (mod Z^3)`` holds iff ``U A t = U d (mod Z^3)``, and the zero rows of ``U A`` turn 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 ``±1`` throughout 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. :param coordinate: The exact reduced coordinate to match. :return: The normalized free parameters, or ``None`` when the coordinate is not on this branch. .. py:method:: nearest_parameters(coordinate) Compute free parameters that put this branch as close to ``coordinate`` as possible. Unlike :meth:`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. :param coordinate: The reduced coordinate to approximate. :return: The normalized free parameters for the nearest branch point. .. py:method:: nearest_parameters_float(coordinate) Project a coordinate onto this branch in floating point for screening. This deliberately mirrors :meth:`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. :param coordinate: A reduced coordinate as three floating-point values. :return: The normalized floating-point free parameters. .. py:method:: coordinate_float(parameters) Evaluate this branch in floating point for candidate screening. :param parameters: One floating-point value for every free parameter. :return: The unwrapped floating-point reduced coordinate. :raises ValueError: If the parameter count is wrong. .. py:class:: WyckoffPosition(record) Represent a Wyckoff position of one space-group setting. :param record: The vendored record describing the Wyckoff position. .. py:method:: from_record(record) :classmethod: Build a Wyckoff position from a vendored record. :param record: The vendored Wyckoff-position record. :return: The corresponding Wyckoff position. .. py:property:: letter :type: str Return the bare Wyckoff letter, such as ``"e"``. :return: The Wyckoff letter without a multiplicity prefix. .. py:property:: multiplicity :type: int Return the number of sites generated by one parameter set. :return: The position multiplicity in the unit cell. .. py:property:: site_symmetry :type: str Return the site-symmetry group in Hermann-Mauguin notation. :return: The site-symmetry symbol. .. py:property:: free :type: tuple[int, Ellipsis] Return the indices of the free parameters in ``(x, y, z)``. :return: The free-parameter indices. .. py:property:: free_count :type: int Return the number of degrees of freedom of the position. :return: The number of free parameters, from zero through three. .. py:property:: branches :type: tuple[WyckoffBranch, Ellipsis] Return the complete, deduplicated orbit branches. :return: One branch for each equivalent site. .. py:property:: representative :type: WyckoffBranch Return the first orbit member printed as ``first_orbit`` in the tables. :return: The representative orbit branch. .. py:method:: coordinates(parameters) 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). :param parameters: The free-parameter values for the position. :return: The unwrapped coordinates of all orbit branches. :raises ValueError: If the number of parameters does not match a branch. .. py:method:: parameters_of(coordinate) 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_orbit`` would reject a majority of legitimate orbit points. :param coordinate: The exact reduced coordinate to match. :return: The normalized free parameters, or ``None`` when no branch matches. .. py:function:: wyckoff_positions(record) 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. :param record: The vendored space-group setting record. :return: The setting's ordered Wyckoff positions.