LCOV - code coverage report
Current view: top level - src - qs_fxc_atom.F (source / functions) Coverage Total Hit
Test: CP2K Regtests (git:24d69ee) Lines: 92.1 % 190 175
Test Date: 2026-09-03 07:32:15 Functions: 100.0 % 1 1

            Line data    Source code
       1              : !--------------------------------------------------------------------------------------------------!
       2              : !   CP2K: A general program to perform molecular dynamics simulations                              !
       3              : !   Copyright 2000-2026 CP2K developers group <https://cp2k.org>                                   !
       4              : !                                                                                                  !
       5              : !   SPDX-License-Identifier: GPL-2.0-or-later                                                      !
       6              : !--------------------------------------------------------------------------------------------------!
       7              : 
       8              : ! **************************************************************************************************
       9              : !> \brief routines that build the integrals of the Fxc kernel calculated
      10              : !>      for the atomic density in the basis set of spherical primitives
      11              : ! **************************************************************************************************
      12              : MODULE qs_fxc_atom
      13              :    USE atomic_kind_types,               ONLY: atomic_kind_type,&
      14              :                                               get_atomic_kind
      15              :    USE basis_set_types,                 ONLY: gto_basis_set_type
      16              :    USE cp_control_types,                ONLY: dft_control_type
      17              :    USE input_section_types,             ONLY: section_vals_get_subs_vals,&
      18              :                                               section_vals_type,&
      19              :                                               section_vals_val_get
      20              :    USE kinds,                           ONLY: dp
      21              :    USE message_passing,                 ONLY: mp_para_env_type
      22              :    USE qs_environment_types,            ONLY: get_qs_env,&
      23              :                                               qs_environment_type
      24              :    USE qs_grid_atom,                    ONLY: grid_atom_type
      25              :    USE qs_harmonics_atom,               ONLY: harmonics_atom_type
      26              :    USE qs_kind_types,                   ONLY: get_qs_kind,&
      27              :                                               has_nlcc,&
      28              :                                               qs_kind_type
      29              :    USE qs_rho_atom_types,               ONLY: get_rho_atom,&
      30              :                                               rho_atom_coeff,&
      31              :                                               rho_atom_type
      32              :    USE qs_vxc_atom_utils,               ONLY: &
      33              :         calc_rho_angular, calc_rho_nlcc, calc_tau_atom, create_tau_basis_cache, dgaVtaudgb, &
      34              :         gaVxcgb_GC, gaVxcgb_noGC, release_tau_basis_cache, tau_basis_cache_type
      35              :    USE util,                            ONLY: get_limit
      36              :    USE xc_atom,                         ONLY: fill_rho_set,&
      37              :                                               xc_2nd_deriv_of_r,&
      38              :                                               xc_rho_set_atom_update
      39              :    USE xc_derivative_set_types,         ONLY: xc_derivative_set_type,&
      40              :                                               xc_dset_create,&
      41              :                                               xc_dset_release
      42              :    USE xc_derivatives,                  ONLY: xc_functionals_get_needs
      43              :    USE xc_rho_cflags_types,             ONLY: xc_rho_cflags_type
      44              :    USE xc_rho_set_types,                ONLY: xc_rho_set_create,&
      45              :                                               xc_rho_set_release,&
      46              :                                               xc_rho_set_type
      47              : #include "./base/base_uses.f90"
      48              : 
      49              :    IMPLICIT NONE
      50              : 
      51              :    PRIVATE
      52              : 
      53              :    CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'qs_fxc_atom'
      54              : 
      55              :    PUBLIC :: fxc_atom_calc
      56              : 
      57              : ! **************************************************************************************************
      58              : 
      59              : CONTAINS
      60              : 
      61              : ! **************************************************************************************************
      62              : !> \brief ...
      63              : !> \param qs_env ...
      64              : !> \param rho_atom_set ...
      65              : !> \param rho1_atom_set ...
      66              : !> \param xc_section ...
      67              : !> \param para_env_ext ...
      68              : !> \param do_scale ...
      69              : !> \param do_triplet ...
      70              : !> \param do_sf ...
      71              : !> \param kind_set_external ...
      72              : ! **************************************************************************************************
      73         6234 :    SUBROUTINE fxc_atom_calc(qs_env, rho_atom_set, rho1_atom_set, xc_section, para_env_ext, &
      74              :                             do_scale, do_triplet, do_sf, kind_set_external)
      75              : 
      76              :       TYPE(qs_environment_type), POINTER                 :: qs_env
      77              :       TYPE(rho_atom_type), DIMENSION(:), POINTER         :: rho_atom_set, rho1_atom_set
      78              :       TYPE(section_vals_type), POINTER                   :: xc_section
      79              :       TYPE(mp_para_env_type), INTENT(IN), OPTIONAL       :: para_env_ext
      80              :       LOGICAL, INTENT(IN), OPTIONAL                      :: do_scale, do_triplet, do_sf
      81              :       TYPE(qs_kind_type), DIMENSION(:), OPTIONAL, &
      82              :          POINTER                                         :: kind_set_external
      83              : 
      84              :       CHARACTER(LEN=*), PARAMETER                        :: routineN = 'fxc_atom_calc'
      85              : 
      86              :       INTEGER                                            :: atom, handle, iatom, ikind, ir, na, &
      87              :                                                             natom, nr, nspins
      88              :       INTEGER, DIMENSION(2)                              :: local_loop_limit
      89              :       INTEGER, DIMENSION(2, 3)                           :: bounds
      90         6234 :       INTEGER, DIMENSION(:), POINTER                     :: atom_list
      91              :       LOGICAL                                            :: accint, donlcc, gradient_functional, &
      92              :                                                             lsd, my_do_sf, nlcc, paw_atom, &
      93              :                                                             scale_rho, tau_f
      94              :       REAL(KIND=dp)                                      :: agr, alpha, density_cut, gradient_cut, &
      95              :                                                             rtot, tau_cut
      96              :       REAL(KIND=dp), CONTIGUOUS, DIMENSION(:, :, :), &
      97         6234 :          POINTER                                         :: vtau_h, vtau_s, vxc_h, vxc_s
      98              :       REAL(KIND=dp), DIMENSION(1, 1, 1)                  :: rtau
      99              :       REAL(KIND=dp), DIMENSION(1, 1, 1, 1)               :: rrho
     100        12468 :       REAL(KIND=dp), DIMENSION(:, :), POINTER            :: rho_nlcc, weight_h, weight_s
     101        18702 :       REAL(KIND=dp), DIMENSION(:, :, :), POINTER         :: rho1_h, rho1_s, rho_h, rho_s, tau1_h, &
     102         6234 :                                                             tau1_s, tau_h, tau_s
     103        12468 :       REAL(KIND=dp), DIMENSION(:, :, :, :), POINTER      :: drho1_h, drho1_s, drho_h, drho_s, vxg_h, &
     104         6234 :                                                             vxg_s
     105         6234 :       TYPE(atomic_kind_type), DIMENSION(:), POINTER      :: atomic_kind_set
     106              :       TYPE(dft_control_type), POINTER                    :: dft_control
     107              :       TYPE(grid_atom_type), POINTER                      :: grid_atom
     108              :       TYPE(gto_basis_set_type), POINTER                  :: basis_1c
     109              :       TYPE(harmonics_atom_type), POINTER                 :: harmonics
     110              :       TYPE(mp_para_env_type), POINTER                    :: para_env
     111         6234 :       TYPE(qs_kind_type), DIMENSION(:), POINTER          :: my_kind_set, qs_kind_set
     112         6234 :       TYPE(rho_atom_coeff), DIMENSION(:), POINTER        :: dr1_h, dr1_s, dr_h, dr_s, int_hh, &
     113         6234 :                                                             int_ss, r1_h, r1_s, r_h, r_s
     114         6234 :       TYPE(rho_atom_coeff), DIMENSION(:, :), POINTER     :: r1_h_d, r1_s_d, r_h_d, r_s_d
     115              :       TYPE(rho_atom_type), POINTER                       :: rho1_atom, rho_atom
     116              :       TYPE(section_vals_type), POINTER                   :: input, xc_fun_section
     117         6234 :       TYPE(tau_basis_cache_type)                         :: tau_basis_cache
     118              :       TYPE(xc_derivative_set_type)                       :: deriv_set
     119              :       TYPE(xc_rho_cflags_type)                           :: needs
     120              :       TYPE(xc_rho_set_type)                              :: rho1_set_h, rho1_set_s, rho_set_h, &
     121              :                                                             rho_set_s
     122              : 
     123              : ! -------------------------------------------------------------------------
     124              : 
     125         6234 :       CALL timeset(routineN, handle)
     126              : 
     127         6234 :       NULLIFY (qs_kind_set)
     128         6234 :       NULLIFY (rho_h, rho_s, drho_h, drho_s, weight_h, weight_s)
     129         6234 :       NULLIFY (rho1_h, rho1_s, drho1_h, drho1_s)
     130         6234 :       NULLIFY (vxc_h, vxc_s, vxg_h, vxg_s)
     131         6234 :       NULLIFY (tau_h, tau_s, tau1_h, tau1_s, vtau_h, vtau_s)
     132         6234 :       NULLIFY (rho_nlcc)
     133              : 
     134              :       CALL get_qs_env(qs_env=qs_env, &
     135              :                       input=input, &
     136              :                       dft_control=dft_control, &
     137              :                       para_env=para_env, &
     138              :                       qs_kind_set=qs_kind_set, &
     139         6234 :                       atomic_kind_set=atomic_kind_set)
     140              : 
     141         6234 :       IF (PRESENT(kind_set_external)) THEN
     142          726 :          my_kind_set => kind_set_external
     143              :       ELSE
     144         5508 :          my_kind_set => qs_kind_set
     145              :       END IF
     146         6234 :       nlcc = has_nlcc(my_kind_set)
     147              : 
     148         6234 :       accint = dft_control%qs_control%gapw_control%accurate_xcint
     149              : 
     150         6234 :       CALL section_vals_val_get(input, "DFT%LSD", l_val=lsd)
     151              :       CALL section_vals_val_get(xc_section, "DENSITY_CUTOFF", &
     152         6234 :                                 r_val=density_cut)
     153              :       CALL section_vals_val_get(xc_section, "GRADIENT_CUTOFF", &
     154         6234 :                                 r_val=gradient_cut)
     155              :       CALL section_vals_val_get(xc_section, "TAU_CUTOFF", &
     156         6234 :                                 r_val=tau_cut)
     157              : 
     158         6234 :       my_do_sf = .FALSE.
     159         6234 :       IF (PRESENT(do_sf)) my_do_sf = do_sf
     160              : 
     161              :       xc_fun_section => section_vals_get_subs_vals(xc_section, &
     162         6234 :                                                    "XC_FUNCTIONAL")
     163         6234 :       IF (lsd) THEN
     164          190 :          nspins = 2
     165              :       ELSE
     166         6044 :          nspins = 1
     167              :       END IF
     168              : 
     169         6234 :       scale_rho = .FALSE.
     170         6234 :       IF (PRESENT(do_scale)) THEN
     171         2864 :          IF (do_scale) THEN
     172              :             ! obscure scaling needed for (some) triplet densities
     173          310 :             scale_rho = .TRUE.
     174          310 :             CPASSERT(PRESENT(do_triplet))
     175          310 :             CPASSERT(do_triplet)
     176          310 :             CPASSERT(nspins == 1)
     177              :          END IF
     178              :       END IF
     179         6234 :       IF (PRESENT(do_triplet)) THEN
     180         2978 :          IF (nspins == 1 .AND. do_triplet) lsd = .TRUE.
     181              :       END IF
     182              : 
     183              :       needs = xc_functionals_get_needs(xc_fun_section, lsd=lsd, &
     184         6234 :                                        calc_potential=.TRUE.)
     185         6234 :       gradient_functional = needs%drho .OR. needs%drho_spin
     186         6234 :       tau_f = (needs%tau .OR. needs%tau_spin)
     187         6234 :       IF (.NOT. tau_f) rtau = 0.0_dp
     188              : 
     189              :       !  Here starts the loop over all the atoms
     190        19836 :       DO ikind = 1, SIZE(atomic_kind_set)
     191              : 
     192        13602 :          NULLIFY (atom_list, harmonics, grid_atom)
     193        13602 :          CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
     194              :          CALL get_qs_kind(my_kind_set(ikind), paw_atom=paw_atom, &
     195        13602 :                           harmonics=harmonics, grid_atom=grid_atom)
     196        13602 :          CALL get_qs_kind(my_kind_set(ikind), basis_set=basis_1c, basis_type="GAPW_1C")
     197        13602 :          IF (.NOT. paw_atom) CYCLE
     198              : 
     199        12784 :          nr = grid_atom%nr
     200        12784 :          na = grid_atom%ng_sphere
     201              : 
     202              :          ! set integration weights
     203        12784 :          IF (accint) THEN
     204         4908 :             weight_h => grid_atom%weight
     205         4908 :             alpha = dft_control%qs_control%gapw_control%aw(ikind)
     206         4908 :             IF (ASSOCIATED(grid_atom%gapw_weight_s)) THEN
     207         4904 :                IF (grid_atom%gapw_weight_alpha /= alpha) DEALLOCATE (grid_atom%gapw_weight_s)
     208              :             END IF
     209         4908 :             IF (.NOT. ASSOCIATED(grid_atom%gapw_weight_s)) THEN
     210           16 :                ALLOCATE (grid_atom%gapw_weight_s(na, nr))
     211          204 :                DO ir = 1, nr
     212          200 :                   agr = 1.0_dp - EXP(-alpha*grid_atom%rad2(ir))
     213        10204 :                   grid_atom%gapw_weight_s(:, ir) = grid_atom%weight(:, ir)*agr
     214              :                END DO
     215            4 :                grid_atom%gapw_weight_alpha = alpha
     216              :             END IF
     217         4908 :             weight_s => grid_atom%gapw_weight_s
     218              :          ELSE
     219         7876 :             weight_h => grid_atom%weight
     220         7876 :             weight_s => grid_atom%weight
     221              :          END IF
     222              : 
     223              :          ! Array dimension: here only one dimensional arrays are used,
     224              :          ! i.e. only the first column of deriv_data is read.
     225              :          ! The other two dimensions are set to size equal 1.
     226       127840 :          bounds(1:2, 1:3) = 1
     227        12784 :          bounds(2, 1) = na
     228        12784 :          bounds(2, 2) = nr
     229              : 
     230        12784 :          CALL xc_dset_create(deriv_set, local_bounds=bounds)
     231              :          CALL xc_rho_set_create(rho_set_h, bounds, rho_cutoff=density_cut, &
     232        12784 :                                 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
     233              :          CALL xc_rho_set_create(rho_set_s, bounds, rho_cutoff=density_cut, &
     234        12784 :                                 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
     235              :          CALL xc_rho_set_create(rho1_set_h, bounds, rho_cutoff=density_cut, &
     236        12784 :                                 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
     237              :          CALL xc_rho_set_create(rho1_set_s, bounds, rho_cutoff=density_cut, &
     238        12784 :                                 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
     239              : 
     240              :          ! allocate the required 3d arrays where to store rho and drho
     241        12784 :          IF (nspins == 1 .AND. .NOT. lsd) THEN
     242        11922 :             CALL xc_rho_set_atom_update(rho_set_h, needs, 1, bounds)
     243        11922 :             CALL xc_rho_set_atom_update(rho1_set_h, needs, 1, bounds)
     244        11922 :             CALL xc_rho_set_atom_update(rho_set_s, needs, 1, bounds)
     245        11922 :             CALL xc_rho_set_atom_update(rho1_set_s, needs, 1, bounds)
     246              :          ELSE
     247          862 :             CALL xc_rho_set_atom_update(rho_set_h, needs, 2, bounds)
     248          862 :             CALL xc_rho_set_atom_update(rho1_set_h, needs, 2, bounds)
     249          862 :             CALL xc_rho_set_atom_update(rho_set_s, needs, 2, bounds)
     250          862 :             CALL xc_rho_set_atom_update(rho1_set_s, needs, 2, bounds)
     251              :          END IF
     252              : 
     253              :          ALLOCATE (rho_h(1:na, 1:nr, 1:nspins), rho1_h(1:na, 1:nr, 1:nspins), &
     254       178976 :                    rho_s(1:na, 1:nr, 1:nspins), rho1_s(1:na, 1:nr, 1:nspins))
     255              : 
     256        89488 :          ALLOCATE (vxc_h(1:na, 1:nr, 1:nspins), vxc_s(1:na, 1:nr, 1:nspins))
     257        12784 :          vxc_h = 0.0_dp
     258        12784 :          vxc_s = 0.0_dp
     259              : 
     260        12784 :          IF (tau_f) THEN
     261            0 :             CALL create_tau_basis_cache(tau_basis_cache, grid_atom, basis_1c, harmonics)
     262              :             ALLOCATE (tau_h(1:na, 1:nr, 1:nspins), tau1_h(1:na, 1:nr, 1:nspins), &
     263            0 :                       tau_s(1:na, 1:nr, 1:nspins), tau1_s(1:na, 1:nr, 1:nspins))
     264            0 :             ALLOCATE (vtau_h(1:na, 1:nr, 1:nspins), vtau_s(1:na, 1:nr, 1:nspins))
     265              :          END IF
     266              : 
     267        12784 :          IF (gradient_functional) THEN
     268              :             ALLOCATE (drho_h(1:4, 1:na, 1:nr, 1:nspins), drho1_h(1:4, 1:na, 1:nr, 1:nspins), &
     269       128212 :                       drho_s(1:4, 1:na, 1:nr, 1:nspins), drho1_s(1:4, 1:na, 1:nr, 1:nspins))
     270        73264 :             ALLOCATE (vxg_h(1:3, 1:na, 1:nr, 1:nspins), vxg_s(1:3, 1:na, 1:nr, 1:nspins))
     271              :          ELSE
     272              :             ALLOCATE (drho_h(1, 1, 1, 1), drho1_h(1, 1, 1, 1), &
     273         3626 :                       drho_s(1, 1, 1, 1), drho1_s(1, 1, 1, 1))
     274         3626 :             ALLOCATE (vxg_h(1, 1, 1, 1), vxg_s(1, 1, 1, 1))
     275         3626 :             rrho = 0.0_dp
     276              :          END IF
     277     95089646 :          vxg_h = 0.0_dp
     278     95089646 :          vxg_s = 0.0_dp
     279              : 
     280              :          ! NLCC: prepare rho and drho of the core charge for this KIND
     281        12784 :          donlcc = .FALSE.
     282        12784 :          IF (nlcc) THEN
     283          208 :             NULLIFY (rho_nlcc)
     284          208 :             rho_nlcc => my_kind_set(ikind)%nlcc_pot
     285          208 :             IF (ASSOCIATED(rho_nlcc)) donlcc = .TRUE.
     286              :          END IF
     287              : 
     288              :          ! parallelization
     289        12784 :          IF (PRESENT(para_env_ext)) THEN
     290         6020 :             local_loop_limit = get_limit(natom, para_env_ext%num_pe, para_env_ext%mepos)
     291              :          ELSE
     292         6764 :             local_loop_limit = get_limit(natom, para_env%num_pe, para_env%mepos)
     293              :          END IF
     294              : 
     295        21869 :          DO iatom = local_loop_limit(1), local_loop_limit(2) !1,natom
     296         9085 :             atom = atom_list(iatom)
     297              : 
     298         9085 :             rho_atom_set(atom)%exc_h = 0.0_dp
     299         9085 :             rho_atom_set(atom)%exc_s = 0.0_dp
     300         9085 :             rho1_atom_set(atom)%exc_h = 0.0_dp
     301         9085 :             rho1_atom_set(atom)%exc_s = 0.0_dp
     302              : 
     303         9085 :             rho_atom => rho_atom_set(atom)
     304         9085 :             rho1_atom => rho1_atom_set(atom)
     305         9085 :             NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
     306         9085 :             NULLIFY (r1_h, r1_s, dr1_h, dr1_s, r1_h_d, r1_s_d)
     307     23822670 :             rho_h = 0.0_dp
     308     23822670 :             rho_s = 0.0_dp
     309     23822670 :             rho1_h = 0.0_dp
     310     23822670 :             rho1_s = 0.0_dp
     311         9085 :             IF (gradient_functional) THEN
     312              :                CALL get_rho_atom(rho_atom=rho_atom, &
     313              :                                  rho_rad_h=r_h, rho_rad_s=r_s, &
     314              :                                  drho_rad_h=dr_h, drho_rad_s=dr_s, &
     315         6537 :                                  rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
     316              :                CALL get_rho_atom(rho_atom=rho1_atom, &
     317              :                                  rho_rad_h=r1_h, rho_rad_s=r1_s, &
     318              :                                  drho_rad_h=dr1_h, drho_rad_s=dr1_s, &
     319         6537 :                                  rho_rad_h_d=r1_h_d, rho_rad_s_d=r1_s_d)
     320    170122791 :                drho_h = 0.0_dp; drho_s = 0.0_dp
     321    170122791 :                drho1_h = 0.0_dp; drho1_s = 0.0_dp
     322              :             ELSE
     323              :                CALL get_rho_atom(rho_atom=rho_atom, &
     324         2548 :                                  rho_rad_h=r_h, rho_rad_s=r_s)
     325              :                CALL get_rho_atom(rho_atom=rho1_atom, &
     326         2548 :                                  rho_rad_h=r1_h, rho_rad_s=r1_s)
     327              :             END IF
     328              : 
     329         9085 :             rtot = 0.0_dp
     330              : 
     331       463335 :             DO ir = 1, nr
     332              :                CALL calc_rho_angular(grid_atom, harmonics, nspins, gradient_functional, &
     333              :                                      ir, r_h, r_s, rho_h, rho_s, dr_h, dr_s, r_h_d, r_s_d, &
     334       454250 :                                      drho_h, drho_s)
     335       454250 :                IF (donlcc) THEN
     336              :                   CALL calc_rho_nlcc(grid_atom, nspins, gradient_functional, &
     337         2600 :                                      ir, rho_nlcc(:, 1), rho_h, rho_s, rho_nlcc(:, 2), drho_h, drho_s)
     338              :                END IF
     339              :                CALL calc_rho_angular(grid_atom, harmonics, nspins, gradient_functional, &
     340              :                                      ir, r1_h, r1_s, rho1_h, rho1_s, dr1_h, dr1_s, r1_h_d, r1_s_d, &
     341       463335 :                                      drho1_h, drho1_s)
     342              :             END DO
     343         9085 :             IF (tau_f) THEN
     344            0 :                CALL calc_tau_atom(tau_h, tau_s, rho_atom, tau_basis_cache, nspins)
     345            0 :                CALL calc_tau_atom(tau1_h, tau1_s, rho1_atom, tau_basis_cache, nspins)
     346              :             END IF
     347         9085 :             IF (scale_rho) THEN
     348       926376 :                rho_h = 2.0_dp*rho_h
     349       926376 :                rho_s = 2.0_dp*rho_s
     350          363 :                IF (gradient_functional) THEN
     351      3426696 :                   drho_h = 2.0_dp*drho_h
     352      3426696 :                   drho_s = 2.0_dp*drho_s
     353              :                END IF
     354          363 :                IF (tau_f) THEN
     355            0 :                   tau_h = 2.0_dp*tau_h
     356            0 :                   tau_s = 2.0_dp*tau_s
     357              :                END IF
     358              :             END IF
     359              : 
     360       463335 :             DO ir = 1, nr
     361       463335 :                IF (tau_f) THEN
     362            0 :                   CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
     363            0 :                   CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau1_h, na, ir)
     364            0 :                   CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
     365            0 :                   CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau1_s, na, ir)
     366       454250 :                ELSE IF (gradient_functional) THEN
     367       326850 :                   CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, rtau, na, ir)
     368       326850 :                   CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, rtau, na, ir)
     369       326850 :                   CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, rtau, na, ir)
     370       326850 :                   CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, rtau, na, ir)
     371              :                ELSE
     372       127400 :                   CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rrho, rtau, na, ir)
     373       127400 :                   CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, rrho, rtau, na, ir)
     374       127400 :                   CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rrho, rtau, na, ir)
     375       127400 :                   CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, rrho, rtau, na, ir)
     376              :                END IF
     377              :             END DO
     378              : 
     379              :             CALL xc_2nd_deriv_of_r(xc_section=xc_section, &
     380              :                                    rho_set=rho_set_h, rho1_set=rho1_set_h, &
     381              :                                    deriv_set=deriv_set, &
     382              :                                    w=weight_h, vxc=vxc_h, vxg=vxg_h, vtau=vtau_h, do_triplet=do_triplet, &
     383         9085 :                                    do_sf=my_do_sf)
     384              :             CALL xc_2nd_deriv_of_r(xc_section=xc_section, &
     385              :                                    rho_set=rho_set_s, rho1_set=rho1_set_s, &
     386              :                                    deriv_set=deriv_set, &
     387              :                                    w=weight_s, vxc=vxc_s, vxg=vxg_s, vtau=vtau_s, do_triplet=do_triplet, &
     388         9085 :                                    do_sf=my_do_sf)
     389              : 
     390         9085 :             CALL get_rho_atom(rho_atom=rho1_atom, ga_Vlocal_gb_h=int_hh, ga_Vlocal_gb_s=int_ss)
     391         9085 :             IF (gradient_functional) THEN
     392              :                CALL gaVxcgb_GC(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, &
     393         6537 :                                grid_atom, basis_1c, harmonics, nspins)
     394              :             ELSE
     395              :                CALL gaVxcgb_noGC(vxc_h, vxc_s, int_hh, int_ss, &
     396         2548 :                                  grid_atom, basis_1c, harmonics, nspins)
     397              :             END IF
     398         9085 :             IF (tau_f) THEN
     399              :                CALL dgaVtaudgb(vtau_h, vtau_s, int_hh, int_ss, &
     400            0 :                                tau_basis_cache, nspins)
     401              :             END IF
     402              : 
     403        21869 :             NULLIFY (r_h, r_s, dr_h, dr_s)
     404              : 
     405              :          END DO
     406              : 
     407              :          ! some cleanup
     408        12784 :          DEALLOCATE (rho_h, rho_s, rho1_h, rho1_s, vxc_h, vxc_s)
     409        12784 :          DEALLOCATE (drho_h, drho_s, vxg_h, vxg_s)
     410        12784 :          DEALLOCATE (drho1_h, drho1_s)
     411        12784 :          IF (tau_f) THEN
     412            0 :             DEALLOCATE (tau_h, tau_s, tau1_h, tau1_s)
     413            0 :             DEALLOCATE (vtau_h, vtau_s)
     414            0 :             CALL release_tau_basis_cache(tau_basis_cache)
     415              :          END IF
     416              : 
     417        12784 :          CALL xc_dset_release(deriv_set)
     418        12784 :          CALL xc_rho_set_release(rho_set_h)
     419        12784 :          CALL xc_rho_set_release(rho1_set_h)
     420        12784 :          CALL xc_rho_set_release(rho_set_s)
     421        46222 :          CALL xc_rho_set_release(rho1_set_s)
     422              :       END DO
     423              : 
     424         6234 :       CALL timestop(handle)
     425              : 
     426       461316 :    END SUBROUTINE fxc_atom_calc
     427              : 
     428              : END MODULE qs_fxc_atom
        

Generated by: LCOV version 2.0-1