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.):
read_dynamical_matrices()– the dynamical matrices of every q-point of the coarse grid (all star members listed in the files) and the crystal;real_space_force_constants()– the Fourier transform to the real-space force constants of the q-grid supercell (q2r.x);write_qe_force_constants()– the QEflfrcfile, readable bymatdyn.xandPAOFLOW.elphon.qe_matdyn.read_qe_ifc();phonon_interpolator()– Wigner-Seitz interpolation of the dynamical matrix to any q with atom-pair images and the simple acoustic sum rule (matdyn.x,asr = 'simple');phonon_dispersion()andphonon_density_of_states()– the band structure along the high-symmetry path of the Bravais lattice and the DOS;q2r_matdyn()– the whole chain, writing<fname>_band.dat,<fname>_band.labelsand<fname>_dos.datin the format of the phonopy route, plotted byPAOFLOW.GPAO.GPAO.plot_phonons().
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#
Parse one QE |
|
|
All dynamical matrices of a |
|
Whether Born effective charges are physically non-zero. |
|
Real-space force constants of the q-grid supercell ( |
|
Impose the simple acoustic sum rule on real-space force constants ( |
|
Write the real-space force constants in QE's |
|
Wigner-Seitz interpolator of the dynamical matrix ( |
|
Replace exact Gamma points of a path by the limit along the path ( |
|
High-symmetry q-path of a Bravais lattice (PAOFLOW's band path). |
|
Phonon frequencies along a q-path. |
|
Phonon density of states on a Gamma-centred q-mesh (Gaussian broadening). |
|
Write |
|
Write |
|
|
Module Contents#
- PAOFLOW.phonon.qe_force_constants.read_dynamical_matrix_file(path)[source]#
Parse one QE
*.dynfile: crystal header and the matrices of its q-star.- Parameters:
path (str) – A
<prefix>.dynNfile ofph.x.- Returns:
ntyp,nat,ibrav,celldm(6,),at(3, 3)(rows,alat;Noneunlessibrav = 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, index3 na + alpha)epsilon(3, 3)andborn_charges(nat, 3, 3)(rows: field direction, as theEffective Charges E-Ublock) orNonewhen the file has no dielectric block.- Return type:
- PAOFLOW.phonon.qe_force_constants.read_dynamical_matrices(prefix, directory='.')[source]#
All dynamical matrices of a
ph.xq-grid run, placed on the full grid.- Parameters:
- Returns:
The header of
read_dynamical_matrix_file()plusqgrid,alat(bohr),atandbg(rows;alatand 2 pi / alat units),tau_cryst(nat, 3),dyn_pathsandforce_constants_q(nq1, nq2, nq3, 3 nat, 3 nat),epsilon,born_chargesandpolar(is_polar()).- Return type:
- Raises:
ValueError – If the q-stars of the files do not cover the full grid.
Notes
<prefix>.dyn0lists the grid and the irreducible q-points; each<prefix>.dynNholds the whole star of its irreducible q, so the files cover the full grid, asq2r.xrequires.
- 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:
Truewhen, after imposing \(\sum_a Z^*_a = 0\) (zasr = 'simple'), an element exceedstolerance.- Return type:
- 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 matricesC(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
nis 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:
force_constants_r (ndarray, shape
(nq1, nq2, nq3, 3 nat, 3 nat)) – Output ofreal_space_force_constants().nat (int) – Atoms per cell.
- 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
flfrcformat (q2r.xoutput).- 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 ofreal_space_force_constants(), before the acoustic sum rule (asq2r.x;matdyn.xapplies it). For a polar crystal the short-range remainder after subtractinglong_range.long_range (LongRangeModel, optional) – Polar crystal: write the
Tflag, QE’s Ewald parameter, the dielectric tensor and the Born charges of the model, so thatmatdyn.xrestores the dipole term (q2r_matdyn()).
- Returns:
path.- Return type:
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(). Withoutlong_rangethe Born effective charges are not written (theFflag).
- 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 ofreal_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, asmatdyn.x, which keep the dispersion symmetric in cells with several atoms.Noneuses 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 interpolatedC(q)before the mass weighting: the analytic dipole/quadrupole term of a polar crystal (dynamical_matrix()), which must have been subtracted fromforce_constants_ron the coarse grid.
- Returns:
phonon_at_q(q_cryst): forq_crystof 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
steptowards 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:
- 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. fromhigh_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_distanceandtick_label(one per point; two labels share a distance at a break).- Return type:
- 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,)anddos(nfreq,)(states/THz per cell, integrating to3 nat).- Return type:
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.datand<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:
- 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:
- 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 theph.xdynamical matrices.- Parameters:
prefix (str) –
fildynofph.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
flfrcformat (e.g.'Si2.fc', relative tooutdir).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;
Noneskips 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);Falseinterpolates 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(orNone),files(written paths),phonon_at_q(the interpolator) andlong_range(the model orNone).- Return type: