Skip to content

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_number

    (int) –

    Atomic number of the element using this basis.

  • angmoms

    (ArrayLike) –

    Angular quantum number l of each shell, stored as an int32 array with shape (n_shells,).

  • name

    (str | 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: Sequence[AtomicBasisT])

Atomic bases in canonical ascending atomic-number order.

The base class stores the shell structure needed to interpret orbital axes. Numerical and Gaussian subclasses add complete radial functions. The position of an atomic basis in atomic_bases is the canonical species index for this basis set.

Parameters:

  • atomic_bases

    (Sequence[AtomicBasisT]) –

    Atomic bases with unique atomic numbers. Input order is ignored.

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_number

    (int) –

    Atomic number of the element using this basis.

  • angmoms

    (ArrayLike) –

    Angular quantum number of each shell.

  • primitive_offsets

    (ArrayLike) –

    Boundaries of each shell's primitive data, with shape (n_shells + 1,).

  • primitive_exponents

    (ArrayLike) –

    Positive primitive exponents in Å\(^{-2}\).

  • contraction_coefficients

    (ArrayLike) –

    Dimensionless contraction coefficients.

  • name

    (str | 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_coordinates

    (ArrayLike) –

    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, ..., l order within each shell.

GaussianBasisSet dataclass

GaussianBasisSet(atomic_bases: Sequence[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_number

    (int) –

    Atomic number of the element using this basis.

  • angmoms

    (ArrayLike) –

    Angular quantum number of each shell.

  • radial_grid

    (ArrayLike) –

    Strictly increasing radial knots in Å, beginning at zero. At least four knots are required.

  • radial_values

    (ArrayLike) –

    Bare radial samples with shape [n_shells, n_grid].

  • name

    (str | 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:

  • radius

    (ArrayLike) –

    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_coordinates

    (ArrayLike) –

    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, ..., l order within each shell.

SplineNumericalBasisSet dataclass

SplineNumericalBasisSet(
    atomic_bases: Sequence[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_number

    (int) –

    Atomic number of the element using this basis.

  • angmoms

    (ArrayLike) –

    Angular quantum number of each shell.

  • radial_spacing

    (float) –

    Positive spacing between radial knots in Å.

  • radial_values

    (ArrayLike) –

    Bare radial samples with shape [n_shells, n_grid].

  • name

    (str | 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:

  • radius

    (ArrayLike) –

    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_coordinates

    (ArrayLike) –

    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, ..., l order within each shell.

UniformNumericalBasisSet dataclass

UniformNumericalBasisSet(
    atomic_bases: Sequence[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_dense

to_dense() -> OrbMatrix

Return an all-zero-shift matrix in global orbital order.

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_dense

to_dense() -> HermOrbMatrix

Return an all-zero-shift matrix in global orbital order.

AtomCartesianTensor2 dataclass

AtomCartesianTensor2(array: ArrayLike)

Atom-level rank-2 Cartesian tensors with shape (*extra_shape, n_atoms, 3, 3).

rotated

rotated(rotation: ArrayLike) -> AtomCartesianTensor2

Return the tensors after an active orthogonal transformation.

AtomCartesianVector dataclass

AtomCartesianVector(array: ArrayLike)

Atom-level real polar vectors with shape (*extra_shape, n_atoms, 3).

rotated

rotated(rotation: ArrayLike) -> AtomCartesianVector

Return the vectors after an active orthogonal transformation.

AtomScalar dataclass

AtomScalar(array: ArrayLike)

Atom-level real scalars with shape (*extra_shape, n_atoms).

CartesianTensor2 dataclass

CartesianTensor2(array: ArrayLike)

One or more real rank-2 Cartesian tensors with shape (*extra_shape, 3, 3).

rotated

rotated(rotation: ArrayLike) -> CartesianTensor2

Return the tensors after an active orthogonal transformation.

CartesianVector dataclass

CartesianVector(array: ArrayLike)

One or more real polar vectors with shape (*extra_shape, 3).

rotated

rotated(rotation: ArrayLike) -> CartesianVector

Return the vectors after an active orthogonal transformation.

Scalar dataclass

Scalar(array: ArrayLike)

One or more real scalars with shape extra_shape.

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_numbers

    (ArrayLike) –

    Non-empty positive atomic numbers with shape (n_atoms,).

  • positions

    (ArrayLike) –

    Cartesian coordinates in Å with shape (n_atoms, 3).

  • cell

    (ArrayLike | None, default: None ) –

    Cartesian cell vectors in Å as the rows of a (3, 3) matrix. Omission gives a zero matrix. Rows selected by pbc must be linearly independent; inactive rows may be zero.

  • pbc

    (ArrayLike, default: False ) –

    Boolean periodic-axis flags. A scalar applies to every axis; otherwise the value must have shape (3,). Omission gives no periodic axes.

  • magmoms

    (ArrayLike | 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:

  • coordinates

    (ArrayLike) –

    Cartesian point coordinates in Å with shape (n_points, 3).

  • weights

    (ArrayLike) –

    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:

  • origin

    (ArrayLike) –

    Cartesian position of grid point (0, 0, 0) with shape (3,).

  • step_vectors

    (ArrayLike) –

    Cartesian displacement for one index step along each grid axis, stored as the rows of a (3, 3) matrix.

  • shape

    (ArrayLike) –

    Number of grid points along the three axes.

  • pbc

    (ArrayLike, 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.

HermOrbMatrix

HermOrbMatrix(array: ArrayLike, orb_counts: ArrayLike, pauli: str | None = None)

Bases: OrbMatrix

Dense Hermitian matrix with two atom-partitioned orbital axes.

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:

  • array

    (ArrayLike) –

    Numeric array with shape (*extra_shape, n_orb, n_orb).

  • orb_counts

    (ArrayLike) –

    Number of basis functions on every atom with shape (n_atoms,).

  • pauli

    (str | None, default: None ) –

    None for spinless values, otherwise a non-empty ordered subset of "0xyz" naming the final leading component axis.

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:

  • array

    (ArrayLike) –

    Numeric array with shape (*extra_shape, n_orb).

  • orb_counts

    (ArrayLike) –

    Number of basis functions on every atom with shape (n_atoms,).

  • pauli

    (str | None, default: None ) –

    None for 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.

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] = dict(),
    basis_sets: dict[str, BasisSet] = dict(),
    atomistic_quantities: dict[str, AtomisticQuantity] = dict(),
)

One geometry and its selected atomistic and 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.

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:

Returns:

  • NDArray[float64]

    Values with shape (n_points, n_orb) in atom-major basis ordering.

merge_basis_sets

merge_basis_sets(basis_sets: Iterable[BasisSet]) -> BasisSet

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: 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, ...]

Build an atomistic neighbor list within a strict distance cutoff.

Parameters:

  • quantities

    (str) –

    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.

  • positions

    (NDArray[float32] | NDArray[float64]) –

    Atomic Cartesian positions. For one structure, use an (n_atoms, 3) NumPy array. For a batch, concatenate all positions into (n_total_atoms, 3). The dtype must be float32 or float64. All values must be finite.

  • cell

    (NDArray[float32] | NDArray[float64]) –

    Cartesian cell vectors stored as rows. Use shape (3, 3) when batch_ptr is None and (n_structures, 3, 3) for a batch. Its floating dtype must match positions. All values must be finite. For every nonempty structure, the rows enabled by pbc must be linearly independent; inactive rows and the full cell may be rank deficient.

  • pbc

    (NDArray[bool_]) –

    Periodic boundary flags for the three cell rows. Use shape (3,) for one structure and (n_structures, 3) for a batch. The dtype must be bool.

  • cutoff

    (float) –

    Strict, finite, positive distance cutoff. positions, cell, and cutoff must use the same length unit.

  • batch_ptr

    (NDArray[int64] | None, default: None ) –

    Optional int64 structure boundaries in the concatenated positions, with shape (n_structures + 1,). It must start at zero, be nondecreasing, and end at n_total_atoms. None denotes one structure and is equivalent to [0, n_atoms]. Its dtype must be int64.

  • algorithm

    (Literal['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_threads

    (int | None, default: None ) –

    Number of CPU threads used by this call, including the calling thread. A positive integer explicitly selects the thread count. None uses the conservative CPU default of one thread. CPU workers are reused across calls.

  • sorted

    (bool, default: False ) –

    If True, sort pairs by source index. The order of target indices and cell shifts within each source is unspecified. The default is False.

  • half_list

    (bool, default: False ) –

    If False (default), return the full directed list. If True, retain the lexicographically smaller of (source, target, Sx, Sy, Sz) and (target, source, -Sx, -Sy, -Sz).

  • include_self

    (bool, default: False ) –

    Whether to include exactly one zero-shift self pair (i, i, [0, 0, 0]) for every atom. The default is False.

Returns:

  • ndarray

    A tuple containing one array for each character in quantities, in

  • ...

    the same order. If n_edges pairs are found:

  • tuple[ndarray, ...]
    • i and j have dtype int64 and shape (n_edges,).
  • tuple[ndarray, ...]
    • P has dtype int64 and shape (n_edges, 2); its columns are
  • tuple[ndarray, ...]

    source and target.

  • tuple[ndarray, ...]
    • S has dtype int32 and shape (n_edges, 3) and translates
  • tuple[ndarray, ...]

    the target image.

  • tuple[ndarray, ...]
    • d has the input floating dtype and shape (n_edges,).
  • tuple[ndarray, ...]
    • D has the input floating dtype and shape (n_edges, 3).
  • tuple[ndarray, ...]

    For pair k in structure b, D[k] is

  • tuple[ndarray, ...]

    positions[target[k]] - positions[source[k]] + S[k] @ cell[b].

  • tuple[ndarray, ...]

    For a single structure, use cell directly.

Raises:

  • TypeError

    If quantities or algorithm is not a string; cpu_threads is neither None nor a Python int; or a boolean option is not a Python bool.

  • ValueError

    If quantities contains an unsupported character; algorithm is unsupported; or frontend shapes, dtypes, batch_ptr, cutoff, cpu_threads, periodic cells, or host-validated index/resource bounds are invalid.

  • RuntimeError

    If the required native CPU 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.

Example
>>> import numpy as np
>>> from elfes.physics import neighbor_list
>>> positions = np.array([[0.0, 0.0, 0.0], [0.8, 0.0, 0.0]])
>>> cell = np.eye(3) * 4.0
>>> pbc = np.zeros(3, dtype=np.bool_)
>>> pairs, shifts, distances = neighbor_list(
...     "PSd", positions, cell, pbc, cutoff=1.0
... )
>>> pairs.shape, shifts.shape, distances.tolist()
((2, 2), (2, 3), [0.8, 0.8])

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

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_set

    (BasisSet) –

    Atomic bases keyed by atomic number.

  • atomic_numbers

    (NDArray[int32]) –

    Atomic numbers with shape (n_atoms,).

  • rotation

    (ArrayLike) –

    Orthogonal Cartesian matrix with shape (3, 3).

Returns:

  • dict[int, NDArray[float64]]

    Block-diagonal orbital rotation keyed by each distinct atomic number.

gaunt_coefficients

gaunt_coefficients(l1: int, l2: int, l3: int) -> NDArray[float64]

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:

  • l1

    (int) –

    Angular degree of the first harmonic.

  • l2

    (int) –

    Angular degree of the second harmonic.

  • l3

    (int) –

    Angular degree of the third harmonic.

Returns:

  • NDArray[float64]

    Coefficients with shape (2*l1 + 1, 2*l2 + 1, 2*l3 + 1).

solid_harmonics

solid_harmonics(l_max: int, vectors: NDArray[float64]) -> NDArray[float64]

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_max

    (int) –

    Highest angular degree to calculate. Results include every degree from zero through l_max.

  • vectors

    (NDArray[float64]) –

    Cartesian vectors with shape (..., 3) and dtype float64.

Returns:

  • NDArray[float64]

    Solid-harmonic values with shape (..., (l_max + 1) ** 2).

spherical_harmonics

spherical_harmonics(l_max: int, directions: NDArray[float64]) -> 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_max

    (int) –

    Highest angular degree to calculate. Results include every degree from zero through l_max.

  • directions

    (NDArray[float64]) –

    Nonzero Cartesian directions with shape (..., 3) and dtype float64.

Returns:

  • NDArray[float64]

    Harmonic values with shape (..., (l_max + 1) ** 2).

wigner_D

wigner_D(l_max: int, rotation: ArrayLike) -> NDArray[float64]

Return flattened 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.

Parameters:

  • l_max

    (int) –

    Highest non-negative angular quantum number.

  • rotation

    (ArrayLike) –

    Proper Cartesian rotation matrices with shape (..., 3, 3) acting on column vectors.

Returns:

  • NDArray[float64]

    Consecutive row-major flattened blocks D_0, ..., D_l_max, with shape

  • NDArray[float64]

    (..., sum((2 * l + 1) ** 2 for l in range(l_max + 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_blocks

    (ArrayLike) –

    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:

  • components

    (ArrayLike) –

    Coefficients with shape (len(pauli), *spatial_shape).

  • pauli

    (str) –

    Stored Pauli components in their axis order.

  • fill_missing

    (complex | 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.