PAOFLOW.topology.do_find_Weyl#

Attributes#

Functions#

pack_HR(HRaux[, ispin])

Pack one spin channel of H(R) into a contiguous matrix for BLAS.

build_Hk(HRpack, nawf, kq, R)

Fourier-transform the packed H(R) to H(k) at a single k-point.

build_Hk_batch(HRpack, nawf, kq, R)

Fourier-transform the packed H(R) to H(k) for a block of k-points.

band_energies(HRpack, nawf, kq, R)

Compute band eigenvalues for one or many k-points.

get_gap(HRpack, nawf, kq, R, nelec)

Return the direct band gap at k-point kq between bands nelec-1 and nelec.

screen_boxes(HRpack, nawf, R, nelec, lo, hi[, factor])

Flag the search boxes that can plausibly contain a band crossing.

get_R_grid_fft(nr1, nr2, nr3)

Build the real-space R-grid corresponding to an FFT supercell.

get_search_grid(nk1, nk2, nk3[, snk1_range, ...])

Generate a uniform 3-D search grid in fractional BZ coordinates.

find_weyl(data_controller, test_rad, search_grid)

Locate and classify Weyl points in the Brillouin zone.

find_min(HRpack, nawf, nelec, R, symf, verbose[, ...])

Find band-gap minima across the BZ using local optimisation.

get_equiv_k(kp, symop, sym_TR, mag_soc)

Expand a set of k-points to all symmetry-equivalent images.

Module Contents#

PAOFLOW.topology.do_find_Weyl.comm[source]#
PAOFLOW.topology.do_find_Weyl.rank[source]#
PAOFLOW.topology.do_find_Weyl.size[source]#
PAOFLOW.topology.do_find_Weyl.pack_HR(HRaux, ispin=0)[source]#

Pack one spin channel of H(R) into a contiguous matrix for BLAS.

Parameters:
  • HRaux (ndarray, shape (nawf, nawf, nR, nspin), complex) – Real-space Hamiltonian on the R-grid in crystal coordinates.

  • ispin (int, optional) – Spin channel to extract (default 0).

Returns:

C-contiguous packing of the requested spin channel. For nspin == 1 this is a view and no data is copied.

Return type:

ndarray, shape (nawf*nawf, nR), complex

Notes

In this layout the Fourier sum over R is a single matrix-vector (or matrix-matrix) product. Slicing the spin axis of the original (nawf, nawf, nR, nspin) array yields a strided view, which forces NumPy to copy the whole Hamiltonian on every contraction; packing once here removes that copy from the optimisation loop.

PAOFLOW.topology.do_find_Weyl.build_Hk(HRpack, nawf, kq, R)[source]#

Fourier-transform the packed H(R) to H(k) at a single k-point.

Parameters:
  • HRpack (ndarray, shape (nawf*nawf, nR), complex) – Packed Hamiltonian from pack_HR().

  • nawf (int) – Dimension of the Hamiltonian matrix.

  • kq (ndarray, shape (3,), float) – k-point in crystal (fractional) coordinates.

  • R (ndarray, shape (nR, 3), float) – Real-space lattice vectors produced by get_R_grid_fft().

Returns:

The Hamiltonian at kq.

Return type:

ndarray, shape (nawf, nawf), complex

Notes

\[H(\mathbf{k}) = \sum_{\mathbf{R}} H(\mathbf{R})\,e^{2\pi i\mathbf{k}\cdot\mathbf{R}}\]

The dot product \(\mathbf{k}\cdot\mathbf{R}\) is accumulated in real arithmetic before exponentiation, and the R-sum is a single ZGEMV call with no temporaries.

PAOFLOW.topology.do_find_Weyl.build_Hk_batch(HRpack, nawf, kq, R)[source]#

Fourier-transform the packed H(R) to H(k) for a block of k-points.

Parameters:
  • HRpack (ndarray, shape (nawf*nawf, nR), complex) – Packed Hamiltonian from pack_HR().

  • nawf (int) – Dimension of the Hamiltonian matrix.

  • kq (ndarray, shape (nk, 3), float) – k-points in crystal (fractional) coordinates.

  • R (ndarray, shape (nR, 3), float) – Real-space lattice vectors.

Returns:

The Hamiltonian at each k-point.

Return type:

ndarray, shape (nk, nawf, nawf), complex

Notes

Identical to build_Hk() but evaluates the R-sum as a single ZGEMM. The one-k-point kernel is memory-bandwidth bound (it streams the whole Hamiltonian for \(\mathcal{O}(n_{awf}^2 n_R)\) flops), so amortising that traffic over a block of k-points is much faster per point.

PAOFLOW.topology.do_find_Weyl.band_energies(HRpack, nawf, kq, R)[source]#

Compute band eigenvalues for one or many k-points.

Parameters:
  • HRpack (ndarray, shape (nawf*nawf, nR), complex) – Packed Hamiltonian from pack_HR().

  • nawf (int) – Dimension of the Hamiltonian matrix.

  • kq (ndarray, shape (3,) or (nk, 3), float) – k-point(s) in crystal (fractional) coordinates.

  • R (ndarray, shape (nR, 3), float) – Real-space lattice vectors.

