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 :: donlcc, gradient_f, lsd, nlcc, paw_atom, &
105 REAL(
dp) :: density_cut, exc_h, exc_s, gradient_cut, &
106 my_adiabatic_rescale_factor, tau_cut
107 REAL(
dp),
DIMENSION(1, 1, 1) :: tau_d
108 REAL(
dp),
DIMENSION(1, 1, 1, 1) :: rho_d
109 REAL(
dp),
DIMENSION(:, :),
POINTER :: rho_nlcc, weight
110 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rho_h, rho_s, tau_h, tau_s, vtau_h, &
112 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: drho_h, drho_s, vxg_h, vxg_s
119 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: my_kind_set
120 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr_h, dr_s, int_hh, int_ss, r_h, r_s
122 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: my_rho_atom_set
131 CALL timeset(routinen, handle)
134 NULLIFY (my_kind_set)
135 NULLIFY (atomic_kind_set)
141 NULLIFY (my_rho_atom_set)
144 IF (
PRESENT(adiabatic_rescale_factor))
THEN
145 my_adiabatic_rescale_factor = adiabatic_rescale_factor
147 my_adiabatic_rescale_factor = 1.0_dp
151 dft_control=dft_control, &
153 atomic_kind_set=atomic_kind_set, &
154 qs_kind_set=my_kind_set, &
156 rho_atom_set=my_rho_atom_set)
158 IF (
PRESENT(kind_set_external)) my_kind_set => kind_set_external
159 IF (
PRESENT(rho_atom_set_external)) my_rho_atom_set => rho_atom_set_external
165 IF (
PRESENT(xc_section_external)) my_xc_section => xc_section_external
173 my_rho_atom_set(:)%exc_h = 0.0_dp
174 my_rho_atom_set(:)%exc_s = 0.0_dp
183 lsd = dft_control%lsd
184 nspins = dft_control%nspins
187 calc_potential=.true.)
189 gradient_f = (needs%drho .OR. needs%drho_spin)
190 tau_f = (needs%tau .OR. needs%tau_spin)
196 NULLIFY (rho_h, drho_h, rho_s, drho_s, weight)
197 NULLIFY (vxc_h, vxc_s, vxg_h, vxg_s)
198 NULLIFY (tau_h, tau_s)
199 NULLIFY (vtau_h, vtau_s)
203 DO ikind = 1,
SIZE(atomic_kind_set)
204 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
205 CALL get_qs_kind(my_kind_set(ikind), paw_atom=paw_atom, &
206 harmonics=harmonics, grid_atom=grid_atom)
207 CALL get_qs_kind(my_kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
209 IF (.NOT. paw_atom) cycle
212 na = grid_atom%ng_sphere
227 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
229 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
235 CALL reallocate(rho_h, 1, na, 1, nr, 1, nspins)
236 CALL reallocate(rho_s, 1, na, 1, nr, 1, nspins)
237 weight => grid_atom%weight
238 CALL reallocate(vxc_h, 1, na, 1, nr, 1, nspins)
239 CALL reallocate(vxc_s, 1, na, 1, nr, 1, nspins)
242 CALL reallocate(drho_h, 1, 4, 1, na, 1, nr, 1, nspins)
243 CALL reallocate(drho_s, 1, 4, 1, na, 1, nr, 1, nspins)
244 CALL reallocate(vxg_h, 1, 3, 1, na, 1, nr, 1, nspins)
245 CALL reallocate(vxg_s, 1, 3, 1, na, 1, nr, 1, nspins)
249 CALL reallocate(tau_h, 1, na, 1, nr, 1, nspins)
250 CALL reallocate(tau_s, 1, na, 1, nr, 1, nspins)
251 CALL reallocate(vtau_h, 1, na, 1, nr, 1, nspins)
252 CALL reallocate(vtau_s, 1, na, 1, nr, 1, nspins)
259 rho_nlcc => my_kind_set(ikind)%nlcc_pot
260 IF (
ASSOCIATED(rho_nlcc)) donlcc = .true.
265 num_pe = para_env%num_pe
266 bo =
get_limit(natom, para_env%num_pe, para_env%mepos)
268 DO iat = bo(1), bo(2)
269 iatom = atom_list(iat)
271 my_rho_atom_set(iatom)%exc_h = 0.0_dp
272 my_rho_atom_set(iatom)%exc_s = 0.0_dp
274 rho_atom => my_rho_atom_set(iatom)
278 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
280 rho_rad_s=r_s, drho_rad_h=dr_h, &
281 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, &
287 CALL get_rho_atom(rho_atom=rho_atom, rho_rad_h=r_h, rho_rad_s=r_s)
292 CALL calc_tau_atom(tau_h, tau_s, rho_atom, my_kind_set(ikind), nspins)
299 ir, r_h, r_s, rho_h, rho_s, dr_h, dr_s, &
300 r_h_d, r_s_d, drho_h, drho_s)
302 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
303 ir, rho_nlcc(:, 1), rho_h, rho_s, rho_nlcc(:, 2), drho_h, drho_s)
308 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
309 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
310 ELSE IF (gradient_f)
THEN
311 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_d, na, ir)
312 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_d, na, ir)
314 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rho_d, tau_d, na, ir)
315 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rho_d, tau_d, na, ir)
323 CALL vxc_of_r_new(xc_fun_section, rho_set_h, deriv_set, 1, needs, weight, &
324 lsd, na, nr, exc_h, vxc_h, vxg_h, vtau_h, energy_only=energy_only, &
325 adiabatic_rescale_factor=my_adiabatic_rescale_factor)
326 rho_atom%exc_h = rho_atom%exc_h + exc_h
332 CALL vxc_of_r_new(xc_fun_section, rho_set_s, deriv_set, 1, needs, weight, &
333 lsd, na, nr, exc_s, vxc_s, vxg_s, vtau_s, energy_only=energy_only, &
334 adiabatic_rescale_factor=my_adiabatic_rescale_factor)
335 rho_atom%exc_s = rho_atom%exc_s + exc_s
339 exc1 = exc1 + rho_atom%exc_h - rho_atom%exc_s
345 IF (.NOT. energy_only)
THEN
346 NULLIFY (int_hh, int_ss)
347 CALL get_rho_atom(rho_atom=rho_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
349 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, &
350 grid_atom, basis_1c, harmonics, nspins)
353 grid_atom, basis_1c, harmonics, nspins)
356 CALL dgavtaudgb(vtau_h, vtau_s, int_hh, int_ss, &
357 grid_atom, basis_1c, harmonics, nspins)
360 NULLIFY (r_h, r_s, dr_h, dr_s)
370 CALL para_env%sum(exc1)
372 IF (
ASSOCIATED(rho_h))
DEALLOCATE (rho_h)
373 IF (
ASSOCIATED(rho_s))
DEALLOCATE (rho_s)
374 IF (
ASSOCIATED(vxc_h))
DEALLOCATE (vxc_h)
375 IF (
ASSOCIATED(vxc_s))
DEALLOCATE (vxc_s)
378 IF (
ASSOCIATED(drho_h))
DEALLOCATE (drho_h)
379 IF (
ASSOCIATED(drho_s))
DEALLOCATE (drho_s)
380 IF (
ASSOCIATED(vxg_h))
DEALLOCATE (vxg_h)
381 IF (
ASSOCIATED(vxg_s))
DEALLOCATE (vxg_s)
385 IF (
ASSOCIATED(tau_h))
DEALLOCATE (tau_h)
386 IF (
ASSOCIATED(tau_s))
DEALLOCATE (tau_s)
387 IF (
ASSOCIATED(vtau_h))
DEALLOCATE (vtau_h)
388 IF (
ASSOCIATED(vtau_s))
DEALLOCATE (vtau_s)
393 CALL timestop(handle)
406 REAL(
dp),
INTENT(INOUT) :: exc1
409 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_vxc_atom_epr'
411 INTEGER :: bo(2), handle, ia, iat, iatom, idir, &
412 ikind, ir, ispin, myfun, na, natom, &
414 INTEGER,
DIMENSION(2, 3) :: bounds
415 INTEGER,
DIMENSION(:),
POINTER :: atom_list
416 LOGICAL :: donlcc, gradient_f, lsd, nlcc, paw_atom, &
418 REAL(
dp) :: density_cut, exc_h, exc_s, gradient_cut, &
420 REAL(
dp),
DIMENSION(1, 1, 1) :: tau_d
421 REAL(
dp),
DIMENSION(1, 1, 1, 1) :: rho_d
422 REAL(
dp),
DIMENSION(:, :),
POINTER :: rho_nlcc, weight
423 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rho_h, rho_s, tau_h, tau_s, vtau_h, &
425 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: drho_h, drho_s, vxg_h, vxg_s
432 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: my_kind_set
433 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr_h, dr_s, int_hh, int_ss, r_h, r_s
435 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: my_rho_atom_set
444 CALL timeset(routinen, handle)
447 NULLIFY (my_kind_set)
448 NULLIFY (atomic_kind_set)
454 NULLIFY (my_rho_atom_set)
458 dft_control=dft_control, &
460 atomic_kind_set=atomic_kind_set, &
461 qs_kind_set=my_kind_set, &
463 rho_atom_set=my_rho_atom_set)
468 "PROPERTIES%LINRES%EPR%PRINT%G_TENSOR%XC")
475 my_rho_atom_set(:)%exc_h = 0.0_dp
476 my_rho_atom_set(:)%exc_s = 0.0_dp
485 lsd = dft_control%lsd
486 nspins = dft_control%nspins
489 calc_potential=.true.)
492 needs%drho_spin = .true.
494 gradient_f = (needs%drho .OR. needs%drho_spin)
495 tau_f = (needs%tau .OR. needs%tau_spin)
501 NULLIFY (rho_h, drho_h, rho_s, drho_s, weight)
502 NULLIFY (vxc_h, vxc_s, vxg_h, vxg_s)
503 NULLIFY (tau_h, tau_s)
504 NULLIFY (vtau_h, vtau_s)
508 DO ikind = 1,
SIZE(atomic_kind_set)
509 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
510 CALL get_qs_kind(my_kind_set(ikind), paw_atom=paw_atom, &
511 harmonics=harmonics, grid_atom=grid_atom)
512 CALL get_qs_kind(my_kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
514 IF (.NOT. paw_atom) cycle
517 na = grid_atom%ng_sphere
532 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
534 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
540 CALL reallocate(rho_h, 1, na, 1, nr, 1, nspins)
541 CALL reallocate(rho_s, 1, na, 1, nr, 1, nspins)
542 weight => grid_atom%weight
543 CALL reallocate(vxc_h, 1, na, 1, nr, 1, nspins)
544 CALL reallocate(vxc_s, 1, na, 1, nr, 1, nspins)
547 CALL reallocate(drho_h, 1, 4, 1, na, 1, nr, 1, nspins)
548 CALL reallocate(drho_s, 1, 4, 1, na, 1, nr, 1, nspins)
549 CALL reallocate(vxg_h, 1, 3, 1, na, 1, nr, 1, nspins)
550 CALL reallocate(vxg_s, 1, 3, 1, na, 1, nr, 1, nspins)
554 CALL reallocate(tau_h, 1, na, 1, nr, 1, nspins)
555 CALL reallocate(tau_s, 1, na, 1, nr, 1, nspins)
556 CALL reallocate(vtau_h, 1, na, 1, nr, 1, nspins)
557 CALL reallocate(vtau_s, 1, na, 1, nr, 1, nspins)
564 rho_nlcc => my_kind_set(ikind)%nlcc_pot
565 IF (
ASSOCIATED(rho_nlcc)) donlcc = .true.
570 num_pe = para_env%num_pe
571 bo =
get_limit(natom, para_env%num_pe, para_env%mepos)
573 DO iat = bo(1), bo(2)
574 iatom = atom_list(iat)
576 my_rho_atom_set(iatom)%exc_h = 0.0_dp
577 my_rho_atom_set(iatom)%exc_s = 0.0_dp
579 rho_atom => my_rho_atom_set(iatom)
583 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
585 rho_rad_s=r_s, drho_rad_h=dr_h, &
586 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, &
592 CALL get_rho_atom(rho_atom=rho_atom, rho_rad_h=r_h, rho_rad_s=r_s)
597 CALL calc_tau_atom(tau_h, tau_s, rho_atom, my_kind_set(ikind), nspins)
604 ir, r_h, r_s, rho_h, rho_s, dr_h, dr_s, &
605 r_h_d, r_s_d, drho_h, drho_s)
607 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
608 ir, rho_nlcc(:, 1), rho_h, rho_s, rho_nlcc(:, 2), drho_h, drho_s)
613 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
614 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
615 ELSE IF (gradient_f)
THEN
616 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_d, na, ir)
617 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_d, na, ir)
619 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rho_d, tau_d, na, ir)
620 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rho_d, tau_d, na, ir)
628 CALL vxc_of_r_epr(xc_fun_section, rho_set_h, deriv_set, needs, weight, &
629 lsd, na, nr, exc_h, vxc_h, vxg_h, vtau_h)
630 rho_atom%exc_h = rho_atom%exc_h + exc_h
636 CALL vxc_of_r_epr(xc_fun_section, rho_set_s, deriv_set, needs, weight, &
637 lsd, na, nr, exc_s, vxc_s, vxg_s, vtau_s)
638 rho_atom%exc_s = rho_atom%exc_s + exc_s
644 gradient_atom_set(iatom)%nablavks_vec_rad_h(idir, ispin)%r_coef(ir, ia) = &
645 gradient_atom_set(iatom)%nablavks_vec_rad_h(idir, ispin)%r_coef(ir, ia) &
646 + vxg_h(idir, ia, ir, ispin)
647 gradient_atom_set(iatom)%nablavks_vec_rad_s(idir, ispin)%r_coef(ir, ia) = &
648 gradient_atom_set(iatom)%nablavks_vec_rad_s(idir, ispin)%r_coef(ir, ia) &
649 + vxg_s(idir, ia, ir, ispin)
657 exc1 = exc1 + rho_atom%exc_h - rho_atom%exc_s
663 NULLIFY (int_hh, int_ss)
664 CALL get_rho_atom(rho_atom=rho_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
666 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, &
667 grid_atom, basis_1c, harmonics, nspins)
670 grid_atom, basis_1c, harmonics, nspins)
673 CALL dgavtaudgb(vtau_h, vtau_s, int_hh, int_ss, &
674 grid_atom, basis_1c, harmonics, nspins)
676 NULLIFY (r_h, r_s, dr_h, dr_s)
686 CALL para_env%sum(exc1)
688 IF (
ASSOCIATED(rho_h))
DEALLOCATE (rho_h)
689 IF (
ASSOCIATED(rho_s))
DEALLOCATE (rho_s)
690 IF (
ASSOCIATED(vxc_h))
DEALLOCATE (vxc_h)
691 IF (
ASSOCIATED(vxc_s))
DEALLOCATE (vxc_s)
694 IF (
ASSOCIATED(drho_h))
DEALLOCATE (drho_h)
695 IF (
ASSOCIATED(drho_s))
DEALLOCATE (drho_s)
696 IF (
ASSOCIATED(vxg_h))
DEALLOCATE (vxg_h)
697 IF (
ASSOCIATED(vxg_s))
DEALLOCATE (vxg_s)
701 IF (
ASSOCIATED(tau_h))
DEALLOCATE (tau_h)
702 IF (
ASSOCIATED(tau_s))
DEALLOCATE (tau_s)
703 IF (
ASSOCIATED(vtau_h))
DEALLOCATE (vtau_h)
704 IF (
ASSOCIATED(vtau_s))
DEALLOCATE (vtau_s)
709 CALL timestop(handle)
726 do_tddfpt2, do_triplet, do_sf, kind_set_external)
728 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: rho_atom_set, rho1_atom_set
732 LOGICAL,
INTENT(IN),
OPTIONAL :: do_tddfpt2, do_triplet, do_sf
734 POINTER :: kind_set_external
736 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_xc_2nd_deriv_atom'
738 INTEGER ::
atom, handle, iatom, ikind, ir, na, &
740 INTEGER,
DIMENSION(2) :: local_loop_limit
741 INTEGER,
DIMENSION(2, 3) :: bounds
742 INTEGER,
DIMENSION(:),
POINTER :: atom_list
743 LOGICAL :: gradient_functional, lsd, my_do_sf, &
744 paw_atom, scale_rho, tau_f
745 REAL(kind=
dp) :: density_cut, gradient_cut, rtot, tau_cut
746 REAL(kind=
dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
747 POINTER :: vxc_h, vxc_s
748 REAL(kind=
dp),
DIMENSION(1, 1, 1) :: rtau
749 REAL(kind=
dp),
DIMENSION(1, 1, 1, 1) :: rrho
750 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: weight
751 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: rho1_h, rho1_s, rho_h, rho_s, tau1_h, &
753 REAL(kind=
dp),
DIMENSION(:, :, :, :),
POINTER :: drho1_h, drho1_s, drho_h, drho_s, vxg_h, &
759 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: my_kind_set, qs_kind_set
760 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr1_h, dr1_s, dr_h, dr_s, int_hh, &
761 int_ss, r1_h, r1_s, r_h, r_s
762 TYPE(
rho_atom_coeff),
DIMENSION(:, :),
POINTER :: r1_h_d, r1_s_d, r_h_d, r_s_d
772 CALL timeset(routinen, handle)
774 NULLIFY (qs_kind_set)
775 NULLIFY (rho_h, rho_s, drho_h, drho_s, weight)
776 NULLIFY (rho1_h, rho1_s, drho1_h, drho1_s)
777 NULLIFY (vxc_h, vxc_s, vxg_h, vxg_s)
778 NULLIFY (tau_h, tau_s, tau1_h, tau1_s)
782 qs_kind_set=qs_kind_set, &
783 atomic_kind_set=atomic_kind_set)
785 IF (
PRESENT(kind_set_external))
THEN
786 my_kind_set => kind_set_external
788 my_kind_set => qs_kind_set
800 IF (
PRESENT(do_sf)) my_do_sf = do_sf
811 IF (
PRESENT(do_tddfpt2) .AND.
PRESENT(do_triplet))
THEN
812 IF (nspins == 1 .AND. do_triplet)
THEN
816 ELSEIF (
PRESENT(do_triplet))
THEN
817 IF (nspins == 1 .AND. do_triplet) lsd = .true.
821 calc_potential=.true.)
822 gradient_functional = needs%drho .OR. needs%drho_spin
823 tau_f = (needs%tau .OR. needs%tau_spin)
825 cpabort(
"Tau functionals not implemented for GAPW 2nd derivatives")
831 DO ikind = 1,
SIZE(atomic_kind_set)
833 NULLIFY (atom_list, harmonics, grid_atom)
834 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
835 CALL get_qs_kind(my_kind_set(ikind), paw_atom=paw_atom, &
836 harmonics=harmonics, grid_atom=grid_atom)
837 CALL get_qs_kind(my_kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
838 IF (.NOT. paw_atom) cycle
841 na = grid_atom%ng_sphere
852 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
854 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
856 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
858 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
861 IF (nspins == 1 .AND. .NOT. lsd)
THEN
873 ALLOCATE (rho_h(1:na, 1:nr, 1:nspins), rho1_h(1:na, 1:nr, 1:nspins), &
874 rho_s(1:na, 1:nr, 1:nspins), rho1_s(1:na, 1:nr, 1:nspins))
876 ALLOCATE (vxc_h(1:na, 1:nr, 1:nspins), vxc_s(1:na, 1:nr, 1:nspins))
880 weight => grid_atom%weight
882 IF (gradient_functional)
THEN
883 ALLOCATE (drho_h(1:4, 1:na, 1:nr, 1:nspins), drho1_h(1:4, 1:na, 1:nr, 1:nspins), &
884 drho_s(1:4, 1:na, 1:nr, 1:nspins), drho1_s(1:4, 1:na, 1:nr, 1:nspins))
885 ALLOCATE (vxg_h(1:3, 1:na, 1:nr, 1:nspins), vxg_s(1:3, 1:na, 1:nr, 1:nspins))
887 ALLOCATE (drho_h(1, 1, 1, 1), drho1_h(1, 1, 1, 1), &
888 drho_s(1, 1, 1, 1), drho1_s(1, 1, 1, 1))
889 ALLOCATE (vxg_h(1, 1, 1, 1), vxg_s(1, 1, 1, 1))
896 local_loop_limit =
get_limit(natom, para_env%num_pe, para_env%mepos)
898 DO iatom = local_loop_limit(1), local_loop_limit(2)
899 atom = atom_list(iatom)
901 rho_atom_set(
atom)%exc_h = 0.0_dp
902 rho_atom_set(
atom)%exc_s = 0.0_dp
903 rho1_atom_set(
atom)%exc_h = 0.0_dp
904 rho1_atom_set(
atom)%exc_s = 0.0_dp
906 rho_atom => rho_atom_set(
atom)
907 rho1_atom => rho1_atom_set(
atom)
908 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
909 NULLIFY (r1_h, r1_s, dr1_h, dr1_s, r1_h_d, r1_s_d)
914 IF (gradient_functional)
THEN
916 rho_rad_h=r_h, rho_rad_s=r_s, &
917 drho_rad_h=dr_h, drho_rad_s=dr_s, &
918 rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
920 rho_rad_h=r1_h, rho_rad_s=r1_s, &
921 drho_rad_h=dr1_h, drho_rad_s=dr1_s, &
922 rho_rad_h_d=r1_h_d, rho_rad_s_d=r1_s_d)
923 drho_h = 0.0_dp; drho_s = 0.0_dp
924 drho1_h = 0.0_dp; drho1_s = 0.0_dp
927 rho_rad_h=r_h, rho_rad_s=r_s)
929 rho_rad_h=r1_h, rho_rad_s=r1_s)
936 ir, r_h, r_s, rho_h, rho_s, dr_h, dr_s, r_h_d, r_s_d, &
939 ir, r1_h, r1_s, rho1_h, rho1_s, dr1_h, dr1_s, r1_h_d, r1_s_d, &
945 IF (gradient_functional)
THEN
946 drho_h = 2.0_dp*drho_h
947 drho_s = 2.0_dp*drho_s
953 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
954 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau1_h, na, ir)
955 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
956 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau1_s, na, ir)
957 ELSE IF (gradient_functional)
THEN
958 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, rtau, na, ir)
959 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, rtau, na, ir)
960 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, rtau, na, ir)
961 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, rtau, na, ir)
963 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rrho, rtau, na, ir)
964 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, rrho, rtau, na, ir)
965 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rrho, rtau, na, ir)
966 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, rrho, rtau, na, ir)
971 rho_set=rho_set_h, rho1_set=rho1_set_h, &
972 deriv_set=deriv_set, &
973 w=weight, vxc=vxc_h, vxg=vxg_h, do_triplet=do_triplet, &
976 rho_set=rho_set_s, rho1_set=rho1_set_s, &
977 deriv_set=deriv_set, &
978 w=weight, vxc=vxc_s, vxg=vxg_s, do_triplet=do_triplet, &
981 CALL get_rho_atom(rho_atom=rho1_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
982 IF (gradient_functional)
THEN
983 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, &
984 grid_atom, basis_1c, harmonics, nspins)
987 grid_atom, basis_1c, harmonics, nspins)
990 NULLIFY (r_h, r_s, dr_h, dr_s)
996 DEALLOCATE (rho_h, rho_s, rho1_h, rho1_s, vxc_h, vxc_s)
997 DEALLOCATE (drho_h, drho_s, vxg_h, vxg_s)
998 DEALLOCATE (drho1_h, drho1_s)
1008 CALL timestop(handle)
1024 kind_set, xc_section, is_triplet, accuracy)
1027 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: rho0_atom_set, rho1_atom_set, &
1031 LOGICAL,
INTENT(IN) :: is_triplet
1032 INTEGER,
INTENT(IN) :: accuracy
1034 CHARACTER(LEN=*),
PARAMETER :: routinen =
'calculate_gfxc_atom'
1035 REAL(kind=
dp),
PARAMETER :: epsrho = 5.e-4_dp
1037 INTEGER :: bo(2), handle, iat, iatom, ikind, ir, &
1038 istep, mspins, myfun, na, natom, nf, &
1039 nr, ns, nspins, nstep, num_pe
1040 INTEGER,
DIMENSION(2, 3) :: bounds
1041 INTEGER,
DIMENSION(:),
POINTER :: atom_list
1042 LOGICAL :: donlcc, gradient_f, lsd, nlcc, paw_atom, &
1044 REAL(
dp) :: beta, density_cut, exc_h, exc_s, &
1045 gradient_cut, oeps1, oeps2, tau_cut
1046 REAL(
dp),
DIMENSION(1, 1, 1) :: tau_d
1047 REAL(
dp),
DIMENSION(1, 1, 1, 1) :: rho_d
1048 REAL(
dp),
DIMENSION(:, :),
POINTER :: rho_nlcc, weight
1049 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rho0_h, rho0_s, rho1_h, rho1_s, rho_h, &
1050 rho_s, tau0_h, tau0_s, tau1_h, tau1_s, &
1051 tau_h, tau_s, vtau_h, vtau_s, vxc_h, &
1053 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: drho0_h, drho0_s, drho1_h, drho1_s, &
1054 drho_h, drho_s, vxg_h, vxg_s
1055 REAL(kind=
dp),
DIMENSION(-4:4) :: ak, bl
1062 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr_h, dr_s, fint_hh, fint_ss, int_hh, &
1065 TYPE(
rho_atom_type),
POINTER :: rho0_atom, rho1_atom, rho2_atom
1071 CALL timeset(routinen, handle)
1075 SELECT CASE (accuracy)
1078 ak(-2:2) = (/1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp/)/12.0_dp
1079 bl(-2:2) = (/-1.0_dp, 16.0_dp, -30.0_dp, 16.0_dp, -1.0_dp/)/12.0_dp
1082 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
1083 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
1086 ak(-4:4) = (/1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
1087 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp/)/280.0_dp
1088 bl(-4:4) = (/-1.0_dp, 128.0_dp/9.0_dp, -112.0_dp, 896.0_dp, -14350.0_dp/9.0_dp, &
1089 896.0_dp, -112.0_dp, 128.0_dp/9.0_dp, -1.0_dp/)/560.0_dp
1091 oeps1 = 1.0_dp/epsrho
1092 oeps2 = 1.0_dp/(epsrho**2)
1095 dft_control=dft_control, &
1096 para_env=para_env, &
1097 atomic_kind_set=atomic_kind_set)
1110 lsd = dft_control%lsd
1111 nspins = dft_control%nspins
1113 IF (is_triplet)
THEN
1114 cpassert(nspins == 1)
1119 gradient_f = (needs%drho .OR. needs%drho_spin)
1120 tau_f = (needs%tau .OR. needs%tau_spin)
1123 DO ikind = 1,
SIZE(atomic_kind_set)
1124 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
1125 CALL get_qs_kind(kind_set(ikind), paw_atom=paw_atom, &
1126 harmonics=harmonics, grid_atom=grid_atom)
1127 CALL get_qs_kind(kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
1129 IF (.NOT. paw_atom) cycle
1132 na = grid_atom%ng_sphere
1139 bounds(1:2, 1:3) = 1
1147 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1149 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1155 weight => grid_atom%weight
1157 ALLOCATE (rho_h(na, nr, mspins), rho_s(na, nr, mspins), &
1158 rho0_h(na, nr, nspins), rho0_s(na, nr, nspins), &
1159 rho1_h(na, nr, nspins), rho1_s(na, nr, nspins))
1160 ALLOCATE (vxc_h(na, nr, mspins), vxc_s(na, nr, mspins))
1161 IF (gradient_f)
THEN
1162 ALLOCATE (drho_h(4, na, nr, mspins), drho_s(4, na, nr, mspins), &
1163 drho0_h(4, na, nr, nspins), drho0_s(4, na, nr, nspins), &
1164 drho1_h(4, na, nr, nspins), drho1_s(4, na, nr, nspins))
1165 ALLOCATE (vxg_h(3, na, nr, mspins), vxg_s(3, na, nr, mspins))
1168 ALLOCATE (tau_h(na, nr, mspins), tau_s(na, nr, mspins), &
1169 tau0_h(na, nr, nspins), tau0_s(na, nr, nspins), &
1170 tau1_h(na, nr, nspins), tau1_s(na, nr, nspins))
1171 ALLOCATE (vtau_h(na, nr, mspins), vtau_s(na, nr, mspins))
1178 rho_nlcc => kind_set(ikind)%nlcc_pot
1179 IF (
ASSOCIATED(rho_nlcc)) donlcc = .true.
1183 num_pe = para_env%num_pe
1184 bo =
get_limit(natom, num_pe, para_env%mepos)
1186 DO iat = bo(1), bo(2)
1187 iatom = atom_list(iat)
1189 NULLIFY (int_hh, int_ss)
1190 rho0_atom => rho0_atom_set(iatom)
1191 CALL get_rho_atom(rho_atom=rho0_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1192 ALLOCATE (fint_ss(nspins), fint_hh(nspins))
1194 nf =
SIZE(int_ss(ns)%r_coef, 1)
1195 ALLOCATE (fint_ss(ns)%r_coef(nf, nf))
1196 nf =
SIZE(int_hh(ns)%r_coef, 1)
1197 ALLOCATE (fint_hh(ns)%r_coef(nf, nf))
1203 rho0_atom => rho0_atom_set(iatom)
1204 IF (gradient_f)
THEN
1205 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
1206 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
1207 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
1212 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s)
1217 ir, r_h, r_s, rho0_h, rho0_s, dr_h, dr_s, &
1218 r_h_d, r_s_d, drho0_h, drho0_s)
1220 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
1221 ir, rho_nlcc(:, 1), rho0_h, rho0_s, rho_nlcc(:, 2), drho0_h, drho0_s)
1226 CALL calc_tau_atom(tau0_h, tau0_s, rho0_atom, kind_set(ikind), nspins)
1233 rho1_atom => rho1_atom_set(iatom)
1234 IF (gradient_f)
THEN
1235 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
1236 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
1237 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
1242 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s)
1246 ir, r_h, r_s, rho1_h, rho1_s, dr_h, dr_s, &
1247 r_h_d, r_s_d, drho1_h, drho1_s)
1251 CALL calc_tau_atom(tau1_h, tau1_s, rho1_atom, kind_set(ikind), nspins)
1254 rho2_atom => rho2_atom_set(iatom)
1256 DO istep = -nstep, nstep
1258 beta = real(istep, kind=
dp)*epsrho
1260 IF (is_triplet)
THEN
1261 rho_h(:, :, 1) = rho0_h(:, :, 1) + beta*rho1_h(:, :, 1)
1262 rho_h(:, :, 2) = rho0_h(:, :, 1)
1263 rho_h = 0.5_dp*rho_h
1264 rho_s(:, :, 1) = rho0_s(:, :, 1) + beta*rho1_s(:, :, 1)
1265 rho_s(:, :, 2) = rho0_s(:, :, 1)
1266 rho_s = 0.5_dp*rho_s
1267 IF (gradient_f)
THEN
1268 drho_h(:, :, :, 1) = drho0_h(:, :, :, 1) + beta*drho1_h(:, :, :, 1)
1269 drho_h(:, :, :, 2) = drho0_h(:, :, :, 1)
1270 drho_h = 0.5_dp*drho_h
1271 drho_s(:, :, :, 1) = drho0_s(:, :, :, 1) + beta*drho1_s(:, :, :, 1)
1272 drho_s(:, :, :, 2) = drho0_s(:, :, :, 1)
1273 drho_s = 0.5_dp*drho_s
1276 tau_h(:, :, 1) = tau0_h(:, :, 1) + beta*tau1_h(:, :, 1)
1277 tau_h(:, :, 2) = tau0_h(:, :, 1)
1278 tau_h = 0.5_dp*tau0_h
1279 tau_s(:, :, 1) = tau0_s(:, :, 1) + beta*tau1_s(:, :, 1)
1280 tau_s(:, :, 2) = tau0_s(:, :, 1)
1281 tau_s = 0.5_dp*tau0_s
1284 rho_h = rho0_h + beta*rho1_h
1285 rho_s = rho0_s + beta*rho1_s
1286 IF (gradient_f)
THEN
1287 drho_h = drho0_h + beta*drho1_h
1288 drho_s = drho0_s + beta*drho1_s
1291 tau_h = tau0_h + beta*tau1_h
1292 tau_s = tau0_s + beta*tau1_s
1296 IF (gradient_f)
THEN
1297 drho_h(4, :, :, :) = sqrt( &
1298 drho_h(1, :, :, :)*drho_h(1, :, :, :) + &
1299 drho_h(2, :, :, :)*drho_h(2, :, :, :) + &
1300 drho_h(3, :, :, :)*drho_h(3, :, :, :))
1302 drho_s(4, :, :, :) = sqrt( &
1303 drho_s(1, :, :, :)*drho_s(1, :, :, :) + &
1304 drho_s(2, :, :, :)*drho_s(2, :, :, :) + &
1305 drho_s(3, :, :, :)*drho_s(3, :, :, :))
1310 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, drho_h, tau_h, na, ir)
1311 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, drho_s, tau_s, na, ir)
1312 ELSE IF (gradient_f)
THEN
1313 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, drho_h, tau_d, na, ir)
1314 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, drho_s, tau_d, na, ir)
1316 CALL fill_rho_set(rho_set_h, lsd, mspins, needs, rho_h, rho_d, tau_d, na, ir)
1317 CALL fill_rho_set(rho_set_s, lsd, mspins, needs, rho_s, rho_d, tau_d, na, ir)
1323 CALL vxc_of_r_new(xc_fun_section, rho_set_h, deriv_set, 1, needs, weight, &
1324 lsd, na, nr, exc_h, vxc_h, vxg_h, vtau_h)
1325 IF (is_triplet)
THEN
1326 vxc_h(:, :, 1) = vxc_h(:, :, 1) - vxc_h(:, :, 2)
1327 IF (gradient_f)
THEN
1328 vxg_h(:, :, :, 1) = vxg_h(:, :, :, 1) - vxg_h(:, :, :, 2)
1331 vtau_h(:, :, 1) = vtau_h(:, :, 1) - vtau_h(:, :, 2)
1336 CALL vxc_of_r_new(xc_fun_section, rho_set_s, deriv_set, 1, needs, weight, &
1337 lsd, na, nr, exc_s, vxc_s, vxg_s, vtau_s)
1338 IF (is_triplet)
THEN
1339 vxc_s(:, :, 1) = vxc_s(:, :, 1) - vxc_s(:, :, 2)
1340 IF (gradient_f)
THEN
1341 vxg_s(:, :, :, 1) = vxg_s(:, :, :, 1) - vxg_s(:, :, :, 2)
1344 vtau_s(:, :, 1) = vtau_s(:, :, 1) - vtau_s(:, :, 2)
1349 fint_hh(ns)%r_coef(:, :) = 0.0_dp
1350 fint_ss(ns)%r_coef(:, :) = 0.0_dp
1352 IF (gradient_f)
THEN
1353 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, fint_hh, fint_ss, &
1354 grid_atom, basis_1c, harmonics, nspins)
1357 grid_atom, basis_1c, harmonics, nspins)
1360 CALL dgavtaudgb(vtau_h, vtau_s, fint_hh, fint_ss, &
1361 grid_atom, basis_1c, harmonics, nspins)
1364 NULLIFY (int_hh, int_ss)
1365 CALL get_rho_atom(rho_atom=rho1_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1367 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_ss(ns)%r_coef(:, :)
1368 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_hh(ns)%r_coef(:, :)
1371 NULLIFY (int_hh, int_ss)
1372 CALL get_rho_atom(rho_atom=rho2_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1374 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps2*bl(istep)*fint_ss(ns)%r_coef(:, :)
1375 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps2*bl(istep)*fint_hh(ns)%r_coef(:, :)
1380 DEALLOCATE (fint_ss(ns)%r_coef)
1381 DEALLOCATE (fint_hh(ns)%r_coef)
1383 DEALLOCATE (fint_ss, fint_hh)
1392 DEALLOCATE (rho_h, rho_s, rho0_h, rho0_s, rho1_h, rho1_s)
1393 DEALLOCATE (vxc_h, vxc_s)
1394 IF (gradient_f)
THEN
1395 DEALLOCATE (drho_h, drho_s, drho0_h, drho0_s, drho1_h, drho1_s)
1396 DEALLOCATE (vxg_h, vxg_s)
1399 DEALLOCATE (tau_h, tau_s, tau0_h, tau0_s, tau1_h, tau1_s)
1400 DEALLOCATE (vtau_h, vtau_s)
1407 CALL timestop(handle)
1424 kind_set, xc_section, is_triplet, accuracy, epsrho)
1427 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: rho0_atom_set, rho1_atom_set, &
1431 LOGICAL,
INTENT(IN) :: is_triplet
1432 INTEGER,
INTENT(IN) :: accuracy
1433 REAL(kind=
dp),
INTENT(IN) :: epsrho
1435 CHARACTER(LEN=*),
PARAMETER :: routinen =
'gfxc_atom_diff'
1437 INTEGER :: bo(2), handle, iat, iatom, ikind, ir, &
1438 istep, mspins, myfun, na, natom, nf, &
1439 nr, ns, nspins, nstep, num_pe
1440 INTEGER,
DIMENSION(2, 3) :: bounds
1441 INTEGER,
DIMENSION(:),
POINTER :: atom_list
1442 LOGICAL :: donlcc, gradient_f, lsd, nlcc, paw_atom, &
1444 REAL(
dp) :: beta, density_cut, gradient_cut, oeps1, &
1446 REAL(
dp),
CONTIGUOUS,
DIMENSION(:, :, :),
POINTER :: vxc_h, vxc_s
1447 REAL(
dp),
DIMENSION(1, 1, 1) :: tau_d
1448 REAL(
dp),
DIMENSION(1, 1, 1, 1) :: rho_d
1449 REAL(
dp),
DIMENSION(:, :),
POINTER :: rho_nlcc, weight
1450 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: rho0_h, rho0_s, rho1_h, rho1_s, rho_h, &
1451 rho_s, tau0_h, tau0_s, tau1_h, tau1_s, &
1452 tau_h, tau_s, vtau_h, vtau_s
1453 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: drho0_h, drho0_s, drho1_h, drho1_s, &
1454 drho_h, drho_s, vxg_h, vxg_s
1455 REAL(kind=
dp),
DIMENSION(-4:4) :: ak
1462 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr_h, dr_s, fint_hh, fint_ss, int_hh, &
1465 TYPE(
rho_atom_type),
POINTER :: rho0_atom, rho1_atom, rho2_atom
1472 CALL timeset(routinen, handle)
1475 SELECT CASE (accuracy)
1478 ak(-2:2) = (/1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp/)/12.0_dp
1481 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
1484 ak(-4:4) = (/1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
1485 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp/)/280.0_dp
1487 oeps1 = 1.0_dp/epsrho
1490 dft_control=dft_control, &
1491 para_env=para_env, &
1492 atomic_kind_set=atomic_kind_set)
1502 do_triplet=is_triplet, kind_set_external=kind_set)
1509 lsd = dft_control%lsd
1510 nspins = dft_control%nspins
1512 IF (is_triplet)
THEN
1513 cpassert(nspins == 1)
1518 gradient_f = (needs%drho .OR. needs%drho_spin)
1519 tau_f = (needs%tau .OR. needs%tau_spin)
1522 DO ikind = 1,
SIZE(atomic_kind_set)
1523 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
1524 CALL get_qs_kind(kind_set(ikind), paw_atom=paw_atom, &
1525 harmonics=harmonics, grid_atom=grid_atom)
1526 CALL get_qs_kind(kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
1528 IF (.NOT. paw_atom) cycle
1531 na = grid_atom%ng_sphere
1538 bounds(1:2, 1:3) = 1
1546 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1548 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1550 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1552 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
1560 weight => grid_atom%weight
1562 ALLOCATE (rho_h(na, nr, nspins), rho_s(na, nr, nspins), &
1563 rho0_h(na, nr, nspins), rho0_s(na, nr, nspins), &
1564 rho1_h(na, nr, nspins), rho1_s(na, nr, nspins))
1565 ALLOCATE (vxc_h(na, nr, nspins), vxc_s(na, nr, nspins))
1566 IF (gradient_f)
THEN
1567 ALLOCATE (drho_h(4, na, nr, nspins), drho_s(4, na, nr, nspins), &
1568 drho0_h(4, na, nr, nspins), drho0_s(4, na, nr, nspins), &
1569 drho1_h(4, na, nr, nspins), drho1_s(4, na, nr, nspins))
1570 ALLOCATE (vxg_h(3, na, nr, nspins), vxg_s(3, na, nr, nspins))
1573 ALLOCATE (tau_h(na, nr, nspins), tau_s(na, nr, nspins), &
1574 tau0_h(na, nr, nspins), tau0_s(na, nr, nspins), &
1575 tau1_h(na, nr, nspins), tau1_s(na, nr, nspins))
1576 ALLOCATE (vtau_h(na, nr, nspins), vtau_s(na, nr, nspins))
1583 rho_nlcc => kind_set(ikind)%nlcc_pot
1584 IF (
ASSOCIATED(rho_nlcc)) donlcc = .true.
1588 num_pe = para_env%num_pe
1589 bo =
get_limit(natom, num_pe, para_env%mepos)
1591 DO iat = bo(1), bo(2)
1592 iatom = atom_list(iat)
1594 NULLIFY (int_hh, int_ss)
1595 rho0_atom => rho0_atom_set(iatom)
1596 CALL get_rho_atom(rho_atom=rho0_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1597 ALLOCATE (fint_ss(nspins), fint_hh(nspins))
1599 nf =
SIZE(int_ss(ns)%r_coef, 1)
1600 ALLOCATE (fint_ss(ns)%r_coef(nf, nf))
1601 nf =
SIZE(int_hh(ns)%r_coef, 1)
1602 ALLOCATE (fint_hh(ns)%r_coef(nf, nf))
1608 rho0_atom => rho0_atom_set(iatom)
1609 IF (gradient_f)
THEN
1610 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
1611 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
1612 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
1617 CALL get_rho_atom(rho_atom=rho0_atom, rho_rad_h=r_h, rho_rad_s=r_s)
1622 ir, r_h, r_s, rho0_h, rho0_s, dr_h, dr_s, &
1623 r_h_d, r_s_d, drho0_h, drho0_s)
1625 CALL calc_rho_nlcc(grid_atom, nspins, gradient_f, &
1626 ir, rho_nlcc(:, 1), rho0_h, rho0_s, rho_nlcc(:, 2), drho0_h, drho0_s)
1631 CALL calc_tau_atom(tau0_h, tau0_s, rho0_atom, kind_set(ikind), nspins)
1638 rho1_atom => rho1_atom_set(iatom)
1639 IF (gradient_f)
THEN
1640 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
1641 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s, drho_rad_h=dr_h, &
1642 drho_rad_s=dr_s, rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
1647 CALL get_rho_atom(rho_atom=rho1_atom, rho_rad_h=r_h, rho_rad_s=r_s)
1651 ir, r_h, r_s, rho1_h, rho1_s, dr_h, dr_s, &
1652 r_h_d, r_s_d, drho1_h, drho1_s)
1656 CALL calc_tau_atom(tau1_h, tau1_s, rho1_atom, kind_set(ikind), nspins)
1661 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau1_h, na, ir)
1662 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau1_s, na, ir)
1663 ELSE IF (gradient_f)
THEN
1664 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau_d, na, ir)
1665 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau_d, na, ir)
1667 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, rho_d, tau_d, na, ir)
1668 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, rho_d, tau_d, na, ir)
1673 rho2_atom => rho2_atom_set(iatom)
1675 DO istep = -nstep, nstep
1677 beta = real(istep, kind=
dp)*epsrho
1679 rho_h = rho0_h + beta*rho1_h
1680 rho_s = rho0_s + beta*rho1_s
1681 IF (gradient_f)
THEN
1682 drho_h = drho0_h + beta*drho1_h
1683 drho_s = drho0_s + beta*drho1_s
1686 tau_h = tau0_h + beta*tau1_h
1687 tau_s = tau0_s + beta*tau1_s
1690 IF (gradient_f)
THEN
1691 drho_h(4, :, :, :) = sqrt( &
1692 drho_h(1, :, :, :)*drho_h(1, :, :, :) + &
1693 drho_h(2, :, :, :)*drho_h(2, :, :, :) + &
1694 drho_h(3, :, :, :)*drho_h(3, :, :, :))
1696 drho_s(4, :, :, :) = sqrt( &
1697 drho_s(1, :, :, :)*drho_s(1, :, :, :) + &
1698 drho_s(2, :, :, :)*drho_s(2, :, :, :) + &
1699 drho_s(3, :, :, :)*drho_s(3, :, :, :))
1704 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
1705 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
1706 ELSE IF (gradient_f)
THEN
1707 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_d, na, ir)
1708 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_d, na, ir)
1710 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rho_d, tau_d, na, ir)
1711 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rho_d, tau_d, na, ir)
1718 rho_set=rho_set_h, rho1_set=rho1_set_h, &
1719 deriv_set=deriv_set, &
1720 w=weight, vxc=vxc_h, vxg=vxg_h, do_triplet=is_triplet)
1724 rho_set=rho_set_s, rho1_set=rho1_set_s, &
1725 deriv_set=deriv_set, &
1726 w=weight, vxc=vxc_s, vxg=vxg_s, do_triplet=is_triplet)
1729 fint_hh(ns)%r_coef(:, :) = 0.0_dp
1730 fint_ss(ns)%r_coef(:, :) = 0.0_dp
1732 IF (gradient_f)
THEN
1733 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, fint_hh, fint_ss, &
1734 grid_atom, basis_1c, harmonics, nspins)
1737 grid_atom, basis_1c, harmonics, nspins)
1740 CALL dgavtaudgb(vtau_h, vtau_s, fint_hh, fint_ss, &
1741 grid_atom, basis_1c, harmonics, nspins)
1744 NULLIFY (int_hh, int_ss)
1745 CALL get_rho_atom(rho_atom=rho2_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
1747 int_ss(ns)%r_coef(:, :) = int_ss(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_ss(ns)%r_coef(:, :)
1748 int_hh(ns)%r_coef(:, :) = int_hh(ns)%r_coef(:, :) + oeps1*ak(istep)*fint_hh(ns)%r_coef(:, :)
1753 DEALLOCATE (fint_ss(ns)%r_coef)
1754 DEALLOCATE (fint_hh(ns)%r_coef)
1756 DEALLOCATE (fint_ss, fint_hh)
1767 DEALLOCATE (rho_h, rho_s, rho0_h, rho0_s, rho1_h, rho1_s)
1768 DEALLOCATE (vxc_h, vxc_s)
1769 IF (gradient_f)
THEN
1770 DEALLOCATE (drho_h, drho_s, drho0_h, drho0_s, drho1_h, drho1_s)
1771 DEALLOCATE (vxg_h, vxg_s)
1774 DEALLOCATE (tau_h, tau_s, tau0_h, tau0_s, tau1_h, tau1_s)
1775 DEALLOCATE (vtau_h, vtau_s)
1782 CALL timestop(handle)
1805 ir, r_h, r_s, rho_h, rho_s, &
1806 dr_h, dr_s, r_h_d, r_s_d, drho_h, drho_s)
1810 INTEGER,
INTENT(IN) :: nspins
1811 LOGICAL,
INTENT(IN) :: grad_func
1812 INTEGER,
INTENT(IN) :: ir
1814 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: rho_h, rho_s
1817 REAL(kind=
dp),
DIMENSION(:, :, :, :),
POINTER :: drho_h, drho_s
1819 INTEGER :: ia, iso, ispin, na
1820 REAL(kind=
dp) :: rad, urad
1822 cpassert(
ASSOCIATED(r_h))
1823 cpassert(
ASSOCIATED(r_s))
1824 cpassert(
ASSOCIATED(rho_h))
1825 cpassert(
ASSOCIATED(rho_s))
1827 cpassert(
ASSOCIATED(dr_h))
1828 cpassert(
ASSOCIATED(dr_s))
1829 cpassert(
ASSOCIATED(r_h_d))
1830 cpassert(
ASSOCIATED(r_s_d))
1831 cpassert(
ASSOCIATED(drho_h))
1832 cpassert(
ASSOCIATED(drho_s))
1835 na = grid_atom%ng_sphere
1836 rad = grid_atom%rad(ir)
1837 urad = grid_atom%oorad2l(ir, 1)
1838 DO ispin = 1, nspins
1839 DO iso = 1, harmonics%max_iso_not0
1841 rho_h(ia, ir, ispin) = rho_h(ia, ir, ispin) + &
1842 r_h(ispin)%r_coef(ir, iso)*harmonics%slm(ia, iso)
1843 rho_s(ia, ir, ispin) = rho_s(ia, ir, ispin) + &
1844 r_s(ispin)%r_coef(ir, iso)*harmonics%slm(ia, iso)
1850 DO ispin = 1, nspins
1851 DO iso = 1, harmonics%max_iso_not0
1855 drho_h(1, ia, ir, ispin) = drho_h(1, ia, ir, ispin) + &
1856 dr_h(ispin)%r_coef(ir, iso)* &
1857 harmonics%a(1, ia)*harmonics%slm(ia, iso) + &
1858 r_h_d(1, ispin)%r_coef(ir, iso)* &
1859 harmonics%slm(ia, iso)
1861 drho_h(2, ia, ir, ispin) = drho_h(2, ia, ir, ispin) + &
1862 dr_h(ispin)%r_coef(ir, iso)* &
1863 harmonics%a(2, ia)*harmonics%slm(ia, iso) + &
1864 r_h_d(2, ispin)%r_coef(ir, iso)* &
1865 harmonics%slm(ia, iso)
1867 drho_h(3, ia, ir, ispin) = drho_h(3, ia, ir, ispin) + &
1868 dr_h(ispin)%r_coef(ir, iso)* &
1869 harmonics%a(3, ia)*harmonics%slm(ia, iso) + &
1870 r_h_d(3, ispin)%r_coef(ir, iso)* &
1871 harmonics%slm(ia, iso)
1874 drho_s(1, ia, ir, ispin) = drho_s(1, ia, ir, ispin) + &
1875 dr_s(ispin)%r_coef(ir, iso)* &
1876 harmonics%a(1, ia)*harmonics%slm(ia, iso) + &
1877 r_s_d(1, ispin)%r_coef(ir, iso)* &
1878 harmonics%slm(ia, iso)
1880 drho_s(2, ia, ir, ispin) = drho_s(2, ia, ir, ispin) + &
1881 dr_s(ispin)%r_coef(ir, iso)* &
1882 harmonics%a(2, ia)*harmonics%slm(ia, iso) + &
1883 r_s_d(2, ispin)%r_coef(ir, iso)* &
1884 harmonics%slm(ia, iso)
1886 drho_s(3, ia, ir, ispin) = drho_s(3, ia, ir, ispin) + &
1887 dr_s(ispin)%r_coef(ir, iso)* &
1888 harmonics%a(3, ia)*harmonics%slm(ia, iso) + &
1889 r_s_d(3, ispin)%r_coef(ir, iso)* &
1890 harmonics%slm(ia, iso)
1892 drho_h(4, ia, ir, ispin) = sqrt( &
1893 drho_h(1, ia, ir, ispin)*drho_h(1, ia, ir, ispin) + &
1894 drho_h(2, ia, ir, ispin)*drho_h(2, ia, ir, ispin) + &
1895 drho_h(3, ia, ir, ispin)*drho_h(3, ia, ir, ispin))
1897 drho_s(4, ia, ir, ispin) = sqrt( &
1898 drho_s(1, ia, ir, ispin)*drho_s(1, ia, ir, ispin) + &
1899 drho_s(2, ia, ir, ispin)*drho_s(2, ia, ir, ispin) + &
1900 drho_s(3, ia, ir, ispin)*drho_s(3, ia, ir, ispin))
1920 SUBROUTINE calc_tau_atom(tau_h, tau_s, rho_atom, qs_kind, nspins)
1922 REAL(
dp),
DIMENSION(:, :, :),
INTENT(INOUT) :: tau_h, tau_s
1925 INTEGER,
INTENT(IN) :: nspins
1927 CHARACTER(len=*),
PARAMETER :: routinen =
'calc_tau_atom'
1929 INTEGER :: dir, handle, ia, ip, ipgf, ir, iset, &
1930 iso, ispin, jp, jpgf, jset, jso, l, &
1931 maxso, na, nr, nset, starti, startj
1932 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf, o2nindex
1933 REAL(
dp) :: cpc_h, cpc_s
1934 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: fga, fgr, r1, r2
1935 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: a1, a2
1936 REAL(
dp),
DIMENSION(:, :),
POINTER :: slm, zet
1937 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dslm_dxyz
1942 NULLIFY (harmonics, grid_atom, basis_1c, lmax, lmin, npgf, zet, slm, dslm_dxyz, o2nindex)
1944 CALL timeset(routinen, handle)
1948 CALL get_qs_kind(qs_kind, grid_atom=grid_atom, harmonics=harmonics)
1949 CALL get_qs_kind(qs_kind, basis_set=basis_1c, basis_type=
"GAPW_1C")
1952 na = grid_atom%ng_sphere
1954 slm => harmonics%slm
1955 dslm_dxyz => harmonics%dslm_dxyz
1963 CALL get_gto_basis_set(gto_basis_set=basis_1c, lmax=lmax, lmin=lmin, npgf=npgf, &
1964 nset=nset, zet=zet, maxso=maxso)
1967 ALLOCATE (a1(na, nset*maxso, 3), a2(na, nset*maxso, 3))
1968 ALLOCATE (r1(nr, nset*maxso), r2(nr, nset*maxso))
1969 a1 = 0.0_dp; a2 = 0.0_dp
1970 r1 = 0.0_dp; r2 = 0.0_dp
1973 DO ipgf = 1, npgf(iset)
1974 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
1975 DO iso =
nsoset(lmin(iset) - 1) + 1,
nsoset(lmax(iset))
1982 r1(1:nr, starti + iso) = grid_atom%rad(1:nr)**(l - 1)*exp(-zet(ipgf, iset)*grid_atom%rad2(1:nr))
1985 r2(1:nr, starti + iso) = -2.0_dp*zet(ipgf, iset)*grid_atom%rad(1:nr)**(l + 1) &
1986 *exp(-zet(ipgf, iset)*grid_atom%rad2(1:nr))
1990 a1(1:na, starti + iso, dir) = dslm_dxyz(dir, 1:na, iso)
1993 a2(1:na, starti + iso, dir) = harmonics%a(dir, 1:na)*slm(1:na, iso)
2001 ALLOCATE (fga(na, 1))
2002 ALLOCATE (fgr(nr, 1))
2003 fga = 0.0_dp; fgr = 0.0_dp
2007 DO ipgf = 1, npgf(iset)
2008 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
2009 DO jpgf = 1, npgf(jset)
2010 startj = (jset - 1)*maxso + (jpgf - 1)*
nsoset(lmax(jset))
2012 DO iso =
nsoset(lmin(iset) - 1) + 1,
nsoset(lmax(iset))
2013 DO jso =
nsoset(lmin(jset) - 1) + 1,
nsoset(lmax(jset))
2015 ip = o2nindex(starti + iso)
2016 jp = o2nindex(startj + jso)
2021 fgr(1:nr, 1) = r1(1:nr, starti + iso)*r1(1:nr, startj + jso)
2023 fga(1:na, 1) = a1(1:na, starti + iso, dir)*a1(1:na, startj + jso, dir)
2025 DO ispin = 1, nspins
2027 cpc_h = rho_atom%cpc_h(ispin)%r_coef(ip, jp)
2028 cpc_s = rho_atom%cpc_s(ispin)%r_coef(ip, jp)
2033 tau_h(ia, ir, ispin) = tau_h(ia, ir, ispin) + 0.5_dp*cpc_h* &
2034 fgr(ir, 1)*fga(ia, 1)
2036 tau_s(ia, ir, ispin) = tau_s(ia, ir, ispin) + 0.5_dp*cpc_s* &
2037 fgr(ir, 1)*fga(ia, 1)
2045 fgr(1:nr, 1) = r1(1:nr, starti + iso)*r2(1:nr, startj + jso)
2047 fga(1:na, 1) = a1(1:na, starti + iso, dir)*a2(1:na, startj + jso, dir)
2049 DO ispin = 1, nspins
2051 cpc_h = rho_atom%cpc_h(ispin)%r_coef(ip, jp)
2052 cpc_s = rho_atom%cpc_s(ispin)%r_coef(ip, jp)
2057 tau_h(ia, ir, ispin) = tau_h(ia, ir, ispin) + 0.5_dp*cpc_h* &
2058 fgr(ir, 1)*fga(ia, 1)
2060 tau_s(ia, ir, ispin) = tau_s(ia, ir, ispin) + 0.5_dp*cpc_s* &
2061 fgr(ir, 1)*fga(ia, 1)
2069 fgr(1:nr, 1) = r2(1:nr, starti + iso)*r1(1:nr, startj + jso)
2071 fga(1:na, 1) = a2(1:na, starti + iso, dir)*a1(1:na, startj + jso, dir)
2073 DO ispin = 1, nspins
2075 cpc_h = rho_atom%cpc_h(ispin)%r_coef(ip, jp)
2076 cpc_s = rho_atom%cpc_s(ispin)%r_coef(ip, jp)
2081 tau_h(ia, ir, ispin) = tau_h(ia, ir, ispin) + 0.5_dp*cpc_h* &
2082 fgr(ir, 1)*fga(ia, 1)
2084 tau_s(ia, ir, ispin) = tau_s(ia, ir, ispin) + 0.5_dp*cpc_s* &
2085 fgr(ir, 1)*fga(ia, 1)
2093 fgr(1:nr, 1) = r2(1:nr, starti + iso)*r2(1:nr, startj + jso)
2095 fga(1:na, 1) = a2(1:na, starti + iso, dir)*a2(1:na, startj + jso, dir)
2097 DO ispin = 1, nspins
2099 cpc_h = rho_atom%cpc_h(ispin)%r_coef(ip, jp)
2100 cpc_s = rho_atom%cpc_s(ispin)%r_coef(ip, jp)
2105 tau_h(ia, ir, ispin) = tau_h(ia, ir, ispin) + 0.5_dp*cpc_h* &
2106 fgr(ir, 1)*fga(ia, 1)
2108 tau_s(ia, ir, ispin) = tau_s(ia, ir, ispin) + 0.5_dp*cpc_s* &
2109 fgr(ir, 1)*fga(ia, 1)
2124 DEALLOCATE (o2nindex)
2126 CALL timestop(handle)
2128 END SUBROUTINE calc_tau_atom
2143 SUBROUTINE calc_rho_nlcc(grid_atom, nspins, grad_func, &
2144 ir, rho_nlcc, rho_h, rho_s, drho_nlcc, drho_h, drho_s)
2147 INTEGER,
INTENT(IN) :: nspins
2148 LOGICAL,
INTENT(IN) :: grad_func
2149 INTEGER,
INTENT(IN) :: ir
2150 REAL(kind=
dp),
DIMENSION(:) :: rho_nlcc
2151 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: rho_h, rho_s
2152 REAL(kind=
dp),
DIMENSION(:) :: drho_nlcc
2153 REAL(kind=
dp),
DIMENSION(:, :, :, :),
POINTER :: drho_h, drho_s
2155 INTEGER :: ia, ispin, na
2156 REAL(kind=
dp) :: drho, dx, dy, dz, rad, rho, urad, xsp
2158 cpassert(
ASSOCIATED(rho_h))
2159 cpassert(
ASSOCIATED(rho_s))
2161 cpassert(
ASSOCIATED(drho_h))
2162 cpassert(
ASSOCIATED(drho_s))
2165 na = grid_atom%ng_sphere
2166 rad = grid_atom%rad(ir)
2167 urad = grid_atom%oorad2l(ir, 1)
2169 xsp = real(nspins, kind=
dp)
2170 rho = rho_nlcc(ir)/xsp
2171 DO ispin = 1, nspins
2172 rho_h(1:na, ir, ispin) = rho_h(1:na, ir, ispin) + rho
2173 rho_s(1:na, ir, ispin) = rho_s(1:na, ir, ispin) + rho
2177 drho = drho_nlcc(ir)/xsp
2178 DO ispin = 1, nspins
2180 IF (grid_atom%azi(ia) == 0.0_dp)
THEN
2184 dx = grid_atom%sin_pol(ia)*grid_atom%sin_azi(ia)
2185 dy = grid_atom%sin_pol(ia)*grid_atom%cos_azi(ia)
2187 dz = grid_atom%cos_pol(ia)
2189 drho_h(1, ia, ir, ispin) = drho_h(1, ia, ir, ispin) + drho*dx
2190 drho_h(2, ia, ir, ispin) = drho_h(2, ia, ir, ispin) + drho*dy
2191 drho_h(3, ia, ir, ispin) = drho_h(3, ia, ir, ispin) + drho*dz
2193 drho_s(1, ia, ir, ispin) = drho_s(1, ia, ir, ispin) + drho*dx
2194 drho_s(2, ia, ir, ispin) = drho_s(2, ia, ir, ispin) + drho*dy
2195 drho_s(3, ia, ir, ispin) = drho_s(3, ia, ir, ispin) + drho*dz
2197 drho_h(4, ia, ir, ispin) = sqrt( &
2198 drho_h(1, ia, ir, ispin)*drho_h(1, ia, ir, ispin) + &
2199 drho_h(2, ia, ir, ispin)*drho_h(2, ia, ir, ispin) + &
2200 drho_h(3, ia, ir, ispin)*drho_h(3, ia, ir, ispin))
2202 drho_s(4, ia, ir, ispin) = sqrt( &
2203 drho_s(1, ia, ir, ispin)*drho_s(1, ia, ir, ispin) + &
2204 drho_s(2, ia, ir, ispin)*drho_s(2, ia, ir, ispin) + &
2205 drho_s(3, ia, ir, ispin)*drho_s(3, ia, ir, ispin))
2210 END SUBROUTINE calc_rho_nlcc
2223 SUBROUTINE gavxcgb_nogc(vxc_h, vxc_s, int_hh, int_ss, grid_atom, basis_1c, harmonics, nspins)
2225 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: vxc_h, vxc_s
2230 INTEGER,
INTENT(IN) :: nspins
2232 CHARACTER(len=*),
PARAMETER :: routinen =
'gaVxcgb_noGC'
2234 INTEGER :: handle, ia, ic, icg, ipgf1, ipgf2, ir, iset1, iset2, iso, iso1, iso2, ispin, l, &
2235 ld, lmax12, lmax_expansion, lmin12, m1, m2, max_iso_not0, max_iso_not0_local, max_s_harm, &
2236 maxl, maxso, n1, n2, na, ngau1, ngau2, nngau1, nr, nset, size1
2237 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: cg_n_list
2238 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: cg_list
2239 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf
2240 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: g1, g2
2241 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: gg, gvg_h, gvg_s, matso_h, matso_s, vx
2242 REAL(
dp),
DIMENSION(:, :),
POINTER :: zet
2243 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: my_cg
2245 CALL timeset(routinen, handle)
2247 NULLIFY (lmin, lmax, npgf, zet, my_cg)
2250 maxso=maxso, maxl=maxl, npgf=npgf, &
2254 na = grid_atom%ng_sphere
2255 my_cg => harmonics%my_CG
2256 max_iso_not0 = harmonics%max_iso_not0
2257 lmax_expansion =
indso(1, max_iso_not0)
2258 max_s_harm = harmonics%max_s_harm
2260 ALLOCATE (g1(nr), g2(nr), gg(nr, 0:2*maxl))
2261 ALLOCATE (gvg_h(na, 0:2*maxl), gvg_s(na, 0:2*maxl))
2264 ALLOCATE (vx(na, nr))
2265 ALLOCATE (cg_list(2,
nsoset(maxl)**2, max_s_harm), cg_n_list(max_s_harm))
2274 CALL get_none0_cg_list(my_cg, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
2275 max_s_harm, lmax_expansion, cg_list, cg_n_list, max_iso_not0_local)
2276 cpassert(max_iso_not0_local .LE. max_iso_not0)
2279 DO ipgf1 = 1, npgf(iset1)
2280 ngau1 = n1*(ipgf1 - 1) + m1
2282 nngau1 =
nsoset(lmin(iset1) - 1) + ngau1
2284 g1(1:nr) = exp(-zet(ipgf1, iset1)*grid_atom%rad2(1:nr))
2285 DO ipgf2 = 1, npgf(iset2)
2286 ngau2 = n2*(ipgf2 - 1) + m2
2288 g2(1:nr) = exp(-zet(ipgf2, iset2)*grid_atom%rad2(1:nr))
2289 lmin12 = lmin(iset1) + lmin(iset2)
2290 lmax12 = lmax(iset1) + lmax(iset2)
2293 IF (lmin12 .LE. lmax_expansion)
THEN
2296 IF (lmin12 == 0)
THEN
2297 gg(1:nr, lmin12) = g1(1:nr)*g2(1:nr)
2299 gg(1:nr, lmin12) = grid_atom%rad2l(1:nr, lmin12)*g1(1:nr)*g2(1:nr)
2303 IF (lmax12 .GT. lmax_expansion) lmax12 = lmax_expansion
2305 DO l = lmin12 + 1, lmax12
2306 gg(1:nr, l) = grid_atom%rad(1:nr)*gg(:, l - 1)
2309 DO ispin = 1, nspins
2312 vx(1:na, ir) = vxc_h(1:na, ir, ispin)
2314 CALL dgemm(
'N',
'N', na, ld, nr, 1.0_dp, vx(1:na, 1:nr), na, &
2315 gg(1:nr, 0:lmax12), nr, 0.0_dp, gvg_h(1:na, 0:lmax12), na)
2317 vx(1:na, ir) = vxc_s(1:na, ir, ispin)
2319 CALL dgemm(
'N',
'N', na, ld, nr, 1.0_dp, vx(1:na, 1:nr), na, &
2320 gg(1:nr, 0:lmax12), nr, 0.0_dp, gvg_s(1:na, 0:lmax12), na)
2324 DO iso = 1, max_iso_not0_local
2325 DO icg = 1, cg_n_list(iso)
2326 iso1 = cg_list(1, icg, iso)
2327 iso2 = cg_list(2, icg, iso)
2330 cpassert(l <= lmax_expansion)
2332 matso_h(iso1, iso2) = matso_h(iso1, iso2) + &
2334 my_cg(iso1, iso2, iso)* &
2335 harmonics%slm(ia, iso)
2336 matso_s(iso1, iso2) = matso_s(iso1, iso2) + &
2338 my_cg(iso1, iso2, iso)* &
2339 harmonics%slm(ia, iso)
2345 DO ic =
nsoset(lmin(iset2) - 1) + 1,
nsoset(lmax(iset2))
2346 iso1 =
nsoset(lmin(iset1) - 1) + 1
2348 CALL daxpy(size1, 1.0_dp, matso_h(iso1, ic), 1, &
2349 int_hh(ispin)%r_coef(nngau1 + 1, iso2), 1)
2350 CALL daxpy(size1, 1.0_dp, matso_s(iso1, ic), 1, &
2351 int_ss(ispin)%r_coef(nngau1 + 1, iso2), 1)
2365 DEALLOCATE (g1, g2, gg, matso_h, matso_s, gvg_s, gvg_h, vx)
2367 DEALLOCATE (cg_list, cg_n_list)
2369 CALL timestop(handle)
2386 SUBROUTINE gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, &
2387 grid_atom, basis_1c, harmonics, nspins)
2389 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: vxc_h, vxc_s
2390 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: vxg_h, vxg_s
2395 INTEGER,
INTENT(IN) :: nspins
2397 CHARACTER(len=*),
PARAMETER :: routinen =
'gaVxcgb_GC'
2399 INTEGER :: dmax_iso_not0_local, handle, ia, ic, icg, ipgf1, ipgf2, ir, iset1, iset2, iso, &
2400 iso1, iso2, ispin, l, lmax12, lmax_expansion, lmin12, m1, m2, max_iso_not0, &
2401 max_iso_not0_local, max_s_harm, maxl, maxso, n1, n2, na, ngau1, ngau2, nngau1, nr, nset, &
2403 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: cg_n_list, dcg_n_list
2404 INTEGER,
ALLOCATABLE,
DIMENSION(:, :, :) :: cg_list, dcg_list
2405 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf
2407 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: g1, g2
2408 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: dgg, gg, gvxcg_h, gvxcg_s, matso_h, &
2410 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: gvxgg_h, gvxgg_s
2411 REAL(
dp),
DIMENSION(:, :),
POINTER :: zet
2412 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: my_cg
2413 REAL(
dp),
DIMENSION(:, :, :, :),
POINTER :: my_cg_dxyz
2415 CALL timeset(routinen, handle)
2417 NULLIFY (lmin, lmax, npgf, zet, my_cg, my_cg_dxyz)
2420 maxso=maxso, maxl=maxl, npgf=npgf, &
2424 na = grid_atom%ng_sphere
2425 my_cg => harmonics%my_CG
2426 my_cg_dxyz => harmonics%my_CG_dxyz
2427 max_iso_not0 = harmonics%max_iso_not0
2428 lmax_expansion =
indso(1, max_iso_not0)
2429 max_s_harm = harmonics%max_s_harm
2431 ALLOCATE (g1(nr), g2(nr), gg(nr, 0:2*maxl), dgg(nr, 0:2*maxl))
2432 ALLOCATE (gvxcg_h(na, 0:2*maxl), gvxcg_s(na, 0:2*maxl))
2433 ALLOCATE (gvxgg_h(3, na, 0:2*maxl), gvxgg_s(3, na, 0:2*maxl))
2434 ALLOCATE (cg_list(2,
nsoset(maxl)**2, max_s_harm), cg_n_list(max_s_harm), &
2435 dcg_list(2,
nsoset(maxl)**2, max_s_harm), dcg_n_list(max_s_harm))
2440 DO ispin = 1, nspins
2449 CALL get_none0_cg_list(my_cg, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
2450 max_s_harm, lmax_expansion, cg_list, cg_n_list, max_iso_not0_local)
2451 cpassert(max_iso_not0_local .LE. max_iso_not0)
2452 CALL get_none0_cg_list(my_cg_dxyz, lmin(iset1), lmax(iset1), lmin(iset2), lmax(iset2), &
2453 max_s_harm, lmax_expansion, dcg_list, dcg_n_list, dmax_iso_not0_local)
2456 DO ipgf1 = 1, npgf(iset1)
2457 ngau1 = n1*(ipgf1 - 1) + m1
2459 nngau1 =
nsoset(lmin(iset1) - 1) + ngau1
2461 g1(1:nr) = exp(-zet(ipgf1, iset1)*grid_atom%rad2(1:nr))
2462 DO ipgf2 = 1, npgf(iset2)
2463 ngau2 = n2*(ipgf2 - 1) + m2
2465 g2(1:nr) = exp(-zet(ipgf2, iset2)*grid_atom%rad2(1:nr))
2466 lmin12 = lmin(iset1) + lmin(iset2)
2467 lmax12 = lmax(iset1) + lmax(iset2)
2470 IF (lmin12 .LE. lmax_expansion)
THEN
2475 IF (lmin12 == 0)
THEN
2476 gg(1:nr, lmin12) = g1(1:nr)*g2(1:nr)
2478 gg(1:nr, lmin12) = grid_atom%rad2l(1:nr, lmin12)*g1(1:nr)*g2(1:nr)
2482 IF (lmax12 .GT. lmax_expansion) lmax12 = lmax_expansion
2484 DO l = lmin12 + 1, lmax12
2485 gg(1:nr, l) = grid_atom%rad(1:nr)*gg(:, l - 1)
2486 dgg(1:nr, l - 1) = dgg(1:nr, l - 1) - 2.0_dp*(zet(ipgf1, iset1) + &
2487 zet(ipgf2, iset2))*gg(1:nr, l)
2489 dgg(1:nr, lmax12) = dgg(1:nr, lmax12) - 2.0_dp*(zet(ipgf1, iset1) + &
2490 zet(ipgf2, iset2))*grid_atom%rad(1:nr)* &
2499 DO l = lmin12, lmax12
2502 gvxcg_h(ia, l) = gvxcg_h(ia, l) + &
2503 gg(ir, l)*vxc_h(ia, ir, ispin) + &
2505 (vxg_h(1, ia, ir, ispin)*harmonics%a(1, ia) + &
2506 vxg_h(2, ia, ir, ispin)*harmonics%a(2, ia) + &
2507 vxg_h(3, ia, ir, ispin)*harmonics%a(3, ia))
2509 gvxcg_s(ia, l) = gvxcg_s(ia, l) + &
2510 gg(ir, l)*vxc_s(ia, ir, ispin) + &
2512 (vxg_s(1, ia, ir, ispin)*harmonics%a(1, ia) + &
2513 vxg_s(2, ia, ir, ispin)*harmonics%a(2, ia) + &
2514 vxg_s(3, ia, ir, ispin)*harmonics%a(3, ia))
2516 urad = grid_atom%oorad2l(ir, 1)
2518 gvxgg_h(1, ia, l) = gvxgg_h(1, ia, l) + &
2519 vxg_h(1, ia, ir, ispin)* &
2522 gvxgg_h(2, ia, l) = gvxgg_h(2, ia, l) + &
2523 vxg_h(2, ia, ir, ispin)* &
2526 gvxgg_h(3, ia, l) = gvxgg_h(3, ia, l) + &
2527 vxg_h(3, ia, ir, ispin)* &
2530 gvxgg_s(1, ia, l) = gvxgg_s(1, ia, l) + &
2531 vxg_s(1, ia, ir, ispin)* &
2534 gvxgg_s(2, ia, l) = gvxgg_s(2, ia, l) + &
2535 vxg_s(2, ia, ir, ispin)* &
2538 gvxgg_s(3, ia, l) = gvxgg_s(3, ia, l) + &
2539 vxg_s(3, ia, ir, ispin)* &
2548 DO iso = 1, max_iso_not0_local
2549 DO icg = 1, cg_n_list(iso)
2550 iso1 = cg_list(1, icg, iso)
2551 iso2 = cg_list(2, icg, iso)
2556 cpassert(l <= lmax_expansion)
2558 matso_h(iso1, iso2) = matso_h(iso1, iso2) + &
2560 harmonics%slm(ia, iso)* &
2561 my_cg(iso1, iso2, iso)
2562 matso_s(iso1, iso2) = matso_s(iso1, iso2) + &
2564 harmonics%slm(ia, iso)* &
2565 my_cg(iso1, iso2, iso)
2574 DO iso = 1, dmax_iso_not0_local
2575 DO icg = 1, dcg_n_list(iso)
2576 iso1 = dcg_list(1, icg, iso)
2577 iso2 = dcg_list(2, icg, iso)
2581 cpassert(l <= lmax_expansion)
2583 matso_h(iso1, iso2) = matso_h(iso1, iso2) + &
2584 (gvxgg_h(1, ia, l)*my_cg_dxyz(1, iso1, iso2, iso) + &
2585 gvxgg_h(2, ia, l)*my_cg_dxyz(2, iso1, iso2, iso) + &
2586 gvxgg_h(3, ia, l)*my_cg_dxyz(3, iso1, iso2, iso))* &
2587 harmonics%slm(ia, iso)
2589 matso_s(iso1, iso2) = matso_s(iso1, iso2) + &
2590 (gvxgg_s(1, ia, l)*my_cg_dxyz(1, iso1, iso2, iso) + &
2591 gvxgg_s(2, ia, l)*my_cg_dxyz(2, iso1, iso2, iso) + &
2592 gvxgg_s(3, ia, l)*my_cg_dxyz(3, iso1, iso2, iso))* &
2593 harmonics%slm(ia, iso)
2605 DO ic =
nsoset(lmin(iset2) - 1) + 1,
nsoset(lmax(iset2))
2606 iso1 =
nsoset(lmin(iset1) - 1) + 1
2608 CALL daxpy(size1, 1.0_dp, matso_h(iso1, ic), 1, &
2609 int_hh(ispin)%r_coef(nngau1 + 1, iso2), 1)
2610 CALL daxpy(size1, 1.0_dp, matso_s(iso1, ic), 1, &
2611 int_ss(ispin)%r_coef(nngau1 + 1, iso2), 1)
2622 DEALLOCATE (g1, g2, gg, dgg, matso_h, matso_s, gvxcg_h, gvxcg_s, gvxgg_h, gvxgg_s)
2623 DEALLOCATE (cg_list, cg_n_list, dcg_list, dcg_n_list)
2625 CALL timestop(handle)
2627 END SUBROUTINE gavxcgb_gc
2642 SUBROUTINE dgavtaudgb(vtau_h, vtau_s, int_hh, int_ss, &
2643 grid_atom, basis_1c, harmonics, nspins)
2645 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: vtau_h, vtau_s
2650 INTEGER,
INTENT(IN) :: nspins
2652 CHARACTER(len=*),
PARAMETER :: routinen =
'dgaVtaudgb'
2654 INTEGER :: dir, handle, ipgf, iset, iso, ispin, &
2655 jpgf, jset, jso, l, maxso, na, nr, &
2656 nset, starti, startj
2657 INTEGER,
DIMENSION(:),
POINTER :: lmax, lmin, npgf
2658 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: fga, fgr, r1, r2, work
2659 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: a1, a2, intso_h, intso_s
2660 REAL(
dp),
DIMENSION(:, :),
POINTER :: slm, zet
2661 REAL(
dp),
DIMENSION(:, :, :),
POINTER :: dslm_dxyz
2663 CALL timeset(routinen, handle)
2665 NULLIFY (zet, slm, dslm_dxyz, lmax, lmin, npgf)
2668 maxso=maxso, npgf=npgf, nset=nset, zet=zet)
2670 na = grid_atom%ng_sphere
2673 slm => harmonics%slm
2674 dslm_dxyz => harmonics%dslm_dxyz
2678 ALLOCATE (a1(na, nset*maxso, 3), a2(na, nset*maxso, 3))
2679 ALLOCATE (r1(nr, nset*maxso), r2(nr, nset*maxso))
2680 a1 = 0.0_dp; a2 = 0.0_dp
2681 r1 = 0.0_dp; r2 = 0.0_dp
2684 DO ipgf = 1, npgf(iset)
2685 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
2686 DO iso =
nsoset(lmin(iset) - 1) + 1,
nsoset(lmax(iset))
2693 r1(1:nr, starti + iso) = grid_atom%rad(1:nr)**(l - 1)*exp(-zet(ipgf, iset)*grid_atom%rad2(1:nr))
2696 r2(1:nr, starti + iso) = -2.0_dp*zet(ipgf, iset)*grid_atom%rad(1:nr)**(l + 1) &
2697 *exp(-zet(ipgf, iset)*grid_atom%rad2(1:nr))
2701 a1(1:na, starti + iso, dir) = dslm_dxyz(dir, 1:na, iso)
2704 a2(1:na, starti + iso, dir) = harmonics%a(dir, 1:na)*slm(1:na, iso)
2712 ALLOCATE (intso_h(nset*maxso, nset*maxso, nspins))
2713 ALLOCATE (intso_s(nset*maxso, nset*maxso, nspins))
2714 intso_h = 0.0_dp; intso_s = 0.0_dp
2716 ALLOCATE (fga(na, 1))
2717 ALLOCATE (fgr(nr, 1))
2718 ALLOCATE (work(na, 1))
2719 fga = 0.0_dp; fgr = 0.0_dp; work = 0.0_dp
2723 DO ipgf = 1, npgf(iset)
2724 starti = (iset - 1)*maxso + (ipgf - 1)*
nsoset(lmax(iset))
2725 DO jpgf = 1, npgf(jset)
2726 startj = (jset - 1)*maxso + (jpgf - 1)*
nsoset(lmax(jset))
2728 DO iso =
nsoset(lmin(iset) - 1) + 1,
nsoset(lmax(iset))
2729 DO jso =
nsoset(lmin(jset) - 1) + 1,
nsoset(lmax(jset))
2734 fgr(1:nr, 1) = r1(1:nr, starti + iso)*r1(1:nr, startj + jso)
2736 fga(1:na, 1) = a1(1:na, starti + iso, dir)*a1(1:na, startj + jso, dir)
2738 DO ispin = 1, nspins
2739 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_h(:, :, ispin), na, fgr, &
2740 nr, 0.0_dp, work, na)
2741 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2742 intso_h(starti + iso:, startj + jso, ispin), 1)
2744 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_s(:, :, ispin), na, fgr, &
2745 nr, 0.0_dp, work, na)
2746 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2747 intso_s(starti + iso:, startj + jso, ispin), 1)
2752 fgr(1:nr, 1) = r1(1:nr, starti + iso)*r2(1:nr, startj + jso)
2754 fga(1:na, 1) = a1(1:na, starti + iso, dir)*a2(1:na, startj + jso, dir)
2756 DO ispin = 1, nspins
2757 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_h(:, :, ispin), na, fgr, &
2758 nr, 0.0_dp, work, na)
2759 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2760 intso_h(starti + iso:, startj + jso, ispin), 1)
2762 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_s(:, :, ispin), na, fgr, &
2763 nr, 0.0_dp, work, na)
2764 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2765 intso_s(starti + iso:, startj + jso, ispin), 1)
2770 fgr(1:nr, 1) = r2(1:nr, starti + iso)*r1(1:nr, startj + jso)
2772 fga(1:na, 1) = a2(1:na, starti + iso, dir)*a1(1:na, startj + jso, dir)
2774 DO ispin = 1, nspins
2775 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_h(:, :, ispin), na, fgr, &
2776 nr, 0.0_dp, work, na)
2777 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2778 intso_h(starti + iso:, startj + jso, ispin), 1)
2780 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_s(:, :, ispin), na, fgr, &
2781 nr, 0.0_dp, work, na)
2782 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2783 intso_s(starti + iso:, startj + jso, ispin), 1)
2788 fgr(1:nr, 1) = r2(1:nr, starti + iso)*r2(1:nr, startj + jso)
2790 fga(1:na, 1) = a2(1:na, starti + iso, dir)*a2(1:na, startj + jso, dir)
2792 DO ispin = 1, nspins
2793 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_h(:, :, ispin), na, fgr, &
2794 nr, 0.0_dp, work, na)
2795 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2796 intso_h(starti + iso:, startj + jso, ispin), 1)
2798 CALL dgemm(
'N',
'N', na, 1, nr, 0.5_dp, vtau_s(:, :, ispin), na, fgr, &
2799 nr, 0.0_dp, work, na)
2800 CALL dgemm(
'T',
'N', 1, 1, na, 1.0_dp, work, na, fga, na, 1.0_dp, &
2801 intso_s(starti + iso:, startj + jso, ispin), 1)
2814 DO ispin = 1, nspins
2815 int_hh(ispin)%r_coef(:, :) = int_hh(ispin)%r_coef(:, :) + intso_h(:, :, ispin)
2816 int_ss(ispin)%r_coef(:, :) = int_ss(ispin)%r_coef(:, :) + intso_s(:, :, ispin)
2819 CALL timestop(handle)
2821 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, 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, 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.
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, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
logical function, public has_nlcc(qs_kind_set)
finds if a given qs run needs to use nlcc
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