22#include "./base/base_uses.f90"
30 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_rho0_types'
36 REAL(
dp),
DIMENSION(:),
POINTER :: qlm_h => null(), &
40 REAL(
dp) :: qlm_z = -1.0_dp
41 REAL(
dp),
DIMENSION(2) :: q0 = -1.0_dp
46 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: qlm_gg => null()
47 REAL(
dp),
DIMENSION(:, :),
POINTER :: g0_h => null(), vg0_h => null()
48 REAL(
dp) :: rpgf0_h = -1.0_dp, rpgf0_s = -1.0_dp
55 POINTER :: mp_gau => null()
56 REAL(
dp) :: zet0_h = -1.0_dp, &
57 total_rho0_h = -1.0_dp
58 REAL(
dp) :: max_rpgf0_s = -1.0_dp
59 REAL(
dp),
DIMENSION(:),
POINTER :: norm_g0l_h => null()
60 INTEGER,
DIMENSION(:),
POINTER :: lmax0_kind => null()
61 INTEGER :: lmax_0 = -1, igrid_zet0_s = -1
97 INTEGER,
INTENT(IN) :: natom
99 INTEGER,
INTENT(IN) :: nkind
101 INTEGER :: iat, ikind
103 IF (
ASSOCIATED(mp_rho))
THEN
104 CALL deallocate_mpole_rho(mp_rho)
107 ALLOCATE (mp_rho(natom))
110 NULLIFY (mp_rho(iat)%Qlm_h)
111 NULLIFY (mp_rho(iat)%Qlm_s)
112 NULLIFY (mp_rho(iat)%Qlm_tot)
113 NULLIFY (mp_rho(iat)%Qlm_car)
116 IF (
ASSOCIATED(mp_gau))
THEN
117 CALL deallocate_mpole_gau(mp_gau)
120 ALLOCATE (mp_gau(nkind))
123 NULLIFY (mp_gau(ikind)%Qlm_gg)
124 NULLIFY (mp_gau(ikind)%g0_h)
125 NULLIFY (mp_gau(ikind)%vg0_h)
126 mp_gau(ikind)%rpgf0_h = 0.0_dp
127 mp_gau(ikind)%rpgf0_s = 0.0_dp
140 INTEGER,
INTENT(IN) :: natom
144 IF (
ASSOCIATED(rho0_set))
THEN
148 ALLOCATE (rho0_set(natom))
151 NULLIFY (rho0_set(iat)%rho0_rad_h)
152 NULLIFY (rho0_set(iat)%vrho0_rad_h)
166 INTEGER,
INTENT(IN) :: nr, nchannels
168 ALLOCATE (rho0_atom%rho0_rad_h)
170 NULLIFY (rho0_atom%rho0_rad_h%r_coef)
171 ALLOCATE (rho0_atom%rho0_rad_h%r_coef(1:nr, 1:nchannels))
172 rho0_atom%rho0_rad_h%r_coef = 0.0_dp
174 ALLOCATE (rho0_atom%vrho0_rad_h)
176 NULLIFY (rho0_atom%vrho0_rad_h%r_coef)
177 ALLOCATE (rho0_atom%vrho0_rad_h%r_coef(1:nr, 1:nchannels))
178 rho0_atom%vrho0_rad_h%r_coef = 0.0_dp
190 IF (
ASSOCIATED(rho0))
THEN
196 NULLIFY (rho0%mp_rho)
197 NULLIFY (rho0%mp_gau)
198 NULLIFY (rho0%norm_g0l_h)
199 NULLIFY (rho0%lmax0_kind)
200 NULLIFY (rho0%rho0_s_rs)
201 NULLIFY (rho0%rho0_s_gs)
215 INTEGER,
INTENT(IN) :: ik
217 INTEGER :: ir, l, lmax, nr
218 REAL(
dp) :: c1, prefactor, root_z_h, z_h
219 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: erf_z_h, gexp, gh_tmp, int1, int2
222 lmax = rho0_mpole%lmax0_kind(ik)
223 z_h = rho0_mpole%zet0_h
227 CALL reallocate(rho0_mpole%mp_gau(ik)%g0_h, 1, nr, 0, lmax)
228 CALL reallocate(rho0_mpole%mp_gau(ik)%vg0_h, 1, nr, 0, lmax)
230 ALLOCATE (gexp(nr), gh_tmp(nr), erf_z_h(nr), int1(nr), int2(nr))
232 gh_tmp(1:nr) = exp(-z_h*grid_atom%rad2(1:nr))
235 erf_z_h(ir) = erf(grid_atom%rad(ir)*root_z_h)
239 IF (gh_tmp(ir) < 1.0e-30_dp) gh_tmp(ir) = 0.0_dp
242 gexp(1:nr) = gh_tmp(1:nr)
243 rho0_mpole%mp_gau(ik)%g0_h(1:nr, 0) = gh_tmp(1:nr)* &
244 rho0_mpole%norm_g0l_h(0)
245 CALL whittaker_c0a(int1, grid_atom%rad, gh_tmp, erf_z_h, z_h, 0, 0, nr)
246 CALL whittaker_ci(int2, grid_atom%rad, gh_tmp, z_h, 0, nr)
248 prefactor =
fourpi*rho0_mpole%norm_g0l_h(0)
250 c1 = sqrt(
pi*
pi*
pi/(z_h*z_h*z_h))*rho0_mpole%norm_g0l_h(0)
253 rho0_mpole%mp_gau(ik)%vg0_h(ir, 0) = c1*erf_z_h(ir)*grid_atom%oorad2l(ir, 1)
257 gh_tmp(1:nr) = gh_tmp(1:nr)*grid_atom%rad(1:nr)
258 rho0_mpole%mp_gau(ik)%g0_h(1:nr, l) = gh_tmp(1:nr)* &
259 rho0_mpole%norm_g0l_h(l)
261 prefactor =
fourpi/(2.0_dp*l + 1.0_dp)*rho0_mpole%norm_g0l_h(l)
262 CALL whittaker_c0a(int1, grid_atom%rad, gexp, erf_z_h, z_h, l, l, nr)
264 rho0_mpole%mp_gau(ik)%vg0_h(ir, l) = prefactor*(int1(ir) + &
265 int2(ir)*grid_atom%rad2l(ir, l))
270 DEALLOCATE (gexp, erf_z_h, gh_tmp, int1, int2)
277 SUBROUTINE deallocate_mpole_gau(mp_gau)
281 INTEGER :: ikind, nkind
287 IF (
ASSOCIATED(mp_gau(ikind)%Qlm_gg))
THEN
288 DEALLOCATE (mp_gau(ikind)%Qlm_gg)
291 DEALLOCATE (mp_gau(ikind)%g0_h)
293 DEALLOCATE (mp_gau(ikind)%vg0_h)
298 END SUBROUTINE deallocate_mpole_gau
304 SUBROUTINE deallocate_mpole_rho(mp_rho)
308 INTEGER :: iat, natom
313 DEALLOCATE (mp_rho(iat)%Qlm_h)
314 DEALLOCATE (mp_rho(iat)%Qlm_s)
315 DEALLOCATE (mp_rho(iat)%Qlm_tot)
316 DEALLOCATE (mp_rho(iat)%Qlm_car)
321 END SUBROUTINE deallocate_mpole_rho
331 INTEGER :: iat, natom
333 IF (
ASSOCIATED(rho0_atom_set))
THEN
335 natom =
SIZE(rho0_atom_set)
338 IF (
ASSOCIATED(rho0_atom_set(iat)%rho0_rad_h))
THEN
339 DEALLOCATE (rho0_atom_set(iat)%rho0_rad_h%r_coef)
340 DEALLOCATE (rho0_atom_set(iat)%rho0_rad_h)
342 IF (
ASSOCIATED(rho0_atom_set(iat)%vrho0_rad_h))
THEN
343 DEALLOCATE (rho0_atom_set(iat)%vrho0_rad_h%r_coef)
344 DEALLOCATE (rho0_atom_set(iat)%vrho0_rad_h)
348 DEALLOCATE (rho0_atom_set)
350 CALL cp_abort(__location__, &
351 "The pointer rho0_atom_set is not associated and "// &
352 "cannot be deallocated")
364 IF (
ASSOCIATED(rho0))
THEN
366 IF (
ASSOCIATED(rho0%mp_gau))
CALL deallocate_mpole_gau(rho0%mp_gau)
368 IF (
ASSOCIATED(rho0%mp_rho))
CALL deallocate_mpole_rho(rho0%mp_rho)
370 IF (
ASSOCIATED(rho0%lmax0_kind))
THEN
371 DEALLOCATE (rho0%lmax0_kind)
374 IF (
ASSOCIATED(rho0%norm_g0l_h))
THEN
375 DEALLOCATE (rho0%norm_g0l_h)
378 IF (
ASSOCIATED(rho0%rho0_s_rs))
THEN
379 CALL rho0%rho0_s_rs%release()
380 DEALLOCATE (rho0%rho0_s_rs)
383 IF (
ASSOCIATED(rho0%rho0_s_gs))
THEN
384 CALL rho0%rho0_s_gs%release()
385 DEALLOCATE (rho0%rho0_s_gs)
390 CALL cp_abort(__location__, &
391 "The pointer rho0 is not associated and "// &
392 "cannot be deallocated")
420 SUBROUTINE get_rho0_mpole(rho0_mpole, g0_h, vg0_h, iat, ikind, lmax_0, l0_ikind, &
421 mp_gau_ikind, mp_rho, norm_g0l_h, &
422 Qlm_gg, Qlm_car, Qlm_tot, &
423 zet0_h, igrid_zet0_s, rpgf0_h, rpgf0_s, &
424 max_rpgf0_s, rho0_s_rs, rho0_s_gs)
427 REAL(
dp),
DIMENSION(:, :),
OPTIONAL,
POINTER :: g0_h, vg0_h
428 INTEGER,
INTENT(IN),
OPTIONAL :: iat, ikind
429 INTEGER,
INTENT(OUT),
OPTIONAL :: lmax_0, l0_ikind
433 REAL(
dp),
DIMENSION(:),
OPTIONAL,
POINTER :: norm_g0l_h
434 REAL(
dp),
DIMENSION(:, :, :),
OPTIONAL,
POINTER :: qlm_gg
435 REAL(
dp),
DIMENSION(:),
OPTIONAL,
POINTER :: qlm_car, qlm_tot
436 REAL(
dp),
INTENT(OUT),
OPTIONAL :: zet0_h
437 INTEGER,
INTENT(OUT),
OPTIONAL :: igrid_zet0_s
438 REAL(
dp),
INTENT(OUT),
OPTIONAL :: rpgf0_h, rpgf0_s, max_rpgf0_s
442 IF (
ASSOCIATED(rho0_mpole))
THEN
444 IF (
PRESENT(lmax_0)) lmax_0 = rho0_mpole%lmax_0
445 IF (
PRESENT(mp_rho)) mp_rho => rho0_mpole%mp_rho
446 IF (
PRESENT(norm_g0l_h)) norm_g0l_h => rho0_mpole%norm_g0l_h
447 IF (
PRESENT(zet0_h)) zet0_h = rho0_mpole%zet0_h
448 IF (
PRESENT(igrid_zet0_s)) igrid_zet0_s = rho0_mpole%igrid_zet0_s
449 IF (
PRESENT(max_rpgf0_s)) max_rpgf0_s = rho0_mpole%max_rpgf0_s
450 IF (
PRESENT(rho0_s_rs)) rho0_s_rs => rho0_mpole%rho0_s_rs
451 IF (
PRESENT(rho0_s_gs)) rho0_s_gs => rho0_mpole%rho0_s_gs
453 IF (
PRESENT(ikind))
THEN
454 IF (
PRESENT(l0_ikind)) l0_ikind = rho0_mpole%lmax0_kind(ikind)
455 IF (
PRESENT(mp_gau_ikind)) mp_gau_ikind => rho0_mpole%mp_gau(ikind)
456 IF (
PRESENT(g0_h)) g0_h => rho0_mpole%mp_gau(ikind)%g0_h
457 IF (
PRESENT(vg0_h)) vg0_h => rho0_mpole%mp_gau(ikind)%vg0_h
458 IF (
PRESENT(qlm_gg)) qlm_gg => rho0_mpole%mp_gau(ikind)%Qlm_gg
459 IF (
PRESENT(rpgf0_h)) rpgf0_h = rho0_mpole%mp_gau(ikind)%rpgf0_h
460 IF (
PRESENT(rpgf0_s)) rpgf0_s = rho0_mpole%mp_gau(ikind)%rpgf0_s
462 IF (
PRESENT(iat))
THEN
463 IF (
PRESENT(qlm_car)) qlm_car => rho0_mpole%mp_rho(iat)%Qlm_car
464 IF (
PRESENT(qlm_tot)) qlm_tot => rho0_mpole%mp_rho(iat)%Qlm_tot
468 cpabort(
"The pointer rho0_mpole is not associated")
483 INTEGER,
INTENT(IN) :: nchan_s, nchan_c
484 REAL(kind=
dp),
INTENT(IN) :: zeff
491 mp_rho%Qlm_h = 0.0_dp
492 mp_rho%Qlm_s = 0.0_dp
493 mp_rho%Qlm_tot = 0.0_dp
494 mp_rho%Qlm_car = 0.0_dp
495 mp_rho%Qlm_z = -2.0_dp*
rootpi*zeff
509 CHARACTER(LEN=*),
INTENT(IN) :: unit_str
510 INTEGER,
INTENT(in) :: output_unit
512 INTEGER :: ikind, l, nkind
515 IF (
ASSOCIATED(rho0_mpole))
THEN
518 WRITE (unit=output_unit, fmt=
"(/,T5,A,/)") &
519 "*** Compensation density charges data set ***"
520 WRITE (unit=output_unit, fmt=
"(T2,A,T35,f16.10)") &
521 "- Rho0 exponent :", rho0_mpole%zet0_h
522 WRITE (unit=output_unit, fmt=
"(T2,A,T35,I5)") &
523 "- Global max l :", rho0_mpole%lmax_0
525 WRITE (unit=output_unit, fmt=
"(T2,A)") &
526 "- Normalization constants for g0"
527 DO l = 0, rho0_mpole%lmax_0
528 WRITE (unit=output_unit, fmt=
"(T20,A,T31,I2,T38,A,f15.5)") &
529 "ang. mom.= ", l,
" hard= ", rho0_mpole%norm_g0l_h(l)
532 nkind =
SIZE(rho0_mpole%lmax0_kind, 1)
534 WRITE (unit=output_unit, fmt=
"(/,T2,A,T55,I2)") &
535 "- rho0 max L and radii in "//trim(unit_str)// &
536 " for the atom kind :", ikind
538 WRITE (unit=output_unit, fmt=
"(T2,T20,A,T55,I5)") &
539 "=> l max :", rho0_mpole%lmax0_kind(ikind)
541 WRITE (unit=output_unit, fmt=
"(T2,T20,A,T55,f20.10)") &
542 "=> max radius of g0: ", &
543 rho0_mpole%mp_gau(ikind)%rpgf0_h*conv
547 WRITE (unit=output_unit, fmt=
"(/,T5,A,/)") &
548 ' WARNING: I cannot print rho0, it is not associated'
real(kind=dp) function, public cp_unit_from_cp2k(value, unit_str, defaults, power)
converts from the internal cp2k units to the given unit
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
real(kind=dp), parameter, public rootpi
real(kind=dp), parameter, public fourpi
Utility routines for the memory handling.
subroutine, public allocate_multipoles(mp_rho, natom, mp_gau, nkind)
...
subroutine, public initialize_mpole_rho(mp_rho, nchan_s, nchan_c, zeff)
...
subroutine, public allocate_rho0_atom_rad(rho0_atom, nr, nchannels)
...
subroutine, public calculate_g0(rho0_mpole, grid_atom, ik)
...
subroutine, public write_rho0_info(rho0_mpole, unit_str, output_unit)
...
subroutine, public allocate_rho0_atom(rho0_set, natom)
...
subroutine, public allocate_rho0_mpole(rho0)
...
subroutine, public deallocate_rho0_mpole(rho0)
...
subroutine, public get_rho0_mpole(rho0_mpole, g0_h, vg0_h, iat, ikind, lmax_0, l0_ikind, mp_gau_ikind, mp_rho, norm_g0l_h, qlm_gg, qlm_car, qlm_tot, zet0_h, igrid_zet0_s, rpgf0_h, rpgf0_s, max_rpgf0_s, rho0_s_rs, rho0_s_gs)
...
subroutine, public deallocate_rho0_atom(rho0_atom_set)
...
Calculates special integrals.
subroutine, public whittaker_c0a(wc, r, expa, erfa, alpha, l1, l2, n)
int(y^(2+l1+l2) * exp(-alpha*y*y),y=0..x) / x^(l2+1); wc(:) :: output r(:) :: coordinate expa(:) :: e...
subroutine, public whittaker_ci(wc, r, expa, alpha, l, n)
int(y^(l+1) * exp(-alpha*y*y),y=x..infinity);