PAOFLOW.elphon.dfpt_io#

Readers for the ph.x outputs that feed the native coarse electron-phonon vertex.

The DFPT coupling source of PAOFLOW.elphon.dfpt_vertex needs, per irreducible q: the induced self-consistent potential dvscf (one record per displacement pattern on the dense FFT grid), the displacement patterns u (patterns.N.xml) and the dynamical matrix (dyn file). Two directory layouts are recognised:

  • the pp.py collection of EPW: <dir>/<prefix>.dvscf_qN, <prefix>.dyn_qN and <prefix>.phsave/patterns.N.xml;

  • the raw ph.x run: <dir>/_ph0/<prefix>.dvscf1 (first q), _ph0/<prefix>.q_N/<prefix>.dvscf1, _ph0/<prefix>.phsave/patterns.N.xml and <dir>/<prefix>.dynN (fildyn written in the run directory).

The crystal space group and the plane-wave setup come from the nscf data-file-schema.xml.

Attributes#

Classes#

DFPTFiles

Paths of the ph.x outputs of one q-grid run.

SpaceGroup

Crystal space-group operations of the scf/nscf run, in QE's conventions.

Functions#

locate_dfpt_files(dfpt_dir[, prefix])

Find the dvscf, pattern and dynamical-matrix files of a ph.x q-grid run.

read_patterns(path)

Displacement patterns of one irreducible q (patterns.N.xml of ph.x).

read_dvscf(path, fft_grid, nmodes[, nspin_mag])

Induced self-consistent potential of ph.x (fildvscf), all patterns of one q.

read_irreducible_q(files, bg)

Irreducible q-points of the ph.x run (crystal coordinates), from the dyn files.

read_long_range_tensors(files)

Dielectric tensor and Born effective charges stored with the Gamma dynamical matrix.

read_space_group(save_dir[, check])

Crystal symmetries from data-file-schema.xml (the crystal_symmetry entries).

read_nscf_plane_wave_setup(save_dir)

Plane-wave and spin setup of the nscf run (data-file-schema.xml).

Module Contents#

PAOFLOW.elphon.dfpt_io.HARTREE_TO_RY = 2.0[source]#
class PAOFLOW.elphon.dfpt_io.DFPTFiles[source]#

Paths of the ph.x outputs of one q-grid run.

Variables:
  • prefix (str) – prefix of the QE run.

  • layout ({'pp', 'ph'}) – pp.py collection or raw ph.x run directory.

  • dvscf (tuple of str) – dvscf file of every irreducible q (ph.x order).

  • patterns (tuple of str) – patterns.N.xml of every irreducible q.

  • dyn (tuple of str) – Dynamical-matrix file of every irreducible q.

  • dyn0 (str or None) – <prefix>.dyn0 (q-grid header) when present.

prefix: str[source]#
layout: str[source]#
dvscf: tuple[str, ...][source]#
patterns: tuple[str, ...][source]#
dyn: tuple[str, ...][source]#
dyn0: str | None[source]#
property nq_irr: int[source]#

Number of irreducible q-points.

PAOFLOW.elphon.dfpt_io.locate_dfpt_files(dfpt_dir, prefix=None)[source]#

Find the dvscf, pattern and dynamical-matrix files of a ph.x q-grid run.

Parameters:
  • dfpt_dir (str) – pp.py save/ directory or the ph.x run directory (holding _ph0/).

  • prefix (str, optional) – QE prefix; inferred from the dvscf file names when omitted.

Returns:

The files of every irreducible q in ph.x order.

Return type:

DFPTFiles

Raises:

FileNotFoundError – When neither layout is found or a q is incomplete.

PAOFLOW.elphon.dfpt_io.read_patterns(path)[source]#

Displacement patterns of one irreducible q (patterns.N.xml of ph.x).

Parameters:

path (str) – The patterns.N.xml file.

Returns:

u (3 nat, 3 nat) complex, column nu = pattern nu in the global mode order (Cartesian index 3 kappa + alpha along the rows); npert (perturbations per irreducible representation); nirr; minus_q (MINUS_Q_SYM); nat.

Return type:

dict

Notes

The dvscf record nu is the response to the pattern u[:, nu]; the Cartesian responses follow from dV_c = sum_nu conj(u[c, nu]) dV_nu (u unitary).

