Density and hamiltonian objects

class gpaw.density.Density(gd, finegd, nspins, collinear, charge, redistributor, background_charge=None)[source]

Density object.

Attributes:
gd Grid descriptor for coarse grids.
finegd Grid descriptor for fine grids.
interpolate Function for interpolating the electron density.
mixer DensityMixer object.
Soft and smooth pseudo functions on uniform 3D grids:
nt_sG Electron density on the coarse grid.
nt_sg Electron density on the fine grid.
nt_g Electron density on the fine grid.
rhot_g Charge density on the fine grid.
nct_G Core electron-density on the coarse grid.

Create the Density object.

calculate_pseudo_density(wfs)[source]

Calculate nt_sG from scratch.

nt_sG will be equal to nct_G plus the contribution from wfs.add_to_density().

get_all_electron_density(atoms=None, gridrefinement=2, spos_ac=None, skip_core=False)[source]

Return real all-electron density array.

Usage: Either get_all_electron_density(atoms) or
get_all_electron_density(spos_ac=spos_ac)
skip_core=True theoretically returns the
all-electron valence density (use with care; will not in general integrate to valence)
get_correction(a, spin)[source]

Integrated atomic density correction.

Get the integrated correction to the pseuso density relative to the all-electron density.

get_spin_contamination(atoms, majority_spin=0)[source]

Calculate the spin contamination.

Spin contamination is defined as the integral over the spin density difference, where it is negative (i.e. the minority spin density is larger than the majority spin density.

initialize_directly_from_arrays(nt_sG, nt_vG, D_asp)[source]

Set D_asp and nt_sG directly.

initialize_from_atomic_densities(basis_functions)[source]

Initialize D_asp, nt_sG and Q_aL from atomic densities.

nt_sG is initialized from atomic orbitals, and will be constructed with the specified magnetic moments and obeying Hund’s rules if hund is true.

initialize_from_other_density(dens, kptband_comm)[source]

Redistribute pseudo density and atomic density matrices.

Collect dens.nt_sG and dens.D_asp to world master and distribute.

initialize_from_wavefunctions(wfs)[source]

Initialize D_asp, nt_sG and Q_aL from wave functions.

normalize(comp_charge)[source]

Normalize pseudo density.

class gpaw.hamiltonian.Hamiltonian(gd, finegd, nspins, collinear, setups, timer, xc, world, redistributor, vext=None)[source]
apply(a_xG, b_xG, wfs, kpt, calculate_P_ani=True)[source]

Apply the Hamiltonian operator to a set of vectors.

Parameters:

a_nG: ndarray
Set of vectors to which the overlap operator is applied.
b_nG: ndarray, output
Resulting S times a_nG vectors.
wfs: WaveFunctions
Wave-function object defined in wavefunctions.py
kpt: KPoint object
k-point object defined in kpoint.py.
calculate_P_ani: bool
When True, the integrals of projector times vectors P_ni = <p_i | a_nG> are calculated. When False, existing P_ani are used
apply_local_potential(psit_nG, Htpsit_nG, s)[source]

Apply the Hamiltonian operator to a set of vectors.

XXX Parameter description is deprecated!

Parameters:

a_nG: ndarray
Set of vectors to which the overlap operator is applied.
b_nG: ndarray, output
Resulting H times a_nG vectors.
kpt: KPoint object
k-point object defined in kpoint.py.
calculate_projections: bool
When True, the integrals of projector times vectors P_ni = <p_i | a_nG> are calculated. When False, existing P_uni are used
local_part_only: bool
When True, the non-local atomic parts of the Hamiltonian are not applied and calculate_projections is ignored.
get_xc_difference(xc, density)[source]

Calculate non-selfconsistent XC-energy difference.

update(density)[source]

Calculate effective potential.

The XC-potential and the Hartree potential are evaluated on the fine grid, and the sum is then restricted to the coarse grid.