55#include "./base/base_uses.f90"
61 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_vxc_atom'
84 adiabatic_rescale_factor, kind_set_external, &
85 rho_atom_set_external, xc_section_external)
88 LOGICAL,
INTENT(IN) :: energy_only
89 REAL(
dp),
INTENT(INOUT) :: exc1
90 REAL(
dp),
INTENT(IN),
OPTIONAL :: adiabatic_rescale_factor
92 POINTER :: kind_set_external
94 POINTER :: rho_atom_set_external
97 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_vxc_atom'
99 INTEGER :: bo(2), handle, iat, iatom, ikind, ir, &
100 myfun, na, natom, nr, nspins, num_pe
101 INTEGER,
DIMENSION(2, 3) :: bounds
102 INTEGER,
DIMENSION(:),
POINTER :: atom_list
103 LOGICAL :: accint, donlcc, gradient_f, lsd, nlcc, &
105 REAL(
dp) :: agr, alpha, density_cut, exc_h, exc_s, &
107 my_adiabatic_rescale_factor, tau_cut
108 REAL(
dp),
DIMENSION(1, 1, 1) :: tau_d
109 REAL(
dp),
DIMENSION(1, 1, 1, 1) :: rho_d
110 REAL(
dp),
DIMENSION(:, :),
POINTER :: rho_nlcc, weight_h, weight_s
111 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rho_h, rho_s, tau_h, tau_s, vtau_h, &
113 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: drho_h, drho_s, vxg_h, vxg_s
120 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: my_kind_set
121 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr_h, dr_s, int_hh, int_ss, r_h, r_s
123 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: my_rho_atom_set
132 CALL timeset(routinen, handle)
135 NULLIFY (my_kind_set)
136 NULLIFY (atomic_kind_set)
142 NULLIFY (my_rho_atom_set)
145 IF (
PRESENT(adiabatic_rescale_factor))
THEN
146 my_adiabatic_rescale_factor = adiabatic_rescale_factor
148 my_adiabatic_rescale_factor = 1.0_dp
152 dft_control=dft_control, &
154 atomic_kind_set=atomic_kind_set, &
155 qs_kind_set=my_kind_set, &
157 rho_atom_set=my_rho_atom_set)
159 IF (
PRESENT(kind_set_external)) my_kind_set => kind_set_external
160 IF (
PRESENT(rho_atom_set_external)) my_rho_atom_set => rho_atom_set_external
163 accint = dft_control%qs_control%gapw_control%accurate_xcint
167 IF (
PRESENT(xc_section_external)) my_xc_section => xc_section_external
175 my_rho_atom_set(:)%exc_h = 0.0_dp
176 my_rho_atom_set(:)%exc_s = 0.0_dp
185 lsd = dft_control%lsd
186 nspins = dft_control%nspins
189 calc_potential=.true.)
191 gradient_f = (needs%drho .OR. needs%drho_spin)
192 tau_f = (needs%tau .OR. needs%tau_spin)
198 NULLIFY (rho_h, drho_h, rho_s, drho_s, weight_h, weight_s)
199 NULLIFY (vxc_h, vxc_s, vxg_h, vxg_s)
200 NULLIFY (tau_h, tau_s)
201 NULLIFY (vtau_h, vtau_s)
205 DO ikind = 1,
SIZE(atomic_kind_set)
206 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
207 CALL get_qs_kind(my_kind_set(ikind), paw_atom=paw_atom, &
208 harmonics=harmonics, grid_atom=grid_atom)
209 CALL get_qs_kind(my_kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
211 IF (.NOT. paw_atom) cycle
214 na = grid_atom%ng_sphere
227 weight_h => grid_atom%weight
228 ALLOCATE (weight_s(na, nr))
229 alpha = dft_control%qs_control%gapw_control%aw(ikind)
231 agr = 1.0_dp - exp(-alpha*grid_atom%rad2(ir))
232 weight_s(:, ir) = grid_atom%weight(:, ir)*agr
235 weight_h => grid_atom%weight
236 weight_s => grid_atom%weight
243 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
245 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
251 CALL reallocate(rho_h, 1, na, 1, nr, 1, nspins)
252 CALL reallocate(rho_s, 1, na, 1, nr, 1, nspins)
253 CALL reallocate(vxc_h, 1, na, 1, nr, 1, nspins)
254 CALL reallocate(vxc_s, 1, na, 1, nr, 1, nspins)
257 CALL reallocate(drho_h, 1, 4, 1, na, 1, nr, 1, nspins)
258 CALL reallocate(drho_s, 1, 4, 1, na, 1, nr, 1, nspins)
259 CALL reallocate(vxg_h, 1, 3, 1, na, 1, nr, 1, nspins)
260 CALL reallocate(vxg_s, 1, 3, 1, na, 1, nr, 1, nspins)
264 CALL reallocate(tau_h, 1, na, 1, nr, 1, nspins)
265 CALL reallocate(tau_s, 1, na, 1, nr, 1, nspins)
266 CALL reallocate(vtau_h, 1, na, 1, nr, 1, nspins)
267 CALL reallocate(vtau_s, 1, na, 1, nr, 1, nspins)
274 rho_nlcc => my_kind_set(ikind)%nlcc_pot
275 IF (
ASSOCIATED(rho_nlcc)) donlcc = .true.
280 num_pe = para_env%num_pe
281 bo =
get_limit(natom, para_env%num_pe, para_env%mepos)
283 DO iat = bo(1), bo(2)
284 iatom = atom_list(iat)
286 my_rho_atom_set(iatom)%exc_h = 0.0_dp
287 my_rho_atom_set(iatom)%exc_s = 0.0_dp
289 rho_atom => my_rho_atom_set(iatom)
293 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
295 rho_rad_s=r_s, drho_rad_h=dr_h, &
296 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, &
302 CALL get_rho_atom(rho_atom=rho_atom, rho_rad_h=r_h, rho_rad_s=r_s)
307 CALL calc_tau_atom(tau_h, tau_s, rho_atom, my_kind_set(ikind), nspins)
314 ir, r_h, r_s, rho_h, rho_s, dr_h, dr_s, &
315 r_h_d, r_s_d, drho_h, drho_s)
317 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
318 ir, rho_nlcc(:, 1), rho_h, rho_s, rho_nlcc(:, 2), drho_h, drho_s)
323 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
324 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
325 ELSE IF (gradient_f)
THEN
326 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_d, na, ir)
327 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_d, na, ir)
329 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rho_d, tau_d, na, ir)
330 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rho_d, tau_d, na, ir)
338 CALL vxc_of_r_new(xc_fun_section, rho_set_h, deriv_set, 1, needs, weight_h, &
339 lsd, na, nr, exc_h, vxc_h, vxg_h, vtau_h, energy_only=energy_only, &
340 adiabatic_rescale_factor=my_adiabatic_rescale_factor)
341 rho_atom%exc_h = rho_atom%exc_h + exc_h
347 CALL vxc_of_r_new(xc_fun_section, rho_set_s, deriv_set, 1, needs, weight_s, &
348 lsd, na, nr, exc_s, vxc_s, vxg_s, vtau_s, energy_only=energy_only, &
349 adiabatic_rescale_factor=my_adiabatic_rescale_factor)
350 rho_atom%exc_s = rho_atom%exc_s + exc_s
354 exc1 = exc1 + rho_atom%exc_h - rho_atom%exc_s
360 IF (.NOT. energy_only)
THEN
361 NULLIFY (int_hh, int_ss)
362 CALL get_rho_atom(rho_atom=rho_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
364 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, &
365 grid_atom, basis_1c, harmonics, nspins)
368 grid_atom, basis_1c, harmonics, nspins)
371 CALL dgavtaudgb(vtau_h, vtau_s, int_hh, int_ss, &
372 grid_atom, basis_1c, harmonics, nspins)
375 NULLIFY (r_h, r_s, dr_h, dr_s)
383 DEALLOCATE (weight_s)
388 CALL para_env%sum(exc1)
390 IF (
ASSOCIATED(rho_h))
DEALLOCATE (rho_h)
391 IF (
ASSOCIATED(rho_s))
DEALLOCATE (rho_s)
392 IF (
ASSOCIATED(vxc_h))
DEALLOCATE (vxc_h)
393 IF (
ASSOCIATED(vxc_s))
DEALLOCATE (vxc_s)
396 IF (
ASSOCIATED(drho_h))
DEALLOCATE (drho_h)
397 IF (
ASSOCIATED(drho_s))
DEALLOCATE (drho_s)
398 IF (
ASSOCIATED(vxg_h))
DEALLOCATE (vxg_h)
399 IF (
ASSOCIATED(vxg_s))
DEALLOCATE (vxg_s)
403 IF (
ASSOCIATED(tau_h))
DEALLOCATE (tau_h)
404 IF (
ASSOCIATED(tau_s))
DEALLOCATE (tau_s)
405 IF (
ASSOCIATED(vtau_h))
DEALLOCATE (vtau_h)
406 IF (
ASSOCIATED(vtau_s))
DEALLOCATE (vtau_s)
411 CALL timestop(handle)
424 REAL(
dp),
INTENT(INOUT) :: exc1
427 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_vxc_atom_epr'
429 INTEGER :: bo(2), handle, ia, iat, iatom, idir, &
430 ikind, ir, ispin, myfun, na, natom, &
432 INTEGER,
DIMENSION(2, 3) :: bounds
433 INTEGER,
DIMENSION(:),
POINTER :: atom_list
434 LOGICAL :: accint, donlcc, gradient_f, lsd, nlcc, &
436 REAL(
dp) :: agr, alpha, density_cut, exc_h, exc_s, &
437 gradient_cut, tau_cut
438 REAL(
dp),
DIMENSION(1, 1, 1) :: tau_d
439 REAL(
dp),
DIMENSION(1, 1, 1, 1) :: rho_d
440 REAL(
dp),
DIMENSION(:, :),
POINTER :: rho_nlcc, weight_h, weight_s
441 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rho_h, rho_s, tau_h, tau_s, vtau_h, &
443 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: drho_h, drho_s, vxg_h, vxg_s
450 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: my_kind_set
451 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr_h, dr_s, int_hh, int_ss, r_h, r_s
453 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: my_rho_atom_set
462 CALL timeset(routinen, handle)
465 NULLIFY (my_kind_set)
466 NULLIFY (atomic_kind_set)
472 NULLIFY (my_rho_atom_set)
476 dft_control=dft_control, &
478 atomic_kind_set=atomic_kind_set, &
479 qs_kind_set=my_kind_set, &
481 rho_atom_set=my_rho_atom_set)
484 accint = dft_control%qs_control%gapw_control%accurate_xcint
487 "PROPERTIES%LINRES%EPR%PRINT%G_TENSOR%XC")
494 my_rho_atom_set(:)%exc_h = 0.0_dp
495 my_rho_atom_set(:)%exc_s = 0.0_dp
504 lsd = dft_control%lsd
505 nspins = dft_control%nspins
508 calc_potential=.true.)
511 needs%drho_spin = .true.
513 gradient_f = (needs%drho .OR. needs%drho_spin)
514 tau_f = (needs%tau .OR. needs%tau_spin)
520 NULLIFY (rho_h, drho_h, rho_s, drho_s, weight_h, weight_s)
521 NULLIFY (vxc_h, vxc_s, vxg_h, vxg_s)
522 NULLIFY (tau_h, tau_s)
523 NULLIFY (vtau_h, vtau_s)
527 DO ikind = 1,
SIZE(atomic_kind_set)
528 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
529 CALL get_qs_kind(my_kind_set(ikind), paw_atom=paw_atom, &
530 harmonics=harmonics, grid_atom=grid_atom)
531 CALL get_qs_kind(my_kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
533 IF (.NOT. paw_atom) cycle
536 na = grid_atom%ng_sphere
549 weight_h => grid_atom%weight
550 ALLOCATE (weight_s(na, nr))
551 alpha = dft_control%qs_control%gapw_control%aw(ikind)
553 agr = 1.0_dp - exp(-alpha*grid_atom%rad2(ir))
554 weight_s(:, ir) = grid_atom%weight(:, ir)*agr
557 weight_h => grid_atom%weight
558 weight_s => grid_atom%weight
565 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
567 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
573 CALL reallocate(rho_h, 1, na, 1, nr, 1, nspins)
574 CALL reallocate(rho_s, 1, na, 1, nr, 1, nspins)
575 CALL reallocate(vxc_h, 1, na, 1, nr, 1, nspins)
576 CALL reallocate(vxc_s, 1, na, 1, nr, 1, nspins)
579 CALL reallocate(drho_h, 1, 4, 1, na, 1, nr, 1, nspins)
580 CALL reallocate(drho_s, 1, 4, 1, na, 1, nr, 1, nspins)
581 CALL reallocate(vxg_h, 1, 3, 1, na, 1, nr, 1, nspins)
582 CALL reallocate(vxg_s, 1, 3, 1, na, 1, nr, 1, nspins)
586 CALL reallocate(tau_h, 1, na, 1, nr, 1, nspins)
587 CALL reallocate(tau_s, 1, na, 1, nr, 1, nspins)
588 CALL reallocate(vtau_h, 1, na, 1, nr, 1, nspins)
589 CALL reallocate(vtau_s, 1, na, 1, nr, 1, nspins)
596 rho_nlcc => my_kind_set(ikind)%nlcc_pot
597 IF (
ASSOCIATED(rho_nlcc)) donlcc = .true.
602 num_pe = para_env%num_pe
603 bo =
get_limit(natom, para_env%num_pe, para_env%mepos)
605 DO iat = bo(1), bo(2)
606 iatom = atom_list(iat)
608 my_rho_atom_set(iatom)%exc_h = 0.0_dp
609 my_rho_atom_set(iatom)%exc_s = 0.0_dp
611 rho_atom => my_rho_atom_set(iatom)
615 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
617 rho_rad_s=r_s, drho_rad_h=dr_h, &
618 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, &
624 CALL get_rho_atom(rho_atom=rho_atom, rho_rad_h=r_h, rho_rad_s=r_s)
629 CALL calc_tau_atom(tau_h, tau_s, rho_atom, my_kind_set(ikind), nspins)
636 ir, r_h, r_s, rho_h, rho_s, dr_h, dr_s, &
637 r_h_d, r_s_d, drho_h, drho_s)
639 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
640 ir, rho_nlcc(:, 1), rho_h, rho_s, rho_nlcc(:, 2), drho_h, drho_s)
645 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
646 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
647 ELSE IF (gradient_f)
THEN
648 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_d, na, ir)
649 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_d, na, ir)
651 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rho_d, tau_d, na, ir)
652 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rho_d, tau_d, na, ir)
660 CALL vxc_of_r_epr(xc_fun_section, rho_set_h, deriv_set, needs, weight_h, &
661 lsd, na, nr, exc_h, vxc_h, vxg_h, vtau_h)
662 rho_atom%exc_h = rho_atom%exc_h + exc_h
668 CALL vxc_of_r_epr(xc_fun_section, rho_set_s, deriv_set, needs, weight_s, &
669 lsd, na, nr, exc_s, vxc_s, vxg_s, vtau_s)
670 rho_atom%exc_s = rho_atom%exc_s + exc_s
676 gradient_atom_set(iatom)%nablavks_vec_rad_h(idir, ispin)%r_coef(ir, ia) = &
677 gradient_atom_set(iatom)%nablavks_vec_rad_h(idir, ispin)%r_coef(ir, ia) &
678 + vxg_h(idir, ia, ir, ispin)
679 gradient_atom_set(iatom)%nablavks_vec_rad_s(idir, ispin)%r_coef(ir, ia) = &
680 gradient_atom_set(iatom)%nablavks_vec_rad_s(idir, ispin)%r_coef(ir, ia) &
681 + vxg_s(idir, ia, ir, ispin)
689 exc1 = exc1 + rho_atom%exc_h - rho_atom%exc_s
695 NULLIFY (int_hh, int_ss)
696 CALL get_rho_atom(rho_atom=rho_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
698 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, &
699 grid_atom, basis_1c, harmonics, nspins)
702 grid_atom, basis_1c, harmonics, nspins)
705 CALL dgavtaudgb(vtau_h, vtau_s, int_hh, int_ss, &
706 grid_atom, basis_1c, harmonics, nspins)
708 NULLIFY (r_h, r_s, dr_h, dr_s)
716 DEALLOCATE (weight_s)
721 CALL para_env%sum(exc1)
723 IF (
ASSOCIATED(rho_h))
DEALLOCATE (rho_h)
724 IF (
ASSOCIATED(rho_s))
DEALLOCATE (rho_s)
725 IF (
ASSOCIATED(vxc_h))
DEALLOCATE (vxc_h)
726 IF (
ASSOCIATED(vxc_s))
DEALLOCATE (vxc_s)
729 IF (
ASSOCIATED(drho_h))
DEALLOCATE (drho_h)
730 IF (
ASSOCIATED(drho_s))
DEALLOCATE (drho_s)
731 IF (
ASSOCIATED(vxg_h))
DEALLOCATE (vxg_h)
732 IF (
ASSOCIATED(vxg_s))
DEALLOCATE (vxg_s)
736 IF (
ASSOCIATED(tau_h))
DEALLOCATE (tau_h)
737 IF (
ASSOCIATED(tau_s))
DEALLOCATE (tau_s)
738 IF (
ASSOCIATED(vtau_h))
DEALLOCATE (vtau_h)
739 IF (
ASSOCIATED(vtau_s))
DEALLOCATE (vtau_s)
744 CALL timestop(handle)
761 do_tddfpt2, do_triplet, do_sf, kind_set_external)
763 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: rho_atom_set, rho1_atom_set
767 LOGICAL,
INTENT(IN),
OPTIONAL :: do_tddfpt2, do_triplet, do_sf
769 POINTER :: kind_set_external
771 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_xc_2nd_deriv_atom'
773 INTEGER ::
atom, handle, iatom, ikind, ir, na, &
775 INTEGER,
DIMENSION(2) :: local_loop_limit
776 INTEGER,
DIMENSION(2, 3) :: bounds
777 INTEGER,
DIMENSION(:),
POINTER :: atom_list
778 LOGICAL :: accint, gradient_functional, lsd, &
779 my_do_sf, paw_atom, scale_rho, tau_f
780 REAL(kind=
dp) :: agr, alpha, density_cut, gradient_cut, &
782 REAL(kind=
dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
783 POINTER :: vxc_h, vxc_s
784 REAL(kind=
dp),
DIMENSION(1, 1, 1) :: rtau
785 REAL(kind=
dp),
DIMENSION(1, 1, 1, 1) :: rrho
786 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: weight_h, weight_s
787 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: rho1_h, rho1_s, rho_h, rho_s, tau1_h, &
789 REAL(kind=
dp),
DIMENSION(:, :, :, :),
POINTER :: drho1_h, drho1_s, drho_h, drho_s, vxg_h, &
796 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: my_kind_set, qs_kind_set
797 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr1_h, dr1_s, dr_h, dr_s, int_hh, &
798 int_ss, r1_h, r1_s, r_h, r_s
799 TYPE(
rho_atom_coeff),
DIMENSION(:, :),
POINTER :: r1_h_d, r1_s_d, r_h_d, r_s_d
809 CALL timeset(routinen, handle)
811 NULLIFY (qs_kind_set)
812 NULLIFY (rho_h, rho_s, drho_h, drho_s, weight_h, weight_s)
813 NULLIFY (rho1_h, rho1_s, drho1_h, drho1_s)
814 NULLIFY (vxc_h, vxc_s, vxg_h, vxg_s)
815 NULLIFY (tau_h, tau_s, tau1_h, tau1_s)
819 dft_control=dft_control, &
820 qs_kind_set=qs_kind_set, &
821 atomic_kind_set=atomic_kind_set)
823 IF (
PRESENT(kind_set_external))
THEN
824 my_kind_set => kind_set_external
826 my_kind_set => qs_kind_set
829 accint = dft_control%qs_control%gapw_control%accurate_xcint
840 IF (
PRESENT(do_sf)) my_do_sf = do_sf
851 IF (
PRESENT(do_tddfpt2) .AND.
PRESENT(do_triplet))
THEN
852 IF (nspins == 1 .AND. do_triplet)
THEN
856 ELSEIF (
PRESENT(do_triplet))
THEN
857 IF (nspins == 1 .AND. do_triplet) lsd = .true.
861 calc_potential=.true.)
862 gradient_functional = needs%drho .OR. needs%drho_spin
863 tau_f = (needs%tau .OR. needs%tau_spin)
865 cpabort(
"Tau functionals not implemented for GAPW 2nd derivatives")
871 DO ikind = 1,
SIZE(atomic_kind_set)
873 NULLIFY (atom_list, harmonics, grid_atom)
874 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
875 CALL get_qs_kind(my_kind_set(ikind), paw_atom=paw_atom, &
876 harmonics=harmonics, grid_atom=grid_atom)
877 CALL get_qs_kind(my_kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
878 IF (.NOT. paw_atom) cycle
881 na = grid_atom%ng_sphere
885 weight_h => grid_atom%weight
886 ALLOCATE (weight_s(na, nr))
887 alpha = dft_control%qs_control%gapw_control%aw(ikind)
889 agr = 1.0_dp - exp(-alpha*grid_atom%rad2(ir))
890 weight_s(:, ir) = grid_atom%weight(:, ir)*agr
893 weight_h => grid_atom%weight
894 weight_s => grid_atom%weight
906 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
908 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
910 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
912 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
915 IF (nspins == 1 .AND. .NOT. lsd)
THEN
927 ALLOCATE (rho_h(1:na, 1:nr, 1:nspins), rho1_h(1:na, 1:nr, 1:nspins), &
928 rho_s(1:na, 1:nr, 1:nspins), rho1_s(1:na, 1:nr, 1:nspins))
930 ALLOCATE (vxc_h(1:na, 1:nr, 1:nspins), vxc_s(1:na, 1:nr, 1:nspins))
934 IF (gradient_functional)
THEN
935 ALLOCATE (drho_h(1:4, 1:na, 1:nr, 1:nspins), drho1_h(1:4, 1:na, 1:nr, 1:nspins), &
936 drho_s(1:4, 1:na, 1:nr, 1:nspins), drho1_s(1:4, 1:na, 1:nr, 1:nspins))
937 ALLOCATE (vxg_h(1:3, 1:na, 1:nr, 1:nspins), vxg_s(1:3, 1:na, 1:nr, 1:nspins))
939 ALLOCATE (drho_h(1, 1, 1, 1), drho1_h(1, 1, 1, 1), &
940 drho_s(1, 1, 1, 1), drho1_s(1, 1, 1, 1))
941 ALLOCATE (vxg_h(1, 1, 1, 1), vxg_s(1, 1, 1, 1))
948 local_loop_limit =
get_limit(natom, para_env%num_pe, para_env%mepos)
950 DO iatom = local_loop_limit(1), local_loop_limit(2)
951 atom = atom_list(iatom)
953 rho_atom_set(
atom)%exc_h = 0.0_dp
954 rho_atom_set(
atom)%exc_s = 0.0_dp
955 rho1_atom_set(
atom)%exc_h = 0.0_dp
956 rho1_atom_set(
atom)%exc_s = 0.0_dp
958 rho_atom => rho_atom_set(
atom)
959 rho1_atom => rho1_atom_set(
atom)
960 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
961 NULLIFY (r1_h, r1_s, dr1_h, dr1_s, r1_h_d, r1_s_d)
966 IF (gradient_functional)
THEN
968 rho_rad_h=r_h, rho_rad_s=r_s, &
969 drho_rad_h=dr_h, drho_rad_s=dr_s, &
970 rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
972 rho_rad_h=r1_h, rho_rad_s=r1_s, &
973 drho_rad_h=dr1_h, drho_rad_s=dr1_s, &
974 rho_rad_h_d=r1_h_d, rho_rad_s_d=r1_s_d)
975 drho_h = 0.0_dp; drho_s = 0.0_dp
976 drho1_h = 0.0_dp; drho1_s = 0.0_dp
979 rho_rad_h=r_h, rho_rad_s=r_s)
981 rho_rad_h=r1_h, rho_rad_s=r1_s)
988 ir, r_h, r_s, rho_h, rho_s, dr_h, dr_s, r_h_d, r_s_d, &
991 ir, r1_h, r1_s, rho1_h, rho1_s, dr1_h, dr1_s, r1_h_d, r1_s_d, &
997 IF (gradient_functional)
THEN
998 drho_h = 2.0_dp*drho_h
999 drho_s = 2.0_dp*drho_s
1005 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
1006 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau1_h, na, ir)
1007 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
1008 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau1_s, na, ir)
1009 ELSE IF (gradient_functional)
THEN
1010 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, rtau, na, ir)
1011 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, rtau, na, ir)
1012 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, rtau, na, ir)
1013 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, rtau, na, ir)
1015 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rrho, rtau, na, ir)
1016 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, rrho, rtau, na, ir)
1017 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rrho, rtau, na, ir)
1018 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, rrho, rtau, na, ir)
1023 rho_set=rho_set_h, rho1_set=rho1_set_h, &
1024 deriv_set=deriv_set, &
1025 w=weight_h, vxc=vxc_h, vxg=vxg_h, do_triplet=do_triplet, &
1028 rho_set=rho_set_s, rho1_set=rho1_set_s, &
1029 deriv_set=deriv_set, &
1030 w=weight_s, vxc=vxc_s, vxg=vxg_s, do_triplet=do_triplet, &
1033 CALL get_rho_atom(rho_atom=rho1_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1034 IF (gradient_functional)
THEN
1035 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, &
1036 grid_atom, basis_1c, harmonics, nspins)
1039 grid_atom, basis_1c, harmonics, nspins)
1042 NULLIFY (r_h, r_s, dr_h, dr_s)
1047 DEALLOCATE (rho_h, rho_s, rho1_h, rho1_s, vxc_h, vxc_s)
1048 DEALLOCATE (drho_h, drho_s, vxg_h, vxg_s)
1049 DEALLOCATE (drho1_h, drho1_s)
1057 DEALLOCATE (weight_s)
1062 CALL timestop(handle)
1078 kind_set, xc_section, is_triplet, accuracy)
1081 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: rho0_atom_set, rho1_atom_set, &
1085 LOGICAL,
INTENT(IN) :: is_triplet
1086 INTEGER,
INTENT(IN) :: accuracy
1088 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_gfxc_atom'
1089 REAL(kind=
dp),
PARAMETER :: epsrho = 5.e-4_dp
1091 INTEGER :: bo(2), handle, iat, iatom, ikind, ir, &
1092 istep, mspins, myfun, na, natom, nf, &
1093 nr, ns, nspins, nstep, num_pe
1094 INTEGER,
DIMENSION(2, 3) :: bounds
1095 INTEGER,
DIMENSION(:),
POINTER :: atom_list
1096 LOGICAL :: accint, donlcc, gradient_f, lsd, nlcc, &
1098 REAL(
dp) :: agr, alpha, beta, density_cut, exc_h, &
1099 exc_s, gradient_cut, oeps1, oeps2, &
1101 REAL(
dp),
DIMENSION(1, 1, 1) :: tau_d
1102 REAL(
dp),
DIMENSION(1, 1, 1, 1) :: rho_d
1103 REAL(
dp),
DIMENSION(:, :),
POINTER :: rho_nlcc, weight_h, weight_s
1104 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rho0_h, rho0_s, rho1_h, rho1_s, rho_h, &
1105 rho_s, tau0_h, tau0_s, tau1_h, tau1_s, &
1106 tau_h, tau_s, vtau_h, vtau_s, vxc_h, &
1108 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: drho0_h, drho0_s, drho1_h, drho1_s, &
1109 drho_h, drho_s, vxg_h, vxg_s
1110 REAL(kind=
dp),
DIMENSION(-4:4) :: ak, bl
1117 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr_h, dr_s, fint_hh, fint_ss, int_hh, &
1120 TYPE(
rho_atom_type),
POINTER :: rho0_atom, rho1_atom, rho2_atom
1126 CALL timeset(routinen, handle)
1130 SELECT CASE (accuracy)
1133 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
1134 bl(-2:2) = [-1.0_dp, 16.0_dp, -30.0_dp, 16.0_dp, -1.0_dp]/12.0_dp
1137 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
1138 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
1141 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
1142 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
1143 bl(-4:4) = [-1.0_dp, 128.0_dp/9.0_dp, -112.0_dp, 896.0_dp, -14350.0_dp/9.0_dp, &
1144 896.0_dp, -112.0_dp, 128.0_dp/9.0_dp, -1.0_dp]/560.0_dp
1146 oeps1 = 1.0_dp/epsrho
1147 oeps2 = 1.0_dp/(epsrho**2)
1150 dft_control=dft_control, &
1151 para_env=para_env, &
1152 atomic_kind_set=atomic_kind_set)
1157 accint = dft_control%qs_control%gapw_control%accurate_xcint
1167 lsd = dft_control%lsd
1168 nspins = dft_control%nspins
1170 IF (is_triplet)
THEN
1171 cpassert(nspins == 1)
1176 gradient_f = (needs%drho .OR. needs%drho_spin)
1177 tau_f = (needs%tau .OR. needs%tau_spin)
1180 DO ikind = 1,
SIZE(atomic_kind_set)
1181 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
1182 CALL get_qs_kind(kind_set(ikind), paw_atom=paw_atom, &
1183 harmonics=harmonics, grid_atom=grid_atom)
1184 CALL get_qs_kind(kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
1186 IF (.NOT. paw_atom) cycle
1189 na = grid_atom%ng_sphere
1193 weight_h => grid_atom%weight
1194 ALLOCATE (weight_s(na, nr))
1195 alpha = dft_control%qs_control%gapw_control%aw(ikind)
1197 agr = 1.0_dp - exp(-alpha*grid_atom%rad2(ikind))
1198 weight_s(:, ir) = grid_atom%weight(:, ir)*agr
1201 weight_h => grid_atom%weight
1202 weight_s => grid_atom%weight
1210 bounds(1:2, 1:3) = 1
1218 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1220 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1226 ALLOCATE (rho_h(na, nr, mspins), rho_s(na, nr, mspins), &
1227 rho0_h(na, nr, nspins), rho0_s(na, nr, nspins), &
1228 rho1_h(na, nr, nspins), rho1_s(na, nr, nspins))
1229 ALLOCATE (vxc_h(na, nr, mspins), vxc_s(na, nr, mspins))
1230 IF (gradient_f)
THEN
1231 ALLOCATE (drho_h(4, na, nr, mspins), drho_s(4, na, nr, mspins), &
1232 drho0_h(4, na, nr, nspins), drho0_s(4, na, nr, nspins), &
1233 drho1_h(4, na, nr, nspins), drho1_s(4, na, nr, nspins))
1234 ALLOCATE (vxg_h(3, na, nr, mspins), vxg_s(3, na, nr, mspins))
1237 ALLOCATE (tau_h(na, nr, mspins), tau_s(na, nr, mspins), &
1238 tau0_h(na, nr, nspins), tau0_s(na, nr, nspins), &
1239 tau1_h(na, nr, nspins), tau1_s(na, nr, nspins))
1240 ALLOCATE (vtau_h(na, nr, mspins), vtau_s(na, nr, mspins))
1247 rho_nlcc => kind_set(ikind)%nlcc_pot
1248 IF (
ASSOCIATED(rho_nlcc)) donlcc = .true.
1252 num_pe = para_env%num_pe
1253 bo =
get_limit(natom, num_pe, para_env%mepos)
1255 DO iat = bo(1), bo(2)
1256 iatom = atom_list(iat)
1258 NULLIFY (int_hh, int_ss)
1259 rho0_atom => rho0_atom_set(iatom)
1260 CALL get_rho_atom(rho_atom=rho0_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1261 ALLOCATE (fint_ss(nspins), fint_hh(nspins))
1263 nf =
SIZE(int_ss(ns)%r_coef, 1)
1264 ALLOCATE (fint_ss(ns)%r_coef(nf, nf))
1265 nf =
SIZE(int_hh(ns)%r_coef, 1)
1266 ALLOCATE (fint_hh(ns)%r_coef(nf, nf))
1272 rho0_atom => rho0_atom_set(iatom)
1273 IF (gradient_f)
THEN
1274 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
1275 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
1276 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
1281 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s)
1286 ir, r_h, r_s, rho0_h, rho0_s, dr_h, dr_s, &
1287 r_h_d, r_s_d, drho0_h, drho0_s)
1289 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
1290 ir, rho_nlcc(:, 1), rho0_h, rho0_s, rho_nlcc(:, 2), drho0_h, drho0_s)
1295 CALL calc_tau_atom(tau0_h, tau0_s, rho0_atom, kind_set(ikind), nspins)
1302 rho1_atom => rho1_atom_set(iatom)
1303 IF (gradient_f)
THEN
1304 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
1305 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
1306 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
1311 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s)
1315 ir, r_h, r_s, rho1_h, rho1_s, dr_h, dr_s, &
1316 r_h_d, r_s_d, drho1_h, drho1_s)
1320 CALL calc_tau_atom(tau1_h, tau1_s, rho1_atom, kind_set(ikind), nspins)
1323 rho2_atom => rho2_atom_set(iatom)
1325 DO istep = -nstep, nstep
1327 beta = real(istep, kind=
dp)*epsrho
1329 IF (is_triplet)
THEN
1330 rho_h(:, :, 1) = rho0_h(:, :, 1) + beta*rho1_h(:, :, 1)
1331 rho_h(:, :, 2) = rho0_h(:, :, 1)
1332 rho_h = 0.5_dp*rho_h
1333 rho_s(:, :, 1) = rho0_s(:, :, 1) + beta*rho1_s(:, :, 1)
1334 rho_s(:, :, 2) = rho0_s(:, :, 1)
1335 rho_s = 0.5_dp*rho_s
1336 IF (gradient_f)
THEN
1337 drho_h(:, :, :, 1) = drho0_h(:, :, :, 1) + beta*drho1_h(:, :, :, 1)
1338 drho_h(:, :, :, 2) = drho0_h(:, :, :, 1)
1339 drho_h = 0.5_dp*drho_h
1340 drho_s(:, :, :, 1) = drho0_s(:, :, :, 1) + beta*drho1_s(:, :, :, 1)
1341 drho_s(:, :, :, 2) = drho0_s(:, :, :, 1)
1342 drho_s = 0.5_dp*drho_s
1345 tau_h(:, :, 1) = tau0_h(:, :, 1) + beta*tau1_h(:, :, 1)
1346 tau_h(:, :, 2) = tau0_h(:, :, 1)
1347 tau_h = 0.5_dp*tau0_h
1348 tau_s(:, :, 1) = tau0_s(:, :, 1) + beta*tau1_s(:, :, 1)
1349 tau_s(:, :, 2) = tau0_s(:, :, 1)
1350 tau_s = 0.5_dp*tau0_s
1353 rho_h = rho0_h + beta*rho1_h
1354 rho_s = rho0_s + beta*rho1_s
1355 IF (gradient_f)
THEN
1356 drho_h = drho0_h + beta*drho1_h
1357 drho_s = drho0_s + beta*drho1_s
1360 tau_h = tau0_h + beta*tau1_h
1361 tau_s = tau0_s + beta*tau1_s
1365 IF (gradient_f)
THEN
1366 drho_h(4, :, :, :) = sqrt( &
1367 drho_h(1, :, :, :)*drho_h(1, :, :, :) + &
1368 drho_h(2, :, :, :)*drho_h(2, :, :, :) + &
1369 drho_h(3, :, :, :)*drho_h(3, :, :, :))
1371 drho_s(4, :, :, :) = sqrt( &
1372 drho_s(1, :, :, :)*drho_s(1, :, :, :) + &
1373 drho_s(2, :, :, :)*drho_s(2, :, :, :) + &
1374 drho_s(3, :, :, :)*drho_s(3, :, :, :))
1379 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, drho_h, tau_h, na, ir)
1380 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, drho_s, tau_s, na, ir)
1381 ELSE IF (gradient_f)
THEN
1382 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, drho_h, tau_d, na, ir)
1383 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, drho_s, tau_d, na, ir)
1385 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, rho_d, tau_d, na, ir)
1386 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, rho_d, tau_d, na, ir)
1392 CALL vxc_of_r_new(xc_fun_section, rho_set_h, deriv_set, 1, needs, weight_h, &
1393 lsd, na, nr, exc_h, vxc_h, vxg_h, vtau_h)
1394 IF (is_triplet)
THEN
1395 vxc_h(:, :, 1) = vxc_h(:, :, 1) - vxc_h(:, :, 2)
1396 IF (gradient_f)
THEN
1397 vxg_h(:, :, :, 1) = vxg_h(:, :, :, 1) - vxg_h(:, :, :, 2)
1400 vtau_h(:, :, 1) = vtau_h(:, :, 1) - vtau_h(:, :, 2)
1405 CALL vxc_of_r_new(xc_fun_section, rho_set_s, deriv_set, 1, needs, weight_s, &
1406 lsd, na, nr, exc_s, vxc_s, vxg_s, vtau_s)
1407 IF (is_triplet)
THEN
1408 vxc_s(:, :, 1) = vxc_s(:, :, 1) - vxc_s(:, :, 2)
1409 IF (gradient_f)
THEN
1410 vxg_s(:, :, :, 1) = vxg_s(:, :, :, 1) - vxg_s(:, :, :, 2)
1413 vtau_s(:, :, 1) = vtau_s(:, :, 1) - vtau_s(:, :, 2)
1418 fint_hh(ns)%r_coef(:, :) = 0.0_dp
1419 fint_ss(ns)%r_coef(:, :) = 0.0_dp
1421 IF (gradient_f)
THEN
1422 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, fint_hh, fint_ss, &
1423 grid_atom, basis_1c, harmonics, nspins)
1426 grid_atom, basis_1c, harmonics, nspins)
1429 CALL dgavtaudgb(vtau_h, vtau_s, fint_hh, fint_ss, &
1430 grid_atom, basis_1c, harmonics, nspins)
1433 NULLIFY (int_hh, int_ss)
1434 CALL get_rho_atom(rho_atom=rho1_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1436 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_ss(ns)%r_coef(:, :)
1437 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_hh(ns)%r_coef(:, :)
1440 NULLIFY (int_hh, int_ss)
1441 CALL get_rho_atom(rho_atom=rho2_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1443 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps2*bl(istep)*fint_ss(ns)%r_coef(:, :)
1444 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps2*bl(istep)*fint_hh(ns)%r_coef(:, :)
1449 DEALLOCATE (fint_ss(ns)%r_coef)
1450 DEALLOCATE (fint_hh(ns)%r_coef)
1452 DEALLOCATE (fint_ss, fint_hh)
1461 DEALLOCATE (rho_h, rho_s, rho0_h, rho0_s, rho1_h, rho1_s)
1462 DEALLOCATE (vxc_h, vxc_s)
1463 IF (gradient_f)
THEN
1464 DEALLOCATE (drho_h, drho_s, drho0_h, drho0_s, drho1_h, drho1_s)
1465 DEALLOCATE (vxg_h, vxg_s)
1468 DEALLOCATE (tau_h, tau_s, tau0_h, tau0_s, tau1_h, tau1_s)
1469 DEALLOCATE (vtau_h, vtau_s)
1472 DEALLOCATE (weight_s)
1479 CALL timestop(handle)
1496 kind_set, xc_section, is_triplet, accuracy, epsrho)
1499 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: rho0_atom_set, rho1_atom_set, &
1503 LOGICAL,
INTENT(IN) :: is_triplet
1504 INTEGER,
INTENT(IN) :: accuracy
1505 REAL(kind=
dp),
INTENT(IN) :: epsrho
1507 CHARACTER(LEN=*),
PARAMETER :: routinen =
'gfxc_atom_diff'
1509 INTEGER :: bo(2), handle, iat, iatom, ikind, ir, &
1510 istep, mspins, myfun, na, natom, nf, &
1511 nr, ns, nspins, nstep, num_pe
1512 INTEGER,
DIMENSION(2, 3) :: bounds
1513 INTEGER,
DIMENSION(:),
POINTER :: atom_list
1514 LOGICAL :: accint, donlcc, gradient_f, lsd, nlcc, &
1516 REAL(
dp) :: agr, alpha, beta, density_cut, &
1517 gradient_cut, oeps1, tau_cut
1518 REAL(
dp),
CONTIGUOUS,
DIMENSION(:, :, :),
POINTER :: vxc_h, vxc_s
1519 REAL(
dp),
DIMENSION(1, 1, 1) :: tau_d
1520 REAL(
dp),
DIMENSION(1, 1, 1, 1) :: rho_d
1521 REAL(
dp),
DIMENSION(:, :),
POINTER :: rho_nlcc, weight_h, weight_s
1522 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rho0_h, rho0_s, rho1_h, rho1_s, rho_h, &
1523 rho_s, tau0_h, tau0_s, tau1_h, tau1_s, &
1524 tau_h, tau_s, vtau_h, vtau_s
1525 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: drho0_h, drho0_s, drho1_h, drho1_s, &
1526 drho_h, drho_s, vxg_h, vxg_s
1527 REAL(kind=
dp),
DIMENSION(-4:4) :: ak
1534 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr_h, dr_s, fint_hh, fint_ss, int_hh, &
1537 TYPE(
rho_atom_type),
POINTER :: rho0_atom, rho1_atom, rho2_atom
1544 CALL timeset(routinen, handle)
1547 SELECT CASE (accuracy)
1550 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
1553 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
1556 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
1557 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
1559 oeps1 = 1.0_dp/epsrho
1562 dft_control=dft_control, &
1563 para_env=para_env, &
1564 atomic_kind_set=atomic_kind_set)
1569 accint = dft_control%qs_control%gapw_control%accurate_xcint
1576 do_triplet=is_triplet, kind_set_external=kind_set)
1583 lsd = dft_control%lsd
1584 nspins = dft_control%nspins
1586 IF (is_triplet)
THEN
1587 cpassert(nspins == 1)
1592 gradient_f = (needs%drho .OR. needs%drho_spin)
1593 tau_f = (needs%tau .OR. needs%tau_spin)
1596 DO ikind = 1,
SIZE(atomic_kind_set)
1597 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
1598 CALL get_qs_kind(kind_set(ikind), paw_atom=paw_atom, &
1599 harmonics=harmonics, grid_atom=grid_atom)
1600 CALL get_qs_kind(kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
1602 IF (.NOT. paw_atom) cycle
1605 na = grid_atom%ng_sphere
1609 weight_h => grid_atom%weight
1610 ALLOCATE (weight_s(na, nr))
1611 alpha = dft_control%qs_control%gapw_control%aw(ikind)
1613 agr = 1.0_dp - exp(-alpha*grid_atom%rad2(ir))
1614 weight_s(:, ir) = grid_atom%weight(:, ir)*agr
1617 weight_h => grid_atom%weight
1618 weight_s => grid_atom%weight
1626 bounds(1:2, 1:3) = 1
1634 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1636 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1638 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1640 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1648 ALLOCATE (rho_h(na, nr, nspins), rho_s(na, nr, nspins), &
1649 rho0_h(na, nr, nspins), rho0_s(na, nr, nspins), &
1650 rho1_h(na, nr, nspins), rho1_s(na, nr, nspins))
1651 ALLOCATE (vxc_h(na, nr, nspins), vxc_s(na, nr, nspins))
1652 IF (gradient_f)
THEN
1653 ALLOCATE (drho_h(4, na, nr, nspins), drho_s(4, na, nr, nspins), &
1654 drho0_h(4, na, nr, nspins), drho0_s(4, na, nr, nspins), &
1655 drho1_h(4, na, nr, nspins), drho1_s(4, na, nr, nspins))
1656 ALLOCATE (vxg_h(3, na, nr, nspins), vxg_s(3, na, nr, nspins))
1659 ALLOCATE (tau_h(na, nr, nspins), tau_s(na, nr, nspins), &
1660 tau0_h(na, nr, nspins), tau0_s(na, nr, nspins), &
1661 tau1_h(na, nr, nspins), tau1_s(na, nr, nspins))
1662 ALLOCATE (vtau_h(na, nr, nspins), vtau_s(na, nr, nspins))
1669 rho_nlcc => kind_set(ikind)%nlcc_pot
1670 IF (
ASSOCIATED(rho_nlcc)) donlcc = .true.
1674 num_pe = para_env%num_pe
1675 bo =
get_limit(natom, num_pe, para_env%mepos)
1677 DO iat = bo(1), bo(2)
1678 iatom = atom_list(iat)
1680 NULLIFY (int_hh, int_ss)
1681 rho0_atom => rho0_atom_set(iatom)
1682 CALL get_rho_atom(rho_atom=rho0_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1683 ALLOCATE (fint_ss(nspins), fint_hh(nspins))
1685 nf =
SIZE(int_ss(ns)%r_coef, 1)
1686 ALLOCATE (fint_ss(ns)%r_coef(nf, nf))
1687 nf =
SIZE(int_hh(ns)%r_coef, 1)
1688 ALLOCATE (fint_hh(ns)%r_coef(nf, nf))
1694 rho0_atom => rho0_atom_set(iatom)
1695 IF (gradient_f)
THEN
1696 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
1697 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
1698 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
1703 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s)
1708 ir, r_h, r_s, rho0_h, rho0_s, dr_h, dr_s, &
1709 r_h_d, r_s_d, drho0_h, drho0_s)
1711 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
1712 ir, rho_nlcc(:, 1), rho0_h, rho0_s, rho_nlcc(:, 2), drho0_h, drho0_s)
1717 CALL calc_tau_atom(tau0_h, tau0_s, rho0_atom, kind_set(ikind), nspins)
1724 rho1_atom => rho1_atom_set(iatom)
1725 IF (gradient_f)
THEN
1726 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
1727 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
1728 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
1733 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s)
1737 ir, r_h, r_s, rho1_h, rho1_s, dr_h, dr_s, &
1738 r_h_d, r_s_d, drho1_h, drho1_s)
1742 CALL calc_tau_atom(tau1_h, tau1_s, rho1_atom, kind_set(ikind), nspins)
1747 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau1_h, na, ir)
1748 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau1_s, na, ir)
1749 ELSE IF (gradient_f)
THEN
1750 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau_d, na, ir)
1751 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau_d, na, ir)
1753 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, rho_d, tau_d, na, ir)
1754 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, rho_d, tau_d, na, ir)
1759 rho2_atom => rho2_atom_set(iatom)
1761 DO istep = -nstep, nstep
1763 beta = real(istep, kind=
dp)*epsrho
1765 rho_h = rho0_h + beta*rho1_h
1766 rho_s = rho0_s + beta*rho1_s
1767 IF (gradient_f)
THEN
1768 drho_h = drho0_h + beta*drho1_h
1769 drho_s = drho0_s + beta*drho1_s
1772 tau_h = tau0_h + beta*tau1_h
1773 tau_s = tau0_s + beta*tau1_s
1776 IF (gradient_f)
THEN
1777 drho_h(4, :, :, :) = sqrt( &
1778 drho_h(1, :, :, :)*drho_h(1, :, :, :) + &
1779 drho_h(2, :, :, :)*drho_h(2, :, :, :) + &
1780 drho_h(3, :, :, :)*drho_h(3, :, :, :))
1782 drho_s(4, :, :, :) = sqrt( &
1783 drho_s(1, :, :, :)*drho_s(1, :, :, :) + &
1784 drho_s(2, :, :, :)*drho_s(2, :, :, :) + &
1785 drho_s(3, :, :, :)*drho_s(3, :, :, :))
1790 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
1791 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
1792 ELSE IF (gradient_f)
THEN
1793 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_d, na, ir)
1794 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_d, na, ir)
1796 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rho_d, tau_d, na, ir)
1797 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rho_d, tau_d, na, ir)
1804 rho_set=rho_set_h, rho1_set=rho1_set_h, &
1805 deriv_set=deriv_set, &
1806 w=weight_h, vxc=vxc_h, vxg=vxg_h, do_triplet=is_triplet)
1810 rho_set=rho_set_s, rho1_set=rho1_set_s, &
1811 deriv_set=deriv_set, &
1812 w=weight_s, vxc=vxc_s, vxg=vxg_s, do_triplet=is_triplet)
1815 fint_hh(ns)%r_coef(:, :) = 0.0_dp
1816 fint_ss(ns)%r_coef(:, :) = 0.0_dp
1818 IF (gradient_f)
THEN
1819 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, fint_hh, fint_ss, &
1820 grid_atom, basis_1c, harmonics, nspins)
1823 grid_atom, basis_1c, harmonics, nspins)
1826 CALL dgavtaudgb(vtau_h, vtau_s, fint_hh, fint_ss, &
1827 grid_atom, basis_1c, harmonics, nspins)
1830 NULLIFY (int_hh, int_ss)
1831 CALL get_rho_atom(rho_atom=rho2_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1833 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_ss(ns)%r_coef(:, :)
1834 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_hh(ns)%r_coef(:, :)
1839 DEALLOCATE (fint_ss(ns)%r_coef)
1840 DEALLOCATE (fint_hh(ns)%r_coef)
1842 DEALLOCATE (fint_ss, fint_hh)
1853 DEALLOCATE (rho_h, rho_s, rho0_h, rho0_s, rho1_h, rho1_s)
1854 DEALLOCATE (vxc_h, vxc_s)
1855 IF (gradient_f)
THEN
1856 DEALLOCATE (drho_h, drho_s, drho0_h, drho0_s, drho1_h, drho1_s)
1857 DEALLOCATE (vxg_h, vxg_s)
1860 DEALLOCATE (tau_h, tau_s, tau0_h, tau0_s, tau1_h, tau1_s)
1861 DEALLOCATE (vtau_h, vtau_s)
1864 DEALLOCATE (weight_s)
1871 CALL timestop(handle)
1894 ir, r_h, r_s, rho_h, rho_s, &
1895 dr_h, dr_s, r_h_d, r_s_d, drho_h, drho_s)
1899 INTEGER,
INTENT(IN) :: nspins
1900 LOGICAL,
INTENT(IN) :: grad_func
1901 INTEGER,
INTENT(IN) :: ir
1903 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: rho_h, rho_s
1906 REAL(kind=
dp),
DIMENSION(:, :, :, :),
POINTER :: drho_h, drho_s
1908 INTEGER :: ia, iso, ispin, na
1909 REAL(kind=
dp) :: rad, urad
1911 cpassert(
ASSOCIATED(r_h))
1912 cpassert(
ASSOCIATED(r_s))
1913 cpassert(
ASSOCIATED(rho_h))
1914 cpassert(
ASSOCIATED(rho_s))
1916 cpassert(
ASSOCIATED(dr_h))
1917 cpassert(
ASSOCIATED(dr_s))
1918 cpassert(
ASSOCIATED(r_h_d))
1919 cpassert(
ASSOCIATED(r_s_d))
1920 cpassert(
ASSOCIATED(drho_h))
1921 cpassert(
ASSOCIATED(drho_s))
1924 na = grid_atom%ng_sphere
1925 rad = grid_atom%rad(ir)
1926 urad = grid_atom%oorad2l(ir, 1)
1927 DO ispin = 1, nspins
1928 DO iso = 1, harmonics%max_iso_not0
1930 rho_h(ia, ir, ispin) = rho_h(ia, ir, ispin) + &
1931 r_h(ispin)%r_coef(ir, iso)*harmonics%slm(ia, iso)
1932 rho_s(ia, ir, ispin) = rho_s(ia, ir, ispin) + &
1933 r_s(ispin)%r_coef(ir, iso)*harmonics%slm(ia, iso)
1939 DO ispin = 1, nspins
1940 DO iso = 1, harmonics%max_iso_not0
1944 drho_h(1, ia, ir, ispin) = drho_h(1, ia, ir, ispin) + &
1945 dr_h(ispin)%r_coef(ir, iso)* &
1946 harmonics%a(1, ia)*harmonics%slm(ia, iso) + &
1947 r_h_d(1, ispin)%r_coef(ir, iso)* &
1948 harmonics%slm(ia, iso)
1950 drho_h(2, ia, ir, ispin) = drho_h(2, ia, ir, ispin) + &
1951 dr_h(ispin)%r_coef(ir, iso)* &
1952 harmonics%a(2, ia)*harmonics%slm(ia, iso) + &
1953 r_h_d(2, ispin)%r_coef(ir, iso)* &
1954 harmonics%slm(ia, iso)
1956 drho_h(3, ia, ir, ispin) = drho_h(3, ia, ir, ispin) + &
1957 dr_h(ispin)%r_coef(ir, iso)* &
1958 harmonics%a(3, ia)*harmonics%slm(ia, iso) + &
1959 r_h_d(3, ispin)%r_coef(ir, iso)* &
1960 harmonics%slm(ia, iso)
1963 drho_s(1, ia, ir, ispin) = drho_s(1, ia, ir, ispin) + &
1964 dr_s(ispin)%r_coef(ir, iso)* &
1965 harmonics%a(1, ia)*harmonics%slm(ia, iso) + &
1966 r_s_d(1, ispin)%r_coef(ir, iso)* &
1967 harmonics%slm(ia, iso)
1969 drho_s(2, ia, ir, ispin) = drho_s(2, ia, ir, ispin) + &
1970 dr_s(ispin)%r_coef(ir, iso)* &
1971 harmonics%a(2, ia)*harmonics%slm(ia, iso) + &
1972 r_s_d(2, ispin)%r_coef(ir, iso)* &
1973 harmonics%slm(ia, iso)
1975 drho_s(3, ia, ir, ispin) = drho_s(3, ia, ir, ispin) + &
1976 dr_s(ispin)%r_coef(ir, iso)* &
1977 harmonics%a(3, ia)*harmonics%slm(ia, iso) + &
1978 r_s_d(3, ispin)%r_coef(ir, iso)* &
1979 harmonics%slm(ia, iso)
1981 drho_h(4, ia, ir, ispin) = sqrt( &
1982 drho_h(1, ia, ir, ispin)*drho_h(1, ia, ir, ispin) + &
1983 drho_h(2, ia, ir, ispin)*drho_h(2, ia, ir, ispin) + &
1984 drho_h(3, ia, ir, ispin)*drho_h(3, ia, ir, ispin))
1986 drho_s(4, ia, ir, ispin) = sqrt( &
1987 drho_s(1, ia, ir, ispin)*drho_s(1, ia, ir, ispin) + &
1988 drho_s(2, ia, ir, ispin)*drho_s(2, ia, ir, ispin) + &
1989 drho_s(3, ia, ir, ispin)*drho_s(3, ia, ir, ispin))
2009 SUBROUTINE calc_tau_atom(tau_h, tau_s, rho_atom, qs_kind, nspins)
2011 REAL(
dp),
DIMENSION(:, :, :),
INTENT(INOUT) :: tau_h, tau_s
2014 INTEGER,
INTENT(IN) :: nspins
2016 CHARACTER(len=*),
PARAMETER :: routinen =
'calc_tau_atom'
2018 INTEGER :: dir, handle, ia, ip, ipgf, ir, iset, &
2019 iso, ispin, jp, jpgf, jset, jso, l, &
2020 maxso, na, nr, nset, starti, startj
2021 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf, o2nindex
2022 REAL(
dp) :: cpc_h, cpc_s
2023 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: fga, fgr, r1, r2
2024 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: a1, a2
2025 REAL(
dp),
DIMENSION(:, :),
POINTER :: slm, zet
2026 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dslm_dxyz
2031 NULLIFY (harmonics, grid_atom, basis_1c, lmax, lmin, npgf, zet, slm, dslm_dxyz, o2nindex)
2033 CALL timeset(routinen, handle)
2037 CALL get_qs_kind(qs_kind, grid_atom=grid_atom, harmonics=harmonics)
2038 CALL get_qs_kind(qs_kind, basis_set=basis_1c, basis_type=
"GAPW_1C")
2041 na = grid_atom%ng_sphere
2043 slm => harmonics%slm
2044 dslm_dxyz => harmonics%dslm_dxyz
2052 CALL get_gto_basis_set(gto_basis_set=basis_1c, lmax=lmax, lmin=lmin, npgf=npgf, &
2053 nset=nset, zet=zet, maxso=maxso)
2056 ALLOCATE (a1(na, nset*maxso, 3), a2(na, nset*maxso, 3))
2057 ALLOCATE (r1(nr, nset*maxso), r2(nr, nset*maxso))
2058 a1 = 0.0_dp; a2 = 0.0_dp
2059 r1 = 0.0_dp; r2 = 0.0_dp
2062 DO ipgf = 1, npgf(iset)
2063 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
2064 DO iso =
nsoset(lmin(iset) - 1) + 1,
nsoset(lmax(iset))
2071 r1(1:nr, starti + iso) = grid_atom%rad(1:nr)**(l - 1)*exp(-zet(ipgf, iset)*grid_atom%rad2(1:nr))
2074 r2(1:nr, starti + iso) = -2.0_dp*zet(ipgf, iset)*grid_atom%rad(1:nr)**(l + 1) &
2075 *exp(-zet(ipgf, iset)*grid_atom%rad2(1:nr))
2079 a1(1:na, starti + iso, dir) = dslm_dxyz(dir, 1:na, iso)
2082 a2(1:na, starti + iso, dir) = harmonics%a(dir, 1:na)*slm(1:na, iso)
2090 ALLOCATE (fga(na, 1))
2091 ALLOCATE (fgr(nr, 1))
2092 fga = 0.0_dp; fgr = 0.0_dp
2096 DO ipgf = 1, npgf(iset)
2097 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
2098 DO jpgf = 1, npgf(jset)
2099 startj = (jset - 1)*maxso + (jpgf - 1)*
nsoset(lmax(jset))
2101 DO iso =
nsoset(lmin(iset) - 1) + 1,
nsoset(lmax(iset))
2102 DO jso =
nsoset(lmin(jset) - 1) + 1,
nsoset(lmax(jset))
2104 ip = o2nindex(starti + iso)
2105 jp = o2nindex(startj + jso)
2110 fgr(1:nr, 1) = r1(1:nr, starti + iso)*r1(1:nr, startj + jso)
2112 fga(1:na, 1) = a1(1:na, starti + iso, dir)*a1(1:na, startj + jso, dir)
2114 DO ispin = 1, nspins
2116 cpc_h = rho_atom%cpc_h(ispin)%r_coef(ip, jp)
2117 cpc_s = rho_atom%cpc_s(ispin)%r_coef(ip, jp)
2122 tau_h(ia, ir, ispin) = tau_h(ia, ir, ispin) + 0.5_dp*cpc_h* &
2123 fgr(ir, 1)*fga(ia, 1)
2125 tau_s(ia, ir, ispin) = tau_s(ia, ir, ispin) + 0.5_dp*cpc_s* &
2126 fgr(ir, 1)*fga(ia, 1)
2134 fgr(1:nr, 1) = r1(1:nr, starti + iso)*r2(1:nr, startj + jso)
2136 fga(1:na, 1) = a1(1:na, starti + iso, dir)*a2(1:na, startj + jso, dir)
2138 DO ispin = 1, nspins
2140 cpc_h = rho_atom%cpc_h(ispin)%r_coef(ip, jp)
2141 cpc_s = rho_atom%cpc_s(ispin)%r_coef(ip, jp)
2146 tau_h(ia, ir, ispin) = tau_h(ia, ir, ispin) + 0.5_dp*cpc_h* &
2147 fgr(ir, 1)*fga(ia, 1)
2149 tau_s(ia, ir, ispin) = tau_s(ia, ir, ispin) + 0.5_dp*cpc_s* &
2150 fgr(ir, 1)*fga(ia, 1)
2158 fgr(1:nr, 1) = r2(1:nr, starti + iso)*r1(1:nr, startj + jso)
2160 fga(1:na, 1) = a2(1:na, starti + iso, dir)*a1(1:na, startj + jso, dir)
2162 DO ispin = 1, nspins
2164 cpc_h = rho_atom%cpc_h(ispin)%r_coef(ip, jp)
2165 cpc_s = rho_atom%cpc_s(ispin)%r_coef(ip, jp)
2170 tau_h(ia, ir, ispin) = tau_h(ia, ir, ispin) + 0.5_dp*cpc_h* &
2171 fgr(ir, 1)*fga(ia, 1)
2173 tau_s(ia, ir, ispin) = tau_s(ia, ir, ispin) + 0.5_dp*cpc_s* &
2174 fgr(ir, 1)*fga(ia, 1)
2182 fgr(1:nr, 1) = r2(1:nr, starti + iso)*r2(1:nr, startj + jso)
2184 fga(1:na, 1) = a2(1:na, starti + iso, dir)*a2(1:na, startj + jso, dir)
2186 DO ispin = 1, nspins
2188 cpc_h = rho_atom%cpc_h(ispin)%r_coef(ip, jp)
2189 cpc_s = rho_atom%cpc_s(ispin)%r_coef(ip, jp)
2194 tau_h(ia, ir, ispin) = tau_h(ia, ir, ispin) + 0.5_dp*cpc_h* &
2195 fgr(ir, 1)*fga(ia, 1)
2197 tau_s(ia, ir, ispin) = tau_s(ia, ir, ispin) + 0.5_dp*cpc_s* &
2198 fgr(ir, 1)*fga(ia, 1)
2213 DEALLOCATE (o2nindex)
2215 CALL timestop(handle)
2217 END SUBROUTINE calc_tau_atom
2232 SUBROUTINE calc_rho_nlcc(grid_atom, nspins, grad_func, &
2233 ir, rho_nlcc, rho_h, rho_s, drho_nlcc, drho_h, drho_s)
2236 INTEGER,
INTENT(IN) :: nspins
2237 LOGICAL,
INTENT(IN) :: grad_func
2238 INTEGER,
INTENT(IN) :: ir
2239 REAL(kind=
dp),
DIMENSION(:) :: rho_nlcc
2240 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: rho_h, rho_s
2241 REAL(kind=
dp),
DIMENSION(:) :: drho_nlcc
2242 REAL(kind=
dp),
DIMENSION(:, :, :, :),
POINTER :: drho_h, drho_s
2244 INTEGER :: ia, ispin, na
2245 REAL(kind=
dp) :: drho, dx, dy, dz, rad, rho, urad, xsp
2247 cpassert(
ASSOCIATED(rho_h))
2248 cpassert(
ASSOCIATED(rho_s))
2250 cpassert(
ASSOCIATED(drho_h))
2251 cpassert(
ASSOCIATED(drho_s))
2254 na = grid_atom%ng_sphere
2255 rad = grid_atom%rad(ir)
2256 urad = grid_atom%oorad2l(ir, 1)
2258 xsp = real(nspins, kind=
dp)
2259 rho = rho_nlcc(ir)/xsp
2260 DO ispin = 1, nspins
2261 rho_h(1:na, ir, ispin) = rho_h(1:na, ir, ispin) + rho
2262 rho_s(1:na, ir, ispin) = rho_s(1:na, ir, ispin) + rho
2266 drho = drho_nlcc(ir)/xsp
2267 DO ispin = 1, nspins
2269 IF (grid_atom%azi(ia) == 0.0_dp)
THEN
2273 dx = grid_atom%sin_pol(ia)*grid_atom%sin_azi(ia)
2274 dy = grid_atom%sin_pol(ia)*grid_atom%cos_azi(ia)
2276 dz = grid_atom%cos_pol(ia)
2278 drho_h(1, ia, ir, ispin) = drho_h(1, ia, ir, ispin) + drho*dx
2279 drho_h(2, ia, ir, ispin) = drho_h(2, ia, ir, ispin) + drho*dy
2280 drho_h(3, ia, ir, ispin) = drho_h(3, ia, ir, ispin) + drho*dz
2282 drho_s(1, ia, ir, ispin) = drho_s(1, ia, ir, ispin) + drho*dx
2283 drho_s(2, ia, ir, ispin) = drho_s(2, ia, ir, ispin) + drho*dy
2284 drho_s(3, ia, ir, ispin) = drho_s(3, ia, ir, ispin) + drho*dz
2286 drho_h(4, ia, ir, ispin) = sqrt( &
2287 drho_h(1, ia, ir, ispin)*drho_h(1, ia, ir, ispin) + &
2288 drho_h(2, ia, ir, ispin)*drho_h(2, ia, ir, ispin) + &
2289 drho_h(3, ia, ir, ispin)*drho_h(3, ia, ir, ispin))
2291 drho_s(4, ia, ir, ispin) = sqrt( &
2292 drho_s(1, ia, ir, ispin)*drho_s(1, ia, ir, ispin) + &
2293 drho_s(2, ia, ir, ispin)*drho_s(2, ia, ir, ispin) + &
2294 drho_s(3, ia, ir, ispin)*drho_s(3, ia, ir, ispin))
2299 END SUBROUTINE calc_rho_nlcc
2312 SUBROUTINE gavxcgb_nogc(vxc_h, vxc_s, int_hh, int_ss, grid_atom, basis_1c, harmonics, nspins)
2314 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: vxc_h, vxc_s
2319 INTEGER,
INTENT(IN) :: nspins
2321 CHARACTER(len=*),
PARAMETER :: routinen =
'gaVxcgb_noGC'
2323 INTEGER :: handle, ia, ic, icg, ipgf1, ipgf2, ir, iset1, iset2, iso, iso1, iso2, ispin, l, &
2324 ld, lmax12, lmax_expansion, lmin12, m1, m2, max_iso_not0, max_iso_not0_local, max_s_harm, &
2325 maxl, maxso, n1, n2, na, ngau1, ngau2, nngau1, nr, nset, size1
2326 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: cg_n_list
2327 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: cg_list
2328 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf
2329 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: g1, g2
2330 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: gg, gvg_h, gvg_s, matso_h, matso_s, vx
2331 REAL(
dp),
DIMENSION(:, :),
POINTER :: zet
2332 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: my_cg
2334 CALL timeset(routinen, handle)
2336 NULLIFY (lmin, lmax, npgf, zet, my_cg)
2339 maxso=maxso, maxl=maxl, npgf=npgf, &
2343 na = grid_atom%ng_sphere
2344 my_cg => harmonics%my_CG
2345 max_iso_not0 = harmonics%max_iso_not0
2346 lmax_expansion =
indso(1, max_iso_not0)
2347 max_s_harm = harmonics%max_s_harm
2349 ALLOCATE (g1(nr), g2(nr), gg(nr, 0:2*maxl))
2350 ALLOCATE (gvg_h(na, 0:2*maxl), gvg_s(na, 0:2*maxl))
2353 ALLOCATE (vx(na, nr))
2354 ALLOCATE (cg_list(2,
nsoset(maxl)**2, max_s_harm), cg_n_list(max_s_harm))
2363 CALL get_none0_cg_list(my_cg, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
2364 max_s_harm, lmax_expansion, cg_list, cg_n_list, max_iso_not0_local)
2365 cpassert(max_iso_not0_local <= max_iso_not0)
2368 DO ipgf1 = 1, npgf(iset1)
2369 ngau1 = n1*(ipgf1 - 1) + m1
2371 nngau1 =
nsoset(lmin(iset1) - 1) + ngau1
2373 g1(1:nr) = exp(-zet(ipgf1, iset1)*grid_atom%rad2(1:nr))
2374 DO ipgf2 = 1, npgf(iset2)
2375 ngau2 = n2*(ipgf2 - 1) + m2
2377 g2(1:nr) = exp(-zet(ipgf2, iset2)*grid_atom%rad2(1:nr))
2378 lmin12 = lmin(iset1) + lmin(iset2)
2379 lmax12 = lmax(iset1) + lmax(iset2)
2382 IF (lmin12 <= lmax_expansion)
THEN
2385 IF (lmin12 == 0)
THEN
2386 gg(1:nr, lmin12) = g1(1:nr)*g2(1:nr)
2388 gg(1:nr, lmin12) = grid_atom%rad2l(1:nr, lmin12)*g1(1:nr)*g2(1:nr)
2392 IF (lmax12 > lmax_expansion) lmax12 = lmax_expansion
2394 DO l = lmin12 + 1, lmax12
2395 gg(1:nr, l) = grid_atom%rad(1:nr)*gg(:, l - 1)
2398 DO ispin = 1, nspins
2401 vx(1:na, ir) = vxc_h(1:na, ir, ispin)
2403 CALL dgemm(
'N',
'N', na, ld, nr, 1.0_dp, vx(1:na, 1:nr), na, &
2404 gg(1:nr, 0:lmax12), nr, 0.0_dp, gvg_h(1:na, 0:lmax12), na)
2406 vx(1:na, ir) = vxc_s(1:na, ir, ispin)
2408 CALL dgemm(
'N',
'N', na, ld, nr, 1.0_dp, vx(1:na, 1:nr), na, &
2409 gg(1:nr, 0:lmax12), nr, 0.0_dp, gvg_s(1:na, 0:lmax12), na)
2413 DO iso = 1, max_iso_not0_local
2414 DO icg = 1, cg_n_list(iso)
2415 iso1 = cg_list(1, icg, iso)
2416 iso2 = cg_list(2, icg, iso)
2419 cpassert(l <= lmax_expansion)
2421 matso_h(iso1, iso2) = matso_h(iso1, iso2) + &
2423 my_cg(iso1, iso2, iso)* &
2424 harmonics%slm(ia, iso)
2425 matso_s(iso1, iso2) = matso_s(iso1, iso2) + &
2427 my_cg(iso1, iso2, iso)* &
2428 harmonics%slm(ia, iso)
2434 DO ic =
nsoset(lmin(iset2) - 1) + 1,
nsoset(lmax(iset2))
2435 iso1 =
nsoset(lmin(iset1) - 1) + 1
2437 CALL daxpy(size1, 1.0_dp, matso_h(iso1, ic), 1, &
2438 int_hh(ispin)%r_coef(nngau1 + 1, iso2), 1)
2439 CALL daxpy(size1, 1.0_dp, matso_s(iso1, ic), 1, &
2440 int_ss(ispin)%r_coef(nngau1 + 1, iso2), 1)
2454 DEALLOCATE (g1, g2, gg, matso_h, matso_s, gvg_s, gvg_h, vx)
2456 DEALLOCATE (cg_list, cg_n_list)
2458 CALL timestop(handle)
2475 SUBROUTINE gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, &
2476 grid_atom, basis_1c, harmonics, nspins)
2478 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: vxc_h, vxc_s
2479 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: vxg_h, vxg_s
2484 INTEGER,
INTENT(IN) :: nspins
2486 CHARACTER(len=*),
PARAMETER :: routinen =
'gaVxcgb_GC'
2488 INTEGER :: dmax_iso_not0_local, handle, ia, ic, icg, ipgf1, ipgf2, ir, iset1, iset2, iso, &
2489 iso1, iso2, ispin, l, lmax12, lmax_expansion, lmin12, m1, m2, max_iso_not0, &
2490 max_iso_not0_local, max_s_harm, maxl, maxso, n1, n2, na, ngau1, ngau2, nngau1, nr, nset, &
2492 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: cg_n_list, dcg_n_list
2493 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: cg_list, dcg_list
2494 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf
2496 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: g1, g2
2497 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dgg, gg, gvxcg_h, gvxcg_s, matso_h, &
2499 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: gvxgg_h, gvxgg_s
2500 REAL(
dp),
DIMENSION(:, :),
POINTER :: zet
2501 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: my_cg
2502 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: my_cg_dxyz
2504 CALL timeset(routinen, handle)
2506 NULLIFY (lmin, lmax, npgf, zet, my_cg, my_cg_dxyz)
2509 maxso=maxso, maxl=maxl, npgf=npgf, &
2513 na = grid_atom%ng_sphere
2514 my_cg => harmonics%my_CG
2515 my_cg_dxyz => harmonics%my_CG_dxyz
2516 max_iso_not0 = harmonics%max_iso_not0
2517 lmax_expansion =
indso(1, max_iso_not0)
2518 max_s_harm = harmonics%max_s_harm
2520 ALLOCATE (g1(nr), g2(nr), gg(nr, 0:2*maxl), dgg(nr, 0:2*maxl))
2521 ALLOCATE (gvxcg_h(na, 0:2*maxl), gvxcg_s(na, 0:2*maxl))
2522 ALLOCATE (gvxgg_h(3, na, 0:2*maxl), gvxgg_s(3, na, 0:2*maxl))
2523 ALLOCATE (cg_list(2,
nsoset(maxl)**2, max_s_harm), cg_n_list(max_s_harm), &
2524 dcg_list(2,
nsoset(maxl)**2, max_s_harm), dcg_n_list(max_s_harm))
2529 DO ispin = 1, nspins
2538 CALL get_none0_cg_list(my_cg, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
2539 max_s_harm, lmax_expansion, cg_list, cg_n_list, max_iso_not0_local)
2540 cpassert(max_iso_not0_local <= max_iso_not0)
2541 CALL get_none0_cg_list(my_cg_dxyz, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
2542 max_s_harm, lmax_expansion, dcg_list, dcg_n_list, dmax_iso_not0_local)
2545 DO ipgf1 = 1, npgf(iset1)
2546 ngau1 = n1*(ipgf1 - 1) + m1
2548 nngau1 =
nsoset(lmin(iset1) - 1) + ngau1
2550 g1(1:nr) = exp(-zet(ipgf1, iset1)*grid_atom%rad2(1:nr))
2551 DO ipgf2 = 1, npgf(iset2)
2552 ngau2 = n2*(ipgf2 - 1) + m2
2554 g2(1:nr) = exp(-zet(ipgf2, iset2)*grid_atom%rad2(1:nr))
2555 lmin12 = lmin(iset1) + lmin(iset2)
2556 lmax12 = lmax(iset1) + lmax(iset2)
2559 IF (lmin12 <= lmax_expansion)
THEN
2564 IF (lmin12 == 0)
THEN
2565 gg(1:nr, lmin12) = g1(1:nr)*g2(1:nr)
2567 gg(1:nr, lmin12) = grid_atom%rad2l(1:nr, lmin12)*g1(1:nr)*g2(1:nr)
2571 IF (lmax12 > lmax_expansion) lmax12 = lmax_expansion
2573 DO l = lmin12 + 1, lmax12
2574 gg(1:nr, l) = grid_atom%rad(1:nr)*gg(:, l - 1)
2575 dgg(1:nr, l - 1) = dgg(1:nr, l - 1) - 2.0_dp*(zet(ipgf1, iset1) + &
2576 zet(ipgf2, iset2))*gg(1:nr, l)
2578 dgg(1:nr, lmax12) = dgg(1:nr, lmax12) - 2.0_dp*(zet(ipgf1, iset1) + &
2579 zet(ipgf2, iset2))*grid_atom%rad(1:nr)* &
2588 DO l = lmin12, lmax12
2591 gvxcg_h(ia, l) = gvxcg_h(ia, l) + &
2592 gg(ir, l)*vxc_h(ia, ir, ispin) + &
2594 (vxg_h(1, ia, ir, ispin)*harmonics%a(1, ia) + &
2595 vxg_h(2, ia, ir, ispin)*harmonics%a(2, ia) + &
2596 vxg_h(3, ia, ir, ispin)*harmonics%a(3, ia))
2598 gvxcg_s(ia, l) = gvxcg_s(ia, l) + &
2599 gg(ir, l)*vxc_s(ia, ir, ispin) + &
2601 (vxg_s(1, ia, ir, ispin)*harmonics%a(1, ia) + &
2602 vxg_s(2, ia, ir, ispin)*harmonics%a(2, ia) + &
2603 vxg_s(3, ia, ir, ispin)*harmonics%a(3, ia))
2605 urad = grid_atom%oorad2l(ir, 1)
2607 gvxgg_h(1, ia, l) = gvxgg_h(1, ia, l) + &
2608 vxg_h(1, ia, ir, ispin)* &
2611 gvxgg_h(2, ia, l) = gvxgg_h(2, ia, l) + &
2612 vxg_h(2, ia, ir, ispin)* &
2615 gvxgg_h(3, ia, l) = gvxgg_h(3, ia, l) + &
2616 vxg_h(3, ia, ir, ispin)* &
2619 gvxgg_s(1, ia, l) = gvxgg_s(1, ia, l) + &
2620 vxg_s(1, ia, ir, ispin)* &
2623 gvxgg_s(2, ia, l) = gvxgg_s(2, ia, l) + &
2624 vxg_s(2, ia, ir, ispin)* &
2627 gvxgg_s(3, ia, l) = gvxgg_s(3, ia, l) + &
2628 vxg_s(3, ia, ir, ispin)* &
2637 DO iso = 1, max_iso_not0_local
2638 DO icg = 1, cg_n_list(iso)
2639 iso1 = cg_list(1, icg, iso)
2640 iso2 = cg_list(2, icg, iso)
2645 cpassert(l <= lmax_expansion)
2647 matso_h(iso1, iso2) = matso_h(iso1, iso2) + &
2649 harmonics%slm(ia, iso)* &
2650 my_cg(iso1, iso2, iso)
2651 matso_s(iso1, iso2) = matso_s(iso1, iso2) + &
2653 harmonics%slm(ia, iso)* &
2654 my_cg(iso1, iso2, iso)
2663 DO iso = 1, dmax_iso_not0_local
2664 DO icg = 1, dcg_n_list(iso)
2665 iso1 = dcg_list(1, icg, iso)
2666 iso2 = dcg_list(2, icg, iso)
2670 cpassert(l <= lmax_expansion)
2672 matso_h(iso1, iso2) = matso_h(iso1, iso2) + &
2673 (gvxgg_h(1, ia, l)*my_cg_dxyz(1, iso1, iso2, iso) + &
2674 gvxgg_h(2, ia, l)*my_cg_dxyz(2, iso1, iso2, iso) + &
2675 gvxgg_h(3, ia, l)*my_cg_dxyz(3, iso1, iso2, iso))* &
2676 harmonics%slm(ia, iso)
2678 matso_s(iso1, iso2) = matso_s(iso1, iso2) + &
2679 (gvxgg_s(1, ia, l)*my_cg_dxyz(1, iso1, iso2, iso) + &
2680 gvxgg_s(2, ia, l)*my_cg_dxyz(2, iso1, iso2, iso) + &
2681 gvxgg_s(3, ia, l)*my_cg_dxyz(3, iso1, iso2, iso))* &
2682 harmonics%slm(ia, iso)
2694 DO ic =
nsoset(lmin(iset2) - 1) + 1,
nsoset(lmax(iset2))
2695 iso1 =
nsoset(lmin(iset1) - 1) + 1
2697 CALL daxpy(size1, 1.0_dp, matso_h(iso1, ic), 1, &
2698 int_hh(ispin)%r_coef(nngau1 + 1, iso2), 1)
2699 CALL daxpy(size1, 1.0_dp, matso_s(iso1, ic), 1, &
2700 int_ss(ispin)%r_coef(nngau1 + 1, iso2), 1)
2711 DEALLOCATE (g1, g2, gg, dgg, matso_h, matso_s, gvxcg_h, gvxcg_s, gvxgg_h, gvxgg_s)
2712 DEALLOCATE (cg_list, cg_n_list, dcg_list, dcg_n_list)
2714 CALL timestop(handle)
2716 END SUBROUTINE gavxcgb_gc
2731 SUBROUTINE dgavtaudgb(vtau_h, vtau_s, int_hh, int_ss, &
2732 grid_atom, basis_1c, harmonics, nspins)
2734 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: vtau_h, vtau_s
2739 INTEGER,
INTENT(IN) :: nspins
2741 CHARACTER(len=*),
PARAMETER :: routinen =
'dgaVtaudgb'
2743 INTEGER :: dir, handle, ipgf, iset, iso, ispin, &
2744 jpgf, jset, jso, l, maxso, na, nr, &
2745 nset, starti, startj
2746 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf
2747 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: fga, fgr, r1, r2, work
2748 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: a1, a2, intso_h, intso_s
2749 REAL(
dp),
DIMENSION(:, :),
POINTER :: slm, zet
2750 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dslm_dxyz
2752 CALL timeset(routinen, handle)
2754 NULLIFY (zet, slm, dslm_dxyz, lmax, lmin, npgf)
2757 maxso=maxso, npgf=npgf, nset=nset, zet=zet)
2759 na = grid_atom%ng_sphere
2762 slm => harmonics%slm
2763 dslm_dxyz => harmonics%dslm_dxyz
2767 ALLOCATE (a1(na, nset*maxso, 3), a2(na, nset*maxso, 3))
2768 ALLOCATE (r1(nr, nset*maxso), r2(nr, nset*maxso))
2769 a1 = 0.0_dp; a2 = 0.0_dp
2770 r1 = 0.0_dp; r2 = 0.0_dp
2773 DO ipgf = 1, npgf(iset)
2774 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
2775 DO iso =
nsoset(lmin(iset) - 1) + 1,
nsoset(lmax(iset))
2782 r1(1:nr, starti + iso) = grid_atom%rad(1:nr)**(l - 1)*exp(-zet(ipgf, iset)*grid_atom%rad2(1:nr))
2785 r2(1:nr, starti + iso) = -2.0_dp*zet(ipgf, iset)*grid_atom%rad(1:nr)**(l + 1) &
2786 *exp(-zet(ipgf, iset)*grid_atom%rad2(1:nr))
2790 a1(1:na, starti + iso, dir) = dslm_dxyz(dir, 1:na, iso)
2793 a2(1:na, starti + iso, dir) = harmonics%a(dir, 1:na)*slm(1:na, iso)
2801 ALLOCATE (intso_h(nset*maxso, nset*maxso, nspins))
2802 ALLOCATE (intso_s(nset*maxso, nset*maxso, nspins))
2803 intso_h = 0.0_dp; intso_s = 0.0_dp
2805 ALLOCATE (fga(na, 1))
2806 ALLOCATE (fgr(nr, 1))
2807 ALLOCATE (work(na, 1))
2808 fga = 0.0_dp; fgr = 0.0_dp; work = 0.0_dp
2812 DO ipgf = 1, npgf(iset)
2813 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
2814 DO jpgf = 1, npgf(jset)
2815 startj = (jset - 1)*maxso + (jpgf - 1)*
nsoset(lmax(jset))
2817 DO iso =
nsoset(lmin(iset) - 1) + 1,
nsoset(lmax(iset))
2818 DO jso =
nsoset(lmin(jset) - 1) + 1,
nsoset(lmax(jset))
2823 fgr(1:nr, 1) = r1(1:nr, starti + iso)*r1(1:nr, startj + jso)
2825 fga(1:na, 1) = a1(1:na, starti + iso, dir)*a1(1:na, startj + jso, dir)
2827 DO ispin = 1, nspins
2828 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_h(:, :, ispin), na, fgr, &
2829 nr, 0.0_dp, work, na)
2830 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2831 intso_h(starti + iso:, startj + jso, ispin), 1)
2833 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_s(:, :, ispin), na, fgr, &
2834 nr, 0.0_dp, work, na)
2835 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2836 intso_s(starti + iso:, startj + jso, ispin), 1)
2841 fgr(1:nr, 1) = r1(1:nr, starti + iso)*r2(1:nr, startj + jso)
2843 fga(1:na, 1) = a1(1:na, starti + iso, dir)*a2(1:na, startj + jso, dir)
2845 DO ispin = 1, nspins
2846 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_h(:, :, ispin), na, fgr, &
2847 nr, 0.0_dp, work, na)
2848 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2849 intso_h(starti + iso:, startj + jso, ispin), 1)
2851 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_s(:, :, ispin), na, fgr, &
2852 nr, 0.0_dp, work, na)
2853 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2854 intso_s(starti + iso:, startj + jso, ispin), 1)
2859 fgr(1:nr, 1) = r2(1:nr, starti + iso)*r1(1:nr, startj + jso)
2861 fga(1:na, 1) = a2(1:na, starti + iso, dir)*a1(1:na, startj + jso, dir)
2863 DO ispin = 1, nspins
2864 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_h(:, :, ispin), na, fgr, &
2865 nr, 0.0_dp, work, na)
2866 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2867 intso_h(starti + iso:, startj + jso, ispin), 1)
2869 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_s(:, :, ispin), na, fgr, &
2870 nr, 0.0_dp, work, na)
2871 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2872 intso_s(starti + iso:, startj + jso, ispin), 1)
2877 fgr(1:nr, 1) = r2(1:nr, starti + iso)*r2(1:nr, startj + jso)
2879 fga(1:na, 1) = a2(1:na, starti + iso, dir)*a2(1:na, startj + jso, dir)
2881 DO ispin = 1, nspins
2882 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_h(:, :, ispin), na, fgr, &
2883 nr, 0.0_dp, work, na)
2884 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2885 intso_h(starti + iso:, startj + jso, ispin), 1)
2887 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_s(:, :, ispin), na, fgr, &
2888 nr, 0.0_dp, work, na)
2889 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2890 intso_s(starti + iso:, startj + jso, ispin), 1)
2903 DO ispin = 1, nspins
2904 int_hh(ispin)%r_coef(:, :) = int_hh(ispin)%r_coef(:, :) + intso_h(:, :, ispin)
2905 int_ss(ispin)%r_coef(:, :) = int_ss(ispin)%r_coef(:, :) + intso_s(:, :, ispin)
2908 CALL timestop(handle)
2910 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)
...
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 fill_rho_set(rho_set, lsd, nspins, needs, rho, drho, tau, na, ir)
...
subroutine, public xc_2nd_deriv_of_r(rho_set, rho1_set, xc_section, deriv_set, w, vxc, vxg, do_triplet, do_sf)
...
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