PAOFLOW.elphon.dfpt_io.read_dvscf(path, fft_grid, nmodes, nspin_mag=1)[source]#

Induced self-consistent potential of ph.x (fildvscf), all patterns of one q.

Parameters:
  • path (str) – <prefix>.dvscf_qN (pp.py) or _ph0/.../<prefix>.dvscf1 (ph.x).

  • fft_grid (tuple of int) – Dense FFT grid (nr1, nr2, nr3) of the scf run.

  • nmodes (int) – 3 nat.

  • nspin_mag (int, optional) – Spin components of the potential (1 for non-magnetic runs).

Returns:

Lattice-periodic part of the Hartree + exchange-correlation response (Ry) to the displacement pattern u[:, nu] with modulation exp(i q . R); the bare ionic term is not included. Index [.., i, j, k] is the grid point i/nr1, j/nr2, k/nr3.

Return type:

ndarray, shape (nmodes, nspin_mag, nr1, nr2, nr3), complex

Raises:

ValueError – When the file size is not nmodes records of nr1 nr2 nr3 nspin_mag complex numbers.

PAOFLOW.elphon.dfpt_io.read_irreducible_q(files, bg)[source]#

Irreducible q-points of the ph.x run (crystal coordinates), from the dyn files.

Parameters:
Returns:

The first q of every dyn file (the irreducible representative; the star follows it).

Return type:

ndarray, shape (nq_irr, 3)

PAOFLOW.elphon.dfpt_io.read_long_range_tensors(files)[source]#

Dielectric tensor and Born effective charges stored with the Gamma dynamical matrix.

Parameters:

files (DFPTFiles) – From locate_dfpt_files().

Returns:

  • epsilon (ndarray (3, 3) or None)

  • born_charges (ndarray (nat, 3, 3) or None) – None when ph.x ran without epsil.

class PAOFLOW.elphon.dfpt_io.SpaceGroup[source]#

Crystal space-group operations of the scf/nscf run, in QE’s conventions.

Variables:
  • rotations (ndarray, shape (nsym, 3, 3), int) – Rotation R acting on crystal coordinates of positions: the operation maps x -> R x - t (QE stores the fractional translation with this sign).

  • translations (ndarray, shape (nsym, 3)) – Fractional translations t (crystal coordinates).

  • equivalent_atoms (ndarray, shape (nsym, nat), int) – equivalent_atoms[isym, kappa] is the atom onto which kappa is mapped (QE irt, 0-based).

  • time_reversal (ndarray, shape (nsym,), bool) – Operations combined with time reversal (magnetic runs only).

  • names (tuple of str) – QE’s symmetry labels.

rotations: numpy.typing.NDArray[numpy.int_][source]#
translations: numpy.typing.NDArray[numpy.float64][source]#
equivalent_atoms: numpy.typing.NDArray[numpy.int_][source]#
time_reversal: numpy.typing.NDArray[numpy.bool_][source]#
names: tuple[str, ...][source]#
property nsym: int[source]#

Number of operations.

PAOFLOW.elphon.dfpt_io.read_space_group(save_dir, check=True)[source]#

Crystal symmetries from data-file-schema.xml (the crystal_symmetry entries).

Parameters:
  • save_dir (str) – QE outdir/prefix.save directory.

  • check (bool, optional) – Verify every operation against the atomic positions (R x_kappa - t equals the position of equivalent_atoms[isym, kappa] modulo lattice vectors).

Return type:

SpaceGroup

Raises:

ValueError – If an operation does not map the atoms as declared (convention mismatch).

PAOFLOW.elphon.dfpt_io.read_nscf_plane_wave_setup(save_dir)[source]#

Plane-wave and spin setup of the nscf run (data-file-schema.xml).

Parameters:

save_dir (str) – QE outdir/prefix.save directory.

Returns:

ecutwfc_ry, ecutrho_ry, fft_grid and fft_smooth (dense and smooth grids), nspin, lsda, noncolin, spinorbit, npol, nbnd, nelec, alat (bohr), at and bg (rows, alat and 2 pi/alat), omega (bohr^3), tau_alat (nat, 3), atom_species (species name of every atom), pseudo_files (species -> UPF file name), species_order.

Return type:

dict