2
! Copyright (C) 1996-2016 The SIESTA group
3
! This file is distributed under the terms of the
4
! GNU General Public License: see COPYING in the top directory
5
! or http://www.gnu.org/copyleft/gpl.txt .
6
! See Docs/Contributors.txt for a list of contributors.
8
subroutine xml2psf_helper( psxml, p )
10
! Translate the more complete xml format and data structure
11
! into the old Siesta type for the pseudopotential
18
integer, parameter :: dp = selected_real_kind(14)
21
type(pseudo_t), intent(in) :: psxml
22
type(pseudopotential_t), intent(out) :: p
24
integer :: position, i, il, ir, lmax, lshellint
25
character(len=1) :: ispp, lshell
27
real(dp) :: zeld(0:4), zelu(0:4)
31
p%name = psxml%header%symbol
32
p%nr = psxml%pot(1)%V%grid%npts
34
p%zval = psxml%header%zval
35
! relativistic and correlation are not needed in Siesta, so they are
37
select case(psxml%header%xcfunctionalparametrization)
38
case('Ceperley-Alder')
42
case('Hedin-Lundqvist')
44
case('Gunnarson-Lundqvist')
46
case('von Barth-Hedin')
48
case('Perdew-Burke-Ernzerhof')
50
case('RPBE - Hammer et al')
52
case('revPBE Zhang+Yang')
54
case('Becke-Lee-Yang-Parr')
60
case('Perdew-Burke-Ernzerhof-solid')
64
select case(psxml%header%relativistic)
70
select case(psxml%header%polarized)
82
select case(psxml%header%core_corrections)
89
p%a = psxml%pot(1)%V%grid%step
90
p%b = psxml%pot(1)%V%grid%scale
92
p%method(1) = psxml%header%creator
93
p%method(2) = psxml%header%date
94
read(psxml%header%flavor,'(4a10)') (p%method(i),i=3,6)
96
p%npotu = psxml%npots_up
97
p%npotd = psxml%npots_down
99
! Allocate the radial variables and semilocal potentials
100
allocate(p%r(1:p%nrval))
101
allocate(p%chcore(1:p%nrval))
102
allocate(p%chval(1:p%nrval))
104
if (p%npotd.gt.0) then
105
allocate(p%vdown(1:p%npotd,1:p%nrval))
106
allocate(p%ldown(1:p%npotd))
109
if (p%npotu.gt.0) then
110
allocate(p%vup(1:p%npotu,1:p%nrval))
111
allocate(p%lup(1:p%npotu))
115
! Calculate the points of the logarithmic radial grid
116
do 30 ir = 1, p%nrval
117
p%r(ir) = p%b * (exp(p%a*(ir-1))-1)
121
! Translate the valence charge density and the pseudo-core charge density,
122
! and define the value at the first point of the logarithmic grid
123
p%chcore(2:p%nrval) = psxml%core_charge%data(1:p%nr)
124
p%chval(2:p%nrval) = psxml%valence_charge%data(1:p%nr)
125
r2=p%r(2)/(p%r(3)-p%r(2))
126
p%chcore(1) = p%chcore(2) - r2*(p%chcore(3)-p%chcore(2))
127
p%chval(1) = p%chval(2) - r2*(p%chval(3)-p%chval(2))
134
lshell = psxml%pot(il)%l
145
p%ldown(il) = lshellint
146
p%vdown(il,2:p%nrval) = psxml%pot(il)%V%data(1:p%nr)
147
zeld(lshellint) = psxml%pot(il)%occupation
151
lshell = psxml%pot(p%npotd+il)%l
162
p%lup(il) = lshellint
163
p%vup(il,2:p%nrval) = psxml%pot(p%npotd+il)%V%data(1:p%nr)
164
zelu(lshellint) = psxml%pot(p%npotd+il)%occupation
169
lmax = max(p%npotd, p%npotu)
171
if ( .not. polarized) then
172
write(p%text(position:),9070)
175
. zeld(il-1)+zelu(il-1),
177
. psxml%pot(il)%cutoff
178
9070 format(i1,a1,f5.2,a1,' r=',f5.2,'/')
179
position = position + 17
181
write(p%text(position:),9090)
187
. psxml%pot(il)%cutoff
188
9090 format(i1,a1,f4.2,',',f4.2,a1,f4.2,'/')
189
position = position + 17
194
! For debugging -------------------------------------------------------
204
! write(6,*)p%method(1)
205
! write(6,*)p%method(2)
206
! write(6,*)p%method(3)
207
! write(6,*)p%method(4)
208
! write(6,*)p%method(5)
209
! write(6,*)p%method(6)
213
! write(6,'(4f20.12)')p%r(1:4)
214
! write(6,'(4f20.12)')p%r(101:104)
215
! write(6,'(4f20.12)')p%vdown(1,1:4)
216
! write(6,'(4f20.12)')p%vdown(2,1:4)
217
! write(6,'(4f20.12)')p%vdown(3,1:4)
218
! write(6,'(4f20.12)')p%vdown(4,1:4)
219
! write(6,'(4f20.12)')p%vup(1,1:4)
220
! write(6,'(4f20.12)')p%vup(2,1:4)
221
! write(6,'(4f20.12)')p%vup(3,1:4)
222
! write(6,'(4f20.12)')p%chcore(1:4)
223
! write(6,'(4f20.12)')p%chval(1:4)
227
! write(6,*)p%r(ir), pseudo%pswf(1)%V%data(ir)
230
end subroutine xml2psf_helper