The Elk Code
effmass.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2002-2005 J. K. Dewhurst and S. Sharma.
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 effmass
7 use modmain
8 use modomp
9 use modtest
10 implicit none
11 ! local variables
12 integer ik0,ik,ist,info
13 integer i,j,k,l,m,n,nthd
14 integer i1,i2,i3,j1,j2,j3
15 real(8) d(3,3),em(3,3)
16 real(8) v1(3),v2(3)
17 real(8) w(3),work(9)
18 ! allocatable arrays
19 integer, allocatable :: ipiv(:)
20 real(8), allocatable :: a(:,:),b(:,:,:,:),c(:,:,:),evalfv(:,:)
21 complex(8), allocatable :: evecfv(:,:,:),evecsv(:,:)
22 ! initialise universal variables
23 call init0
24 call init1
25 allocate(ipiv(nkpt))
26 allocate(a(nkpt,nkpt))
27 n=2*ndspem+1
28 allocate(b(0:n-1,0:n-1,0:n-1,nstsv))
29 allocate(c(0:n-1,0:n-1,0:n-1))
30 ! read density and potentials from file
31 call readstate
32 ! Fourier transform Kohn-Sham potential to G-space
33 call genvsig
34 ! find the new linearisation energies
35 call linengy
36 ! generate the APW and local-orbital radial functions and integrals
37 call genapwlofr
38 ! generate the spin-orbit coupling radial functions
39 call gensocfr
40 ik0=0
41 ! begin parallel loop over k-points
42 call holdthd(nkpt,nthd)
43 !$OMP PARALLEL DEFAULT(SHARED) &
44 !$OMP PRIVATE(evalfv,evecfv,evecsv) &
45 !$OMP PRIVATE(i1,i2,i3,j1,j2,j3,ist) &
46 !$OMP NUM_THREADS(nthd)
47 allocate(evalfv(nstfv,nspnfv))
48 allocate(evecfv(nmatmax,nstfv,nspnfv))
49 allocate(evecsv(nstsv,nstsv))
50 !$OMP DO SCHEDULE(DYNAMIC)
51 do ik=1,nkpt
52  i1=ivk(1,ik); i2=ivk(2,ik); i3=ivk(3,ik)
53  if ((i1 == 0).and.(i2 == 0).and.(i3 == 0)) ik0=ik
54 ! solve the first- and second-variational eigenvalue equations
55  call eveqn(ik,evalfv,evecfv,evecsv)
56 ! copy eigenvalues to new array
57  j1=i1+ndspem; j2=i2+ndspem; j3=i3+ndspem
58  do ist=1,nstsv
59  b(j1,j2,j3,ist)=evalsv(ist,ik)
60  end do
61 end do
62 !$OMP END DO
63 deallocate(evalfv,evecfv,evecsv)
64 !$OMP END PARALLEL
65 call freethd(nthd)
66 ! set up polynomial matrix
67 i=0
68 do i3=-ndspem,ndspem
69  do i2=-ndspem,ndspem
70  do i1=-ndspem,ndspem
71  i=i+1
72  v1(1)=dble(i1); v1(2)=dble(i2); v1(3)=dble(i3)
73  v1(:)=v1(:)*deltaem
74  j=0
75  v2(3)=1.d0
76  do j3=0,n-1
77  v2(2)=1.d0
78  do j2=0,n-1
79  v2(1)=1.d0
80  do j1=0,n-1
81  j=j+1
82  a(i,j)=v2(1)*v2(2)*v2(3)
83  v2(1)=v2(1)*v1(1)
84  end do
85  v2(2)=v2(2)*v1(2)
86  end do
87  v2(3)=v2(3)*v1(3)
88  end do
89  end do
90  end do
91 end do
92 ! solve for the polynomial coefficients
93 call dgesv(nkpt,nstsv,a,nkpt,ipiv,b,nkpt,info)
94 if (info /= 0) then
95  write(*,*)
96  write(*,'("Error(effmass): could not determine polynomial coefficients")')
97  write(*,'(" DGESV returned INFO = ",I8)') info
98  write(*,*)
99  stop
100 end if
101 open(50,file='EFFMASS.OUT',form='FORMATTED')
102 write(50,*)
103 write(50,'("(effective mass matrices are in Cartesian coordinates)")')
104 write(50,*)
105 write(50,'("k-point (lattice coordinates) :")')
106 write(50,'(3G18.10)') vklem
107 write(50,*)
108 write(50,'("k-point (Cartesian coordinates) :")')
109 call r3mv(bvec,vklem,v1)
110 write(50,'(3G18.10)') v1
111 ! begin loop over states
112 do ist=1,nstsv
113 ! compute matrix of derivatives with respect to k-vector
114  do k=1,3
115  do l=1,3
116  c(:,:,:)=b(:,:,:,ist)
117  do i=1,2
118  if (i == 1) then
119  m=k
120  else
121  m=l
122  end if
123  if (m == 1) then
124  do j=0,n-2
125  c(j,:,:)=dble(j+1)*c(j+1,:,:)
126  end do
127  c(n-1,:,:)=0.d0
128  else if (m == 2) then
129  do j=0,n-2
130  c(:,j,:)=dble(j+1)*c(:,j+1,:)
131  end do
132  c(:,n-1,:)=0.d0
133  else if (m == 3) then
134  do j=0,n-2
135  c(:,:,j)=dble(j+1)*c(:,:,j+1)
136  end do
137  c(:,:,n-1)=0.d0
138  end if
139  end do
140 ! derivative evaluated at zero
141  d(k,l)=c(0,0,0)
142  end do
143  end do
144  write(50,*)
145  write(50,*)
146  write(50,'("State, eigenvalue : ",I6,G18.10)') ist,evalsv(ist,ik0)
147  write(50,*)
148  write(50,'(" matrix of eigenvalue derivatives with respect to k :")')
149  do i=1,3
150  write(50,'(3G18.10)') (d(i,j),j=1,3)
151  end do
152  write(50,'(" trace : ",G18.10)') d(1,1)+d(2,2)+d(3,3)
153 ! invert derivative matrix
154  call r3minv(d,em)
155  write(50,*)
156  write(50,'(" effective mass tensor (inverse of derivative matrix) :")')
157  do i=1,3
158  write(50,'(3G18.10)') (em(i,j),j=1,3)
159  end do
160  write(50,'(" trace : ",G18.10)') em(1,1)+em(2,2)+em(3,3)
161 ! find the eigenvalues
162  call dsyev('N','U',3,em,3,w,work,9,info)
163  write(50,'(" eigenvalues :")')
164  write(50,'(3G18.10)') w
165 ! end loop over states
166 end do
167 close(50)
168 write(*,*)
169 write(*,'("Info(effmass):")')
170 write(*,'(" Effective mass tensor for each state written to EFFMASS.OUT")')
171 write(*,'(" for k-point (lattice) ",3G18.10)') vklem
172 ! write the effective mass eigenvalues of the last state to test file
173 call writetest(25,'effective mass',nv=3,tol=1.d-5,rva=w)
174 deallocate(ipiv,a,b,c)
175 end subroutine
176 
integer nmatmax
Definition: modmain.f90:853
subroutine writetest(id, descr, nv, iv, iva, tol, rv, rva, zv, zva)
Definition: modtest.f90:16
real(8), dimension(:,:), allocatable evalsv
Definition: modmain.f90:921
integer nkpt
Definition: modmain.f90:461
subroutine r3minv(a, b)
Definition: r3minv.f90:10
Definition: modomp.f90:6
subroutine genvsig
Definition: genvsig.f90:10
subroutine genapwlofr
Definition: genapwlofr.f90:7
subroutine effmass
Definition: effmass.f90:7
subroutine gensocfr
Definition: gensocfr.f90:7
subroutine linengy
Definition: linengy.f90:10
integer nstsv
Definition: modmain.f90:889
subroutine eveqn(ik, evalfv, evecfv, evecsv)
Definition: eveqn.f90:10
real(8) deltaem
Definition: modmain.f90:481
real(8), dimension(3, 3) bvec
Definition: modmain.f90:16
subroutine init1
Definition: init1.f90:10
integer ndspem
Definition: modmain.f90:483
subroutine readstate
Definition: readstate.f90:10
subroutine freethd(nthd)
Definition: modomp.f90:106
subroutine holdthd(nloop, nthd)
Definition: modomp.f90:78
subroutine init0
Definition: init0.f90:10
pure subroutine r3mv(a, x, y)
Definition: r3mv.f90:10
integer nstfv
Definition: modmain.f90:887
real(8), dimension(3) vklem
Definition: modmain.f90:479
integer, dimension(:,:), allocatable ivk
Definition: modmain.f90:465
integer nspnfv
Definition: modmain.f90:289