elfes.physics
Physical data objects and transformations.
AtomicBasis
dataclass
AtomicBasis(atomic_number: int, angmoms: ArrayLike, name: str | None = None)
Shell structure for one element.
Repeated angular quantum numbers represent distinct radial shells. Shells
use ascending l; repeated l values retain their input order. Each
shell contains magnetic components m = -l, ..., +l in normalized
Wikipedia real spherical harmonic convention.
Parameters:
-
(atomic_numberint) –Atomic number of the element using this basis.
-
(angmomsArrayLike) –Angular quantum number
lof each shell, stored as an int32 array with shape(n_shells,). -
(namestr | None, default:None) –Optional source-level basis name.
n_orb
property
n_orb: int
Number of basis functions on one atomic center.
BasisSet
dataclass
BasisSet(atomic_bases: tuple[AtomicBasisT, ...] | list[AtomicBasisT])
Atomic bases keyed by atomic number.
The base class stores the shell structure needed to interpret orbital axes. Numerical and Gaussian subclasses add complete radial functions.
Parameters:
-
(atomic_basestuple[AtomicBasisT, ...] | list[AtomicBasisT]) –Atomic bases with unique atomic numbers.
atomic_basis
atomic_basis(atomic_number: int) -> AtomicBasisT
Return the basis for one atomic number.
atom_orb_counts
atom_orb_counts(atomic_numbers: ArrayLike) -> NDArray[int32]
Return orbital counts in atom order.
orb_offsets
orb_offsets(atomic_numbers: ArrayLike) -> NDArray[int64]
Return atom boundaries in the global orbital order.
n_orb
n_orb(atomic_numbers: ArrayLike) -> int
Return the total orbital count for an atomic-number sequence.
GaussianAtomicBasis
dataclass
GaussianAtomicBasis(
atomic_number: int,
angmoms: ArrayLike,
primitive_offsets: ArrayLike,
primitive_exponents: ArrayLike,
contraction_coefficients: ArrayLike,
name: str | None = None,
)
Bases: AtomicBasis
Contracted Gaussian functions for one element.
Every shell contains one contracted radial function. General contractions are therefore expanded into repeated shells with the same angular momentum. Primitive exponents use Å\(^{-2}\) and coefficients multiply individually normalized primitive radial functions. The stored coefficients retain the actual scale of the contracted function.
Parameters:
-
(atomic_numberint) –Atomic number of the element using this basis.
-
(angmomsArrayLike) –Angular quantum number of each shell.
-
(primitive_offsetsArrayLike) –Boundaries of each shell's primitive data, with shape
(n_shells + 1,). -
(primitive_exponentsArrayLike) –Positive primitive exponents in Å\(^{-2}\).
-
(contraction_coefficientsArrayLike) –Dimensionless contraction coefficients.
-
(namestr | None, default:None) –Optional source-level basis name.
n_orb
property
n_orb: int
Number of basis functions on one atomic center.
evaluate
evaluate(relative_coordinates: ArrayLike) -> NDArray[float64]
Evaluate all three-dimensional basis functions about one center.
Parameters:
-
(relative_coordinatesArrayLike) –Cartesian coordinates relative to the center in Å, with shape
(..., 3).
Returns:
-
NDArray[float64]–Values with shape
(..., n_orb)in shell order and then -
NDArray[float64]–m = -l, ..., lorder within each shell.
GaussianBasisSet
dataclass
GaussianBasisSet(
atomic_bases: tuple[GaussianAtomicBasis, ...] | list[GaussianAtomicBasis],
name: str | None = None,
)
Bases: BasisSet[GaussianAtomicBasis]
Role-neutral Gaussian atomic bases keyed by atomic number.
atomic_basis
atomic_basis(atomic_number: int) -> AtomicBasisT
Return the basis for one atomic number.
atom_orb_counts
atom_orb_counts(atomic_numbers: ArrayLike) -> NDArray[int32]
Return orbital counts in atom order.
orb_offsets
orb_offsets(atomic_numbers: ArrayLike) -> NDArray[int64]
Return atom boundaries in the global orbital order.
n_orb
n_orb(atomic_numbers: ArrayLike) -> int
Return the total orbital count for an atomic-number sequence.
SplineNumericalAtomicBasis
dataclass
SplineNumericalAtomicBasis(
atomic_number: int,
angmoms: ArrayLike,
radial_grid: ArrayLike,
radial_values: ArrayLike,
name: str | None = None,
)
Bases: AtomicBasis
Spline-interpolated numerical radial functions for one element.
All shells share radial_grid. radial_values[s] is the bare radial
function for angmoms[s] in Å\(^{-3/2}\). r_max is the final
radial-grid knot and therefore the largest shell cutoff. cutoff_index[s] is
derived as the first knot of that shell's exact zero tail.
Parameters:
-
(atomic_numberint) –Atomic number of the element using this basis.
-
(angmomsArrayLike) –Angular quantum number of each shell.
-
(radial_gridArrayLike) –Strictly increasing radial knots in Å, beginning at zero. At least four knots are required.
-
(radial_valuesArrayLike) –Bare radial samples with shape
[n_shells, n_grid]. -
(namestr | None, default:None) –Optional source-level basis name.
n_orb
property
n_orb: int
Number of basis functions on one atomic center.
r_max
property
r_max: float
Largest shell cutoff in Å.
evaluate_radial
evaluate_radial(radius: ArrayLike) -> NDArray[float64]
Evaluate every radial shell at radii in Å.
Parameters:
-
(radiusArrayLike) –Non-negative radii with any shape.
Returns:
-
NDArray[float64]–Radial values with shape
(n_shells, *radius.shape).
evaluate
evaluate(relative_coordinates: ArrayLike) -> NDArray[float64]
Evaluate all three-dimensional basis functions about one center.
Parameters:
-
(relative_coordinatesArrayLike) –Cartesian coordinates relative to the center in Å, with shape
(..., 3).
Returns:
-
NDArray[float64]–Values with shape
(..., n_orb)in shell order and then -
NDArray[float64]–m = -l, ..., lorder within each shell.
SplineNumericalBasisSet
dataclass
SplineNumericalBasisSet(
atomic_bases: tuple[SplineNumericalAtomicBasis, ...]
| list[SplineNumericalAtomicBasis],
name: str | None = None,
)
Bases: BasisSet[SplineNumericalAtomicBasis]
Spline numerical atomic bases keyed by atomic number.
atomic_basis
atomic_basis(atomic_number: int) -> AtomicBasisT
Return the basis for one atomic number.
atom_orb_counts
atom_orb_counts(atomic_numbers: ArrayLike) -> NDArray[int32]
Return orbital counts in atom order.
orb_offsets
orb_offsets(atomic_numbers: ArrayLike) -> NDArray[int64]
Return atom boundaries in the global orbital order.
n_orb
n_orb(atomic_numbers: ArrayLike) -> int
Return the total orbital count for an atomic-number sequence.
UniformNumericalAtomicBasis
dataclass
UniformNumericalAtomicBasis(
atomic_number: int,
angmoms: ArrayLike,
radial_spacing: float,
radial_values: ArrayLike,
name: str | None = None,
)
Bases: AtomicBasis
Numerical radial functions on a uniform grid beginning at the origin.
radial_values[:, i] samples all shells at i * radial_spacing.
cutoff_index[s] is derived as the first knot of shell s's exact zero
tail. One common zero knot may follow the largest shell cutoff to make the
Simpson grid odd. The full radial grid and global spline coefficients are
not stored.
Parameters:
-
(atomic_numberint) –Atomic number of the element using this basis.
-
(angmomsArrayLike) –Angular quantum number of each shell.
-
(radial_spacingfloat) –Positive spacing between radial knots in Å.
-
(radial_valuesArrayLike) –Bare radial samples with shape
[n_shells, n_grid]. -
(namestr | None, default:None) –Optional source-level basis name.
n_orb
property
n_orb: int
Number of basis functions on one atomic center.
n_grid_points
property
n_grid_points: int
Number of uniform radial knots.
r_max
property
r_max: float
Largest shell cutoff in Å.
cutoffs
property
cutoffs: NDArray[float64]
Exact shell cutoffs in Å.
evaluate_radial
evaluate_radial(radius: ArrayLike) -> NDArray[float64]
Evaluate every radial shell at radii in Å.
Parameters:
-
(radiusArrayLike) –Non-negative radii with any shape.
Returns:
-
NDArray[float64]–Radial values with shape
(n_shells, *radius.shape).
evaluate
evaluate(relative_coordinates: ArrayLike) -> NDArray[float64]
Evaluate all three-dimensional basis functions about one center.
Parameters:
-
(relative_coordinatesArrayLike) –Cartesian coordinates relative to the center in Å, with shape
(..., 3).
Returns:
-
NDArray[float64]–Values with shape
(..., n_orb)in shell order and then -
NDArray[float64]–m = -l, ..., lorder within each shell.
UniformNumericalBasisSet
dataclass
UniformNumericalBasisSet(
atomic_bases: tuple[UniformNumericalAtomicBasis, ...]
| list[UniformNumericalAtomicBasis],
name: str | None = None,
)
Bases: BasisSet[UniformNumericalAtomicBasis]
Uniform numerical atomic bases sharing one radial spacing.
atomic_basis
atomic_basis(atomic_number: int) -> AtomicBasisT
Return the basis for one atomic number.
atom_orb_counts
atom_orb_counts(atomic_numbers: ArrayLike) -> NDArray[int32]
Return orbital counts in atom order.
orb_offsets
orb_offsets(atomic_numbers: ArrayLike) -> NDArray[int64]
Return atom boundaries in the global orbital order.
n_orb
n_orb(atomic_numbers: ArrayLike) -> int
Return the total orbital count for an atomic-number sequence.
BlockSparseOrbMatrix
dataclass
BlockSparseOrbMatrix(
atom_pairs: ArrayLike,
pair_shifts: ArrayLike,
orb_counts: ArrayLike,
values: ArrayLike,
pauli: str | None = None,
)
Bases: _BlockSparseOrbMatrixBase
General cell-shift-indexed atom-pair orbital matrix.
atom_pairs[n] = (i, j) identifies the bra and ket basis centers of block
n. pair_shifts[n] selects the cell image of the ket center. Stored block
keys are sorted and unique; every stored block is an actual directed block,
and a missing key represents zero. No relation between a key and its
reverse-cell partner is implied.
Spatial matrix elements are flattened along the leading axis of values,
whose shape is (n_values, *extra_shape). block(n) restores the shape
(*extra_shape, n_orb_i, n_orb_j). When pauli is present, its component
axis is the final axis of extra_shape.
from_blocks
classmethod
from_blocks(
atom_pairs: ArrayLike,
blocks: Iterable[ArrayLike],
orb_counts: ArrayLike,
*,
pair_shifts: ArrayLike | None = None,
pauli: str | None = None,
) -> Self
Pack blocks aligned with atom-pair and optional cell-shift rows.
Input rows may be unordered; they and their corresponding blocks are
sorted lexicographically before storage. Every block has shape
(*extra_shape, n_orb_i, n_orb_j), with one shared extra_shape.
block
block(block_idx: int) -> NDArray
Return one stored block with shape (*extra_shape, n_i, n_j).
to_kspace
to_kspace(kpoints: ArrayLike) -> OrbMatrix
Fourier-fold the matrix at k-points in fractional coordinates.
HermBlockSparseOrbMatrix
HermBlockSparseOrbMatrix(
atom_pairs: ArrayLike,
pair_shifts: ArrayLike,
orb_counts: ArrayLike,
values: ArrayLike,
pauli: str | None = None,
)
Bases: _BlockSparseOrbMatrixBase
Hermitian cell-shift-indexed atom-pair orbital matrix.
Only the lexicographically first key in each Hermitian-partner pair is stored; the other block is its conjugate transpose. Missing partner pairs contribute zero matrix elements. Onsite blocks are exactly Hermitian.
Spatial matrix elements are flattened along the leading axis of values,
whose shape is (n_values, *extra_shape). block(n) restores the shape
(*extra_shape, n_orb_i, n_orb_j). When pauli is present, its component
axis is the final axis of extra_shape.
from_blocks
classmethod
from_blocks(
atom_pairs: ArrayLike,
blocks: Iterable[ArrayLike],
orb_counts: ArrayLike,
*,
pair_shifts: ArrayLike | None = None,
pauli: str | None = None,
) -> Self
Pack blocks aligned with atom-pair and optional cell-shift rows.
Input rows may be unordered; they and their corresponding blocks are
sorted lexicographically before storage. Every block has shape
(*extra_shape, n_orb_i, n_orb_j), with one shared extra_shape.
block
block(block_idx: int) -> NDArray
Return one stored block with shape (*extra_shape, n_i, n_j).
rotated
rotated(
spatial_rotation: ArrayLike,
basis_set: BasisSet,
atomic_numbers: ArrayLike,
*,
spin_rotation: bool | ArrayLike = False,
) -> HermBlockSparseOrbMatrix
Return the matrix after actively rotating the spatial system.
Both orbital axes rotate by spatial_rotation. spin_rotation leaves
Pauli components fixed when False, follows the spatial system as an
axial vector when True, or applies an explicit proper spin rotation.
Pair shifts, other leading dimensions, and block ordering are preserved.
to_gamma
to_gamma() -> HermOrbMatrix
Fold the periodic matrix at Γ without allocating complex phases.
to_kspace
to_kspace(kpoints: ArrayLike) -> HermOrbMatrix
Fourier-fold the matrix at k-points in fractional coordinates.
The integer ket-cell shifts use the ELFES forward phase
exp(+2πi k·R). A single (3,) k-point returns one matrix. An
(n_kpoints, 3) batch returns matrices with n_kpoints as the first
axis.
Geometry
dataclass
Geometry(
atomic_numbers: ArrayLike,
positions: ArrayLike,
cell: ArrayLike | None = None,
pbc: ArrayLike = False,
*,
magmoms: ArrayLike | None = None,
)
Ordered atomic structure with boundary conditions and optional magnetic input.
Atom order is significant and defines the atom indices used by associated physical data.
Parameters:
-
(atomic_numbersArrayLike) –Non-empty positive atomic numbers with shape
(n_atoms,). -
(positionsArrayLike) –Cartesian coordinates in Å with shape
(n_atoms, 3). -
(cellArrayLike | None, default:None) –Cartesian cell vectors in Å as the rows of a
(3, 3)matrix. Omission gives a zero matrix. Rows selected bypbcmust be linearly independent; inactive rows may be zero. -
(pbcArrayLike, default:False) –Boolean periodic-axis flags. A scalar applies to every axis; otherwise the value must have shape
(3,). Omission gives no periodic axes. -
(magmomsArrayLike | None, default:None) –Optional input atomic magnetic moments in μB. Signed collinear moments have shape
(n_atoms,); noncollinear Cartesian moments have shape(n_atoms, 3).
rotated
rotated(rotation: ArrayLike, *, spin_rotation: bool | ArrayLike = False) -> Geometry
Return the geometry after an active orthogonal transformation.
spin_rotation=False leaves magnetic moments fixed in spin space.
True applies the joint axial-vector action det(Q) Q, while a
proper 3 × 3 matrix supplies an independent spin rotation.
Collinear magnetic moments only support the default fixed spin axis.
QuadratureGrid
dataclass
QuadratureGrid(coordinates: ArrayLike, weights: ArrayLike)
Cartesian quadrature points and their integration weights.
Parameters:
-
(coordinatesArrayLike) –Cartesian point coordinates in Å with shape
(n_points, 3). -
(weightsArrayLike) –Integration weights in Å\(^{3}\) with shape
(n_points,).
shape
property
shape: tuple[int]
Shape of the sampled point axis.
n_points
property
n_points: int
Number of sampled points.
integrate
integrate(values: ArrayLike) -> NDArray
Integrate values whose final axis is the point axis.
rotated
rotated(rotation: ArrayLike) -> QuadratureGrid
Return the quadrature points after an active rotation.
UniformGrid
dataclass
UniformGrid(
origin: ArrayLike, step_vectors: ArrayLike, shape: ArrayLike, pbc: ArrayLike = False
)
Uniform three-dimensional affine grid.
Grid point (i, j, k) has Cartesian position
origin + [i, j, k] @ step_vectors. Lengths are in Å.
Parameters:
-
(originArrayLike) –Cartesian position of grid point
(0, 0, 0)with shape(3,). -
(step_vectorsArrayLike) –Cartesian displacement for one index step along each grid axis, stored as the rows of a
(3, 3)matrix. -
(shapeArrayLike) –Number of grid points along the three axes.
-
(pbcArrayLike, default:False) –Boolean periodic-axis flags. A scalar applies to every grid axis; omission gives no periodic axes.
n_points
property
n_points: int
Number of sampled points.
grid_vectors
property
grid_vectors: NDArray[float64]
Full grid-period vectors as rows of a (3, 3) matrix.
volume_element
property
volume_element: float
Volume represented by one grid point in Å\(^{3}\).
coordinates
coordinates(indices: ArrayLike) -> NDArray[float64]
Map grid-index triples with shape (..., 3) to Cartesian points.
integrate
integrate(values: ArrayLike) -> NDArray
Integrate values whose final three axes match the grid.
rotated
rotated(rotation: ArrayLike) -> UniformGrid
Return the grid after an active orthogonal transformation.
validate_geometry
validate_geometry(geometry: Geometry) -> None
Check that this grid and a Geometry describe the same domain.
SplineNumericalBasisGridCalculator
SplineNumericalBasisGridCalculator(
geometry: Geometry,
basis_set: SplineNumericalBasisSet,
grid: UniformGrid,
*,
cpu_threads: int = 1,
)
Bases: _NumericalBasisGridCalculatorBase
Reusable spline numerical basis calculator bound to one geometry and grid.
Construction prepares the complete cutoff-local traversal plan and one spherical-harmonic workspace per CPU thread. Reuse the calculator when both integration and expansion use the same geometry, basis, and grid. Calls on one calculator are serialized because its compiled workspaces own reusable scratch memory.
Parameters:
-
(geometryGeometry) –Atom positions and periodic cell used by the basis functions.
-
(basis_setSplineNumericalBasisSet) –Spline numerical basis evaluated on the grid.
-
(gridUniformGrid) –Uniform grid on which values are integrated or expanded.
-
(cpu_threadsint, default:1) –Threads used inside the fused grid calculation.
integrate
integrate(volumetric: UniformVolumetric) -> OrbVector
Integrate values on the bound grid against the numerical basis.
expand
expand(coeffs: OrbVector) -> UniformVolumetric
Evaluate auxiliary coefficients on the bound grid.
UniformNumericalBasisGridCalculator
UniformNumericalBasisGridCalculator(
geometry: Geometry,
basis_set: UniformNumericalBasisSet,
grid: UniformGrid,
*,
cpu_threads: int = 1,
)
Bases: _NumericalBasisGridCalculatorBase
Numerical-basis grid calculator using uniform radial samples directly.
The native kernel derives the radial interval by integer indexing and uses precomputed local-Hermite tangents. It does not copy radial-grid arrays or global spline coefficients.
integrate
integrate(volumetric: UniformVolumetric) -> OrbVector
Integrate values on the bound grid against the numerical basis.
expand
expand(coeffs: OrbVector) -> UniformVolumetric
Evaluate auxiliary coefficients on the bound grid.
SplineNumericalOverlapCalculator
SplineNumericalOverlapCalculator(
basis_set: SplineNumericalBasisSet,
parameters: SplineNumericalOverlapParameters | None = None,
*,
cpu_threads: int = 1,
)
Bases: _NumericalOverlapCalculatorBase
Calculate ordinary overlaps for geometries sharing one spline numerical basis.
Construction copies the spline numerical atomic bases into the native kernel.
Radial transforms and two-center distance tables are prepared lazily for
species and species pairs encountered by later calculations, then reused by
the calculator. cpu_threads controls native neighbor search and warm block
evaluation within one call; it defaults to one.
calculate
calculate(geometry: Geometry) -> HermBlockSparseOrbMatrix
Return the overlap matrix for one geometry.
calculate_gamma
calculate_gamma(geometry: Geometry) -> HermOrbMatrix
Return the real dense Γ-folded overlap for one geometry.
SplineNumericalOverlapParameters
dataclass
SplineNumericalOverlapParameters(
*,
k_cutoff: float = 120.0,
k_spacing: float = 0.04,
distance_spacing: float = 0.005,
radial_quadrature_order: int = 8,
)
Resolution parameters for spline numerical overlap preparation.
Lengths use Å and reciprocal lengths use Å\(^{-1}\).
UniformNumericalOverlapCalculator
UniformNumericalOverlapCalculator(
basis_set: UniformNumericalBasisSet, *, cpu_threads: int = 1
)
Bases: _NumericalOverlapCalculatorBase
Calculate overlaps from uniform radial samples without source splines.
cpu_threads controls native neighbor search and warm block evaluation
within one call; it defaults to one.
calculate
calculate(geometry: Geometry) -> HermBlockSparseOrbMatrix
Return the overlap matrix for one geometry.
calculate_gamma
calculate_gamma(geometry: Geometry) -> HermOrbMatrix
Return the real dense Γ-folded overlap for one geometry.
calculate_basis_connection
calculate_basis_connection(geometry: Geometry) -> BlockSparseOrbMatrix
Return the ket-side basis connection in Å\(^{-1}\).
For ket-cell displacement \(\boldsymbol d=\boldsymbol\tau_j+\boldsymbol R-\boldsymbol\tau_i\), the Cartesian components are \(\langle\phi_{i\boldsymbol0}|\partial_{\tau_{j\alpha}} \phi_{j\boldsymbol R}\rangle=\partial_{d_\alpha}S_{ij}(\boldsymbol d)\). Every directed partner block is stored explicitly.
UniformNumericalSpinOrbitCalculator
UniformNumericalSpinOrbitCalculator(
basis_set: UniformNumericalBasisSet,
potential_set: UniformNumericalSpinOrbitPotentialSet,
*,
cpu_threads: int = 1,
)
Calculate the fixed spin-orbit Hamiltonian for one numerical basis.
Species-level radial transforms and two-center AO--projector tables are
prepared lazily and reused. Each geometry is evaluated as finite-cutoff
AO--projector overlaps followed by projector-centered sparse contractions.
cpu_threads controls native neighbor search, overlap evaluation, and
contraction; it defaults to one.
calculate
calculate(geometry: Geometry) -> HermBlockSparseOrbMatrix
Return fixed Pauli \(x,y,z\) SOC blocks in eV.
UniformNumericalSpinOrbitPotential
dataclass
UniformNumericalSpinOrbitPotential(
projectors: UniformNumericalAtomicBasis, d_so: HermOrbMatrix
)
Separable spin-orbit potential for one species.
projectors is the ordered KB-projector family. d_so stores its
spin-traceless nonlocal coefficient matrix in eV, expanded as Pauli
\(x,y,z\) components over the projector axes. In the real-projector
convention used here, every component of d_so is purely imaginary and
Hermitian.
Parameters:
-
(projectorsUniformNumericalAtomicBasis) –Uniform numerical KB projectors for one species.
-
(d_soHermOrbMatrix) –Projector-space \(D^{\mathrm{SO}}\) in eV, with one atomic orbital partition and
pauli="xyz".
UniformNumericalSpinOrbitPotentialSet
dataclass
UniformNumericalSpinOrbitPotentialSet(
atomic_potentials: tuple[UniformNumericalSpinOrbitPotential, ...]
| list[UniformNumericalSpinOrbitPotential],
)
Uniform numerical spin-orbit potentials keyed by atomic number.
projectors is the role-neutral basis set assembled from each atomic
potential's projector family.
atomic_potential
atomic_potential(atomic_number: int) -> UniformNumericalSpinOrbitPotential
Return the potential for one atomic number.
HermOrbMatrix
HermOrbMatrix(array: ArrayLike, orb_counts: ArrayLike, pauli: str | None = None)
Bases: OrbMatrix
Dense Hermitian matrix with two atom-partitioned orbital axes.
real
property
real: Self
Return the same matrix type with a view of the real array.
submatrix
submatrix(atom_i: int, atom_j: int) -> NDArray
Return the orbital submatrix for one atom pair.
rotated
rotated(
spatial_rotation: ArrayLike,
basis_set: BasisSet,
atomic_numbers: ArrayLike,
*,
spin_rotation: bool | ArrayLike = False,
) -> HermOrbMatrix
Return the Hermitian matrix after actively rotating the spatial system.
Both orbital axes rotate by spatial_rotation. spin_rotation leaves
Pauli components fixed when False, follows the spatial system as an
axial vector when True, or applies an explicit proper spin rotation.
Any earlier batch dimensions are preserved.
OrbMatrix
dataclass
OrbMatrix(array: ArrayLike, orb_counts: ArrayLike, pauli: str | None = None)
General dense array with two atom-partitioned orbital axes.
Arbitrary leading dimensions are preserved. When pauli is present,
its component axis is immediately before the two orbital axes.
Parameters:
-
(arrayArrayLike) –Numeric array with shape
(*extra_shape, n_orb, n_orb). -
(orb_countsArrayLike) –Number of basis functions on every atom with shape
(n_atoms,). -
(paulistr | None, default:None) –Nonefor spinless values, otherwise a non-empty ordered subset of"0xyz"naming the final leading component axis.
real
property
real: Self
Return the same matrix type with a view of the real array.
submatrix
submatrix(atom_i: int, atom_j: int) -> NDArray
Return the orbital submatrix for one atom pair.
OrbVector
dataclass
OrbVector(array: ArrayLike, orb_counts: ArrayLike, pauli: str | None = None)
Dense array with one atom-partitioned orbital axis.
Arbitrary leading dimensions are preserved. The final dimension is the
concatenation of the atom-centered basis functions described by
orb_counts. When pauli is present, its component axis is
immediately before the orbital axis.
Parameters:
-
(arrayArrayLike) –Numeric array with shape
(*extra_shape, n_orb). -
(orb_countsArrayLike) –Number of basis functions on every atom with shape
(n_atoms,). -
(paulistr | None, default:None) –Nonefor values without Pauli semantics, otherwise a non-empty ordered subset of"0xyz"naming the final leading component axis.
subvector
subvector(atom_i: int) -> NDArray
Return the orbital subvector for one atom.
rotated
rotated(
spatial_rotation: ArrayLike,
basis_set: BasisSet,
atomic_numbers: ArrayLike,
*,
spin_rotation: bool | ArrayLike = False,
) -> OrbVector
Return values after actively rotating the spatial system.
The final orbital axis rotates by spatial_rotation. spin_rotation
leaves Pauli components fixed when False, follows the spatial system
as an axial vector when True, or applies an explicit proper spin
rotation. Any earlier batch dimensions are preserved.
TriuOrbMatrix
TriuOrbMatrix(array: ArrayLike, orb_counts: ArrayLike, pauli: str | None = None)
Bases: OrbMatrix
Dense upper-triangular matrix with atom-partitioned orbital axes.
real
property
real: Self
Return the same matrix type with a view of the real array.
submatrix
submatrix(atom_i: int, atom_j: int) -> NDArray
Return the orbital submatrix for one atom pair.
ElectronicQuantity
dataclass
ElectronicQuantity(
data: BlockSparseOrbMatrix
| HermBlockSparseOrbMatrix
| OrbMatrix
| OrbVector
| Volumetric,
basis_role: str | None = None,
)
One electronic quantity and the atom-centered basis role it uses.
basis_role is an open string key into Sample.basis_sets. Common
conventional names include ao, aux, and paw_coupled.
Sample
dataclass
Sample(
geometry: Geometry,
electronic_quantities: dict[str, ElectronicQuantity],
basis_sets: dict[str, BasisSet] = dict(),
)
One geometry and its selected electronic quantities.
Dataset membership and its stable sample ID are assigned outside this physical object.
QuadratureVolumetric
dataclass
QuadratureVolumetric(grid: QuadratureGrid, values: ArrayLike, pauli: str | None = None)
One or more real functions sampled at explicit quadrature points.
extra_shape
property
extra_shape: tuple[int, ...]
Shape of the non-spatial value axes.
l1_norm
l1_norm() -> float | NDArray[float64]
Return the quadrature-integrated L1 norm of each set of values.
l2_norm
l2_norm() -> float | NDArray[float64]
Return the quadrature-integrated L2 norm of each set of values.
rotated
rotated(
spatial_rotation: ArrayLike, *, spin_rotation: bool | ArrayLike = False
) -> QuadratureVolumetric
Return the values and quadrature points after an active rotation.
spin_rotation leaves Pauli components fixed when False, follows the
spatial system as an axial vector when True, or applies an explicit
proper spin rotation.
UniformVolumetric
dataclass
UniformVolumetric(grid: UniformGrid, values: ArrayLike, pauli: str | None = None)
One or more real functions sampled on a three-dimensional uniform grid.
extra_shape
property
extra_shape: tuple[int, ...]
Shape of the non-spatial value axes.
l1_norm
l1_norm() -> float | NDArray[float64]
Return the grid-integrated L1 norm of each set of values.
l2_norm
l2_norm() -> float | NDArray[float64]
Return the grid-integrated L2 norm of each set of values.
rotated
rotated(
spatial_rotation: ArrayLike, *, spin_rotation: bool | ArrayLike = False
) -> UniformVolumetric
Return the values and uniform grid after an active rotation.
spin_rotation leaves Pauli components fixed when False, follows the
spatial system as an axial vector when True, or applies an explicit
proper spin rotation.
calculate_aux_coeffs
calculate_aux_coeffs(
aux_overlap: HermOrbMatrix,
basis_integrals: OrbVector,
*,
solver: Literal["cholesky", "pseudoinverse"] = "cholesky",
rank_rtol: float = 1e-12,
) -> OrbVector
Solve ordinary L2 projection equations for auxiliary coefficients.
Each leading dimension of basis_integrals.array is an independent
right-hand side. The two inputs must use the same atom-partitioned
auxiliary-basis order.
Parameters:
-
(aux_overlapHermOrbMatrix) –Real dense auxiliary-basis overlap.
-
(basis_integralsOrbVector) –Real
<chi_lambda | f>values. -
(solverLiteral['cholesky', 'pseudoinverse'], default:'cholesky') –"cholesky"requires a full-rank positive-definite overlap."pseudoinverse"accepts a rank-deficient Hermitian overlap and returns the minimum-norm solution after removing eigenvalues belowrank_rtolrelative to the largest absolute eigenvalue. -
(rank_rtolfloat, default:1e-12) –Relative eigenvalue cutoff used by
"pseudoinverse".
Returns:
evaluate_basis_for_geometry
evaluate_basis_for_geometry(
geometry: Geometry,
basis_set: SplineNumericalBasisSet | UniformNumericalBasisSet | GaussianBasisSet,
coordinates: ArrayLike,
) -> NDArray[float64]
Evaluate a basis set placed on a finite geometry at Cartesian points.
Parameters:
-
(geometryGeometry) –Atomic centers; periodic geometries are unsupported.
-
(basis_setSplineNumericalBasisSet | UniformNumericalBasisSet | GaussianBasisSet) –Basis functions selected by each atom's atomic number.
-
(coordinatesArrayLike) –Cartesian coordinates in Å with shape
(n_points, 3).
Returns:
-
NDArray[float64]–Values with shape
(n_points, n_orb)in atom-major basis ordering.
merge_basis_sets
Merge compatible element subsets of one concrete basis-set type.
Shared atomic numbers must have equal complete atomic bases. The returned atomic bases are ordered by atomic number independently of input order.
calculate_gaussian_basis_integrals
calculate_gaussian_basis_integrals(
geometry: Geometry,
ao_basis_set: GaussianBasisSet,
basis_set: GaussianBasisSet,
density_matrix: HermOrbMatrix | HermBlockSparseOrbMatrix,
) -> OrbVector
Contract a Gaussian AO density matrix with three-center overlaps.
Three-center integrals are evaluated one target-basis shell at a time and
immediately contracted with every leading density-matrix component. The
full (n_ao, n_ao, n_basis) tensor is never materialized.
calculate_gaussian_overlap
calculate_gaussian_overlap(
geometry: Geometry, basis_set: GaussianBasisSet
) -> HermOrbMatrix
Calculate the ordinary overlap matrix of a finite Gaussian basis.
evaluate_gaussian_density
evaluate_gaussian_density(
geometry: Geometry,
ao_basis_set: GaussianBasisSet,
density_matrix: HermOrbMatrix | HermBlockSparseOrbMatrix,
grid: QuadratureGrid,
) -> QuadratureVolumetric
Evaluate physical components of a Gaussian AO density matrix at quadrature points.
neighbor_list
neighbor_list(
quantities: str,
positions: Tensor,
cell: Tensor,
pbc: Tensor,
cutoff: float,
batch_ptr: Tensor | None = None,
*,
algorithm: Literal["auto", "brute_force", "cell_list"] = "auto",
cpu_threads: int | None = None,
sorted: bool = False,
half_list: bool = False,
include_self: bool = False,
) -> tuple[Tensor, ...]
neighbor_list(
quantities: str,
positions: NDArray[float32] | NDArray[float64],
cell: NDArray[float32] | NDArray[float64],
pbc: NDArray[bool_],
cutoff: float,
batch_ptr: NDArray[int64] | None = None,
*,
algorithm: Literal["auto", "brute_force", "cell_list"] = "auto",
cpu_threads: int | None = None,
sorted: bool = False,
half_list: bool = False,
include_self: bool = False,
) -> tuple[ndarray, ...]
neighbor_list(
quantities: str,
positions: Tensor | ndarray,
cell: Tensor | ndarray,
pbc: Tensor | ndarray,
cutoff: float,
batch_ptr: Tensor | ndarray | None = None,
*,
algorithm: Literal["auto", "brute_force", "cell_list"] = "auto",
cpu_threads: int | None = None,
sorted: bool = False,
half_list: bool = False,
include_self: bool = False,
) -> tuple[Tensor, ...] | tuple[ndarray, ...]
Build an atomistic neighbor list within a strict distance cutoff.
Parameters:
-
(quantitiesstr) –String selecting the returned quantities and their order. The supported characters are
"i"for source indices,"j"for target indices,"P"for paired indices,"S"for integer cell shifts,"d"for distances, and"D"for displacement vectors. Characters may be repeated. An empty string returns an empty tuple. -
(positionsTensor | ndarray) –Atomic Cartesian positions. For one structure, use an
(n_atoms, 3)PyTorch tensor or NumPy array. For a batch, concatenate all positions into(n_total_atoms, 3). The dtype must befloat32orfloat64. Torch inputs may be on CPU or CUDA; NumPy inputs use the CPU backend. All values must be finite. -
(cellTensor | ndarray) –Cartesian cell vectors stored as rows. Use shape
(3, 3)whenbatch_ptrisNoneand(n_structures, 3, 3)for a batch. Its floating dtype and, for Torch, device must matchpositions. All values must be finite. For every nonempty structure, the rows enabled bypbcmust be linearly independent; inactive rows and the full cell may be rank deficient. -
(pbcTensor | ndarray) –Periodic boundary flags for the three cell rows. Use shape
(3,)for one structure and(n_structures, 3)for a batch. The dtype must bebooland the array ecosystem/device must matchpositions. -
(cutofffloat) –Strict, finite, positive distance cutoff.
positions,cell, andcutoffmust use the same length unit. -
(batch_ptrTensor | ndarray | None, default:None) –Optional
int64structure boundaries in the concatenatedpositions, with shape(n_structures + 1,). It must start at zero, be nondecreasing, and end atn_total_atoms.Nonedenotes one structure and is equivalent to[0, n_atoms]. Its array ecosystem and, for Torch, device must matchpositions. -
(algorithmLiteral['auto', 'brute_force', 'cell_list'], default:'auto') –Search method.
"auto"(default) selects a backend- appropriate method."brute_force"exhaustively checks every relevant atom pair."cell_list"partitions space so that atoms only inspect nearby regions. -
(cpu_threadsint | None, default:None) –Number of CPU threads used by this call, including the calling thread. A positive integer explicitly selects the thread count.
Noneuses the conservative CPU default of one thread and leaves the option unspecified for CUDA. CPU workers are reused across calls. CUDA calls reject any explicit integer because CUDA execution does not use the CPU search pool. -
(sortedbool, default:False) –If
True, sort pairs by source index. The order of target indices and cell shifts within each source is unspecified. The default isFalse. -
(half_listbool, default:False) –If
False(default), return the full directed list. IfTrue, retain the lexicographically smaller of(source, target, Sx, Sy, Sz)and(target, source, -Sx, -Sy, -Sz). -
(include_selfbool, default:False) –Whether to include exactly one zero-shift self pair
(i, i, [0, 0, 0])for every atom. The default isFalse.
Returns:
-
tuple[Tensor, ...] | tuple[ndarray, ...]–A tuple containing one array for each character in
quantities, in -
tuple[Tensor, ...] | tuple[ndarray, ...]–the same order. All arrays use the same ecosystem as the inputs and,
-
tuple[Tensor, ...] | tuple[ndarray, ...]–for Torch, the same device. If
n_edgespairs are found: -
tuple[Tensor, ...] | tuple[ndarray, ...]–iandjhave dtypeint64and shape(n_edges,).
-
tuple[Tensor, ...] | tuple[ndarray, ...]–Phas dtypeint64and shape(n_edges, 2); its columns are
-
tuple[Tensor, ...] | tuple[ndarray, ...]–sourceandtarget. -
tuple[Tensor, ...] | tuple[ndarray, ...]–Shas dtypeint32and shape(n_edges, 3)and translates
-
tuple[Tensor, ...] | tuple[ndarray, ...]–the target image.
-
tuple[Tensor, ...] | tuple[ndarray, ...]–dhas the input floating dtype and shape(n_edges,).
-
tuple[Tensor, ...] | tuple[ndarray, ...]–Dhas the input floating dtype and shape(n_edges, 3).
-
tuple[Tensor, ...] | tuple[ndarray, ...]–For pair
kin structureb,D[k]is -
tuple[Tensor, ...] | tuple[ndarray, ...]–positions[target[k]] - positions[source[k]] + S[k] @ cell[b]. -
tuple[Tensor, ...] | tuple[ndarray, ...]–For a single structure, use
celldirectly.
Raises:
-
TypeError–If
quantitiesoralgorithmis not a string;cpu_threadsis neitherNonenor a Pythonint; array arguments mix PyTorch and NumPy or use an unsupported container type; or a boolean option is not a Pythonbool. -
ValueError–If
quantitiescontains an unsupported character;algorithmis unsupported; or frontend shapes, dtypes, devices,batch_ptr,cutoff,cpu_threads, periodic cells, or host-validated index/resource bounds are invalid. -
RuntimeError–If the required native CPU or CUDA extension is missing; if native search discovers nonfinite positions or a representative wrap/output shift outside its integer range; if an explicitly requested cell list cannot safely process the input; or if backend execution otherwise fails.
Note
The result contains atom-image pairs whose squared distance is strictly
less than cutoff**2. half_list=False returns both directions:
pair (source, target, S) has reverse pair
(target, source, -S). A zero-shift self pair is controlled only by
include_self. Periodic self-images remain ordinary cutoff pairs,
and multiple periodic images are retained. Pairs never cross structures,
shifts along inactive pbc axes are zero. Output order is
unspecified unless sorted=True.
Neighbor identity is discrete and is not differentiable. For Torch inputs, returned distances and displacement vectors are computed from the original floating tensors and remain differentiable while the neighbor identity is fixed.
Example
>>> import torch
>>> from elfes.physics import neighbor_list
>>> positions = torch.tensor([[0.0, 0.0, 0.0], [0.8, 0.0, 0.0]])
>>> cell = torch.eye(3) * 4.0
>>> pbc = torch.tensor([False, False, False])
>>> pairs, shifts, distances = neighbor_list(
... "PSd", positions, cell, pbc, cutoff=1.0
... )
>>> pairs.shape, shifts.shape, distances.tolist()
(torch.Size([2, 2]), torch.Size([2, 3]), [0.800000011920929, 0.800000011920929])
build_pyscf_quadrature_grid
build_pyscf_quadrature_grid(geometry: Geometry, *, level: int = 3) -> QuadratureGrid
Build a PySCF atom-centered quadrature grid.
normalize_radial_functions
normalize_radial_functions(
basis: SplineNumericalAtomicBasis,
) -> SplineNumericalAtomicBasis
normalize_radial_functions(
basis: UniformNumericalAtomicBasis,
) -> UniformNumericalAtomicBasis
normalize_radial_functions(basis: SplineNumericalBasisSet) -> SplineNumericalBasisSet
normalize_radial_functions(basis: UniformNumericalBasisSet) -> UniformNumericalBasisSet
normalize_radial_functions(
basis: SplineNumericalAtomicBasis
| SplineNumericalBasisSet
| UniformNumericalAtomicBasis
| UniformNumericalBasisSet,
) -> (
SplineNumericalAtomicBasis
| SplineNumericalBasisSet
| UniformNumericalAtomicBasis
| UniformNumericalBasisSet
)
Return a new basis whose radial shells have unit radial norm.
radial_norm_integrals
radial_norm_integrals(
atomic_basis: SplineNumericalAtomicBasis | UniformNumericalAtomicBasis,
) -> NDArray[float64]
Integrate r^2 |R(r)|^2 for every radial shell.
Spline numerical bases use five-point Gauss–Legendre quadrature on each spline interval. Uniform numerical bases use composite Simpson quadrature on their stored samples.
basis_rotations
basis_rotations(
basis_set: BasisSet, atomic_numbers: NDArray[int32], rotation: ArrayLike
) -> dict[int, NDArray[float64]]
Construct active function rotations for the requested elements.
The recursion is evaluated once through the largest requested angular momentum, then each requested block is shared by every matching shell and element.
Parameters:
-
(basis_setBasisSet) –Atomic bases keyed by atomic number.
-
(atomic_numbersNDArray[int32]) –Atomic numbers with shape
(n_atoms,). -
(rotationArrayLike) –Orthogonal Cartesian matrix with shape
(3, 3).
Returns:
-
dict[int, NDArray[float64]]–Block-diagonal orbital rotation keyed by each distinct atomic number.
gaunt_coefficients
Return triple products of normalized real spherical harmonics.
The harmonics follow the Wikipedia real spherical harmonic convention.
Each output axis is ordered by m = -l, ..., l. Combinations that violate
the angular-momentum selection rules return an exact-zero array.
Parameters:
-
(l1int) –Angular degree of the first harmonic.
-
(l2int) –Angular degree of the second harmonic.
-
(l3int) –Angular degree of the third harmonic.
Returns:
-
NDArray[float64]–Coefficients with shape
(2*l1 + 1, 2*l2 + 1, 2*l3 + 1).
solid_harmonics
Evaluate real solid harmonics through l_max.
Each degree-l block contains r**l * Y_lm(r_hat) in the Wikipedia
real spherical harmonic convention, ordered by m = -l, ..., l. At the
origin the degree-zero component is Y_00 and all higher-degree
components are zero.
Parameters:
-
(l_maxint) –Highest angular degree to calculate. Results include every degree from zero through
l_max. -
(vectorsTensor | NDArray[float64]) –Cartesian vectors with shape
(..., 3). NumPy inputs must use dtypefloat64. Torch inputs may be on CPU or CUDA and must use dtypefloat32orfloat64.
Returns:
-
Tensor | NDArray[float64]–Solid-harmonic values with shape
(..., (l_max + 1) ** 2), using the -
Tensor | NDArray[float64]–same array ecosystem, floating dtype and, for Torch, device as
-
Tensor | NDArray[float64]–vectors. Torch results support reverse-mode differentiation through -
Tensor | NDArray[float64]–second derivatives.
spherical_harmonics
spherical_harmonics(l_max: int, directions: Tensor) -> Tensor
spherical_harmonics(l_max: int, directions: NDArray[float64]) -> NDArray[float64]
spherical_harmonics(
l_max: int, directions: Tensor | NDArray[float64]
) -> Tensor | NDArray[float64]
Evaluate normalized real spherical harmonics through l_max.
The harmonics follow the Wikipedia real spherical harmonic convention and
are ordered in consecutive degree blocks, with m = -l, ..., l within
each block.
Parameters:
-
(l_maxint) –Highest angular degree to calculate. Results include every degree from zero through
l_max. -
(directionsTensor | NDArray[float64]) –Nonzero Cartesian directions with shape
(..., 3). NumPy inputs must use dtypefloat64. Torch inputs may be on CPU or CUDA and must use dtypefloat32orfloat64.
Returns:
-
Tensor | NDArray[float64]–Harmonic values with shape
(..., (l_max + 1) ** 2), using the same -
Tensor | NDArray[float64]–array ecosystem, floating dtype and, for Torch, device as
directions. -
Tensor | NDArray[float64]–Torch results support reverse-mode differentiation through second
-
Tensor | NDArray[float64]–derivatives.
wigner_D
Return real Wigner D matrices through l_max.
The matrices use the Wikipedia real spherical harmonic basis, with each
block ordered by m = -l, ..., l and the l = 1 block ordered as
(y, z, x). They describe an active orthogonal transformation acting on
Cartesian column vectors: Y_l(rotation.T @ x) = Y_l(x) @ D_l(rotation)
when the harmonics form a row. For an improper transformation, inversion
is separated from a proper rotation and contributes the natural parity
(-1)**l.
Parameters:
-
(l_maxint) –Highest non-negative angular quantum number.
-
(rotationArrayLike) –Orthogonal Cartesian matrix with shape
(3, 3)acting on column vectors.
Returns:
-
NDArray[float64]–Tuple indexed by
lcontaining matrices with shape -
...–(2 * l + 1, 2 * l + 1).
Notes
This is the Ivanic–Ruedenberg direct recursion, including the 1998
correction and the independently verified m < 0 V term used by
google/spherical-harmonics (Apache-2.0) and spaudiopy (MIT).
References
Ivanic and Ruedenberg, J. Phys. Chem. 100, 6342–6347 (1996), doi:10.1021/jp953350u; correction, J. Phys. Chem. A 102, 9099–9100 (1998), doi:10.1021/jp9833350.
collinear_pauli
collinear_pauli(up: ArrayLike, down: ArrayLike) -> NDArray
Convert equal-shaped spin-up/down values to (0, z) components.
decompose_pauli
decompose_pauli(spin_blocks: ArrayLike) -> NDArray
Decompose explicit spin blocks into Pauli coefficients.
The first two axes are spin row and column in (up, down) order.
Remaining axes contain the corresponding spatial values. Coefficients
satisfy H = sum_A H[A] * sigma_A.
Parameters:
-
(spin_blocksArrayLike) –Array with shape
(2, 2, *spatial_shape).
Returns:
-
NDArray–Complex Pauli coefficients with shape
(4, *spatial_shape)and -
NDArray–component order
(0, x, y, z).
reconstruct_pauli
reconstruct_pauli(
components: ArrayLike, pauli: str, *, fill_missing: complex | None = None
) -> NDArray[complex128]
Reconstruct explicit spin blocks from Pauli coefficients.
Parameters:
-
(componentsArrayLike) –Coefficients with shape
(len(pauli), *spatial_shape). -
(paulistr) –Stored Pauli components in their axis order.
-
(fill_missingcomplex | None, default:None) –Value assigned to components absent from
pauli. Required unless all four components are present.
Returns:
-
NDArray[complex128]–Complex array with shape
(2, 2, *spatial_shape). The first two axes -
NDArray[complex128]–are spin row and column in
(up, down)order.
volumetric_l1_diff
volumetric_l1_diff(first: Volumetric, second: Volumetric) -> float | NDArray[float64]
Return the grid-integrated L1 difference between sampled values.
volumetric_l2_diff
volumetric_l2_diff(first: Volumetric, second: Volumetric) -> float | NDArray[float64]
Return the grid-integrated L2 difference between sampled values.