m_wfd/wave_free_3D [ Functions ]

Wave(:,:,:)<wave_t>=The array of structures.
[what]=String defining what has to be freed.
"A"=Both ug and ur as PAW Cprj, if any. Default.
"G" =Only ug.
"R" =Only ur
"C" =Only PAW Cprj.
[mask(:,:,:)]=Mask used to select the elements that have to be deallocated. All of them, if not specified.

m_wfd/wave_init_0D [ Functions ]

usepaw=1 if PAW is used.
npw =Number of plane-waves for ug
nfft=Number of FFT points for the real space wavefunction.
nspinor=Number of spinor components.
natom=Number of atoms in cprj matrix elements.
nlmn_size(natom)=Number of (n,l,m) channel for each atom. Ordering of atoms depends on cprj_order
cprj_order=Flag defining the ordering of the atoms in the cprj matrix elements (CPR_RANDOM|CPR_SORTED).
Use to know if we have to reorder the matrix elements when wfd_get_cprj is called.

m_wfd/wfd_copy_cg [ Functions ]

Return a copy u(g) in a real(dp) array. Useful if we have to interface
the wavefunction descriptor with Abinit code expecting cg(2,npw_k*nspinor) arrays
The routine takes also into account the fact that the ug in wfs could be stored in single-precision.

m_wfd/wfd_distribute_bands [ Functions ]

Distribute a set of bands taking into account the distribution of the ug.

INPUTS

band=the index of the band.
ik_ibz=Index of the k-point in the IBZ
spin=spin index
[got(Wfd%nproc)]=The number of tasks already assigned to the nodes.
[bmask(Wfd%mband)]=The routine will raise an error if one band index
is not treated by any processor. bmask can be used to select the subset of
indices that are expected to be available.

OUTPUT

my_nband=The number of bands that will be treated by this node.
my_band_list(1:my_nband)=The band indices for this node

m_wfd/wfd_distribute_bbp [ Functions ]

