55#include "./base/base_uses.f90"
61 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_vxc_atom'
63 TYPE tau_basis_cache_type
64 INTEGER :: maxso = 0, na = 0, nr = 0, nsatbas = 0, &
66 INTEGER,
DIMENSION(:),
POINTER :: lmax => null(), lmin => null(), &
67 n2oindex => null(), npgf => null(), &
69 REAL(dp),
DIMENSION(:, :),
POINTER :: zet => null()
70 REAL(dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: grad
71 END TYPE tau_basis_cache_type
94 adiabatic_rescale_factor, kind_set_external, &
95 rho_atom_set_external, xc_section_external)
98 LOGICAL,
INTENT(IN) :: energy_only
99 REAL(
dp),
INTENT(INOUT) :: exc1
100 REAL(
dp),
INTENT(IN),
OPTIONAL :: adiabatic_rescale_factor
102 POINTER :: kind_set_external
104 POINTER :: rho_atom_set_external
107 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_vxc_atom'
109 INTEGER :: bo(2), handle, iat, iatom, ikind, ir, &
110 myfun, na, natom, nr, nspins, num_pe
111 INTEGER,
DIMENSION(2, 3) :: bounds
112 INTEGER,
DIMENSION(:),
POINTER :: atom_list
113 LOGICAL :: accint, donlcc, gradient_f, lsd, nlcc, &
115 REAL(
dp) :: agr, alpha, density_cut, exc_h, exc_s, &
117 my_adiabatic_rescale_factor, tau_cut
118 REAL(
dp),
DIMENSION(1, 1, 1) :: tau_d
119 REAL(
dp),
DIMENSION(1, 1, 1, 1) :: rho_d
120 REAL(
dp),
DIMENSION(:, :),
POINTER :: rho_nlcc, weight_h, weight_s
121 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rho_h, rho_s, tau_h, tau_s, vtau_h, &
123 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: drho_h, drho_s, vxg_h, vxg_s
130 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: my_kind_set
131 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr_h, dr_s, int_hh, int_ss, r_h, r_s
133 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: my_rho_atom_set
136 TYPE(tau_basis_cache_type) :: tau_basis_cache
143 CALL timeset(routinen, handle)
146 NULLIFY (my_kind_set)
147 NULLIFY (atomic_kind_set)
153 NULLIFY (my_rho_atom_set)
156 IF (
PRESENT(adiabatic_rescale_factor))
THEN
157 my_adiabatic_rescale_factor = adiabatic_rescale_factor
159 my_adiabatic_rescale_factor = 1.0_dp
163 dft_control=dft_control, &
165 atomic_kind_set=atomic_kind_set, &
166 qs_kind_set=my_kind_set, &
168 rho_atom_set=my_rho_atom_set)
170 IF (
PRESENT(kind_set_external)) my_kind_set => kind_set_external
171 IF (
PRESENT(rho_atom_set_external)) my_rho_atom_set => rho_atom_set_external
174 accint = dft_control%qs_control%gapw_control%accurate_xcint
178 IF (
PRESENT(xc_section_external)) my_xc_section => xc_section_external
186 my_rho_atom_set(:)%exc_h = 0.0_dp
187 my_rho_atom_set(:)%exc_s = 0.0_dp
196 lsd = dft_control%lsd
197 nspins = dft_control%nspins
200 calc_potential=.true.)
202 gradient_f = (needs%drho .OR. needs%drho_spin)
203 tau_f = (needs%tau .OR. needs%tau_spin)
209 NULLIFY (rho_h, drho_h, rho_s, drho_s, weight_h, weight_s)
210 NULLIFY (vxc_h, vxc_s, vxg_h, vxg_s)
211 NULLIFY (tau_h, tau_s)
212 NULLIFY (vtau_h, vtau_s)
216 DO ikind = 1,
SIZE(atomic_kind_set)
217 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
218 CALL get_qs_kind(my_kind_set(ikind), paw_atom=paw_atom, &
219 harmonics=harmonics, grid_atom=grid_atom)
220 CALL get_qs_kind(my_kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
222 IF (.NOT. paw_atom) cycle
225 na = grid_atom%ng_sphere
238 weight_h => grid_atom%weight
239 alpha = dft_control%qs_control%gapw_control%aw(ikind)
240 IF (
ASSOCIATED(grid_atom%gapw_weight_s))
THEN
241 IF (grid_atom%gapw_weight_alpha /= alpha)
DEALLOCATE (grid_atom%gapw_weight_s)
243 IF (.NOT.
ASSOCIATED(grid_atom%gapw_weight_s))
THEN
244 ALLOCATE (grid_atom%gapw_weight_s(na, nr))
246 agr = 1.0_dp - exp(-alpha*grid_atom%rad2(ir))
247 grid_atom%gapw_weight_s(:, ir) = grid_atom%weight(:, ir)*agr
249 grid_atom%gapw_weight_alpha = alpha
251 weight_s => grid_atom%gapw_weight_s
253 weight_h => grid_atom%weight
254 weight_s => grid_atom%weight
261 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
263 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
269 CALL reallocate(rho_h, 1, na, 1, nr, 1, nspins)
270 CALL reallocate(rho_s, 1, na, 1, nr, 1, nspins)
271 CALL reallocate(vxc_h, 1, na, 1, nr, 1, nspins)
272 CALL reallocate(vxc_s, 1, na, 1, nr, 1, nspins)
275 CALL reallocate(drho_h, 1, 4, 1, na, 1, nr, 1, nspins)
276 CALL reallocate(drho_s, 1, 4, 1, na, 1, nr, 1, nspins)
277 CALL reallocate(vxg_h, 1, 3, 1, na, 1, nr, 1, nspins)
278 CALL reallocate(vxg_s, 1, 3, 1, na, 1, nr, 1, nspins)
282 CALL create_tau_basis_cache(tau_basis_cache, grid_atom, basis_1c, harmonics)
283 CALL reallocate(tau_h, 1, na, 1, nr, 1, nspins)
284 CALL reallocate(tau_s, 1, na, 1, nr, 1, nspins)
285 CALL reallocate(vtau_h, 1, na, 1, nr, 1, nspins)
286 CALL reallocate(vtau_s, 1, na, 1, nr, 1, nspins)
293 rho_nlcc => my_kind_set(ikind)%nlcc_pot
294 IF (
ASSOCIATED(rho_nlcc)) donlcc = .true.
299 num_pe = para_env%num_pe
300 bo =
get_limit(natom, para_env%num_pe, para_env%mepos)
302 DO iat = bo(1), bo(2)
303 iatom = atom_list(iat)
305 my_rho_atom_set(iatom)%exc_h = 0.0_dp
306 my_rho_atom_set(iatom)%exc_s = 0.0_dp
308 rho_atom => my_rho_atom_set(iatom)
312 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
314 rho_rad_s=r_s, drho_rad_h=dr_h, &
315 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, &
321 CALL get_rho_atom(rho_atom=rho_atom, rho_rad_h=r_h, rho_rad_s=r_s)
326 CALL calc_tau_atom(tau_h, tau_s, rho_atom, tau_basis_cache, nspins)
333 ir, r_h, r_s, rho_h, rho_s, dr_h, dr_s, &
334 r_h_d, r_s_d, drho_h, drho_s)
336 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
337 ir, rho_nlcc(:, 1), rho_h, rho_s, rho_nlcc(:, 2), drho_h, drho_s)
343 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
344 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
345 ELSE IF (gradient_f)
THEN
346 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_d, na, ir)
347 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_d, na, ir)
349 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rho_d, tau_d, na, ir)
350 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rho_d, tau_d, na, ir)
358 CALL vxc_of_r_new(xc_fun_section, rho_set_h, deriv_set, 1, needs, weight_h, &
359 lsd, na, nr, exc_h, vxc_h, vxg_h, vtau_h, energy_only=energy_only, &
360 adiabatic_rescale_factor=my_adiabatic_rescale_factor)
361 rho_atom%exc_h = rho_atom%exc_h + exc_h
367 CALL vxc_of_r_new(xc_fun_section, rho_set_s, deriv_set, 1, needs, weight_s, &
368 lsd, na, nr, exc_s, vxc_s, vxg_s, vtau_s, energy_only=energy_only, &
369 adiabatic_rescale_factor=my_adiabatic_rescale_factor)
370 rho_atom%exc_s = rho_atom%exc_s + exc_s
374 exc1 = exc1 + rho_atom%exc_h - rho_atom%exc_s
380 IF (.NOT. energy_only)
THEN
381 NULLIFY (int_hh, int_ss)
382 CALL get_rho_atom(rho_atom=rho_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
384 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, &
385 grid_atom, basis_1c, harmonics, nspins)
388 grid_atom, basis_1c, harmonics, nspins)
391 CALL dgavtaudgb(vtau_h, vtau_s, int_hh, int_ss, &
392 tau_basis_cache, nspins)
395 NULLIFY (r_h, r_s, dr_h, dr_s)
398 IF (tau_f)
CALL release_tau_basis_cache(tau_basis_cache)
406 CALL para_env%sum(exc1)
408 IF (
ASSOCIATED(rho_h))
DEALLOCATE (rho_h)
409 IF (
ASSOCIATED(rho_s))
DEALLOCATE (rho_s)
410 IF (
ASSOCIATED(vxc_h))
DEALLOCATE (vxc_h)
411 IF (
ASSOCIATED(vxc_s))
DEALLOCATE (vxc_s)
414 IF (
ASSOCIATED(drho_h))
DEALLOCATE (drho_h)
415 IF (
ASSOCIATED(drho_s))
DEALLOCATE (drho_s)
416 IF (
ASSOCIATED(vxg_h))
DEALLOCATE (vxg_h)
417 IF (
ASSOCIATED(vxg_s))
DEALLOCATE (vxg_s)
421 IF (
ASSOCIATED(tau_h))
DEALLOCATE (tau_h)
422 IF (
ASSOCIATED(tau_s))
DEALLOCATE (tau_s)
423 IF (
ASSOCIATED(vtau_h))
DEALLOCATE (vtau_h)
424 IF (
ASSOCIATED(vtau_s))
DEALLOCATE (vtau_s)
429 CALL timestop(handle)
442 REAL(
dp),
INTENT(INOUT) :: exc1
445 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_vxc_atom_epr'
447 INTEGER :: bo(2), handle, ia, iat, iatom, idir, &
448 ikind, ir, ispin, myfun, na, natom, &
450 INTEGER,
DIMENSION(2, 3) :: bounds
451 INTEGER,
DIMENSION(:),
POINTER :: atom_list
452 LOGICAL :: accint, donlcc, gradient_f, lsd, nlcc, &
454 REAL(
dp) :: agr, alpha, density_cut, exc_h, exc_s, &
455 gradient_cut, tau_cut
456 REAL(
dp),
DIMENSION(1, 1, 1) :: tau_d
457 REAL(
dp),
DIMENSION(1, 1, 1, 1) :: rho_d
458 REAL(
dp),
DIMENSION(:, :),
POINTER :: rho_nlcc, weight_h, weight_s
459 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rho_h, rho_s, tau_h, tau_s, vtau_h, &
461 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: drho_h, drho_s, vxg_h, vxg_s
468 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: my_kind_set
469 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr_h, dr_s, int_hh, int_ss, r_h, r_s
471 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: my_rho_atom_set
474 TYPE(tau_basis_cache_type) :: tau_basis_cache
481 CALL timeset(routinen, handle)
484 NULLIFY (my_kind_set)
485 NULLIFY (atomic_kind_set)
491 NULLIFY (my_rho_atom_set)
495 dft_control=dft_control, &
497 atomic_kind_set=atomic_kind_set, &
498 qs_kind_set=my_kind_set, &
500 rho_atom_set=my_rho_atom_set)
503 accint = dft_control%qs_control%gapw_control%accurate_xcint
506 "PROPERTIES%LINRES%EPR%PRINT%G_TENSOR%XC")
513 my_rho_atom_set(:)%exc_h = 0.0_dp
514 my_rho_atom_set(:)%exc_s = 0.0_dp
523 lsd = dft_control%lsd
524 nspins = dft_control%nspins
527 calc_potential=.true.)
530 needs%drho_spin = .true.
532 gradient_f = (needs%drho .OR. needs%drho_spin)
533 tau_f = (needs%tau .OR. needs%tau_spin)
539 NULLIFY (rho_h, drho_h, rho_s, drho_s, weight_h, weight_s)
540 NULLIFY (vxc_h, vxc_s, vxg_h, vxg_s)
541 NULLIFY (tau_h, tau_s)
542 NULLIFY (vtau_h, vtau_s)
546 DO ikind = 1,
SIZE(atomic_kind_set)
547 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
548 CALL get_qs_kind(my_kind_set(ikind), paw_atom=paw_atom, &
549 harmonics=harmonics, grid_atom=grid_atom)
550 CALL get_qs_kind(my_kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
552 IF (.NOT. paw_atom) cycle
555 na = grid_atom%ng_sphere
568 weight_h => grid_atom%weight
569 alpha = dft_control%qs_control%gapw_control%aw(ikind)
570 IF (
ASSOCIATED(grid_atom%gapw_weight_s))
THEN
571 IF (grid_atom%gapw_weight_alpha /= alpha)
DEALLOCATE (grid_atom%gapw_weight_s)
573 IF (.NOT.
ASSOCIATED(grid_atom%gapw_weight_s))
THEN
574 ALLOCATE (grid_atom%gapw_weight_s(na, nr))
576 agr = 1.0_dp - exp(-alpha*grid_atom%rad2(ir))
577 grid_atom%gapw_weight_s(:, ir) = grid_atom%weight(:, ir)*agr
579 grid_atom%gapw_weight_alpha = alpha
581 weight_s => grid_atom%gapw_weight_s
583 weight_h => grid_atom%weight
584 weight_s => grid_atom%weight
591 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
593 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
599 CALL reallocate(rho_h, 1, na, 1, nr, 1, nspins)
600 CALL reallocate(rho_s, 1, na, 1, nr, 1, nspins)
601 CALL reallocate(vxc_h, 1, na, 1, nr, 1, nspins)
602 CALL reallocate(vxc_s, 1, na, 1, nr, 1, nspins)
605 CALL reallocate(drho_h, 1, 4, 1, na, 1, nr, 1, nspins)
606 CALL reallocate(drho_s, 1, 4, 1, na, 1, nr, 1, nspins)
607 CALL reallocate(vxg_h, 1, 3, 1, na, 1, nr, 1, nspins)
608 CALL reallocate(vxg_s, 1, 3, 1, na, 1, nr, 1, nspins)
612 CALL create_tau_basis_cache(tau_basis_cache, grid_atom, basis_1c, harmonics)
613 CALL reallocate(tau_h, 1, na, 1, nr, 1, nspins)
614 CALL reallocate(tau_s, 1, na, 1, nr, 1, nspins)
615 CALL reallocate(vtau_h, 1, na, 1, nr, 1, nspins)
616 CALL reallocate(vtau_s, 1, na, 1, nr, 1, nspins)
623 rho_nlcc => my_kind_set(ikind)%nlcc_pot
624 IF (
ASSOCIATED(rho_nlcc)) donlcc = .true.
629 num_pe = para_env%num_pe
630 bo =
get_limit(natom, para_env%num_pe, para_env%mepos)
632 DO iat = bo(1), bo(2)
633 iatom = atom_list(iat)
635 my_rho_atom_set(iatom)%exc_h = 0.0_dp
636 my_rho_atom_set(iatom)%exc_s = 0.0_dp
638 rho_atom => my_rho_atom_set(iatom)
642 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
644 rho_rad_s=r_s, drho_rad_h=dr_h, &
645 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, &
651 CALL get_rho_atom(rho_atom=rho_atom, rho_rad_h=r_h, rho_rad_s=r_s)
656 CALL calc_tau_atom(tau_h, tau_s, rho_atom, tau_basis_cache, nspins)
663 ir, r_h, r_s, rho_h, rho_s, dr_h, dr_s, &
664 r_h_d, r_s_d, drho_h, drho_s)
666 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
667 ir, rho_nlcc(:, 1), rho_h, rho_s, rho_nlcc(:, 2), drho_h, drho_s)
672 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
673 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
674 ELSE IF (gradient_f)
THEN
675 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_d, na, ir)
676 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_d, na, ir)
678 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rho_d, tau_d, na, ir)
679 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rho_d, tau_d, na, ir)
687 CALL vxc_of_r_epr(xc_fun_section, rho_set_h, deriv_set, needs, weight_h, &
688 lsd, na, nr, exc_h, vxc_h, vxg_h, vtau_h)
689 rho_atom%exc_h = rho_atom%exc_h + exc_h
695 CALL vxc_of_r_epr(xc_fun_section, rho_set_s, deriv_set, needs, weight_s, &
696 lsd, na, nr, exc_s, vxc_s, vxg_s, vtau_s)
697 rho_atom%exc_s = rho_atom%exc_s + exc_s
703 gradient_atom_set(iatom)%nablavks_vec_rad_h(idir, ispin)%r_coef(ir, ia) = &
704 gradient_atom_set(iatom)%nablavks_vec_rad_h(idir, ispin)%r_coef(ir, ia) &
705 + vxg_h(idir, ia, ir, ispin)
706 gradient_atom_set(iatom)%nablavks_vec_rad_s(idir, ispin)%r_coef(ir, ia) = &
707 gradient_atom_set(iatom)%nablavks_vec_rad_s(idir, ispin)%r_coef(ir, ia) &
708 + vxg_s(idir, ia, ir, ispin)
716 exc1 = exc1 + rho_atom%exc_h - rho_atom%exc_s
722 NULLIFY (int_hh, int_ss)
723 CALL get_rho_atom(rho_atom=rho_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
725 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, &
726 grid_atom, basis_1c, harmonics, nspins)
729 grid_atom, basis_1c, harmonics, nspins)
732 CALL dgavtaudgb(vtau_h, vtau_s, int_hh, int_ss, &
733 tau_basis_cache, nspins)
735 NULLIFY (r_h, r_s, dr_h, dr_s)
738 IF (tau_f)
CALL release_tau_basis_cache(tau_basis_cache)
746 CALL para_env%sum(exc1)
748 IF (
ASSOCIATED(rho_h))
DEALLOCATE (rho_h)
749 IF (
ASSOCIATED(rho_s))
DEALLOCATE (rho_s)
750 IF (
ASSOCIATED(vxc_h))
DEALLOCATE (vxc_h)
751 IF (
ASSOCIATED(vxc_s))
DEALLOCATE (vxc_s)
754 IF (
ASSOCIATED(drho_h))
DEALLOCATE (drho_h)
755 IF (
ASSOCIATED(drho_s))
DEALLOCATE (drho_s)
756 IF (
ASSOCIATED(vxg_h))
DEALLOCATE (vxg_h)
757 IF (
ASSOCIATED(vxg_s))
DEALLOCATE (vxg_s)
761 IF (
ASSOCIATED(tau_h))
DEALLOCATE (tau_h)
762 IF (
ASSOCIATED(tau_s))
DEALLOCATE (tau_s)
763 IF (
ASSOCIATED(vtau_h))
DEALLOCATE (vtau_h)
764 IF (
ASSOCIATED(vtau_s))
DEALLOCATE (vtau_s)
769 CALL timestop(handle)
786 do_tddfpt2, do_triplet, do_sf, kind_set_external)
788 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: rho_atom_set, rho1_atom_set
792 LOGICAL,
INTENT(IN),
OPTIONAL :: do_tddfpt2, do_triplet, do_sf
794 POINTER :: kind_set_external
796 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_xc_2nd_deriv_atom'
798 INTEGER ::
atom, handle, iatom, ikind, ir, na, &
800 INTEGER,
DIMENSION(2) :: local_loop_limit
801 INTEGER,
DIMENSION(2, 3) :: bounds
802 INTEGER,
DIMENSION(:),
POINTER :: atom_list
803 LOGICAL :: accint, gradient_functional, lsd, &
804 my_do_sf, paw_atom, scale_rho, tau_f
805 REAL(kind=
dp) :: agr, alpha, density_cut, gradient_cut, &
807 REAL(kind=
dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
808 POINTER :: vtau_h, vtau_s, vxc_h, vxc_s
809 REAL(kind=
dp),
DIMENSION(1, 1, 1) :: rtau
810 REAL(kind=
dp),
DIMENSION(1, 1, 1, 1) :: rrho
811 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: weight_h, weight_s
812 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: rho1_h, rho1_s, rho_h, rho_s, tau1_h, &
814 REAL(kind=
dp),
DIMENSION(:, :, :, :),
POINTER :: drho1_h, drho1_s, drho_h, drho_s, vxg_h, &
821 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: my_kind_set, qs_kind_set
822 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr1_h, dr1_s, dr_h, dr_s, int_hh, &
823 int_ss, r1_h, r1_s, r_h, r_s
824 TYPE(
rho_atom_coeff),
DIMENSION(:, :),
POINTER :: r1_h_d, r1_s_d, r_h_d, r_s_d
827 TYPE(tau_basis_cache_type) :: tau_basis_cache
835 CALL timeset(routinen, handle)
837 NULLIFY (qs_kind_set)
838 NULLIFY (rho_h, rho_s, drho_h, drho_s, weight_h, weight_s)
839 NULLIFY (rho1_h, rho1_s, drho1_h, drho1_s)
840 NULLIFY (vxc_h, vxc_s, vxg_h, vxg_s)
841 NULLIFY (tau_h, tau_s, tau1_h, tau1_s, vtau_h, vtau_s)
845 dft_control=dft_control, &
846 qs_kind_set=qs_kind_set, &
847 atomic_kind_set=atomic_kind_set)
849 IF (
PRESENT(kind_set_external))
THEN
850 my_kind_set => kind_set_external
852 my_kind_set => qs_kind_set
855 accint = dft_control%qs_control%gapw_control%accurate_xcint
866 IF (
PRESENT(do_sf)) my_do_sf = do_sf
877 IF (
PRESENT(do_tddfpt2) .AND.
PRESENT(do_triplet))
THEN
878 IF (nspins == 1 .AND. do_triplet)
THEN
882 ELSEIF (
PRESENT(do_triplet))
THEN
883 IF (nspins == 1 .AND. do_triplet) lsd = .true.
887 calc_potential=.true.)
888 gradient_functional = needs%drho .OR. needs%drho_spin
889 tau_f = (needs%tau .OR. needs%tau_spin)
890 IF (.NOT. tau_f) rtau = 0.0_dp
893 DO ikind = 1,
SIZE(atomic_kind_set)
895 NULLIFY (atom_list, harmonics, grid_atom)
896 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
897 CALL get_qs_kind(my_kind_set(ikind), paw_atom=paw_atom, &
898 harmonics=harmonics, grid_atom=grid_atom)
899 CALL get_qs_kind(my_kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
900 IF (.NOT. paw_atom) cycle
903 na = grid_atom%ng_sphere
907 weight_h => grid_atom%weight
908 alpha = dft_control%qs_control%gapw_control%aw(ikind)
909 IF (
ASSOCIATED(grid_atom%gapw_weight_s))
THEN
910 IF (grid_atom%gapw_weight_alpha /= alpha)
DEALLOCATE (grid_atom%gapw_weight_s)
912 IF (.NOT.
ASSOCIATED(grid_atom%gapw_weight_s))
THEN
913 ALLOCATE (grid_atom%gapw_weight_s(na, nr))
915 agr = 1.0_dp - exp(-alpha*grid_atom%rad2(ir))
916 grid_atom%gapw_weight_s(:, ir) = grid_atom%weight(:, ir)*agr
918 grid_atom%gapw_weight_alpha = alpha
920 weight_s => grid_atom%gapw_weight_s
922 weight_h => grid_atom%weight
923 weight_s => grid_atom%weight
935 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
937 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
939 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
941 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
944 IF (nspins == 1 .AND. .NOT. lsd)
THEN
956 ALLOCATE (rho_h(1:na, 1:nr, 1:nspins), rho1_h(1:na, 1:nr, 1:nspins), &
957 rho_s(1:na, 1:nr, 1:nspins), rho1_s(1:na, 1:nr, 1:nspins))
959 ALLOCATE (vxc_h(1:na, 1:nr, 1:nspins), vxc_s(1:na, 1:nr, 1:nspins))
964 CALL create_tau_basis_cache(tau_basis_cache, grid_atom, basis_1c, harmonics)
965 ALLOCATE (tau_h(1:na, 1:nr, 1:nspins), tau1_h(1:na, 1:nr, 1:nspins), &
966 tau_s(1:na, 1:nr, 1:nspins), tau1_s(1:na, 1:nr, 1:nspins))
967 ALLOCATE (vtau_h(1:na, 1:nr, 1:nspins), vtau_s(1:na, 1:nr, 1:nspins))
970 IF (gradient_functional)
THEN
971 ALLOCATE (drho_h(1:4, 1:na, 1:nr, 1:nspins), drho1_h(1:4, 1:na, 1:nr, 1:nspins), &
972 drho_s(1:4, 1:na, 1:nr, 1:nspins), drho1_s(1:4, 1:na, 1:nr, 1:nspins))
973 ALLOCATE (vxg_h(1:3, 1:na, 1:nr, 1:nspins), vxg_s(1:3, 1:na, 1:nr, 1:nspins))
975 ALLOCATE (drho_h(1, 1, 1, 1), drho1_h(1, 1, 1, 1), &
976 drho_s(1, 1, 1, 1), drho1_s(1, 1, 1, 1))
977 ALLOCATE (vxg_h(1, 1, 1, 1), vxg_s(1, 1, 1, 1))
984 local_loop_limit =
get_limit(natom, para_env%num_pe, para_env%mepos)
986 DO iatom = local_loop_limit(1), local_loop_limit(2)
987 atom = atom_list(iatom)
989 rho_atom_set(
atom)%exc_h = 0.0_dp
990 rho_atom_set(
atom)%exc_s = 0.0_dp
991 rho1_atom_set(
atom)%exc_h = 0.0_dp
992 rho1_atom_set(
atom)%exc_s = 0.0_dp
994 rho_atom => rho_atom_set(
atom)
995 rho1_atom => rho1_atom_set(
atom)
996 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
997 NULLIFY (r1_h, r1_s, dr1_h, dr1_s, r1_h_d, r1_s_d)
1002 IF (gradient_functional)
THEN
1004 rho_rad_h=r_h, rho_rad_s=r_s, &
1005 drho_rad_h=dr_h, drho_rad_s=dr_s, &
1006 rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
1008 rho_rad_h=r1_h, rho_rad_s=r1_s, &
1009 drho_rad_h=dr1_h, drho_rad_s=dr1_s, &
1010 rho_rad_h_d=r1_h_d, rho_rad_s_d=r1_s_d)
1011 drho_h = 0.0_dp; drho_s = 0.0_dp
1012 drho1_h = 0.0_dp; drho1_s = 0.0_dp
1015 rho_rad_h=r_h, rho_rad_s=r_s)
1017 rho_rad_h=r1_h, rho_rad_s=r1_s)
1024 ir, r_h, r_s, rho_h, rho_s, dr_h, dr_s, r_h_d, r_s_d, &
1027 ir, r1_h, r1_s, rho1_h, rho1_s, dr1_h, dr1_s, r1_h_d, r1_s_d, &
1031 CALL calc_tau_atom(tau_h, tau_s, rho_atom, tau_basis_cache, nspins)
1032 CALL calc_tau_atom(tau1_h, tau1_s, rho1_atom, tau_basis_cache, nspins)
1035 rho_h = 2.0_dp*rho_h
1036 rho_s = 2.0_dp*rho_s
1037 IF (gradient_functional)
THEN
1038 drho_h = 2.0_dp*drho_h
1039 drho_s = 2.0_dp*drho_s
1042 tau_h = 2.0_dp*tau_h
1043 tau_s = 2.0_dp*tau_s
1049 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
1050 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau1_h, na, ir)
1051 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
1052 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau1_s, na, ir)
1053 ELSE IF (gradient_functional)
THEN
1054 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, rtau, na, ir)
1055 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, rtau, na, ir)
1056 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, rtau, na, ir)
1057 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, rtau, na, ir)
1059 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rrho, rtau, na, ir)
1060 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, rrho, rtau, na, ir)
1061 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rrho, rtau, na, ir)
1062 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, rrho, rtau, na, ir)
1067 rho_set=rho_set_h, rho1_set=rho1_set_h, &
1068 deriv_set=deriv_set, &
1069 w=weight_h, vxc=vxc_h, vxg=vxg_h, vtau=vtau_h, do_triplet=do_triplet, &
1072 rho_set=rho_set_s, rho1_set=rho1_set_s, &
1073 deriv_set=deriv_set, &
1074 w=weight_s, vxc=vxc_s, vxg=vxg_s, vtau=vtau_s, do_triplet=do_triplet, &
1077 CALL get_rho_atom(rho_atom=rho1_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1078 IF (gradient_functional)
THEN
1079 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, &
1080 grid_atom, basis_1c, harmonics, nspins)
1083 grid_atom, basis_1c, harmonics, nspins)
1086 CALL dgavtaudgb(vtau_h, vtau_s, int_hh, int_ss, &
1087 tau_basis_cache, nspins)
1090 NULLIFY (r_h, r_s, dr_h, dr_s)
1095 DEALLOCATE (rho_h, rho_s, rho1_h, rho1_s, vxc_h, vxc_s)
1096 DEALLOCATE (drho_h, drho_s, vxg_h, vxg_s)
1097 DEALLOCATE (drho1_h, drho1_s)
1099 DEALLOCATE (tau_h, tau_s, tau1_h, tau1_s)
1100 DEALLOCATE (vtau_h, vtau_s)
1101 CALL release_tau_basis_cache(tau_basis_cache)
1111 CALL timestop(handle)
1127 kind_set, xc_section, is_triplet, accuracy)
1130 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: rho0_atom_set, rho1_atom_set, &
1134 LOGICAL,
INTENT(IN) :: is_triplet
1135 INTEGER,
INTENT(IN) :: accuracy
1137 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_gfxc_atom'
1138 REAL(kind=
dp),
PARAMETER :: epsrho = 5.e-4_dp
1140 INTEGER :: bo(2), handle, iat, iatom, ikind, ir, &
1141 istep, mspins, myfun, na, natom, nf, &
1142 nr, ns, nspins, nstep, num_pe
1143 INTEGER,
DIMENSION(2, 3) :: bounds
1144 INTEGER,
DIMENSION(:),
POINTER :: atom_list
1145 LOGICAL :: accint, donlcc, gradient_f, lsd, nlcc, &
1147 REAL(
dp) :: agr, alpha, beta, density_cut, exc_h, &
1148 exc_s, gradient_cut, oeps1, oeps2, &
1150 REAL(
dp),
DIMENSION(1, 1, 1) :: tau_d
1151 REAL(
dp),
DIMENSION(1, 1, 1, 1) :: rho_d
1152 REAL(
dp),
DIMENSION(:, :),
POINTER :: rho_nlcc, weight_h, weight_s
1153 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rho0_h, rho0_s, rho1_h, rho1_s, rho_h, &
1154 rho_s, tau0_h, tau0_s, tau1_h, tau1_s, &
1155 tau_h, tau_s, vtau_h, vtau_s, vxc_h, &
1157 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: drho0_h, drho0_s, drho1_h, drho1_s, &
1158 drho_h, drho_s, vxg_h, vxg_s
1159 REAL(kind=
dp),
DIMENSION(-4:4) :: ak, bl
1166 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr_h, dr_s, fint_hh, fint_ss, int_hh, &
1169 TYPE(
rho_atom_type),
POINTER :: rho0_atom, rho1_atom, rho2_atom
1171 TYPE(tau_basis_cache_type) :: tau_basis_cache
1176 CALL timeset(routinen, handle)
1178 NULLIFY (vtau_h, vtau_s)
1182 SELECT CASE (accuracy)
1185 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
1186 bl(-2:2) = [-1.0_dp, 16.0_dp, -30.0_dp, 16.0_dp, -1.0_dp]/12.0_dp
1189 ak(-3:3) = [-1.0_dp, 9.0_dp, -45.0_dp, 0.0_dp, 45.0_dp, -9.0_dp, 1.0_dp]/60.0_dp
1190 bl(-3:3) = [2.0_dp, -27.0_dp, 270.0_dp, -490.0_dp, 270.0_dp, -27.0_dp, 2.0_dp]/180.0_dp
1193 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
1194 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
1195 bl(-4:4) = [-1.0_dp, 128.0_dp/9.0_dp, -112.0_dp, 896.0_dp, -14350.0_dp/9.0_dp, &
1196 896.0_dp, -112.0_dp, 128.0_dp/9.0_dp, -1.0_dp]/560.0_dp
1198 oeps1 = 1.0_dp/epsrho
1199 oeps2 = 1.0_dp/(epsrho**2)
1202 dft_control=dft_control, &
1203 para_env=para_env, &
1204 atomic_kind_set=atomic_kind_set)
1209 accint = dft_control%qs_control%gapw_control%accurate_xcint
1219 lsd = dft_control%lsd
1220 nspins = dft_control%nspins
1222 IF (is_triplet)
THEN
1223 cpassert(nspins == 1)
1228 gradient_f = (needs%drho .OR. needs%drho_spin)
1229 tau_f = (needs%tau .OR. needs%tau_spin)
1232 DO ikind = 1,
SIZE(atomic_kind_set)
1233 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
1234 CALL get_qs_kind(kind_set(ikind), paw_atom=paw_atom, &
1235 harmonics=harmonics, grid_atom=grid_atom)
1236 CALL get_qs_kind(kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
1238 IF (.NOT. paw_atom) cycle
1241 na = grid_atom%ng_sphere
1245 weight_h => grid_atom%weight
1246 alpha = dft_control%qs_control%gapw_control%aw(ikind)
1247 IF (
ASSOCIATED(grid_atom%gapw_weight_s))
THEN
1248 IF (grid_atom%gapw_weight_alpha /= alpha)
DEALLOCATE (grid_atom%gapw_weight_s)
1250 IF (.NOT.
ASSOCIATED(grid_atom%gapw_weight_s))
THEN
1251 ALLOCATE (grid_atom%gapw_weight_s(na, nr))
1253 agr = 1.0_dp - exp(-alpha*grid_atom%rad2(ir))
1254 grid_atom%gapw_weight_s(:, ir) = grid_atom%weight(:, ir)*agr
1256 grid_atom%gapw_weight_alpha = alpha
1258 weight_s => grid_atom%gapw_weight_s
1260 weight_h => grid_atom%weight
1261 weight_s => grid_atom%weight
1269 bounds(1:2, 1:3) = 1
1277 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1279 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1285 ALLOCATE (rho_h(na, nr, mspins), rho_s(na, nr, mspins), &
1286 rho0_h(na, nr, nspins), rho0_s(na, nr, nspins), &
1287 rho1_h(na, nr, nspins), rho1_s(na, nr, nspins))
1288 ALLOCATE (vxc_h(na, nr, mspins), vxc_s(na, nr, mspins))
1289 IF (gradient_f)
THEN
1290 ALLOCATE (drho_h(4, na, nr, mspins), drho_s(4, na, nr, mspins), &
1291 drho0_h(4, na, nr, nspins), drho0_s(4, na, nr, nspins), &
1292 drho1_h(4, na, nr, nspins), drho1_s(4, na, nr, nspins))
1293 ALLOCATE (vxg_h(3, na, nr, mspins), vxg_s(3, na, nr, mspins))
1296 CALL create_tau_basis_cache(tau_basis_cache, grid_atom, basis_1c, harmonics)
1297 ALLOCATE (tau_h(na, nr, mspins), tau_s(na, nr, mspins), &
1298 tau0_h(na, nr, nspins), tau0_s(na, nr, nspins), &
1299 tau1_h(na, nr, nspins), tau1_s(na, nr, nspins))
1300 ALLOCATE (vtau_h(na, nr, mspins), vtau_s(na, nr, mspins))
1307 rho_nlcc => kind_set(ikind)%nlcc_pot
1308 IF (
ASSOCIATED(rho_nlcc)) donlcc = .true.
1312 num_pe = para_env%num_pe
1313 bo =
get_limit(natom, num_pe, para_env%mepos)
1315 DO iat = bo(1), bo(2)
1316 iatom = atom_list(iat)
1318 NULLIFY (int_hh, int_ss)
1319 rho0_atom => rho0_atom_set(iatom)
1320 CALL get_rho_atom(rho_atom=rho0_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1321 ALLOCATE (fint_ss(nspins), fint_hh(nspins))
1323 nf =
SIZE(int_ss(ns)%r_coef, 1)
1324 ALLOCATE (fint_ss(ns)%r_coef(nf, nf))
1325 nf =
SIZE(int_hh(ns)%r_coef, 1)
1326 ALLOCATE (fint_hh(ns)%r_coef(nf, nf))
1332 rho0_atom => rho0_atom_set(iatom)
1333 IF (gradient_f)
THEN
1334 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
1335 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
1336 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
1341 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s)
1346 ir, r_h, r_s, rho0_h, rho0_s, dr_h, dr_s, &
1347 r_h_d, r_s_d, drho0_h, drho0_s)
1349 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
1350 ir, rho_nlcc(:, 1), rho0_h, rho0_s, rho_nlcc(:, 2), drho0_h, drho0_s)
1355 CALL calc_tau_atom(tau0_h, tau0_s, rho0_atom, tau_basis_cache, nspins)
1362 rho1_atom => rho1_atom_set(iatom)
1363 IF (gradient_f)
THEN
1364 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
1365 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
1366 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
1371 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s)
1375 ir, r_h, r_s, rho1_h, rho1_s, dr_h, dr_s, &
1376 r_h_d, r_s_d, drho1_h, drho1_s)
1380 CALL calc_tau_atom(tau1_h, tau1_s, rho1_atom, tau_basis_cache, nspins)
1383 rho2_atom => rho2_atom_set(iatom)
1385 DO istep = -nstep, nstep
1387 beta = real(istep, kind=
dp)*epsrho
1389 IF (is_triplet)
THEN
1390 rho_h(:, :, 1) = rho0_h(:, :, 1) + beta*rho1_h(:, :, 1)
1391 rho_h(:, :, 2) = rho0_h(:, :, 1)
1392 rho_h = 0.5_dp*rho_h
1393 rho_s(:, :, 1) = rho0_s(:, :, 1) + beta*rho1_s(:, :, 1)
1394 rho_s(:, :, 2) = rho0_s(:, :, 1)
1395 rho_s = 0.5_dp*rho_s
1396 IF (gradient_f)
THEN
1397 drho_h(:, :, :, 1) = drho0_h(:, :, :, 1) + beta*drho1_h(:, :, :, 1)
1398 drho_h(:, :, :, 2) = drho0_h(:, :, :, 1)
1399 drho_h = 0.5_dp*drho_h
1400 drho_s(:, :, :, 1) = drho0_s(:, :, :, 1) + beta*drho1_s(:, :, :, 1)
1401 drho_s(:, :, :, 2) = drho0_s(:, :, :, 1)
1402 drho_s = 0.5_dp*drho_s
1405 tau_h(:, :, 1) = tau0_h(:, :, 1) + beta*tau1_h(:, :, 1)
1406 tau_h(:, :, 2) = tau0_h(:, :, 1)
1407 tau_h = 0.5_dp*tau0_h
1408 tau_s(:, :, 1) = tau0_s(:, :, 1) + beta*tau1_s(:, :, 1)
1409 tau_s(:, :, 2) = tau0_s(:, :, 1)
1410 tau_s = 0.5_dp*tau0_s
1413 rho_h = rho0_h + beta*rho1_h
1414 rho_s = rho0_s + beta*rho1_s
1415 IF (gradient_f)
THEN
1416 drho_h = drho0_h + beta*drho1_h
1417 drho_s = drho0_s + beta*drho1_s
1420 tau_h = tau0_h + beta*tau1_h
1421 tau_s = tau0_s + beta*tau1_s
1425 IF (gradient_f)
THEN
1426 drho_h(4, :, :, :) = sqrt( &
1427 drho_h(1, :, :, :)*drho_h(1, :, :, :) + &
1428 drho_h(2, :, :, :)*drho_h(2, :, :, :) + &
1429 drho_h(3, :, :, :)*drho_h(3, :, :, :))
1431 drho_s(4, :, :, :) = sqrt( &
1432 drho_s(1, :, :, :)*drho_s(1, :, :, :) + &
1433 drho_s(2, :, :, :)*drho_s(2, :, :, :) + &
1434 drho_s(3, :, :, :)*drho_s(3, :, :, :))
1439 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, drho_h, tau_h, na, ir)
1440 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, drho_s, tau_s, na, ir)
1441 ELSE IF (gradient_f)
THEN
1442 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, drho_h, tau_d, na, ir)
1443 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, drho_s, tau_d, na, ir)
1445 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, rho_d, tau_d, na, ir)
1446 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, rho_d, tau_d, na, ir)
1452 CALL vxc_of_r_new(xc_fun_section, rho_set_h, deriv_set, 1, needs, weight_h, &
1453 lsd, na, nr, exc_h, vxc_h, vxg_h, vtau_h)
1454 IF (is_triplet)
THEN
1455 vxc_h(:, :, 1) = vxc_h(:, :, 1) - vxc_h(:, :, 2)
1456 IF (gradient_f)
THEN
1457 vxg_h(:, :, :, 1) = vxg_h(:, :, :, 1) - vxg_h(:, :, :, 2)
1460 vtau_h(:, :, 1) = vtau_h(:, :, 1) - vtau_h(:, :, 2)
1465 CALL vxc_of_r_new(xc_fun_section, rho_set_s, deriv_set, 1, needs, weight_s, &
1466 lsd, na, nr, exc_s, vxc_s, vxg_s, vtau_s)
1467 IF (is_triplet)
THEN
1468 vxc_s(:, :, 1) = vxc_s(:, :, 1) - vxc_s(:, :, 2)
1469 IF (gradient_f)
THEN
1470 vxg_s(:, :, :, 1) = vxg_s(:, :, :, 1) - vxg_s(:, :, :, 2)
1473 vtau_s(:, :, 1) = vtau_s(:, :, 1) - vtau_s(:, :, 2)
1478 fint_hh(ns)%r_coef(:, :) = 0.0_dp
1479 fint_ss(ns)%r_coef(:, :) = 0.0_dp
1481 IF (gradient_f)
THEN
1482 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, fint_hh, fint_ss, &
1483 grid_atom, basis_1c, harmonics, nspins)
1486 grid_atom, basis_1c, harmonics, nspins)
1489 CALL dgavtaudgb(vtau_h, vtau_s, fint_hh, fint_ss, &
1490 tau_basis_cache, nspins)
1493 NULLIFY (int_hh, int_ss)
1494 CALL get_rho_atom(rho_atom=rho1_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1496 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_ss(ns)%r_coef(:, :)
1497 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_hh(ns)%r_coef(:, :)
1500 NULLIFY (int_hh, int_ss)
1501 CALL get_rho_atom(rho_atom=rho2_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1503 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps2*bl(istep)*fint_ss(ns)%r_coef(:, :)
1504 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps2*bl(istep)*fint_hh(ns)%r_coef(:, :)
1509 DEALLOCATE (fint_ss(ns)%r_coef)
1510 DEALLOCATE (fint_hh(ns)%r_coef)
1512 DEALLOCATE (fint_ss, fint_hh)
1521 DEALLOCATE (rho_h, rho_s, rho0_h, rho0_s, rho1_h, rho1_s)
1522 DEALLOCATE (vxc_h, vxc_s)
1523 IF (gradient_f)
THEN
1524 DEALLOCATE (drho_h, drho_s, drho0_h, drho0_s, drho1_h, drho1_s)
1525 DEALLOCATE (vxg_h, vxg_s)
1528 DEALLOCATE (tau_h, tau_s, tau0_h, tau0_s, tau1_h, tau1_s)
1529 DEALLOCATE (vtau_h, vtau_s)
1530 CALL release_tau_basis_cache(tau_basis_cache)
1536 CALL timestop(handle)
1553 kind_set, xc_section, is_triplet, accuracy, epsrho)
1556 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: rho0_atom_set, rho1_atom_set, &
1560 LOGICAL,
INTENT(IN) :: is_triplet
1561 INTEGER,
INTENT(IN) :: accuracy
1562 REAL(kind=
dp),
INTENT(IN) :: epsrho
1564 CHARACTER(LEN=*),
PARAMETER :: routinen =
'gfxc_atom_diff'
1566 INTEGER :: bo(2), handle, iat, iatom, ikind, ir, &
1567 istep, mspins, myfun, na, natom, nf, &
1568 nr, ns, nspins, nstep, num_pe
1569 INTEGER,
DIMENSION(2, 3) :: bounds
1570 INTEGER,
DIMENSION(:),
POINTER :: atom_list
1571 LOGICAL :: accint, donlcc, gradient_f, lsd, nlcc, &
1573 REAL(
dp) :: agr, alpha, beta, density_cut, &
1574 gradient_cut, oeps1, tau_cut
1575 REAL(
dp),
CONTIGUOUS,
DIMENSION(:, :, :),
POINTER :: vtau_h, vtau_s, vxc_h, vxc_s
1576 REAL(
dp),
DIMENSION(1, 1, 1) :: tau_d
1577 REAL(
dp),
DIMENSION(1, 1, 1, 1) :: rho_d
1578 REAL(
dp),
DIMENSION(:, :),
POINTER :: rho_nlcc, weight_h, weight_s
1579 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rho0_h, rho0_s, rho1_h, rho1_s, rho_h, &
1580 rho_s, tau0_h, tau0_s, tau1_h, tau1_s, &
1582 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: drho0_h, drho0_s, drho1_h, drho1_s, &
1583 drho_h, drho_s, vxg_h, vxg_s
1584 REAL(kind=
dp),
DIMENSION(-4:4) :: ak
1591 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr_h, dr_s, fint_hh, fint_ss, int_hh, &
1594 TYPE(
rho_atom_type),
POINTER :: rho0_atom, rho1_atom, rho2_atom
1596 TYPE(tau_basis_cache_type) :: tau_basis_cache
1602 CALL timeset(routinen, handle)
1604 NULLIFY (vtau_h, vtau_s)
1607 SELECT CASE (accuracy)
1610 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
1613 ak(-3:3) = [-1.0_dp, 9.0_dp, -45.0_dp, 0.0_dp, 45.0_dp, -9.0_dp, 1.0_dp]/60.0_dp
1616 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
1617 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
1619 oeps1 = 1.0_dp/epsrho
1622 dft_control=dft_control, &
1623 para_env=para_env, &
1624 atomic_kind_set=atomic_kind_set)
1629 accint = dft_control%qs_control%gapw_control%accurate_xcint
1636 do_triplet=is_triplet, kind_set_external=kind_set)
1643 lsd = dft_control%lsd
1644 nspins = dft_control%nspins
1646 IF (is_triplet)
THEN
1647 cpassert(nspins == 1)
1652 gradient_f = (needs%drho .OR. needs%drho_spin)
1653 tau_f = (needs%tau .OR. needs%tau_spin)
1656 DO ikind = 1,
SIZE(atomic_kind_set)
1657 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
1658 CALL get_qs_kind(kind_set(ikind), paw_atom=paw_atom, &
1659 harmonics=harmonics, grid_atom=grid_atom)
1660 CALL get_qs_kind(kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
1662 IF (.NOT. paw_atom) cycle
1665 na = grid_atom%ng_sphere
1669 weight_h => grid_atom%weight
1670 alpha = dft_control%qs_control%gapw_control%aw(ikind)
1671 IF (
ASSOCIATED(grid_atom%gapw_weight_s))
THEN
1672 IF (grid_atom%gapw_weight_alpha /= alpha)
DEALLOCATE (grid_atom%gapw_weight_s)
1674 IF (.NOT.
ASSOCIATED(grid_atom%gapw_weight_s))
THEN
1675 ALLOCATE (grid_atom%gapw_weight_s(na, nr))
1677 agr = 1.0_dp - exp(-alpha*grid_atom%rad2(ir))
1678 grid_atom%gapw_weight_s(:, ir) = grid_atom%weight(:, ir)*agr
1680 grid_atom%gapw_weight_alpha = alpha
1682 weight_s => grid_atom%gapw_weight_s
1684 weight_h => grid_atom%weight
1685 weight_s => grid_atom%weight
1693 bounds(1:2, 1:3) = 1
1701 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1703 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1705 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1707 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1715 ALLOCATE (rho_h(na, nr, nspins), rho_s(na, nr, nspins), &
1716 rho0_h(na, nr, nspins), rho0_s(na, nr, nspins), &
1717 rho1_h(na, nr, nspins), rho1_s(na, nr, nspins))
1718 ALLOCATE (vxc_h(na, nr, nspins), vxc_s(na, nr, nspins))
1719 IF (gradient_f)
THEN
1720 ALLOCATE (drho_h(4, na, nr, nspins), drho_s(4, na, nr, nspins), &
1721 drho0_h(4, na, nr, nspins), drho0_s(4, na, nr, nspins), &
1722 drho1_h(4, na, nr, nspins), drho1_s(4, na, nr, nspins))
1723 ALLOCATE (vxg_h(3, na, nr, nspins), vxg_s(3, na, nr, nspins))
1726 CALL create_tau_basis_cache(tau_basis_cache, grid_atom, basis_1c, harmonics)
1727 ALLOCATE (tau_h(na, nr, nspins), tau_s(na, nr, nspins), &
1728 tau0_h(na, nr, nspins), tau0_s(na, nr, nspins), &
1729 tau1_h(na, nr, nspins), tau1_s(na, nr, nspins))
1730 ALLOCATE (vtau_h(na, nr, nspins), vtau_s(na, nr, nspins))
1737 rho_nlcc => kind_set(ikind)%nlcc_pot
1738 IF (
ASSOCIATED(rho_nlcc)) donlcc = .true.
1742 num_pe = para_env%num_pe
1743 bo =
get_limit(natom, num_pe, para_env%mepos)
1745 DO iat = bo(1), bo(2)
1746 iatom = atom_list(iat)
1748 NULLIFY (int_hh, int_ss)
1749 rho0_atom => rho0_atom_set(iatom)
1750 CALL get_rho_atom(rho_atom=rho0_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1751 ALLOCATE (fint_ss(nspins), fint_hh(nspins))
1753 nf =
SIZE(int_ss(ns)%r_coef, 1)
1754 ALLOCATE (fint_ss(ns)%r_coef(nf, nf))
1755 nf =
SIZE(int_hh(ns)%r_coef, 1)
1756 ALLOCATE (fint_hh(ns)%r_coef(nf, nf))
1762 rho0_atom => rho0_atom_set(iatom)
1763 IF (gradient_f)
THEN
1764 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
1765 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
1766 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
1771 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s)
1776 ir, r_h, r_s, rho0_h, rho0_s, dr_h, dr_s, &
1777 r_h_d, r_s_d, drho0_h, drho0_s)
1779 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
1780 ir, rho_nlcc(:, 1), rho0_h, rho0_s, rho_nlcc(:, 2), drho0_h, drho0_s)
1785 CALL calc_tau_atom(tau0_h, tau0_s, rho0_atom, tau_basis_cache, nspins)
1792 rho1_atom => rho1_atom_set(iatom)
1793 IF (gradient_f)
THEN
1794 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
1795 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
1796 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
1801 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s)
1805 ir, r_h, r_s, rho1_h, rho1_s, dr_h, dr_s, &
1806 r_h_d, r_s_d, drho1_h, drho1_s)
1810 CALL calc_tau_atom(tau1_h, tau1_s, rho1_atom, tau_basis_cache, nspins)
1815 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau1_h, na, ir)
1816 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau1_s, na, ir)
1817 ELSE IF (gradient_f)
THEN
1818 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau_d, na, ir)
1819 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau_d, na, ir)
1821 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, rho_d, tau_d, na, ir)
1822 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, rho_d, tau_d, na, ir)
1827 rho2_atom => rho2_atom_set(iatom)
1829 DO istep = -nstep, nstep
1831 beta = real(istep, kind=
dp)*epsrho
1833 rho_h = rho0_h + beta*rho1_h
1834 rho_s = rho0_s + beta*rho1_s
1835 IF (gradient_f)
THEN
1836 drho_h = drho0_h + beta*drho1_h
1837 drho_s = drho0_s + beta*drho1_s
1840 tau_h = tau0_h + beta*tau1_h
1841 tau_s = tau0_s + beta*tau1_s
1844 IF (gradient_f)
THEN
1845 drho_h(4, :, :, :) = sqrt( &
1846 drho_h(1, :, :, :)*drho_h(1, :, :, :) + &
1847 drho_h(2, :, :, :)*drho_h(2, :, :, :) + &
1848 drho_h(3, :, :, :)*drho_h(3, :, :, :))
1850 drho_s(4, :, :, :) = sqrt( &
1851 drho_s(1, :, :, :)*drho_s(1, :, :, :) + &
1852 drho_s(2, :, :, :)*drho_s(2, :, :, :) + &
1853 drho_s(3, :, :, :)*drho_s(3, :, :, :))
1858 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
1859 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
1860 ELSE IF (gradient_f)
THEN
1861 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_d, na, ir)
1862 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_d, na, ir)
1864 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rho_d, tau_d, na, ir)
1865 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rho_d, tau_d, na, ir)
1872 rho_set=rho_set_h, rho1_set=rho1_set_h, &
1873 deriv_set=deriv_set, &
1874 w=weight_h, vxc=vxc_h, vxg=vxg_h, vtau=vtau_h, &
1875 do_triplet=is_triplet)
1879 rho_set=rho_set_s, rho1_set=rho1_set_s, &
1880 deriv_set=deriv_set, &
1881 w=weight_s, vxc=vxc_s, vxg=vxg_s, vtau=vtau_s, &
1882 do_triplet=is_triplet)
1885 fint_hh(ns)%r_coef(:, :) = 0.0_dp
1886 fint_ss(ns)%r_coef(:, :) = 0.0_dp
1888 IF (gradient_f)
THEN
1889 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, fint_hh, fint_ss, &
1890 grid_atom, basis_1c, harmonics, nspins)
1893 grid_atom, basis_1c, harmonics, nspins)
1896 CALL dgavtaudgb(vtau_h, vtau_s, fint_hh, fint_ss, &
1897 tau_basis_cache, nspins)
1900 NULLIFY (int_hh, int_ss)
1901 CALL get_rho_atom(rho_atom=rho2_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1903 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_ss(ns)%r_coef(:, :)
1904 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_hh(ns)%r_coef(:, :)
1909 DEALLOCATE (fint_ss(ns)%r_coef)
1910 DEALLOCATE (fint_hh(ns)%r_coef)
1912 DEALLOCATE (fint_ss, fint_hh)
1923 DEALLOCATE (rho_h, rho_s, rho0_h, rho0_s, rho1_h, rho1_s)
1924 DEALLOCATE (vxc_h, vxc_s)
1925 IF (gradient_f)
THEN
1926 DEALLOCATE (drho_h, drho_s, drho0_h, drho0_s, drho1_h, drho1_s)
1927 DEALLOCATE (vxg_h, vxg_s)
1930 DEALLOCATE (tau_h, tau_s, tau0_h, tau0_s, tau1_h, tau1_s)
1931 DEALLOCATE (vtau_h, vtau_s)
1932 CALL release_tau_basis_cache(tau_basis_cache)
1938 CALL timestop(handle)
1961 ir, r_h, r_s, rho_h, rho_s, &
1962 dr_h, dr_s, r_h_d, r_s_d, drho_h, drho_s)
1966 INTEGER,
INTENT(IN) :: nspins
1967 LOGICAL,
INTENT(IN) :: grad_func
1968 INTEGER,
INTENT(IN) :: ir
1970 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: rho_h, rho_s
1973 REAL(kind=
dp),
DIMENSION(:, :, :, :),
POINTER :: drho_h, drho_s
1975 INTEGER :: ia, iso, ispin, na
1976 REAL(kind=
dp) :: rad, urad
1978 cpassert(
ASSOCIATED(r_h))
1979 cpassert(
ASSOCIATED(r_s))
1980 cpassert(
ASSOCIATED(rho_h))
1981 cpassert(
ASSOCIATED(rho_s))
1983 cpassert(
ASSOCIATED(dr_h))
1984 cpassert(
ASSOCIATED(dr_s))
1985 cpassert(
ASSOCIATED(r_h_d))
1986 cpassert(
ASSOCIATED(r_s_d))
1987 cpassert(
ASSOCIATED(drho_h))
1988 cpassert(
ASSOCIATED(drho_s))
1991 na = grid_atom%ng_sphere
1992 rad = grid_atom%rad(ir)
1993 urad = grid_atom%oorad2l(ir, 1)
1994 DO ispin = 1, nspins
1995 DO iso = 1, harmonics%max_iso_not0
1997 rho_h(ia, ir, ispin) = rho_h(ia, ir, ispin) + &
1998 r_h(ispin)%r_coef(ir, iso)*harmonics%slm(ia, iso)
1999 rho_s(ia, ir, ispin) = rho_s(ia, ir, ispin) + &
2000 r_s(ispin)%r_coef(ir, iso)*harmonics%slm(ia, iso)
2006 DO ispin = 1, nspins
2007 DO iso = 1, harmonics%max_iso_not0
2011 drho_h(1, ia, ir, ispin) = drho_h(1, ia, ir, ispin) + &
2012 dr_h(ispin)%r_coef(ir, iso)* &
2013 harmonics%a(1, ia)*harmonics%slm(ia, iso) + &
2014 r_h_d(1, ispin)%r_coef(ir, iso)* &
2015 harmonics%slm(ia, iso)
2017 drho_h(2, ia, ir, ispin) = drho_h(2, ia, ir, ispin) + &
2018 dr_h(ispin)%r_coef(ir, iso)* &
2019 harmonics%a(2, ia)*harmonics%slm(ia, iso) + &
2020 r_h_d(2, ispin)%r_coef(ir, iso)* &
2021 harmonics%slm(ia, iso)
2023 drho_h(3, ia, ir, ispin) = drho_h(3, ia, ir, ispin) + &
2024 dr_h(ispin)%r_coef(ir, iso)* &
2025 harmonics%a(3, ia)*harmonics%slm(ia, iso) + &
2026 r_h_d(3, ispin)%r_coef(ir, iso)* &
2027 harmonics%slm(ia, iso)
2030 drho_s(1, ia, ir, ispin) = drho_s(1, ia, ir, ispin) + &
2031 dr_s(ispin)%r_coef(ir, iso)* &
2032 harmonics%a(1, ia)*harmonics%slm(ia, iso) + &
2033 r_s_d(1, ispin)%r_coef(ir, iso)* &
2034 harmonics%slm(ia, iso)
2036 drho_s(2, ia, ir, ispin) = drho_s(2, ia, ir, ispin) + &
2037 dr_s(ispin)%r_coef(ir, iso)* &
2038 harmonics%a(2, ia)*harmonics%slm(ia, iso) + &
2039 r_s_d(2, ispin)%r_coef(ir, iso)* &
2040 harmonics%slm(ia, iso)
2042 drho_s(3, ia, ir, ispin) = drho_s(3, ia, ir, ispin) + &
2043 dr_s(ispin)%r_coef(ir, iso)* &
2044 harmonics%a(3, ia)*harmonics%slm(ia, iso) + &
2045 r_s_d(3, ispin)%r_coef(ir, iso)* &
2046 harmonics%slm(ia, iso)
2051 drho_h(4, ia, ir, ispin) = sqrt( &
2052 drho_h(1, ia, ir, ispin)*drho_h(1, ia, ir, ispin) + &
2053 drho_h(2, ia, ir, ispin)*drho_h(2, ia, ir, ispin) + &
2054 drho_h(3, ia, ir, ispin)*drho_h(3, ia, ir, ispin))
2056 drho_s(4, ia, ir, ispin) = sqrt( &
2057 drho_s(1, ia, ir, ispin)*drho_s(1, ia, ir, ispin) + &
2058 drho_s(2, ia, ir, ispin)*drho_s(2, ia, ir, ispin) + &
2059 drho_s(3, ia, ir, ispin)*drho_s(3, ia, ir, ispin))
2073 SUBROUTINE create_tau_basis_cache(tau_cache, grid_atom, basis_1c, harmonics)
2075 TYPE(tau_basis_cache_type),
INTENT(INOUT) :: tau_cache
2080 INTEGER :: dir, ia, igrid, ip, ipgf, ir, iset, iso, &
2082 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: a1, a2, gexp, r1, r2
2083 REAL(
dp),
DIMENSION(:, :),
POINTER :: slm
2084 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dslm_dxyz
2086 NULLIFY (slm, dslm_dxyz)
2088 CALL release_tau_basis_cache(tau_cache)
2091 lmin=tau_cache%lmin, maxso=tau_cache%maxso, &
2092 npgf=tau_cache%npgf, nset=tau_cache%nset, &
2095 n2oindex=tau_cache%n2oindex, &
2096 nsatbas=tau_cache%nsatbas)
2098 tau_cache%nr = grid_atom%nr
2099 tau_cache%na = grid_atom%ng_sphere
2100 slm => harmonics%slm
2101 dslm_dxyz => harmonics%dslm_dxyz
2103 ALLOCATE (tau_cache%grad(tau_cache%na*tau_cache%nr, tau_cache%nsatbas, 3))
2104 ALLOCATE (a1(tau_cache%na), a2(tau_cache%na), gexp(tau_cache%nr), &
2105 r1(tau_cache%nr), r2(tau_cache%nr))
2106 tau_cache%grad = 0.0_dp
2108 DO iset = 1, tau_cache%nset
2109 DO ipgf = 1, tau_cache%npgf(iset)
2110 starti = (iset - 1)*tau_cache%maxso + &
2111 (ipgf - 1)*
nsoset(tau_cache%lmax(iset))
2112 gexp(1:tau_cache%nr) = exp(-tau_cache%zet(ipgf, iset)* &
2113 grid_atom%rad2(1:tau_cache%nr))
2114 DO iso =
nsoset(tau_cache%lmin(iset) - 1) + 1,
nsoset(tau_cache%lmax(iset))
2115 ip = tau_cache%o2nindex(starti + iso)
2119 r1(1:tau_cache%nr) = grid_atom%rad(1:tau_cache%nr)**(l - 1)*gexp(1:tau_cache%nr)
2120 r2(1:tau_cache%nr) = -2.0_dp*tau_cache%zet(ipgf, iset)* &
2121 grid_atom%rad2(1:tau_cache%nr)*r1(1:tau_cache%nr)
2124 a1(1:tau_cache%na) = dslm_dxyz(dir, 1:tau_cache%na, iso)
2125 a2(1:tau_cache%na) = harmonics%a(dir, 1:tau_cache%na)*slm(1:tau_cache%na, iso)
2126 DO ir = 1, tau_cache%nr
2127 DO ia = 1, tau_cache%na
2128 igrid = ia + (ir - 1)*tau_cache%na
2129 tau_cache%grad(igrid, ip, dir) = r1(ir)*a1(ia) + r2(ir)*a2(ia)
2137 DEALLOCATE (a1, a2, gexp, r1, r2)
2139 END SUBROUTINE create_tau_basis_cache
2145 SUBROUTINE release_tau_basis_cache(tau_cache)
2147 TYPE(tau_basis_cache_type),
INTENT(INOUT) :: tau_cache
2149 IF (
ALLOCATED(tau_cache%grad))
DEALLOCATE (tau_cache%grad)
2150 IF (
ASSOCIATED(tau_cache%n2oindex))
DEALLOCATE (tau_cache%n2oindex)
2151 IF (
ASSOCIATED(tau_cache%o2nindex))
DEALLOCATE (tau_cache%o2nindex)
2152 NULLIFY (tau_cache%lmax, tau_cache%lmin, tau_cache%n2oindex, tau_cache%npgf, &
2153 tau_cache%zet, tau_cache%o2nindex)
2157 tau_cache%nsatbas = 0
2160 END SUBROUTINE release_tau_basis_cache
2173 SUBROUTINE calc_tau_atom(tau_h, tau_s, rho_atom, tau_cache, nspins)
2175 REAL(
dp),
DIMENSION(:, :, :),
INTENT(INOUT) :: tau_h, tau_s
2177 TYPE(tau_basis_cache_type),
INTENT(IN) :: tau_cache
2178 INTEGER,
INTENT(IN) :: nspins
2180 CHARACTER(len=*),
PARAMETER :: routinen =
'calc_tau_atom'
2182 INTEGER :: dir, handle, ia, ibas, igrid, ir, ispin, &
2184 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: work
2186 CALL timeset(routinen, handle)
2188 cpassert(
ALLOCATED(tau_cache%grad))
2196 nbas = tau_cache%nsatbas
2198 ALLOCATE (work(ngrid, nbas))
2200 DO ispin = 1, nspins
2202 CALL dgemm(
'N',
'T', ngrid, nbas, nbas, 0.5_dp, tau_cache%grad(:, :, dir), &
2203 ngrid, rho_atom%cpc_h(ispin)%r_coef, nbas, 0.0_dp, work, ngrid)
2207 igrid = ia + (ir - 1)*na
2208 tau_h(ia, ir, ispin) = tau_h(ia, ir, ispin) + &
2209 tau_cache%grad(igrid, ibas, dir)*work(igrid, ibas)
2214 CALL dgemm(
'N',
'T', ngrid, nbas, nbas, 0.5_dp, tau_cache%grad(:, :, dir), &
2215 ngrid, rho_atom%cpc_s(ispin)%r_coef, nbas, 0.0_dp, work, ngrid)
2219 igrid = ia + (ir - 1)*na
2220 tau_s(ia, ir, ispin) = tau_s(ia, ir, ispin) + &
2221 tau_cache%grad(igrid, ibas, dir)*work(igrid, ibas)
2230 CALL timestop(handle)
2232 END SUBROUTINE calc_tau_atom
2247 SUBROUTINE calc_rho_nlcc(grid_atom, nspins, grad_func, &
2248 ir, rho_nlcc, rho_h, rho_s, drho_nlcc, drho_h, drho_s)
2251 INTEGER,
INTENT(IN) :: nspins
2252 LOGICAL,
INTENT(IN) :: grad_func
2253 INTEGER,
INTENT(IN) :: ir
2254 REAL(kind=
dp),
DIMENSION(:) :: rho_nlcc
2255 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: rho_h, rho_s
2256 REAL(kind=
dp),
DIMENSION(:) :: drho_nlcc
2257 REAL(kind=
dp),
DIMENSION(:, :, :, :),
POINTER :: drho_h, drho_s
2259 INTEGER :: ia, ispin, na
2260 REAL(kind=
dp) :: drho, dx, dy, dz, rad, rho, urad, xsp
2262 cpassert(
ASSOCIATED(rho_h))
2263 cpassert(
ASSOCIATED(rho_s))
2265 cpassert(
ASSOCIATED(drho_h))
2266 cpassert(
ASSOCIATED(drho_s))
2269 na = grid_atom%ng_sphere
2270 rad = grid_atom%rad(ir)
2271 urad = grid_atom%oorad2l(ir, 1)
2273 xsp = real(nspins, kind=
dp)
2274 rho = rho_nlcc(ir)/xsp
2275 DO ispin = 1, nspins
2276 rho_h(1:na, ir, ispin) = rho_h(1:na, ir, ispin) + rho
2277 rho_s(1:na, ir, ispin) = rho_s(1:na, ir, ispin) + rho
2281 drho = drho_nlcc(ir)/xsp
2282 DO ispin = 1, nspins
2284 IF (grid_atom%azi(ia) == 0.0_dp)
THEN
2288 dx = grid_atom%sin_pol(ia)*grid_atom%sin_azi(ia)
2289 dy = grid_atom%sin_pol(ia)*grid_atom%cos_azi(ia)
2291 dz = grid_atom%cos_pol(ia)
2293 drho_h(1, ia, ir, ispin) = drho_h(1, ia, ir, ispin) + drho*dx
2294 drho_h(2, ia, ir, ispin) = drho_h(2, ia, ir, ispin) + drho*dy
2295 drho_h(3, ia, ir, ispin) = drho_h(3, ia, ir, ispin) + drho*dz
2297 drho_s(1, ia, ir, ispin) = drho_s(1, ia, ir, ispin) + drho*dx
2298 drho_s(2, ia, ir, ispin) = drho_s(2, ia, ir, ispin) + drho*dy
2299 drho_s(3, ia, ir, ispin) = drho_s(3, ia, ir, ispin) + drho*dz
2301 drho_h(4, ia, ir, ispin) = sqrt( &
2302 drho_h(1, ia, ir, ispin)*drho_h(1, ia, ir, ispin) + &
2303 drho_h(2, ia, ir, ispin)*drho_h(2, ia, ir, ispin) + &
2304 drho_h(3, ia, ir, ispin)*drho_h(3, ia, ir, ispin))
2306 drho_s(4, ia, ir, ispin) = sqrt( &
2307 drho_s(1, ia, ir, ispin)*drho_s(1, ia, ir, ispin) + &
2308 drho_s(2, ia, ir, ispin)*drho_s(2, ia, ir, ispin) + &
2309 drho_s(3, ia, ir, ispin)*drho_s(3, ia, ir, ispin))
2314 END SUBROUTINE calc_rho_nlcc
2327 SUBROUTINE gavxcgb_nogc(vxc_h, vxc_s, int_hh, int_ss, grid_atom, basis_1c, harmonics, nspins)
2329 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: vxc_h, vxc_s
2334 INTEGER,
INTENT(IN) :: nspins
2336 CHARACTER(len=*),
PARAMETER :: routinen =
'gaVxcgb_noGC'
2338 INTEGER :: handle, ia, ic, icg, ipgf1, ipgf2, ir, iset1, iset2, iso, iso1, iso2, ispin, l, &
2339 ld, lmax12, lmax_expansion, lmin12, m1, m2, max_iso_not0, max_iso_not0_local, max_s_harm, &
2340 maxl, maxso, n1, n2, na, ngau1, ngau2, nngau1, nr, nset, size1
2341 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: cg_n_list
2342 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: cg_list
2343 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf
2344 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: g1, g2
2345 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: gg, gvg_h, gvg_s, matso_h, matso_s, vx
2346 REAL(
dp),
DIMENSION(:, :),
POINTER :: zet
2347 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: my_cg
2349 CALL timeset(routinen, handle)
2351 NULLIFY (lmin, lmax, npgf, zet, my_cg)
2354 maxso=maxso, maxl=maxl, npgf=npgf, &
2358 na = grid_atom%ng_sphere
2359 my_cg => harmonics%my_CG
2360 max_iso_not0 = harmonics%max_iso_not0
2361 lmax_expansion =
indso(1, max_iso_not0)
2362 max_s_harm = harmonics%max_s_harm
2364 ALLOCATE (g1(nr), g2(nr), gg(nr, 0:2*maxl))
2365 ALLOCATE (gvg_h(na, 0:2*maxl), gvg_s(na, 0:2*maxl))
2368 ALLOCATE (vx(na, nr))
2369 ALLOCATE (cg_list(2,
nsoset(maxl)**2, max_s_harm), cg_n_list(max_s_harm))
2378 CALL get_none0_cg_list(my_cg, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
2379 max_s_harm, lmax_expansion, cg_list, cg_n_list, max_iso_not0_local)
2380 cpassert(max_iso_not0_local <= max_iso_not0)
2383 DO ipgf1 = 1, npgf(iset1)
2384 ngau1 = n1*(ipgf1 - 1) + m1
2386 nngau1 =
nsoset(lmin(iset1) - 1) + ngau1
2388 g1(1:nr) = exp(-zet(ipgf1, iset1)*grid_atom%rad2(1:nr))
2389 DO ipgf2 = 1, npgf(iset2)
2390 ngau2 = n2*(ipgf2 - 1) + m2
2392 g2(1:nr) = exp(-zet(ipgf2, iset2)*grid_atom%rad2(1:nr))
2393 lmin12 = lmin(iset1) + lmin(iset2)
2394 lmax12 = lmax(iset1) + lmax(iset2)
2397 IF (lmin12 <= lmax_expansion)
THEN
2400 IF (lmin12 == 0)
THEN
2401 gg(1:nr, lmin12) = g1(1:nr)*g2(1:nr)
2403 gg(1:nr, lmin12) = grid_atom%rad2l(1:nr, lmin12)*g1(1:nr)*g2(1:nr)
2407 IF (lmax12 > lmax_expansion) lmax12 = lmax_expansion
2409 DO l = lmin12 + 1, lmax12
2410 gg(1:nr, l) = grid_atom%rad(1:nr)*gg(:, l - 1)
2413 DO ispin = 1, nspins
2416 vx(1:na, ir) = vxc_h(1:na, ir, ispin)
2418 CALL dgemm(
'N',
'N', na, ld, nr, 1.0_dp, vx(1:na, 1:nr), na, &
2419 gg(1:nr, 0:lmax12), nr, 0.0_dp, gvg_h(1:na, 0:lmax12), na)
2421 vx(1:na, ir) = vxc_s(1:na, ir, ispin)
2423 CALL dgemm(
'N',
'N', na, ld, nr, 1.0_dp, vx(1:na, 1:nr), na, &
2424 gg(1:nr, 0:lmax12), nr, 0.0_dp, gvg_s(1:na, 0:lmax12), na)
2428 DO iso = 1, max_iso_not0_local
2429 DO icg = 1, cg_n_list(iso)
2430 iso1 = cg_list(1, icg, iso)
2431 iso2 = cg_list(2, icg, iso)
2434 cpassert(l <= lmax_expansion)
2436 matso_h(iso1, iso2) = matso_h(iso1, iso2) + &
2438 my_cg(iso1, iso2, iso)* &
2439 harmonics%slm(ia, iso)
2440 matso_s(iso1, iso2) = matso_s(iso1, iso2) + &
2442 my_cg(iso1, iso2, iso)* &
2443 harmonics%slm(ia, iso)
2449 DO ic =
nsoset(lmin(iset2) - 1) + 1,
nsoset(lmax(iset2))
2450 iso1 =
nsoset(lmin(iset1) - 1) + 1
2452 CALL daxpy(size1, 1.0_dp, matso_h(iso1, ic), 1, &
2453 int_hh(ispin)%r_coef(nngau1 + 1, iso2), 1)
2454 CALL daxpy(size1, 1.0_dp, matso_s(iso1, ic), 1, &
2455 int_ss(ispin)%r_coef(nngau1 + 1, iso2), 1)
2469 DEALLOCATE (g1, g2, gg, matso_h, matso_s, gvg_s, gvg_h, vx)
2471 DEALLOCATE (cg_list, cg_n_list)
2473 CALL timestop(handle)
2490 SUBROUTINE gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, &
2491 grid_atom, basis_1c, harmonics, nspins)
2493 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: vxc_h, vxc_s
2494 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: vxg_h, vxg_s
2499 INTEGER,
INTENT(IN) :: nspins
2501 CHARACTER(len=*),
PARAMETER :: routinen =
'gaVxcgb_GC'
2503 INTEGER :: dmax_iso_not0_local, handle, ia, ic, icg, ipgf1, ipgf2, ir, iset1, iset2, iso, &
2504 iso1, iso2, ispin, l, lmax12, lmax_expansion, lmin12, m1, m2, max_iso_not0, &
2505 max_iso_not0_local, max_s_harm, maxl, maxso, n1, n2, na, ngau1, ngau2, nngau1, nr, nset, &
2507 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: cg_n_list, dcg_n_list
2508 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: cg_list, dcg_list
2509 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf
2511 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: g1, g2
2512 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dgg, gg, gvxcg_h, gvxcg_s, matso_h, &
2514 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: gvxgg_h, gvxgg_s
2515 REAL(
dp),
DIMENSION(:, :),
POINTER :: zet
2516 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: my_cg
2517 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: my_cg_dxyz
2519 CALL timeset(routinen, handle)
2521 NULLIFY (lmin, lmax, npgf, zet, my_cg, my_cg_dxyz)
2524 maxso=maxso, maxl=maxl, npgf=npgf, &
2528 na = grid_atom%ng_sphere
2529 my_cg => harmonics%my_CG
2530 my_cg_dxyz => harmonics%my_CG_dxyz
2531 max_iso_not0 = harmonics%max_iso_not0
2532 lmax_expansion =
indso(1, max_iso_not0)
2533 max_s_harm = harmonics%max_s_harm
2535 ALLOCATE (g1(nr), g2(nr), gg(nr, 0:2*maxl), dgg(nr, 0:2*maxl))
2536 ALLOCATE (gvxcg_h(na, 0:2*maxl), gvxcg_s(na, 0:2*maxl))
2537 ALLOCATE (gvxgg_h(3, na, 0:2*maxl), gvxgg_s(3, na, 0:2*maxl))
2538 ALLOCATE (cg_list(2,
nsoset(maxl)**2, max_s_harm), cg_n_list(max_s_harm), &
2539 dcg_list(2,
nsoset(maxl)**2, max_s_harm), dcg_n_list(max_s_harm))
2544 DO ispin = 1, nspins
2553 CALL get_none0_cg_list(my_cg, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
2554 max_s_harm, lmax_expansion, cg_list, cg_n_list, max_iso_not0_local)
2555 cpassert(max_iso_not0_local <= max_iso_not0)
2556 CALL get_none0_cg_list(my_cg_dxyz, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
2557 max_s_harm, lmax_expansion, dcg_list, dcg_n_list, dmax_iso_not0_local)
2560 DO ipgf1 = 1, npgf(iset1)
2561 ngau1 = n1*(ipgf1 - 1) + m1
2563 nngau1 =
nsoset(lmin(iset1) - 1) + ngau1
2565 g1(1:nr) = exp(-zet(ipgf1, iset1)*grid_atom%rad2(1:nr))
2566 DO ipgf2 = 1, npgf(iset2)
2567 ngau2 = n2*(ipgf2 - 1) + m2
2569 g2(1:nr) = exp(-zet(ipgf2, iset2)*grid_atom%rad2(1:nr))
2570 lmin12 = lmin(iset1) + lmin(iset2)
2571 lmax12 = lmax(iset1) + lmax(iset2)
2574 IF (lmin12 <= lmax_expansion)
THEN
2579 IF (lmin12 == 0)
THEN
2580 gg(1:nr, lmin12) = g1(1:nr)*g2(1:nr)
2582 gg(1:nr, lmin12) = grid_atom%rad2l(1:nr, lmin12)*g1(1:nr)*g2(1:nr)
2586 IF (lmax12 > lmax_expansion) lmax12 = lmax_expansion
2588 DO l = lmin12 + 1, lmax12
2589 gg(1:nr, l) = grid_atom%rad(1:nr)*gg(:, l - 1)
2590 dgg(1:nr, l - 1) = dgg(1:nr, l - 1) - 2.0_dp*(zet(ipgf1, iset1) + &
2591 zet(ipgf2, iset2))*gg(1:nr, l)
2593 dgg(1:nr, lmax12) = dgg(1:nr, lmax12) - 2.0_dp*(zet(ipgf1, iset1) + &
2594 zet(ipgf2, iset2))*grid_atom%rad(1:nr)* &
2603 DO l = lmin12, lmax12
2606 gvxcg_h(ia, l) = gvxcg_h(ia, l) + &
2607 gg(ir, l)*vxc_h(ia, ir, ispin) + &
2609 (vxg_h(1, ia, ir, ispin)*harmonics%a(1, ia) + &
2610 vxg_h(2, ia, ir, ispin)*harmonics%a(2, ia) + &
2611 vxg_h(3, ia, ir, ispin)*harmonics%a(3, ia))
2613 gvxcg_s(ia, l) = gvxcg_s(ia, l) + &
2614 gg(ir, l)*vxc_s(ia, ir, ispin) + &
2616 (vxg_s(1, ia, ir, ispin)*harmonics%a(1, ia) + &
2617 vxg_s(2, ia, ir, ispin)*harmonics%a(2, ia) + &
2618 vxg_s(3, ia, ir, ispin)*harmonics%a(3, ia))
2620 urad = grid_atom%oorad2l(ir, 1)
2622 gvxgg_h(1, ia, l) = gvxgg_h(1, ia, l) + &
2623 vxg_h(1, ia, ir, ispin)* &
2626 gvxgg_h(2, ia, l) = gvxgg_h(2, ia, l) + &
2627 vxg_h(2, ia, ir, ispin)* &
2630 gvxgg_h(3, ia, l) = gvxgg_h(3, ia, l) + &
2631 vxg_h(3, ia, ir, ispin)* &
2634 gvxgg_s(1, ia, l) = gvxgg_s(1, ia, l) + &
2635 vxg_s(1, ia, ir, ispin)* &
2638 gvxgg_s(2, ia, l) = gvxgg_s(2, ia, l) + &
2639 vxg_s(2, ia, ir, ispin)* &
2642 gvxgg_s(3, ia, l) = gvxgg_s(3, ia, l) + &
2643 vxg_s(3, ia, ir, ispin)* &
2652 DO iso = 1, max_iso_not0_local
2653 DO icg = 1, cg_n_list(iso)
2654 iso1 = cg_list(1, icg, iso)
2655 iso2 = cg_list(2, icg, iso)
2660 cpassert(l <= lmax_expansion)
2662 matso_h(iso1, iso2) = matso_h(iso1, iso2) + &
2664 harmonics%slm(ia, iso)* &
2665 my_cg(iso1, iso2, iso)
2666 matso_s(iso1, iso2) = matso_s(iso1, iso2) + &
2668 harmonics%slm(ia, iso)* &
2669 my_cg(iso1, iso2, iso)
2678 DO iso = 1, dmax_iso_not0_local
2679 DO icg = 1, dcg_n_list(iso)
2680 iso1 = dcg_list(1, icg, iso)
2681 iso2 = dcg_list(2, icg, iso)
2685 cpassert(l <= lmax_expansion)
2687 matso_h(iso1, iso2) = matso_h(iso1, iso2) + &
2688 (gvxgg_h(1, ia, l)*my_cg_dxyz(1, iso1, iso2, iso) + &
2689 gvxgg_h(2, ia, l)*my_cg_dxyz(2, iso1, iso2, iso) + &
2690 gvxgg_h(3, ia, l)*my_cg_dxyz(3, iso1, iso2, iso))* &
2691 harmonics%slm(ia, iso)
2693 matso_s(iso1, iso2) = matso_s(iso1, iso2) + &
2694 (gvxgg_s(1, ia, l)*my_cg_dxyz(1, iso1, iso2, iso) + &
2695 gvxgg_s(2, ia, l)*my_cg_dxyz(2, iso1, iso2, iso) + &
2696 gvxgg_s(3, ia, l)*my_cg_dxyz(3, iso1, iso2, iso))* &
2697 harmonics%slm(ia, iso)
2709 DO ic =
nsoset(lmin(iset2) - 1) + 1,
nsoset(lmax(iset2))
2710 iso1 =
nsoset(lmin(iset1) - 1) + 1
2712 CALL daxpy(size1, 1.0_dp, matso_h(iso1, ic), 1, &
2713 int_hh(ispin)%r_coef(nngau1 + 1, iso2), 1)
2714 CALL daxpy(size1, 1.0_dp, matso_s(iso1, ic), 1, &
2715 int_ss(ispin)%r_coef(nngau1 + 1, iso2), 1)
2726 DEALLOCATE (g1, g2, gg, dgg, matso_h, matso_s, gvxcg_h, gvxcg_s, gvxgg_h, gvxgg_s)
2727 DEALLOCATE (cg_list, cg_n_list, dcg_list, dcg_n_list)
2729 CALL timestop(handle)
2731 END SUBROUTINE gavxcgb_gc
2744 SUBROUTINE dgavtaudgb(vtau_h, vtau_s, int_hh, int_ss, &
2747 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: vtau_h, vtau_s
2749 TYPE(tau_basis_cache_type),
INTENT(IN) :: tau_cache
2750 INTEGER,
INTENT(IN) :: nspins
2752 CHARACTER(len=*),
PARAMETER :: routinen =
'dgaVtaudgb'
2754 INTEGER :: dir, handle, ia, ibas, igrid, iold, ir, &
2755 ispin, jbas, jold, max_old_basis, na, &
2757 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: int_h, int_s, weighted_grad
2759 CALL timeset(routinen, handle)
2761 cpassert(
ALLOCATED(tau_cache%grad))
2762 cpassert(
ASSOCIATED(tau_cache%n2oindex))
2766 nbas = tau_cache%nsatbas
2768 max_old_basis = maxval(tau_cache%n2oindex)
2769 ALLOCATE (int_h(nbas, nbas), int_s(nbas, nbas), weighted_grad(ngrid, nbas))
2771 DO ispin = 1, nspins
2772 cpassert(
SIZE(int_hh(ispin)%r_coef, 1) >= max_old_basis)
2773 cpassert(
SIZE(int_hh(ispin)%r_coef, 2) >= max_old_basis)
2774 cpassert(
SIZE(int_ss(ispin)%r_coef, 1) >= max_old_basis)
2775 cpassert(
SIZE(int_ss(ispin)%r_coef, 2) >= max_old_basis)
2782 igrid = ia + (ir - 1)*na
2783 weighted_grad(igrid, ibas) = vtau_h(ia, ir, ispin)* &
2784 tau_cache%grad(igrid, ibas, dir)
2788 CALL dgemm(
'T',
'N', nbas, nbas, ngrid, 0.5_dp, tau_cache%grad(:, :, dir), &
2789 ngrid, weighted_grad, ngrid, 1.0_dp, int_h, nbas)
2794 igrid = ia + (ir - 1)*na
2795 weighted_grad(igrid, ibas) = vtau_s(ia, ir, ispin)* &
2796 tau_cache%grad(igrid, ibas, dir)
2800 CALL dgemm(
'T',
'N', nbas, nbas, ngrid, 0.5_dp, tau_cache%grad(:, :, dir), &
2801 ngrid, weighted_grad, ngrid, 1.0_dp, int_s, nbas)
2805 jold = tau_cache%n2oindex(jbas)
2807 iold = tau_cache%n2oindex(ibas)
2808 int_hh(ispin)%r_coef(iold, jold) = int_hh(ispin)%r_coef(iold, jold) + &
2810 int_ss(ispin)%r_coef(iold, jold) = int_ss(ispin)%r_coef(iold, jold) + &
2816 DEALLOCATE (int_h, int_s, weighted_grad)
2818 CALL timestop(handle)
2820 END SUBROUTINE dgavtaudgb
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum, ccon)
...
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Defines the basic variable types.
integer, parameter, public dp
Utility routines for the memory handling.
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public nsoset
integer, dimension(:, :), allocatable, public indso
subroutine, public get_paw_basis_info(basis_1c, o2nindex, n2oindex, nsatbas)
Return some info on the PAW basis derived from a GTO basis set.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
logical function, public has_nlcc(qs_kind_set)
finds if a given qs run needs to use nlcc
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
Type definitiona for linear response calculations.
subroutine, public get_rho_atom(rho_atom, cpc_h, cpc_s, rho_rad_h, rho_rad_s, drho_rad_h, drho_rad_s, vrho_rad_h, vrho_rad_s, rho_rad_h_d, rho_rad_s_d, ga_vlocal_gb_h, ga_vlocal_gb_s, int_scr_h, int_scr_s)
...
routines that build the integrals of the Vxc potential calculated for the atomic density in the basis...
subroutine, public calculate_xc_2nd_deriv_atom(rho_atom_set, rho1_atom_set, qs_env, xc_section, para_env, do_tddfpt2, do_triplet, do_sf, kind_set_external)
...
subroutine, public calculate_gfxc_atom(qs_env, rho0_atom_set, rho1_atom_set, rho2_atom_set, kind_set, xc_section, is_triplet, accuracy)
...
subroutine, public calc_rho_angular(grid_atom, harmonics, nspins, grad_func, ir, r_h, r_s, rho_h, rho_s, dr_h, dr_s, r_h_d, r_s_d, drho_h, drho_s)
...
subroutine, public calculate_vxc_atom_epr(qs_env, exc1, gradient_atom_set)
...
subroutine, public gavxcgb_nogc(vxc_h, vxc_s, int_hh, int_ss, grid_atom, basis_1c, harmonics, nspins)
...
subroutine, public gfxc_atom_diff(qs_env, rho0_atom_set, rho1_atom_set, rho2_atom_set, kind_set, xc_section, is_triplet, accuracy, epsrho)
...
subroutine, public calculate_vxc_atom(qs_env, energy_only, exc1, adiabatic_rescale_factor, kind_set_external, rho_atom_set_external, xc_section_external)
...
All kind of helpful little routines.
pure integer function, dimension(2), public get_limit(m, n, me)
divide m entries into n parts, return size of part me
subroutine, public vxc_of_r_epr(xc_fun_section, rho_set, deriv_set, needs, w, lsd, na, nr, exc, vxc, vxg, vtau)
Specific EPR version of vxc_of_r_new.
subroutine, public vxc_of_r_new(xc_fun_section, rho_set, deriv_set, deriv_order, needs, w, lsd, na, nr, exc, vxc, vxg, vtau, energy_only, adiabatic_rescale_factor)
...
subroutine, public xc_rho_set_atom_update(rho_set, needs, nspins, bo)
...
subroutine, public xc_2nd_deriv_of_r(rho_set, rho1_set, xc_section, deriv_set, w, vxc, vxg, vtau, do_triplet, do_sf)
...
subroutine, public fill_rho_set(rho_set, lsd, nspins, needs, rho, drho, tau, na, ir)
...
represent a group ofunctional derivatives
subroutine, public xc_dset_zero_all(deriv_set)
...
subroutine, public xc_dset_release(derivative_set)
releases a derivative set
subroutine, public xc_dset_create(derivative_set, pw_pool, local_bounds)
creates a derivative set object
type(xc_rho_cflags_type) function, public xc_functionals_get_needs(functionals, lsd, calc_potential)
...
subroutine, public xc_rho_set_create(rho_set, local_bounds, rho_cutoff, drho_cutoff, tau_cutoff)
allocates and does (minimal) initialization of a rho_set
subroutine, public xc_rho_set_release(rho_set, pw_pool)
releases the given rho_set
Provides all information about an atomic kind.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.
A derivative set contains the different derivatives of a xc-functional in form of a linked list.
contains a flag for each component of xc_rho_set, so that you can use it to tell which components you...
represent a density, with all the representation and data needed to perform a functional evaluation