The Elk Code
 
Loading...
Searching...
No Matches
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
6subroutine effmass
7use modmain
8use modomp
9use modtest
10implicit none
11! local variables
12integer ik0,ik,ist,info
13integer i,j,k,l,m,n,nthd
14integer i1,i2,i3,j1,j2,j3
15real(8) d(3,3),em(3,3)
16real(8) v1(3),v2(3)
17real(8) w(3),work(9)
18! allocatable arrays
19integer, allocatable :: ipiv(:)
20real(8), allocatable :: a(:,:),b(:,:,:,:),c(:,:,:),evalfv(:,:)
21complex(8), allocatable :: evecfv(:,:,:),evecsv(:,:)
22! initialise universal variables
23call init0
24call init1
25allocate(ipiv(nkpt))
26allocate(a(nkpt,nkpt))
27n=2*ndspem+1
28allocate(b(0:n-1,0:n-1,0:n-1,nstsv))
29allocate(c(0:n-1,0:n-1,0:n-1))
30! read density and potentials from file
31call readstate
32! Fourier transform Kohn-Sham potential to G-space
33call genvsig
34! find the new linearisation energies
35call linengy
36! generate the APW and local-orbital radial functions and integrals
37call genapwlofr
38! generate the spin-orbit coupling radial functions
39call gensocfr
40ik0=0
41! begin parallel loop over k-points
42call 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)
47allocate(evalfv(nstfv,nspnfv))
48allocate(evecfv(nmatmax,nstfv,nspnfv))
49allocate(evecsv(nstsv,nstsv))
50!$OMP DO SCHEDULE(DYNAMIC)
51do 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
61end do
62!$OMP END DO
63deallocate(evalfv,evecfv,evecsv)
64!$OMP END PARALLEL
65call freethd(nthd)
66! set up polynomial matrix
67i=0
68do 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
91end do
92! solve for the polynomial coefficients
93call dgesv(nkpt,nstsv,a,nkpt,ipiv,b,nkpt,info)
94if (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
100end if
101open(50,file='EFFMASS.OUT',form='FORMATTED')
102write(50,*)
103write(50,'("(effective mass matrices are in Cartesian coordinates)")')
104write(50,*)
105write(50,'("k-point (lattice coordinates) :")')
106write(50,'(3G18.10)') vklem
107write(50,*)
108write(50,'("k-point (Cartesian coordinates) :")')
109call r3mv(bvec,vklem,v1)
110write(50,'(3G18.10)') v1
111! begin loop over states
112do 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
166end do
167close(50)
168write(*,*)
169write(*,'("Info(effmass):")')
170write(*,'(" Effective mass tensor for each state written to EFFMASS.OUT")')
171write(*,'(" for k-point (lattice) ",3G18.10)') vklem
172! write the effective mass eigenvalues of the last state to test file
173call writetest(25,'effective mass',nv=3,tol=1.d-5,rva=w)
174deallocate(ipiv,a,b,c)
175end subroutine
176
subroutine effmass
Definition effmass.f90:7
subroutine eveqn(ik, evalfv, evecfv, evecsv)
Definition eveqn.f90:10
subroutine genapwlofr
Definition genapwlofr.f90:7
subroutine gensocfr
Definition gensocfr.f90:7
subroutine genvsig
Definition genvsig.f90:10
subroutine init0
Definition init0.f90:10
subroutine init1
Definition init1.f90:10
subroutine linengy
Definition linengy.f90:10
real(8), dimension(3, 3) bvec
Definition modmain.f90:16
real(8) deltaem
Definition modmain.f90:481
integer, dimension(:,:), allocatable ivk
Definition modmain.f90:465
integer nkpt
Definition modmain.f90:461
integer nspnfv
Definition modmain.f90:289
integer nmatmax
Definition modmain.f90:848
integer nstsv
Definition modmain.f90:886
integer nstfv
Definition modmain.f90:884
real(8), dimension(3) vklem
Definition modmain.f90:479
real(8), dimension(:,:), allocatable evalsv
Definition modmain.f90:918
integer ndspem
Definition modmain.f90:483
subroutine holdthd(nloop, nthd)
Definition modomp.f90:78
subroutine freethd(nthd)
Definition modomp.f90:106
subroutine writetest(id, descr, nv, iv, iva, tol, rv, rva, zv, zva)
Definition modtest.f90:16
subroutine r3minv(a, b)
Definition r3minv.f90:10
pure subroutine r3mv(a, x, y)
Definition r3mv.f90:10
subroutine readstate
Definition readstate.f90:10