httk.atomistic¶
httk-atomistic: crystal structure representations for httk v2.
Provides the Structure domain and its component families (Cell, Sites, Species),
each following the httk-core view/backend pattern. A Structure holds a cell, a
sites, a tuple of species, and a species_at_sites; each component has a
class representation and a primitive representation convertible through views. ASU and
exact-vector numerics are planned follow-ups.
Submodules¶
- httk.atomistic.cell
- httk.atomistic.cell_api
- httk.atomistic.cell_backend
- httk.atomistic.cell_class
- httk.atomistic.cell_class_view
- httk.atomistic.cell_like
- httk.atomistic.cell_numeric_view
- httk.atomistic.cell_params
- httk.atomistic.cell_params_view
- httk.atomistic.cell_primitive
- httk.atomistic.cell_primitive_view
- httk.atomistic.cell_view
- httk.atomistic.elements
- httk.atomistic.numeric_cell
- httk.atomistic.numeric_sites
- httk.atomistic.numeric_structure
- httk.atomistic.sites
- httk.atomistic.sites_api
- httk.atomistic.sites_backend
- httk.atomistic.sites_class
- httk.atomistic.sites_class_view
- httk.atomistic.sites_like
- httk.atomistic.sites_numeric_view
- httk.atomistic.sites_primitive
- httk.atomistic.sites_primitive_view
- httk.atomistic.sites_view
- httk.atomistic.species
- httk.atomistic.species_api
- httk.atomistic.species_backend
- httk.atomistic.species_class
- httk.atomistic.species_class_view
- httk.atomistic.species_like
- httk.atomistic.species_primitive
- httk.atomistic.species_primitive_view
- httk.atomistic.species_view
- httk.atomistic.structure
- httk.atomistic.structure_api
- httk.atomistic.structure_backend
- httk.atomistic.structure_entries
- httk.atomistic.structure_like
- httk.atomistic.structure_numeric_view
- httk.atomistic.structure_primitive
- httk.atomistic.structure_primitive_view
- httk.atomistic.structure_simple
- httk.atomistic.structure_simple_view
- httk.atomistic.structure_view
- httk.atomistic.vasp_structures
Attributes¶
The 118 IUPAC element symbols in atomic-number order ( |
|
Classes¶
A crystallographic cell: its basis, the 3x3 matrix of cell vectors, held exactly. |
|
Abstract base class for the canonical cell interface. |
|
Abstract base class for all backends of cell data. |
|
Backend for a cell backed by an actual |
|
A view presenting an underlying cell backend as a |
|
A view presenting an underlying cell backend as a |
|
Backend for a cell backed by cell parameters |
|
A view presenting an underlying cell backend as cell parameters. |
|
Backend for a cell backed by a raw 3x3 list or tuple of numbers (or any 3x3 vector-like). |
|
A view presenting an underlying cell backend as the raw 3x3 basis matrix of floats. |
|
Abstract base class for all views of cell data. |
|
A plain-numpy presentation of a |
|
A plain-numpy presentation of a |
|
A plain-numpy presentation of a |
|
The sites of a crystal structure: the Nx3 matrix of reduced coordinates, held exactly. |
|
Abstract base class for the canonical sites interface. |
|
Abstract base class for all backends of sites data. |
|
Backend for sites backed by an actual |
|
A view presenting an underlying sites backend as 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. |
|
Abstract base class for all views of sites data. |
|
A chemical species occupying one or more sites, mirroring the OPTIMADE |
|
Abstract base class for the canonical single-species interface. |
|
Abstract base class for all backends of single-species data. |
|
Backend for a species backed by an actual |
|
A view presenting an underlying species backend as a |
|
Backend for a species backed by an OPTIMADE species dict. |
|
A view presenting an underlying species backend as an OPTIMADE species dict. |
|
Abstract base class for all views of single-species data. |
|
A crystal structure in the Simple representation. |
|
Abstract base class for the canonical structure interface. |
|
Abstract base class for all backends of crystal structure data. |
|
Serves OPTIMADE |
|
A view presenting an underlying structure backend as a |
|
Backend for a crystal structure backed by an spglib-like triple. |
|
A view presenting an underlying structure backend as a primitive triple. |
|
Backend for a crystal structure backed by an actual |
|
A view presenting an underlying structure backend as a |
|
Abstract base class for all views of crystal structure data. |
Functions¶
|
Return the atomic number (1-118) of an element symbol. |
|
Return the element symbol for the atomic number z (1-118). |
|
Load a file and build a |
|
Build an exact |
Package Contents¶
- class httk.atomistic.Cell(basis: httk.core.VectorLike, scale: Any = 1)[source]¶
A crystallographic cell: its basis, the 3x3 matrix of cell vectors, held exactly.
The lattice vectors are the rows of
basis. Internally a Cell factors that basis into a positiveSurdScalarscaletimes anunscaled_basis(aSurdVectorof shape(3, 3)), withbasis == scale * unscaled_basis. The split lets an overall length factor be carried symbolically: a hexagonal cell of lattice parameteraand ratioc/ais the exactunscaledrows(1, 0, 0),(-1/2, sqrt(3)/2, 0),(0, 0, c/a)scaled bya— so thesqrt(3)stays exact regardless ofa. A cell built from an absolute basis simply hasscale == 1.Numbers embed exactly: rationals (and rational-valued floats) stay rational, and a
SurdVectorbasis keeps its radicals. Derived quantities are exact whenever the geometry is metric-rational (the crystallographic case):lengthscome fromsqrt_of()of the rational squared row lengths,angles(degrees) from the exact reverse-Nivenacos_degrees()where possible,volumefrom the exact determinant, andmetricis the exact rational Gram matrix. When a squared length happens to be irrational,lengths/anglesfall back to a deterministic rational approximation (documented per accessor). Exact accessors return vector objects — render them with.to_floats()(nested plain-float lists, numpy-free),float(...)on scalars,numeric()(true numpy arrays), or a view of your choice.- property scale: httk.core.SurdScalar¶
The overall (strictly positive) length factor, as an exact
SurdScalar.
- property unscaled_basis: httk.core.SurdVector¶
The 3x3 cell vectors before applying
scale, as an exactSurdVector.
- property basis: httk.core.SurdVector¶
The 3x3 lattice vectors
scale * unscaled_basis(one vector per row), exact.
- numeric() httk.atomistic.numeric_cell.NumericCell[source]¶
A plain-numpy presentation of this cell (requires the
httk-atomistic[numpy]extra).
- metric() httk.core.SurdVector[source]¶
The exact Gram matrix
matrix * matrix^T(rational for a metric-rational cell).
- property lengths: tuple[httk.core.SurdScalar, Ellipsis]¶
The lengths of the three cell vectors (the scaled row norms).
Exact via
sqrt_of()whenever the row’s squared length is rational (the crystallographic case); otherwise a deterministic rational-approximationSurdScalarat_FALLBACK_PREC(the length would be a nested radical, outside the surd field).
- property angles: tuple[fractions.Fraction, Ellipsis]¶
The cell angles
(alpha, beta, gamma)in degrees, as exactFractionvalues.Following the crystallographic convention,
alphais the angle between rowsbandc,betabetweenaandc, andgammabetweenaandb. Angles are scale-independent, so they are computed from the unscaled basis. The cosine is formed exactly in the surd field and reversed through the Niven table (acos_degrees()) for an exact answer; a non-Niven angle falls back to a deterministicacos()at_FALLBACK_PREC.
- property volume: httk.core.SurdScalar¶
The cell volume, the exact absolute determinant of
basis.
- class httk.atomistic.CellAPI[source]¶
Bases:
abc.ABCAbstract base class for the canonical cell interface.
It declares the exact accessors that every cell backend produces from its own native representation and every cell view builds its presentation from: the
basisof 3x3 lattice vectors (scale * unscaled_basis), the positivescale, and theunscaled_basis. All three are exact httk-core vectors; this is the single interchange format, with no pairwise conversion between backends.- property basis: httk.core.SurdVector¶
- Abstractmethod:
- property scale: httk.core.SurdScalar¶
- Abstractmethod:
- property unscaled_basis: httk.core.SurdVector¶
- Abstractmethod:
- class httk.atomistic.CellBackend(backend, **hints)[source]¶
Bases:
httk.core.Backend[CellBackend],httk.atomistic.cell_api.CellAPIAbstract base class for all backends of cell data.
Concrete backends carry a native representation and produce the canonical 3x3
basisdeclared byCellAPIfrom it.- backend_classes: ClassVar[list[type[httk.core.Backend[Any]]]]¶
- class httk.atomistic.CellClass(obj: httk.atomistic.cell.Cell, **hints: Any)[source]¶
Bases:
httk.atomistic.cell_backend.CellBackendBackend for a cell backed by an actual
Cellobject.Its exact accessors delegate to the wrapped Cell (preserving its
scale/unscaled_basissplit), andunwrapreturns that Cell.- property basis: httk.core.SurdVector¶
- property scale: httk.core.SurdScalar¶
- property unscaled_basis: httk.core.SurdVector¶
- unwrap() Any[source]¶
Return the most raw representation possible of this backend, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.CellClassView(obj: httk.atomistic.cell_like.CellLike, **hints: Any)[source]¶
Bases:
httk.atomistic.cell_view.CellView,httk.atomistic.cell.CellA view presenting an underlying cell backend as a
Cell.This view is a genuine
Cell, so it can be passed anywhere a Cell is accepted. Its basis is built eagerly from the backend on construction.- unwrap() Any[source]¶
Return the most raw representation possible of this view, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- type httk.atomistic.CellLike = cell_backend.CellBackend | cell_view.CellView | cell.Cell | httk.core.VectorLike[source]¶
- class httk.atomistic.CellNumericView(obj: httk.atomistic.cell_like.CellLike, **hints: Any)[source]¶
Bases:
httk.atomistic.cell_view.CellView,httk.atomistic.numeric_cell.NumericCellA view presenting an underlying cell backend as a
NumericCell.This view is a genuine
NumericCell, so it can be passed anywhere one is accepted. Its exactCellis built eagerly from the backend on construction, preserving the scale/unscaled split. Like aNumericCellit requires numpy (raisingImportErrorotherwise).- unwrap() Any[source]¶
Return the most raw representation possible of this view, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.CellParams(obj: Any, **hints: Any)[source]¶
Bases:
httk.atomistic.cell_backend.CellBackendBackend for a cell backed by cell parameters
(a, b, c, alpha, beta, gamma).The native representation is a flat length-6 vector-like of the cell-vector lengths
a/b/cand the anglesalpha/beta/gammain degrees, stored as exactFractionvalues (parsed viaany_to_fraction()). The exactbasisis derived lazily and cached using the standard crystallographic orientation convention (first cell vector along x, second in the xy-plane); for the common Niven angles it is exact (radicals intact). Since parameters carry no separate length factor,scaleis the exact1andunscaled_basis == basis. Parameters carry no orientation, so a cell → parameters → cell round-trip reproduces lengths, angles, and volume, but not the original orientation.unwrapreturns the original raw object.- property basis: httk.core.SurdVector¶
- property scale: httk.core.SurdScalar¶
- property unscaled_basis: httk.core.SurdVector¶
- property params: tuple[fractions.Fraction, Ellipsis]¶
The stored
(a, b, c, alpha, beta, gamma)as exact Fractions (angles in degrees).
- unwrap() Any[source]¶
Return the most raw representation possible of this backend, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.CellParamsView(obj: httk.atomistic.cell_like.CellLike, **hints: Any)[source]¶
Bases:
httk.atomistic.cell_view.CellView,tupleA view presenting an underlying cell backend as cell parameters.
This view is a genuine flat 6-tuple
(a, b, c, alpha, beta, gamma)with the angles in degrees, built eagerly and immutable, with the elements also available as the named propertiesa/b/c/alpha/beta/gamma. Parameters carry no orientation, so converting a cell to parameters is lossy: reconstructing a cell from this view reproduces the lengths, angles, and volume, but not the original cell-vector orientation.- unwrap() Any[source]¶
Return the most raw representation possible of this view, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.CellPrimitive(obj: Any, **hints: Any)[source]¶
Bases:
httk.atomistic.cell_backend.CellBackendBackend for a cell backed by a raw 3x3 list or tuple of numbers (or any 3x3 vector-like).
The native representation is preserved verbatim (one cell vector per row); the exact
SurdVectorbasisis built lazily and cached. This representation carries no separate length factor, soscaleis the exact1andunscaled_basis == basis.unwrapreturns the original raw object.- property basis: httk.core.SurdVector¶
- property scale: httk.core.SurdScalar¶
- property unscaled_basis: httk.core.SurdVector¶
- unwrap() Any[source]¶
Return the most raw representation possible of this backend, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.CellPrimitiveView(obj: httk.atomistic.cell_like.CellLike, **hints: Any)[source]¶
Bases:
httk.atomistic.cell_view.CellView,tupleA view presenting an underlying cell backend as the raw 3x3 basis matrix of floats.
This view is a genuine tuple of three cell-vector rows (the scaled lattice vectors rendered to floats from the exact
basis), built eagerly and immutable.- unwrap() Any[source]¶
Return the most raw representation possible of this view, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.CellView[source]¶
Bases:
httk.core.View[httk.atomistic.cell_backend.CellBackend]Abstract base class for all views of cell data.
- httk.atomistic.SYMBOLS: tuple[str, Ellipsis] = ('H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl',...[source]¶
The 118 IUPAC element symbols in atomic-number order (
SYMBOLS[0]is hydrogen).
- httk.atomistic.atomic_number(symbol: str) int[source]¶
Return the atomic number (1-118) of an element symbol.
Raises ValueError for anything that is not one of the 118 element symbols (in particular for the
"X"and"vacancy"pseudo-symbols).
- httk.atomistic.symbol_of(z: int) str[source]¶
Return the element symbol for the atomic number z (1-118).
Raises ValueError for atomic numbers outside the 1-118 range.
- class httk.atomistic.NumericCell(cell: httk.atomistic.cell_like.CellLike)[source]¶
A plain-numpy presentation of a
Cell.Where a
Cellholds its geometry exactly (aSurdVectorbasis, exactSurdScalarlengths/volume, exactFractionangles), aNumericCellmirrors that interface but returns plain numpy numbers — afloat64numpy.ndarrayfor every vector and a plainfloatfor every scalar — for callers who do not need exact arithmetic and just want numpy arrays.The presentation is numpy-backed, so constructing a
NumericCellrequires numpy (thehttk-atomistic[numpy]extra) and raisesImportErroreagerly when it is unavailable. The exact object is always one hop away viaexact.- property unscaled_basis: httk.core.NumericVector¶
The 3x3 cell vectors before applying
scaleas afloat64numpy array.
- property basis: httk.core.NumericVector¶
The 3x3 lattice vectors
scale * unscaled_basisas afloat64numpy array.
- property lengths: httk.core.NumericVector¶
The three cell-vector lengths as a
(3,)float64numpy array.
- property angles: httk.core.NumericVector¶
The cell angles
(alpha, beta, gamma)in degrees as a(3,)float64numpy array.
- metric() httk.core.NumericVector[source]¶
The Gram matrix
basis * basis^Tas afloat64numpy array.
- property exact: httk.atomistic.cell.Cell¶
The exact
Cellthis presentation wraps.
- class httk.atomistic.NumericSites(sites: httk.atomistic.sites_like.SitesLike)[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.- property reduced_coords: httk.core.NumericVector¶
The Nx3 reduced site coordinates as a
float64numpy array.
- property exact: httk.atomistic.sites.Sites¶
The exact
Sitesthis presentation wraps.
- class httk.atomistic.NumericStructure(structure: httk.atomistic.structure_like.StructureLike)[source]¶
A plain-numpy presentation of a
Structure.Where a
Structureholds its geometry exactly (a surdcellbasis, rational reduced coordinates, an exact Cartesian frame), aNumericStructuremirrors that interface but returns plain numpy numbers: itscellis aNumericCell, itssitesaNumericSites, andcartesian_sites()afloat64numpy array. Thespecies/species_at_sitesare passed through unchanged (they are already plain data). It is for callers who do not need exact arithmetic and just want numpy arrays.The presentation is numpy-backed, so constructing a
NumericStructurerequires numpy (thehttk-atomistic[numpy]extra) and raisesImportErroreagerly when it is unavailable. The exact object is always one hop away viaexact.- property cell: httk.atomistic.numeric_cell.NumericCell¶
The cell as a
NumericCell.
- property sites: httk.atomistic.numeric_sites.NumericSites¶
The sites as a
NumericSites.
- property species: tuple[httk.atomistic.species.Species, Ellipsis]¶
The distinct species, passed through unchanged.
- property species_at_sites: tuple[str, Ellipsis]¶
The species name occupying each site, passed through unchanged.
- cartesian_sites() httk.core.NumericVector[source]¶
The Cartesian site positions as an
(N, 3)float64numpy array.
- property exact: httk.atomistic.structure.Structure¶
The exact
Structurethis presentation wraps.
- class httk.atomistic.Sites(reduced_coords: httk.core.VectorLike)[source]¶
The 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 reduced deterministically through the vector family’sfractionshub (never raising on data); the exact Cartesian frame — where radicals belong — is obtained instead viacartesian_sites().- property reduced_coords: httk.core.FracVector¶
The Nx3 reduced site coordinates as an exact
FracVector(one site per row).
- numeric() httk.atomistic.numeric_sites.NumericSites[source]¶
A plain-numpy presentation of these sites (requires the
httk-atomistic[numpy]extra).
- class httk.atomistic.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:
- class httk.atomistic.SitesBackend(backend, **hints)[source]¶
Bases:
httk.core.Backend[SitesBackend],httk.atomistic.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]]]]¶
- class httk.atomistic.SitesClass(obj: httk.atomistic.sites.Sites, **hints: Any)[source]¶
Bases:
httk.atomistic.sites_backend.SitesBackendBackend for sites backed by an actual
Sitesobject.Its
reduced_coordsaccessor delegates to the wrapped Sites, andunwrapreturns that Sites.- property reduced_coords: httk.core.FracVector¶
- unwrap() Any[source]¶
Return the most raw representation possible of this backend, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.SitesClassView(obj: httk.atomistic.sites_like.SitesLike, **hints: Any)[source]¶
Bases:
httk.atomistic.sites_view.SitesView,httk.atomistic.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 coordinates are built eagerly from the backend on construction.- unwrap() Any[source]¶
Return the most raw representation possible of this view, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- type httk.atomistic.SitesLike = sites_backend.SitesBackend | sites_view.SitesView | sites.Sites | httk.core.VectorLike[source]¶
- class httk.atomistic.SitesNumericView(obj: httk.atomistic.sites_like.SitesLike, **hints: Any)[source]¶
Bases:
httk.atomistic.sites_view.SitesView,httk.atomistic.numeric_sites.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 eagerly from the backend on construction. Like aNumericSitesit requires numpy (raisingImportErrorotherwise).- unwrap() Any[source]¶
Return the most raw representation possible of this view, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.SitesPrimitive(obj: Any, **hints: Any)[source]¶
Bases:
httk.atomistic.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.- property reduced_coords: httk.core.FracVector¶
- unwrap() Any[source]¶
Return the most raw representation possible of this backend, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.SitesPrimitiveView(obj: httk.atomistic.sites_like.SitesLike, **hints: Any)[source]¶
Bases:
httk.atomistic.sites_view.SitesView,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.- unwrap() Any[source]¶
Return the most raw representation possible of this view, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.SitesView[source]¶
Bases:
httk.core.View[httk.atomistic.sites_backend.SitesBackend]Abstract base class for all views of sites data.
- class httk.atomistic.Species[source]¶
A chemical species occupying one or more sites, mirroring the OPTIMADE
speciesobject.A species has a
name(unique within a structure; it need not be a chemical symbol), a list ofchemical_symbolscomposing it, and a matching list ofconcentrationvalues. Each chemical symbol is an element symbol, or one of the pseudo-symbols"X"(unknown) or"vacancy". The optionalmass,attached,nattached, andoriginal_namefields carry the remaining OPTIMADE species information;attachedandnattachedmust be given together and share their length.- property is_single_element: bool¶
Whether this species is a single, unattached, real chemical element.
True only for a species composed of exactly one element symbol (not
"X"or"vacancy") with no attached particles. Such species are the ones that can be represented as a bare atomic number in the primitive representation.
- class httk.atomistic.SpeciesAPI[source]¶
Bases:
abc.ABCAbstract base class for the canonical single-species interface.
It declares the accessors mirroring the OPTIMADE
speciesfields that every species backend produces from its own native representation and every species view builds its presentation from:name,chemical_symbols,concentration, and the optionalmass,attached,nattached, andoriginal_name.
- class httk.atomistic.SpeciesBackend(backend, **hints)[source]¶
Bases:
httk.core.Backend[SpeciesBackend],httk.atomistic.species_api.SpeciesAPIAbstract base class for all backends of single-species data.
Concrete backends carry a native representation and produce the canonical OPTIMADE species accessors declared by
SpeciesAPIfrom it.- backend_classes: ClassVar[list[type[httk.core.Backend[Any]]]]¶
- class httk.atomistic.SpeciesClass(obj: httk.atomistic.species.Species, **hints: Any)[source]¶
Bases:
httk.atomistic.species_backend.SpeciesBackendBackend for a species backed by an actual
Speciesobject.Its accessors delegate to the wrapped Species, and
unwrapreturns that Species.- unwrap() Any[source]¶
Return the most raw representation possible of this backend, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.SpeciesClassView(obj: httk.atomistic.species_like.SpeciesLike, **hints: Any)[source]¶
Bases:
httk.atomistic.species_view.SpeciesView,httk.atomistic.species.SpeciesA view presenting an underlying species backend as a
Species.This view is a genuine frozen
Species, so it can be passed anywhere a Species is accepted. Its fields are built eagerly from the backend on construction, with fullSpeciesvalidation applied at that point.- unwrap() Any[source]¶
Return the most raw representation possible of this view, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- type httk.atomistic.SpeciesLike = species_backend.SpeciesBackend | species_view.SpeciesView | species.Species | dict[str, Any][source]¶
- class httk.atomistic.SpeciesPrimitive(obj: dict[str, Any], **hints: Any)[source]¶
Bases:
httk.atomistic.species_backend.SpeciesBackendBackend for a species backed by an OPTIMADE species dict.
The native representation is a mapping with the OPTIMADE
speciesfields; the requiredname/chemical_symbols/concentrationare validated conservatively on construction. The accessors read the corresponding fields (optional fields absent from the dict read asNone), andunwrapreturns the original dict.- unwrap() Any[source]¶
Return the most raw representation possible of this backend, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.SpeciesPrimitiveView(obj: httk.atomistic.species_like.SpeciesLike, **hints: Any)[source]¶
Bases:
httk.atomistic.species_view.SpeciesView,dictA view presenting an underlying species backend as an OPTIMADE species dict.
This view is a genuine
dictcarrying the OPTIMADEspeciesfields (optional fields that areNoneare omitted; list-valued fields are plain lists). Unlike the immutable-subclass views, a dict is mutable, so this view is a detached copy: mutating it does not affect the underlying backend.- unwrap() Any[source]¶
Return the most raw representation possible of this view, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.SpeciesView[source]¶
Bases:
httk.core.View[httk.atomistic.species_backend.SpeciesBackend]Abstract base class for all views of single-species data.
- class httk.atomistic.Structure(cell: httk.atomistic.cell_like.CellLike, sites: httk.atomistic.sites_like.SitesLike, species: collections.abc.Sequence[httk.atomistic.species_like.SpeciesLike], species_at_sites: collections.abc.Sequence[str])[source]¶
A crystal structure in the Simple representation.
A Structure holds a
cell(aCellof 3x3 cell vectors),sites(aSitesof Nx3 reduced coordinates), a list ofspecies(each aSpecies), and a length-Nspecies_at_sitesgiving the species name occupying each site. Inputs are normalized on construction through the component families: the cell, sites, and each species are passed through their*Likeunions, and everyspecies_at_sitesname must match one of the (uniquely named) species.The numeric model is exact and split by purpose. The fractional frame — reduced coordinates and symmetry — is rational and lives in
sitesas aFracVector. The Cartesian frame — where radicals such as the hexagonalsqrt(3)appear — is exact in the squarefree-radical field:cell.basisis aSurdVectorandcartesian_sites()returns the exact Cartesian positions. Pure magnitudes (bond-length comparisons) stay rational-exact viacell.metric(). Floats appear only at the presentation and JSON boundaries.- property cell: httk.atomistic.cell.Cell¶
The cell (3x3 cell vectors) as a
Cell.
- property sites: httk.atomistic.sites.Sites¶
The site coordinates (Nx3 reduced coordinates) as a
Sites.
- property species: tuple[httk.atomistic.species.Species, Ellipsis]¶
The distinct species of this structure.
- property species_at_sites: tuple[str, Ellipsis]¶
The species name occupying each site, in site order.
- cartesian_sites() httk.core.SurdVector[source]¶
The exact Cartesian site positions as an
(N, 3)SurdVector.Under the row-vector convention this is
reduced_coords * cell.basis(each Cartesian position is the sum over lattice vectorssum_k reduced[k] * basis[k]). The reduced coordinates are rational (aFracVector), the cell basis carries the radicals (aSurdVector), so the product is exact in the surd field — the hexagonalsqrt(3)survives into the Cartesian positions.
- numeric() httk.atomistic.numeric_structure.NumericStructure[source]¶
A plain-numpy presentation of this structure (requires the
httk-atomistic[numpy]extra).
- class httk.atomistic.StructureAPI[source]¶
Bases:
abc.ABCAbstract base class for the canonical structure interface.
It declares the Simple quartet that every structure backend produces from its own native representation and every structure view builds its presentation from:
cell,sites,species, andspecies_at_sites. This is the single interchange format; there is no pairwise conversion between backends.- property cell: httk.atomistic.cell.Cell¶
- Abstractmethod:
- property sites: httk.atomistic.sites.Sites¶
- Abstractmethod:
- property species: tuple[httk.atomistic.species.Species, Ellipsis]¶
- Abstractmethod:
- class httk.atomistic.StructureBackend(backend, **hints)[source]¶
Bases:
httk.core.Backend[StructureBackend],httk.atomistic.structure_api.StructureAPIAbstract base class for all backends of crystal structure data.
Concrete backends carry a native representation and produce the canonical Simple quartet declared by
StructureAPIfrom it.- backend_classes: ClassVar[list[type[httk.core.Backend[Any]]]]¶
- class httk.atomistic.StructureEntryProvider(entries: collections.abc.Mapping[str, httk.atomistic.structure_like.StructureLike | None], *, extra_definitions: collections.abc.Mapping[str, httk.core.PropertyDefinition] | None = None, properties: collections.abc.Mapping[str, collections.abc.Mapping[str, Any]] | None = None)[source]¶
Bases:
httk.core.EntryProviderServes OPTIMADE
structuresfrom a mapping of id to structure.entriesmaps each entry id to aStructure(or any structure exposing thecell/sites/species/species_at_sitesquartet, or a(cell, sites, species, species_at_sites)tuple), or toNonefor a known entry that has no structure (its structural columns then serve null).The always-served structural fields are
id,type,nsites,elements,nelements,species(as OPTIMADE species dicts),species_at_sites,lattice_vectors(the cell basis rows),cartesian_site_positions(reduced coordinates times the cell basis), andstructure_features(disorderwhen any species mixes several chemical symbols;site_attachmentswhen any species has attached atoms). The standard composition fieldsnperiodic_dimensions,dimension_types,elements_ratios,chemical_formula_reduced/_anonymous/_descriptiveare auto-derived for a fully ordered structure (every species a single, unattached element), else served as null.extra_definitionsextends the served entry-type definition with custom database-specific properties (each carrying a registered prefix), andpropertiessupplies their per-entry values as{entry_id: {name: value}}; every property named there MUST be described by the (extended) definition (aValueErrorat construction names any offender), and a value absent for an entry is served as null.- entry_types() collections.abc.Mapping[str, httk.core.EntryTypeDefinition][source]¶
- records(entry_type: str) collections.abc.Iterable[collections.abc.Mapping[str, Any]][source]¶
- type httk.atomistic.StructureLike = structure_backend.StructureBackend | structure_view.StructureView | structure.Structure | tuple[httk.core.VectorLike, httk.core.VectorLike, Any] | list[Any][source]¶
- class httk.atomistic.StructureNumericView(obj: httk.atomistic.structure_like.StructureLike, **hints: Any)[source]¶
Bases:
httk.atomistic.structure_view.StructureView,httk.atomistic.numeric_structure.NumericStructureA view presenting an underlying structure backend as a
NumericStructure.This view is a genuine
NumericStructure, so it can be passed anywhere one is accepted. Its exactStructureis built eagerly from the backend’s quartet on construction. Like aNumericStructureit requires numpy (raisingImportErrorotherwise).- unwrap() Any[source]¶
Return the most raw representation possible of this view, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.StructurePrimitive(obj: Any, **hints: Any)[source]¶
Bases:
httk.atomistic.structure_backend.StructureBackendBackend for a crystal structure backed by an spglib-like triple.
The native representation is a length-3
(lattice, positions, numbers)list or tuple, wherelatticeis 3x3,positionsis Nx3 reduced coordinates, andnumbersis the length-N sequence of atomic numbers. The quartet is derived lazily and cached:cellis aCell,sitesaSites,speciesone single-elementSpeciesper distinct atomic number, andunwrapreturns the original triple.- property cell: httk.atomistic.cell.Cell¶
- property sites: httk.atomistic.sites.Sites¶
- property species: tuple[httk.atomistic.species.Species, Ellipsis]¶
- unwrap() Any[source]¶
Return the most raw representation possible of this backend, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.StructurePrimitiveView(obj: httk.atomistic.structure_like.StructureLike, **hints: Any)[source]¶
Bases:
httk.atomistic.structure_view.StructureView,tupleA view presenting an underlying structure backend as a primitive triple.
This view is a genuine
(lattice, positions, numbers)tuple, built eagerly and immutable. Because the primitive representation carries only bare atomic numbers, every site’s species must be a single, unattached chemical element (seeSpecies.is_single_element); otherwise a TypeError is raised.- unwrap() Any[source]¶
Return the most raw representation possible of this view, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.StructureSimple(obj: httk.atomistic.structure.Structure, **hints: Any)[source]¶
Bases:
httk.atomistic.structure_backend.StructureBackendBackend for a crystal structure backed by an actual
Structureobject.Its quartet accessors delegate to the wrapped Structure, and
unwrapreturns that Structure.- property cell: httk.atomistic.cell.Cell¶
- property sites: httk.atomistic.sites.Sites¶
- property species: tuple[httk.atomistic.species.Species, Ellipsis]¶
- unwrap() Any[source]¶
Return the most raw representation possible of this backend, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.StructureSimpleView(obj: httk.atomistic.structure_like.StructureLike, **hints: Any)[source]¶
Bases:
httk.atomistic.structure_view.StructureView,httk.atomistic.structure.StructureA view presenting an underlying structure backend as a
Structure.This view is a genuine
Structure, so it can be passed anywhere a Structure is accepted. Its quartet is built eagerly from the backend on construction.- unwrap() Any[source]¶
Return the most raw representation possible of this view, i.e., if it uses a backend with an internal representaion - or if it can (possibly lossly) convert itself into a more raw representation that still would be recognized as a <Something>Like type, that representation will be returned. If this is not possible, the instance itself is returned.
- class httk.atomistic.StructureView[source]¶
Bases:
httk.core.View[httk.atomistic.structure_backend.StructureBackend]Abstract base class for all views of crystal structure data.
- httk.atomistic.load_structure(path: str) httk.atomistic.structure.Structure[source]¶
Load a file and build a
Structurefrom it.httk.core.load(path)selects the reader by file type (transparently decompressing.bz2/.gzfiles); the payload’s"format"tag then selects the matching structure builder. A payload without a recognized"format"tag (for example a CIF, which returns a different shape) raises a clearValueError.
- httk.atomistic.structure_from_poscar(data: collections.abc.Mapping[str, Any]) httk.atomistic.structure.Structure[source]¶
Build an exact
Structurefrom a neutral POSCAR mapping.datais the mapping returned byhttk.io.read_poscar(itsformatmust be"vasp-poscar"). The cell basis is taken exactly from the file’s string rows. For a positive universal scaling factor thescalestring is used directly as the cell’s exact scale; for a negative scaling factor (a target volumeV) the scale is the cube root ofV / |det(basis)|— a value outside the exact surd field, so it is a deterministic rational approximation (the basis rows themselves stay exact).Direct coordinates become reduced coordinates directly (exact strings). Cartesian coordinates are converted exactly as
cart * basis.inv()under the row-vector convention; because VASP scales both the lattice vectors and the Cartesian positions by the universal scaling factor, that factor cancels and the reduced coordinates are exact regardless of the scale/volume case.Species come from the VASP-5 species line (one single-element, unattached
Speciesof concentration 1.0 per distinct symbol); a VASP-4 file (no species symbols) raises aValueError. Selective dynamics flags, if present, are ignored.