Wave functions¶

class
gpaw.wavefunctions.base.
WaveFunctions
(gd, nvalence, setups, bd, dtype, collinear, world, kd, kptband_comm, timer)[source]¶ …
 setups:
List of setup objects.
 symmetry:
Symmetry object.
 kpt_u:
List of kpoint objects.
 nbands: int
Number of bands.
 nspins: int
Number of spins.
 dtype: dtype
Data type of wave functions (float or complex).
 bzk_kc: ndarray
Scaled kpoints used for sampling the whole Brillouin zone  values scaled to [0.5, 0.5).
 ibzk_kc: ndarray
Scaled kpoints in the irreducible part of the Brillouin zone.
 weight_k: ndarray
Weights of the kpoints in the irreducible part of the Brillouin zone (summing up to 1).
 kpt_comm:
MPIcommunicator for parallelization over kpoints.

calculate_atomic_density_matrices
(D_asp)[source]¶ Calculate atomic density matrices from projections.

calculate_atomic_density_matrices_with_occupation
(D_asp, f_un)[source]¶ Calculate atomic density matrices from projections with custom occupation f_un.

calculate_density_contribution
(nt_sG)[source]¶ Calculate contribution to pseudo density from wave functions.
Array entries are written to (not added to).

collect_array
(name, k, s, subset=None)[source]¶ Helper method for collect_eigenvalues and collect_occupations.
For the parallel case find the rank in kpt_comm that contains the (k,s) pair, for this rank, collect on the corresponding domain a full array on the domain master and send this to the global master.

collect_auxiliary
(value, k, s, shape=1, dtype=<class 'float'>)[source]¶ Helper method for collecting bandindependent scalars/arrays.
For the parallel case find the rank in kpt_comm that contains the (k,s) pair, for this rank, collect on the corresponding domain a full array on the domain master and send this to the global master.

collect_projections
(k, s)[source]¶ Helper method for collecting projector overlaps across domains.
For the parallel case find the rank in kpt_comm that contains the (k,s) pair, for this rank, send to the global master.

get_orbital_density_matrix
(a, kpt, n)[source]¶ Add the nth band density from kpt to density matrix D_sp

get_wave_function_array
(n, k, s, realspace=True, periodic=False)[source]¶ Return pseudowavefunction array on master.
 n: int
Global band index.
 k: int
Global IBZ kpoint index.
 s: int
Spin index (0 or 1).
 realspace: bool
Transform plane wave or LCAO expansion coefficients to realspace.
For the parallel case find the ranks in kd.comm and bd.comm that contains to (n, k, s), and collect on the corresponding domain a full array on the domain master and send this to the global master.

class
gpaw.wavefunctions.fd.
FDWaveFunctions
(stencil, parallel, initksl, gd, nvalence, setups, bd, dtype, world, kd, kptband_comm, timer, reuse_wfs_method=None, collinear=True)[source]¶

class
gpaw.wavefunctions.pw.
PWWaveFunctions
(ecut, gammacentered, fftwflags, dedepsilon, parallel, initksl, reuse_wfs_method, collinear, gd, nvalence, setups, bd, dtype, world, kd, kptband_comm, timer)[source]¶ 
apply_pseudo_hamiltonian
(kpt, ham, psit_xG, Htpsit_xG)[source]¶ Apply the pseudo Hamiltonian i.e. without PAW corrections.

get_wave_function_array
(n, k, s, realspace=True, cut=True, periodic=False)[source]¶ Return pseudowavefunction array on master.
 n: int
Global band index.
 k: int
Global IBZ kpoint index.
 s: int
Spin index (0 or 1).
 realspace: bool
Transform plane wave or LCAO expansion coefficients to realspace.
For the parallel case find the ranks in kd.comm and bd.comm that contains to (n, k, s), and collect on the corresponding domain a full array on the domain master and send this to the global master.


