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.
9 ! order of predictor-corrector polynomial
10 integer, parameter :: np
=4
11 ! maximum number of states
12 integer, parameter :: maxspst
=40
13 ! maximum angular momentum allowed
14 integer, parameter :: lmax
=50
15 ! exchange-correlation type
16 integer, parameter :: xctype
=3
17 integer, parameter :: xcgrad
=0
18 integer nz
,spnst
,spnr
,nrmt
19 integer nlx
,nlorb
,i
,l
,maxl
20 integer ist
,jst
,ir
,iostat
21 real(8), parameter :: pi
=3.1415926535897932385d0
22 ! core-valence cut-off energy
23 real(8), parameter :: ecvcut
=-3.5d0
24 ! semi-core cut-off energy
25 real(8), parameter :: esccut
=-0.35d0
27 real(8), parameter :: boe
=0.15d0
28 real(8) spmass
,rmt
,spzn
,sprmin
,sprmax
,t1
29 character(256) spsymb
,spname
31 logical spcore(maxspst
)
32 integer spn(maxspst
),spl(maxspst
),spk(maxspst
)
33 real(8) spocc(maxspst
),eval(maxspst
)
35 real(8), allocatable
:: r(:),rho(:),vr(:),rwf(:,:,:)
36 real(8), allocatable
:: fr(:),gr(:),cf(:,:)
37 open(40,file
='species.dat',action
='READ',status
='OLD',form
='FORMATTED')
39 read(40,*,iostat
=iostat
) nz
46 if (spnst
.gt
.maxspst
) then
48 write(*,'("Error(species): too many states for species ",A)') trim(spname
)
53 read(40,*) spn(ist
),spl(ist
),spk(ist
),i
55 if (spn(ist
).lt
.spn(ist
-1)) then
57 write(*,'("Error(species): states improperly ordered")')
58 write(*,'(" for species ",A)') trim(spname
)
66 write(*,'("Info(species): running Z = ",I4,", (",A,")")') nz
,trim(spname
)
67 ! nuclear charge in units of e
69 ! minimum radial mesh point proportional to 1/sqrt(Z)
70 sprmin
=2.d
-6/sqrt(abs(dble(spzn
)))
71 ! set the number of radial mesh points proportional to number of nodes
72 nrmt
=100*(spn(spnst
)+1)
73 ! find the optimal effective infinity
76 t1
=log(sprmax
/sprmin
)/log(rmt
/sprmin
)
77 spnr
=int(t1
*dble(nrmt
))
78 if (allocated(r
)) deallocate(r
)
79 if (allocated(rho
)) deallocate(rho
)
80 if (allocated(vr
)) deallocate(vr
)
81 if (allocated(rwf
)) deallocate(rwf
)
82 if (allocated(fr
)) deallocate(fr
)
83 if (allocated(gr
)) deallocate(gr
)
84 if (allocated(cf
)) deallocate(cf
)
88 allocate(rwf(spnr
,2,spnst
))
92 ! generate the radial mesh
93 call radmesh(spnr
,nrmt
,rmt
,sprmin
,r
)
94 ! solve the Kohn-Sham-Dirac equations for the atom
95 call atom(.true
.,spzn
,spnst
,spn
,spl
,spk
,spocc
,xctype
,xcgrad
,np
,spnr
,r
,eval
, &
98 if (rho(ir
).gt
.1.d
-20) then
105 ! check total charge is correct
107 fr(ir
)=4.d0
*pi
*rho(ir
)*r(ir
)**2
109 call fderiv(-1,spnr
,r
,fr
,gr
,cf
)
110 if (abs(gr(spnr
)+spzn
).gt
.1.d
-5) then
112 write(*,'("Error(species): charge mismatch")')
116 ! find which states belong to core
118 if (eval(ist
).lt
.ecvcut
) then
124 ! check that the state for same n and l but different k is also core
126 if (spcore(ist
)) then
128 if ((spn(ist
).eq
.spn(jst
)).and
.(spl(ist
).eq
.spl(jst
))) spcore(jst
)=.true
.
132 ! find the total number of local orbitals
136 if (.not
.spcore(ist
)) then
137 if ((spl(ist
).eq
.0).or
.(spl(ist
).eq
.spk(ist
))) then
138 if (eval(ist
).lt
.esccut
) nlorb
=nlorb
+1
140 if (spl(ist
).gt
.maxl
) maxl
=spl(ist
)
144 if (maxl
.gt
.3) maxl
=3
147 ! open the atomic data file
148 open(50,file
=trim(spsymb
)//'.in',action
='WRITE',form
='FORMATTED')
149 write(50,'(" ''",A,"''",T45,": spsymb")') trim(spsymb
)
150 write(50,'(" ''",A,"''",T45,": spname")') trim(spname
)
151 write(50,'(G14.6,T45,": spzn")') spzn
152 write(50,'(G18.10,T45,": spmass")') spmass
153 write(50,'(G14.6,2F10.4,I6,T45,": sprmin, rmt, sprmax, nrmt")') sprmin
,rmt
, &
155 write(50,'(I4,T45,": spnst")') spnst
156 write(50,'(3I4,G14.6,L1,T45,": spn, spl, spk, spocc, spcore")') spn(1),spl(1), &
157 spk(1),spocc(1),spcore(1)
159 write(50,'(3I4,G14.6,L1)') spn(ist
),spl(ist
),spk(ist
),spocc(ist
),spcore(ist
)
161 write(50,'(I4,T45,": apword")') 1
162 write(50,'(F8.4,I4," ",L1,T45,": apwe0, apwdm, apwve")') boe
,0,.false
.
163 write(50,'(I4,T45,": nlx")') nlx
164 write(50,'(I4,T45,": nlorb")') nlorb
165 ! write the local-orbitals
167 write(50,'(2I4,T45,": lorbl, lorbord")') l
,2
168 write(50,'(F8.4,I4," ",L1,T45,": lorbe0, lorbdm, lorbve")') boe
,0,.false
.
169 write(50,'(F8.4,I4," ",L1)') boe
,1,.false
.
172 if (.not
.spcore(ist
)) then
173 if ((spl(ist
).eq
.0).or
.(spl(ist
).eq
.spk(ist
))) then
174 if (eval(ist
).lt
.esccut
) then
175 write(50,'(2I4,T45,": lorbl, lorbord")') spl(ist
),3
176 write(50,'(F8.4,I4," ",L1,T45,": lorbe0, lorbdm, lorbve")') boe
,0, &
178 write(50,'(F8.4,I4," ",L1)') boe
,1,.false
.
179 write(50,'(F8.4,I4," ",L1)') eval(ist
)+0.5d0*boe
,0,.true
.
185 ! read another element from file