PAOFLOW.gen.epw_inputs#

Input generation for the EPW coupling source of the PAO electron-phonon route.

epw.x with epbwrite = .true. writes the coarse Bloch-basis coupling (PAOFLOW.elphon.qe_elph_io.read_epw_epb()) computed from the nscf wavefunctions, i.e. in the same band gauge as PAOFLOW’s projections on that save. This module writes what such a run needs beyond the usual QE inputs:

  • the explicit full k-point list of the nscf run (EPW requires the complete uniform grid with crystal coordinates in [0, 1));

  • a placeholder prefix.ukk, so that EPW can run with wannierize = .false. when no Wannier functions are wanted (only the .epb files are used);

  • a minimal epw.in;

  • the pw.x scf / nscf and ph.x inputs of the two run directories (qe/phonon/ and qe/nscf/, as in examples/elphon/<System>), derived from a pw.x input of the system.

Functions#

uniform_kpoint_list(nk)

Full Gamma-centred k-grid in crystal coordinates, as EPW expects it.

kpoints_card(nk)

K_POINTS crystal card with the full grid for the nscf run.

parse_exclude_bands(spec)

Parse an EPW/wannier90 band list such as '1:5, 8' (or '1-5 8').

exclude_bands_string(exclude_bands)

EPW bands_skipped value for a list of 1-based band indices.

write_placeholder_ukk(path, nbnd, nk_total[, nbndsub, ...])

Write a prefix.ukk that lets EPW run without a Wannierization.

epw_input(prefix, masses_amu, nk, nq, nbndsub[, ...])

Minimal epw.in that writes the coarse Bloch coupling (epbwrite).

edit_pw_input(text[, values, remove, kpoints])

Set, add or remove namelist variables of a pw.x input.

species_masses(text)

Atomic masses (amu) of the ATOMIC_SPECIES card of a pw.x input.

scf_input(template, prefix[, pseudo_dir])

pw.x scf of the phonon/ run directory, from a pw.x input.

nscf_input(template, prefix, nk, nbnd[, pseudo_dir, ...])

pw.x nscf of the coarse-grid run directory: the full grid as an explicit list.

automatic_kpoints_card(nk)

K_POINTS automatic card of a Gamma-centred grid (the irreducible wedge).

hubbard_nscf_input(template, prefix, nk, nbnd[, ...])

pw.x nscf on the EPW k list for a DFT+U(+V) run (the HUBBARD card kept).

optics_nscf_input(template, prefix, nk, nbnd[, pseudo_dir])

pw.x nscf of the optics (dielectric_tensor) run: automatic grid, many bands.

ph_input(prefix, nq[, title, epsil, tr2_ph])

ph.x DFPT input on the coarse q-grid (irreducible q, fildvscf for the coupling).

Module Contents#

PAOFLOW.gen.epw_inputs.uniform_kpoint_list(nk)[source]#

Full Gamma-centred k-grid in crystal coordinates, as EPW expects it.

Parameters:

nk (tuple of int) – Grid dimensions (nk1, nk2, nk3).

Returns:

Columns k1, k2, k3 (crystal coordinates in [0, 1)) and the weight 1 / N. The third index runs fastest, the order of K_POINTS automatic that PAOFLOW’s Fourier transforms assume (PAOFLOW.inputs.read_QE_xml.uniform_grid_from_kpoints()).

Return type:

NDArray[np.float64], shape (nk1 * nk2 * nk3, 4)

PAOFLOW.gen.epw_inputs.kpoints_card(nk)[source]#

K_POINTS crystal card with the full grid for the nscf run.

Parameters:

nk (tuple of int) – Grid dimensions (nk1, nk2, nk3).

Returns:

The card, ready to append to a pw.x nscf input.

Return type:

str

PAOFLOW.gen.epw_inputs.parse_exclude_bands(spec)[source]#

Parse an EPW/wannier90 band list such as '1:5, 8' (or '1-5 8').

Parameters:

spec (str) – Comma- or space-separated 1-based band indices and first:last (or first-last) ranges; an optional exclude_bands = prefix is ignored.

Returns:

Sorted, unique 1-based band indices (empty for a blank string).

Return type:

list of int

Raises:

ValueError – If an entry is not an integer or a valid range.

PAOFLOW.gen.epw_inputs.exclude_bands_string(exclude_bands)[source]#

