MD

Charge-density-wave dynamics on supercells.

class elphmod.md.Driver(elph, kT, f, n, nk=(1,), nq=(1,), supercell=None, unscreen=True, shared_memory=True, **kwargs)[source]

MD driver for DFPT-based displacements dynamics.

Parameters:
elphelphmod.elph.Model

Localized model for electron-phonon coupling. Initialize el with rydberg=True and ph and elph with divide_mass=False and map everthing to the appropriate supercell before (elph.supercell).

kTfloat

Smearing temperature in Ry.

ffunction

Particle distribution as a function of energy divided by kT.

nfloat

Number of electrons per primitive cell.

nk, nqtuple of int, optional

Shape of k and q mesh. By default, only k = q = 0 is used.

supercellndarray, optional

Supercell lattice vectors as multiples of primitive lattice vectors. If given, the simulation is performed on a supercell for q = k = 0. Sparse matrices are used for Hamiltonian, dynamical matrix, and electron-phonon coupling to save memory. Note that elph should belong to the primitive cell in this case, and nq and nk are only used for the unscreening, which is still done one the primitive cell. To do the unscreening on the supercell (recommended), a sparse supercell model elph can be directly provided instead of using this option.

unscreenbool, default True

Unscreen phonons? Otherwise, they are assumed to be unscreened already.

shared_memorybool, default True

Store d0 and d in shared memory?

**kwargs

Attributes to be set initially.

Attributes:
elph, kT, f, n, nk, nq

Copies of initialization parameters.

mufloat

Current chemical potential.

k, qndarray

k and q meshes.

undarray

Atomic displacements.

C0ndarray

Unscreened force constants.

H0ndarray

Unperturbed electron Hamiltonian in orbital basis.

d0ndarray

Electron-phonon coupling in orbital basis.

dndarray

Electron-phonon coupling in band basis.

sparsebool

Is the simulation performed on a supercell using sparse matrices?

interactivebool, default False

Shall plots be updated interactively?

scalefloat, default 10.0

Displacement scaling factor for plots.

sizefloat, default 100.0

Marker size for atoms in points squared.

pausefloat, default 1e-3

Minimal frame duration for interactive plots in seconds.

basislist of list, default None

For each basis atom in the first primitive cell, indices of orbitals located at this atom. Matching atom and orbital orders as ensured by elphmod.elph.Model.supercell() are required.

node, imagesMPI.Intracomm

Communicators between processes that share memory or same node.rank if shared_memory.

center_mass()[source]

Subtract collective translational displacement component.

density()[source]

Calculate electron density for all orbitals.

Returns:
ndarray

Electron density. Should add up to the number of electrons.

density_per_atom()[source]

Calculate electron density per atom.

diagonalize()[source]

Diagonalize Hamiltonian of perturbed system.

electrons(seedname=None, dk1=1, dk2=1, dk3=1, rydberg=False)[source]

Set up tight-binding model for current structure.

Parameters:
seednamestr

Prefix of file with Hamiltonian in Wannier90 format.

dk1, dk2, dk3int, optional

Only use data for every dkn-th k point along the n-th axis? This reduces the size of the Hamiltonian file.

rydbergbool, default False

Keep Ry units? Otherwise they are converted to eV.

Returns:
object

Tight-binding model for the electrons.

find_Fermi_level()[source]

Update chemical potential.

Returns:
float

New chemical potential.

free_energy(u=None, show=True)[source]

Calculate free energy.

Parameters:
undarray

Updated atomic displacements (e.g., from optimization routine).

showbool

Print free energy?

Returns:
float

Free energy in Ry.

from_xyz(xyz)[source]

Load saved atomic positions if compatible.

If an interactive plot is open, it is updated. If xyz contains a full trajectory, all steps are shown in an interactive plot (whose speed can be controlled via pause) and the last atomic positions are kept.

Parameters:
xyzstr

Name of .xyz file.

hessian(parameters=None, gamma_only=True, apply_asr_simple=False, fildyn=None, eps=1e-10, kT=None)[source]

Calculate second derivative of free energy.

Parameters:
parametersndarray

Dummy positional argument for optimization routines.

gamma_onlydefault True

Calculate Hessian for q = 0 only?

apply_asr_simpledefault False

Apply simple acoustic sum rule correction to force constants according to Eq. 81 of Gonze and Lee, Phys. Rev. B 55, 10355 (1997)? This is done before saving the Hessian to file.

fildynstr, optional

Filename to save Hessian.

epsfloat

Smallest allowed absolute value of divisor.

kTfloat, optional

Smearing temperature. If given, it is used to calculate the double Fermi-surface average of the electron-phonon coupling squared, which is then also returned.

Returns:
ndarray

Force constants in Ry per bohr squared.

ndarray, optional

Fermi-surface average of electron-phonon coupling squared.

jacobian(parameters=None, show=True)[source]

Calculate first derivative of free energy.

Parameters:
parametersndarray

Dummy positional argument for optimization routines.

showbool

Print free energy?

Returns:
ndarray

Negative forces in Ry per bohr.

static load(filename)[source]

Load driver from file.

This should only be used in serial runs. Shared memory will be lost.

Parameters:
filenamestr

Filename for pickled representation of driver.

Returns:
object

MD driver for DFPT-based displacements dynamics.

phonons(divide_mass=True, **kwargs)[source]

Set up mass-spring model for current structure.

Parameters:
divide_massbool

Divide force constants by atomic masses?

**kwargs

Parameters passed to elphmod.ph.q2r().

Returns:
object

Mass-spring model for the phonons.

plot(filename=None, interactive=None, scale=None, padding=1.0, size=None, pause=None, label=False, elev=None, azim=None)[source]

Plot crystal structure and displacements.

Parameters:
filenamestr, optional

Figure filename. If given, the plot is saved rather than shown.

interactivebool, optional

Shall the plot be updated? If given, this sets the eponymous attribute, which is used by default.

scalefloat, optional

Displacement scaling factor. If given, this sets the eponymous attribute, which is used by default.

paddingfloat, optional

Padding between crystal and plotting box in angstrom.

sizefloat, optional

Marker size for atoms.

pausefloat, optional

Minimal frame duration for interactive plots in seconds.

labelbool, optional

Show atom indices?

elev, azimfloat, optional

Elevation and azimuthal view angles.

random_displacements(amplitude=0.01)[source]

Displace atoms randomly from unperturbed positions.

Parameters:
amplitudefloat

Maximum displacement.

save(filename)[source]

Save driver to file.

Parameters:
filenamestr

Filename for pickled representation of driver.

superconductivity(eps=1e-10, kT=None)[source]

Calculate effective couplings and phonon frequencies.

Note that d is destroyed.

Parameters:
epsfloat

Phonon frequencies squared below eps are set to eps; corresponding couplings are set to zero.

tolfloat, optional

If any phonon frequency squared is smaller than tol, all return values are None. A very small negative value can be chosen to skip calculations involving significant imaginary frequencies.

kTfloat, optional

Smearing temperature. By default, kT is used.

Returns:
float

Effective electron-phonon coupling strength \(\lambda\).

float

Logarithmic average phonon energy.

float

Second-moment average phonon energy.

float

Minimum phonon energy. Imaginary frequencies are given as negative.

to_pwi(pwi, **kwargs)[source]

Save current atomic positions etc. to PWscf input file.

Parameters:
pwistr

Filename.

**kwargs

Keyword arguments with further parameters to be written.

to_xyz(xyz, append=False)[source]

Save current atomic positions.

Parameters:
xyzstr

Name of .xyz file.

appendbool, default False

Append rather than overwrite positions?

update_plot()[source]

Update open plot.