The Elk Code
chargeu.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2019 T. Mueller, J. K. Dewhurst, S. Sharma and E. K. U. Gross.
3 ! This file is distributed under the terms of the GNU General Public License.
4 ! See the file COPYING for license details.
5 
6 subroutine chargeu
7 use modmain
8 use modulr
9 use modtest
10 implicit none
11 ! local variables
12 integer is,ias,nrc,nrci,ifq,ir
13 real(8) t1
14 ! automatic arrays
15 real(8) rfft(nqpt)
16 complex(8) zfft(nfqrz)
17 ! external functions
18 complex(8), external :: zfmtint
19 ! calculate muffin-tin charges
20 chgmttot=0.d0
21 do ias=1,natmtot
22  is=idxis(ias)
23  nrc=nrcmt(is)
24  nrci=nrcmti(is)
25  do ifq=1,nfqrz
26  zfft(ifq)=zfmtint(nrc,nrci,wr2cmt(:,is),rhoqmt(:,ias,ifq))
27  end do
28  chgmt(ias)=zfft(1)%re
30  call rzfftifc(3,ngridq,1,rfft,zfft)
31  chgmtru(ias,1:nqpt)=rfft(1:nqpt)
32 ! store the muffin-tin charges in Q-space
33  chgmtqu(ias,1:nfqrz)=zfft(1:nfqrz)
34 end do
35 ! calculate interstitial and total charges
36 t1=omega/ngtc
37 do ifq=1,nfqrz
38  zfft(ifq)=t1*sum(rhoqir(1:ngtc,ifq)*cfrc(1:ngtc))
39 end do
40 chgir=zfft(1)%re
42 call rzfftifc(3,ngridq,1,rfft,zfft)
43 do ir=1,nqpt
44  chgirru(ir)=rfft(ir)
45  chgtotru(ir)=sum(chgmtru(1:natmtot,ir))+chgirru(ir)
46 end do
47 ! store the interstitial charge in Q-space
48 chgirqu(1:nfqrz)=zfft(1:nfqrz)
49 ! store the total charge in Q-space
50 do ifq=1,nfqrz
51  chgtotqu(ifq)=sum(chgmtqu(1:natmtot,ifq))+chgirqu(ifq)
52 end do
53 ! write muffin-tin charges to file
54 call writetest(730,'ULR total charges',nv=nqpt,tol=5.d-5,rva=chgtotru)
55 end subroutine
56 
subroutine writetest(id, descr, nv, iv, iva, tol, rv, rva, zv, zva)
Definition: modtest.f90:16
integer ngtc
Definition: modmain.f90:395
real(8) omega
Definition: modmain.f90:20
real(8), dimension(:), allocatable chgmt
Definition: modmain.f90:735
complex(8), dimension(:), allocatable chgirqu
Definition: modulr.f90:62
complex(8), dimension(:,:), allocatable chgmtqu
Definition: modulr.f90:62
subroutine chargeu
Definition: chargeu.f90:7
real(8), dimension(:,:), allocatable chgmtru
Definition: modulr.f90:55
real(8) chgir
Definition: modmain.f90:733
integer, dimension(3) ngridq
Definition: modmain.f90:518
real(8) chgcalc
Definition: modmain.f90:731
real(8) chgmttot
Definition: modmain.f90:737
real(8), dimension(:,:), allocatable wr2cmt
Definition: modmain.f90:191
integer, dimension(maxatoms *maxspecies) idxis
Definition: modmain.f90:44
complex(8), dimension(:,:,:), allocatable rhoqmt
Definition: modulr.f90:59
subroutine rzfftifc(nd, n, sgn, r, z)
integer natmtot
Definition: modmain.f90:40
real(8), dimension(:), allocatable cfrc
Definition: modmain.f90:441
integer, dimension(maxspecies) nrcmt
Definition: modmain.f90:175
integer, dimension(maxspecies) nrcmti
Definition: modmain.f90:213
Definition: modulr.f90:6
real(8), dimension(:), allocatable chgtotru
Definition: modulr.f90:55
real(8), dimension(:), allocatable chgirru
Definition: modulr.f90:55
complex(8), dimension(:), allocatable chgtotqu
Definition: modulr.f90:62
complex(8), dimension(:,:), allocatable rhoqir
Definition: modulr.f90:59