PAOFLOW.elphon.do_pao_eph#

Pseudo-atomic-orbital (Agapito-Bernardi) electron-phonon coupling driver.

This is the interpolation route of PAOFLOW.elphon: instead of reconstructing the DFPT perturbation from dvscf (bare local + nonlocal + induced), it reads Quantum ESPRESSO’s full coarse-grid coupling el_ph_mat – which already contains every contribution (including NLCC and ultrasoft augmentation) that ph.x computes – rotates it into the PAOFLOW pseudo-atomic-orbital (PAO) gauge, and Wigner-Seitz interpolates the electrons and the vertex to a dense grid to evaluate the isotropic Eliashberg properties.

Reference: L. A. Agapito and M. Bernardi, “Ab initio electron-phonon interactions using atomic orbital wave functions”, Phys. Rev. B 97, 235146 (2018).

The heavy lifting reuses the existing, validated primitives: vertex_pao_R() (PAO gauge + electron Fourier transform), lambda_q_dense_ws() (Wigner-Seitz dense interpolation + Fermi-surface double delta) and eliashberg_from_modes() (alpha^2F / lambda / Tc).

Functions#

vertex_from_qe_elphmat(elphmat_path, A, kpts_cryst, bg, ng)

PAO-gauge real-space vertex g(R_e) from one QE el_ph_mat dump.

vertex_from_qe_ahc(ahc_dir, iq, A, kpts_cryst, ...[, ...])

PAO-gauge real-space vertex g(R_e) from one unpatched QE AHC dump.

vertex_from_epw(epmatq_q, A, kpts_cryst, q_cryst, ng, ...)

PAO-gauge real-space vertex g(R_e) for one q from EPW's coarse coupling.

load_epw_coupling(epw_dir, nbnd, nk, nat, bg[, ...])

Load EPW's coarse Bloch coupling (epbwrite) with its band bookkeeping.

check_long_range_terms(zstar, epsi[, ...])

Refuse couplings whose long-range part the interpolation does not treat.

phonon_modes_from_force_constants(force_constants, ...)

Phonon frequencies and mass-weighted eigenvectors at one q.

eliashberg_from_qe_coupling(A, HRs, kpts_cryst, bg, ...)

Isotropic Eliashberg properties from QE's coarse el_ph_mat (PAO route).

Module Contents#

PAOFLOW.elphon.do_pao_eph.vertex_from_qe_elphmat(elphmat_path, A, kpts_cryst, bg, ng, long_range=None)[source]#

PAO-gauge real-space vertex g(R_e) from one QE el_ph_mat dump.

Parameters:
  • elphmat_path (str) – Path to elphmat.<iq>.dat (patched-QE dump).

  • A (ndarray (nbnd, nawf, nk)) – PAO projection matrices A_{ni}(k) = <phi_i|psi_nk> (arry['U'][..., ispin]), grabbed after projectability and before pao_hamiltonian.

  • kpts_cryst (ndarray (nk, 3)) – PAOFLOW coarse-grid k-points (crystal coordinates).

  • bg (ndarray (3, 3)) – Reciprocal-lattice vectors (rows), for the xq/xk -> crystal map.

  • ng (tuple(int, int, int)) – Coarse k-grid dimensions (== the pw.x SCF grid).

Returns:

  • gR (ndarray (nawf, nawf, ncart, n1, n2, n3))

  • q_cryst (ndarray (3,)) – The q-point of this dump in crystal coordinates.

PAOFLOW.elphon.do_pao_eph.vertex_from_qe_ahc(ahc_dir, iq, A, kpts_cryst, q_cryst, ng, nbnd, nmodes, nk, long_range=None)[source]#

PAO-gauge real-space vertex g(R_e) from one unpatched QE AHC dump.

Like vertex_from_qe_elphmat(), but reads the Cartesian ahc_gkk (read_qe_ahc_gkk()): no pattern rotation and no k-permutation – the AHC records are already in the nscf k-order, the same order as A and kpts_cryst for the same lead.save.

