The Elk Code
 
Loading...
Searching...
No Matches
eliashberg.f90
Go to the documentation of this file.
1
2! Copyright (C) 2011 A. Sanna 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!BOP
7! !ROUTINE: eliashberg
8! !INTERFACE:
9subroutine eliashberg
10! !USES:
11use modmain
12use modphonon
13use modomp
14! !DESCRIPTION:
15! Calculates the superconducting gap within Eliashberg theory. This
16! implementation is isotropic and assumes a flat density of states. The
17! Eliashberg function $\alpha^2F$ is required as input for this calculation.
18!
19! !REVISION HISTORY:
20! Created December 2010 (Antonio Sanna)
21! Modified, June 2011 (JKD)
22!EOP
23!BOC
24implicit none
25! local variables
26! maximum allowed number of Matsubara frequencies
27integer, parameter :: maxwf=40000
28! maximum number of iterations
29integer, parameter :: maxit=1000
30integer nwf,nwfcl,nin,nout
31integer itemp,it,i,m,n,nthd
32! convergence tolerance
33real(8), parameter :: eps=1.d-12
34! mixing paramter
35real(8), parameter :: beta=0.5d0
36real(8) lambda,wlog,wrms,tc
37real(8) wfmax,tmin,tmax,dtemp,temp
38real(8) dw,dmu,sm,a,b,t0,t1
39! allocatable arrays
40real(8), allocatable :: w(:),a2f(:),wf(:),l(:)
41real(8), allocatable :: d0(:),d(:),z0(:),z(:),r(:)
42complex(8), allocatable :: zin(:),uin(:),zout(:),uout(:)
43! initialise universal variables
44call init0
45call init1
46allocate(w(nwplot),a2f(nwplot))
47! read in the Eliashberg function
48call readalpha2f(w,a2f)
49dw=(w(nwplot)-w(1))/dble(nwplot)
50! compute the McMillan parameters
51call mcmillan(w,a2f,lambda,wlog,wrms,tc)
52! Matsubara frequency cut-off
53wfmax=20.d0*wrms
54! minumum temperature
55tmin=tc/6.d0
56if (tmin < 1.d-2) tmin=0.1d0
57! maximum temperature
58tmax=5.d0*tc
59if (tmax < 1.d0) tmax=1.d0
60! temperature step size
61dtemp=(tmax-tmin)/dble(ntemp)
62! maximum number of fermionic Matsubara frequencies
63nwf=nint(wfmax/(twopi*kboltz*dtemp))
64if (nwf < 1) nwf=1
65if (nwf > maxwf) nwf=maxwf
66allocate(wf(-nwf:nwf))
67allocate(l(-2*nwf:2*nwf))
68allocate(d0(0:nwf),d(0:nwf))
69allocate(z0(0:nwf),z(0:nwf))
70allocate(r(0:nwf))
71allocate(zin(0:nwf),uin(0:nwf))
72! generate output points for continuation on the real axis
73nout=4*nwplot
74allocate(zout(nout),uout(nout))
75do i=1,nout
76 zout(i)=2.d0*dble(i-1)*dw
77end do
78! open files for writing
79open(62,file='ELIASHBERG.OUT',form='FORMATTED')
80open(63,file='ELIASHBERG_IA.OUT',form='FORMATTED')
81open(64,file='ELIASHBERG_GAP_T.OUT',form='FORMATTED')
82open(65,file='ELIASHBERG_GAP_RA.OUT',form='FORMATTED')
83open(66,file='ELIASHBERG_Z_RA.OUT',form='FORMATTED')
84call writebox(62,"Eliashberg equations")
85write(62,*)
86write(62,'("Temperature range : ",2G18.10)') tmin,tmax
87write(62,'("Number of temperature steps : ",I6)') ntemp
88write(62,'("Number of output frequencies : ",I8)') nout
89write(62,'("Fermionic Matsubara frequency cut-off")')
90write(62,'(" phonons : ",G18.10)') wfmax
91write(62,'(" Coulomb : ",G18.10)') 2.d0*wrms
92flush(62)
93d0(:)=1.d-4
94z0(:)=1.d0
95! main loop over temperature
96do itemp=1,ntemp
97 write(*,'("Info(eliashberg): temperature step ",I6," of ",I6)') itemp,ntemp
98 temp=dble(itemp)*dtemp+tmin
99 write(62,*)
100 write(62,'("Temperature (kelvin) : ",G18.10)') temp
101 t0=pi*kboltz*temp
102! number of Matsubara frequencies
103 nwf=nint(wfmax/(2.d0*t0))
104 if (nwf > maxwf) nwf=maxwf
105 nwfcl=nint(2.d0*wrms/(2.d0*t0))
106 if (nwfcl < 1) nwfcl=1
107 if (nwfcl > nwf) nwfcl=nwf
108 write(62,'("Number of Matsubara frequencies")')
109 write(62,'(" phonons : ",I8)') nwf
110 write(62,'(" Coulomb : ",I8)') nwfcl
111! make Pade approximant input points same as Matsubara frequencies
112 nin=nwf
113! generate fermionic Matsubara frequencies
114 do m=-nwf,nwf
115 wf(m)=t0*dble(2*m+1)
116 end do
117! compute lambda
118 call holdthd(4*nwf+1,nthd)
119!$OMP PARALLEL DO DEFAULT(SHARED) &
120!$OMP PRIVATE(t1,sm,i) &
121!$OMP SCHEDULE(DYNAMIC) &
122!$OMP NUM_THREADS(nthd)
123 do m=-2*nwf,2*nwf
124 t1=(t0*dble(2*m))**2
125 sm=0.d0
126 do i=1,nwplot
127 sm=sm+w(i)*a2f(i)/(w(i)**2+t1)
128 end do
129 l(m)=2.d0*sm*dw
130 end do
131!$OMP END PARALLEL DO
132 call freethd(nthd)
133! begin iteration loop
134 do it=1,maxit
135 do m=0,nwf
136 r(m)=sqrt((wf(m)**2+d0(m)**2)*z0(m)**2)
137 end do
138 do n=0,nwf
139 sm=0.d0
140 do m=0,nwf-1
141 sm=sm+(l(n-m)-l(n+m+1))*z0(m)*wf(m)/r(m)
142 end do
143 z(n)=t0*sm/wf(n)
144 end do
145 z(0:nwf)=z(0:nwf)+1.d0
146 z0(0:nwf)=z(0:nwf)
147! Coulomb part of summation
148 dmu=0.d0
149 do n=0,nwfcl
150 dmu=dmu+mustar*d0(n)*z(n)/r(n)
151 end do
152 dmu=dmu*2.d0
153! Gap
154 do n=0,nwf
155 sm=0.d0
156 do m=0,nwf-1
157 sm=sm+(l(n-m)+l(n+m+1))*d0(m)*z(m)/r(m)
158 end do
159 d(n)=t0*(sm-dmu)/z(n)
160 end do
161! mix old and new gap functions
162 d(0:nwf)=beta*d(0:nwf)+(1.d0-beta)*d0(0:nwf)
163 sm=0.d0
164 do m=0,nwf
165 sm=sm+abs(d0(m)-d(m))
166 end do
167 sm=sm/dble(2*nwf)
168 d0(0:nwf)=d(0:nwf)
169 if (sm <= eps) then
170 write(62,'("Eliashberg equations converged in ",I6," iterations")') it
171 goto 10
172 end if
173! end iteration loop
174 end do
175 write(*,*)
176 write(*,'("Warning(eliashberg): failed to converge: possibly close to T_c")')
177 write(62,'("Failed to converge: possibly close to T_c")')
17810 continue
179 flush(62)
180 do n=-nwf,nwf
181 if (n >= 0) then
182 m=n
183 else
184 m=-n-1
185 end if
186 write(63,'(3G18.10)') wf(n),d(m),z(m)
187 end do
188 write(63,*)
189 flush(63)
190 write(64,'(3G18.10)') temp,d(0),z(0)
191 flush(64)
192! analytic continuation to real axis
193 do m=0,nin
194 zin(m)=cmplx(0.d0,wf(m),8)
195 uin(m)=d(m)
196 end do
197 call pade(nin,zin,uin,nout,zout,uout)
198 do i=1,nout
199 a=dble(uout(i))
200 b=aimag(uout(i))
201 write(65,'(3G18.10)') dble(zout(i)),a,b
202 end do
203 write(65,*)
204 flush(65)
205 do m=0,nin
206 uin(m)=z(m)
207 end do
208 call pade(nin,zin,uin,nout,zout,uout)
209 do i=1,nout
210 a=dble(uout(i))
211 b=aimag(uout(i))
212 write(66,'(3G18.10)') dble(zout(i)),a,b
213 end do
214 write(66,*)
215 flush(66)
216! end loop over temperatures
217end do
218close(62); close(63); close(64); close(65); close(66)
219write(*,*)
220write(*,'("Info(eliashberg):")')
221write(*,'(" calculation information written to ELIASHBERG.OUT")')
222write(*,'(" gap and Z functions on the imaginary axis written to &
223 &ELIASHBERG_IA.OUT")')
224write(*,'(" gap vs. temperature written to ELIASHBERG_GAP_T.OUT")')
225write(*,'(" gap function on the real axis written to ELIASHBERG_GAP_RA.OUT")')
226write(*,'(" Z function on the real axis written to ELIASHBERG_Z_RA.OUT")')
227deallocate(w,a2f,wf,l)
228deallocate(d0,d,z0,z,r)
229deallocate(zin,uin,zout,uout)
230end subroutine
231!EOC
232
subroutine eliashberg
subroutine init0
Definition init0.f90:10
subroutine init1
Definition init1.f90:10
subroutine mcmillan(w, a2f, lambda, wlog, wrms, tc)
Definition mcmillan.f90:7
real(8), parameter pi
Definition modmain.f90:1229
integer nwplot
Definition modmain.f90:1070
real(8), parameter twopi
Definition modmain.f90:1230
real(8), parameter kboltz
Definition modmain.f90:1262
subroutine holdthd(nloop, nthd)
Definition modomp.f90:78
subroutine freethd(nthd)
Definition modomp.f90:106
integer ntemp
Definition modphonon.f90:25
real(8) mustar
Definition modphonon.f90:23
pure subroutine pade(ni, zi, ui, no, zo, uo)
Definition pade.f90:10
subroutine readalpha2f(w, a2f)
subroutine writebox(fnum, str)
Definition writebox.f90:7