The Elk Code
phscdvs.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2008 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl.
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 phscdvs(p,vsmt0,vsir0)
7 use modmain
8 use modphonon
9 implicit none
10 ! arguments
11 integer, intent(in) :: p
12 real(8), intent(in) :: vsmt0(npmtmax,natmtot),vsir0(ngtot)
13 ! local variables
14 integer is,ia,ja,ias,jas
15 integer nr,nri,np,i
16 integer iv(3),ig0,ifg0,ifg
17 real(8) vl(3),vc(3),t1
18 complex(8) z0,z1,z2
19 ! allocatable arrays
20 real(8), allocatable :: rfmt(:)
21 complex(8), allocatable :: zfmt(:),zfir(:)
22 ! prefactor
23 z0=1.d0/deltaph
24 ! multiply by i for sin-like displacement
25 if (p == 1) z0=z0*zi
26 !------------------------------!
27 ! muffin-tin potential !
28 !------------------------------!
29 allocate(rfmt(npmtmax),zfmt(npmtmax))
30 z1=z0/dble(nscph)
31 ias=0
32 jas=0
33 do is=1,nspecies
34  nr=nrmt(is)
35  nri=nrmti(is)
36  np=npmt(is)
37  ja=0
38  do ia=1,natoms0(is)
39  ias=ias+1
40  do i=1,nscph
41  ja=ja+1
42  jas=jas+1
43 ! compute the difference between the perturbed and unperturbed potentials
44  rfmt(1:np)=vsmt(1:np,jas)-vsmt0(1:np,jas)
45 ! convert real potential difference to a complex spherical harmonic expansion
46  call rtozfmt(nr,nri,rfmt,zfmt)
47 ! the muffin-tin potential should have an *explicit* phase exp(iq.r)
48  t1=-dot_product(vqc(:,iqph),vscph(:,i))
49  z2=z1*cmplx(cos(t1),sin(t1),8)
50 ! add to total
51  dvsmt(1:np,ias)=dvsmt(1:np,ias)+z2*zfmt(1:np)
52  end do
53 ! end loop over atoms and species
54  end do
55 end do
56 deallocate(rfmt,zfmt)
57 !--------------------------------!
58 ! interstitial potential !
59 !--------------------------------!
60 ! Fourier transform interstitial potential derivative to G-space
61 allocate(zfir(ngtot))
62 zfir(1:ngtot)=z0*(vsir(1:ngtot)-vsir0(1:ngtot))
63 call zfftifc(3,ngridg,-1,zfir)
64 ! convert to G+q-space
65 do ig0=1,ngtot0
66  ifg0=igfft0(ig0)
67  vl(1:3)=dble(ivg0(1:3,ig0))+vql(1:3,iqph)
68  call r3mv(bvec0,vl,vc)
69  call r3mv(binv,vc,vl)
70  iv(1:3)=nint(vl(1:3))
71  if ((iv(1) >= intgv(1,1)).and.(iv(1) <= intgv(2,1)).and. &
72  (iv(2) >= intgv(1,2)).and.(iv(2) <= intgv(2,2)).and. &
73  (iv(3) >= intgv(1,3)).and.(iv(3) <= intgv(2,3))) then
74  ifg=igfft(ivgig(iv(1),iv(2),iv(3)))
75  dvsir(ifg0)=dvsir(ifg0)+zfir(ifg)
76  else
77  dvsir(ifg0)=0.d0
78  end if
79 end do
80 ! Fourier transform back to real-space
81 if (p == 1) call zfftifc(3,ngridg0,1,dvsir)
82 deallocate(zfir)
83 end subroutine
84 
subroutine phscdvs(p, vsmt0, vsir0)
Definition: phscdvs.f90:7
integer, dimension(3) ngridg
Definition: modmain.f90:386
complex(8), dimension(:), allocatable dvsir
Definition: modphonon.f90:112
integer, dimension(maxspecies) npmt
Definition: modmain.f90:213
integer, dimension(:,:,:), allocatable ivgig
Definition: modmain.f90:402
pure subroutine rtozfmt(nr, nri, rfmt, zfmt)
Definition: rtozfmt.f90:7
real(8), dimension(:), allocatable vsir
Definition: modmain.f90:651
real(8), dimension(3, 3) bvec0
Definition: modmain.f90:16
real(8), dimension(:,:), allocatable vscph
Definition: modphonon.f90:46
real(8), dimension(:,:), allocatable vqc
Definition: modmain.f90:547
subroutine zfftifc(nd, n, sgn, z)
Definition: zfftifc_fftw.f90:7
integer, dimension(:), allocatable igfft
Definition: modmain.f90:406
complex(8), dimension(:,:), pointer, contiguous dvsmt
Definition: modphonon.f90:110
real(8), dimension(:,:), allocatable vql
Definition: modmain.f90:545
integer, dimension(2, 3) intgv
Definition: modmain.f90:394
real(8), dimension(3, 3) binv
Definition: modmain.f90:18
integer ngtot0
Definition: modmain.f90:390
integer, dimension(:,:), allocatable ivg0
Definition: modmain.f90:400
integer, dimension(3) ngridg0
Definition: modmain.f90:386
integer iqph
Definition: modphonon.f90:15
integer nspecies
Definition: modmain.f90:34
complex(8), parameter zi
Definition: modmain.f90:1240
integer, dimension(:), allocatable igfft0
Definition: modmain.f90:406
pure subroutine r3mv(a, x, y)
Definition: r3mv.f90:10
real(8), dimension(:,:), pointer, contiguous vsmt
Definition: modmain.f90:649
integer, dimension(maxspecies) nrmti
Definition: modmain.f90:211
integer, dimension(maxspecies) natoms0
Definition: modmain.f90:36
real(8) deltaph
Definition: modphonon.f90:48
integer nscph
Definition: modphonon.f90:44
integer, dimension(maxspecies) nrmt
Definition: modmain.f90:150