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(
SIZE(fxc_rho_uf)), gxc_rho(
SIZE(gxc_rho_uf)))
238 CALL auxbas_pw_pool%create_pw(xc_g)
239 CALL xc_pw_pool%create_pw(xc_g_uf)
240 DO ispin = 1,
SIZE(fxc_rho)
241 CALL auxbas_pw_pool%create_pw(fxc_rho(ispin))
245 CALL xc_pw_pool%give_back_pw(fxc_rho_uf(ispin))
247 DO ispin = 1,
SIZE(gxc_rho)
248 CALL auxbas_pw_pool%create_pw(gxc_rho(ispin))
252 CALL xc_pw_pool%give_back_pw(gxc_rho_uf(ispin))
254 CALL xc_pw_pool%give_back_pw(xc_g_uf)
255 CALL auxbas_pw_pool%give_back_pw(xc_g)
257 DEALLOCATE (fxc_rho_uf, gxc_rho_uf)
259 NULLIFY (fxc_rho, gxc_rho)
263 ALLOCATE (fxc_tau(
SIZE(fxc_tau_uf)), gxc_tau(
SIZE(gxc_tau_uf)))
265 TYPE(pw_c1d_gs_type) :: xc_g, xc_g_uf
266 CALL auxbas_pw_pool%create_pw(xc_g)
267 CALL xc_pw_pool%create_pw(xc_g_uf)
268 DO ispin = 1,
SIZE(fxc_tau)
269 CALL auxbas_pw_pool%create_pw(fxc_tau(ispin))
270 CALL pw_transfer(fxc_tau_uf(ispin), xc_g_uf)
271 CALL pw_transfer(xc_g_uf, xc_g)
272 CALL pw_transfer(xc_g, fxc_tau(ispin))
273 CALL xc_pw_pool%give_back_pw(fxc_tau_uf(ispin))
275 DO ispin = 1,
SIZE(gxc_tau)
276 CALL auxbas_pw_pool%create_pw(gxc_tau(ispin))
277 CALL pw_transfer(gxc_tau_uf(ispin), xc_g_uf)
278 CALL pw_transfer(xc_g_uf, xc_g)
279 CALL pw_transfer(xc_g, gxc_tau(ispin))
280 CALL xc_pw_pool%give_back_pw(gxc_tau_uf(ispin))
282 CALL xc_pw_pool%give_back_pw(xc_g_uf)
283 CALL auxbas_pw_pool%give_back_pw(xc_g)
285 DEALLOCATE (fxc_tau_uf, gxc_tau_uf)
287 NULLIFY (fxc_tau, gxc_tau)
290 fxc_rho => fxc_rho_uf
291 fxc_tau => fxc_tau_uf
292 gxc_rho => gxc_rho_uf
293 gxc_tau => gxc_tau_uf
297 IF (
ASSOCIATED(rho_nlcc))
THEN
300 CALL pw_axpy(rho_nlcc, rho_r(ispin), factor)
301 CALL pw_axpy(rho_nlcc_g, rho_g(ispin), factor)
305 ELSE IF (analytic_2nd_deriv .AND. .NOT. analytic_3rd_deriv)
THEN
308 CALL get_qs_env(qs_env, xcint_weights=weights)
309 CALL qs_fgxc_gdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
310 order, eps_delta, is_triplet, spinflip, &
311 fxc_rho, fxc_tau, gxc_rho, gxc_tau)
313 ELSE IF (.NOT. (analytic_2nd_deriv .OR. analytic_3rd_deriv))
THEN
315 CALL qs_fgxc_fgdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
316 order, is_triplet, spinflip, &
317 fxc_rho, fxc_tau, gxc_rho, gxc_tau)
320 cpabort(
"EXC derivative option not available")
323 IF (do_onecenter)
THEN
324 IF (analytic_2nd_deriv .AND. analytic_3rd_deriv)
THEN
325 cpabort(
"Analytic 3rd EXC derivatives not available")
326 ELSE IF (analytic_2nd_deriv)
THEN
327 CALL fgxc_atom_diff(qs_env, rho0_atom_set, rhof_atom_set, rhog_atom_set, &
328 qs_kind_set, xc_section, is_triplet, order, eps_delta)
329 ELSE IF (analytic_3rd_deriv)
THEN
330 CALL cp_warn(__location__,
"XC Analytic 3rd derivatives cannot be combined with "// &
331 "numeric 2nd derivatives.")
332 cpabort(
"XC derivative options")
334 CALL fgxc_atom_calc(qs_env, rho0_atom_set, rhof_atom_set, rhog_atom_set, &
335 qs_kind_set, xc_section, is_triplet, order)
339 CALL timestop(handle)
362 SUBROUTINE qs_fgxc_analytic(rho0_struct, rho1_struct, xc_section, pw_pool, weights, &
363 is_triplet, spinflip, fxc_rho, fxc_tau, gxc_rho, gxc_tau)
365 TYPE(qs_rho_type),
POINTER :: rho0_struct, rho1_struct
366 TYPE(section_vals_type),
POINTER :: xc_section
367 TYPE(pw_pool_type),
POINTER :: pw_pool
368 TYPE(pw_r3d_rs_type),
POINTER :: weights
369 LOGICAL,
INTENT(IN) :: is_triplet, spinflip
370 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
372 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_fgxc_analytic'
374 INTEGER :: handle, ispin, nspins, spindim
375 INTEGER,
DIMENSION(2, 3) :: bo
376 LOGICAL :: do_sf, lsd
378 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho0_g, rho1_g
379 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho0_r, rho1_r, tau0_r, tau1_r
380 TYPE(section_vals_type),
POINTER :: xc_fun_section
381 TYPE(xc_derivative_set_type) :: deriv_set
382 TYPE(xc_rho_cflags_type) :: needs
383 TYPE(xc_rho_set_type) :: rho0_set, rho1_set
385 CALL timeset(routinen, handle)
388 cpassert(.NOT.
ASSOCIATED(fxc_rho))
389 cpassert(.NOT.
ASSOCIATED(fxc_tau))
390 cpassert(.NOT.
ASSOCIATED(gxc_rho))
391 cpassert(.NOT.
ASSOCIATED(gxc_tau))
392 cpassert(
ASSOCIATED(rho0_struct))
393 cpassert(
ASSOCIATED(rho1_struct))
395 cpassert(.NOT. is_triplet)
401 CALL qs_rho_get(rho0_struct, rho_r=rho0_r, rho_g=rho0_g, tau_r=tau0_r)
402 nspins =
SIZE(rho0_r)
406 CALL qs_rho_get(rho1_struct, rho_r=rho1_r, rho_g=rho1_g, tau_r=tau1_r)
410 IF (.NOT. (do_sf .OR. nspins == 1 .OR. nspins == 2))
THEN
411 cpabort(
"Analytic 3rd XC derivatives: unsupported spin case")
422 IF (nspins == 1)
THEN
427 xc_fun_section => section_vals_get_subs_vals(xc_section,
"XC_FUNCTIONAL")
428 needs = xc_functionals_get_needs(xc_fun_section, lsd, .true.)
431 ALLOCATE (fxc_rho(spindim), gxc_rho(nspins))
432 DO ispin = 1, spindim
433 CALL pw_pool%create_pw(fxc_rho(ispin))
434 CALL pw_zero(fxc_rho(ispin))
437 CALL pw_pool%create_pw(gxc_rho(ispin))
438 CALL pw_zero(gxc_rho(ispin))
441 IF (needs%tau .OR. needs%tau_spin)
THEN
442 IF (.NOT.
ASSOCIATED(tau1_r))
THEN
443 cpabort(
"Tau-dependent functionals requires allocated kinetic energy density grid")
445 ALLOCATE (fxc_tau(spindim), gxc_tau(nspins))
446 DO ispin = 1, spindim
447 CALL pw_pool%create_pw(fxc_tau(ispin))
448 CALL pw_zero(fxc_tau(ispin))
451 CALL pw_pool%create_pw(gxc_tau(ispin))
452 CALL pw_zero(gxc_tau(ispin))
465 CALL xc_prep_3rd_deriv(deriv_set, rho0_set, rho0_r, pw_pool, weights, &
466 xc_section, tau_r=tau0_r, do_sf=do_sf)
469 bo = rho1_r(1)%pw_grid%bounds_local
474 CALL xc_rho_set_create(rho1_set, bo, &
475 rho_cutoff=section_get_rval(xc_section,
"DENSITY_CUTOFF"), &
476 drho_cutoff=section_get_rval(xc_section,
"GRADIENT_CUTOFF"), &
477 tau_cutoff=section_get_rval(xc_section,
"TAU_CUTOFF"))
484 CALL xc_rho_set_update(rho1_set, rho1_r, rho1_g, tau1_r, needs, &
485 section_get_ival(xc_section,
"XC_GRID%XC_DERIV"), &
486 section_get_ival(xc_section,
"XC_GRID%XC_SMOOTH_RHO"), &
487 pw_pool, spinflip=do_sf)
497 CALL xc_calc_2nd_deriv_analytical(fxc_rho, fxc_tau, deriv_set, rho0_set, rho1_set, pw_pool, &
498 xc_section, .false., spinflip=do_sf, tddfpt_fac=
fac)
500 CALL xc_calc_3rd_deriv_analytical(gxc_rho, gxc_tau, deriv_set, rho0_set, rho1_set, pw_pool, &
501 xc_section, spinflip=do_sf)
503 CALL xc_dset_release(deriv_set)
504 CALL xc_rho_set_release(rho0_set)
505 CALL xc_rho_set_release(rho1_set)
507 CALL timestop(handle)
509 END SUBROUTINE qs_fgxc_analytic
526 SUBROUTINE qs_fgxc_gdiff(qs_env, rho0_struct, rho1_struct, xc_section, accuracy, epsrho, &
527 is_triplet, spinflip, fxc_rho, fxc_tau, gxc_rho, gxc_tau)
529 TYPE(qs_environment_type),
POINTER :: qs_env
530 TYPE(qs_rho_type),
POINTER :: rho0_struct, rho1_struct
531 TYPE(section_vals_type),
POINTER :: xc_section
532 INTEGER,
INTENT(IN) :: accuracy
533 REAL(kind=dp),
INTENT(IN) :: epsrho
534 LOGICAL,
INTENT(IN) :: is_triplet, spinflip
535 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
537 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_fgxc_gdiff'
539 INTEGER :: handle, ispin, istep, nspins, nstep
541 REAL(kind=dp) :: alpha, beta, exc, oeps1
542 REAL(kind=dp),
DIMENSION(-4:4) :: ak
543 TYPE(dft_control_type),
POINTER :: dft_control
544 TYPE(pw_env_type),
POINTER :: pw_env
545 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
546 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: v_tau_rspace, v_tau_rspaceb, vxc00, &
548 TYPE(qs_rho_type),
POINTER :: rhoin
549 TYPE(rho_atom_type),
DIMENSION(:),
POINTER :: rho0_atom_set, rho1_atom_set
551 CALL timeset(routinen, handle)
553 cpassert(.NOT.
ASSOCIATED(fxc_rho))
554 cpassert(.NOT.
ASSOCIATED(fxc_tau))
555 cpassert(.NOT.
ASSOCIATED(gxc_rho))
556 cpassert(.NOT.
ASSOCIATED(gxc_tau))
557 cpassert(
ASSOCIATED(rho0_struct))
558 cpassert(
ASSOCIATED(rho1_struct))
563 SELECT CASE (accuracy)
566 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
569 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
572 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
573 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
576 CALL get_qs_env(qs_env, dft_control=dft_control, pw_env=pw_env)
577 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
579 nspins = dft_control%nspins
583 CALL qs_fxc_create(qs_env, rho0_struct, rho1_struct, rho0_atom_set, xc_section, &
584 .false., fxc_rho, fxc_tau, rho1_atom_set, &
585 is_triplet=is_triplet, spinflip=do_sf)
587 CALL qs_fxc_fdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
588 accuracy, fxc_rho, fxc_tau, is_triplet)
591 DO istep = -nstep, nstep
593 IF (ak(istep) /= 0.0_dp)
THEN
595 beta = real(istep, kind=dp)*epsrho
598 CALL qs_rho_create(rhoin)
599 NULLIFY (vxc00, vxc00b, v_tau_rspace, v_tau_rspaceb)
600 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, nspins)
601 CALL qs_rho_scale_and_add(rhoin, rho1_struct, alpha, beta)
604 CALL qs_fxc_create(qs_env, rhoin, rho1_struct, rho0_atom_set, xc_section, &
605 .false., vxc00, v_tau_rspace, rho1_atom_set, &
606 is_triplet=is_triplet, spinflip=do_sf)
608 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, nspins)
609 CALL qs_rho_scale_and_add_b(rhoin, rho1_struct, alpha, beta)
610 CALL qs_fxc_create(qs_env, rhoin, rho1_struct, rho0_atom_set, xc_section, &
611 .false., vxc00b, v_tau_rspaceb, rho1_atom_set, &
612 is_triplet=is_triplet, spinflip=do_sf)
614 CALL qs_fxc_fdiff(qs_env, rhoin, rho1_struct, xc_section, accuracy, &
615 fxc_rho=vxc00, fxc_tau=v_tau_rspace, is_triplet=is_triplet)
617 CALL qs_rho_release(rhoin)
619 IF (.NOT.
ASSOCIATED(gxc_rho))
THEN
620 ALLOCATE (gxc_rho(nspins))
622 CALL auxbas_pw_pool%create_pw(gxc_rho(ispin))
623 CALL pw_zero(gxc_rho(ispin))
627 CALL pw_axpy(vxc00(1), gxc_rho(1), ak(istep))
628 CALL pw_axpy(vxc00b(1), gxc_rho(2), ak(istep))
631 CALL pw_axpy(vxc00(ispin), gxc_rho(ispin), ak(istep))
634 IF (
ASSOCIATED(v_tau_rspace))
THEN
635 IF (.NOT.
ASSOCIATED(gxc_tau))
THEN
636 ALLOCATE (gxc_tau(nspins))
638 CALL auxbas_pw_pool%create_pw(gxc_tau(ispin))
639 CALL pw_zero(gxc_tau(ispin))
643 CALL pw_axpy(v_tau_rspace(1), gxc_tau(1), ak(istep))
644 CALL pw_axpy(v_tau_rspaceb(1), gxc_tau(2), ak(istep))
647 CALL pw_axpy(v_tau_rspace(ispin), gxc_tau(ispin), ak(istep))
651 CALL qs_fgxc_release(vxc00, v_tau_rspace, vxc00b, v_tau_rspaceb, auxbas_pw_pool)
656 oeps1 = 1.0_dp/epsrho
658 CALL pw_scale(gxc_rho(ispin), oeps1)
660 IF (
ASSOCIATED(gxc_tau))
THEN
662 CALL pw_scale(gxc_tau(ispin), oeps1)
666 CALL timestop(handle)
668 END SUBROUTINE qs_fgxc_gdiff
684 SUBROUTINE qs_fgxc_fgdiff(qs_env, rho0_struct, rho1_struct, xc_section, &
685 accuracy, is_triplet, spinflip, &
686 fxc_rho, fxc_tau, gxc_rho, gxc_tau)
688 TYPE(qs_environment_type),
POINTER :: qs_env
689 TYPE(qs_rho_type),
POINTER :: rho0_struct, rho1_struct
690 TYPE(section_vals_type),
POINTER :: xc_section
691 INTEGER,
INTENT(IN) :: accuracy
692 LOGICAL,
INTENT(IN) :: is_triplet, spinflip
693 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
695 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_fgxc_fgdiff'
696 REAL(kind=dp),
PARAMETER :: epsrho = 5.e-4_dp
698 INTEGER :: handle, ispin, istep, nspins, nstep
699 REAL(kind=dp) :: alpha, beta, exc, oeps1, oeps2
700 REAL(kind=dp),
DIMENSION(-4:4) :: ak, bl
701 TYPE(dft_control_type),
POINTER :: dft_control
702 TYPE(pw_env_type),
POINTER :: pw_env
703 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
704 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: v_tau_rspace, vxc00
705 TYPE(qs_ks_env_type),
POINTER :: ks_env
706 TYPE(qs_rho_type),
POINTER :: rhoin
708 CALL timeset(routinen, handle)
710 cpassert(.NOT.
ASSOCIATED(fxc_rho))
711 cpassert(.NOT.
ASSOCIATED(fxc_tau))
712 cpassert(.NOT.
ASSOCIATED(gxc_rho))
713 cpassert(.NOT.
ASSOCIATED(gxc_tau))
714 cpassert(
ASSOCIATED(rho0_struct))
715 cpassert(
ASSOCIATED(rho1_struct))
718 cpassert(.NOT. spinflip)
722 SELECT CASE (accuracy)
725 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
726 bl(-2:2) = [-1.0_dp, 16.0_dp, -30.0_dp, 16.0_dp, -1.0_dp]/12.0_dp
729 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
730 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
733 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
734 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
735 bl(-4:4) = [-1.0_dp, 128.0_dp/9.0_dp, -112.0_dp, 896.0_dp, -14350.0_dp/9.0_dp, &
736 896.0_dp, -112.0_dp, 128.0_dp/9.0_dp, -1.0_dp]/560.0_dp
739 CALL get_qs_env(qs_env, ks_env=ks_env, dft_control=dft_control, pw_env=pw_env)
740 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
742 nspins = dft_control%nspins
745 DO istep = -nstep, nstep
748 beta = real(istep, kind=dp)*epsrho
751 CALL qs_rho_create(rhoin)
752 NULLIFY (vxc00, v_tau_rspace)
754 cpassert(nspins == 1)
756 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, 2)
758 CALL qs_rho_scale_and_add(rhoin, rho1_struct, alpha, 0.5_dp*beta)
759 CALL qs_vxc_create(ks_env, rhoin, xc_section, vxc00, v_tau_rspace, exc)
760 CALL pw_axpy(vxc00(2), vxc00(1), -1.0_dp)
762 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, nspins)
763 CALL qs_rho_scale_and_add(rhoin, rho1_struct, alpha, beta)
764 CALL qs_vxc_create(ks_env, rhoin, xc_section, vxc00, v_tau_rspace, exc)
766 CALL qs_rho_release(rhoin)
768 IF (.NOT.
ASSOCIATED(fxc_rho))
THEN
769 ALLOCATE (fxc_rho(nspins))
771 CALL auxbas_pw_pool%create_pw(fxc_rho(ispin))
772 CALL pw_zero(fxc_rho(ispin))
775 IF (.NOT.
ASSOCIATED(gxc_rho))
THEN
776 ALLOCATE (gxc_rho(nspins))
778 CALL auxbas_pw_pool%create_pw(gxc_rho(ispin))
779 CALL pw_zero(gxc_rho(ispin))
782 cpassert(.NOT.
ASSOCIATED(v_tau_rspace))
784 IF (ak(istep) /= 0.0_dp)
THEN
785 CALL pw_axpy(vxc00(ispin), fxc_rho(ispin), ak(istep))
787 IF (bl(istep) /= 0.0_dp)
THEN
788 CALL pw_axpy(vxc00(ispin), gxc_rho(ispin), bl(istep))
791 DO ispin = 1,
SIZE(vxc00)
792 CALL auxbas_pw_pool%give_back_pw(vxc00(ispin))
798 oeps1 = 1.0_dp/epsrho
799 oeps2 = 1.0_dp/(epsrho**2)
801 CALL pw_scale(fxc_rho(ispin), oeps1)
802 CALL pw_scale(gxc_rho(ispin), oeps2)
805 CALL timestop(handle)
807 END SUBROUTINE qs_fgxc_fgdiff
819 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho, fxc_tau, gxc_rho, gxc_tau
820 TYPE(pw_pool_type),
POINTER :: pw_pool
824 IF (
ASSOCIATED(fxc_rho))
THEN
825 DO ispin = 1,
SIZE(fxc_rho)
826 CALL pw_pool%give_back_pw(fxc_rho(ispin))
830 IF (
ASSOCIATED(fxc_tau))
THEN
831 DO ispin = 1,
SIZE(fxc_tau)
832 CALL pw_pool%give_back_pw(fxc_tau(ispin))
836 IF (
ASSOCIATED(gxc_rho))
THEN
837 DO ispin = 1,
SIZE(gxc_rho)
838 CALL pw_pool%give_back_pw(gxc_rho(ispin))
842 IF (
ASSOCIATED(gxc_tau))
THEN
843 DO ispin = 1,
SIZE(gxc_tau)
844 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_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, dispersion_env, compute_virial, virial_xc)
...
subroutine, public qs_fxc_fdiff(qs_env, rho0_struct, rho1_struct, xc_section, accuracy, fxc_rho, fxc_tau, is_triplet, spinflip)
...
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