76#include "./base/base_uses.f90"
85 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_fgxc'
110 xc_section, do_onecenter, is_triplet, spinflip, &
111 fxc_rho, fxc_tau, gxc_rho, gxc_tau, &
112 rhof_atom_set, rhog_atom_set, qs_kind_set)
115 TYPE(
qs_rho_type),
POINTER :: rho0_struct, rho1_struct
118 LOGICAL,
INTENT(IN) :: do_onecenter, is_triplet, spinflip
119 TYPE(
pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
120 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: rhof_atom_set, rhog_atom_set
121 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
123 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_fgxc_create'
125 INTEGER :: handle, ispin, nspins, nsteps, order
126 LOGICAL :: analytic_2nd_deriv, analytic_3rd_deriv, &
127 has_rho, has_tau, uf_grid
128 REAL(kind=
dp) :: eps_delta, factor
133 TYPE(
pw_pool_type),
POINTER :: auxbas_pw_pool, uf_pw_pool, xc_pw_pool
134 TYPE(
pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho_uf, fxc_tau_uf, gxc_rho_uf, &
139 CALL timeset(routinen, handle)
142 cpassert(.NOT.
ASSOCIATED(fxc_rho))
143 cpassert(.NOT.
ASSOCIATED(fxc_tau))
144 cpassert(.NOT.
ASSOCIATED(gxc_rho))
145 cpassert(.NOT.
ASSOCIATED(gxc_tau))
146 cpassert(
ASSOCIATED(rho0_struct))
147 cpassert(
ASSOCIATED(rho1_struct))
154 IF (analytic_3rd_deriv .AND. .NOT. analytic_2nd_deriv)
THEN
155 CALL cp_warn(__location__,
"XC Analytic 3rd derivatives cannot be combined with "// &
156 "numeric 2nd derivatives.")
157 cpabort(
"XC derivative options")
160 CALL get_qs_env(qs_env, dft_control=dft_control)
161 nspins = dft_control%nspins
164 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, xc_pw_pool=xc_pw_pool)
165 uf_grid = .NOT.
pw_grid_compare(auxbas_pw_pool%pw_grid, xc_pw_pool%pw_grid)
167 NULLIFY (fxc_rho_uf, fxc_tau_uf, gxc_rho_uf, gxc_tau_uf)
168 IF (analytic_2nd_deriv .AND. analytic_3rd_deriv)
THEN
171 NULLIFY (rho_nlcc, rho_nlcc_g)
172 CALL get_qs_env(qs_env, rho_nlcc=rho_nlcc, rho_nlcc_g=rho_nlcc_g)
173 IF (
ASSOCIATED(rho_nlcc))
THEN
174 NULLIFY (rho_r, rho_g)
175 CALL qs_rho_get(rho0_struct, rho_r=rho_r, rho_g=rho_g)
178 CALL pw_axpy(rho_nlcc, rho_r(ispin), factor)
179 CALL pw_axpy(rho_nlcc_g, rho_g(ispin), factor)
185 CALL get_qs_env(qs_env, xcint_weights=weights)
189 IF (
ASSOCIATED(weights))
THEN
190 ALLOCATE (weights_uf)
191 CALL xc_pw_pool%create_pw(weights_uf)
194 CALL auxbas_pw_pool%create_pw(weights_g)
195 CALL xc_pw_pool%create_pw(weights_g_uf)
199 CALL xc_pw_pool%give_back_pw(weights_g_uf)
200 CALL auxbas_pw_pool%give_back_pw(weights_g)
204 ALLOCATE (rho0_uf, rho1_uf)
209 uf_pw_pool => xc_pw_pool
211 weights_uf => weights
212 rho0_uf => rho0_struct
213 rho1_uf => rho1_struct
214 uf_pw_pool => auxbas_pw_pool
219 IF (.NOT. spinflip .AND. is_triplet)
THEN
220 cpabort(
"Analytic 3rd XC derivatives: no restricted triplets yet")
222 CALL qs_fgxc_analytic(rho0_uf, rho1_uf, xc_section, uf_pw_pool, weights_uf, &
223 is_triplet, spinflip, &
224 fxc_rho_uf, fxc_tau_uf, gxc_rho_uf, gxc_tau_uf)
228 IF (
ASSOCIATED(fxc_rho_uf) .AND.
ASSOCIATED(gxc_rho_uf)) has_rho = .true.
230 IF (
ASSOCIATED(fxc_tau_uf) .AND.
ASSOCIATED(gxc_tau_uf)) has_tau = .true.
235 ALLOCATE (fxc_rho(nspins), gxc_rho(nspins))
237 CALL auxbas_pw_pool%create_pw(fxc_rho(ispin))
238 CALL auxbas_pw_pool%create_pw(gxc_rho(ispin))
241 CALL auxbas_pw_pool%create_pw(xc_g)
242 CALL xc_pw_pool%create_pw(xc_g_uf)
249 CALL xc_pw_pool%give_back_pw(xc_g_uf)
250 CALL auxbas_pw_pool%give_back_pw(xc_g)
252 CALL xc_pw_pool%give_back_pw(fxc_rho_uf(ispin))
253 CALL xc_pw_pool%give_back_pw(gxc_rho_uf(ispin))
255 DEALLOCATE (fxc_rho_uf, gxc_rho_uf)
257 NULLIFY (fxc_rho, gxc_rho)
261 ALLOCATE (fxc_tau(nspins), gxc_tau(nspins))
263 CALL auxbas_pw_pool%create_pw(fxc_tau(ispin))
264 CALL auxbas_pw_pool%create_pw(gxc_tau(ispin))
266 TYPE(pw_c1d_gs_type) :: xc_g, xc_g_uf
267 CALL auxbas_pw_pool%create_pw(xc_g)
268 CALL xc_pw_pool%create_pw(xc_g_uf)
269 CALL pw_transfer(fxc_tau_uf(ispin), xc_g_uf)
270 CALL pw_transfer(xc_g_uf, xc_g)
271 CALL pw_transfer(xc_g, fxc_tau(ispin))
272 CALL pw_transfer(gxc_tau_uf(ispin), xc_g_uf)
273 CALL pw_transfer(xc_g_uf, xc_g)
274 CALL pw_transfer(xc_g, gxc_tau(ispin))
275 CALL xc_pw_pool%give_back_pw(xc_g_uf)
276 CALL auxbas_pw_pool%give_back_pw(xc_g)
278 CALL xc_pw_pool%give_back_pw(fxc_tau_uf(ispin))
279 CALL xc_pw_pool%give_back_pw(gxc_tau_uf(ispin))
281 DEALLOCATE (fxc_tau_uf, gxc_tau_uf)
283 NULLIFY (fxc_tau, gxc_tau)
286 fxc_rho => fxc_rho_uf
287 fxc_tau => fxc_tau_uf
288 gxc_rho => gxc_rho_uf
289 gxc_tau => gxc_tau_uf
293 IF (
ASSOCIATED(rho_nlcc))
THEN
296 CALL pw_axpy(rho_nlcc, rho_r(ispin), factor)
297 CALL pw_axpy(rho_nlcc_g, rho_g(ispin), factor)
301 ELSE IF (analytic_2nd_deriv .AND. .NOT. analytic_3rd_deriv)
THEN
304 CALL get_qs_env(qs_env, xcint_weights=weights)
305 CALL qs_fgxc_gdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
306 order, eps_delta, is_triplet, spinflip, &
307 fxc_rho, fxc_tau, gxc_rho, gxc_tau)
309 ELSE IF (.NOT. (analytic_2nd_deriv .OR. analytic_3rd_deriv))
THEN
311 CALL qs_fgxc_fgdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
312 order, is_triplet, spinflip, &
313 fxc_rho, fxc_tau, gxc_rho, gxc_tau)
316 cpabort(
"EXC derivative option not available")
319 IF (do_onecenter)
THEN
320 IF (analytic_2nd_deriv .AND. analytic_3rd_deriv)
THEN
321 cpabort(
"Analytic 3rd EXC derivatives not available")
322 ELSE IF (analytic_2nd_deriv)
THEN
323 CALL fgxc_atom_diff(qs_env, rho0_atom_set, rhof_atom_set, rhog_atom_set, &
324 qs_kind_set, xc_section, is_triplet, order, eps_delta)
325 ELSE IF (analytic_3rd_deriv)
THEN
326 CALL cp_warn(__location__,
"XC Analytic 3rd derivatives cannot be combined with "// &
327 "numeric 2nd derivatives.")
328 cpabort(
"XC derivative options")
330 CALL fgxc_atom_calc(qs_env, rho0_atom_set, rhof_atom_set, rhog_atom_set, &
331 qs_kind_set, xc_section, is_triplet, order)
335 CALL timestop(handle)
358 SUBROUTINE qs_fgxc_analytic(rho0_struct, rho1_struct, xc_section, pw_pool, weights, &
359 is_triplet, spinflip, fxc_rho, fxc_tau, gxc_rho, gxc_tau)
361 TYPE(qs_rho_type),
POINTER :: rho0_struct, rho1_struct
362 TYPE(section_vals_type),
POINTER :: xc_section
363 TYPE(pw_pool_type),
POINTER :: pw_pool
364 TYPE(pw_r3d_rs_type),
POINTER :: weights
365 LOGICAL,
INTENT(IN) :: is_triplet, spinflip
366 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
368 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_fgxc_analytic'
370 INTEGER :: handle, ispin, nspins, spindim
371 INTEGER,
DIMENSION(2, 3) :: bo
372 LOGICAL :: do_sf, lsd
374 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho0_g, rho1_g
375 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho0_r, rho1_r, tau0_r, tau1_r
376 TYPE(section_vals_type),
POINTER :: xc_fun_section
377 TYPE(xc_derivative_set_type) :: deriv_set
378 TYPE(xc_rho_cflags_type) :: needs
379 TYPE(xc_rho_set_type) :: rho0_set, rho1_set
381 CALL timeset(routinen, handle)
384 cpassert(.NOT.
ASSOCIATED(fxc_rho))
385 cpassert(.NOT.
ASSOCIATED(fxc_tau))
386 cpassert(.NOT.
ASSOCIATED(gxc_rho))
387 cpassert(.NOT.
ASSOCIATED(gxc_tau))
388 cpassert(
ASSOCIATED(rho0_struct))
389 cpassert(
ASSOCIATED(rho1_struct))
391 cpassert(.NOT. is_triplet)
397 CALL qs_rho_get(rho0_struct, rho_r=rho0_r, rho_g=rho0_g, tau_r=tau0_r)
398 nspins =
SIZE(rho0_r)
402 CALL qs_rho_get(rho1_struct, rho_r=rho1_r, rho_g=rho1_g, tau_r=tau1_r)
406 IF (.NOT. (do_sf .OR. nspins == 1 .OR. nspins == 2))
THEN
407 cpabort(
"Analytic 3rd XC derivatives: unsupported spin case")
418 IF (nspins == 1)
THEN
423 xc_fun_section => section_vals_get_subs_vals(xc_section,
"XC_FUNCTIONAL")
424 needs = xc_functionals_get_needs(xc_fun_section, lsd, .true.)
427 ALLOCATE (fxc_rho(spindim), gxc_rho(nspins))
428 DO ispin = 1, spindim
429 CALL pw_pool%create_pw(fxc_rho(ispin))
430 CALL pw_zero(fxc_rho(ispin))
433 CALL pw_pool%create_pw(gxc_rho(ispin))
434 CALL pw_zero(gxc_rho(ispin))
437 IF (needs%tau .OR. needs%tau_spin)
THEN
438 IF (.NOT.
ASSOCIATED(tau1_r))
THEN
439 cpabort(
"Tau-dependent functionals requires allocated kinetic energy density grid")
441 ALLOCATE (fxc_tau(spindim), gxc_tau(nspins))
442 DO ispin = 1, spindim
443 CALL pw_pool%create_pw(fxc_tau(ispin))
444 CALL pw_zero(fxc_tau(ispin))
447 CALL pw_pool%create_pw(gxc_tau(ispin))
448 CALL pw_zero(gxc_tau(ispin))
461 CALL xc_prep_3rd_deriv(deriv_set, rho0_set, rho0_r, pw_pool, weights, &
462 xc_section, tau_r=tau0_r, do_sf=do_sf)
465 bo = rho1_r(1)%pw_grid%bounds_local
470 CALL xc_rho_set_create(rho1_set, bo, &
471 rho_cutoff=section_get_rval(xc_section,
"DENSITY_CUTOFF"), &
472 drho_cutoff=section_get_rval(xc_section,
"GRADIENT_CUTOFF"), &
473 tau_cutoff=section_get_rval(xc_section,
"TAU_CUTOFF"))
480 CALL xc_rho_set_update(rho1_set, rho1_r, rho1_g, tau1_r, needs, &
481 section_get_ival(xc_section,
"XC_GRID%XC_DERIV"), &
482 section_get_ival(xc_section,
"XC_GRID%XC_SMOOTH_RHO"), &
483 pw_pool, spinflip=do_sf)
493 CALL xc_calc_2nd_deriv_analytical(fxc_rho, fxc_tau, deriv_set, rho0_set, rho1_set, pw_pool, &
494 xc_section, .false., spinflip=do_sf, tddfpt_fac=
fac)
496 CALL xc_calc_3rd_deriv_analytical(gxc_rho, gxc_tau, deriv_set, rho0_set, rho1_set, pw_pool, &
497 xc_section, spinflip=do_sf)
499 CALL xc_dset_release(deriv_set)
500 CALL xc_rho_set_release(rho0_set)
501 CALL xc_rho_set_release(rho1_set)
503 CALL timestop(handle)
505 END SUBROUTINE qs_fgxc_analytic
522 SUBROUTINE qs_fgxc_gdiff(qs_env, rho0_struct, rho1_struct, xc_section, accuracy, epsrho, &
523 is_triplet, spinflip, fxc_rho, fxc_tau, gxc_rho, gxc_tau)
525 TYPE(qs_environment_type),
POINTER :: qs_env
526 TYPE(qs_rho_type),
POINTER :: rho0_struct, rho1_struct
527 TYPE(section_vals_type),
POINTER :: xc_section
528 INTEGER,
INTENT(IN) :: accuracy
529 REAL(kind=dp),
INTENT(IN) :: epsrho
530 LOGICAL,
INTENT(IN) :: is_triplet, spinflip
531 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
533 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_fgxc_gdiff'
535 INTEGER :: handle, ispin, istep, nspins, nstep
537 REAL(kind=dp) :: alpha, beta, exc, oeps1
538 REAL(kind=dp),
DIMENSION(-4:4) :: ak
539 TYPE(dft_control_type),
POINTER :: dft_control
540 TYPE(pw_env_type),
POINTER :: pw_env
541 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
542 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: v_tau_rspace, vxc00, vxc00b
543 TYPE(qs_rho_type),
POINTER :: rhoin
544 TYPE(rho_atom_type),
DIMENSION(:),
POINTER :: rho0_atom_set, rho1_atom_set
546 CALL timeset(routinen, handle)
548 cpassert(.NOT.
ASSOCIATED(fxc_rho))
549 cpassert(.NOT.
ASSOCIATED(fxc_tau))
550 cpassert(.NOT.
ASSOCIATED(gxc_rho))
551 cpassert(.NOT.
ASSOCIATED(gxc_tau))
552 cpassert(
ASSOCIATED(rho0_struct))
553 cpassert(
ASSOCIATED(rho1_struct))
558 SELECT CASE (accuracy)
561 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
564 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
567 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
568 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
571 CALL get_qs_env(qs_env, dft_control=dft_control, pw_env=pw_env)
572 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
574 nspins = dft_control%nspins
578 CALL qs_fxc_create(qs_env, rho0_struct, rho1_struct, rho0_atom_set, xc_section, &
579 .false., fxc_rho, fxc_tau, rho1_atom_set, &
580 is_triplet=is_triplet, spinflip=do_sf)
582 CALL qs_fxc_fdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
583 accuracy, fxc_rho, fxc_tau, is_triplet)
586 DO istep = -nstep, nstep
588 IF (ak(istep) /= 0.0_dp)
THEN
590 beta = real(istep, kind=dp)*epsrho
593 CALL qs_rho_create(rhoin)
594 NULLIFY (vxc00, vxc00b, v_tau_rspace)
595 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, nspins)
596 CALL qs_rho_scale_and_add(rhoin, rho1_struct, alpha, beta)
599 CALL qs_fxc_create(qs_env, rhoin, rho1_struct, rho0_atom_set, xc_section, &
600 .false., vxc00, v_tau_rspace, rho1_atom_set, &
601 is_triplet=is_triplet, spinflip=do_sf)
603 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, nspins)
604 CALL qs_rho_scale_and_add_b(rhoin, rho1_struct, alpha, beta)
605 CALL qs_fxc_create(qs_env, rhoin, rho1_struct, rho0_atom_set, xc_section, &
606 .false., vxc00b, v_tau_rspace, rho1_atom_set, &
607 is_triplet=is_triplet, spinflip=do_sf)
609 CALL qs_fxc_fdiff(qs_env, rhoin, rho1_struct, xc_section, accuracy, &
610 fxc_rho=vxc00, fxc_tau=v_tau_rspace, is_triplet=is_triplet)
612 CALL qs_rho_release(rhoin)
614 IF (.NOT.
ASSOCIATED(gxc_rho))
THEN
615 ALLOCATE (gxc_rho(nspins))
617 CALL auxbas_pw_pool%create_pw(gxc_rho(ispin))
618 CALL pw_zero(gxc_rho(ispin))
622 CALL pw_axpy(vxc00(1), gxc_rho(1), ak(istep))
623 CALL pw_axpy(vxc00b(1), gxc_rho(2), ak(istep))
626 CALL pw_axpy(vxc00(ispin), gxc_rho(ispin), ak(istep))
629 DO ispin = 1,
SIZE(vxc00)
630 CALL auxbas_pw_pool%give_back_pw(vxc00(ispin))
633 IF (
ASSOCIATED(vxc00b))
THEN
634 CALL auxbas_pw_pool%give_back_pw(vxc00b(1))
637 IF (
ASSOCIATED(v_tau_rspace))
THEN
638 IF (.NOT.
ASSOCIATED(gxc_tau))
THEN
639 ALLOCATE (gxc_tau(nspins))
641 CALL auxbas_pw_pool%create_pw(gxc_tau(ispin))
642 CALL pw_zero(gxc_tau(ispin))
646 CALL pw_axpy(v_tau_rspace(ispin), gxc_tau(ispin), ak(istep))
648 DO ispin = 1,
SIZE(v_tau_rspace)
649 CALL auxbas_pw_pool%give_back_pw(v_tau_rspace(ispin))
651 DEALLOCATE (v_tau_rspace)
657 oeps1 = 1.0_dp/epsrho
659 CALL pw_scale(gxc_rho(ispin), oeps1)
661 IF (
ASSOCIATED(gxc_tau))
THEN
663 CALL pw_scale(gxc_tau(ispin), oeps1)
667 CALL timestop(handle)
669 END SUBROUTINE qs_fgxc_gdiff
685 SUBROUTINE qs_fgxc_fgdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
686 accuracy, is_triplet, spinflip, &
687 fxc_rho, fxc_tau, gxc_rho, gxc_tau)
689 TYPE(qs_environment_type),
POINTER :: qs_env
690 TYPE(qs_rho_type),
POINTER :: rho0_struct, rho1_struct
691 TYPE(section_vals_type),
POINTER :: xc_section
692 INTEGER,
INTENT(IN) :: accuracy
693 LOGICAL,
INTENT(IN) :: is_triplet, spinflip
694 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
696 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_fgxc_fgdiff'
697 REAL(kind=dp),
PARAMETER :: epsrho = 5.e-4_dp
699 INTEGER :: handle, ispin, istep, nspins, nstep
700 REAL(kind=dp) :: alpha, beta, exc, oeps1, oeps2
701 REAL(kind=dp),
DIMENSION(-4:4) :: ak, bl
702 TYPE(dft_control_type),
POINTER :: dft_control
703 TYPE(pw_env_type),
POINTER :: pw_env
704 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
705 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: v_tau_rspace, vxc00
706 TYPE(qs_ks_env_type),
POINTER :: ks_env
707 TYPE(qs_rho_type),
POINTER :: rhoin
709 CALL timeset(routinen, handle)
711 cpassert(.NOT.
ASSOCIATED(fxc_rho))
712 cpassert(.NOT.
ASSOCIATED(fxc_tau))
713 cpassert(.NOT.
ASSOCIATED(gxc_rho))
714 cpassert(.NOT.
ASSOCIATED(gxc_tau))
715 cpassert(
ASSOCIATED(rho0_struct))
716 cpassert(
ASSOCIATED(rho1_struct))
719 cpassert(.NOT. spinflip)
723 SELECT CASE (accuracy)
726 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
727 bl(-2:2) = [-1.0_dp, 16.0_dp, -30.0_dp, 16.0_dp, -1.0_dp]/12.0_dp
730 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
731 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
734 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
735 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
736 bl(-4:4) = [-1.0_dp, 128.0_dp/9.0_dp, -112.0_dp, 896.0_dp, -14350.0_dp/9.0_dp, &
737 896.0_dp, -112.0_dp, 128.0_dp/9.0_dp, -1.0_dp]/560.0_dp
740 CALL get_qs_env(qs_env, ks_env=ks_env, dft_control=dft_control, pw_env=pw_env)
741 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
743 nspins = dft_control%nspins
746 DO istep = -nstep, nstep
749 beta = real(istep, kind=dp)*epsrho
752 CALL qs_rho_create(rhoin)
753 NULLIFY (vxc00, v_tau_rspace)
755 cpassert(nspins == 1)
757 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, 2)
759 CALL qs_rho_scale_and_add(rhoin, rho1_struct, alpha, 0.5_dp*beta)
760 CALL qs_vxc_create(ks_env, rhoin, xc_section, vxc00, v_tau_rspace, exc)
761 CALL pw_axpy(vxc00(2), vxc00(1), -1.0_dp)
763 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, nspins)
764 CALL qs_rho_scale_and_add(rhoin, rho1_struct, alpha, beta)
765 CALL qs_vxc_create(ks_env, rhoin, xc_section, vxc00, v_tau_rspace, exc)
767 CALL qs_rho_release(rhoin)
769 IF (.NOT.
ASSOCIATED(fxc_rho))
THEN
770 ALLOCATE (fxc_rho(nspins))
772 CALL auxbas_pw_pool%create_pw(fxc_rho(ispin))
773 CALL pw_zero(fxc_rho(ispin))
776 IF (.NOT.
ASSOCIATED(gxc_rho))
THEN
777 ALLOCATE (gxc_rho(nspins))
779 CALL auxbas_pw_pool%create_pw(gxc_rho(ispin))
780 CALL pw_zero(gxc_rho(ispin))
783 cpassert(.NOT.
ASSOCIATED(v_tau_rspace))
785 IF (ak(istep) /= 0.0_dp)
THEN
786 CALL pw_axpy(vxc00(ispin), fxc_rho(ispin), ak(istep))
788 IF (bl(istep) /= 0.0_dp)
THEN
789 CALL pw_axpy(vxc00(ispin), gxc_rho(ispin), bl(istep))
792 DO ispin = 1,
SIZE(vxc00)
793 CALL auxbas_pw_pool%give_back_pw(vxc00(ispin))
799 oeps1 = 1.0_dp/epsrho
800 oeps2 = 1.0_dp/(epsrho**2)
802 CALL pw_scale(fxc_rho(ispin), oeps1)
803 CALL pw_scale(gxc_rho(ispin), oeps2)
806 CALL timestop(handle)
808 END SUBROUTINE qs_fgxc_fgdiff
820 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
821 TYPE(pw_pool_type),
POINTER :: pw_pool
825 IF (
ASSOCIATED(fxc_rho))
THEN
826 DO ispin = 1,
SIZE(fxc_rho)
827 CALL pw_pool%give_back_pw(fxc_rho(ispin))
831 IF (
ASSOCIATED(fxc_tau))
THEN
832 DO ispin = 1,
SIZE(fxc_tau)
833 CALL pw_pool%give_back_pw(fxc_tau(ispin))
837 IF (
ASSOCIATED(gxc_rho))
THEN
838 DO ispin = 1,
SIZE(gxc_rho)
839 CALL pw_pool%give_back_pw(gxc_rho(ispin))
843 IF (
ASSOCIATED(gxc_tau))
THEN
844 DO ispin = 1,
SIZE(gxc_tau)
845 CALL pw_pool%give_back_pw(gxc_tau(ispin))
static GRID_HOST_DEVICE double fac(const int i)
Factorial function, e.g. fac(5) = 5! = 120.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Defines the basic variable types.
integer, parameter, public dp
container for various plainwaves related things
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
This module defines the grid data type and some basic operations on it.
logical function, public pw_grid_compare(grida, gridb)
Check if two pw_grids are equal.
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
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.
routines that build the integrals of the Fxc kernel calculated for the atomic density in the basis se...
subroutine, public fgxc_atom_diff(qs_env, rho0_atom_set, rho1_atom_set, rho2_atom_set, kind_set, xc_section, is_triplet, accuracy, epsrho)
...
subroutine, public fgxc_atom_calc(qs_env, rho0_atom_set, rho1_atom_set, rho2_atom_set, kind_set, xc_section, is_triplet, accuracy)
...
https://en.wikipedia.org/wiki/Finite_difference_coefficient
subroutine, public qs_fgxc_release(fxc_rho, fxc_tau, gxc_rho, gxc_tau, pw_pool)
...
subroutine, public qs_fgxc_create(qs_env, rho0_struct, rho1_struct, rho0_atom_set, xc_section, do_onecenter, is_triplet, spinflip, fxc_rho, fxc_tau, gxc_rho, gxc_tau, rhof_atom_set, rhog_atom_set, qs_kind_set)
...
Setup Routine for Fxc Potentials.
subroutine, public qs_fxc_fdiff(qs_env, rho0_struct, rho1_struct, xc_section, accuracy, fxc_rho, fxc_tau, is_triplet, spinflip)
...
subroutine, public qs_fxc_create(qs_env, rho0_struct, rho1_struct, rho0_atom_set, xc_section, do_onecenter, fxc_rho, fxc_tau, rho1_atom_set, do_scale, is_triplet, spinflip, no_weights, uf_grid_results, pw_env_ext, kind_set_external, para_env_external, compute_virial, virial_xc)
...
Define the quickstep kind type and their sub types.
methods of the rho structure (defined in qs_rho_types)
subroutine, public qs_rho_copy(rho_input, rho_output, auxbas_pw_pool, mspin, factor)
Allocate a density structure and fill it with data from an input structure SIZE(rho_input) == mspin =...
subroutine, public qs_rho_scale_and_add_b(rhoa, rhob, alpha, beta)
rhoa(2) = alpha*rhoa(2)+beta*rhob(1)
subroutine, public qs_rho_scale_and_add(rhoa, rhob, alpha, beta)
rhoa = alpha*rhoa+beta*rhob
subroutine, public qs_rho_transfer(rho_input, rho_output, in_pw_pool, out_pw_pool)
Allocate a density structure and fill it with data from an input structure Transfer all data to input...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
subroutine, public qs_rho_create(rho)
Allocates a new instance of rho.
subroutine, public qs_rho_release(rho_struct)
releases a rho_struct by decreasing the reference count by one and deallocating if it reaches 0 (to b...
subroutine, public qs_vxc_create(ks_env, rho_struct, xc_section, vxc_rho, vxc_tau, exc, just_energy, edisp, dispersion_env, adiabatic_rescale_factor, pw_env_external, native_skala_atom_force, qs_env_external, native_gapw_composite_override, native_skala_defer_to_atom_composite)
calculates and allocates the xc potential, already reducing it to the dependence on rho and the one o...
represent a group ofunctional derivatives
subroutine, public xc_dset_release(derivative_set)
releases a derivative set
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
subroutine, public xc_rho_set_update(rho_set, rho_r, rho_g, tau, needs, xc_deriv_method_id, xc_rho_smooth_id, pw_pool, spinflip)
updates the given rho set with the density given by rho_r (and rho_g). The rho set will contain the c...
Exchange and Correlation functional calculations.
subroutine, public xc_calc_2nd_deriv_analytical(v_xc, v_xc_tau, deriv_set, rho_set, rho1_set, pw_pool, xc_section, gapw, vxg, tddfpt_fac, compute_virial, virial_xc, spinflip)
Calculates the second derivative of E_xc at rho in the direction rho1 (if you see the second derivati...
subroutine, public xc_calc_3rd_deriv_analytical(v_xc, v_xc_tau, deriv_set, rho_set, rho1_set, pw_pool, xc_section, spinflip, gapw, vxg)
Calculates the third functional derivative of the exchange-correlation functional,...
subroutine, public xc_prep_3rd_deriv(deriv_set, rho_set, rho_r, pw_pool, weights, xc_section, tau_r, do_sf)
Prepare deriv_set for the calculation of the 3rd derivatives of the density functional....
contained for different pw related things
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Provides all information about a quickstep kind.
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
keeps the density in various representations, keeping track of which ones are valid.
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