exciting-0.9.150
[exciting.git] / src / rdmft.f90
blobef2f0800f5ce834239834be047c0fc68079238cf
2 ! Copyright (C) 2002-2008 J. K. Dewhurst, S. Sharma and E. K. U. Gross.
3 ! This file is distributed under the terms of the GNU Lesser General Public
4 ! License. See the file COPYING for license details.
6 subroutine rdmft
7 ! 1-reduced density matrix functional theory
8 use modmain
9 implicit none
10 ! local variables
11 integer ik
12 call init0
13 call init1
14 ! generate q-point set and wiq2 array
15 call init2
16 ! read density and potentials from file
17 call readstate
18 ! generate the core wavefunctions and densities
19 call gencore
20 ! find the new linearisation energies
21 call linengy
22 ! generate the APW radial functions
23 call genapwfr
24 ! generate the local-orbital radial functions
25 call genlofr
26 ! compute the overlap radial integrals
27 call olprad
28 ! compute the Hamiltonian radial integrals
29 call hmlrad
30 ! compute the kinetic energy of the core
31 call energykncr
32 ! generate the kinetic matrix elements
33 call genkinmat
34 ! read in the occupancies
35 do ik=1,nkpt
36 call getoccsv(vkl(1,ik),occsv(1,ik))
37 end do
38 ! calculate Coulomb potential matrix elements
39 call genvmat(vclmt,vclir,vclmat)
40 ! derivative of kinetic energy w.r.t. evecsv
41 call rdmdkdc
42 ! open information files
43 open(60,file='RDM_INFO.OUT',action='WRITE',form='FORMATTED')
44 ! write out general information to RDM_INFO.OUT
45 call writeinfo(60)
46 ! begin main self-consistent loop
47 do iscl=1,rdmmaxscl
48 write(60,*)
49 write(60,'("+-------------------------+")')
50 write(60,'("| Iteration number : ",I4," |")') iscl
51 write(60,'("+-------------------------+")')
52 call flushifc(60)
53 ! minimisation over natural orbitals
54 if (maxitc.ge.1) then
55 call rdmminc
56 write(60,*)
57 write(60,'("Natural orbital minimisation done")')
58 call rdmwriteengy(60)
59 end if
60 ! minimisation over occupation number
61 if (maxitn.ge.1) then
62 call rdmminn
63 write(60,*)
64 write(60,'("Occupation number minimisation done")')
65 call rdmwriteengy(60)
66 end if
67 ! end loop over iscl
68 end do
69 ! write density to STATE.OUT
70 call writestate
71 ! write occupation numbers for restart
72 do ik=1,nkpt
73 call putoccsv(ik,occsv(1,ik))
74 end do
75 ! close RDM_INFO.OUT file
76 close(60)
77 return
78 end subroutine