The Elk Code
potcoulu.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2018 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 potcoulu
7 use modmain
8 use modulr
9 use modmpi
10 use modomp
11 implicit none
12 ! local variables
13 integer ifq,is,ias
14 integer nr,nri,ir
15 integer nrc,nrci,i
16 integer n,lp,nthd
17 ! allocatable arrays
18 complex(8), allocatable :: zrhomt(:,:),zrhoir(:),zvclmt(:,:)
19 call holdthd(nfqrz/np_mpi,nthd)
20 !$OMP PARALLEL DEFAULT(SHARED) &
21 !$OMP PRIVATE(zrhomt,zrhoir,zvclmt) &
22 !$OMP PRIVATE(ias,is,nr,nri) &
23 !$OMP PRIVATE(i,ir,nrc,nrci) &
24 !$OMP NUM_THREADS(nthd)
25 allocate(zrhomt(npmtmax,natmtot),zrhoir(ngtot))
26 allocate(zvclmt(npmtmax,natmtot))
27 !$OMP DO SCHEDULE(DYNAMIC)
28 do ifq=1,nfqrz
29 ! distribute among MPI processes
30  if (mod(ifq-1,np_mpi) /= lp_mpi) cycle
31 ! convert the complex muffin-tin density from coarse to fine radial mesh
32  do ias=1,natmtot
33  is=idxis(ias)
34  zrhomt(1:npcmt(is),ias)=rhoqmt(1:npcmt(is),ias,ifq)
35  end do
36  call zfmtctof(zrhomt)
37 ! solve the complex Poisson's equation in the muffin-tins
38  call genzvclmt(nrmt,nrmti,nrmtmax,rlmt,wprmt,npmtmax,zrhomt,zvclmt)
39 ! add the nuclear monopole potentials for Q=0
40  if (ifq == 1) then
41  do ias=1,natmtot
42  is=idxis(ias)
43  nr=nrmt(is)
44  nri=nrmti(is)
45  i=1
46  do ir=1,nri
47  zvclmt(i,ias)=zvclmt(i,ias)+vcln(ir,is)
48  i=i+lmmaxi
49  end do
50  do ir=nri+1,nr
51  zvclmt(i,ias)=zvclmt(i,ias)+vcln(ir,is)
52  i=i+lmmaxo
53  end do
54  end do
55  end if
56 ! convert the interstitial density from coarse to fine grid
57  call zfirctof(rhoqir(:,ifq),zrhoir)
58 ! solve Poisson's equation in the entire unit cell
60  gclgq(:,ifq),ngvec,jlgqrmt(:,:,:,ifq),ylmgq(:,:,ifq),sfacgq(:,:,ifq),zrhoir,&
61  npmtmax,zvclmt,vsqir(:,ifq))
62  do ias=1,natmtot
63  is=idxis(ias)
64  nrc=nrcmt(is)
65  nrci=nrcmti(is)
66 ! convert from fine to coarse radial mesh
67  call zfmtftoc(nrc,nrci,zvclmt(:,ias),vsqmt(:,ias,ifq))
68 ! convert to spherical coordinates
69  call zbshtip(nrc,nrci,vsqmt(:,ias,ifq))
70  end do
71 end do
72 !$OMP END DO
73 deallocate(zrhomt,zrhoir,zvclmt)
74 !$OMP END PARALLEL
75 call freethd(nthd)
76 ! broadcast potentials to every MPI process
77 if (np_mpi > 1) then
79  do ifq=1,nfqrz
80  lp=mod(ifq-1,np_mpi)
81  call mpi_bcast(vsqmt(:,:,ifq),n,mpi_double_complex,lp,mpicom,ierror)
82  end do
83  do ifq=1,nfqrz
84  lp=mod(ifq-1,np_mpi)
85  call mpi_bcast(vsqir(:,ifq),ngtot,mpi_double_complex,lp,mpicom,ierror)
86  end do
87 end if
88 end subroutine
89 
subroutine zfmtctof(zfmt)
Definition: zfmtctof.f90:7
complex(8), dimension(:,:,:), pointer, contiguous vsqmt
Definition: modulr.f90:84
complex(8), dimension(:,:,:), allocatable sfacgq
Definition: modulr.f90:44
real(8), dimension(:,:,:,:), allocatable jlgqrmt
Definition: modulr.f90:40
integer, dimension(maxspecies) npcmt
Definition: modmain.f90:214
integer npcmtmax
Definition: modmain.f90:216
integer, dimension(3) ngridg
Definition: modmain.f90:386
integer ngtot
Definition: modmain.f90:390
integer lmmaxo
Definition: modmain.f90:203
subroutine zpotcoul(iash, nrmt_, nrmti_, npmt_, ld1, rl, ngridg_, igfft_, ngp, gpc, gclgp, ld2, jlgprmt, ylmgp, sfacgp, zrhoir, ld3, zvclmt, zvclir)
Definition: zpotcoul.f90:11
complex(8), dimension(:,:), pointer, contiguous vsqir
Definition: modulr.f90:84
real(8), dimension(:,:), allocatable vcln
Definition: modmain.f90:97
real(8), dimension(:,:,:), allocatable rlmt
Definition: modmain.f90:179
integer, dimension(maxspecies) npmt
Definition: modmain.f90:213
Definition: modomp.f90:6
integer np_mpi
Definition: modmpi.f90:13
integer, dimension(:), allocatable igfft
Definition: modmain.f90:406
subroutine potcoulu
Definition: potcoulu.f90:7
subroutine zbshtip(nr, nri, zfmt)
Definition: zbshtip.f90:7
pure subroutine zfmtftoc(nrc, nrci, zfmt, zfcmt)
Definition: zfmtftoc.f90:7
integer ngvec
Definition: modmain.f90:396
complex(8), dimension(:,:,:), allocatable ylmgq
Definition: modulr.f90:42
subroutine genzvclmt(nrmt_, nrmti_, ld1, rl, wpr, ld2, zrhomt, zvclmt)
Definition: genzvclmt.f90:7
integer, dimension(maxatoms *maxspecies) idxis
Definition: modmain.f90:44
real(8), dimension(:,:), allocatable gqc
Definition: modulr.f90:36
integer lmmaxi
Definition: modmain.f90:207
integer nfqrz
Definition: modmain.f90:539
Definition: modmpi.f90:6
subroutine zfirctof(zfirc, zfir)
Definition: zfirctof.f90:7
integer lp_mpi
Definition: modmpi.f90:15
complex(8), dimension(:,:,:), allocatable rhoqmt
Definition: modulr.f90:60
subroutine freethd(nthd)
Definition: modomp.f90:106
subroutine holdthd(nloop, nthd)
Definition: modomp.f90:78
integer npmtmax
Definition: modmain.f90:216
integer natmtot
Definition: modmain.f90:40
real(8), dimension(:,:,:), allocatable wprmt
Definition: modmain.f90:185
real(8), dimension(:,:), allocatable gclgq
Definition: modulr.f90:38
integer, dimension(maxspecies) nrcmt
Definition: modmain.f90:173
integer, dimension(maxspecies) nrcmti
Definition: modmain.f90:211
Definition: modulr.f90:6
integer nrmtmax
Definition: modmain.f90:152
integer, dimension(maxspecies) nrmti
Definition: modmain.f90:211
integer mpicom
Definition: modmpi.f90:11
integer ierror
Definition: modmpi.f90:19
integer, dimension(maxspecies) nrmt
Definition: modmain.f90:150
complex(8), dimension(:,:), allocatable rhoqir
Definition: modulr.f90:60