EPW bands_skipped value for a list of 1-based band indices.

Parameters:

exclude_bands (list of int) – 1-based band indices to exclude.

Returns:

e.g. 'exclude_bands = 1:5, 8', with consecutive bands joined into first:last ranges as in the EPW and wannier90 documentation.

Return type:

str

PAOFLOW.gen.epw_inputs.write_placeholder_ukk(path, nbnd, nk_total, nbndsub=None, exclude_bands=None, nelec=None, noncolin=False, wannier90_stubs=True)[source]#

Write a prefix.ukk that lets EPW run without a Wannierization.

Parameters:
  • path (str) – Output file, prefix.ukk in the directory where epw.x is run.

  • nbnd (int) – Number of nscf bands.

  • nk_total (int) – Number of k-points of the nscf grid.

  • nbndsub (int, optional) – Number of “Wannier functions” declared to EPW (nbndsub in epw.in). Defaults to the number of kept bands; must not exceed it nor EPW’s limit of 200.

  • exclude_bands (list of int, optional) – 1-based indices of bands excluded from the electron-phonon calculation (e.g. semicore states). With wannierize = .false. EPW reads the exclusion from this file only; bands_skipped in epw.in is used solely to write wannier90’s .win.

  • nelec (float, optional) – Number of valence electrons; required with exclude_bands to count the occupied excluded bands (EPW’s nbndskip).

  • noncolin (bool, optional) – Noncollinear calculation (one electron per band in nbndskip).

  • wannier90_stubs (bool, optional) – Also write empty wannier90 overlap files prefix.bvec (no b-vectors) and prefix.mmn next to path (default True). EPW’s Wannier stage reads them unconditionally (vmebloch2wan); with zero b-vectors it completes, with zero position matrix elements, instead of stopping after the .epb files are written.

Returns:

Writes path in the list-directed format of EPW’s write_filukk: kept-band list, identity rotations, every kept band inside the outer window (so EPW does not pack bands in the .epb files), the excluded-band flags and zero centres; plus the two stub files when wannier90_stubs is true.

Return type:

None

Raises:

ValueError – If nbndsub is out of range, a band index is invalid, or nelec is missing while bands are excluded.

Notes

nbndskip follows EPW’s setup_nnkp: the number of excluded bands with index <= nelec / 2 (<= nelec if noncollinear). The rotations only enter EPW’s Wannier stage, which runs after the .epb files are written and whose output PAOFLOW does not use.

PAOFLOW.gen.epw_inputs.epw_input(prefix, masses_amu, nk, nq, nbndsub, dvscf_dir='./save', outdir='./', wannierize=False, exclude_bands=None)[source]#

Minimal epw.in that writes the coarse Bloch coupling (epbwrite).

Parameters:
  • prefix (str) – Calculation prefix (same as the QE runs).

  • masses_amu (list of float) – Atomic mass of each species (amu), in species order.

  • nk (tuple of int) – Coarse k-grid (the nscf grid) and coarse q-grid (the ph.x grid); nq must divide nk in each direction.

  • nq (tuple of int) – Coarse k-grid (the nscf grid) and coarse q-grid (the ph.x grid); nq must divide nk in each direction.

  • nbndsub (int) – Number of Wannier functions; with wannierize=False use the value given to write_placeholder_ukk().

  • dvscf_dir (str, optional) – Directory prepared by EPW’s pp.py (dvscf, patterns, dyn files).

  • outdir (str, optional) – QE outdir of the nscf run.

  • wannierize (bool, optional) – Run wannier90 inside EPW (requires the usual proj/window inputs, to be added by hand). Default False uses the .ukk file.

  • exclude_bands (list of int, optional) – 1-based bands to exclude, written as bands_skipped. With wannierize=False EPW takes the exclusion from the .ukk file (write_placeholder_ukk() with the same list); the line is kept so that the input documents, and with wannierize=True applies, the same choice.

Returns:

The &inputepw namelist.

Return type:

str

Raises:

ValueError – If the q-grid is not commensurate with the k-grid.

PAOFLOW.gen.epw_inputs.edit_pw_input(text, values=None, remove=(), kpoints=None)[source]#

Set, add or remove namelist variables of a pw.x input.

