PAOFLOW.phonon.qe_force_constants#

Interatomic force constants and phonon interpolation from QE dynamical matrices.

The PAOFLOW counterpart of Quantum ESPRESSO’s q2r.x + matdyn.x, working directly on the <prefix>.dyn0 … <prefix>.dynN files written by ph.x (ldisp = .true.):

The same interpolator serves the dense-q electron-phonon routes of PAOFLOW.elphon.do_pao_eph_dense_q. Polar materials get the dipole (LO-TO) term of LongRangeModel: as q2r.x with zasr it is subtracted from the coarse dynamical matrices before the transform to real space (and the Born charges and dielectric tensor are written to the flfrc file), and as matdyn.x it is added back at every q, including the direction-dependent limit at Gamma along a path.

Units: force constants in Ry/bohr^2, masses in QE Rydberg units (amu * 911.444), lattice vectors in alat, q in crystal coordinates unless stated, frequencies in THz (or cm^-1 in the writers).

Attributes#

Functions#

read_dynamical_matrix_file(path)

Parse one QE *.dyn file: crystal header and the matrices of its q-star.

read_dynamical_matrices(prefix[, directory])

All dynamical matrices of a ph.x q-grid run, placed on the full grid.

is_polar(born_charges[, tolerance])

Whether Born effective charges are physically non-zero.

real_space_force_constants(force_constants_q)

Real-space force constants of the q-grid supercell (q2r.x).

apply_acoustic_sum_rule(force_constants_r, nat)

Impose the simple acoustic sum rule on real-space force constants (asr = 'simple').

write_qe_force_constants(path, dynamical_matrices, ...)

Write the real-space force constants in QE's flfrc format (q2r.x output).

phonon_interpolator(force_constants_r, masses_ry, ...)

Wigner-Seitz interpolator of the dynamical matrix (matdyn.x).

gamma_limit_points(q_cryst, bg[, step])

Replace exact Gamma points of a path by the limit along the path (matdyn.x).

high_symmetry_path(ibrav, alat, at)

