httk.atomistic.cell¶
The Cell class for httk-atomistic.
Classes¶
A crystallographic cell: its basis, the 3x3 matrix of cell vectors, held exactly. |
Module Contents¶
- class httk.atomistic.cell.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[source]¶
The overall (strictly positive) length factor, as an exact
SurdScalar.
- property unscaled_basis: httk.core.SurdVector[source]¶
The 3x3 cell vectors before applying
scale, as an exactSurdVector.
- property basis: httk.core.SurdVector[source]¶
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][source]¶
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][source]¶
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[source]¶
The cell volume, the exact absolute determinant of
basis.