PAOFLOW.elphon.elph_bloch#
Shared Bloch / PAO-gauge vertex machinery for the electron-phonon PAO route.
Provides the geometry reader and the interpolation primitives used by
PAOFLOW.elphon.do_pao_eph to turn QE’s coarse-grid Cartesian coupling into
the dense-grid Eliashberg properties:
read_nscf()– k-points, eigenvalues, Fermi level and lattice from the QEdata-file-schema.xml;atom_masses()– per-species masses expanded to the atoms of the cell;kq_index_map()–k -> (index of k+q on the grid, umklapp G0);vertex_pao_R()– rotate the band-basis Cartesian coupling into the PAO gaugeA_{k+q}^T d A_k^*(A_{ni} = <phi_i|psi_n>) and Fourier-transform it to the electron real-space cellsg(R_e);lambda_q_dense_ws()– Wigner-Seitz interpolate the electrons (HRs) and the vertex to a dense grid and evaluate the Fermi-surface double delta ->lambda_{q nu}.
Attributes#
Functions#
|
Read k-points, eigenvalues, Fermi level and lattice from |
|
Centre of every PAO orbital in crystal coordinates. |
|
Expand per-species masses to one mass per atom. |
|
Map |
|
PAO-gauge vertex in real space |
|
Place a PAO-gauge vertex |
|
|
|
Dense-grid electron spectrum + Fermi-surface delta, shared by every q. |
|
Energies (Ry) and eigenvectors of the cached PAO Hamiltonian at arbitrary k-points. |
|
|
|
Vertex Wigner-Seitz phases |
|
Wigner-Seitz phases of the coupling vertex for a block of dense k-points. |
|
Free the MPI shared memory of |
|
Intraband (Drude) plasma-frequency tensor from the dense Fermi surface. |
|
Band-basis velocity matrix elements |
|
Wigner-Seitz weighted vertex cells, flattened for the dense-k matmul. |
|
Band- and mode-resolved coupling |
|
|
Module Contents#
- PAOFLOW.elphon.elph_bloch.read_nscf(save_dir, unfold=False)[source]#
Read k-points, eigenvalues, Fermi level and lattice from
data-file-schema.xml.- Parameters:
save_dir (str) – QE save directory.
unfold (bool, optional) – The nscf holds the irreducible wedge of a Gamma-centred automatic grid: return the k-points and eigenvalues of the full grid in
K_POINTS automaticorder (PAOFLOW.elphon.wavefunction_symmetry.WavefunctionProvider).
- Returns:
{'kpts_cart', 'kpts_cryst', 'eigs_ry', 'ef_ry', 'nbnd', 'nk', 'bg', 'at', 'alat', 'omega', 'fft'}.kpts_cartin 2*pi/alat,kpts_crystin reciprocal-lattice fractions, energies in Ry (referred to E_F),bgreciprocal vectors (rows, 2*pi/alat),atreal vectors (rows, alat).- Return type:
- PAOFLOW.elphon.elph_bloch.pao_orbital_positions(data_controller, at)[source]#
Centre of every PAO orbital in crystal coordinates.
- Parameters:
data_controller (DataController) – PAOFLOW data after
projections(arrays['basis']holds each orbital’s Cartesiantauin bohr,attributes['alat']the lattice parameter).at (ndarray, shape
(3, 3)) – Direct lattice vectors (rows, alat units), e.g.read_nscf(...)['at'].
- Returns:
Orbital centres, input of the orbital-pair Wigner-Seitz interpolation of
precompute_dense_electrons().- Return type:
ndarray, shape
(nawf, 3)
- PAOFLOW.elphon.elph_bloch.atom_masses(species_masses, species, atom_names)[source]#
Expand per-species masses to one mass per atom.
- Parameters:
species_masses (sequence of float) – Mass of each species (amu), in the order of
species(theATOMIC_SPECIESorder, as EPW’samass(i)).species (sequence of str) – Species names, e.g.
list(read_nscf(...)['species']).atom_names (sequence of str) – Species name of every atom in the cell, e.g.
read_nscf(...)['atom_names'].
- Returns:
Mass of each atom (amu), the
masses_amuexpected byeliashberg_from_qe_coupling()andeliashberg_dense_q().- Return type:
ndarray, shape
(nat,)- Raises:
ValueError – If the number of masses differs from the number of species, or an atom has an unknown species.
- PAOFLOW.elphon.elph_bloch.kq_index_map(kpts_cryst, q_cryst, nkgrid, tol=1e-05)[source]#
Map
k -> (index of k+q on the grid, umklapp G0).- Parameters:
- Returns:
ikq (ndarray
(nk,)int) – Index of the grid point equal tok + qmodulo a reciprocal vector.G0 (ndarray
(nk, 3)int) – The umklapp vectorG0 = (k + q) - k'in reciprocal-lattice units.
- PAOFLOW.elphon.elph_bloch.vertex_pao_R(d, A, ikq, kgrid_idx, ng, long_range=None)[source]#
PAO-gauge vertex in real space
g(R_e)for one q (EPW electron transform).Rotates the band-basis deformation potentials to the PAO gauge,
g^{PAO}_{ij,c}(k) = (A_{k+q}^T d_c(k) A_k^*)_{ij}, places them on the coarse k-grid and Fourier-transforms to the electron cellsR_e(fftn / N).lambda_q_dense_ws_fast()evaluates it back withexp(+2 pi i k.R), whereas the electron Hamiltonian follows PAOFLOW’sHks = fftn(HRs)(exp(-2 pi i k.R)), so both are taken at the same physical k.- Parameters:
d (ndarray
(nk, nbnd, nbnd, ncart)) – Band-basis Cartesian deformation potentialsd_{mn,c}(k) = <psi_{m,k+q}|dV/du_c|psi_{n,k}>(QE’sel_ph_mat/ahc_gkkon the coarse k-grid).A (ndarray
(nbnd, nawf, nk)) – PAO projectionsA_{n i}(k) = <phi_i|psi_{nk}>(arry['U'][..., ispin]), the convention of both the internal projector and QE’sprojwfc.x.ikq (ndarray
(nk,)) – Index ofk+qon the coarse grid.kgrid_idx (ndarray
(nk, 3)int) – Integer grid labelsround(k_cryst * ng) % ngof each k-point.long_range (ndarray
(nawf, nawf, ncart), optional) – Analytic long-range vertex of this q (LongRangeModel), subtracted from the PAO-gauge vertex at every k so that only the short-range part is Fourier-interpolated; the dense drivers add it back (band_vertex()).
- Returns:
The PAO-gauge vertex in the electron real-space cells.
- Return type:
ndarray
(nawf, nawf, ncart, n1, n2, n3)complex
Notes
With
A_{ni}(k) = \langle\phi_i|\psi_{nk}\ranglethe PAO vertex is the band-projected operator\[g^{PAO}_{ij,c}(k) = \sum_{mn} \langle\phi_i|\psi_{m,k+q}\rangle\, d_{mn,c}(k)\, \langle\psi_{nk}|\phi_j\rangle = \left(A_{k+q}^{T}\, d_c(k)\, A_k^{*}\right)_{ij},\]i.e. \(\langle\phi_i|P_{k+q}\, \partial V/\partial u_c\, P_k|\phi_j\rangle\). Each band index enters once as a bra and once as a ket, so the result does not depend on the band phases, provided
dandAare built from the same Kohn-Sham states. It is the operator that the band-basis contractionV_{k+q}^\dagger g V_k(PAO eigenvectors ofH = A E A^\dagger) maps back tod.
- PAOFLOW.elphon.elph_bloch.pao_vertex_to_cells(gk_b, kgrid_idx, ng)[source]#
Place a PAO-gauge vertex
g(k)on the coarse k-grid and transform it tog(R_e).- Parameters:
gk_b (ndarray
(nk, nawf, nawf, ncart)) –g^{PAO}_{ij,c}(k)of every coarse k-point.kgrid_idx (ndarray
(nk, 3)int) – Integer grid labels of the k-points (seevertex_pao_R()).
- Returns:
g(R_e) = N^-1 sum_k exp(-2 pi i k.R) g(k)(the tail ofvertex_pao_R()).- Return type:
ndarray
(nawf, nawf, ncart, n1, n2, n3)complex
- PAOFLOW.elphon.elph_bloch.lambda_q_dense_ws(gR, HRs, q_cryst, ng_coarse, at, zmass, freqs_thz, sigmas_ry, Nk, ispin=0, kblock=4096, nelec=None, spin_degeneracy=2.0)[source]#
lambda_{q nu}with a Wigner-Seitz (EPW-style) electron interpolation.spin_degeneracy(2 for scalar bands, 1 for spinors) sets the Fermi level ofnelecelectrons.Same as
lambda_q_dense()but the vertexgRand the PAO HamiltonianHRsare interpolated to the dense grid with explicit Wigner-Seitz real-space sums (proper zone-boundary degeneracy weights) instead of a plain zero-padding Fourier embed, andk+qis evaluated directly at(k+q)(no grid roll).- Parameters:
gR (ndarray
(nawf, nawf, ncart, n1, n2, n3)) – Vertex real-space cells; its grid may differ fromHRs(e.g. a coarse 6^3 coupling combined with a dense 18^3 electron Hamiltonian).HRs (ndarray
(nawf, nawf, m1, m2, m3, nspin))q_cryst (ndarray
(3,)) – q-point in crystal coordinates (exact, not restricted to the coarse grid).ng_coarse (ignored) – Kept for backward compatibility; the H and vertex grids are read from the array shapes so the two may differ.
at (ndarray
(3, 3)) – Real-lattice vectors (rows, alat units) for the WS construction.zmass (see
lambda_q_dense().)freqs_thz (see
lambda_q_dense().)sigmas_ry (see
lambda_q_dense().)Nk (see
lambda_q_dense().)
- Returns:
{'lambda_qnu', 'gamma_ghz', 'dos_ef', 'nk_dense'}.- Return type:
- PAOFLOW.elphon.elph_bloch.precompute_dense_electrons(HRs, at, Nk, sigmas_ry, nelec, ng_vertex, ispin=0, kblock=4096, fs_window=8.0, orbital_positions=None, velocities=False, alat=None, diagonal_velocities=False, keep_bands=None, comm=None, spin_degeneracy=2.0, adaptive_smearing=None)[source]#
Dense-grid electron spectrum + Fermi-surface delta, shared by every q.
spin_degeneracy(2 for scalar bands, 1 for spinors with spin-orbit coupling) sets the Fermi level ofnelecelectrons; it must match the degeneracy the caller uses for the density of states and the plasma frequency.Diagonalises
H(k)once on the regularNk^3grid (Wigner-Seitz interpolation ofHRs). Because the electronic spectrum is q-independent,E(k+q)/V(k+q)for any commensurate q are index shifts of this array, solambda_q_dense_ws_fast()needs no per-q re-diagonalisation (the dominant cost oflambda_q_dense_ws()when looping over many q). The Wigner-Seitz phase of the coupling gridng_vertexis cached too, so the per-q vertex interpolation reduces to a single BLAS matmul.- Parameters:
HRs (ndarray
(nawf, nawf, m1, m2, m3, nspin)) – PAO Hamiltonian (E_Fat 0).at (ndarray
(3, 3)) – Real-lattice vectors (rows, alat units) for the Wigner-Seitz sums.Nk (int) – Dense grid size.
sigmas_ry (array_like) – Fermi-surface smearing(s) (Ry).
nelec (float or None) – Valence electrons for the dense Fermi-level recompute (
None-> 0).ng_vertex (tuple(int, int, int)) – Real-space grid of the coupling vertex
gR(itsshape[3:6]).ispin (int, optional)
kblock (int, optional)
fs_window (float, optional) – Fermi-surface window in smearings for the shell mask (default 8, exact to
exp(-fs_window^2)); lower it to prune wide-band metals more aggressively.orbital_positions (ndarray
(nawf, 3), optional) – Orbital centres in crystal coordinates (pao_orbital_positions()). When given,Hand the vertex are interpolated with orbital-pair Wigner-Seitz images (_ws_lattice_pairs()), which keeps the dense bands and couplings symmetric in cells with several atoms;Noneuses the single-site images of_ws_lattice().velocities (bool, optional) – Also cache the real-space terms of the velocity operator so that
band_velocities()can evaluatev(k)in the gauge ofV(defaultFalse; the other keys are unchanged either way).alat (float, optional) – Lattice parameter (bohr); required with
velocities=True.diagonal_velocities (bool, optional) – With
velocities, also cache the band velocitiesvelocity_diag(nkd, nawf, 3)(Ry bohr, averaged over degenerate subspaces) for the plasma frequency and the transport coupling. These are the group velocities \(\partial_{\mathbf k}\varepsilon\); the non-local pseudopotential correction belongs to interband dipoles only.keep_bands (callable, optional) –
E (nkd, nawf) [Ry] -> band indices: store the eigenvectors (and the diagonal velocities) of these bands only,V(nkd, nawf, nband), to save memory on dense grids (energies are kept for all bands; the indices are stored as'bands').Nonekeeps all bands.comm (mpi4py communicator, optional) – With a communicator,
EandVlive in MPI shared memory, one copy per node, and the diagonalisation is split between the ranks of each node (identical results). Release them withrelease_dense_electrons()once every rank is done.Nonekeeps private arrays (serial use).adaptive_smearing (float, optional) – Adaptive Fermi-surface smearing (Yates et al.; 0.7 is the usual Gaussian prefactor): the delta of every state has the width
adaptive_smearing * |v_nk| * dkwithdkthe spacing of the dense grid (state_widths()), floored at the corresponding entry ofsigmas_ry; the Fermi level,dk,dosand the shell follow ('widths'(nsigma, nkd, nawf)is stored). Needsvelocities=True,diagonal_velocities=Trueand all bands kept.
- Returns:
Cache consumed by
lambda_q_dense_ws_fast()– keysNk,nawf,E(nkd, nawf)(Ry),V(nkd, nawf, nawf),dk(nsigma, nkd, nawf),dos(nsigma,), plus the vertex Wigner-Seitz images (Nintg,Midxg,Wg,ng_vertex; the phases of a block of k come fromvertex_phases()). Withvelocities=Trueit also holds'velocity', the input ofband_velocities().- Return type:
- PAOFLOW.elphon.elph_bloch.bloch_states_at(electrons, k_cryst)[source]#
Energies (Ry) and eigenvectors of the cached PAO Hamiltonian at arbitrary k-points.
- Parameters:
electrons (dict) – Output of
precompute_dense_electrons().k_cryst (ndarray
(nk, 3)) – Crystal coordinates (not restricted to the dense grid).
- Returns:
energies (ndarray
(nk, nawf)) – Same scale and convention aselectrons['E'].vectors (ndarray
(nk, nawf, nawf)) – Columns, in the gauge ofelectrons['V'](band_vertex()takes them).
- PAOFLOW.elphon.elph_bloch.group_velocities_at(electrons, k_cryst, at, alat, step=0.0001)[source]#
|v_nk|-ready group velocities (Ry bohr) at arbitrary k by central differences.- Parameters:
electrons (dict) – Output of
precompute_dense_electrons().k_cryst (ndarray
(nk, 3))at (ndarray
(3, 3)) – Lattice vectors (rows, alat units).alat (float) – Lattice parameter (bohr).
step (float, optional) – Finite-difference step (2 pi / alat units) along each Cartesian direction.
- Returns:
d e_n / d kof the energy-ordered bands (Ry bohr); at band crossings the sorted bands exchange character, which only matters for the ordering, not for the magnitudes used by the adaptive widths.- Return type:
ndarray
(nk, nawf, 3)
- PAOFLOW.elphon.elph_bloch.vertex_phases_at(electrons, k_cryst)[source]#
Vertex Wigner-Seitz phases
e^{2 pi i k.n}(nk, nws)at arbitrary k-points.
- PAOFLOW.elphon.elph_bloch.vertex_phases(electrons, k_indices)[source]#
Wigner-Seitz phases of the coupling vertex for a block of dense k-points.
- Parameters:
electrons (dict) – Output of
precompute_dense_electrons().k_indices (ndarray of int, shape
(nb,)) – Flat indices intoelectrons['K'].
- Returns:
\(e^{2\pi i\,\mathbf k\cdot\mathbf n}\) for the vertex cells
electrons['Nintg'](computed per block instead of stored for the whole grid, which would cost16 nkd nwsbytes per rank).- Return type:
ndarray, shape
(nb, nws), complex
- PAOFLOW.elphon.elph_bloch.release_dense_electrons(electrons)[source]#
Free the MPI shared memory of
precompute_dense_electrons()(commgiven).Collective over the communicator passed to
precompute_dense_electrons(); the arraysEandVmust not be used afterwards.- Parameters:
electrons (dict) – Output of
precompute_dense_electrons().
- PAOFLOW.elphon.elph_bloch.fermi_surface_plasma_frequency(electrons, cell_volume, isig=0, spin_degeneracy=2.0)[source]#
Intraband (Drude) plasma-frequency tensor from the dense Fermi surface.
- Parameters:
electrons (dict) – Cache of
precompute_dense_electrons()withvelocities=True.cell_volume (float) – Unit-cell volume (bohr^3).
isig (int, optional) – Smearing index of the Fermi-surface delta
electrons['dk'].spin_degeneracy (float, optional) – 2 without spin-orbit coupling, 1 with it.
- Returns:
\((\hbar\omega_p)^2_{\alpha\beta}\) in eV^2.
- Return type:
ndarray, shape
(3, 3)
Notes
\[\omega^2_{p,\alpha\beta} = \frac{4\pi e^2 g_s}{\Omega N_k} \sum_{n\mathbf k} v^\alpha_{n\mathbf k} v^\beta_{n\mathbf k}\, \delta(\varepsilon_{n\mathbf k} - \mu),\]with \(e^2 = 2\) in Rydberg units; for free electrons it reduces to \(4\pi n e^2/m\).
- PAOFLOW.elphon.elph_bloch.band_velocities(electrons, k_indices, bands=slice(None), position_dipoles=None)[source]#
Band-basis velocity matrix elements
<m k|v_alpha|n k>on the dense grid.Evaluates the PAO velocity operator at the dense k-points
K[k_indices]and rotates it with the cached eigenvectorsV, so the result shares the gauge of the band-basis coupling ofband_vertex()(required whenevergandvinterfere, as in phonon-assisted absorption).- Parameters:
electrons (dict) – Output of
precompute_dense_electrons()withvelocities=True.k_indices (ndarray, shape
(nb,), int) – Flat indices into the dense gridelectrons['K'].bands (ndarray of int or slice, optional) – Bands kept in the rotation (default all
nawf).position_dipoles (callable, optional) –
K_cryst (nb, 3) -> (nb, 3, nawf, nawf): the position dipoles \(\mathbf d(\mathbf k)\) of the PAO basis in bohr (position_dipole_operator()); adds the commutator \(i[H(\mathbf k), \mathbf d(\mathbf k)]\) in the orbital basis before the band rotation (see Notes).
- Returns:
v_{mn,alpha}(k)in Ry bohr (Rydberg atomic units,hbar = 1).- Return type:
ndarray, shape
(nb, 3, nband, nband), complex
Notes
In the lattice-periodic PAO Bloch basis of
H(k)the velocity operator \(i[H, \mathbf{r}]\), with the position operator diagonal on the orbital centres \(\boldsymbol{\tau}_i\), is\[\mathbf{v}_{ij}(\mathbf{k}) = \partial_{\mathbf{k}} H_{ij}(\mathbf{k}) + i\, H_{ij}(\mathbf{k})\, (\boldsymbol{\tau}_j - \boldsymbol{\tau}_i),\]the PAO analogue of EPW’s
vme = 'wannier'(and minus PAOFLOW’sdHkspofdo_gradient()). The band matrix is \(V_k^\dagger \mathbf{v}(\mathbf{k}) V_k\).With
position_dipolesthe off-diagonal position matrix of the orbitals is included as well, \(\mathbf{v} \mathrel{+}= i[H, \mathbf d(\mathbf k)]\), whose band-basis form \(i(\varepsilon_n - \varepsilon_m) d_{nm}\) is the analogue of EPW’s Berry-connection term; it vanishes on the diagonal and inside degenerate blocks by construction.Its diagonal is exactly the group velocity \(\partial_{\mathbf k}\varepsilon_{n\mathbf k}\) (Hellmann-Feynman), with the non-local pseudopotential already inside the PAO Hamiltonian; no separate \([V_{\rm NL}, \mathbf r]\) term is needed (one was carried until October 2026 and double counted it).
- PAOFLOW.elphon.elph_bloch.vertex_ws_coefficients(gR, electrons)[source]#
Wigner-Seitz weighted vertex cells, flattened for the dense-k matmul.
- Parameters:
gR (ndarray, shape
(nawf, nawf, ncart, n1, n2, n3), complex) – PAO-gauge vertex real-space cells for one q (grid ==ng_vertex).electrons (dict) – Output of
precompute_dense_electrons().
- Returns:
Coefficients
gnwithg(k) = vertex_phases(electrons, k) @ gn.- Return type:
ndarray, shape
(nws, nawf*nawf*ncart), complex
- PAOFLOW.elphon.elph_bloch.band_vertex(gn_flat, phkg, Vkq, Vk, zmass, long_range=None)[source]#
Band- and mode-resolved coupling
g_{mn,nu}(k, q)for a block of dense k.- Parameters:
gn_flat (ndarray, shape
(nws, nawf*nawf*ncart), complex) – Output ofvertex_ws_coefficients().phkg (ndarray, shape
(nb, nws), complex) – Vertex Wigner-Seitz phases of the block (vertex_phases()).Vkq (ndarray, shape
(nb, nawf, nband), complex) – Eigenvectors atk+q(rowsm) andk(columnsn); a band subset may be passed as column slices.Vk (ndarray, shape
(nb, nawf, nband), complex) – Eigenvectors atk+q(rowsm) andk(columnsn); a band subset may be passed as column slices.zmass (ndarray, shape
(nmode, ncart)) – Mass-scaled phonon eigenvectorsz / sqrt(M)(Rydberg mass units).long_range (ndarray, shape
(nawf, nawf, ncart), optional) – Analytic long-range vertex of this q in the PAO gauge (vertex_pao()), added back to the interpolated short-range part at every k of the block.
- Returns:
g_{mn,nu} = <m, k+q| dV_{q nu} |n, k>in Rydberg units, without the zero-point factor \(1/\sqrt{2\omega_{q\nu}}\).- Return type:
ndarray, shape
(nb, nmode, nband_kq, nband_k), complex
- PAOFLOW.elphon.elph_bloch.lambda_q_dense_ws_fast(gR, electrons, q_cryst, zmass, freqs_thz, kblock=4096, pair_coupling=None, pair_weights=None, pair_q_weight=None, transport=False, long_range=None)[source]#
lambda_{q nu}for one q, reusing aprecompute_dense_electrons()cache.Numerically identical to
lambda_q_dense_ws()(deterministiceigh), but the q-independent dense electron spectrum, Fermi level and Fermi-surface delta come fromelectrons; only the coupling vertex is interpolated per q, andk+qis an index shift (requiresNkcommensurate withq).- Parameters:
gR (ndarray
(nawf, nawf, ncart, n1, n2, n3)) – PAO-gauge vertex real-space cells for this q (grid ==ng_vertex).electrons (dict) – Output of
precompute_dense_electrons().q_cryst (ndarray
(3,)) – q-point (crystal coordinates);q * Nkmust be integer.zmass (ndarray
(nmode, ncart))freqs_thz (ndarray
(nmode,))kblock (int, optional)
pair_coupling (FermiSurfacePairCoupling, optional) – Also accumulate the state-resolved Fermi-surface coupling of the anisotropic Migdal-Eliashberg equations (
FermiSurfacePairCoupling). Its window is added to the Fermi-surface shell.pair_weights (ndarray
(nmode,), optional) – Mode weights passed topair_coupling(q-star multiplicity over the number of q, 0 for excluded modes); required withpair_coupling.pair_q_weight (float, optional) – q-star multiplicity over the number of q (Coulomb pairs); required with
pair_coupling.long_range (ndarray
(nawf, nawf, ncart), optional) – Long-range vertex of this q added at every k (band_vertex()).transport (bool, optional) – Also return the transport coupling
lambda_tr_qnu(needsprecompute_dense_electrons(..., velocities=True)): the same double delta weighted by \(\mathbf v_{n\mathbf k}\cdot(\mathbf v_{n\mathbf k} - \mathbf v_{m\mathbf k+\mathbf q})/\langle v^2\rangle_{FS}\) (Allen’s transport Eliashberg function, trace form).
- Returns:
{'lambda_qnu', 'gamma_ghz', 'dos_ef', 'nk_dense'}, plus'lambda_tr_qnu'withtransport.- Return type: