The Elk Code
init2.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 init2
7 use modmain
8 use modrdm
9 use modphonon
10 use modgw
11 use modvars
12 use modmpi
13 implicit none
14 ! local variables
15 logical lsym(48)
16 integer isym,iv(3),iq
17 real(8) boxl(3,0:3)
18 real(8) ts0,ts1
19 
20 call timesec(ts0)
21 
22 !---------------------!
23 ! q-point set !
24 !---------------------!
25 ! check if the system is an isolated molecule
26 if (molecule) ngridq(:)=1
27 ! store the point group symmetries for reducing the q-point set
28 if (reduceq == 0) then
29  nsymqpt=1
30  symqpt(:,:,1)=symlat(:,:,1)
31 else
32  lsym(:)=.false.
33  do isym=1,nsymcrys
34  lsym(lsplsymc(isym))=.true.
35  end do
36  nsymqpt=0
37  do isym=1,nsymlat
38  if (lsym(isym)) then
40  symqpt(:,:,nsymqpt)=symlat(:,:,isym)
41  end if
42  end do
43 end if
44 if (any(task == [105,180,185,320,330,331,670,680])) then
45 ! equal k- and q-point grids for nesting function, BSE, linear-reposnse TDDFT
46 ! and TDHFC
47  ngridq(:)=ngridk(:)
48 else if (any(task == [5,300,600,601,620]).or.(xctype(1) < 0).or.ksgwrho) then
49 ! allow the q-point grid to be smaller than the k-point grid for OEP,
50 ! Hartree-Fock, RDMFT and GW
51  if (any(ngridq(:) < 1)) ngridq(:)=ngridk(:)
52 else
53  ngridq(:)=abs(ngridq(:))
54 end if
55 ! check that the q-point and k-point grids are commensurate for some tasks
56 if (any(task == [5,205,240,241,300,600,601,620]).or.(xctype(1) < 0).or. &
57  ksgwrho) then
58  iv(:)=mod(ngridk(:),ngridq(:))
59  if (any(iv(:) /= 0)) then
60  write(*,*)
61  write(*,'("Error(init2): k-point grid incommensurate with q-point grid")')
62  write(*,'(" ngridk :",3(X,I0))') ngridk
63  write(*,'(" ngridq :",3(X,I0))') ngridq
64  write(*,*)
65  stop
66  end if
67 end if
68 ! allocate the q-point arrays
69 if (allocated(ivqiq)) deallocate(ivqiq)
70 allocate(ivqiq(0:ngridq(1)-1,0:ngridq(2)-1,0:ngridq(3)-1))
71 if (allocated(ivqiqnr)) deallocate(ivqiqnr)
72 allocate(ivqiqnr(0:ngridq(1)-1,0:ngridq(2)-1,0:ngridq(3)-1))
73 nqptnr=ngridq(1)*ngridq(2)*ngridq(3)
74 if (allocated(ivq)) deallocate(ivq)
75 allocate(ivq(3,nqptnr))
76 if (allocated(vql)) deallocate(vql)
77 allocate(vql(3,nqptnr))
78 if (allocated(vqc)) deallocate(vqc)
79 allocate(vqc(3,nqptnr))
80 if (allocated(wqpt)) deallocate(wqpt)
81 allocate(wqpt(nqptnr))
82 ! set up the q-point box (offset should always be zero)
83 boxl(:,:)=0.d0
84 boxl(1,1)=1.d0; boxl(2,2)=1.d0; boxl(3,3)=1.d0
85 ! generate the q-point set
86 ! (note that the vectors vql and vqc are in the first Brillouin zone)
89 ! q-point length
90 if (allocated(qc)) deallocate(qc)
91 allocate(qc(nqptnr))
92 do iq=1,nqptnr
93  qc(iq)=norm2(vqc(1:3,iq))
94 end do
95 ! write the q-points to QPOINTS.OUT
96 if (mp_mpi) call writeqpts
97 ! write to VARIABLES.OUT
98 if (wrtvars) then
99  call writevars('nsymqpt',iv=nsymqpt)
100  call writevars('symqpt',nv=9*nsymqpt,iva=symqpt)
101  call writevars('ngridq',nv=3,iva=ngridq)
102  call writevars('nqpt',iv=nqpt)
103  call writevars('ivqiq',nv=nqptnr,iva=ivqiq)
104  call writevars('ivq',nv=3*nqptnr,iva=ivq)
105  call writevars('vql',nv=3*nqptnr,rva=vql)
106  call writevars('wqpt',nv=nqpt,rva=wqpt)
107 end if
108 
109 !--------------------------------------------------------!
110 ! OEP, Hartree-Fock, RDMFT, BSE and GW variables !
111 !--------------------------------------------------------!
112 if (any(task == [5,180,185,300,320,330,331,600,601,620,670]).or. &
113  (xctype(1) < 0).or.ksgwrho) then
114 ! determine the regularised Coulomb Green's function for small q
115  call gengclq
116 ! output the Coulomb Green's function to GCLQ.OUT
117  if (mp_mpi) call writegclq
118 ! initialise OEP variables
119  if (xctype(1) < 0) call initoep
120 end if
121 if (task == 300) then
122  if (allocated(vclmat)) deallocate(vclmat)
123  allocate(vclmat(nstsv,nstsv,nkpt))
124  if (allocated(dkdc)) deallocate(dkdc)
125  allocate(dkdc(nstsv,nstsv,nkpt))
126 end if
127 
128 call timesec(ts1)
129 timeinit=timeinit+ts1-ts0
130 
131 end subroutine
132 
real(8), dimension(:), allocatable qc
Definition: modmain.f90:552
integer task
Definition: modmain.f90:1299
logical mp_mpi
Definition: modmpi.f90:17
subroutine genppts(tfbz, nsym, sym, ngridp, npptnr, epslat, bvec, boxl, nppt, ipvip, ipvipnr, ivp, vpl, vpc, wppt, wpptnr)
Definition: genppts.f90:11
integer, dimension(3) xctype
Definition: modmain.f90:591
integer nqpt
Definition: modmain.f90:528
integer nkpt
Definition: modmain.f90:464
integer, dimension(:,:), allocatable ivq
Definition: modmain.f90:532
real(8) wqptnr
Definition: modmain.f90:556
integer nsymcrys
Definition: modmain.f90:361
integer, dimension(3, 3, 48) symlat
Definition: modmain.f90:347
integer, dimension(3, 3, 48) symqpt
Definition: modmain.f90:526
complex(8), dimension(:,:,:), allocatable dkdc
Definition: modrdm.f90:15
Definition: modrdm.f90:6
real(8) timeinit
Definition: modmain.f90:1215
integer nstsv
Definition: modmain.f90:885
real(8), dimension(:,:), allocatable vqc
Definition: modmain.f90:550
subroutine initoep
Definition: initoep.f90:7
integer, dimension(maxsymcrys) lsplsymc
Definition: modmain.f90:367
integer nsymlat
Definition: modmain.f90:345
subroutine init2
Definition: init2.f90:7
integer, dimension(3) ngridk
Definition: modmain.f90:451
real(8), dimension(:,:), allocatable vql
Definition: modmain.f90:548
integer, dimension(:,:,:), allocatable ivqiq
Definition: modmain.f90:534
real(8), dimension(3, 3) bvec
Definition: modmain.f90:16
integer nqptnr
Definition: modmain.f90:530
integer, dimension(:,:,:), allocatable ivqiqnr
Definition: modmain.f90:536
integer, dimension(3) ngridq
Definition: modmain.f90:518
Definition: modgw.f90:6
logical wrtvars
Definition: modvars.f90:9
real(8) epslat
Definition: modmain.f90:24
Definition: modmpi.f90:6
subroutine timesec(ts)
Definition: timesec.f90:10
integer reduceq
Definition: modmain.f90:522
subroutine writegclq
Definition: writegclq.f90:10
logical ksgwrho
Definition: modgw.f90:38
subroutine gengclq
Definition: gengclq.f90:10
real(8), dimension(:), allocatable wqpt
Definition: modmain.f90:554
complex(8), dimension(:,:,:), allocatable vclmat
Definition: modrdm.f90:13
integer nsymqpt
Definition: modmain.f90:524
logical molecule
Definition: modmain.f90:47
subroutine writevars(vname, n1, n2, n3, n4, n5, n6, nv, iv, iva, rv, rva, zv, zva, sv, sva)
Definition: modvars.f90:16
subroutine writeqpts
Definition: writeqpts.f90:7