Parameters:
  • ahc_dir (str) – Directory with the ahc_gkk_iq<iq>.bin files.

  • iq (int) – 1-based q index (matches <prefix>.dyn<iq>).

  • A (ndarray (nbnd, nawf, nk)) – PAO projections A_{ni}(k) = <phi_i|psi_nk>.

  • kpts_cryst (ndarray (nk, 3)) – Coarse-grid k-points (crystal), nscf order.

  • q_cryst (ndarray (3,)) – q-point (crystal coordinates), from the .dyn file.

  • ng (tuple(int, int, int)) – Coarse k-grid dimensions.

  • nbnd (int) – AHC array dimensions.

  • nmodes (int) – AHC array dimensions.

  • nk (int) – AHC array dimensions.

Return type:

ndarray (nawf, nawf, ncart, n1, n2, n3)

PAOFLOW.elphon.do_pao_eph.vertex_from_epw(epmatq_q, A, kpts_cryst, q_cryst, ng, ibndkept, long_range=None)[source]#

PAO-gauge real-space vertex g(R_e) for one q from EPW’s coarse coupling.

Parameters:
  • epmatq_q (NDArray[np.complex128], shape (nbndep, nbndep, nk, 3 nat)) – One q slice of read_epw_epb() ['epmatq']: <psi_{m,k+q}| dV/du_c |psi_{n,k}> over the bands kept by EPW, Cartesian displacement basis, nscf k order.

  • A (NDArray[np.complex128], shape (nbnd, nawf, nk)) – PAO projections A_{ni}(k) = <phi_i|psi_nk> on the same nscf save that EPW read (all nbnd bands).

  • kpts_cryst (NDArray[np.float64], shape (nk, 3)) – Coarse k-points (crystal coordinates), nscf order.

  • q_cryst (NDArray[np.float64], shape (3,)) – The q-point of the slice (crystal coordinates).

  • ng (tuple of int) – Coarse k-grid dimensions.

  • ibndkept (NDArray[np.integer], shape (nbndep,)) – 0-based nscf index of each band kept by EPW (read_epw_ukk() ['ibndkept']).

  • long_range (NDArray[np.complex128], shape (nawf, nawf, 3 nat), optional) – Long-range vertex of this q to subtract in the PAO gauge (vertex_pao_R()).

Returns:

The PAO-gauge vertex in the electron real-space cells.

Return type:

NDArray[np.complex128], shape (nawf, nawf, 3 nat, n1, n2, n3)

Raises:

ValueError – If k + q does not fall on the coarse k-grid.

Notes

EPW evaluates both psi_{k+q} (the stored grid point k + q - G) and psi_k from the nscf wavefunctions, so the band phases match those of A and the rotation vertex_pao_R() is consistent for every q. The vertex is restricted to the kept bands, g = A_{k+q}[kept]^T d A_k[kept]^*.

PAOFLOW.elphon.do_pao_eph.load_epw_coupling(epw_dir, nbnd, nk, nat, bg, prefix=None, ukk_path=None)[source]#

Load EPW’s coarse Bloch coupling (epbwrite) with its band bookkeeping.

Parameters:
  • epw_dir (str) – EPW outdir holding prefix.epb1 ... prefix.epbN.

  • nbnd (int) – Number of bands of the nscf run (rows of the PAO projections A).

  • nk (int) – Number of coarse k-points.

  • nat (int) – Number of atoms.

  • bg (NDArray[np.float64], shape (3, 3)) – Reciprocal-lattice vectors (rows, 2 pi / alat).

  • prefix (str, optional) – Calculation prefix; inferred from the single *.epb1 file if omitted.

  • ukk_path (str, optional) – Path to prefix.ukk (default: epw_dir/prefix.ukk).

Returns:

epmatq (nbndep, nbndep, nk, 3 nat, nq), q_cryst (nq, 3), dynq (3 nat, 3 nat, nq), ibndkept (nbndep,), nq, and the Born charges zstar (nat, 3, 3) and dielectric tensor epsi (3, 3) (zero unless ph.x ran with epsil = .true.).

Return type:

dict

Raises:
PAOFLOW.elphon.do_pao_eph.check_long_range_terms(zstar, epsi, allow_missing_long_range=False, zstar_tol=0.1, long_range=None)[source]#

