74 SUBROUTINE fxc_atom_calc(qs_env, rho_atom_set, rho1_atom_set, xc_section, para_env_ext, &
75 do_scale, do_triplet, do_sf, kind_set_external)
78 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: rho_atom_set, rho1_atom_set
81 LOGICAL,
INTENT(IN),
OPTIONAL :: do_scale, do_triplet, do_sf
83 POINTER :: kind_set_external
85 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fxc_atom_calc'
87 INTEGER ::
atom, handle, iatom, ikind, ir, na, &
89 INTEGER,
DIMENSION(2) :: local_loop_limit
90 INTEGER,
DIMENSION(2, 3) :: bounds
91 INTEGER,
DIMENSION(:),
POINTER :: atom_list
92 LOGICAL :: accint, donlcc, gradient_functional, &
93 lsd, my_do_sf, nlcc, paw_atom, &
95 REAL(kind=
dp) :: agr, alpha, density_cut, gradient_cut, &
97 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: fw
98 REAL(kind=
dp),
CONTIGUOUS,
DIMENSION(:, :, :), &
99 POINTER :: vtau_h, vtau_s, vxc_h, vxc_s
100 REAL(kind=
dp),
DIMENSION(1, 1, 1) :: rtau
101 REAL(kind=
dp),
DIMENSION(1, 1, 1, 1) :: rrho
102 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: rho_nlcc, weight_h, weight_s
103 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: rho1_h, rho1_s, rho_h, rho_s, tau1_h, &
105 REAL(kind=
dp),
DIMENSION(:, :, :, :),
POINTER :: drho1_h, drho1_s, drho_h, drho_s, vxg_h, &
113 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: my_kind_set, qs_kind_set
114 TYPE(
rho_atom_coeff),
DIMENSION(:),
POINTER :: dr1_h, dr1_s, dr_h, dr_s, int_hh, &
115 int_ss, r1_h, r1_s, r_h, r_s
116 TYPE(
rho_atom_coeff),
DIMENSION(:, :),
POINTER :: r1_h_d, r1_s_d, r_h_d, r_s_d
127 CALL timeset(routinen, handle)
129 NULLIFY (qs_kind_set)
130 NULLIFY (rho_h, rho_s, drho_h, drho_s, weight_h, weight_s)
131 NULLIFY (rho1_h, rho1_s, drho1_h, drho1_s)
132 NULLIFY (vxc_h, vxc_s, vxg_h, vxg_s)
133 NULLIFY (tau_h, tau_s, tau1_h, tau1_s, vtau_h, vtau_s)
138 dft_control=dft_control, &
140 qs_kind_set=qs_kind_set, &
141 atomic_kind_set=atomic_kind_set)
143 IF (
PRESENT(kind_set_external))
THEN
144 my_kind_set => kind_set_external
146 my_kind_set => qs_kind_set
150 accint = dft_control%qs_control%gapw_control%accurate_xcint
161 IF (
PRESENT(do_sf)) my_do_sf = do_sf
172 IF (
PRESENT(do_scale))
THEN
176 cpassert(
PRESENT(do_triplet))
178 cpassert(nspins == 1)
181 IF (
PRESENT(do_triplet))
THEN
182 IF (nspins == 1 .AND. do_triplet) lsd = .true.
186 calc_potential=.true.)
187 gradient_functional = needs%drho .OR. needs%drho_spin
188 tau_f = (needs%tau .OR. needs%tau_spin)
189 IF (.NOT. tau_f) rtau = 0.0_dp
192 DO ikind = 1,
SIZE(atomic_kind_set)
194 NULLIFY (atom_list, harmonics, grid_atom)
195 CALL get_atomic_kind(atomic_kind_set(ikind), atom_list=atom_list, natom=natom)
196 CALL get_qs_kind(my_kind_set(ikind), paw_atom=paw_atom, &
197 harmonics=harmonics, grid_atom=grid_atom)
198 CALL get_qs_kind(my_kind_set(ikind), basis_set=basis_1c, basis_type=
"GAPW_1C")
199 IF (.NOT. paw_atom) cycle
202 na = grid_atom%ng_sphere
205 weight_h => grid_atom%weight
206 weight_s => grid_atom%weight
208 on = dft_control%qs_control%gapw_control%oweights
209 alpha = dft_control%qs_control%gapw_control%aw(ikind)
210 IF (
ASSOCIATED(grid_atom%gapw_weight_s))
THEN
211 IF (grid_atom%gapw_weight_alpha /= alpha)
DEALLOCATE (grid_atom%gapw_weight_s)
213 IF (.NOT.
ASSOCIATED(grid_atom%gapw_weight_s))
THEN
214 ALLOCATE (grid_atom%gapw_weight_s(na, nr))
218 agr = 1.0_dp - fw(ir)
219 grid_atom%gapw_weight_s(:, ir) = agr*grid_atom%weight(:, ir)
222 grid_atom%gapw_weight_alpha = alpha
224 weight_s => grid_atom%gapw_weight_s
236 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
238 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
240 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
242 drho_cutoff=gradient_cut, tau_cutoff=tau_cut)
245 IF (nspins == 1 .AND. .NOT. lsd)
THEN
257 ALLOCATE (rho_h(1:na, 1:nr, 1:nspins), rho1_h(1:na, 1:nr, 1:nspins), &
258 rho_s(1:na, 1:nr, 1:nspins), rho1_s(1:na, 1:nr, 1:nspins))
260 ALLOCATE (vxc_h(1:na, 1:nr, 1:nspins), vxc_s(1:na, 1:nr, 1:nspins))
266 ALLOCATE (tau_h(1:na, 1:nr, 1:nspins), tau1_h(1:na, 1:nr, 1:nspins), &
267 tau_s(1:na, 1:nr, 1:nspins), tau1_s(1:na, 1:nr, 1:nspins))
268 ALLOCATE (vtau_h(1:na, 1:nr, 1:nspins), vtau_s(1:na, 1:nr, 1:nspins))
271 IF (gradient_functional)
THEN
272 ALLOCATE (drho_h(1:4, 1:na, 1:nr, 1:nspins), drho1_h(1:4, 1:na, 1:nr, 1:nspins), &
273 drho_s(1:4, 1:na, 1:nr, 1:nspins), drho1_s(1:4, 1:na, 1:nr, 1:nspins))
274 ALLOCATE (vxg_h(1:3, 1:na, 1:nr, 1:nspins), vxg_s(1:3, 1:na, 1:nr, 1:nspins))
276 ALLOCATE (drho_h(1, 1, 1, 1), drho1_h(1, 1, 1, 1), &
277 drho_s(1, 1, 1, 1), drho1_s(1, 1, 1, 1))
278 ALLOCATE (vxg_h(1, 1, 1, 1), vxg_s(1, 1, 1, 1))
288 rho_nlcc => my_kind_set(ikind)%nlcc_pot
289 IF (
ASSOCIATED(rho_nlcc)) donlcc = .true.
293 IF (
PRESENT(para_env_ext))
THEN
294 local_loop_limit =
get_limit(natom, para_env_ext%num_pe, para_env_ext%mepos)
296 local_loop_limit =
get_limit(natom, para_env%num_pe, para_env%mepos)
299 DO iatom = local_loop_limit(1), local_loop_limit(2)
300 atom = atom_list(iatom)
302 rho_atom_set(
atom)%exc_h = 0.0_dp
303 rho_atom_set(
atom)%exc_s = 0.0_dp
304 rho1_atom_set(
atom)%exc_h = 0.0_dp
305 rho1_atom_set(
atom)%exc_s = 0.0_dp
307 rho_atom => rho_atom_set(
atom)
308 rho1_atom => rho1_atom_set(
atom)
309 NULLIFY (r_h, r_s, dr_h, dr_s, r_h_d, r_s_d)
310 NULLIFY (r1_h, r1_s, dr1_h, dr1_s, r1_h_d, r1_s_d)
315 IF (gradient_functional)
THEN
317 rho_rad_h=r_h, rho_rad_s=r_s, &
318 drho_rad_h=dr_h, drho_rad_s=dr_s, &
319 rho_rad_h_d=r_h_d, rho_rad_s_d=r_s_d)
321 rho_rad_h=r1_h, rho_rad_s=r1_s, &
322 drho_rad_h=dr1_h, drho_rad_s=dr1_s, &
323 rho_rad_h_d=r1_h_d, rho_rad_s_d=r1_s_d)
324 drho_h = 0.0_dp; drho_s = 0.0_dp
325 drho1_h = 0.0_dp; drho1_s = 0.0_dp
328 rho_rad_h=r_h, rho_rad_s=r_s)
330 rho_rad_h=r1_h, rho_rad_s=r1_s)
337 ir, r_h, r_s, rho_h, rho_s, dr_h, dr_s, r_h_d, r_s_d, &
339 IF (donlcc .AND.
ASSOCIATED(rho_nlcc))
THEN
341 ir, rho_nlcc(:, 1), rho_h, rho_s, rho_nlcc(:, 2), drho_h, drho_s)
344 ir, r1_h, r1_s, rho1_h, rho1_s, dr1_h, dr1_s, r1_h_d, r1_s_d, &
348 CALL calc_tau_atom(tau_h, tau_s, rho_atom, tau_basis_cache, nspins)
349 CALL calc_tau_atom(tau1_h, tau1_s, rho1_atom, tau_basis_cache, nspins)
354 IF (gradient_functional)
THEN
355 drho_h = 2.0_dp*drho_h
356 drho_s = 2.0_dp*drho_s
366 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, tau_h, na, ir)
367 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, tau1_h, na, ir)
368 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, tau_s, na, ir)
369 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, tau1_s, na, ir)
370 ELSE IF (gradient_functional)
THEN
371 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, drho_h, rtau, na, ir)
372 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, drho1_h, rtau, na, ir)
373 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, drho_s, rtau, na, ir)
374 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, drho1_s, rtau, na, ir)
376 CALL fill_rho_set(rho_set_h, lsd, nspins, needs, rho_h, rrho, rtau, na, ir)
377 CALL fill_rho_set(rho1_set_h, lsd, nspins, needs, rho1_h, rrho, rtau, na, ir)
378 CALL fill_rho_set(rho_set_s, lsd, nspins, needs, rho_s, rrho, rtau, na, ir)
379 CALL fill_rho_set(rho1_set_s, lsd, nspins, needs, rho1_s, rrho, rtau, na, ir)
384 rho_set=rho_set_h, rho1_set=rho1_set_h, &
385 deriv_set=deriv_set, &
386 w=weight_h, vxc=vxc_h, vxg=vxg_h, vtau=vtau_h, do_triplet=do_triplet, &
389 rho_set=rho_set_s, rho1_set=rho1_set_s, &
390 deriv_set=deriv_set, &
391 w=weight_s, vxc=vxc_s, vxg=vxg_s, vtau=vtau_s, do_triplet=do_triplet, &
394 CALL get_rho_atom(rho_atom=rho1_atom, ga_vlocal_gb_h=int_hh, ga_vlocal_gb_s=int_ss)
395 IF (gradient_functional)
THEN
396 CALL gavxcgb_gc(vxc_h, vxc_s, vxg_h, vxg_s, int_hh, int_ss, &
397 grid_atom, basis_1c, harmonics, nspins)
400 grid_atom, basis_1c, harmonics, nspins)
403 CALL dgavtaudgb(vtau_h, vtau_s, int_hh, int_ss, &
404 tau_basis_cache, nspins)
407 NULLIFY (r_h, r_s, dr_h, dr_s)
412 DEALLOCATE (rho_h, rho_s, rho1_h, rho1_s, vxc_h, vxc_s)
413 DEALLOCATE (drho_h, drho_s, vxg_h, vxg_s)
414 DEALLOCATE (drho1_h, drho1_s)
416 DEALLOCATE (tau_h, tau_s, tau1_h, tau1_s)
417 DEALLOCATE (vtau_h, vtau_s)
428 CALL timestop(handle)
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
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, hund_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, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.