Miscellaneous objects and functions¶

gpaw.occupations.
occupation_numbers
(occ, eps_skn, weight_k, nelectrons)[source]¶ Calculate occupation numbers from eigenvalues in eV.
 occ: dict
 Example: {‘name’: ‘fermidirac’, ‘width’: 0.05} (width in eV).
 eps_skn: ndarray, shape=(nspins, nibzkpts, nbands)
 Eigenvalues.
 weight_k: ndarray, shape=(nibzkpts,)
 Weights of kpoints in IBZ (must sum to 1).
 nelectrons: int or float
 Number of electrons.
Returns a tuple containing:
 f_skn (sums to nelectrons)
 fermilevel
 magnetic moment
 entropy as S*T

class
gpaw.lfc.
NewLocalizedFunctionsCollection
(gd, spline_aj, kd=None, cut=False, dtype=<class 'float'>, integral=None, forces=None)[source]¶ New LocalizedFunctionsCollection
Utilizes that localized functions can be stored on a spherical subset of the uniform grid, as opposed to LocalizedFunctionsCollection which is just a wrapper around the old localized_functions which use rectangular grids.

add
(a_xG, c_axi=1.0, q=1)[source]¶ Add localized functions to extended arrays.
 a a a (G) += > c Phi (G) x  xi i a,i

add_derivative
(a, v, a_xG, c_axi=1.0, q=1)[source]¶ Add derivative of localized functions on atom to extended arrays.
Parameters:
 a: int
 Atomic index of the derivative
 v: int
 Cartesian coordinate of the derivative (0, 1 or 2)
This function adds the following sum to the extended arrays:
 a a a (G) += > c dPhi (G) x  xi iv i
where:
a d a dPhi (G) =  Phi (g) iv dv i
is the derivative of the Phi^a and v is either x, y, or z.

derivative
(a_xG, c_axiv, q=1)[source]¶ Calculate x, y, and zderivatives of localized function integrals.
/ a* c_axiv =  dG a (G) dPhi (G) / x iv
where:
a d a dPhi (G) =  Phi (g) iv dv i
and v is either x, y, or z, and R^a_v is the center of Phi^a.
Notice that d Phi^a_i / dR^a_v ==  d Phi^a_i / d v.


class
gpaw.spline.
Spline
(l, rcut, list) → Spline object[source]¶ The integer l gives the angular momentum quantum number and the list contains the spline values from r=0 to r=rcut.
The array f_g gives the radial part of the function on the grid. The radial function is multiplied by a real solid spherical harmonics (r^l * Y_lm).

class
gpaw.poisson.
FDPoissonSolver
(nn=3, relax='J', eps=2e10, maxiter=1000, remove_moment=None, use_charge_center=False)[source]¶

class
gpaw.xc.functional.
XCFunctional
(name, type)[source]¶ 
calculate
(gd, n_sg, v_sg=None, e_g=None)[source]¶ Calculate energy and potential.
 gd: GridDescriptor
 Descriptor for 3d grid.
 n_sg: rank4 ndarray
 Spin densities.
 v_sg: rank4 ndarray
 Array for potential. The XC potential is added to the values already there.
 e_g: rank3 ndarray
 Energy density. Values must be written directly, not added.
The total XC energy is returned.


class
gpaw.grid_descriptor.
GridDescriptor
(N_c, cell_cv=[1, 1, 1], pbc_c=True, comm=None, parsize_c=None)[source]¶ Descriptorclass for uniform 3D grid
A
GridDescriptor
object holds information on how functions, such as wave functions and electron densities, are discreticed in a certain domain in space. The main information here is how many grid points are used in each direction of the unit cell.There are methods for tasks such as allocating arrays, performing symmetry operations and integrating functions over space. All methods work correctly also when the domain is parallelized via domain decomposition.
This is how a 2x2x2 3D array is laid out in memory:
37 \   \   15 z 26  y  \  \  \  \ \ \ 04 +x
Example:
>>> a = np.zeros((2, 2, 2)) >>> a.ravel()[:] = range(8) >>> a array([[[0, 1], [2, 3]], [[4, 5], [6, 7]]])
Construct griddescriptor object.
parameters:
 N_c: 3 ints
 Number of grid points along axes.
 cell_cv: 3 float’s or 3x3 floats
 Unit cell.
 pbc_c: one or three bools
 Periodic boundary conditions flag(s).
 comm: MPIcommunicator
 Communicator for domaindecomposition.
 parsize_c: tuple of 3 ints, a single int or None
 Number of domains.