High-symmetry q-path of a Bravais lattice (PAOFLOW's band path).

phonon_dispersion(phonon_at_q, bg, segments[, labels, ...])

Phonon frequencies along a q-path.

phonon_density_of_states(phonon_at_q[, mesh, ...])

Phonon density of states on a Gamma-centred q-mesh (Gaussian broadening).

write_phonon_band_files(outdir, fname, dispersion[, units])

Write <fname>_band.dat and <fname>_band.labels (format of the phonopy route).

write_phonon_dos_file(outdir, fname, dos[, units])

Write <fname>_dos.dat (frequency and total DOS, format of the phonopy route).

q2r_matdyn(prefix[, directory, outdir, fname, ...])

q2r.x + matdyn.x: dispersion and DOS from the ph.x dynamical matrices.

Module Contents#

PAOFLOW.phonon.qe_force_constants.AMU_RY = 911.4442421[source]#
PAOFLOW.phonon.qe_force_constants.RY_TO_THZ = 3289.842[source]#
PAOFLOW.phonon.qe_force_constants.THZ_TO_CM1 = 33.35641[source]#
PAOFLOW.phonon.qe_force_constants.PHONON_WS_SIGN = 1[source]#
PAOFLOW.phonon.qe_force_constants.read_dynamical_matrix_file(path)[source]#

Parse one QE *.dyn file: crystal header and the matrices of its q-star.

Parameters:

path (str) – A <prefix>.dynN file of ph.x.

Returns:

ntyp, nat, ibrav, celldm (6,), at (3, 3) (rows, alat; None unless ibrav = 0), species_names, species_masses_ry (ntyp,), atom_types (nat,) (0-based), masses_ry (nat,), tau_cart (nat, 3) (alat), q_cart (list of (3,), units of 2 pi / alat), force_constants (list of (3 nat, 3 nat) complex, Ry/bohr^2, index 3 na + alpha) epsilon (3, 3) and born_charges (nat, 3, 3) (rows: field direction, as the Effective Charges E-U block) or None when the file has no dielectric block.

Return type:

dict

PAOFLOW.phonon.qe_force_constants.read_dynamical_matrices(prefix, directory='.')[source]#

All dynamical matrices of a ph.x q-grid run, placed on the full grid.

Parameters:
  • prefix (str) – fildyn of ph.x (the files are <prefix>.dyn0 … <prefix>.dynN).

  • directory (str, optional) – Directory of the files.

Returns:

The header of read_dynamical_matrix_file() plus qgrid, alat (bohr), at and bg (rows; alat and 2 pi / alat units), tau_cryst (nat, 3), dyn_paths and force_constants_q (nq1, nq2, nq3, 3 nat, 3 nat), epsilon, born_charges and polar (is_polar()).

Return type:

dict

Raises:

ValueError – If the q-stars of the files do not cover the full grid.

Notes

<prefix>.dyn0 lists the grid and the irreducible q-points; each <prefix>.dynN holds the whole star of its irreducible q, so the files cover the full grid, as q2r.x requires.

PAOFLOW.phonon.qe_force_constants.is_polar(born_charges, tolerance=0.05)[source]#

Whether Born effective charges are physically non-zero.

Parameters:
  • born_charges (ndarray, shape (nat, 3, 3), or None) – Born effective charges (units of e).

  • tolerance (float, optional) – Largest element regarded as numerical noise, after the charge-neutrality sum rule.

Returns:

True when, after imposing \(\sum_a Z^*_a = 0\) (zasr = 'simple'), an element exceeds tolerance.

Return type:

bool

PAOFLOW.phonon.qe_force_constants.real_space_force_constants(force_constants_q)[source]#

Real-space force constants of the q-grid supercell (q2r.x).

Parameters:

force_constants_q (ndarray, shape (nq1, nq2, nq3, 3 nat, 3 nat)) – Dynamical matrices C(q) (not mass-weighted) on the full q-grid.

Returns:

\(C(\mathbf n)\), indexed by the supercell cell n.

Return type:

ndarray, shape (nq1, nq2, nq3, 3 nat, 3 nat), complex

Notes

\[C(\mathbf n) = \frac{1}{N_q}\sum_{\mathbf q} C(\mathbf q)\, e^{-2\pi i\,\mathbf q\cdot\mathbf n}, \qquad C(\mathbf q) = \sum_{\mathbf n} C(\mathbf n)\, e^{2\pi i\,\mathbf q\cdot\mathbf n},\]

with q in crystal coordinates; the cell n is QE’s -R (write_qe_force_constants()).

PAOFLOW.phonon.qe_force_constants.apply_acoustic_sum_rule(force_constants_r, nat)[source]#

Impose the simple acoustic sum rule on real-space force constants (asr = 'simple').

Parameters:
Returns:

A corrected copy.

Return type:

ndarray

Notes

\(C_{\alpha\beta}(\mathbf 0; a, a) \mathrel{-}= \sum_{\mathbf n, b} C_{\alpha\beta}(\mathbf n; a, b)\): a rigid translation costs no energy, so the acoustic frequencies vanish at Gamma.

PAOFLOW.phonon.qe_force_constants.write_qe_force_constants(path, dynamical_matrices, force_constants_r, long_range=None)[source]#

Write the real-space force constants in QE’s flfrc format (q2r.x output).

Parameters:
  • path (str) – Output file (e.g. Si2.fc).

  • dynamical_matrices (dict) – Output of read_dynamical_matrices() (crystal header).

  • force_constants_r (ndarray, shape (nq1, nq2, nq3, 3 nat, 3 nat)) – Output of real_space_force_constants(), before the acoustic sum rule (as q2r.x; matdyn.x applies it). For a polar crystal the short-range remainder after subtracting long_range.

  • long_range (LongRangeModel, optional) – Polar crystal: write the T flag, QE’s Ewald parameter, the dielectric tensor and the Born charges of the model, so that matdyn.x restores the dipole term (q2r_matdyn()).

Returns:

path.

Return type:

str

Notes

QE stores \(\Phi(\mathbf R)\) with \(C(\mathbf q) = \sum_{\mathbf R}\Phi(\mathbf R) e^{-i\mathbf q\cdot\mathbf R}\), i.e. \(\Phi(\mathbf m) = C(-\mathbf m)\) of real_space_force_constants(). Without long_range the Born effective charges are not written (the F flag).

PAOFLOW.phonon.qe_force_constants.phonon_interpolator(force_constants_r, masses_ry, qgrid, at, atom_positions=None, acoustic_sum_rule=True, long_range=None)[source]#

Wigner-Seitz interpolator of the dynamical matrix (matdyn.x).

Parameters:
  • force_constants_r (ndarray, shape (nq1, nq2, nq3, 3 nat, 3 nat)) – Output of real_space_force_constants().

  • masses_ry (ndarray, shape (nat,)) – Atomic masses in QE Rydberg units.

  • qgrid (sequence of int) – The coarse q-grid.

  • at (ndarray, shape (3, 3)) – Direct lattice vectors (rows, alat).

  • atom_positions (ndarray, shape (nat, 3), optional) – Atomic positions (crystal coordinates): atom-pair Wigner-Seitz images, as matdyn.x, which keep the dispersion symmetric in cells with several atoms. None uses single-site images.

  • acoustic_sum_rule (bool, optional) – Apply apply_acoustic_sum_rule() first (asr = 'simple').

  • long_range (callable, optional) – q_cryst -> (3 nat, 3 nat) force constants (Ry/bohr^2) added to the interpolated C(q) before the mass weighting: the analytic dipole/quadrupole term of a polar crystal (dynamical_matrix()), which must have been subtracted from force_constants_r on the coarse grid.

Returns:

phonon_at_q(q_cryst): for q_cryst of shape (3,) it returns (freq_thz (nmode,), z (nmode, nmode)), the frequencies (negative for unstable modes) and the mass-weighted eigenvectors as rows; for shape (nq, 3) the arrays gain a leading q axis.

Return type:

callable

PAOFLOW.phonon.qe_force_constants.gamma_limit_points(q_cryst, bg, step=1e-05)[source]#

Replace exact Gamma points of a path by the limit along the path (matdyn.x).

Parameters:
  • q_cryst (ndarray, shape (nq, 3)) – Path in crystal coordinates, in order.

  • bg (ndarray, shape (3, 3)) – Reciprocal lattice vectors (rows, 2 pi / alat).

  • step (float, optional) – Length of the displacement (2 pi / alat).

Returns:

The path with every Gamma point moved by step towards the next point of the path (towards the previous one for the last point), where the non-analytic dipole term of a polar crystal takes its direction-dependent limit.

Return type:

ndarray, shape (nq, 3)

PAOFLOW.phonon.qe_force_constants.high_symmetry_path(ibrav, alat, at)[source]#

High-symmetry q-path of a Bravais lattice (PAOFLOW’s band path).

Parameters:
  • ibrav (int) – QE Bravais-lattice index (ibrav = 0 has no default path).

  • alat (float) – Lattice parameter (bohr).

  • at (ndarray, shape (3, 3)) – Direct lattice vectors (rows, alat).

Returns:

  • segments (list of list of ndarray) – Continuous segments, each a list of crystal q-points.

  • labels (list of str) – Display labels, one per point.

PAOFLOW.phonon.qe_force_constants.phonon_dispersion(phonon_at_q, bg, segments, labels=None, npoints=51)[source]#

Phonon frequencies along a q-path.

Parameters:
  • phonon_at_q (callable) – Output of phonon_interpolator().

  • bg (ndarray, shape (3, 3)) – Reciprocal lattice vectors (rows, 2 pi / alat), for the path length.

  • segments (sequence of sequence of ndarray) – Continuous path segments of crystal q-points (| breaks between segments), e.g. from high_symmetry_path().

  • labels (sequence of str, optional) – One label per point of segments.

  • npoints (int, optional) – Points per straight line, end points included.

Returns:

distance (nq,) (2 pi / alat), frequency_thz (nq, nmode), q_cryst (nq, 3), tick_distance and tick_label (one per point; two labels share a distance at a break).

Return type:

dict

PAOFLOW.phonon.qe_force_constants.phonon_density_of_states(phonon_at_q, mesh=(24, 24, 24), sigma_thz=0.1, frequency_step_thz=0.02, chunk=4096)[source]#

Phonon density of states on a Gamma-centred q-mesh (Gaussian broadening).

Parameters:
  • phonon_at_q (callable) – Output of phonon_interpolator().

  • mesh (sequence of int, optional) – q-mesh.

  • sigma_thz (float, optional) – Gaussian width (THz).

  • frequency_step_thz (float, optional) – Spacing of the frequency grid (THz).

  • chunk (int, optional) – q-points per batch.

Returns:

frequency_thz (nfreq,) and dos (nfreq,) (states/THz per cell, integrating to 3 nat).

Return type:

dict

Notes

\(g(\nu) = \frac{1}{N_q}\sum_{\mathbf q j}\frac{1}{\sigma\sqrt{2\pi}} e^{-(\nu-\nu_{\mathbf q j})^2/2\sigma^2}\).

PAOFLOW.phonon.qe_force_constants.write_phonon_band_files(outdir, fname, dispersion, units='THz')[source]#

Write <fname>_band.dat and <fname>_band.labels (format of the phonopy route).

Parameters:
  • outdir (str) – Output directory.

  • fname (str) – File stem.

  • dispersion (dict) – Output of phonon_dispersion().

  • units ({'THz', 'cm-1'}, optional) – Frequency unit.

Returns:

The written files, read by PAOFLOW.GPAO.GPAO.plot_phonons().

Return type:

list of str

PAOFLOW.phonon.qe_force_constants.write_phonon_dos_file(outdir, fname, dos, units='THz')[source]#

Write <fname>_dos.dat (frequency and total DOS, format of the phonopy route).

Parameters:
  • outdir (str) – Output directory.

  • fname (str) – File stem.

  • dos (dict) – Output of phonon_density_of_states().

  • units ({'THz', 'cm-1'}, optional) – Frequency unit (the DOS is per unit of it).

Returns:

The written file.

Return type:

str

PAOFLOW.phonon.qe_force_constants.q2r_matdyn(prefix, directory='.', outdir='.', fname='phonon', force_constants_file=None, segments=None, labels=None, npoints=51, mesh=(24, 24, 24), sigma_thz=0.1, units='THz', acoustic_sum_rule=True, long_range='auto', zasr='simple')[source]#

q2r.x + matdyn.x: dispersion and DOS from the ph.x dynamical matrices.

Parameters:
  • prefix (str) – fildyn of ph.x.

  • directory (str, optional) – Directory of the <prefix>.dyn* files.

  • outdir (str, optional) – Output directory.

  • fname (str, optional) – Stem of the output files.

  • force_constants_file (str, optional) – Also write the real-space force constants in QE flfrc format (e.g. 'Si2.fc', relative to outdir).

  • segments (optional) – q-path (crystal coordinates) and labels; default: the high-symmetry path of the Bravais lattice (high_symmetry_path()).

  • labels (optional) – q-path (crystal coordinates) and labels; default: the high-symmetry path of the Bravais lattice (high_symmetry_path()).

  • npoints (int, optional) – Points per straight line of the path.

  • mesh (sequence of int, optional) – q-mesh of the DOS; None skips the DOS.

  • sigma_thz (float, optional) – Gaussian width of the DOS (THz).

  • units ({'THz', 'cm-1'}, optional) – Frequency unit of the written files.

  • acoustic_sum_rule (bool, optional) – Impose the simple acoustic sum rule.

  • long_range ({'auto', False} or LongRangeModel, optional) – Polar crystals (is_polar()): 'auto' builds the dipole model from the Born charges and dielectric tensor of the dynamical matrices (from_dynamical_matrices()), subtracts its force constants before the transform to real space and adds them back at every q (LO-TO splitting, q2r.x + matdyn.x); False interpolates the full matrices and warns; a model is used as given.

  • zasr ({'simple', 'no'}, optional) – Charge-neutrality sum rule on the Born charges of the model (q2r.x).

Returns:

dynamical_matrices, dispersion, dos (or None), files (written paths), phonon_at_q (the interpolator) and long_range (the model or None).

Return type:

dict