15 USE ieee_arithmetic,
ONLY: ieee_is_finite
29 LOGICAL :: source_root_argument
31 INTEGER,
PARAMETER :: la = 4, lb = 4, na = 2, nb = 2
32 REAL(kind=
dp),
PARAMETER :: alpha(na) = [.1_dp, 3._dp], beta(nb) = [.3_dp, 2.1_dp],
gamma(2) = [.2_dp, 4._dp]
33 REAL(kind=
dp),
PARAMETER :: coeff(1, 2) = reshape([-.7_dp, 2.3_dp], [1, 2])
34 INTEGER :: n, grid, geometry, i, j, k, ld, ma, mb, io_unit
35 CHARACTER(len=default_path_length) :: filename
36 REAL(kind=
dp) :: rabv(3), rac(3), rbc(3), dx, error, force_a(3), force_b(3), ref_a(3), ref_b(3), scale, threshold
37 REAL(kind=
dp),
ALLOCATABLE :: vri(:), dri(:, :), rri(:), rdri(:, :), energy_only(:, :)
38 REAL(kind=
dp),
ALLOCATABLE :: r(:), rab(:), potential(:), v(:, :), da(:, :, :), db(:, :, :), &
39 reference(:, :), density(:, :), s(:, :, :), fs(:, :, :)
41 TYPE(atom_upfpot_type) :: pot
47 IF (grid == 2) n = 2500
48 ALLOCATE (r(n), rab(n), potential(n))
51 dx = log(1 + 12.5_dp/.001_dp)/(n - 1)
52 r(i) = .001_dp*(exp((i - 1)*dx) - 1)
53 rab(i) = dx*(r(i) + .001_dp)
55 r(i) = (i - 1)*.005_dp
59 potential(:) = coeff(1, 1)*exp(-
gamma(1)*r*r) + coeff(1, 2)*exp(-
gamma(2)*r*r)
60 ALLOCATE (pot%r(n), pot%rab(n), pot%vlocal(n))
64 pot%vlocal(:) = potential
66 IF (r(i) > 0._dp)
THEN
67 pot%vlocal(i) = potential(i) - pot%zion*erf(sqrt(.8_dp)*r(i))/r(i)
69 pot%vlocal(i) = potential(i) - 2*pot%zion*sqrt(.8_dp/
pi)
74 IF (grid == 4) threshold = 1.e-2_dp
78 ld =
ncoset(2*max(la, lb) + 2)
79 ALLOCATE (v(ma, mb), da(ma, mb, 3), db(ma, mb, 3), reference(ma, mb), density(ma, mb), s(ld, ld, la + lb + 3), fs(ld, ld, 4))
80 ALLOCATE (vri(ma), dri(ma, 3), rri(ma), rdri(ma, 3), energy_only(ma, mb))
83 density(i, j) = sin(real(17*i + 3*j,
dp))/real(ma*mb,
dp)
87 SELECT CASE (geometry)
91 rabv = [.3_dp, -.5_dp, .8_dp]; rac = [.2_dp, .4_dp, -.7_dp]
93 rabv = [3._dp, 2._dp, -1._dp]; rac = [-1._dp, 2._dp, .3_dp]
95 rabv = [-7._dp, 1._dp, 2._dp]; rac = [.5_dp, -.2_dp, 1.7_dp]
100 IF (maxval(abs(v - energy_only))/max(1._dp, maxval(abs(v))) > 1.e-12_dp)
THEN
101 error stop
'Energy-only and derivative local operators differ'
103 reference = 0; s = 0; fs = 0
104 CALL ppl_integral(la, 0, na, spread(100._dp, 1, na), alpha, lb, 0, nb, spread(100._dp, 1, nb), beta, &
105 2,
gamma, [1, 1], coeff, 100._dp, rabv, norm2(rabv), rac, norm2(rac), rbc, norm2(rbc), reference, s, &
106 density, force_a, force_b, fs)
107 scale = max(1._dp, maxval(abs(reference)))
108 error = maxval(abs(v - reference))/scale
110 ref_a(k) = sum(density*da(:, :, k))
111 ref_b(k) = sum(density*db(:, :, k))
113 IF (io_unit > 0)
WRITE (io_unit,
'(A,2I3,3ES18.9)')
'Native local matrix/derivative errors: ', grid, geometry, &
114 error, maxval(abs(force_a - ref_a)), maxval(abs(force_b - ref_b))
115 IF (error > 1.e-10_dp) error stop
'Local radial integral differs from analytic three-center reference'
116 IF (maxval(abs(force_a - ref_a)) > 1.e-10_dp .OR. maxval(abs(force_b - ref_b)) > 1.e-10_dp)
THEN
117 error stop
'Local derivative mismatch'
121 CALL ppl_integral_ri(la, 0, na, spread(100._dp, 1, na), alpha, 2,
gamma, [1, 1], coeff, 100._dp, &
122 -rac, norm2(rac), rri, rdri)
123 scale = max(1._dp, maxval(abs(rri)), maxval(abs(rdri)))
124 error = max(maxval(abs(vri - rri)), maxval(abs(dri - rdri)))/scale
125 IF (io_unit > 0)
WRITE (io_unit,
'(A,2I3,ES18.9)')
'Native local RI errors: ', grid, geometry, error
126 IF (error > 1.e-10_dp) error stop
'Local RI operator differs from analytic Gaussian integrals'
128 IF (maxval(abs(vri - rri))/scale > 1.e-10_dp) error stop
'Energy-only RI local operator mismatch'
130 DEALLOCATE (r, rab, potential, v, da, db, reference, density, s, fs, vri, dri, rri, rdri, energy_only)
136 ALLOCATE (v(ma, mb), da(ma, mb, 3), db(ma, mb, 3))
137 DO i = 1, command_argument_count()
138 CALL get_command_argument(i, filename)
141 INQUIRE (file=trim(filename)//
"/tests/UNIT_TESTS", exist=source_root_argument)
142 IF (source_root_argument) cycle
146 rabv = [.3_dp, -.5_dp, .8_dp]; rac = [.2_dp, .4_dp, -.7_dp]
148 IF (.NOT. all(ieee_is_finite(v)) .OR. .NOT. all(ieee_is_finite(da)) .OR. .NOT. all(ieee_is_finite(db)))
THEN
149 error stop
'Non-finite native local UPF integrals'
151 IF (io_unit > 0)
WRITE (io_unit,
'(A,1X,A,2ES18.9)') &
152 'Native local UPF:', trim(filename), cache%radial%radius, maxval(abs(v))
155 DEALLOCATE (v, da, db)
Calculation of three-center overlap integrals over Cartesian Gaussian-type functions for the second t...
subroutine, public ppl_integral(la_max_set, la_min_set, npgfa, rpgfa, zeta, lb_max_set, lb_min_set, npgfb, rpgfb, zetb, nexp_ppl, alpha_ppl, nct_ppl, cexp_ppl, rpgfc, rab, dab, rac, dac, rbc, dbc, vab, s, pab, force_a, force_b, fs, hab2, hab2_work, deltar, iatom, jatom, katom)
Calculation of three-center overlap integrals <a|c|b> over Cartesian Gaussian functions for the local...
subroutine, public ppl_integral_ri(la_max_set, la_min_set, npgfa, rpgfa, zeta, nexp_ppl, alpha_ppl, nct_ppl, cexp_ppl, rpgfc, rac, dac, va, dva)
Calculation of two-center overlap integrals <a|c> over Cartesian Gaussian functions for the local par...
Routines that process Quantum Espresso UPF files.
pure subroutine, public atom_release_upf(upfpot)
...
subroutine, public atom_read_upf(pot, upf_filename, read_header, read_augmentation)
...
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
Calculation of the incomplete Gamma function F_n(t) for multi-center integrals over Cartesian Gaussia...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_path_length
subroutine, public cp2k_finalize()
...
subroutine, public cp2k_init()
...
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
Provides Cartesian and spherical orbital pointers and indices.
subroutine, public init_orbital_pointers(maxl)
Initialize or update the orbital pointers.
integer, dimension(:), allocatable, public ncoset
Local UPF matrix elements from the original radial potential. The Gaussian core electrostatics suppli...
subroutine, public upf_local_matrix(local, la, alpha, lb, beta, rab, rac, v, da, db)
Evaluate primitive three-center local integrals by the Gaussian product theorem.
subroutine, public upf_local_init(pot, alpha, degree, local, eps)
Prepare the short-range local potential outside parallel regions.
subroutine, public upf_local_ri(local, la, zeta, rac, v, dv)
Local potential against a single Cartesian Gaussian for RI.
program upf_local_integrals_unittest