Code documentation¶
PyZFS can be extended to support more wavefunction formats by defining subclasses of WavefunctionLoader abstract class. The abstract method scan and load have to be override to parse and read the wavefunction data into memory and store as a Wavefunction object.
PyZFS API documentation:
ZFS¶
-
class
pyzfs.zfs.main.
ZFSCalculation
(**kwargs)¶ Bases:
object
Zero field splitting D tensor calculation.
Generally, calculation of D tensor involves pairwise iteration over many wavefuctions (KS orbitals). Physically, wavefunction is uniquely labeled by a 2-tuple of band index (int) and spin (“up” or “down”). Internally, each wavefunction is labeled by an integer index. Several maps are defined to describe related transformations.
-
wfc
¶ container for all KS orbitals
Type: Wavefunction
-
ft
¶ defines grid size for fourier transform
Type: FourierTransform
-
ddig
¶ dipole-dipole interaction tensor in G space. Shape = (6, n1, n2, n3), where first index labels cartisian directions (xx, xy, xz, yy, yz, zz), last 3 indices iterate over G space
Type: ndarray
-
Iglobal
¶ global I array of shape (norbs, norbs, 6) first two indices iterate over wavefunctions, last index labels catesian directions in xx, xy, xz, yy, yz, xz manner
Type: ndarray
-
I
¶ local I matrix, first two dimensions are distributed among processors
Type: ndarray
-
D
¶ 3 by 3 matrix, total D tensor
Type: ndarray
-
ev, evc
eigenvalues and eigenvectors of D tensor
Type: ndarray
-
Dvalue, Evalue
scalar D and E parameters for triplet
Type: float
-
get_xml
()¶ Generate an xml to store information of this calculation.
Returns: A string containing xml.
-
Common¶
-
class
pyzfs.common.wfc.baseloader.
WavefunctionLoader
(memory='critical')¶ A wavefunction loader that can load the wavefunction generated by given DFT codes into memory, stored as a Wavefunction object.
-
load
(iorbs, sdm)¶ Load read space KS orbitals to memory, store in wfc.iorb_psir_map.
Parameters: - iorbs – a list of integers representing orbital indices.
- sdm – a SymmetricDistributedMatrix object indicating how the wavefunction is distributed.
Returns: After load is called, the wavefunction will be loaded into self.wfc.
-
scan
()¶ Scan current directory, construct wavefunction object
-
-
class
pyzfs.common.wfc.wavefunction.
Wavefunction
(cell, ft, nuorbs, ndorbs, iorb_sb_map, iorb_fname_map, dft=None, gamma=True, gvecs=None)¶ Container class for Kohn-Sham orbitals
Physically, wavefunction is uniquely labeled by a 2-tuple of band index (int) and spin (“up” or “down”). Internally, each wavefunction is labeled by an integer index. Several maps are defined to describe related transformations.
-
norbs
¶ total number of KS orbitals to be considered
Type: int
-
nuorbs/ndorbs
number of spin up/down orbitals
Type: int
-
sb_iorb_map
¶ (spin, band index) -> orb index map
Type: dict
-
iorb_sb_map
¶ orb index -> (spin, band index) map
Type: list
-
iorb_psir_map
¶ orb index -> orb object (3D array) map
Type: dict
-
ft
¶ defines grid size for fourier transform
Type: FourierTransform
Right now only consider ground state, insulating, spin-polarized case. No occupation number considerations are implemented yet.
-
compute_psir_from_psig_arr
(psig_arr)¶ Compute psi(r) based on psi(G) defined on self.gvecs
-
get_psir
(iorb)¶ Get psi(r) of certain index
-
get_rhog
(iorb)¶ Get rho(G) of certain index
-
normalize
(psir)¶ Normalize psir.
-
-
class
pyzfs.common.cell.
Cell
(ase_cell)¶ A wrapper class for ASE Atoms that defines R and G vectors.
-
class
pyzfs.common.ft.
FourierTransform
(n1, n2, n3)¶ Define forward/backward 3D FT on a given grid
- Forward/backward FT are defined with following conventions:
- f(G) = 1/omega * int{ f(r) exp(-iGr) dr } f(r) = sigma{ f(G) exp(iGr) }
-
backward
(fg)¶ Fourier backward transform a function.
Parameters: fg (np.ndarray) – function in G space (3D array) Returns: function in R space (with same grid size)
-
forward
(fr)¶ Fourier forward transform a function.
Parameters: fr (np.ndarray) – function in R space (3D array) Returns: function in G space (with same grid size)
-
interp
(fr, n1, n2, n3)¶ Fourier interpolate a function to a smoother grid.
Parameters: - fr – function to be interpolated
- n2, n3 (n1,) – new grid size
Returns: interpolated function (3D array of size n1 by n2 by n3)
-
class
pyzfs.common.parallel.
DistributedMatrix
(pgrid, shape, dtype)¶ An array whose first two dimensions are distributed.
Convention: a variable indexing local block of a distributed matrix should have trailing “loc” in its name, otherwise it is considered a global index
-
collect
()¶ Gather the distributed matrix to all processor.
Returns: global matrix.
-
gtol
(i, j=None)¶ global -> local index map
-
ltog
(iloc, jloc=None)¶ local -> global index map
-
-
class
pyzfs.common.parallel.
ProcessorGrid
(comm, square=False)¶ 2D Grid of processors used to wrap MPI communications.
-
class
pyzfs.common.parallel.
SymmetricDistributedMatrix
(pgrid, shape, dtype)¶ A array whose first two dimensions are distributed and symmetric.
-
get_triu_iterator
()¶ Get a list of 2D indices to iterate over upper triangular part of the local matrix.
Returns: list of 2-tuples of ints.
-
symmetrize
()¶ Compute lower triangular part of the matrix from upper triangular part.
-