kups.core.cell
¶
Simulation cell representations.
This module separates two concepts that other simulation codes usually conflate into one "cell" object:
-
Frame — pure geometry. A 3D parallelepiped defined by three basis vectors. No periodicity, no boundary semantics. What ASE calls
cell, OpenMM callsboxVectors, LAMMPS calls the simulation box; in crystallography the basis vectors of a periodic structure are conventionally called lattice vectors.Framesubsumes all of these — a Frame just describes a parallelepiped, and the meaning (periodic-translation vector vs bounding-box edge) is supplied by the cell type that wraps it. -
Cell — frame plus per-axis boundary semantics. Decides whether the frame is interpreted as a periodic unit cell or a bounding domain on each axis.
Why split: the same parallelepiped means different things in different
contexts. A 30 Å cubic frame inside a PeriodicCell
is a periodic unit cell — particles wrap, neighbor searches honour minimum
image. The same frame inside a VacuumCell is
the bounding box of a finite domain — no wrapping, neighbor searches treat
it as a spatial-partitioning hint. Naming the geometry "Lattice" or "Cell"
would prejudice the reading toward the periodic case; Frame is
boundary-condition-agnostic and reads equally honestly in both.
Frame implementations¶
- OrthogonalFrame — 3 DOF, axes-aligned parallelepiped parameterized by side lengths. Diagonal fast paths for volume, inverse, and coordinate transforms.
- TriclinicFrame — 6 DOF, general parallelepiped parameterized by the lower-triangular elements of the basis matrix.
- MaterializedFrame — caches
vectors,inverse_vectors, andvolumeas concrete arrays. Produced byFrame.materialize; useful when the same frame is queried many times or when the inverse needs to be cached across a JIT boundary.
Both expose vectors (the basis matrix —
this is what crystallography calls lattice vectors),
inverse_vectors,
volume,
perpendicular_lengths,
to_fractional /
to_real coordinate transforms, plus
tile for per-axis multiplicity tiling and
__mul__ for uniform scaling.
Cell implementations¶
- PeriodicCell — all three axes periodic
(literal
(True, True, True)). The frame is the unit cell of a periodic crystal or fluid. - VacuumCell — all three axes open (literal
(False, False, False)). The frame is the bounding parallelepiped of a finite simulation domain.
Cell is generic over the periodicity literal P
so consumers can narrow statically on the boundary axis. An Ewald path
that requires periodic boundaries declares Cell[Periodic3D] and
pyright rejects VacuumCell at the call site:
def ewald(cell: Cell[Periodic3D]) -> Energy: ...
ewald(PeriodicCell(frame)) # OK
ewald(VacuumCell(frame)) # pyright: "Vacuum is not assignable to Periodic3D"
Cell re-exposes the frame's geometric properties as passthrough so callers
can write cell.volume, cell.vectors etc. without going through
cell.frame. For frame-specific fields (OrthogonalFrame.lengths,
TriclinicFrame.tril / angles), narrow with isinstance:
The same Frame instance can be wrapped in either cell type:
frame = OrthogonalFrame(lengths=jnp.array([20., 20., 20.]))
PeriodicCell(frame) # 20 Å cubic crystal — particles wrap
VacuumCell(frame) # 20 Å bounding box of a cluster — no wrap
Convention¶
Frame vectors follow the row convention: r_real = r_frac @ frame.vectors.
BaseFrame
¶
Bases: Frame, ABC
Abstract base implementing every Frame
operation that derives purely from
vectors.
Concrete frames subclass BaseFrame and supply only their
parameterisation — the vectors primitive plus
from_matrix,
tile and __mul__. The lower-triangular
convention shared by all frames lets the basis inverse, volume,
perpendicular lengths, and coordinate transforms be computed here once via
the triangular fast paths in
kups.core.utils.math. Subclasses may override any
of these with cheaper specialised forms (e.g. OrthogonalFrame's
diagonal paths).
Mirrors the Lens /
BaseLens split: Frame is the structural
interface, BaseFrame the shared implementation.
Source code in src/kups/core/cell.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
Cell
¶
Bases: Sliceable, Generic[_P]
A Frame plus per-axis boundary semantics.
Generic over the periodicity literal P (a length-3 tuple of
booleans). PeriodicCell and
VacuumCell are subclasses that pin P
to a literal-typed default; for slab and wire geometries, construct
Cell(frame, periodic=mask) directly — the literal tuple narrows
P to the corresponding [Slab2D][kups.core.cell.Slab2D] or
[Wire1D][kups.core.cell.Wire1D] alias.
The cell delegates geometry queries (volume, vectors, etc.) to
its frame. Periodic-mask-aware operations
([wrap][kups.core.cell.Cell.wrap], fold,
minimum_image_shifts)
live on the cell so callers don't need to access cell.periodic
directly.
Source code in src/kups/core/cell.py
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 | |
fold(r_frac)
¶
Fold fractional coords into [0, 1) on periodic axes; non-periodic
axes pass through unchanged.
Returns (folded, in_cell) where in_cell is a per-particle
mask, True where the folded coords lie in [0, 1) on every
axis. For fully-periodic cells, in_cell is trivially True
after folding; for cells with non-periodic axes, particles that
leaked out of the box on those axes are flagged False.
Used by neighbor-list spatial hashing; complementary to
[wrap][kups.core.cell.Cell.wrap] which uses the [-0.5, 0.5)
convention.
Source code in src/kups/core/cell.py
from_pbc(frame, pbc)
staticmethod
¶
Construct the cell flavor matching pbc.
Returns PeriodicCell for
(True, True, True), VacuumCell
for (False, False, False), and a generic Cell[P] carrying
the runtime mask for slab and wire geometries (P is inferred
from the literal tuple).
Source code in src/kups/core/cell.py
minimum_image_shifts(deltas)
¶
Per-axis minimum-image shifts for fractional separations.
Returns round(deltas) on periodic axes (the closest integer
cell offset that wraps the separation to its minimum image) and
0 on non-periodic axes.
Source code in src/kups/core/cell.py
CoordinateSpace
¶
Bases: Enum
Enumeration for coordinate systems.
Attributes:
| Name | Type | Description |
|---|---|---|
REAL |
Cartesian coordinates in Angstroms. |
|
FRACTIONAL |
Scaled coordinates in [0, 1) relative to frame vectors. |
Source code in src/kups/core/cell.py
DeformedFrame
¶
Frame parameterised as a differentiable deformation
of a fixed reference frame: vectors = base @ deformation.
base is held fixed (stop-gradient); only deformation's parameters are
optimised. Right-multiplication deforms Cartesian space, so vectors stays
lower-triangular and atoms at fixed fractional coordinates ride the cell. The
deformation frame chooses the parameterisation: a
LogTriclinicFrame gives the unconstrained
matrix-exponential map of ASE's FrechetCellFilter (build with
from_frame); a
TriclinicFrame gives the linear deformation
gradient of ASE's UnitCellFilter. vectors is generally nonlinear in the
parameters, so the gradient maps use the general inverse-Jacobian path on
BaseFrame.
Attributes:
| Name | Type | Description |
|---|---|---|
base |
Frame
|
Reference frame, held fixed (stop-gradient); the identity deformation reproduces it. |
deformation |
Frame
|
Differentiable deformation gradient (the optimised frame). |
Source code in src/kups/core/cell.py
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 | |
from_frame(frame, *, cell_factor=1.0, deformation=LogTriclinicFrame)
classmethod
¶
ASE FrechetCellFilter-style: an exponential-map deformation anchored
at frame (identity deformation, so vectors == frame.vectors).
deformation selects the deformation parameterisation:
LogTriclinicFrame (default) keeps
base = frame with a lower-triangular (6,) matrix-log deformation;
MatrixLogFrame gives a full-3x3
deformation, re-anchoring base as a MatrixLogFrame built from
frame.vectors (via the exact triangular log) so every leaf is
(..., 3, 3) and the resulting frame represents rotated / sheared cells.
Source code in src/kups/core/cell.py
Frame
¶
Bases: Protocol
3D parallelepiped geometry, no periodicity attached.
A Frame is a pure geometric container — three basis vectors that span a parallelepiped in 3D space. It does not commit to whether those vectors represent periodic translations or just bounding-box edges; that distinction is supplied by the Cell type that wraps a Frame.
In crystallography these basis vectors are conventionally called
"lattice vectors". They are exposed here under the name
vectors because the crystallographic
label implies a periodic interpretation that does not apply to all
Frame uses (e.g. the bounding box of a vacuum simulation).
The parameterised implementations subclass
BaseFrame, which implements every operation
derivable from vectors:
- OrthogonalFrame: 3 DOF (lengths).
- TriclinicFrame: 6 DOF (lower-triangular).
MaterializedFrame stores the basis
matrix, inverse and volume directly and implements this interface without
going through BaseFrame.
Source code in src/kups/core/cell.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
inverse_vectors
property
¶
Matrix inverse of vectors,
used to convert real-space coordinates to fractional, shape
(..., 3, 3).
matrix
property
¶
Static structure of vectors used to
dispatch the geometric primitives (inverse, volume, transforms) onto the
matching fast path. LOWER_TRIANGULAR / DIAGONAL keep the triangular
and diagonal forms; GENERAL falls back to dense 3x3 algebra.
perpendicular_lengths
property
¶
Perpendicular distance between opposing faces, per axis,
shape (..., 3). Used by neighbor-list cutoff checks and by
min_multiplicity.
reference_vectors
property
¶
Fixed reference basis for deformation-relative atom coordinates,
shape (..., 3, 3). The identity for directly-parameterised frames
(so atom DOFs are fractional); a frame that parameterises a deformation
of a stored reference (e.g. DeformedFrame)
returns that reference, conditioning the DOFs against it.
vectors
property
¶
Basis vectors of the parallelepiped, shape (..., 3, 3).
Rows are the basis vectors. Lower-triangular by convention so that
v[0] lies along x, v[1] in the xy-plane, v[2] general.
Crystallography calls this matrix the lattice vectors.
volume
property
¶
Volume of the parallelepiped, shape (...).
__mul__(other)
¶
from_matrix(vecs)
classmethod
¶
Construct from a (..., 3, 3) basis matrix.
Projects the input onto the frame's parameter space — entries
not represented by the parameterisation are discarded
(OrthogonalFrame keeps the diagonal; TriclinicFrame
keeps the lower-triangular block). Used to wrap a generic
∂E/∂h matrix back into the same frame type as an input cell.
Source code in src/kups/core/cell.py
materialize()
¶
Return a MaterializedFrame
with vectors, inverse_vectors and volume evaluated
and stored as concrete arrays.
Use this to avoid recomputing the inverse and determinant when the same frame is queried many times, or to lift these arrays across a JIT boundary so downstream callers don't need to know the frame's parametrisation.
Requires at least one leading batch dim so that vectors
(B, ..., 3, 3), inverse_vectors (B, ..., 3, 3) and
volume (B, ...) share a leading axis (see
MaterializedFrame).
Source code in src/kups/core/cell.py
parameter_gradient(vectors_grad)
¶
Pull a cartesian ∂E/∂h matrix back onto the frame's parameter
space, returning a same-type frame whose parameter leaves hold
∂E/∂θ.
Implements ∂E/∂θ = Jᵀ·∂E/∂h with J = ∂vectors/∂θ via the
vector-Jacobian product of vectors.
General for any parameterisation — the vjp linearises at the current
parameters, so it is correct even when vectors is a nonlinear
function of the parameters. Inverse of
vectors_gradient.
Source code in src/kups/core/cell.py
tile(multiplicities)
¶
Per-axis integer scaling. Used by make_supercell to build supercells.
to_fractional(r)
¶
to_real(r_frac)
¶
vectors_gradient(parameter_grad)
¶
Map a parameter-space gradient frame (parameter_grad holding
∂E/∂θ in its parameter leaves) to the cartesian ∂E/∂h matrix,
shape (..., 3, 3).
Implements vec(∂E/∂h) = (Jᵀ)⁺·∂E/∂θ with J = ∂vectors/∂θ — the
pseudo-inverse of the Jacobian, evaluated at this frame's parameters.
For a parameterisation whose vectors map is linear with orthonormal
Jacobian (TriclinicFrame, OrthogonalFrame) this reduces to
reconstructing the matrix from the gradient frame; the general path
covers nonlinear parameterisations. Inverse of
parameter_gradient.
Source code in src/kups/core/cell.py
LinearFrame
¶
Bases: BaseFrame, ABC
Abstract base for frames whose vectors map is linear with orthonormal
Jacobian (e.g. OrthogonalFrame, TriclinicFrame).
For these frames, the parameter-space gradient to cartesian gradient map reduces to reconstructing the matrix from the parameter leaves, so we can skip the general pseudo-inverse path in [BaseFrame.vectors_gradient][kups.core.cell.BaseFrame.vectors_gradient] and just return the reconstructed matrix directly.
Source code in src/kups/core/cell.py
LogTriclinicFrame
¶
Triclinic Frame parameterised in the matrix log.
Stores the 6 lower-triangular elements of a matrix A; the basis vectors
are expm(A). Because A is lower-triangular, expm(A) is too (its
diagonal is exp of A's diagonal), so the lower-triangular convention
shared by every other frame is preserved.
The exponential map is unconstrained: any A yields a basis with strictly
positive volume exp(tr A), so gradient-based cell relaxation in A never
has to guard against a collapsing or inverting cell. Unlike
TriclinicFrame, vectors is a nonlinear
function of the parameters, so the parameter/cartesian gradient maps use the
general inverse-Jacobian path on BaseFrame rather
than a constant-Jacobian shortcut.
Attributes:
| Name | Type | Description |
|---|---|---|
tril |
Array
|
Lower-triangular elements |
cell_factor |
Array
|
Stiffening factor (ASE's |
Source code in src/kups/core/cell.py
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 | |
from_matrix(vecs, *, cell_factor=1.0)
classmethod
¶
Construct from a lower-triangular basis matrix L (positive
diagonal), shape (..., 3, 3), storing A = cell_factor * logm(L) so
that vectors == expm(A / cell_factor) == L.
Source code in src/kups/core/cell.py
MaterializedFrame
¶
Bases: Sliceable
Frame that stores its basis matrix, inverse, and volume as concrete arrays.
Produced by Frame.materialize.
Useful when the same frame is queried repeatedly (no recomputation
of the inverse or determinant) or when the arrays need to cross a
JIT boundary independently of the frame's original parametrisation.
Coordinate transforms dispatch on the stored
[structure][kups.core.cell.MaterializedFrame.structure] (default
GENERAL, so manually-constructed frames with arbitrary vectors are
correct); materialize propagates the
source frame's structure so triangular / diagonal sources keep the fast path.
The three array fields are pytree leaves and must share a leading batch
dim B to satisfy the Sliceable
contract — unbatched single-frame inputs must be wrapped with an
explicit [None] axis before being passed in.
Attributes:
| Name | Type | Description |
|---|---|---|
vectors |
Array
|
Basis matrix, shape |
inverse_vectors |
Array
|
Matrix inverse of |
volume |
Array
|
Absolute determinant of |
structure |
Array
|
Static structure flag dispatching the coordinate transforms. |
Source code in src/kups/core/cell.py
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 | |
MatrixLogFrame
¶
Full-3×3 matrix-log Frame: vectors = expm(A / cf).
The GENERAL sibling of LogTriclinicFrame:
stores a full (..., 3, 3) generator A and exponentiates the whole
matrix (not just a lower-triangular block), so vectors can be a rotated /
sheared cell. The matrix exponential is the principal one; its vjp is the
expm_frechet adjoint, so the inherited
parameter_gradient /
vectors_gradient are exact with no
custom rule.
Used as both the base and the deformation of a
DeformedFrame (build with
from_frame passing
deformation=MatrixLogFrame) to express the full-3x3 Frechet basis: every
leaf is (..., 3, 3), so a per-system
Batched slice yields all-(3, 3) leaves
that share a leading axis (a (6,) tril base would fail).
Attributes:
| Name | Type | Description |
|---|---|---|
log_matrix |
Array
|
Generator |
cell_factor |
Array
|
Stiffening factor (ASE's |
Source code in src/kups/core/cell.py
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 | |
from_lower_triangular(vecs, *, cell_factor=1.0)
classmethod
¶
Construct from a lower-triangular basis matrix (positive diagonal) via the exact triangular_3x3_logm.
The closed-form triangular log is exact even for repeated diagonal entries (cubic / tetragonal cells), unlike the eig-based from_matrix.
Source code in src/kups/core/cell.py
from_matrix(vecs, *, cell_factor=1.0)
classmethod
¶
Construct from an arbitrary basis matrix via the general (eig-based)
logm, shape (..., 3, 3).
For an arbitrary matrix; inaccurate for repeated eigenvalues (defective matrices). Use from_lower_triangular for the reference cell, whose diagonal can repeat.
Source code in src/kups/core/cell.py
OrthogonalFrame
¶
Bases: LinearFrame, Sliceable
Axis-aligned Frame with 3 degrees of freedom.
Parameterized by the three side lengths. Overrides every BaseFrame operation with a cheaper diagonal form (volume, inverse, coordinate transforms) than the general triclinic path. Use this when the simulation domain has perpendicular axes (cubic, tetragonal, or orthorhombic crystals; standard rectangular MD boxes).
Attributes:
| Name | Type | Description |
|---|---|---|
lengths |
Array
|
Box side lengths |
Source code in src/kups/core/cell.py
from_matrix(vecs)
classmethod
¶
Construct from a diagonal basis matrix, shape (..., 3, 3).
Projects the input matrix onto the orthogonal subspace by taking
its diagonal — off-diagonal entries are discarded, matching the
3-parameter (Lx, Ly, Lz) representation.
Source code in src/kups/core/cell.py
PeriodicCell
¶
Bases: Cell[Periodic3D]
Cell that is periodic along all three axes.
The frame is interpreted as a unit cell — a tile of a periodic
crystal or fluid. wrap folds coordinates into the primary unit
cell; the neighbor list applies the minimum-image convention; the
Ewald summation requires this cell type.
Source code in src/kups/core/cell.py
TriclinicFrame
¶
Bases: LinearFrame, Sliceable
General triclinic Frame with 6 degrees of freedom.
Stores the 6 independent elements of the lower-triangular basis matrix. Vectors are a linear function of these parameters, making them suitable for gradient-based optimization (e.g. NPT cell-vector relaxation).
Use this when the simulation domain has non-orthogonal axes (monoclinic / triclinic crystals, sheared MD boxes). For axis-aligned domains, OrthogonalFrame is cheaper.
Inherits the basis inverse, perpendicular lengths, coordinate transforms,
and materialize from BaseFrame; supplies
the vectors map, a cheap diagonal-product volume, and the
crystallographic readouts.
Attributes:
| Name | Type | Description |
|---|---|---|
tril |
Array
|
Lower-triangular elements |
Source code in src/kups/core/cell.py
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | |
from_lengths_and_angles(lengths, angles)
classmethod
¶
Construct from crystallographic parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lengths
|
Array
|
Lattice lengths |
required |
angles
|
Array
|
Lattice angles |
required |
Source code in src/kups/core/cell.py
from_matrix(vecs)
classmethod
¶
Construct from a lower-triangular basis matrix, shape (..., 3, 3).
Projects the input onto the 6-parameter lower-triangular space by
keeping its lower triangle. Distinct from
parameter_gradient, which
pulls a gradient cotangent back rather than a primal matrix.
Source code in src/kups/core/cell.py
TriclinicMap
¶
Bases: Protocol
Mapping that takes positions in an arbitrary frame and returns them in the lower-triangular triclinic frame produced by to_lower_triangular.
Source code in src/kups/core/cell.py
VacuumCell
¶
Bases: Cell[Vacuum]
Cell with all three axes open.
The frame is interpreted as the bounding parallelepiped of a finite
simulation domain — a cluster, an isolated molecule, a gas-phase
sample. wrap is a no-op; long-range electrostatics use direct
pairwise sums (no Ewald). The frame is still required because the
neighbor-list machinery needs a spatial-partitioning hint.
Source code in src/kups/core/cell.py
is_3d_periodic(cell)
¶
is_vacuum(cell)
¶
make_supercell(cell, multiplicities, to_replicate, to_shift)
¶
Replicate a cell along each periodic axis.
Tiles the cell according to multiplicities (clamped to 1 on
non-periodic axes), replicates the data, and shifts coordinates into
the expanded cell using periodic wrapping. The returned cell has the
same concrete type as the input.
Source code in src/kups/core/cell.py
min_multiplicity(cell, cutoff)
¶
Minimum supercell replication per axis for a given cutoff.
Returns 1 for non-periodic axes (no replication needed).
Source code in src/kups/core/cell.py
require_periodic_3d(cell)
¶
Raise TypeError unless cell is fully 3D-periodic.
Equivalent to asserting isinstance(cell, PeriodicCell) but with a
helpful message.
Source code in src/kups/core/cell.py
require_periodic_3d_triclinic(cell)
¶
Shorthand for require_periodic_3d(cell); require_triclinic_frame(cell).
require_triclinic_frame(cell)
¶
Raise TypeError unless cell.frame is a
TriclinicFrame.
Some integrators (e.g. fully-flexible-cell NPT Langevin) drift the cell
matrix to a general lower-triangular state at every step, which an
OrthogonalFrame (3-DOF) cannot represent.
Use TriclinicFrame.from_matrix
to auto-promote cell.frame before constructing such an integrator.
Source code in src/kups/core/cell.py
to_lower_triangular(vecs)
¶
Convert arbitrary basis vectors to lower-triangular form via QR.
The returned basis has a positive diagonal. The coordinate mapper applies the same rigid rotation to positions, preserving fractional coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vecs
|
Array
|
Basis vectors as rows of a 3x3 matrix, shape |
required |
Returns:
| Type | Description |
|---|---|
tuple[Array, TriclinicMap]
|
Tuple of (lower_triangular_vectors, coordinate_rotation_fn). |