class
gpaw.wavefunctions.pw.
PW
(ecut=340, fftwflags=0, cell=None, gammacentered=False, pulay_stress=None, dedecut=None, force_complex_dtype=False)[source]¶ Planewave basis mode.
 ecut: float
Planewave cutoff in eV.
 gammacentered: bool
Center the grid of chosen plane waves around the gamma point or q/kvector
 dedecut: float or None or ‘estimate’
Estimate of derivative of total energy with respect to planewave cutoff. Used to calculate pulay_stress.
 pulay_stress: float or None
Pulaystress correction.
 fftwflags: int
Flags for making an FFTW plan. There are 4 possibilities (default is MEASURE):
from gpaw.fftw import ESTIMATE, MEASURE, PATIENT, EXHAUSTIVE
 cell: 3x3 ndarray
Use this unit cell to chose the planewaves.
Only one of dedecut and pulay_stress can be used.

class
gpaw.wavefunctions.lcao.
LCAOWaveFunctions
(ksl, gd, nvalence, setups, bd, dtype, world, kd, kptband_comm, timer, atomic_correction=None, collinear=True)[source]¶ 
add_to_density_from_k_point_with_occupation
(nt_sG, kpt, f_n)[source]¶ Add contribution to pseudo electrondensity. Do not use the standard occupation numbers, but ones given with argument f_n.

calculate_atomic_density_matrices_with_occupation
(D_asp, f_un)[source]¶ Calculate atomic density matrices from projections with custom occupation f_un.

initialize_wave_functions_from_lcao
()[source]¶ Fill the calc.wfs.kpt_[u].psit_nG arrays with useful data.
Normally psit_nG is NOT used in lcao mode, but some extensions (like ase.dft.wannier) want to have it. This code is adapted from fd.py / initialize_from_lcao_coefficients() and fills psit_nG with data constructed from the current lcao coefficients (kpt.C_nM).
(This may or may not work in bandparallel case!)


class
gpaw.kpoint.
KPoint
(weightk: float, weight: float, s: int, k: int, q: int, phase_cd=None)[source]¶ Class for a single kpoint.
The KPoint class takes care of all wave functions for a certain kpoint and a certain spin.
Attributes:
 eps_n: float ndarray
Eigenvalues.
 f_n: float ndarray
Occupation numbers. The occupation numbers already include the kpoint weight in supercell calculations.
Construct kpoint object.
Parameters:
 weightk:
Weight of this kpoint.
 weight:
Old confusing weight.
 s: int
Spin index: up or down (0 or 1).
 k: int
kpoint IBZindex.
 q: int
local kpoint index.
 phase_cd: complex ndarray
Bloch phasefactors for translations  axis c=0,1,2 and direction d=0,1.

class
gpaw.eigensolvers.eigensolver.
Eigensolver
(keep_htpsit=True, blocksize=1)[source]¶ 
calculate_residuals
(kpt, wfs, ham, psit, P, eps_n, R, C, n_x=None, calculate_change=False)[source]¶ Calculate residual.
From R=Ht*psit calculate R=H*psiteps*S*psit.

iterate
(ham, wfs)[source]¶ Solves eigenvalue problem iteratively
This method is inherited by the actual eigensolver which should implement iterate_one_k_point method for a single iteration of a single kpoint.

subspace_diagonalize
(ham, wfs, kpt)[source]¶ Diagonalize the Hamiltonian in the subspace of kpt.psit_nG
Htpsit_nG is a work array of same size as psit_nG which contains the local part of the Hamiltonian times psit on exit
First, the Hamiltonian (defined by kin, vt_sG, and dH_asp) is applied to the wave functions, then the H_nn matrix is calculated and diagonalized, and finally, the wave functions (and also Htpsit_nG are rotated. Also the projections P_ani are rotated.
It is assumed that the wave functions psit_nG are orthonormal and that the integrals of projector functions and wave functions P_ani are already calculated.
Return rotated wave functions and H applied to the rotated wave functions if self.keep_htpsit is True.
