httk.atomistic.models.sites¶
Submodules¶
- httk.atomistic.models.sites.api
- httk.atomistic.models.sites.backend
- httk.atomistic.models.sites.like
- httk.atomistic.models.sites.numeric
- httk.atomistic.models.sites.numeric_view
- httk.atomistic.models.sites.plain
- httk.atomistic.models.sites.plain_view
- httk.atomistic.models.sites.record
- httk.atomistic.models.sites.sites
- httk.atomistic.models.sites.view
- httk.atomistic.models.sites.view_base
Attributes¶
Classes¶
Abstract base class for the canonical sites interface. |
|
Abstract base class for all backends of sites data. |
|
A plain-numpy presentation of a |
|
A view presenting an underlying sites backend as a |
|
Backend for sites backed by a raw Nx3 list or tuple of numbers (or any Nx3 vector-like). |
|
A view presenting an underlying sites backend as a raw Nx3 matrix of floats. |
|
The sites of a crystal structure: the Nx3 matrix of reduced coordinates, held exactly. |
|
A view presenting an underlying sites backend as a |
|
Abstract base class for all views of sites data. |
Package Contents¶
- class httk.atomistic.models.sites.SitesAPI[source]¶
Bases:
abc.ABCAbstract base class for the canonical sites interface.
It declares the single
reduced_coordsaccessor (the exact Nx3 rationalFracVectorof reduced coordinates) that every sites backend produces from its own native representation and every sites view builds its presentation from. This is the single interchange format; there is no pairwise conversion between backends.- property reduced_coords: httk.core.FracVector¶
- Abstractmethod:
Return the reduced site coordinates.
- property num_sites: int¶
Return the number of coordinate rows.
- Returns:
The number of sites.
- Return type:
- property precision: fractions.Fraction | None¶
How precisely the coordinates were stated, in fractional units, or
None.Fractional, not a length: reduced coordinates are dimensionless and a
Siteshas no cell to convert with.cartesian_precision()does the conversion, where the cell is known.Concrete rather than abstract, so a backend with no source of precision inherits
Noneinstead of breaking.- Returns:
The fractional precision, or
Nonewhen unknown.- Return type:
fractions.Fraction | None
- class httk.atomistic.models.sites.SitesBackend(backend, **hints)[source]¶
Bases:
httk.core.Backend[SitesBackend],httk.atomistic.models.sites.api.SitesAPIAbstract base class for all backends of sites data.
Concrete backends carry a native representation and produce the canonical Nx3
reduced_coordsdeclared bySitesAPIfrom it.- backend_classes: ClassVar[list[type[httk.core.Backend[Any]]]]¶
- type httk.atomistic.models.sites.SitesLike = httk.atomistic.models.sites.backend.SitesBackend | httk.atomistic.models.sites.view_base.SitesViewBase | httk.atomistic.models.sites.sites.Sites | httk.core.VectorLike[source]¶
- class httk.atomistic.models.sites.NumericSites(sites)[source]¶
A plain-numpy presentation of a
Sitesobject.Where a
Sitesholds its reduced coordinates exactly (an Nx3 rationalFracVector), aNumericSitesmirrors that interface but returns plainfloat64numpy arrays, for callers who do not need exact arithmetic and just want numpy arrays. It is len/iter/indexable over its rows, each yielded as a(3,)numpy array.The presentation is numpy-backed, so constructing a
NumericSitesrequires numpy (thehttk-atomistic[numpy]extra) and raisesImportErroreagerly when it is unavailable. The exact object is always one hop away viaexact.- Parameters:
sites (httk.atomistic.models.sites.like.SitesLike) – The sites or sites-like object to present.
- property precision: float | None¶
The fractional coordinate precision, or
Noneif unknown.- Returns:
The precision as a floating-point value.
- Return type:
float | None
- property reduced_coords: httk.core.NumericVector¶
The Nx3 reduced site coordinates.
- Returns:
The coordinates as floating-point values.
- Return type:
- property exact: httk.atomistic.models.sites.sites.Sites¶
The exact sites this presentation wraps.
- Returns:
The exact sites.
- Return type:
- class httk.atomistic.models.sites.SitesNumericView(obj, **hints)[source]¶
Bases:
httk.atomistic.models.sites.view_base.SitesViewBase,httk.atomistic.models.sites.numeric.NumericSitesA view presenting an underlying sites backend as a
NumericSitesobject.This view is a genuine
NumericSites, so it can be passed anywhere one is accepted. Its exactSitesis built lazily from the backend on first access. Like aNumericSitesit requires numpy (raisingImportErrorotherwise).- Parameters:
obj (httk.atomistic.models.sites.like.SitesLike) – The sites-like object to present.
**hints (Any) – Backend-selection hints.
- unwrap()[source]¶
Return the raw object behind the backend.
- Returns:
The unwrapped source object.
- Return type:
Any
- class httk.atomistic.models.sites.PlainSites(obj, **hints)[source]¶
Bases:
httk.atomistic.models.sites.backend.SitesBackendBackend for sites backed by a raw Nx3 list or tuple of numbers (or any Nx3 vector-like).
The native representation is preserved verbatim (one site per row); the exact rational
FracVectorreduced_coordsare built lazily and cached, andunwrapreturns the original raw object.- Parameters:
obj (Any) – The raw reduced-coordinate representation.
**hints (Any) – Backend-selection hints.
- property reduced_coords: httk.core.FracVector¶
Return the reduced coordinates in the canonical representation.
- Returns:
The exact reduced coordinates.
- Return type:
- class httk.atomistic.models.sites.PlainSitesView(obj, **hints)[source]¶
Bases:
httk.atomistic.models.sites.view_base.SitesViewBase,tupleA view presenting an underlying sites backend as a raw Nx3 matrix of floats.
This view is a genuine tuple of reduced-coordinate rows (rendered to floats from the exact
reduced_coords), built eagerly and immutable.- Parameters:
obj (httk.atomistic.models.sites.like.SitesLike) – The sites-like object to present.
**hints (Any) – Backend-selection hints.
- class httk.atomistic.models.sites.Sites(reduced_coords, precision=None)[source]¶
Bases:
httk.atomistic.models.sites.backend.SitesBackendThe sites of a crystal structure: the Nx3 matrix of reduced coordinates, held exactly.
Reduced (fractional) coordinates are the symmetry-native frame: point-group operations are integer matrices and translations are rationals, so no radicals ever appear. They are therefore stored as an exact rational
FracVectorof shape(N, 3). A Sites object is iterable and indexable over its length-3 coordinate rows (each aFracVector), withlengiving the number of sites.Inputs embed exactly: rationals (and rational-valued floats), rational strings, and numpy arrays all land on their exact rational value. An irrational
SurdVectorinput is rejected; the exact Cartesian frame — where radicals belong — is obtained instead viacartesian_sites().- Parameters:
reduced_coords (httk.core.VectorLike) – The reduced coordinates, one site per row.
precision (Any) – The fractional precision carried from the source, if known.
- property reduced_coords: httk.core.FracVector¶
The Nx3 reduced site coordinates as an exact
FracVector(one site per row).
- property precision: fractions.Fraction | None¶
How precisely these coordinates were stated, in fractional units, or
None.Fractional and therefore dimensionless: reduced coordinates are fractions of a cell edge, and a
Sitescarries no cell to convert with. Usecartesian_precision()for the corresponding length, which is the number an interatomic tolerance or an spglibsymprecactually wants.It is the coarsest precision among the coordinates, since a structure is only as precisely stated as its least precisely stated number.
Nonemeans unknown.- Returns:
The fractional precision, or
Nonewhen unknown.- Return type:
fractions.Fraction | None
- numeric()[source]¶
Return a plain-numpy presentation of these sites.
- Returns:
The numpy-backed presentation.
- Raises:
ImportError – If numpy is unavailable.
- Return type:
- class httk.atomistic.models.sites.SitesView(obj, **hints)[source]¶
Bases:
httk.atomistic.models.sites.view_base.SitesViewBase,httk.atomistic.models.sites.sites.SitesA view presenting an underlying sites backend as a
Sitesobject.This view is a genuine
Sites, so it can be passed anywhere a Sites is accepted. Its state is built lazily on first access from the backend.- Parameters:
obj (httk.atomistic.models.sites.like.SitesLike) – The sites-like object to present.
**hints (Any) – Backend-selection hints.
- unwrap()[source]¶
Return the raw object behind the backend.
- Returns:
The unwrapped source object.
- Return type:
Any
- class httk.atomistic.models.sites.SitesViewBase[source]¶
Bases:
httk.core.View[httk.atomistic.models.sites.backend.SitesBackend]Abstract base class for all views of sites data.