24 use,
intrinsic :: iso_fortran_env
41 integer,
parameter,
public :: &
42 LOGRID_PSF = 1, & !< log grid used in Troullier-Martins code
52 real(real64),
allocatable :: rofi(:)
53 real(real64),
allocatable :: r2ofi(:)
54 real(real64),
allocatable :: drdi(:)
55 real(real64),
allocatable :: s(:)
62 type(logrid_t),
intent(out) :: grid
63 integer,
intent(in) :: flavor
64 real(real64),
intent(in) :: aa, bb
65 integer,
intent(in) :: nrval
67 real(real64) :: rpb, ea
72 assert(flavor == logrid_psf .or. flavor ==
logrid_cpi)
82 safe_allocate(grid%rofi(1:nrval))
83 safe_allocate(grid%r2ofi(1:nrval))
84 safe_allocate(grid%drdi(1:nrval))
85 safe_allocate(grid%s(1:nrval))
87 select case (grid%flavor)
92 grid%drdi(ir) = aa*rpb
94 grid%rofi(ir) = bb*
expm1(aa*(ir-1))
103 grid%drdi(2) = bb*rpb
104 do ir = 3, grid%nrval
105 grid%rofi(ir) = grid%rofi(ir-1)*aa
106 grid%drdi(ir) = grid%rofi(ir)*rpb
111 do ir = 1, grid%nrval
112 grid%s(ir) =
sqrt(grid%drdi(ir))
113 grid%r2ofi(ir) = grid%rofi(ir)**2
122 type(logrid_t),
intent(inout) :: grid
126 safe_deallocate_a(grid%rofi)
127 safe_deallocate_a(grid%r2ofi)
128 safe_deallocate_a(grid%drdi)
129 safe_deallocate_a(grid%s)
137 type(
logrid_t),
intent(in) :: grid_in
138 type(
logrid_t),
intent(inout) :: grid_out
144 grid_out%flavor = grid_in%flavor
145 grid_out%a = grid_in%a
146 grid_out%b = grid_in%b
147 grid_out%nrval = grid_in%nrval
149 safe_allocate(grid_out%rofi (1:grid_out%nrval))
150 safe_allocate(grid_out%r2ofi(1:grid_out%nrval))
151 safe_allocate(grid_out%drdi (1:grid_out%nrval))
152 safe_allocate(grid_out%s (1:grid_out%nrval))
154 grid_out%rofi(:) = grid_in%rofi(:)
155 grid_out%r2ofi(:) = grid_in%r2ofi(:)
156 grid_out%drdi(:) = grid_in%drdi(:)
157 grid_out%s(:) = grid_in%s(:)
166 real(real64),
intent(in) :: rofi
173 do ir = 1, grid%nrval-1
175 if (rofi >= grid%rofi(ir).and.rofi < grid%rofi(ir+1))
then
176 if (abs(rofi-grid%rofi(ir)) < abs(rofi-grid%rofi(ir+1)))
then
192 integer,
intent(in) :: zz
193 real(real64),
intent(out) :: aa, bb
194 integer,
intent(out) :: np
196 real(real64) :: xmin, xmax, a1, a2, f1, fm
205 xmin =
sqrt(real(zz, real64) )*1e-5_real64
206 xmax =
sqrt(real(zz, real64) )*30.0_real64
207 np =
floor(
sqrt(real(zz, real64) )*200_real64)
212 f1 =
func(xmin, xmax, real(np, real64) , a1)
216 fm =
func(xmin, xmax, real(np, real64) , aa)
217 if (
m_half*abs(a1 - a2) < 1.0e-16_real64)
exit
228 write(
message(1),
'(a,es13.6,a,es13.6,a,i4)')
'Debug: Log grid parameters: a = ', aa, &
229 ' b = ', bb,
' np = ', np
234 real(real64) function
func(r1, rn, n, a)
235 real(real64),
intent(in) :: r1, rn, a, n
double log(double __x) __attribute__((__nothrow__
double exp(double __x) __attribute__((__nothrow__
double sqrt(double __x) __attribute__((__nothrow__
double floor(double __x) __attribute__((__nothrow__
real(real64) function func(r1, rn, n, a)
real(real64), parameter, public m_two
real(real64), parameter, public m_max_exp_arg
real(real64), parameter, public m_huge
real(real64), parameter, public m_zero
real(real64), parameter, public m_half
real(real64), parameter, public m_one
subroutine, public logrid_find_parameters(namespace, zz, aa, bb, np)
subroutine, public logrid_copy(grid_in, grid_out)
integer, parameter, public logrid_cpi
log grid used in FHI code
integer function, public logrid_index(grid, rofi)
subroutine, public logrid_end(grid)
subroutine, public logrid_init(grid, flavor, aa, bb, nrval)
This module is intended to contain "only mathematical" functions and procedures.
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)