25 use,
intrinsic :: iso_fortran_env
51 integer :: no_l_channels
52 real(real64),
allocatable :: vps(:, :)
53 real(real64),
allocatable :: KB(:,:)
54 real(real64),
allocatable :: dkbcos(:)
55 real(real64),
allocatable,
private :: dknorm(:)
56 real(real64),
allocatable :: kb_radius(:)
58 integer :: so_no_l_channels
59 real(real64),
allocatable :: so_vps(:,:)
60 real(real64),
allocatable,
private :: so_KB(:,:)
61 real(real64),
allocatable,
private :: so_dkbcos(:)
62 real(real64),
allocatable,
private :: so_dknorm(:)
63 real(real64),
allocatable,
private :: so_kb_radius(:)
65 real(real64),
allocatable :: vlocal(:)
66 real(real64),
allocatable :: rphi(:, :,:)
68 logical :: core_corrections
69 real(real64),
allocatable :: chcore(:)
76 type(ps_in_grid_t),
intent(out) :: ps
77 integer,
intent(in) :: flavor, nrval
78 real(real64),
intent(in) :: a, b
79 integer,
intent(in) :: no_l, so_no_l
87 ps% no_l_channels = no_l
88 ps%so_no_l_channels = so_no_l
91 safe_allocate(ps%vps (1:ps%g%nrval, 1:no_l))
92 safe_allocate(ps%chcore (1:ps%g%nrval))
93 safe_allocate(ps%vlocal (1:ps%g%nrval))
95 safe_allocate(ps%rphi (1:ps%g%nrval, 1:no_l, 1:3))
96 safe_allocate(ps%KB (1:ps%g%nrval, 1:no_l))
97 safe_allocate(ps%dkbcos(1:no_l))
98 safe_allocate(ps%dknorm(1:no_l))
99 safe_allocate(ps%kb_radius(1:no_l+1))
101 if (so_no_l > 0)
then
102 safe_allocate(ps%so_vps(1:ps%g%nrval, 1:so_no_l))
103 safe_allocate(ps%so_KB (1:ps%g%nrval, 1:so_no_l))
104 safe_allocate(ps%so_dkbcos(1:so_no_l))
105 safe_allocate(ps%so_dknorm(1:so_no_l))
106 safe_allocate(ps%so_kb_radius(1:so_no_l))
115 type(ps_in_grid_t),
intent(inout) :: ps
119 safe_deallocate_a(ps%vps)
120 safe_deallocate_a(ps%chcore)
121 safe_deallocate_a(ps%vlocal)
123 safe_deallocate_a(ps%rphi)
124 safe_deallocate_a(ps%KB)
125 safe_deallocate_a(ps%dkbcos)
126 safe_deallocate_a(ps%dknorm)
127 safe_deallocate_a(ps%kb_radius)
129 if (ps%so_no_l_channels > 0)
then
130 safe_deallocate_a(ps%so_vps)
131 safe_deallocate_a(ps%so_KB)
132 safe_deallocate_a(ps%so_dkbcos)
133 safe_deallocate_a(ps%so_dknorm)
134 safe_deallocate_a(ps%so_kb_radius)
146 integer,
intent(in) :: l_loc
147 real(real64),
intent(in) :: rcore
151 real(real64) :: a, b, qtot
152 real(real64),
allocatable :: rho(:)
157 ps%vlocal(:) = ps%vps(:, l_loc+1)
159 else if (l_loc == -1)
then
161 message(1) =
"For the moment, Vanderbilt local potentials are only possible with tm grids."
165 a = 1.82_real64 / rcore
167 safe_allocate(rho(1:ps%g%nrval))
169 do ir = 1, ps%g%nrval
170 rho(ir) =
exp(-(
sinh(a*b*ps%g%rofi(ir)) /
sinh(b))**2)
171 rho(ir) =
m_four *
m_pi * rho(ir) * ps%g%r2ofi(ir)
174 qtot = sum(rho(:)*ps%g%drdi(:))
175 rho(:) = - rho(:)*(ps%zval/qtot)
177 call vhrtre(rho, ps%vlocal, ps%g%rofi, ps%g%drdi, ps%g%s, ps%g%nrval, ps%g%a)
178 ps%vlocal(1) = ps%vlocal(2)
180 safe_deallocate_a(rho)
197 do l = 1, ps%no_l_channels
198 ps%KB(2:, l) = (ps%vps(2:, l) - ps%vlocal(2:))*(ps%rphi(2:, l, 1)/ps%g%rofi(2:))*ps%dknorm(l)
203 do l = 1, ps%so_no_l_channels
204 ps%so_KB(2:, l) = ps%so_vps(2:, l)*(ps%rphi(2:, l, 1)/ps%g%rofi(2:))*ps%dknorm(l)
221 integer,
intent(in) :: lloc
224 real(real64) :: dnrm, avgv, vphi
225 real(real64),
parameter :: tol = 1.0e-20_real64
229 do l = 1, ps%no_l_channels
230 if (l-1 == lloc)
then
238 do ir = 1, ps%g%nrval
239 vphi = (ps%vps(ir, l) - ps%vlocal(ir))*ps%rphi(ir, l, 1)
240 dnrm = dnrm + vphi*vphi*ps%g%drdi(ir)
241 avgv = avgv + vphi*ps%rphi(ir, l, 1)*ps%g%drdi(ir)
243 ps%dkbcos(l) = dnrm/safe_tol(avgv, tol)
244 ps%dknorm(l) =
m_one/safe_tol(
sqrt(dnrm), tol)
247 do l = 1, ps%so_no_l_channels
250 do ir = 1, ps%g%nrval
251 vphi = ps%so_vps(ir, l)*ps%rphi(ir, l, 1)
252 dnrm = dnrm + vphi*vphi*ps%g%drdi(ir)
253 avgv = avgv + vphi*ps%rphi(ir, l, 1)*ps%g%drdi(ir)
255 ps%so_dkbcos(l) = dnrm/safe_tol(avgv, tol)
256 ps%so_dknorm(l) =
m_one/safe_tol(
sqrt(dnrm), tol)
266 integer,
intent(in) :: lloc
269 real(real64) :: dincv, phi
270 real(real64),
parameter :: threshold = 1.0e-6_real64
275 do ir = ps%g%nrval-1, 2, -1
276 dincv = abs(ps%vlocal(ir)*ps%g%rofi(ir) +
m_two*ps%zval)
277 if (dincv > threshold)
exit
279 ps%kb_radius(ps%no_l_channels+1) = ps%g%rofi(ir + 1)
282 do l = 1, ps%no_l_channels
283 if (l-1 == lloc)
then
288 do ir = ps%g%nrval-1, 2, -1
289 phi = (ps%rphi(ir, l, 1)/ps%g%rofi(ir))*ps%dknorm(l)
290 dincv = abs((ps%vps(ir, l) - ps%vlocal(ir))*phi)
292 if (dincv > threshold)
exit
294 phi = (ps%rphi(ir, l, 1)/ps%g%rofi(ir))*ps%dknorm(l)
297 ps%kb_radius(l) = ps%g%rofi(ir + 1)
301 do l = 1, ps%so_no_l_channels
302 do ir = ps%g%nrval-1, 2, -1
303 phi = (ps%rphi(ir, l, 1)/ps%g%rofi(ir))*ps%so_dknorm(l)
304 dincv = abs((ps%so_vps(ir, l))*phi)
306 if (dincv > threshold)
exit
309 ps%so_kb_radius(l) = ps%g%rofi(ir + 1)
328 do l = 1, ps%no_l_channels
329 nrm =
sqrt(sum(ps%g%drdi(:)*ps%rphi(:, l, 1)**2))
330 nrm = abs(nrm -
m_one)
331 if (nrm > 1.0e-5_real64)
then
332 write(
message(1),
'(a,i2,a)')
"Eigenstate for l = ", l-1,
' is not normalized.'
333 write(
message(2),
'(a, f12.6,a)')
'(abs(1 - norm) = ', nrm,
')'
344 real(real64),
intent(in) :: x(:)
345 real(real64),
intent(in) :: y(:)
346 logical,
optional,
intent(in) :: high_order
348 real(real64) :: x1, x2, x3
349 real(real64) :: y1, y2, y3
360 y0 = y1*x2*x3*(x2 - x3) + y2*x1*x3*(x3 - x1) + y3*x1*x2*(x1 - x2)
361 y0 = y0/((x1 - x2)*(x1 - x3)*(x2 - x3))
365 y0 = y1 - (y2 - y1)*x1/(x2 - x1)
double exp(double __x) __attribute__((__nothrow__
double sqrt(double __x) __attribute__((__nothrow__
double sinh(double __x) __attribute__((__nothrow__
subroutine, public vhrtre(rho, v, r, drdi, srdrdi, nr, a)
VHRTRE CONSTRUCTS THE ELECTROSTATIC POTENTIAL DUE TO A SUPPLIED ! ELECTRON DENSITY....
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
real(real64), parameter, public m_four
real(real64), parameter, public m_pi
some mathematical constants
real(real64), parameter, public m_one
integer, parameter, public logrid_psf
log grid used in Troullier-Martins code
subroutine, public logrid_end(grid)
subroutine, public logrid_init(grid, flavor, aa, bb, nrval)
subroutine, public messages_warning(no_lines, all_nodes, namespace)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public ps_in_grid_kb_projectors(ps)
KB-projectors kb = (vps - vlocal) |phi> * dknorm.
subroutine, public ps_in_grid_end(ps)
subroutine, public ps_in_grid_cutoff_radii(ps, lloc)
subroutine, public ps_in_grid_init(ps, flavor, a, b, nrval, no_l, so_no_l)
subroutine, public ps_in_grid_kb_cosines(ps, lloc)
KB-cosines and KB-norms: dkbcos stores the KB "cosines:" || (v_l - v_local) phi_l ||^2 / < (v_l - v_l...
subroutine, public ps_in_grid_vlocal(ps, l_loc, rcore, namespace)
real(real64) function, public first_point_extrapolate(x, y, high_order)
subroutine, public ps_in_grid_check_rphi(ps, namespace)
checks normalization of the pseudo wavefunctions