Note that if pbc_c[c] is False, then the actual number of gridpoints along axis c is one less than N_c[c].
Attributes:
dv
Volume per grid point. h_cv
Array of the grid spacing along the three axes. N_c
Array of the number of grid points along the three axes. n_c
Number of grid points on this CPU. beg_c
Beginning of gridpoint indices (inclusive). end_c
End of gridpoint indices (exclusive). comm
MPIcommunicator for domain decomposition. The length unit is Bohr.

bytecount
(dtype=<class 'float'>)[source]¶ Get the number of bytes used by a grid of specified dtype.

coarsen
()[source]¶ Return coarsened \(GridDescriptor\) object.
Reurned descriptor has 2x2x2 fewer grid points.

collect
(a_xg, out=None, broadcast=False)[source]¶ Collect distributed array to masterCPU or all CPU’s.

coords
(c, pad=True)[source]¶ Return coordinates along one of the three axes.
Useful for plotting:
import matplotlib.pyplot as plt plt.plot(gd.coords(0), data[:, 0, 0]) plt.show()

distribute
(B_xg, out=None)[source]¶ Distribute full array B_xg to subdomains, result in b_xg.
B_xg is not used by the slaves (i.e. it should be None on all slaves) b_xg must be allocated on all nodes and will be overwritten.

empty
(n=(), dtype=<class 'float'>, global_array=False, pad=False)[source]¶ Return new uninitialized 3D array for this domain.
The type can be set with the
dtype
keyword (default:float
). Extra dimensions can be added withn=dim
. A global array spanning all domains can be allocated withglobal_array=True
.

get_grid_point_coordinates
(dtype=<class 'float'>, global_array=False)[source]¶ Construct cartesian coordinates of grid points in the domain.

get_grid_point_distance_vectors
(r_v, mic=True, dtype=<class 'float'>)[source]¶ Return distances to a given vector in the domain.
mic: if true adopts the mininimum image convention procedure by W. Smith in ‘The Minimum image convention in NonCubic MD cells’ March 29, 1989

get_nearest_grid_point
(spos_c, force_to_this_domain=False)[source]¶ Return index of nearest grid point.
The nearest grid point can be on a different CPU than the one the nucleus belongs to (i.e. return can be negative, or larger than gd.end_c), in which case something clever should be done. The point can be forced to the grid descriptors domain to be consistent with self.get_rank_from_position(spos_c).

integrate
(a_xg, b_yg=None, global_integral=True, hermitian=False, _transposed_result=None)[source]¶ Integrate function(s) over domain.
 a_xg: ndarray
 Function(s) to be integrated.
 b_yg: ndarray
 If present, integrate a_xg.conj() * b_yg.
 global_integral: bool
 If the array(s) are distributed over several domains, then the total sum will be returned. To get the local contribution only, use global_integral=False.
 hermitian: bool
 Result is hermitian.
 _transposed_result: ndarray
 Long story. Don’t use this unless you are a method of the MatrixOperator class …

interpolate_grid_points
(spos_nc, vt_g, target_n, use_mlsqr=True)[source]¶ Return interpolated values.
Calculate interpolated values from array vt_g based on the scaled coordinates on spos_c.
Uses moving least squares algorithm by default, or otherwise trilinear interpolation.
This doesn’t work in parallel, since it would require communication between neighbouring grid.

new_descriptor
(N_c=None, cell_cv=None, pbc_c=None, comm=None, parsize_c=None)[source]¶ Create new descriptor based on this one.
The new descriptor will use the same class (possibly a subclass) and all arguments will be equal to those of this descriptor unless new arguments are provided.

plane_wave
(k_c)[source]¶ Evaluate plane wave on grid.
Returns:
_ _ ik.r e ,
where the wave vector is given by k_c (in units of reciprocal lattice vectors).

refine
()[source]¶ Return refined \(GridDescriptor\) object.
Returned descriptor has 2x2x2 more grid points.

wannier_matrix
(psit_nG, psit_nG1, G_c, nbands=None)[source]¶ Wannier localization integrals
The soft part of Z is given by (Eq. 27 ref1):
~ ~ i G.r ~ Z = <psi  e psi > nm n m
psit_nG and psit_nG1 are the set of wave functions for the two different spin/kpoints in question.
ref1: Thygesen et al, Phys. Rev. B 72, 125119 (2005)