Distribute a set of (b,b') indices taking into account the MPI distribution of the ug.
It is used to calculate matrix elements of the form <b,k,s|O|b',k,s>

INPUTS

Wfd<wfd_t>=
ik_ibz=The index of the k-point in the IBZ.
spin=Spin index.
allup=String used to select or not the upper triangle. Possible values:
"All" =Entire (b,b') matrix will be distributed.
"Upper"=Only the upper triangle is distributed.
[got(%nproc)]=The number of tasks already assigned to the nodes. Used to optimize the work load.
Be careful when this routine is called inside several loops since each node should call the routine
at each iteration with the same (local) copy of got so that bbp_distrb will assume the same value on each node.
[bbp_mask(%mband,%mband)]= mask used to select a subset of (b,b') indices.

OUTPUT

my_nbbp=The number of (b,b') indices treated by this node.
bbp_distrb(%mband%mband)=The rank of the node that will treat (b,b').

m_wfd/wfd_distribute_kb_kpbp [ Functions ]

This routines distributes as set of (b,b') indices taking into account the MPI distribution of the ug.
It is used to calculate matrix elements of the form <b,k,s|O|b',k',s>

INPUTS

Wfd<wfd_t>=
ik_ibz =The index of the k-point k in the IBZ.
ikp_ibz=The index of the k-point k' in the IBZ.
spin=Spin index.
allup=String used to select the upper triangle of the (b,b') matrix. Possible values:
"All" =Entire (b,b') matrix will be distributed.
"Upper"=Only the upper triangle is distributed.
[got(%nproc)]=The number of tasks already assigned to the nodes. Used to optimize the distribution of the tasks.
Be careful when this routine is called inside several loops since each node should call the routine
at each iteration with the same (local) copy of got so that bbp_distrb will assume the same value on each node.
[bbp_mask(%mband,%mband)]= mask used to select a subset of (b,b') indices.

OUTPUT

my_nbbp=The number of (b,b') indices treated by this node.
bbp_distrb(%mband%mband)=The rank of the node that will treat (b,b').

m_wfd/wfd_everybody_has_ug [ Functions ]

Return .TRUE. if all the nodes inside comm own the specified ug state.

INPUTS

band=the index of the band.
ik_ibz=Index of the k-point in the IBZ
spin=spin index

PARENTS

SOURCE

3868 function wfd_everybody_has_ug(Wfd,band,ik_ibz,spin) result(answer)
3869 3870 3871 !This section has been created automatically by the script Abilint (TD).
3872 !Do not modify the following lines by hand.
3873 #undef ABI_FUNC
3874 #define ABI_FUNC 'wfd_everybody_has_ug'
3875 !End of the abilint section
3876 3877 implicit none
3878 3879 !Arguments ------------------------------------
3880 !scalars
3881 integer,intent(in) :: band,ik_ibz,spin
3882 logical :: answer
3883 type(wfd_t),intent(in) :: Wfd
3884 3885 !Local variables ------------------------------
3886 !scalars
3887 integer :: how_many,nzeros,ib
3888 !arrays
3889 integer :: proc_ranks(Wfd%nproc),indices(3)
3890 3891 !************************************************************************
3892 3893 indices = (/band,ik_ibz,spin/)
3894 3895 if ( ALL(indices/=(/0,0,0/)) ) then
3896 call wfd_who_has_ug(Wfd,band,ik_ibz,spin,how_many,proc_ranks)
3897 answer = (how_many==Wfd%nproc); RETURN
3898 else
3899 nzeros = COUNT(indices==0)
3900 if (nzeros==3) MSG_ERROR("All indices are zero!")
3901 3902 answer=.TRUE.
3903 MSG_WARNING("Some cases are not coded!") ! TODO
3904 3905 if (band==0) then
3906 3907 if (nzeros==1) then ! All the bands for the given k-point and spin?
3908 ib=0
3909 do while(answer.and.ib<Wfd%nband(ik_ibz,spin))
3910 ib=ib+1
3911 call wfd_who_has_ug(Wfd,ib,ik_ibz,spin,how_many,proc_ranks)
3912 answer = (how_many==Wfd%nproc)
3913 end do; RETURN
3914 3915 else if (ik_ibz==0) then ! All the bands and all the k-points for the the given spin?
3916 3917 else if (spin==0) then ! All the bands and all the spins for the given k-point?
3918 3919 end if
3920 3921 else if (ik_ibz==0) then
3922 if (nzeros==1) then ! All the k-points for the the given band and spin?
3923 3924 else if (band==0) then ! All the k-points and all the bands for the the given spin?
3925 3926 else if (spin==0) then ! All the k-points and all the spins for the the given band?
3927 3928 end if
3929 3930 else
3931 if (nzeros==1) then ! All the spins for the the given band and k-point?
3932 3933 else if (ik_ibz==0) then ! All the spins and all the k-points for the the given band?
3934 3935 else if (band==0) then ! All the spins and all the bands for the the given k-point?
3936 3937 end if
3938 end if
3939 3940 MSG_ERROR("Not implemented error")
3941 end if
3942 3943 end function wfd_everybody_has_ug

m_wfd/wfd_extract_cgblock [ Functions ]

This routine extract a block of wavefunctions for a given spin and k-points.
The wavefunctions are stored in a real(dp) array with the same convention
as the one used in the GS part of Abinit, i.e cg_block(2,nspinor*npw_k*num_bands)

m_wfd/wfd_from_wfk [ Functions ]

This routine opens the specified WFK file, initializes the wavefunction descriptor with the
values reported in the header and reads the wavefunctions from file. The API is very simple
and it does not allow the user to specify how the wavefunctions should be MPI distributed.
All the wavefunction are stored on each node, only the spin is distributed.

INPUTS

wfk_fname=Name of the WFK file.
iomode=Option specifying the fileformat as well as the IO mode to be used.
Psps<pseudopotential_type>=variables related to pseudopotentials
Pawtab(ntypat*usepaw)<type(pawtab_type)>=paw tabulated starting data.
ngfft(18)=Information about 3D FFT, see ~abinit/doc/variables/vargs.htm#ngfft
nloalg(3)=Governs the choice of the algorithm for nonlocal operator. See doc.
keep_ur=Logical flag defining whether the set of u(r) should be saved in memory
comm=MPI communicator

m_wfd/wfd_ihave [ Functions ]

This function is used to ask the processor whether it has a particular (ug|ur|cprj) and with which status.

INPUTS

band=Band index.
ik_ibz=k-point index
spin=Spin index.
what=String defining what has to be tested.
ug
ur
cprj
[how]=string defining which status is checked.
Possible mutually exclusive values: "Allocated", "Stored".
Only the first character is checked (no case-sensitive)
By default the function returns .TRUE. if the wave is either WFD_ALLOCATED or WFD_STORED.

NOTES

A zero index can be used to inquire the status of a bunch of states.
Thus (band,ik_ibz,spin) = (0,1,1) means: Do you have at least one band for the first k-point and the first spin.

m_wfd/wfd_ihave_cprj [ Functions ]

This function is used to ask the processor whether it has a particular cprj and with which status.

INPUTS

band=Band index.
ik_ibz=k-point index
spin=Spin index.
[how]=string defining which status is checked. By default the function returns
.TRUE. if the wave is either WFD_ALLOCATED or WFD_STORED.
Possible mutually exclusive values: "Allocated", "Stored".
Only the first character is checked (no case-sensitive)

NOTES

A zero index can be used to inquire the status of a bunch of states.
Thus (band,ik_ibz,spin) = (0,1,1) means: Do you have at least one band for the first k-point and the first spin.

m_wfd/wfd_ihave_ug [ Functions ]

This function is used to ask the processor whether it has a particular ug and with which status.

INPUTS

band=Band index.
ik_ibz=k-point index
spin=Spin index.
[how]=string defining which status is checked.
Possible mutually exclusive values: "Allocated", "Stored".
Only the first character is checked (no case-sensitive)
By default the function returns .TRUE. if the wave is either WFD_ALLOCATED or WFD_STORED.

NOTES

A zero index can be used to inquire the status of a bunch of states.
Thus (band,ik_ibz,spin) = (0,1,1) means: Do you have at least one band for the first k-point and the first spin.

m_wfd/wfd_ihave_ur [ Functions ]

This function is used to ask the processor whether it has a particular ur and with which status.

INPUTS

band=Band index.
ik_ibz=k-point index
spin=Spin index.
[how]=string defining which status is checked. By default the function returns
.TRUE. if the wave is either WFD_ALLOCATED or WFD_STORED.
Possible mutually exclusive values: "Allocated", "Stored".
Only the first character is checked (no case-sensitive)

NOTES

A zero index can be used to inquire the status of a bunch of states.
Thus (band,ik_ibz,spin) = (0,1,1) means: Do you have at least one band for the first k-point and the first spin.

m_wfd/wfd_mkrho [ Functions ]

ngfftf(18)=array containing all the information for the "fine" FFT.
Cryst<crystal_t> Info on the crystalline structure
optcalc=option for calculation. If =0 (default value) perform calculation
of electronic density. If =1, perform calculation of kinetic energy density.
In both cases, the result is returned in rhor.
Psps<type(pseudopotential_type)>=variables related to pseudopotentials
nfftf=Total number of points on the fine FFT grid (for this processor)
Kmesh<kmesh_t>= Info on the k-sampling:
Wfd<wfd_t)=datatype gathering info on the wavefunctions.
[optcalc]=Optional option used to calculate the kinetic energy density. Defaults to 0.

OUTPUT

rhor(nfftf,nspden)=The density in the real space on the fine FFT grid.
If nsppol==2, total charge in first half, spin-up component in second half.
(for non-collinear magnetism, first element: total density, 3 next ones: mx,my,mz in units of hbar/2)
If optcalc==1 (optional argument, default value is 0), then rhor will actually
contains kinetic energy density (taur) instead of electronic density.

NOTES

In the case of PAW calculations:
All computations are done on the fine FFT grid.
All variables (nfftf,ngfftf,mgfftf) refer to this fine FFT grid.
All arrays (densities/potentials...) are computed on this fine FFT grid.
Developers have to be careful when introducing others arrays:
they have to be stored on the fine FFT grid.
In the case of norm-conserving calculations:
The mesh is the usual augmented FFT grid to treat correctly the convolution.

m_wfd/wfd_mybands [ Functions ]

Return the list of band indices of the ug owned by this node at given (k,s).

INPUTS

ik_ibz=Index of the k-point in the IBZ
spin=spin index
[how]=string defining which status is checked.
Possible mutually exclusive values: "Allocated", "Stored".
Only the first character is checked (no case-sensitive)
By default the list of bands whose status is either WFD_ALLOCATED or WFD_STORED is returned.

OUTPUT

how_manyb=The number of bands owned by this node
my_band_list(Wfd%mband)=The first how_manyb values are the bands treated by this node.

m_wfd/wfd_paw_get_aeur [ Functions ]

band,ik_ibz,spin=indices specifying the band, the k-point and the spin.
Psps<pseudopotential_type>=variables related to pseudopotentials
Cryst<crystal_t>= data type gathering info on symmetries and unit cell.
Wfd<wfd_t>=wavefunction descriptor.
Pawtab(ntypat*usepaw)<type(pawtab_type)>=paw tabulated starting data.
Pawfgrtab(natom)<pawfgrtab_type>= atomic data given on fine rectangular grid.
NB: rpaw should be used in nhatgrid to initialize the datatype (optcut=1 option) instead of the radius for the
shape functions (rpaw /= rshp).
Paw_onsite(natom)<paw_pwaves_lmn_t>=3D PAW partial waves in real space for each FFT point in the PAW spheres.

(1) The true wavefunction integrates in real space to the unit cell volume.
The definition of the cprj matrix elements includes the term 1/SQRT(ucvol) that comes
from the use of a normalized planewave e^(iG.r)/SQRT(omega) in the FFT transform G-->R (see e.g. opernla_ylm)
On the contrary, the convention for the G-->R transform employed in the FFT routines used in abinit is
u(r) = sum_G u(G) e^(iG.r); u(G) = one/omega \int u(r) e^(-iG.r)dr.
Hence we have to multiply the onsite part by SQRT(uvol) before adding the smooth FFT part in real space.
(2) Care has to be taken in the calculation of the onsite contribution when the FFT point belongs to the PAW
sphere of a periodically repeated atom. In this case one evaluates the onsite term associated to the
atom in the first unit cell then the contribution has to be multiplied by a k- dependent
phase factor to account for the wrapping of the real-space point in the first unit cell.

m_wfd/wfd_pawrhoij [ Functions ]

atindx1(natom)=index table for atoms, inverse of atindx
cprj(natom,nspinor*mband*mkmem*nsppol)= wave functions projected with non-local projectors:
cprj_nk(i)=<p_i|Cnk> where p_i is a non-local projector.
istwfk(nkpt)=parameter that describes the storage of wfs
kptopt=option for the generation of k points
mband=maximum number of bands
natom=number of atoms in cell
nkpt=number of k points
nspinor=number of spinorial components of the wavefunctions
nsppol=1 for unpolarized, 2 for spin-polarized
occ(mband*nkpt*nsppol)=occupation number for each band for each k
pawprtvol=control print volume and debugging output for PAW

m_wfd/wfd_plot_ur [ Functions ]

This routine writes the squared modulus of the wavefunctions in real space
to an external files, one for each (k,b,s). File are written in the XSF format (Xcrysden).
A subset of (b,k,s) states can be specified via the bks_mask. The routine is MPI parallelized.

INPUTS

Wfd<wfd_t>=Wavefunction descriptor.
Cryst<crystal_t>= Information on symmetries and unit cell.
Psps<pseudopotential_type>=Pseudopotential info.
Pawtab(ntypat*usepaw)<type(pawtab_type)>=PAW tabulated starting data.
Pawrad(ntypat*usepaw)<type(pawrad_type)>=paw radial mesh and related data.
ngfftf(18)=The FFT mesh used for plotting |wfr|**2, it can differ from the one internally used in Wfd.
For example, PAW wavefunctions should be plotted on a much finer FFT mesh.
bks_mask(mband,nkibz,nsppol)=logical mask used to select the states to be plotted.

m_wfd/wfd_ptr_ug [ Functions ]

Returns a pointer to ug
WARNING: Do not use the returned pointer to modify the location of memory.
The status of the object should always be modified via the appropriate method.
Use the pointer only if you want to avoid a copy and you are not going to change the ug!

INPUTS

Wfd<wfd_t>=the data type
band=the index of the band.
ik_ibz=Index of the k-point in the IBZ
spin=spin index

m_wfd/wfd_ptr_ur [ Functions ]

Returns a pointer to ur
WARNING: Do not use the returned pointer to modify the location of memory.
The status of the object should always be modified via the appropriate method.
Use the pointer only if you want to avoid a copy and you are not going to change the ug!

INPUTS

Wfd<wfd_t>=the data type
band=the index of the band.
ik_ibz=Index of the k-point in the IBZ
spin=spin index

m_wfd/wfd_push_ug [ Functions ]

This routine changes the status of the object by saving the wavefunction in the correct
slot inside Wfd%Wave. It also set the corresponding has_ug flag to WFD_STORED.
If the status of the corresponding ur is (WFD_STORED|WFD_ALLOCATED), then an G->R FFT transform
is done (see also update_ur)

INPUTS

band=Band index.
ik_ibz=k-point index
spin=Spin index.
Cryst<crystal_t>=Object defining the unit cell and its symmetries.
ug(Wfd%npwwfn*Wfd%nspinor)=The ug to be saved.
[update_ur]=If .FALSE.: no G-->R transform is done even if ur is (WFD_STORED|WFD_ALLOCATED) so be careful.
Defaults to .TRUE.
[update_cprj]=If .FALSE.: <C|p_i> matrix elements are not recalculatedd even
if cprj is (WFD_STORED|WFD_ALLOCATED) so be careful. Defaults to .TRUE.

m_wfd/wfd_rotate [ Functions ]

This routine performs a linear transformation of the wavefunctions stored in Wfd
taking into account memory distribution. The transformation is done in reciprocal
space therefore all the ug should be available. Wavefunctions in real space are then
obtained via FFT. The implementation assumes that the matrix associated to the
linear transformation is sparse (No BLAS-3 calls here).

INPUTS

Cryst<crystal_t>=Object defining the unit cell and its symmetries.
m_lda_to_qp(mband,mband,nkibz,nsppol)= expansion of the QP amplitudes in terms of KS wavefunctions.
[bmask(mband,nkibz,nsppol)]=The routine will raise an error if one band index
is not treated by any processor. bmask can be used to select the subset of
indices that are expected to be available.

m_wfd/wfd_sym_ur [ Functions ]

Wfd<wfd_t>=the wavefunction descriptor.
Cryst<crystal_t>=Structure describing the crystal structure and its symmetries.
Kmesh<kmesh_t>=Structure describing the BZ sampling
band=Band index.
ik_bz=Index of the k-point in the BZ.
spin=Spin index
[trans] = "N" if only the symmetried wavefunction is needed, "C" if the complex conjugate is required.
Default is "N"
[with_umklp] = Optional flag. If .True. (Default) the umklapp G0 vector in the relation kbz = Sk + G0
is taken into account when constructing u_kbz.

m_wfd/wfd_update_bkstab [ Functions ]

This routine should be called by all the nodes before any MPI operation involving the object.
It updates the bks_tab storing information on the distribution of ug.
INPUT
[show]=If present and > 0, print tabs to unit show.

m_wfd/wfd_wave_free [ Functions ]

mask(Wfd%mband,Wfd%nkibz,Wfd%nsppol)=.TRUE. if the memory allocated for
this state has to be freed
[what]=String specifying which array have to be deallocated.
Possible values (no case-sensitive).
"All"= To free both ug and ur and PAW Cprj, if any. Default
"G" = Only ug
"R" = Only ur.
"C" = Only PAW Cprj.