Returns:

Eigenvalues in ascending order, Hermitian upper triangle.

Return type:

ndarray, shape (nk, nawf), float

Notes

k-points are processed in blocks sized to keep the batched Hamiltonian below roughly 16 MB.

PAOFLOW.topology.do_find_Weyl.get_gap(HRpack, nawf, kq, R, nelec)[source]#

Return the direct band gap at k-point kq between bands nelec-1 and nelec.

This is the scalar objective function minimised by find_min() to locate Weyl (band-crossing) points. A gap of zero indicates a band-touching or crossing.

Parameters:
  • HRpack (ndarray, shape (nawf*nawf, nR), complex) – Packed Hamiltonian from pack_HR().

  • nawf (int) – Dimension of the Hamiltonian matrix.

  • kq (ndarray, shape (3,), float) – k-point in crystal (fractional) coordinates.

  • R (ndarray, shape (nR, 3), float) – Real-space lattice vectors.

  • nelec (int) – Number of occupied bands; the gap is evaluated between band index nelec - 1 (HOMO) and nelec (LUMO).

Returns:

Energy difference E[nelec] - E[nelec - 1] at kq.

Return type:

float

Notes

Only the first spin channel is built, since the gap is defined on ispin = 0.

PAOFLOW.topology.do_find_Weyl.screen_boxes(HRpack, nawf, R, nelec, lo, hi, factor=2.0)[source]#

Flag the search boxes that can plausibly contain a band crossing.

Parameters:
  • HRpack (ndarray, shape (nawf*nawf, nR), complex) – Packed Hamiltonian from pack_HR().

  • nawf (int) – Dimension of the Hamiltonian matrix.

  • R (ndarray, shape (nR, 3), float) – Real-space lattice vectors.

  • nelec (int) – Number of occupied bands.

  • lo (ndarray, shape (nbox, 3), float) – Lower and upper corners of each search box, in crystal coordinates.

  • hi (ndarray, shape (nbox, 3), float) – Lower and upper corners of each search box, in crystal coordinates.

  • factor (float, optional) – Safety margin on the gap-variation bound (default 2.0). Larger values keep more boxes.

Returns:

True for boxes that must be handed to the optimiser.

Return type:

ndarray, shape (nbox,), bool

Notes

The gap is sampled on a 9-point stencil (centre plus the eight corners) of every box in a single batched evaluation; adjacent boxes share corners, so the stencil is de-duplicated first. A box is discarded when its smallest sampled gap exceeds factor times the largest gap variation observed across the box, i.e. when a linear (Lipschitz) extrapolation of the sampled slope cannot reach zero inside the box. This is a heuristic, not a proof: it assumes the gap does not develop structure finer than the box on which it is sampled. Pass factor <= 0 in find_min() to disable.

PAOFLOW.topology.do_find_Weyl.get_R_grid_fft(nr1, nr2, nr3)[source]#

Build the real-space R-grid corresponding to an FFT supercell.

Generates all nr1 * nr2 * nr3 lattice vectors in fractional coordinates and folds them into the centred interval [-0.5, 0.5) so that the Fourier sums converge correctly with the PAOFLOW convention.

Parameters:
  • nr1 (int) – Number of FFT grid points along each reciprocal-space direction.

  • nr2 (int) – Number of FFT grid points along each reciprocal-space direction.

  • nr3 (int) – Number of FFT grid points along each reciprocal-space direction.

Returns:

R – Lattice vectors in units of the corresponding primitive vectors, ordered as k + j*nr3 + i*nr2*nr3.

Return type:

ndarray, shape (nr1 * nr2 * nr3, 3)

PAOFLOW.topology.do_find_Weyl.get_search_grid(nk1, nk2, nk3, snk1_range=[-0.5, 0.5], snk2_range=[-0.5, 0.5], snk3_range=[-0.5, 0.5], endpoint=False)[source]#

Generate a uniform 3-D search grid in fractional BZ coordinates.

Creates a full-factorial mesh with nk1 * nk2 * nk3 points by taking the outer product of three np.linspace arrays and reshaping to a flat list of k-vectors. These grid points are used as the lower bounds of the optimisation boxes in find_min().

Parameters:
  • nk1 (int) – Number of grid points along each reciprocal direction.

  • nk2 (int) – Number of grid points along each reciprocal direction.

  • nk3 (int) – Number of grid points along each reciprocal direction.

  • snk1_range (list of float, optional) – [start, stop] range for each direction. Default is the full first Brillouin zone [-0.5, 0.5].

  • snk2_range (list of float, optional) – [start, stop] range for each direction. Default is the full first Brillouin zone [-0.5, 0.5].

  • snk3_range (list of float, optional) – [start, stop] range for each direction. Default is the full first Brillouin zone [-0.5, 0.5].

  • endpoint (bool, optional) – If False (default), the stop value is excluded, matching the Monkhorst–Pack convention and avoiding zone-boundary duplication.

