The Elk Code
 
Loading...
Searching...
No Matches
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
6subroutine potcoulu
7use modmain
8use modulr
9use modmpi
10use modomp
11implicit none
12! local variables
13integer ifq,is,ias
14integer nr,nri,ir
15integer nrc,nrci,i
16integer n,lp,nthd
17! allocatable arrays
18complex(8), allocatable :: zrhomt(:,:),zrhoir(:),zvclmt(:,:)
19call 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)
25allocate(zrhomt(npmtmax,natmtot),zrhoir(ngtot))
26allocate(zvclmt(npmtmax,natmtot))
27!$OMP DO SCHEDULE(DYNAMIC)
28do 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
71end do
72!$OMP END DO
73deallocate(zrhomt,zrhoir,zvclmt)
74!$OMP END PARALLEL
75call freethd(nthd)
76! broadcast potentials to every MPI process
77if (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
87end if
88end subroutine
89
subroutine genzvclmt(nrmt_, nrmti_, ld1, rl, wpr, ld2, zrhomt, zvclmt)
Definition genzvclmt.f90:7
integer, dimension(maxspecies) nrmti
Definition modmain.f90:211
integer ngtot
Definition modmain.f90:390
integer, dimension(3) ngridg
Definition modmain.f90:386
integer nfqrz
Definition modmain.f90:539
integer, dimension(maxspecies) nrmt
Definition modmain.f90:150
integer lmmaxi
Definition modmain.f90:207
integer ngvec
Definition modmain.f90:396
integer, dimension(maxspecies) nrcmt
Definition modmain.f90:173
integer, dimension(maxatoms *maxspecies) idxis
Definition modmain.f90:44
integer natmtot
Definition modmain.f90:40
integer npcmtmax
Definition modmain.f90:216
integer, dimension(maxspecies) npcmt
Definition modmain.f90:214
integer, dimension(:), allocatable igfft
Definition modmain.f90:406
real(8), dimension(:,:,:), allocatable wprmt
Definition modmain.f90:185
integer npmtmax
Definition modmain.f90:216
integer, dimension(maxspecies) npmt
Definition modmain.f90:213
real(8), dimension(:,:), allocatable vcln
Definition modmain.f90:97
integer nrmtmax
Definition modmain.f90:152
integer lmmaxo
Definition modmain.f90:203
integer, dimension(maxspecies) nrcmti
Definition modmain.f90:211
real(8), dimension(:,:,:), allocatable rlmt
Definition modmain.f90:179
integer lp_mpi
Definition modmpi.f90:15
integer ierror
Definition modmpi.f90:19
integer mpicom
Definition modmpi.f90:11
integer np_mpi
Definition modmpi.f90:13
subroutine holdthd(nloop, nthd)
Definition modomp.f90:78
subroutine freethd(nthd)
Definition modomp.f90:106
complex(8), dimension(:,:,:), pointer, contiguous vsqmt
Definition modulr.f90:83
complex(8), dimension(:,:,:), allocatable rhoqmt
Definition modulr.f90:59
real(8), dimension(:,:,:,:), allocatable jlgqrmt
Definition modulr.f90:40
real(8), dimension(:,:), allocatable gqc
Definition modulr.f90:36
complex(8), dimension(:,:), pointer, contiguous vsqir
Definition modulr.f90:83
complex(8), dimension(:,:,:), allocatable ylmgq
Definition modulr.f90:42
complex(8), dimension(:,:,:), allocatable sfacgq
Definition modulr.f90:44
real(8), dimension(:,:), allocatable gclgq
Definition modulr.f90:38
complex(8), dimension(:,:), allocatable rhoqir
Definition modulr.f90:59
subroutine potcoulu
Definition potcoulu.f90:7
subroutine zbshtip(nr, nri, zfmt)
Definition zbshtip.f90:7
subroutine zfirctof(zfirc, zfir)
Definition zfirctof.f90:7
subroutine zfmtctof(zfmt)
Definition zfmtctof.f90:7
pure subroutine zfmtftoc(nrc, nrci, zfmt, zfcmt)
Definition zfmtftoc.f90:7
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