PAOFLOW.sparse.doubling#

Cell doubling as pure index arithmetic on the bond list.

Replicates hamiltonian.do_doubling.doubling_HRs exactly, without ever materializing the dense (2 nawf, 2 nawf, nk1, nk2, nk3, nspin) array. The dense kernel indexes its cell_index map by the negated folded lattice coordinate (ix = -round(Rx*nk1), “the minus sign is due to the Fourier transformation”), so in the true folded coordinates produced by folded_R_triples() it builds

\[\begin{split}H^{2\times}(M) = \begin{pmatrix} H(2M) & H(2M-1) \\ H(2M+1) & H(2M) \end{pmatrix}\end{split}\]

and the inverse map per bond with folded axis index m is:

  • m even: contributes the (0,0) and (1,1) blocks at M = m/2 (dnm kept — same replica);

  • m odd: contributes the (0,1) block at M = (m+1)/2 and the (1,0) block at M = (m-1)/2 (dnm = 0 — the dense doubling_attr_arry doubles Dnm block-diagonally, zeroing cross-replica pairs).

Each doubling therefore exactly doubles nnz: memory grows linearly in the number of orbitals, not quadratically as in the dense kernel. The truncation eig_bound carries over unchanged (doubling only rearranges and duplicates row content). Thresholding commutes with doubling.

The driver remains responsible for the accompanying metadata updates (tau/a_vectors in the DataController plus the dense doubling_attr_arry for scalar attributes); double_axis updates the container’s own a_vectors copy.

Functions#

double_axis(sph, axis)

Return a new bond list for the cell doubled along one axis.

Module Contents#

PAOFLOW.sparse.doubling.double_axis(sph, axis)[source]#

Return a new bond list for the cell doubled along one axis.

Parameters:
  • sph (SparseHamiltonian) – Bond list of the current cell. Left unmodified; its raw bond arrays must still be present, i.e. it must not have been compacted.

  • axis (int) – Lattice axis to double, 0, 1 or 2.

Returns:

Bond list of the doubled cell: 2 * nawf orbitals, 2 * nnz bonds, the same R grid, and a_vectors with the doubled axis scaled by two.

Return type:

SparseHamiltonian

Raises:
  • AssertionError – If a mapped lattice index leaves the folded window of the R grid, which would mean the halved index no longer names a vector of the supercell’s own lattice.

  • RuntimeError – If sph has been compacted and no longer holds the bond arrays.

Notes

Doubling a cell along an axis means describing the same crystal with a unit cell twice as long, holding two copies of the original basis. The orbital index therefore doubles: orbital i of the first replica keeps index i, orbital i of the second gets i + nawf. A hopping that used to reach from cell m to cell 0 now either stays inside one supercell (connecting the two replicas) or crosses to a neighbouring supercell, depending on whether m is even or odd:

  • even m connects like-numbered replicas and lands on supercell m/2, contributing to both diagonal blocks;

  • odd m connects the two different replicas and lands on supercells (m ± 1) / 2, contributing to the two off-diagonal blocks.

Python’s floor division implements the even case exactly, negative indices included, and the ±1 offsets of the odd case pick out the two supercells a cross-replica hopping reaches. So the whole operation is integer arithmetic on the axis component of each bond plus an offset on its row or column index — no matrix is ever built, and the bond count merely doubles. The dense kernel, by contrast, allocates the full (2 nawf, 2 nawf, ...) array and pays four times the memory per doubling.

The intra-cell orbital position differences dnm, which enter the velocity operator, are kept on the diagonal blocks and zeroed on the off-diagonal ones. This follows the dense convention exactly: the dense driver rebuilds Dnm for the doubled cell as a block-diagonal repeat, which leaves cross-replica pairs at zero.