Refuse couplings whose long-range part the interpolation does not treat.

The PAO interpolation Fourier-interpolates the full coupling and force constants; it has no dipole (Frohlich) or quadrupole subtract-and-restore step (EPW lpolar). That is exact for metals, whose free carriers screen the long-range fields, but not for insulators and semiconductors.

Parameters:
  • zstar (NDArray[np.float64], shape (nat, 3, 3)) – Born effective charges (load_epw_coupling()).

  • epsi (NDArray[np.float64], shape (3, 3)) – High-frequency dielectric tensor; zero when ph.x did not compute it.

  • allow_missing_long_range (bool, optional) – Only warn instead of raising for polar materials (default False).

  • zstar_tol (float, optional) – Born charges below this magnitude are DFPT noise (default 0.1).

  • long_range (LongRangeModel, optional) – The analytic model that the drivers subtract and restore (LongRangeModel): with it a polar material is accepted, and only a non-polar insulator without quadrupoles still warns.

Raises:

NotImplementedError – For a polar material (max |Z*| > zstar_tol) unless allow_missing_long_range: the dipole term diverges as 1/|q| and cannot be Fourier-interpolated.

Warns:

UserWarning – For a non-polar insulator or semiconductor (epsi present, Z* = 0, e.g. Si): the dynamical-quadrupole term is not included.

Notes

See docs/internals/long-range-elphon-plan.md for the planned dipole and quadrupole treatment. Under MPI the warnings are issued by rank 0 only (every rank still raises).

PAOFLOW.elphon.do_pao_eph.phonon_modes_from_force_constants(force_constants, masses_ry)[source]#

Phonon frequencies and mass-weighted eigenvectors at one q.

Parameters:
  • force_constants (NDArray[np.complex128], shape (3 nat, 3 nat)) – Force-constant matrix C(q) (Ry/bohr^2, not divided by the masses).

  • masses_ry (NDArray[np.float64], shape (3 nat,)) – Mass of the atom of each Cartesian component (QE Rydberg units).

Returns:

  • freq_thz (NDArray[np.float64], shape (3 nat,)) – Signed frequencies (THz; negative for imaginary modes).

  • z (NDArray[np.complex128], shape (3 nat, 3 nat)) – Orthonormal eigenvectors of D = C / sqrt(M_a M_b), one per row (the convention of read_qe_dyn()).

PAOFLOW.elphon.do_pao_eph.eliashberg_from_qe_coupling(A, HRs, kpts_cryst, bg, at, coupling_dir, q_weights, ng, dyn_paths, elphmat_fmt='elphmat.%d.dat', source='elphmat', masses_amu=None, nk_dense=18, sigmas_ry=(0.02,), nelec=None, spin_degeneracy=2.0, mu_star=0.1, ispin=0, isig=0, sigma_w_frac=0.02, fs_window=8.0, comm=None, orbital_positions=None, allow_missing_long_range=False, save_dir=None, pseudo_dir=None, prefix=None, basis='auto')[source]#

Isotropic Eliashberg properties from QE’s coarse el_ph_mat (PAO route).

For every irreducible q the coupling dump is rotated into the PAO gauge, Wigner-Seitz interpolated to a dense grid and reduced to lambda_{q nu}; the modes are combined with their star weights and fed to the validated property engine. The q = Gamma acoustic modes (omega -> 0) are zeroed, matching QE.