Parameters:
  • text (str) – The pw.x input.

  • values (dict, optional) – {namelist: {variable: value}} with values already in Fortran syntax (e.g. "'nscf'", '16'). An existing assignment is replaced in place; a missing one is appended to its namelist.

  • remove (tuple of str, optional) – Variables to delete from every namelist.

  • kpoints (str, optional) – Replacement K_POINTS card (header and data).

Returns:

The edited input.

Return type:

str

PAOFLOW.gen.epw_inputs.species_masses(text)[source]#

Atomic masses (amu) of the ATOMIC_SPECIES card of a pw.x input.

Parameters:

text (str) – The pw.x input.

Returns:

One mass per species, in card order (empty if the card is missing).

Return type:

list of float

PAOFLOW.gen.epw_inputs.scf_input(template, prefix, pseudo_dir=None)[source]#

pw.x scf of the phonon/ run directory, from a pw.x input.

Parameters:
  • template (str) – A pw.x input of the system (structure, cutoffs, smearing, k-grid).

  • prefix (str) – Calculation prefix.

  • pseudo_dir (str, optional) – pseudo_dir for the run directory (unchanged if None).

Returns:

The input with calculation = 'scf', outdir = './' and the symmetry switches removed (ph.x works on the irreducible q only).

Return type:

str

PAOFLOW.gen.epw_inputs.nscf_input(template, prefix, nk, nbnd, pseudo_dir=None, explicit=True)[source]#

pw.x nscf of the coarse-grid run directory: the full grid as an explicit list.

Parameters:
  • template (str) – A pw.x input of the system (usually the scf one).

  • prefix (str) – Calculation prefix.

  • nk (tuple of int) – Coarse k-grid (EPW nk1..3), written by kpoints_card().

  • nbnd (int) – Number of bands.

  • pseudo_dir (str, optional) – pseudo_dir for the run directory (unchanged if None).

  • explicit (bool, optional) – The full grid as an explicit K_POINTS crystal list (EPW needs it); False writes K_POINTS automatic (the irreducible wedge, which PAOFLOW’s native coupling unfolds by symmetry).

Returns:

The nscf input (verbosity = 'high', no forces or stress).

Return type:

str

PAOFLOW.gen.epw_inputs.automatic_kpoints_card(nk)[source]#

K_POINTS automatic card of a Gamma-centred grid (the irreducible wedge).

Parameters:

nk (tuple of int) – Grid dimensions.

Returns:

The card.

Return type:

str

PAOFLOW.gen.epw_inputs.hubbard_nscf_input(template, prefix, nk, nbnd, pseudo_dir=None)[source]#

pw.x nscf on the EPW k list for a DFT+U(+V) run (the HUBBARD card kept).

Parameters:
Returns:

The nscf input: the same structure and Hubbard card, the full k-grid as an explicit list. The run directory must hold the save of the Hubbard scf (charge density, data-file-schema.xml and occup.txt).

Return type:

str

Raises:

ValueError – If the template has no HUBBARD card.

PAOFLOW.gen.epw_inputs.optics_nscf_input(template, prefix, nk, nbnd, pseudo_dir=None)[source]#

pw.x nscf of the optics (dielectric_tensor) run: automatic grid, many bands.

Parameters:
  • template (str) – A pw.x input of the system (cards other than K_POINTS, including a HUBBARD card, are kept).

  • prefix (str) – Calculation prefix.

  • nk (tuple of int) – Monkhorst-Pack grid (K_POINTS automatic, no shift).

  • nbnd (int) – Number of bands (more than the orbitals of the extended PAO basis).

  • pseudo_dir (str, optional) – pseudo_dir for the run directory (unchanged if None).

Returns:

The nscf input.

Return type:

str

PAOFLOW.gen.epw_inputs.ph_input(prefix, nq, title=None, epsil=False, tr2_ph=1e-14)[source]#

ph.x DFPT input on the coarse q-grid (irreducible q, fildvscf for the coupling).

Parameters:
  • prefix (str) – Calculation prefix.

  • nq (tuple of int) – Coarse q-grid (EPW nq1..3).

  • title (str, optional) – Title line (defaults to prefix).

  • epsil (bool, optional) – Dielectric tensor and Born effective charges at Gamma (insulators and semiconductors: the long-range dipole model and the quadrupoles need them; ph.x refuses it for metals).

  • tr2_ph (float, optional) – Self-consistency threshold.

Returns:

The &INPUTPH input, run in the scf directory.

Return type:

str