Returns:

grid – Cartesian product of the three 1-D grids, ordered with the first index varying slowest (indexing='ij').

Return type:

ndarray, shape (nk1 * nk2 * nk3, 3)

PAOFLOW.topology.do_find_Weyl.find_weyl(data_controller, test_rad, search_grid)[source]#

Locate and classify Weyl points in the Brillouin zone.

Orchestrates the full Weyl-point search workflow:

  1. Calls find_min() to minimise the band gap over a coarse search grid and collect band-touching candidates.

  2. If symmetry is enabled (attr['symmetrize']), expands candidates to all symmetry-equivalent k-points via get_equiv_k().

  3. Optionally uses z2pack to compute the Chern number on a small sphere around each candidate; points with non-zero Chern number are confirmed as Weyl points. If z2pack is unavailable, chirality is recorded as '?'. The candidates are distributed over the MPI ranks, each of which builds its own tbmodels model from hamiltonian.dat.

  4. Writes a summary table to weyl_points.dat in attr['opath'].

Parameters:
  • data_controller (DataController) – Provides HRs, sym_rot, b_vectors, sym_TR, nelec, symmetrize, verbose, dftMAG, dftSO, alat, opath. The optional attribute weyl_screen_factor (default 2.0) tunes the box screening of screen_boxes(); set it to 0 to disable.

  • test_rad (float) – Radius (in fractional BZ units) of the z2pack Chern-number sphere. Currently unused: the radius is fixed at 0.005.

  • search_grid (list of int, length 3) – [nk1, nk2, nk3] number of cells to divide the BZ into for the initial coarse gap-minimisation search.

Returns:

  • None – Writes weyl_points.dat to attr['opath'] on rank 0.

  • Output files (written to opath)

  • ————————————

  • weyl_points.dat – Formatted table with columns: index, Cartesian k-coordinates in units of 2π/alat, Chern number, and energy.

PAOFLOW.topology.do_find_Weyl.find_min(HRpack, nawf, nelec, R, symf, verbose, search_grid=[8, 8, 8], screen_factor=2.0)[source]#

Find band-gap minima across the BZ using local optimisation.

Divides the first BZ into nk1 * nk2 * nk3 rectangular boxes and runs an L-BFGS-B minimisation of get_gap() inside each box, with the box centre as the initial guess. The BZ boxes are distributed across MPI ranks for parallelism; partial results are collected with gather_full().

Boxes are first screened with screen_boxes(), which samples the gap on a batched 9-point stencil and skips boxes that cannot reach zero; this removes the great majority of the optimiser calls.

On rank 0, candidates with a gap smaller than 1e-5 are retained. If symmetry is enabled (symf), they are further de-duplicated by sorting on energy and removing entries with identical energies (to 4 decimal places), leaving only symmetry-inequivalent Weyl points.

Parameters:
  • HRpack (ndarray, shape (nawf*nawf, nR), complex) – Packed Hamiltonian from pack_HR().

  • nawf (int) – Dimension of the Hamiltonian matrix.

  • nelec (int) – Number of occupied bands; gap is E[nelec] - E[nelec-1].

  • R (ndarray, shape (nR, 3)) – Real-space lattice vectors from get_R_grid_fft().

  • symf (bool) – If True, de-duplicate candidates using energy degeneracy.

  • verbose (bool) – Print intermediate candidate information to stdout.

  • search_grid (list of int, optional) – [nk1, nk2, nk3] subdivision of the BZ. Default [8, 8, 8].

  • screen_factor (float, optional) – Safety margin passed to screen_boxes(). Values <= 0 disable screening and optimise inside every box.

Returns:

  • candidates (ndarray, shape (nc, 3) or None on non-root ranks) – k-coordinates (fractional) of the band-touching candidates.

  • ene (ndarray, shape (nc,) or None on non-root ranks) – Energy at the LUMO band for each candidate.

PAOFLOW.topology.do_find_Weyl.get_equiv_k(kp, symop, sym_TR, mag_soc)[source]#

Expand a set of k-points to all symmetry-equivalent images.

Applies each space-group rotation symop[isym] (and optionally its time-reversal partner -k) to every k-point in kp, then de-duplicates the result to return only unique images within the first BZ (folded to [-0.5, 0.5)).

Time-reversal symmetry adds the set {-k} unless the system is a magnetic SOC calculation (mag_soc = dftMAG and dftSO).

Parameters:
  • kp (ndarray, shape (nc, 3)) – Input k-points in crystal (fractional) coordinates.

  • symop (ndarray, shape (nsym, 3, 3)) – Rotation matrices of the crystal point group.

  • sym_TR (ndarray of bool, shape (nsym,)) – True for operations that include time reversal (i.e. act as k' = -R k).

  • mag_soc (bool) – True when both dftMAG and dftSO are active; disables the automatic {-k} extension.

Returns:

newk_tot – All unique symmetry-equivalent k-points, rounded to 4 decimal places.

Return type:

ndarray, shape (nu, 3)