The Elk Code
sfacinit.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2010 A. I. Baranov and F. Wagner.
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 sfacinit
7 use modmain
8 use modpw
9 implicit none
10 ! local variables
11 logical trhonorm0
12 integer ik,ist,is,ias
13 ! allocatable arrays
14 real(8), allocatable :: occcr0(:,:)
15 ! initialise universal variables
16 call init0
17 call init1
18 ! read density and potentials from file
19 call readstate
20 ! use existing density if wsfac is default
21 if ((wsfac(1) <= -1.d6).and.(wsfac(2) >= 1.d6)) goto 10
22 ! make a copy of the core state occupation numbers
23 allocate(occcr0(nstspmax,natmtot))
24 occcr0(:,:)=occcr(:,:)
25 ! zero the core state occupation numbers for eigenvalues not in energy window
26 do ias=1,natmtot
27  is=idxis(ias)
28  do ist=1,nstsp(is)
29  if (spcore(ist,is)) then
30  if ((evalcr(ist,ias) < wsfac(1)).or.(evalcr(ist,ias) > wsfac(2))) then
31  occcr(ist,ias)=0.d0
32  end if
33  end if
34  end do
35 end do
36 ! generate the core wavefunctions and densities
37 call gencore
38 ! restore the core state occupation numbers
39 occcr(:,:)=occcr0(:,:)
40 deallocate(occcr0)
41 ! find the new linearisation energies
42 call linengy
43 ! generate the APW radial functions
44 call genapwfr
45 ! generate the local-orbital radial functions
46 call genlofr
47 do ik=1,nkpt
48 ! get the eigenvalues and occupation numbers from file
49  call getevalsv(filext,ik,vkl(:,ik),evalsv(:,ik))
50  call getoccsv(filext,ik,vkl(:,ik),occsv(:,ik))
51 ! zero occupation numbers for eigenvalues not in energy window
52  do ist=1,nstsv
53  if ((evalsv(ist,ik) < wsfac(1)).or.(evalsv(ist,ik) > wsfac(2))) then
54  occsv(ist,ik)=0.d0
55  end if
56  end do
57 end do
58 ! computed density should not be normalised
59 trhonorm0=trhonorm
60 trhonorm=.false.
61 ! generate the density and magnetisation
62 call rhomag
63 trhonorm=trhonorm0
64 10 continue
65 ! generate the H-vectors
66 call genhvec
67 end subroutine
68 
character(256) filext
Definition: modmain.f90:1301
real(8), dimension(:,:), allocatable evalsv
Definition: modmain.f90:921
real(8), dimension(:,:), allocatable occcr
Definition: modmain.f90:935
integer nkpt
Definition: modmain.f90:461
subroutine genlofr
Definition: genlofr.f90:10
subroutine genhvec
Definition: genhvec.f90:7
subroutine getevalsv(fext, ikp, vpl, evalsv_)
Definition: getevalsv.f90:7
subroutine gencore
Definition: gencore.f90:10
real(8), dimension(:,:), allocatable evalcr
Definition: modmain.f90:937
subroutine rhomag
Definition: rhomag.f90:7
logical trhonorm
Definition: modmain.f90:618
subroutine linengy
Definition: linengy.f90:10
logical, dimension(maxstsp, maxspecies) spcore
Definition: modmain.f90:127
integer nstsv
Definition: modmain.f90:889
real(8), dimension(2) wsfac
Definition: modmain.f90:1108
real(8), dimension(:,:), allocatable occsv
Definition: modmain.f90:905
subroutine init1
Definition: init1.f90:10
real(8), dimension(:,:), allocatable vkl
Definition: modmain.f90:471
integer, dimension(maxatoms *maxspecies) idxis
Definition: modmain.f90:44
subroutine genapwfr
Definition: genapwfr.f90:10
subroutine sfacinit
Definition: sfacinit.f90:7
subroutine getoccsv(fext, ikp, vpl, occsvp)
Definition: getoccsv.f90:7
Definition: modpw.f90:6
subroutine readstate
Definition: readstate.f90:10
integer, dimension(maxspecies) nstsp
Definition: modmain.f90:113
subroutine init0
Definition: init0.f90:10
integer natmtot
Definition: modmain.f90:40
integer nstspmax
Definition: modmain.f90:115