The Elk Code
phdos.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2002-2005 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 phdos
7 use modmain
8 use modphonon
9 use modtest
10 implicit none
11 ! local variables
12 integer iq,i,iw
13 integer i1,i2,i3
14 real(8) wmin,wmax,wd,dw
15 real(8) tmax,temp(ntemp),s(ntemp)
16 real(8) v(3),t1,t2
17 ! allocatable arrays
18 real(8), allocatable :: wq(:),w(:),gw(:),f(:)
19 complex(8), allocatable :: dq(:,:),ev(:,:)
20 ! external functions
21 real(8), external :: splint
22 ! initialise universal variables
23 call init0
24 call init2
25 call initph
26 allocate(wq(nbph),w(nwplot),gw(nwplot),f(nwplot))
27 allocate(dq(nbph,nbph),ev(nbph,nbph))
28 ! find the minimum and maximum frequencies
29 wmin=0.d0
30 wmax=0.d0
31 do iq=1,nqpt
32  call dynev(dynq(:,:,iq),wq,ev)
33  wmin=min(wmin,wq(1))
34  wmax=max(wmax,wq(nbph))
35 end do
36 t1=(wmax-wmin)*0.1d0
37 wmin=wmin-t1
38 wmax=wmax+t1
39 wd=wmax-wmin
40 if (wd < 1.d-8) wd=1.d0
41 dw=wd/dble(nwplot)
42 ! generate energy grid
43 do iw=1,nwplot
44  w(iw)=dw*dble(iw-1)+wmin
45 end do
46 gw(:)=0.d0
47 do i1=0,ngrkf-1
48  v(1)=dble(i1)/dble(ngrkf)
49  do i2=0,ngrkf-1
50  v(2)=dble(i2)/dble(ngrkf)
51  do i3=0,ngrkf-1
52  v(3)=dble(i3)/dble(ngrkf)
53 ! compute the dynamical matrix at this particular q-point
54  call dynrtoq(v,dynr,dq)
55 ! find the phonon frequencies
56  call dynev(dq,wq,ev)
57  do i=1,nbph
58  t1=(wq(i)-wmin)/dw+1.d0
59  iw=nint(t1)
60  if ((iw >= 1).and.(iw <= nwplot)) then
61  gw(iw)=gw(iw)+1.d0
62  end if
63  end do
64  end do
65  end do
66 end do
67 t1=1.d0/(dw*dble(ngrkf)**3)
68 gw(:)=t1*gw(:)
69 ! smooth phonon DOS if required
70 if (nswplot > 0) call fsmooth(nswplot,nwplot,gw)
71 ! write phonon DOS to file
72 open(50,file='PHDOS.OUT',form='FORMATTED')
73 do iw=1,nwplot
74  write(50,'(2G18.10)') w(iw),gw(iw)
75 end do
76 close(50)
77 write(*,*)
78 write(*,'("Info(phdos):")')
79 write(*,'(" phonon density of states written to PHDOS.OUT")')
80 !-------------------------------------------!
81 ! thermodynamic properties from DOS !
82 !-------------------------------------------!
83 ! maximum temperature
84 tmax=wmax/kboltz
85 ! temperature grid
86 do i=1,ntemp
87  temp(i)=tmax*dble(i)/dble(ntemp)
88 end do
89 open(50,file='THERMO.OUT',form='FORMATTED')
90 write(50,*)
91 write(50,'("(All quantities are per unit cell)")')
92 ! zero point energy
93 do iw=1,nwplot
94  f(iw)=gw(iw)*w(iw)
95 end do
96 t1=splint(nwplot,w,f)
97 t1=0.5d0*t1
98 write(50,*)
99 write(50,'("Zero-point energy : ",G18.10)') t1
100 ! vibrational energy
101 write(50,*)
102 write(50,'("Vibrational energy vs. temperature :")')
103 do i=1,ntemp
104  do iw=1,nwplot
105  t1=w(iw)/(2.d0*kboltz*temp(i))
106  if (t1 > 0.d0) then
107  f(iw)=gw(iw)*w(iw)*cosh(t1)/sinh(t1)
108  else
109  f(iw)=0.d0
110  end if
111  end do
112  t1=splint(nwplot,w,f)
113  t1=0.5d0*t1
114  write(50,'(2G18.10)') temp(i),t1
115  s(i)=t1
116 end do
117 ! free energy
118 write(50,*)
119 write(50,'("Free energy vs. temperature :")')
120 do i=1,ntemp
121  do iw=1,nwplot
122  t1=2.d0*sinh(w(iw)/(2.d0*kboltz*temp(i)))
123  if (t1 > 0.d0) then
124  f(iw)=gw(iw)*log(t1)
125  else
126  f(iw)=0.d0
127  end if
128  end do
129  t1=splint(nwplot,w,f)
130  t1=kboltz*temp(i)*t1
131  write(50,'(2G18.10)') temp(i),t1
132 ! compute entropy from S = (F-E)/T
133  s(i)=(s(i)-t1)/temp(i)
134 end do
135 ! entropy
136 write(50,*)
137 write(50,'("Entropy vs. temperature :")')
138 do i=1,ntemp
139  write(50,'(2G18.10)') temp(i),s(i)
140 end do
141 ! heat capacity
142 write(50,*)
143 write(50,'("Heat capacity vs. temperature :")')
144 do i=1,ntemp
145  do iw=1,nwplot
146  t1=w(iw)/(kboltz*temp(i))
147  t2=exp(t1)-1.d0
148  if (abs(t2) > 1.d-14) then
149  f(iw)=gw(iw)*(t1**2)*(t2+1.d0)/t2**2
150  else
151  f(iw)=0.d0
152  end if
153  end do
154  t1=splint(nwplot,w,f)
155  t1=kboltz*t1
156  write(50,'(2G18.10)') temp(i),t1
157 end do
158 close(50)
159 write(*,'(" thermodynamic properties written to THERMO.OUT")')
160 ! write phonon DOS to test file
161 call writetest(210,'phonon DOS',nv=nwplot,tol=1.d-2,rva=gw)
162 deallocate(wq,w,gw,f,dq,ev)
163 end subroutine
164 
integer ngrkf
Definition: modmain.f90:1075
real(8), dimension(:,:,:), allocatable dynr
Definition: modphonon.f90:29
subroutine writetest(id, descr, nv, iv, iva, tol, rv, rva, zv, zva)
Definition: modtest.f90:16
integer nqpt
Definition: modmain.f90:525
real(8), parameter kboltz
Definition: modmain.f90:1263
subroutine phdos
Definition: phdos.f90:7
pure subroutine fsmooth(m, n, f)
Definition: fsmooth.f90:10
subroutine dynrtoq(vpl, dr, dq)
Definition: dynrtoq.f90:7
subroutine dynev(dq, wq, ev)
Definition: dynev.f90:7
complex(8), dimension(:,:,:), allocatable dynq
Definition: modphonon.f90:27
integer nbph
Definition: modphonon.f90:13
subroutine init2
Definition: init2.f90:7
subroutine initph
Definition: initph.f90:7
integer nswplot
Definition: modmain.f90:1077
subroutine init0
Definition: init0.f90:10
integer nwplot
Definition: modmain.f90:1073