64#include "./base/base_uses.f90"
74 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_fxc'
104 xc_section, do_onecenter, &
105 fxc_rho, fxc_tau, rho1_atom_set, &
106 do_scale, is_triplet, spinflip, no_weights, uf_grid_results, &
107 pw_env_ext, kind_set_external, para_env_external, &
108 dispersion_env, compute_virial, virial_xc)
111 TYPE(
qs_rho_type),
POINTER :: rho0_struct, rho1_struct
114 LOGICAL,
INTENT(IN) :: do_onecenter
117 LOGICAL,
INTENT(IN),
OPTIONAL :: do_scale, is_triplet, spinflip, &
118 no_weights, uf_grid_results
121 POINTER :: kind_set_external
124 LOGICAL,
INTENT(IN),
OPTIONAL :: compute_virial
125 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(INOUT), &
126 OPTIONAL :: virial_xc
128 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_fxc_create'
130 INTEGER :: handle, ispin, nspins, nsteps, order, vdw
131 LOGICAL :: do_virial, do_w, ret_uf, uf_grid, vdw_nl
132 REAL(kind=
dp) :: eps_delta, factor
137 TYPE(
pw_pool_type),
POINTER :: auxbas_pw_pool, xc_pw_pool
138 TYPE(
pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho_lo, fxc_rho_uf, fxc_tau_lo, &
139 fxc_tau_uf, fxc_vdw, rho1_r, rho_r
143 CALL timeset(routinen, handle)
146 IF (
PRESENT(compute_virial)) do_virial = compute_virial
148 CALL get_qs_env(qs_env, dft_control=dft_control)
150 IF (
PRESENT(pw_env_ext))
THEN
155 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, xc_pw_pool=xc_pw_pool)
156 uf_grid = .NOT.
pw_grid_compare(auxbas_pw_pool%pw_grid, xc_pw_pool%pw_grid)
158 nspins = dft_control%nspins
159 IF (
ASSOCIATED(fxc_rho))
THEN
160 cpassert(nspins ==
SIZE(fxc_rho))
162 IF (
ASSOCIATED(fxc_tau))
THEN
163 cpassert(nspins ==
SIZE(fxc_tau))
166 NULLIFY (rho_nlcc, rho_nlcc_g)
167 CALL get_qs_env(qs_env, rho_nlcc=rho_nlcc, rho_nlcc_g=rho_nlcc_g)
168 IF (
ASSOCIATED(rho_nlcc))
THEN
169 NULLIFY (rho_r, rho_g)
170 CALL qs_rho_get(rho0_struct, rho_r=rho_r, rho_g=rho_g)
173 CALL pw_axpy(rho_nlcc, rho_r(ispin), factor)
174 CALL pw_axpy(rho_nlcc_g, rho_g(ispin), factor)
179 IF (
PRESENT(no_weights)) do_w = .NOT. no_weights
181 CALL get_qs_env(qs_env, xcint_weights=weights)
186 NULLIFY (fxc_rho_lo, fxc_tau_lo)
188 IF (
PRESENT(uf_grid_results))
THEN
189 ret_uf = uf_grid_results
194 IF (
ASSOCIATED(weights))
THEN
195 ALLOCATE (weights_uf)
196 CALL xc_pw_pool%create_pw(weights_uf)
199 CALL auxbas_pw_pool%create_pw(weights_g)
200 CALL xc_pw_pool%create_pw(weights_g_uf)
204 CALL xc_pw_pool%give_back_pw(weights_g_uf)
205 CALL auxbas_pw_pool%give_back_pw(weights_g)
209 ALLOCATE (rho0_uf, rho1_uf)
215 NULLIFY (fxc_rho_uf, fxc_tau_uf)
216 CALL qs_fxc_calculate(rho0_uf, rho1_uf, xc_section, weights_uf, xc_pw_pool, &
217 fxc_rho_uf, fxc_tau_uf, &
218 is_triplet=is_triplet, spinflip=spinflip, &
219 compute_virial=do_virial, virial_xc=virial_xc)
223 DEALLOCATE (rho0_uf, rho1_uf)
224 IF (
ASSOCIATED(weights_uf))
THEN
225 CALL xc_pw_pool%give_back_pw(weights_uf)
226 DEALLOCATE (weights_uf)
229 fxc_rho_lo => fxc_rho_uf
230 fxc_tau_lo => fxc_tau_uf
232 IF (
ASSOCIATED(fxc_rho_uf))
THEN
233 ALLOCATE (fxc_rho_lo(nspins))
235 CALL auxbas_pw_pool%create_pw(fxc_rho_lo(ispin))
238 CALL auxbas_pw_pool%create_pw(fxc_g)
239 CALL xc_pw_pool%create_pw(fxc_g_uf)
243 CALL xc_pw_pool%give_back_pw(fxc_g_uf)
244 CALL auxbas_pw_pool%give_back_pw(fxc_g)
246 CALL xc_pw_pool%give_back_pw(fxc_rho_uf(ispin))
248 DEALLOCATE (fxc_rho_uf)
250 IF (
ASSOCIATED(fxc_tau_uf))
THEN
251 ALLOCATE (fxc_tau_lo(nspins))
253 CALL auxbas_pw_pool%create_pw(fxc_tau_lo(ispin))
255 TYPE(pw_c1d_gs_type) :: fxc_g, fxc_g_uf
256 CALL auxbas_pw_pool%create_pw(fxc_g)
257 CALL xc_pw_pool%create_pw(fxc_g_uf)
258 CALL pw_transfer(fxc_tau_uf(ispin), fxc_g_uf)
259 CALL pw_transfer(fxc_g_uf, fxc_g)
260 CALL pw_transfer(fxc_g, fxc_tau_lo(ispin))
261 CALL xc_pw_pool%give_back_pw(fxc_g_uf)
262 CALL auxbas_pw_pool%give_back_pw(fxc_g)
264 CALL xc_pw_pool%give_back_pw(fxc_tau_uf(ispin))
270 CALL qs_fxc_calculate(rho0_struct, rho1_struct, xc_section, weights, auxbas_pw_pool, &
271 fxc_rho_lo, fxc_tau_lo, &
272 is_triplet=is_triplet, spinflip=spinflip, &
273 compute_virial=do_virial, virial_xc=virial_xc)
278 IF (
PRESENT(dispersion_env))
THEN
279 CALL section_vals_val_get(xc_section,
"VDW_POTENTIAL%POTENTIAL_TYPE", i_val=vdw)
280 vdw_nl = (vdw == xc_vdw_fun_nonloc)
282 nsteps = section_get_ival(xc_section,
"NSTEPS")
284 eps_delta = section_get_rval(xc_section,
"STEP_SIZE")
285 CALL qs_rho_get(rho1_struct, rho_r=rho1_r)
286 ALLOCATE (fxc_vdw(nspins))
288 CALL auxbas_pw_pool%create_pw(fxc_vdw(ispin))
290 CALL qs_fxc_nlvdw_fdiff(qs_env, dispersion_env, rho_r, rho1_r, &
291 order, eps_delta, fxc_vdw)
296 IF (
ASSOCIATED(rho_nlcc))
THEN
299 CALL pw_axpy(rho_nlcc, rho_r(ispin), factor)
300 CALL pw_axpy(rho_nlcc_g, rho_g(ispin), factor)
305 IF (
ASSOCIATED(fxc_rho))
THEN
306 DO ispin = 1, min(
SIZE(fxc_rho_lo),
SIZE(fxc_rho))
307 CALL pw_transfer(fxc_rho_lo(ispin), fxc_rho(ispin))
309 DO ispin = 1,
SIZE(fxc_rho_lo)
310 CALL auxbas_pw_pool%give_back_pw(fxc_rho_lo(ispin))
312 DEALLOCATE (fxc_rho_lo)
314 fxc_rho => fxc_rho_lo
316 IF (
ASSOCIATED(fxc_tau))
THEN
317 IF (
ASSOCIATED(fxc_tau_lo))
THEN
318 DO ispin = 1, min(
SIZE(fxc_tau_lo),
SIZE(fxc_tau))
319 CALL pw_transfer(fxc_tau_lo(ispin), fxc_tau(ispin))
321 DO ispin = 1,
SIZE(fxc_tau_lo)
322 CALL auxbas_pw_pool%give_back_pw(fxc_tau_lo(ispin))
324 DEALLOCATE (fxc_tau_lo)
327 CALL pw_zero(fxc_tau(ispin))
331 fxc_tau => fxc_tau_lo
337 CALL pw_axpy(fxc_vdw(ispin), fxc_rho(ispin), 1.0_dp)
338 CALL auxbas_pw_pool%give_back_pw(fxc_vdw(ispin))
343 IF (do_onecenter)
THEN
344 CALL fxc_atom_calc(qs_env, rho0_atom_set, rho1_atom_set, xc_section, &
345 do_scale=do_scale, do_triplet=is_triplet, do_sf=spinflip, &
346 para_env_ext=para_env_external, &
347 kind_set_external=kind_set_external)
350 CALL timestop(handle)
368 SUBROUTINE qs_fxc_calculate(rho0, rho1, xc_section, weights, auxbas_pw_pool, &
369 fxc_rho, fxc_tau, is_triplet, spinflip, &
370 compute_virial, virial_xc)
372 TYPE(qs_rho_type),
POINTER :: rho0, rho1
373 TYPE(section_vals_type),
POINTER :: xc_section
374 TYPE(pw_r3d_rs_type),
POINTER :: weights
375 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
376 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho, fxc_tau
377 LOGICAL,
INTENT(IN),
OPTIONAL :: is_triplet, spinflip, compute_virial
378 REAL(kind=dp),
DIMENSION(3, 3),
INTENT(INOUT), &
379 OPTIONAL :: virial_xc
381 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_fxc_calculate'
383 INTEGER :: handle, ispin, mspins, nspins
384 INTEGER,
DIMENSION(2, 3) :: bo
385 LOGICAL :: do_analytic, do_sf, do_triplet, &
387 REAL(kind=dp),
DIMENSION(:, :, :, :),
POINTER :: vxg
388 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho0_g, rho1_g
389 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho0_r, rho1_r, tau0_r, tau1_r
390 TYPE(qs_rho_type),
POINTER :: rhot0, rhot1
391 TYPE(section_vals_type),
POINTER :: xc_fun_section
392 TYPE(xc_derivative_set_type) :: xc_deriv_set
393 TYPE(xc_rho_cflags_type) :: needs
394 TYPE(xc_rho_set_type) :: rho0_set, rho1_set
396 CALL timeset(routinen, handle)
399 IF (
PRESENT(is_triplet)) do_triplet = is_triplet
402 IF (
PRESENT(spinflip)) do_sf = spinflip
405 IF (
PRESENT(compute_virial)) do_virial = compute_virial
407 do_analytic = section_get_lval(xc_section,
"2ND_DERIV_ANALYTICAL")
409 CALL qs_rho_get(rho0, rho_r=rho0_r, rho_g=rho0_g, tau_r=tau0_r)
410 CALL qs_rho_get(rho1, rho_r=rho1_r, tau_r=tau1_r)
413 mspins =
SIZE(rho0_r)
414 nspins =
SIZE(rho0_r)
416 IF (nspins == 1 .AND. do_triplet)
THEN
425 cpassert(.NOT.
ASSOCIATED(fxc_rho))
426 cpassert(.NOT.
ASSOCIATED(fxc_tau))
427 xc_fun_section => section_vals_get_subs_vals(xc_section,
"XC_FUNCTIONAL")
428 needs = xc_functionals_get_needs(xc_fun_section, lsd, .true.)
429 ALLOCATE (fxc_rho(mspins))
431 CALL auxbas_pw_pool%create_pw(fxc_rho(ispin))
432 CALL pw_zero(fxc_rho(ispin))
434 IF (needs%tau .OR. needs%tau_spin)
THEN
435 IF (.NOT.
ASSOCIATED(tau1_r))
THEN
436 cpabort(
"Tau-dependent functionals requires allocated kinetic energy density grid")
438 ALLOCATE (fxc_tau(mspins))
440 CALL auxbas_pw_pool%create_pw(fxc_tau(ispin))
441 CALL pw_zero(fxc_tau(ispin))
445 IF (mspins == 1 .AND. do_triplet)
THEN
448 CALL qs_rho_create(rhot0)
449 CALL qs_rho_copy(rho0, rhot0, auxbas_pw_pool, 2, factor=2.0_dp)
452 CALL qs_rho_create(rhot1)
453 CALL qs_rho_copy(rho1, rhot1, auxbas_pw_pool, 2, factor=2.0_dp)
455 CALL qs_rho_get(rhot0, rho_r=rho0_r, rho_g=rho0_g, tau_r=tau0_r)
456 CALL qs_rho_get(rhot1, rho_r=rho1_r, tau_r=tau1_r)
458 CALL xc_prep_2nd_deriv(xc_deriv_set, rho0_set, rho0_r, auxbas_pw_pool, weights, &
459 xc_section=xc_section, tau_r=tau0_r)
460 bo = rho1_r(1)%pw_grid%bounds_local
462 CALL xc_rho_set_create(rho1_set, bo, &
463 rho_cutoff=section_get_rval(xc_section,
"DENSITY_CUTOFF"), &
464 drho_cutoff=section_get_rval(xc_section,
"GRADIENT_CUTOFF"), &
465 tau_cutoff=section_get_rval(xc_section,
"TAU_CUTOFF"))
468 CALL xc_rho_set_update(rho1_set, rho1_r, rho1_g, tau1_r, needs, &
469 section_get_ival(xc_section,
"XC_GRID%XC_DERIV"), &
470 section_get_ival(xc_section,
"XC_GRID%XC_SMOOTH_RHO"), &
471 auxbas_pw_pool, spinflip=do_sf)
473 CALL xc_prep_2nd_deriv(xc_deriv_set, rho0_set, rho0_r, auxbas_pw_pool, weights, &
474 xc_section=xc_section, tau_r=tau0_r)
475 bo = rho1_r(1)%pw_grid%bounds_local
477 CALL xc_rho_set_create(rho1_set, bo, &
478 rho_cutoff=section_get_rval(xc_section,
"DENSITY_CUTOFF"), &
479 drho_cutoff=section_get_rval(xc_section,
"GRADIENT_CUTOFF"), &
480 tau_cutoff=section_get_rval(xc_section,
"TAU_CUTOFF"))
483 CALL xc_rho_set_update(rho1_set, rho1_r, rho1_g, tau1_r, needs, &
484 section_get_ival(xc_section,
"XC_GRID%XC_DERIV"), &
485 section_get_ival(xc_section,
"XC_GRID%XC_SMOOTH_RHO"), &
486 auxbas_pw_pool, spinflip=do_sf)
489 IF (mspins == 1 .AND. do_triplet .AND. do_analytic)
THEN
491 CALL xc_calc_2nd_deriv_analytical(fxc_rho, fxc_tau, xc_deriv_set, rho0_set, &
492 rho1_set, auxbas_pw_pool, xc_section, &
493 gapw=.false., vxg=vxg, tddfpt_fac=-1.0_dp, spinflip=do_sf, &
494 compute_virial=compute_virial, virial_xc=virial_xc)
496 ELSE IF (do_analytic)
THEN
498 CALL xc_calc_2nd_deriv_analytical(fxc_rho, fxc_tau, xc_deriv_set, rho0_set, &
499 rho1_set, auxbas_pw_pool, xc_section, &
500 gapw=.false., vxg=vxg, spinflip=do_sf, &
501 compute_virial=compute_virial, virial_xc=virial_xc)
505 CALL xc_calc_2nd_deriv_numerical(fxc_rho, fxc_tau, rho0_set, rho1_r, rho1_g, tau1_r, &
506 auxbas_pw_pool, weights, xc_section, &
507 do_triplet, compute_virial, virial_xc, xc_deriv_set)
511 IF (mspins == 1 .AND. do_triplet)
THEN
512 CALL qs_rho_release(rhot0)
514 CALL qs_rho_release(rhot1)
518 CALL xc_dset_release(xc_deriv_set)
519 CALL xc_rho_set_release(rho0_set)
520 CALL xc_rho_set_release(rho1_set)
522 CALL timestop(handle)
524 END SUBROUTINE qs_fxc_calculate
536 SUBROUTINE qs_fxc_prep(qs_env, rho0_struct, xc_rho_set, xc_deriv_set, &
537 xc_section, pw_env_ext, is_triplet)
539 TYPE(qs_environment_type),
POINTER :: qs_env
540 TYPE(qs_rho_type),
POINTER :: rho0_struct
541 TYPE(xc_rho_set_type) :: xc_rho_set
542 TYPE(xc_derivative_set_type) :: xc_deriv_set
543 TYPE(section_vals_type),
POINTER :: xc_section
544 TYPE(pw_env_type),
OPTIONAL,
POINTER :: pw_env_ext
545 LOGICAL,
INTENT(IN),
OPTIONAL :: is_triplet
547 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_fxc_prep'
549 INTEGER :: handle, ispin, nspins
551 REAL(kind=dp) :: factor
552 TYPE(dft_control_type),
POINTER :: dft_control
553 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g
554 TYPE(pw_c1d_gs_type),
POINTER :: rho_nlcc_g
555 TYPE(pw_env_type),
POINTER :: pw_env
556 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool, xc_pw_pool
557 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r
558 TYPE(pw_r3d_rs_type),
POINTER :: rho_nlcc, weights, weights_uf
559 TYPE(qs_rho_type),
POINTER :: rho0_uf
561 CALL timeset(routinen, handle)
563 CALL get_qs_env(qs_env, dft_control=dft_control)
565 IF (
PRESENT(pw_env_ext))
THEN
568 CALL get_qs_env(qs_env, pw_env=pw_env)
570 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, xc_pw_pool=xc_pw_pool)
571 uf_grid = .NOT. pw_grid_compare(auxbas_pw_pool%pw_grid, xc_pw_pool%pw_grid)
573 nspins = dft_control%nspins
575 NULLIFY (rho_nlcc, rho_nlcc_g)
576 CALL get_qs_env(qs_env, rho_nlcc=rho_nlcc, rho_nlcc_g=rho_nlcc_g)
577 IF (
ASSOCIATED(rho_nlcc))
THEN
578 NULLIFY (rho_r, rho_g)
579 CALL qs_rho_get(rho0_struct, rho_r=rho_r, rho_g=rho_g)
582 CALL pw_axpy(rho_nlcc, rho_r(ispin), factor)
583 CALL pw_axpy(rho_nlcc_g, rho_g(ispin), factor)
588 CALL get_qs_env(qs_env, xcint_weights=weights)
592 IF (
ASSOCIATED(weights))
THEN
593 ALLOCATE (weights_uf)
594 CALL xc_pw_pool%create_pw(weights_uf)
596 TYPE(pw_c1d_gs_type) :: weights_g, weights_g_uf
597 CALL auxbas_pw_pool%create_pw(weights_g)
598 CALL xc_pw_pool%create_pw(weights_g_uf)
599 CALL pw_transfer(weights, weights_g)
600 CALL pw_transfer(weights_g, weights_g_uf)
601 CALL pw_transfer(weights_g_uf, weights_uf)
602 CALL xc_pw_pool%give_back_pw(weights_g_uf)
603 CALL auxbas_pw_pool%give_back_pw(weights_g)
608 CALL qs_rho_create(rho0_uf)
609 CALL qs_rho_transfer(rho0_struct, rho0_uf, auxbas_pw_pool, xc_pw_pool)
611 CALL qs_fxc_deriv(rho0_uf, xc_rho_set, xc_deriv_set, &
612 xc_section, weights_uf, xc_pw_pool, is_triplet)
614 CALL qs_rho_release(rho0_uf)
616 IF (
ASSOCIATED(weights_uf))
THEN
617 CALL xc_pw_pool%give_back_pw(weights_uf)
618 DEALLOCATE (weights_uf)
621 CALL qs_fxc_deriv(rho0_struct, xc_rho_set, xc_deriv_set, &
622 xc_section, weights, auxbas_pw_pool, is_triplet)
626 IF (
ASSOCIATED(rho_nlcc))
THEN
629 CALL pw_axpy(rho_nlcc, rho_r(ispin), factor)
630 CALL pw_axpy(rho_nlcc_g, rho_g(ispin), factor)
634 CALL timestop(handle)
648 SUBROUTINE qs_fxc_deriv(rho0, xc_rho_set, xc_deriv_set, xc_section, weights, auxbas_pw_pool, &
651 TYPE(qs_rho_type),
POINTER :: rho0
652 TYPE(xc_rho_set_type) :: xc_rho_set
653 TYPE(xc_derivative_set_type) :: xc_deriv_set
654 TYPE(section_vals_type),
POINTER :: xc_section
655 TYPE(pw_r3d_rs_type),
POINTER :: weights
656 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
657 LOGICAL,
INTENT(IN) :: is_triplet
659 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_fxc_deriv'
662 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho0_r, tau0_r
663 TYPE(qs_rho_type),
POINTER :: rhot0
665 CALL timeset(routinen, handle)
667 NULLIFY (rho0_r, tau0_r)
671 CALL qs_rho_create(rhot0)
672 CALL qs_rho_copy(rho0, rhot0, auxbas_pw_pool, 2, factor=2.0_dp)
673 CALL qs_rho_get(rhot0, rho_r=rho0_r, tau_r=tau0_r)
674 CALL xc_prep_2nd_deriv(xc_deriv_set, xc_rho_set, rho0_r, auxbas_pw_pool, weights, &
675 xc_section=xc_section, tau_r=tau0_r)
676 CALL qs_rho_release(rhot0)
679 CALL qs_rho_get(rho0, rho_r=rho0_r, tau_r=tau0_r)
680 CALL xc_prep_2nd_deriv(xc_deriv_set, xc_rho_set, rho0_r, auxbas_pw_pool, weights, &
681 xc_section=xc_section, tau_r=tau0_r)
684 CALL timestop(handle)
686 END SUBROUTINE qs_fxc_deriv
709 SUBROUTINE qs_fxc_apply(qs_env, xc_deriv_set, xc_rho_set, rho1_struct, rho0_atom_set, &
710 xc_section, do_onecenter, fxc_rho, fxc_tau, rho1_atom_set, &
711 do_scale, is_triplet, spinflip, pw_env_ext, &
712 kind_set_external, para_env_external, compute_virial, virial_xc)
714 TYPE(qs_environment_type),
POINTER :: qs_env
715 TYPE(xc_derivative_set_type) :: xc_deriv_set
716 TYPE(xc_rho_set_type) :: xc_rho_set
717 TYPE(qs_rho_type),
POINTER :: rho1_struct
718 TYPE(rho_atom_type),
DIMENSION(:),
POINTER :: rho0_atom_set
719 TYPE(section_vals_type),
POINTER :: xc_section
720 LOGICAL,
INTENT(IN) :: do_onecenter
721 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho, fxc_tau
722 TYPE(rho_atom_type),
DIMENSION(:),
POINTER :: rho1_atom_set
723 LOGICAL,
INTENT(IN),
OPTIONAL :: do_scale, is_triplet, spinflip
724 TYPE(pw_env_type),
OPTIONAL,
POINTER :: pw_env_ext
725 TYPE(qs_kind_type),
DIMENSION(:),
OPTIONAL, &
726 POINTER :: kind_set_external
727 TYPE(mp_para_env_type),
INTENT(IN),
OPTIONAL :: para_env_external
728 LOGICAL,
INTENT(IN),
OPTIONAL :: compute_virial
729 REAL(kind=dp),
DIMENSION(3, 3),
INTENT(INOUT), &
730 OPTIONAL :: virial_xc
732 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_fxc_apply'
734 INTEGER :: handle, ispin, nspins
735 LOGICAL :: do_virial, uf_grid
736 TYPE(dft_control_type),
POINTER :: dft_control
737 TYPE(pw_env_type),
POINTER :: pw_env
738 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool, xc_pw_pool
739 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho_lo, fxc_rho_uf, fxc_tau_lo, &
741 TYPE(pw_r3d_rs_type),
POINTER :: weights, weights_uf
742 TYPE(qs_rho_type),
POINTER :: rho1_uf
744 CALL timeset(routinen, handle)
747 IF (
PRESENT(compute_virial)) do_virial = compute_virial
749 CALL get_qs_env(qs_env, dft_control=dft_control)
751 IF (
PRESENT(pw_env_ext))
THEN
754 CALL get_qs_env(qs_env, pw_env=pw_env)
756 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, xc_pw_pool=xc_pw_pool)
757 uf_grid = .NOT. pw_grid_compare(auxbas_pw_pool%pw_grid, xc_pw_pool%pw_grid)
759 nspins = dft_control%nspins
760 IF (
ASSOCIATED(fxc_rho))
THEN
761 cpassert(nspins ==
SIZE(fxc_rho))
763 IF (
ASSOCIATED(fxc_tau))
THEN
764 cpassert(nspins ==
SIZE(fxc_tau))
767 CALL get_qs_env(qs_env, xcint_weights=weights)
769 NULLIFY (fxc_rho_lo, fxc_tau_lo)
772 IF (
ASSOCIATED(weights))
THEN
773 ALLOCATE (weights_uf)
774 CALL xc_pw_pool%create_pw(weights_uf)
776 TYPE(pw_c1d_gs_type) :: weights_g, weights_g_uf
777 CALL auxbas_pw_pool%create_pw(weights_g)
778 CALL xc_pw_pool%create_pw(weights_g_uf)
779 CALL pw_transfer(weights, weights_g)
780 CALL pw_transfer(weights_g, weights_g_uf)
781 CALL pw_transfer(weights_g_uf, weights_uf)
782 CALL xc_pw_pool%give_back_pw(weights_g_uf)
783 CALL auxbas_pw_pool%give_back_pw(weights_g)
788 CALL qs_rho_create(rho1_uf)
789 CALL qs_rho_transfer(rho1_struct, rho1_uf, auxbas_pw_pool, xc_pw_pool)
791 NULLIFY (fxc_rho_uf, fxc_tau_uf)
792 CALL qs_fxc_eval(xc_deriv_set, xc_rho_set, rho1_uf, xc_section, &
793 weights_uf, xc_pw_pool, fxc_rho_uf, fxc_tau_uf, &
794 is_triplet=is_triplet, spinflip=spinflip, &
795 compute_virial=do_virial, virial_xc=virial_xc)
797 CALL qs_rho_release(rho1_uf)
799 IF (
ASSOCIATED(weights_uf))
THEN
800 CALL xc_pw_pool%give_back_pw(weights_uf)
801 DEALLOCATE (weights_uf)
803 IF (
ASSOCIATED(fxc_rho_uf))
THEN
804 ALLOCATE (fxc_rho_lo(nspins))
806 CALL auxbas_pw_pool%create_pw(fxc_rho_lo(ispin))
808 TYPE(pw_c1d_gs_type) :: fxc_g, fxc_g_uf
809 CALL auxbas_pw_pool%create_pw(fxc_g)
810 CALL xc_pw_pool%create_pw(fxc_g_uf)
811 CALL pw_transfer(fxc_rho_uf(ispin), fxc_g_uf)
812 CALL pw_transfer(fxc_g_uf, fxc_g)
813 CALL pw_transfer(fxc_g, fxc_rho_lo(ispin))
814 CALL xc_pw_pool%give_back_pw(fxc_g_uf)
815 CALL auxbas_pw_pool%give_back_pw(fxc_g)
817 CALL xc_pw_pool%give_back_pw(fxc_rho_uf(ispin))
819 DEALLOCATE (fxc_rho_uf)
821 IF (
ASSOCIATED(fxc_tau_uf))
THEN
822 ALLOCATE (fxc_tau_lo(nspins))
824 CALL auxbas_pw_pool%create_pw(fxc_tau_lo(ispin))
826 TYPE(pw_c1d_gs_type) :: fxc_g, fxc_g_uf
827 CALL auxbas_pw_pool%create_pw(fxc_g)
828 CALL xc_pw_pool%create_pw(fxc_g_uf)
829 CALL pw_transfer(fxc_tau_uf(ispin), fxc_g_uf)
830 CALL pw_transfer(fxc_g_uf, fxc_g)
831 CALL pw_transfer(fxc_g, fxc_tau_lo(ispin))
832 CALL xc_pw_pool%give_back_pw(fxc_g_uf)
833 CALL auxbas_pw_pool%give_back_pw(fxc_g)
835 CALL xc_pw_pool%give_back_pw(fxc_tau_uf(ispin))
840 CALL qs_fxc_eval(xc_deriv_set, xc_rho_set, rho1_struct, xc_section, &
841 weights, auxbas_pw_pool, fxc_rho_lo, fxc_tau_lo, &
842 is_triplet=is_triplet, spinflip=spinflip, &
843 compute_virial=do_virial, virial_xc=virial_xc)
847 IF (
ASSOCIATED(fxc_rho))
THEN
848 DO ispin = 1, min(
SIZE(fxc_rho_lo),
SIZE(fxc_rho))
849 CALL pw_transfer(fxc_rho_lo(ispin), fxc_rho(ispin))
851 DO ispin = 1,
SIZE(fxc_rho_lo)
852 CALL auxbas_pw_pool%give_back_pw(fxc_rho_lo(ispin))
854 DEALLOCATE (fxc_rho_lo)
856 fxc_rho => fxc_rho_lo
858 IF (
ASSOCIATED(fxc_tau))
THEN
859 IF (
ASSOCIATED(fxc_tau_lo))
THEN
860 DO ispin = 1, min(
SIZE(fxc_tau_lo),
SIZE(fxc_tau))
861 CALL pw_transfer(fxc_tau_lo(ispin), fxc_tau(ispin))
863 DO ispin = 1,
SIZE(fxc_tau_lo)
864 CALL auxbas_pw_pool%give_back_pw(fxc_tau_lo(ispin))
866 DEALLOCATE (fxc_tau_lo)
869 CALL pw_zero(fxc_tau(ispin))
873 fxc_tau => fxc_tau_lo
876 IF (do_onecenter)
THEN
877 CALL fxc_atom_calc(qs_env, rho0_atom_set, rho1_atom_set, xc_section, &
878 do_scale=do_scale, do_triplet=is_triplet, do_sf=spinflip, &
879 para_env_ext=para_env_external, &
880 kind_set_external=kind_set_external)
883 CALL timestop(handle)
902 SUBROUTINE qs_fxc_eval(xc_deriv_set, xc_rho_set, rho1, xc_section, weights, auxbas_pw_pool, &
903 fxc_rho, fxc_tau, is_triplet, spinflip, &
904 compute_virial, virial_xc)
906 TYPE(xc_derivative_set_type) :: xc_deriv_set
907 TYPE(xc_rho_set_type) :: xc_rho_set
908 TYPE(qs_rho_type),
POINTER :: rho1
909 TYPE(section_vals_type),
POINTER :: xc_section
910 TYPE(pw_r3d_rs_type),
POINTER :: weights
911 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
912 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho, fxc_tau
913 LOGICAL,
INTENT(IN),
OPTIONAL :: is_triplet, spinflip, compute_virial
914 REAL(kind=dp),
DIMENSION(3, 3),
INTENT(INOUT), &
915 OPTIONAL :: virial_xc
917 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_fxc_eval'
919 INTEGER :: handle, ispin, mspins, nspins
920 INTEGER,
DIMENSION(2, 3) :: bo
921 LOGICAL :: do_analytic, do_sf, do_triplet, &
923 REAL(kind=dp),
DIMENSION(:, :, :, :),
POINTER :: vxg
924 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho1_g
925 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho1_r, tau1_r
926 TYPE(qs_rho_type),
POINTER :: rhot1
927 TYPE(section_vals_type),
POINTER :: xc_fun_section
928 TYPE(xc_rho_cflags_type) :: needs
929 TYPE(xc_rho_set_type) :: rho1_set
931 CALL timeset(routinen, handle)
934 IF (
PRESENT(is_triplet)) do_triplet = is_triplet
937 IF (
PRESENT(spinflip)) do_sf = spinflip
940 IF (
PRESENT(compute_virial)) do_virial = compute_virial
942 do_analytic = section_get_lval(xc_section,
"2ND_DERIV_ANALYTICAL")
944 CALL qs_rho_get(rho1, rho_r=rho1_r, tau_r=tau1_r)
947 mspins =
SIZE(rho1_r)
948 nspins =
SIZE(rho1_r)
950 IF (nspins == 1 .AND. do_triplet)
THEN
959 cpassert(.NOT.
ASSOCIATED(fxc_rho))
960 cpassert(.NOT.
ASSOCIATED(fxc_tau))
961 xc_fun_section => section_vals_get_subs_vals(xc_section,
"XC_FUNCTIONAL")
962 needs = xc_functionals_get_needs(xc_fun_section, lsd, .true.)
963 ALLOCATE (fxc_rho(mspins))
965 CALL auxbas_pw_pool%create_pw(fxc_rho(ispin))
966 CALL pw_zero(fxc_rho(ispin))
968 IF (needs%tau .OR. needs%tau_spin)
THEN
969 IF (.NOT.
ASSOCIATED(tau1_r))
THEN
970 cpabort(
"Tau-dependent functionals requires allocated kinetic energy density grid")
972 ALLOCATE (fxc_tau(mspins))
974 CALL auxbas_pw_pool%create_pw(fxc_tau(ispin))
975 CALL pw_zero(fxc_tau(ispin))
979 IF (mspins == 1 .AND. do_triplet)
THEN
982 CALL qs_rho_create(rhot1)
983 CALL qs_rho_copy(rho1, rhot1, auxbas_pw_pool, 2, factor=2.0_dp)
985 CALL qs_rho_get(rhot1, rho_r=rho1_r, tau_r=tau1_r)
988 bo = rho1_r(1)%pw_grid%bounds_local
990 CALL xc_rho_set_create(rho1_set, bo, &
991 rho_cutoff=section_get_rval(xc_section,
"DENSITY_CUTOFF"), &
992 drho_cutoff=section_get_rval(xc_section,
"GRADIENT_CUTOFF"), &
993 tau_cutoff=section_get_rval(xc_section,
"TAU_CUTOFF"))
996 CALL xc_rho_set_update(rho1_set, rho1_r, rho1_g, tau1_r, needs, &
997 section_get_ival(xc_section,
"XC_GRID%XC_DERIV"), &
998 section_get_ival(xc_section,
"XC_GRID%XC_SMOOTH_RHO"), &
999 auxbas_pw_pool, spinflip=do_sf)
1001 IF (mspins == 1 .AND. do_triplet .AND. do_analytic)
THEN
1003 CALL xc_calc_2nd_deriv_analytical(fxc_rho, fxc_tau, xc_deriv_set, xc_rho_set, &
1004 rho1_set, auxbas_pw_pool, xc_section, &
1005 gapw=.false., vxg=vxg, tddfpt_fac=-1.0_dp, spinflip=do_sf, &
1006 compute_virial=compute_virial, virial_xc=virial_xc)
1008 ELSE IF (do_analytic)
THEN
1010 CALL xc_calc_2nd_deriv_analytical(fxc_rho, fxc_tau, xc_deriv_set, xc_rho_set, &
1011 rho1_set, auxbas_pw_pool, xc_section, &
1012 gapw=.false., vxg=vxg, spinflip=do_sf, &
1013 compute_virial=compute_virial, virial_xc=virial_xc)
1017 CALL xc_calc_2nd_deriv_numerical(fxc_rho, fxc_tau, xc_rho_set, rho1_r, rho1_g, tau1_r, &
1018 auxbas_pw_pool, weights, xc_section, &
1019 do_triplet, compute_virial, virial_xc, xc_deriv_set)
1023 IF (mspins == 1 .AND. do_triplet)
THEN
1024 CALL qs_rho_release(rhot1)
1027 CALL xc_rho_set_release(rho1_set)
1029 CALL timestop(handle)
1031 END SUBROUTINE qs_fxc_eval
1061 SUBROUTINE qs_fxc_fdiff(qs_env, rho0_struct, rho1_struct, xc_section, accuracy, &
1062 fxc_rho, fxc_tau, is_triplet, spinflip)
1064 TYPE(qs_environment_type),
POINTER :: qs_env
1065 TYPE(qs_rho_type),
POINTER :: rho0_struct, rho1_struct
1066 TYPE(section_vals_type),
POINTER :: xc_section
1067 INTEGER,
INTENT(IN) :: accuracy
1068 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rho, fxc_tau
1069 LOGICAL,
INTENT(IN),
OPTIONAL :: is_triplet, spinflip
1071 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_fxc_fdiff'
1072 REAL(kind=dp),
PARAMETER :: epsrho = 5.e-4_dp
1074 INTEGER :: handle, ispin, istep, nspins, nstep
1075 LOGICAL :: do_sf, do_triplet
1076 REAL(kind=dp) :: alpha, beta, exc, oeps1
1077 REAL(kind=dp),
DIMENSION(-4:4) :: ak
1078 TYPE(dft_control_type),
POINTER :: dft_control
1079 TYPE(pw_env_type),
POINTER :: pw_env
1080 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
1081 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: v_tau_rspace, vxc00
1082 TYPE(qs_ks_env_type),
POINTER :: ks_env
1083 TYPE(qs_rho_type),
POINTER :: rhoin
1085 CALL timeset(routinen, handle)
1087 cpassert(.NOT.
ASSOCIATED(fxc_rho))
1088 cpassert(.NOT.
ASSOCIATED(fxc_tau))
1089 cpassert(
ASSOCIATED(rho0_struct))
1090 cpassert(
ASSOCIATED(rho1_struct))
1092 do_triplet = .false.
1093 IF (
PRESENT(is_triplet)) do_triplet = is_triplet
1096 IF (
PRESENT(spinflip)) do_sf = spinflip
1098 cpabort(
"Spin Flip TDDFT only available with analytic 2nd xc derivatives")
1102 SELECT CASE (accuracy)
1105 ak(-2:2) = [1.0_dp, -8.0_dp, 0.0_dp, 8.0_dp, -1.0_dp]/12.0_dp
1108 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
1111 ak(-4:4) = [1.0_dp, -32.0_dp/3.0_dp, 56.0_dp, -224.0_dp, 0.0_dp, &
1112 224.0_dp, -56.0_dp, 32.0_dp/3.0_dp, -1.0_dp]/280.0_dp
1115 CALL get_qs_env(qs_env, ks_env=ks_env, dft_control=dft_control, pw_env=pw_env)
1116 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
1118 nspins = dft_control%nspins
1121 DO istep = -nstep, nstep
1123 IF (ak(istep) /= 0.0_dp)
THEN
1125 beta = real(istep, kind=dp)*epsrho
1128 CALL qs_rho_create(rhoin)
1129 NULLIFY (vxc00, v_tau_rspace)
1130 IF (do_triplet)
THEN
1131 cpassert(nspins == 1)
1133 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, 2)
1135 CALL qs_rho_scale_and_add(rhoin, rho1_struct, alpha, 0.5_dp*beta)
1136 CALL qs_vxc_create(ks_env, rhoin, xc_section, vxc00, v_tau_rspace, exc)
1137 CALL pw_axpy(vxc00(2), vxc00(1), -1.0_dp)
1138 IF (
ASSOCIATED(v_tau_rspace))
CALL pw_axpy(v_tau_rspace(2), v_tau_rspace(1), -1.0_dp)
1140 CALL qs_rho_copy(rho0_struct, rhoin, auxbas_pw_pool, nspins)
1141 CALL qs_rho_scale_and_add(rhoin, rho1_struct, alpha, beta)
1142 CALL qs_vxc_create(ks_env, rhoin, xc_section, vxc00, v_tau_rspace, exc)
1144 CALL qs_rho_release(rhoin)
1146 IF (.NOT.
ASSOCIATED(fxc_rho))
THEN
1147 ALLOCATE (fxc_rho(nspins))
1148 DO ispin = 1, nspins
1149 CALL auxbas_pw_pool%create_pw(fxc_rho(ispin))
1150 CALL pw_zero(fxc_rho(ispin))
1153 DO ispin = 1, nspins
1154 CALL pw_axpy(vxc00(ispin), fxc_rho(ispin), ak(istep))
1156 DO ispin = 1,
SIZE(vxc00)
1157 CALL auxbas_pw_pool%give_back_pw(vxc00(ispin))
1160 IF (
ASSOCIATED(v_tau_rspace))
THEN
1161 IF (.NOT.
ASSOCIATED(fxc_tau))
THEN
1162 ALLOCATE (fxc_tau(nspins))
1163 DO ispin = 1, nspins
1164 CALL auxbas_pw_pool%create_pw(fxc_tau(ispin))
1165 CALL pw_zero(fxc_tau(ispin))
1168 DO ispin = 1, nspins
1169 CALL pw_axpy(v_tau_rspace(ispin), fxc_tau(ispin), ak(istep))
1171 DO ispin = 1,
SIZE(v_tau_rspace)
1172 CALL auxbas_pw_pool%give_back_pw(v_tau_rspace(ispin))
1174 DEALLOCATE (v_tau_rspace)
1180 oeps1 = 1.0_dp/epsrho
1181 DO ispin = 1, nspins
1182 CALL pw_scale(fxc_rho(ispin), oeps1)
1184 IF (
ASSOCIATED(fxc_tau))
THEN
1185 DO ispin = 1, nspins
1186 CALL pw_scale(fxc_tau(ispin), oeps1)
1190 CALL timestop(handle)
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
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 ...
Calculation of non local dispersion functionals Some routines adapted from: Copyright (C) 2001-2009 Q...
subroutine, public qs_fxc_nlvdw_fdiff(qs_env, dispersion_env, rho0_r, rho1_r, accuracy, epsrho, fxc_rho)
Second derivative of nl-vdW potential using finite differences.
Definition of disperson types for DFT calculations.
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 fxc_atom_calc(qs_env, rho_atom_set, rho1_atom_set, xc_section, para_env_ext, do_scale, do_triplet, do_sf, kind_set_external)
...
Setup Routine for Fxc Potentials.
subroutine, public qs_fxc_apply(qs_env, xc_deriv_set, xc_rho_set, rho1_struct, rho0_atom_set, xc_section, do_onecenter, fxc_rho, fxc_tau, rho1_atom_set, do_scale, is_triplet, spinflip, pw_env_ext, kind_set_external, para_env_external, compute_virial, virial_xc)
...
subroutine, public qs_fxc_prep(qs_env, rho0_struct, xc_rho_set, xc_deriv_set, xc_section, pw_env_ext, is_triplet)
...
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(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_prep_2nd_deriv(deriv_set, rho_set, rho_r, pw_pool, weights, xc_section, tau_r)
Prepare objects for the calculation of the 2nd derivatives of the density functional....
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_2nd_deriv_numerical(v_xc, v_tau, rho_set, rho1_r, rho1_g, tau1_r, pw_pool, weights, xc_section, do_triplet, calc_virial, virial_xc, deriv_set)
calculates 2nd derivative numerically
stores all the informations relevant to an mpi environment
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