Parameters:
  • A (ndarray (nbnd, nawf, nk)) – PAO projections A_{ni}(k) = <phi_i|psi_nk> (grab arry['U'][..., ispin] before pao_hamiltonian).

  • HRs (ndarray (nawf, nawf, m1, m2, m3, nspin)) – PAO Hamiltonian (E_F at 0), from pao_hamiltonian.

  • kpts_cryst (ndarray (nk, 3)) – Coarse-grid k-points (crystal coordinates), e.g. read_nscf output.

  • bg (ndarray (3, 3)) – Reciprocal- and real-lattice vectors (rows).

  • at (ndarray (3, 3)) – Reciprocal- and real-lattice vectors (rows).

  • coupling_dir (str) – Directory holding the coupling files (elphmat.<iq>.dat for source='elphmat', ahc_gkk_iq<iq>.bin for source='ahc', or EPW’s prefix.epb* and prefix.ukk for source='epw').

  • q_weights (array_like (nq,) or None) – Star sizes of the irreducible q-points (need not be normalised). For a full un-reduced q-grid (e.g. the 27-point AHC output) use all ones. For source='epw', None selects unit weights over EPW’s full grid.

  • ng (tuple(int, int, int)) – Coarse coupling k-grid (== SCF grid).

  • dyn_paths (sequence of str or None) – One QE *.dyn file per q (for frequencies/eigenvectors; also supplies the q-point for source='ahc'). Unused for source='epw', whose q-points and force constants come from the .epb files.

  • elphmat_fmt (str, optional) – Filename template for the patched dumps (%d is the 1-based q index).

  • source ({'elphmat', 'ahc', 'epw', 'dfpt'}, optional) – Coupling input: the patched el_ph_mat dump (any pseudo), the unpatched QE AHC ahc_gkk binaries (norm-conserving only), EPW’s coarse Bloch coupling (epbwrite; any pseudo), or the native vertex computed from the ph.x outputs in coupling_dir and the nscf wavefunctions of save_dir ('dfpt', norm-conserving; CoarseVertexSetup). Only 'epw' and 'dfpt' evaluate psi_{k+q} from the same nscf save as A; the other ph.x sources recompute it with arbitrary band phases, which breaks the k-interpolation for q != 0.

  • masses_amu (array_like (natom,), optional) – Atomic masses (amu); required to mass-weight the phonon eigenvectors.

  • nk_dense (int, optional) – Dense interpolation grid size.

  • sigmas_ry (array_like, optional) – Fermi-surface smearing(s) (Ry); isig selects which one is reported.

  • nelec (float, optional) – Valence electrons for the dense-grid Fermi-level recompute.

  • spin_degeneracy (float, optional) – 2 for scalar bands, 1 for spinors (spin-orbit coupling): sets the Fermi level of nelec electrons on the dense grid.

  • mu_star (float, optional) – Coulomb pseudopotential for Tc.

  • ispin (int, optional)

  • isig (int, optional)

  • sigma_w_frac (float, optional) – Gaussian width (fraction of max frequency) for the alpha^2F histogram.

  • fs_window (float, optional) – Fermi-surface window (in smearings) used to prune the dense-grid double delta: only k with a band within fs_window * sigma of E_F are kept. The default (8) is exact to exp(-fs_window^2); lower it (e.g. 4-5) to speed up metals with wide bands at a controlled tolerance.

  • comm (mpi4py communicator, optional) – MPI communicator used to distribute the per-q loop (each q is an independent unit of work reusing the shared dense-electron cache). Defaults to MPI.COMM_WORLD; run mpirun -np N python ... for an (up to) N-fold speedup, capped at nq ranks. The dense electron diagonalisation is computed redundantly on every rank (the cache is needed by all q and is too large to broadcast cheaply); only the per-q vertex interpolation is parallelised.

  • orbital_positions (ndarray (nawf, 3), optional) – PAO orbital centres in crystal coordinates (pao_orbital_positions()). When given, the electrons and the vertex are interpolated with orbital-pair Wigner-Seitz images, required for symmetric interpolation in cells with several atoms; None keeps the single-site images.

  • allow_missing_long_range (bool, optional) – For source='epw' and 'dfpt', run a polar material without the long-range dipole term instead of raising (check_long_range_terms()).

  • save_dir – source='dfpt' options (see prepare_dense_vertex()).

  • pseudo_dir – source='dfpt' options (see prepare_dense_vertex()).

  • prefix – source='dfpt' options (see prepare_dense_vertex()).

  • basis – source='dfpt' options (see prepare_dense_vertex()).

Returns:

The eliashberg_from_modes() result, with the extra keys 'lambda_qv', 'omega_qv_thz' (both (nq, nmode)) and 'dos_ef' ((nq,), states/spin/Ry per q).

Return type:

dict