133#include "./base/base_uses.f90"
139 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_tddfpt2_forces'
171 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tddfpt_forces_main'
173 INTEGER :: handle, ispin, nspins, spin
177 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_pe_asymm, matrix_pe_symm, &
178 matrix_s, matrix_s_aux_fit
182 CALL timeset(routinen, handle)
184 CALL get_qs_env(qs_env, dft_control=dft_control)
188 IF (dft_control%qs_control%gapw .OR. dft_control%qs_control%gapw_xc)
CALL cite_reference(
sertcan2024)
190 nspins = dft_control%nspins
191 tddfpt_control => dft_control%tddfpt2_control
200 IF (gs_mos(ispin)%nmo_occ /= gs_mos(ispin)%nmo_active)
THEN
201 CALL cp_abort(__location__,
"RES-TDDFPT Forces NYA")
206 IF (
ASSOCIATED(ex_env%cpmos))
THEN
207 DO ispin = 1,
SIZE(ex_env%cpmos)
210 DEALLOCATE (ex_env%cpmos)
212 ALLOCATE (ex_env%cpmos(nspins))
216 CALL cp_fm_get_info(gs_mos(ispin)%mos_occ, matrix_struct=matrix_struct)
220 CALL get_qs_env(qs_env=qs_env, matrix_s=matrix_s)
221 NULLIFY (matrix_pe_asymm, matrix_pe_symm)
231 ALLOCATE (ex_env%matrix_pe(ispin)%matrix)
232 CALL dbcsr_create(ex_env%matrix_pe(ispin)%matrix, template=matrix_s(1)%matrix)
233 CALL dbcsr_copy(ex_env%matrix_pe(ispin)%matrix, matrix_s(1)%matrix)
234 CALL dbcsr_set(ex_env%matrix_pe(ispin)%matrix, 0.0_dp)
236 ALLOCATE (matrix_pe_symm(ispin)%matrix)
237 CALL dbcsr_create(matrix_pe_symm(ispin)%matrix, template=matrix_s(1)%matrix)
238 CALL dbcsr_copy(matrix_pe_symm(ispin)%matrix, ex_env%matrix_pe(ispin)%matrix)
240 ALLOCATE (matrix_pe_asymm(ispin)%matrix)
241 CALL dbcsr_create(matrix_pe_asymm(ispin)%matrix, template=matrix_s(1)%matrix, &
242 matrix_type=dbcsr_type_antisymmetric)
251 CALL tddfpt_resvec1(ex_env%evect(spin), gs_mos(spin)%mos_active, &
252 matrix_s(1)%matrix, ex_env%matrix_pe(ispin)%matrix, ispin, do_sf)
256 IF (dft_control%do_admm)
THEN
258 CALL get_admm_env(admm_env, matrix_s_aux_fit=matrix_s_aux_fit)
261 ALLOCATE (ex_env%matrix_pe_admm(ispin)%matrix)
262 CALL dbcsr_create(ex_env%matrix_pe_admm(ispin)%matrix, template=matrix_s_aux_fit(1)%matrix)
263 CALL dbcsr_copy(ex_env%matrix_pe_admm(ispin)%matrix, matrix_s_aux_fit(1)%matrix)
264 CALL dbcsr_set(ex_env%matrix_pe_admm(ispin)%matrix, 0.0_dp)
265 CALL tddfpt_resvec1_admm(ex_env%matrix_pe(ispin)%matrix, &
266 admm_env, ex_env%matrix_pe_admm(ispin)%matrix)
272 ALLOCATE (ex_env%matrix_hz(ispin)%matrix)
273 CALL dbcsr_create(ex_env%matrix_hz(ispin)%matrix, template=matrix_s(1)%matrix)
274 CALL dbcsr_copy(ex_env%matrix_hz(ispin)%matrix, matrix_s(1)%matrix)
275 CALL dbcsr_set(ex_env%matrix_hz(ispin)%matrix, 0.0_dp)
278 IF (dft_control%qs_control%xtb)
THEN
279 CALL tddfpt_resvec2_xtb(qs_env, ex_env%matrix_pe, gs_mos, ex_env%matrix_hz, ex_env%cpmos)
281 CALL tddfpt_resvec2(qs_env, ex_env%matrix_pe, ex_env%matrix_pe_admm, &
282 gs_mos, ex_env%matrix_hz, ex_env%cpmos)
287 DO ispin = 1,
SIZE(ex_env%evect, 1)
288 ALLOCATE (ex_env%matrix_px1(ispin)%matrix)
289 CALL dbcsr_create(ex_env%matrix_px1(ispin)%matrix, template=matrix_s(1)%matrix)
290 CALL dbcsr_copy(ex_env%matrix_px1(ispin)%matrix, matrix_s(1)%matrix)
291 CALL dbcsr_set(ex_env%matrix_px1(ispin)%matrix, 0.0_dp)
293 ALLOCATE (ex_env%matrix_px1_asymm(ispin)%matrix)
294 CALL dbcsr_create(ex_env%matrix_px1_asymm(ispin)%matrix, template=matrix_s(1)%matrix, &
295 matrix_type=dbcsr_type_antisymmetric)
299 IF (tddfpt_control%do_admm)
THEN
301 CALL get_admm_env(admm_env, matrix_s_aux_fit=matrix_s_aux_fit)
304 DO ispin = 1,
SIZE(ex_env%evect, 1)
305 ALLOCATE (ex_env%matrix_px1_admm(ispin)%matrix)
306 CALL dbcsr_create(ex_env%matrix_px1_admm(ispin)%matrix, template=matrix_s_aux_fit(1)%matrix)
307 CALL dbcsr_copy(ex_env%matrix_px1_admm(ispin)%matrix, matrix_s_aux_fit(1)%matrix)
308 CALL dbcsr_set(ex_env%matrix_px1_admm(ispin)%matrix, 0.0_dp)
310 ALLOCATE (ex_env%matrix_px1_admm_asymm(ispin)%matrix)
311 CALL dbcsr_create(ex_env%matrix_px1_admm_asymm(ispin)%matrix, template=matrix_s_aux_fit(1)%matrix, &
312 matrix_type=dbcsr_type_antisymmetric)
314 ex_env%matrix_px1_admm_asymm(ispin)%matrix)
318 CALL tddfpt_forces(qs_env, ex_env, gs_mos, kernel_env, sub_env, work_matrices)
320 CALL tddfpt_resvec3(qs_env, ex_env%cpmos, work_matrices)
325 CALL timestop(handle)
340 SUBROUTINE tddfpt_forces(qs_env, ex_env, gs_mos, kernel_env, sub_env, work_matrices)
350 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tddfpt_forces'
353 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: natom_of_kind
354 LOGICAL :: debug_forces
355 REAL(kind=
dp) :: ehartree, exc
358 TYPE(
qs_force_type),
DIMENSION(:),
POINTER :: ks_force, td_force
360 CALL timeset(routinen, handle)
363 debug_forces = ex_env%debug_forces
365 CALL get_qs_env(qs_env, dft_control=dft_control, force=ks_force, &
366 atomic_kind_set=atomic_kind_set)
370 DEALLOCATE (natom_of_kind)
374 IF (dft_control%qs_control%xtb)
THEN
375 CALL tddfpt_force_direct(qs_env, ex_env, gs_mos, kernel_env, sub_env, &
376 work_matrices, debug_forces)
382 ex_env%vtau_rspace, ex_env%vadmm_rspace, ehartree, exc, &
383 vadmm_tau_rspace=ex_env%vadmm_tau_rspace)
386 CALL tddfpt_force_direct(qs_env, ex_env, gs_mos, kernel_env, sub_env, &
387 work_matrices, debug_forces)
396 CALL timestop(handle)
398 END SUBROUTINE tddfpt_forces
417 SUBROUTINE tddfpt_force_direct(qs_env, ex_env, gs_mos, kernel_env, sub_env, work_matrices, &
427 LOGICAL :: debug_forces
429 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tddfpt_force_direct'
431 INTEGER :: handle, iounit, ispin, nact, natom, &
434 REAL(kind=
dp) :: evalue
435 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: ftot1, ftot2
436 REAL(kind=
dp),
DIMENSION(3) :: fodeb
438 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: evect
440 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s, matrix_wx1, &
450 CALL timeset(routinen, handle)
453 IF (logger%para_env%is_source())
THEN
459 evect => ex_env%evect
461 CALL get_qs_env(qs_env=qs_env, ks_env=ks_env, para_env=para_env, &
462 sab_orb=sab_orb, dft_control=dft_control, force=force)
463 NULLIFY (tddfpt_control)
464 tddfpt_control => dft_control%tddfpt2_control
470 nspins = dft_control%nspins
472 IF (debug_forces)
THEN
473 CALL get_qs_env(qs_env, natom=natom, atomic_kind_set=atomic_kind_set)
474 ALLOCATE (ftot1(3, natom))
480 CALL tddfpt_kernel_force(qs_env, ex_env, gs_mos, kernel_env, sub_env, work_matrices, debug_forces)
483 NULLIFY (matrix_wx1, matrix_wz)
485 matrix_wx1 => ex_env%matrix_wx1
486 CALL get_qs_env(qs_env=qs_env, matrix_s=matrix_s, matrix_ks=matrix_ks)
494 ALLOCATE (matrix_wz(ispin)%matrix)
495 CALL dbcsr_create(matrix=matrix_wz(ispin)%matrix, template=matrix_s(1)%matrix)
497 CALL dbcsr_set(matrix_wz(ispin)%matrix, 0.0_dp)
500 IF (.NOT. (do_sf .AND. (ispin == 1)))
THEN
503 evalue = ex_env%evalue
504 IF (tddfpt_control%oe_corr ==
oe_shift)
THEN
505 evalue = ex_env%evalue - tddfpt_control%ev_shift
511 IF (.NOT. (do_sf .AND. (ispin == 2)))
THEN
513 matrix_wz(ispin)%matrix)
516 IF (nspins == 2)
THEN
517 CALL dbcsr_add(matrix_wz(1)%matrix, matrix_wz(2)%matrix, &
518 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
521 IF (debug_forces) fodeb(1:3) = force(1)%overlap(1:3, 1)
525 matrix_name=
"OVERLAP MATRIX", &
526 basis_type_a=
"ORB", basis_type_b=
"ORB", &
527 sab_nl=sab_orb, calculate_forces=.true., &
528 matrix_p=matrix_wz(1)%matrix)
531 IF (debug_forces)
THEN
532 fodeb(1:3) = force(1)%overlap(1:3, 1) - fodeb(1:3)
533 CALL para_env%sum(fodeb)
534 IF (iounit > 0)
WRITE (iounit,
"(T3,A,T33,3F16.8)")
"DEBUG:: Wx*dS ", fodeb
539 CALL get_qs_env(qs_env=qs_env, matrix_s=matrix_s, matrix_ks=matrix_ks)
543 ALLOCATE (matrix_wz(ispin)%matrix)
544 CALL dbcsr_create(matrix=matrix_wz(ispin)%matrix, template=matrix_s(1)%matrix)
546 CALL dbcsr_set(matrix_wz(ispin)%matrix, 0.0_dp)
549 IF (.NOT. (do_sf .AND. (ispin == 2)))
THEN
550 evalue = ex_env%evalue
551 IF (tddfpt_control%oe_corr ==
oe_shift)
THEN
552 evalue = ex_env%evalue - tddfpt_control%ev_shift
560 matrix_ks(spin)%matrix, matrix_wz(ispin)%matrix, evalue)
563 IF (nspins == 2)
THEN
564 CALL dbcsr_add(matrix_wz(1)%matrix, matrix_wz(2)%matrix, &
565 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
568 IF (debug_forces) fodeb(1:3) = force(1)%overlap(1:3, 1)
570 matrix_name=
"OVERLAP MATRIX", &
571 basis_type_a=
"ORB", basis_type_b=
"ORB", &
572 sab_nl=sab_orb, calculate_forces=.true., &
573 matrix_p=matrix_wz(1)%matrix)
576 IF (debug_forces)
THEN
577 fodeb(1:3) = force(1)%overlap(1:3, 1) - fodeb(1:3)
578 CALL para_env%sum(fodeb)
579 IF (iounit > 0)
WRITE (iounit,
"(T3,A,T33,3F16.8)")
"DEBUG:: xWx*dS ", fodeb
585 IF (
ASSOCIATED(matrix_wx1))
THEN
586 IF (nspins == 2 .AND. .NOT. do_sf)
THEN
587 CALL dbcsr_add(matrix_wx1(1)%matrix, matrix_wx1(2)%matrix, &
588 alpha_scalar=0.5_dp, beta_scalar=0.5_dp)
589 ELSE IF (nspins == 2 .AND. do_sf)
THEN
590 CALL dbcsr_add(matrix_wx1(1)%matrix, matrix_wx1(2)%matrix, &
591 alpha_scalar=1.0_dp, beta_scalar=1.0_dp)
594 IF (debug_forces) fodeb(1:3) = force(1)%overlap(1:3, 1)
596 matrix_name=
"OVERLAP MATRIX", &
597 basis_type_a=
"ORB", basis_type_b=
"ORB", &
598 sab_nl=sab_orb, calculate_forces=.true., &
599 matrix_p=matrix_wx1(1)%matrix)
601 IF (debug_forces)
THEN
602 fodeb(1:3) = force(1)%overlap(1:3, 1) - fodeb(1:3)
603 CALL para_env%sum(fodeb)
604 IF (iounit > 0)
WRITE (iounit,
"(T3,A,T33,3F16.8)")
"DEBUG:: D^XKP*dS ", fodeb
608 IF (debug_forces)
THEN
609 ALLOCATE (ftot2(3, natom))
611 fodeb(1:3) = ftot2(1:3, 1) - ftot1(1:3, 1)
612 CALL para_env%sum(fodeb)
613 IF (iounit > 0)
WRITE (iounit,
"(T3,A,T30,3F16.8)")
"DEBUG:: Excitation Force", fodeb
614 DEALLOCATE (ftot1, ftot2)
617 CALL timestop(handle)
619 END SUBROUTINE tddfpt_force_direct
631 SUBROUTINE tddfpt_resvec1(evect, mos_active, matrix_s, matrix_pe, spin, do_sf)
633 TYPE(
cp_fm_type),
INTENT(IN) :: evect, mos_active
634 TYPE(
dbcsr_type),
POINTER :: matrix_s, matrix_pe
635 INTEGER,
INTENT(IN) :: spin
636 LOGICAL,
INTENT(IN) :: do_sf
638 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tddfpt_resvec1'
640 INTEGER :: handle, iounit, nact, nao, norb
646 CALL timeset(routinen, handle)
647 CALL cp_fm_get_info(mos_active, nrow_global=nao, ncol_global=norb)
649 cpassert(norb == nact)
652 IF (.NOT. do_sf .OR. (do_sf .AND. (spin == 2)))
THEN
657 IF (.NOT. do_sf .OR. (do_sf .AND. (spin == 1)))
THEN
661 nrow_global=norb, ncol_global=norb)
668 CALL parallel_gemm(
'T',
'N', norb, norb, nao, 1.0_dp, cxmat, evect, 0.0_dp, xxmat)
670 CALL parallel_gemm(
'N',
'N', nao, norb, norb, 1.0_dp, mos_active, xxmat, 0.0_dp, cxmat)
674 ncol=norb, alpha=-1.0_dp, symmetry_mode=1)
680 IF (.NOT. do_sf)
THEN
681 IF (abs(tmp) > 1.e-08_dp)
THEN
683 IF (logger%para_env%is_source())
THEN
688 cpwarn(
"Electron count of excitation density matrix is non-zero.")
690 WRITE (iounit,
"(T2,A,T61,G20.10)")
"Measured electron count is ", tmp
691 WRITE (iounit,
"(T2,A,/)") repeat(
"*", 79)
694 ELSE IF (spin == 1)
THEN
695 IF (abs(tmp + 1) > 1.e-08_dp)
THEN
697 IF (logger%para_env%is_source())
THEN
702 cpwarn(
"Count of occupied occupation number change is not -1.")
704 WRITE (iounit,
"(T2,A,T61,G20.10)")
"Measured electron count is ", tmp
705 WRITE (iounit,
"(T2,A,/)") repeat(
"*", 79)
708 ELSE IF (spin == 2)
THEN
709 IF (abs(tmp - 1) > 1.e-08_dp)
THEN
711 IF (logger%para_env%is_source())
THEN
716 cpwarn(
"Count of unoccupied occupation number change is not 1.")
718 WRITE (iounit,
"(T2,A,T61,G20.10)")
"Measured electron count is ", tmp
719 WRITE (iounit,
"(T2,A,/)") repeat(
"*", 79)
725 CALL timestop(handle)
727 END SUBROUTINE tddfpt_resvec1
735 SUBROUTINE tddfpt_resvec1_admm(matrix_pe, admm_env, matrix_pe_admm)
741 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tddfpt_resvec1_admm'
743 INTEGER :: handle, nao, nao_aux
745 CALL timeset(routinen, handle)
747 nao_aux = admm_env%nao_aux_fit
748 nao = admm_env%nao_orb
752 1.0_dp, admm_env%A, admm_env%work_orb_orb, 0.0_dp, &
753 admm_env%work_aux_orb)
755 1.0_dp, admm_env%work_aux_orb, admm_env%A, 0.0_dp, &
756 admm_env%work_aux_aux)
757 CALL copy_fm_to_dbcsr(admm_env%work_aux_aux, matrix_pe_admm, keep_sparsity=.true.)
759 CALL timestop(handle)
761 END SUBROUTINE tddfpt_resvec1_admm
774 SUBROUTINE tddfpt_resvec2(qs_env, matrix_pe, matrix_pe_admm, gs_mos, matrix_hz, cpmos)
777 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_pe, matrix_pe_admm
781 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(INOUT) :: cpmos
783 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tddfpt_resvec2'
785 CHARACTER(LEN=default_string_length) :: basis_type
786 INTEGER :: handle, iounit, ispin, mspin, n_rep_hf, &
787 nao, nao_aux, natom, norb, nspins
788 LOGICAL :: distribute_fock_matrix, do_hfx, do_onecenter, gapw, gapw_xc, &
789 hfx_treat_lsd_in_core, needs_tau_response, s_mstruct_changed
790 REAL(kind=
dp) :: eh1, focc, rhotot, thartree
791 REAL(kind=
dp),
DIMENSION(2) :: total_rho
792 REAL(kind=
dp),
DIMENSION(:),
POINTER :: qlm_tot
798 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: mhz, mpe
802 TYPE(
hfx_type),
DIMENSION(:, :),
POINTER :: x_data
803 TYPE(
local_rho_type),
POINTER :: local_rho_set, local_rho_set_admm
806 POINTER :: sab, sab_aux_fit
809 TYPE(
pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g, rho_g_aux, rhoz_g_aux, &
810 rhoz_tau_g_aux, trho_g, trho_tau_g, &
811 trho_xc_g, trho_xc_tau_g
816 TYPE(
pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r, rho_r_aux, rhoz_r_aux, &
817 rhoz_tau_r_aux, trho_r, trho_tau_r, &
818 trho_xc_r, trho_xc_tau_r, v_xc, &
820 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
822 TYPE(
qs_rho_type),
POINTER :: rho, rho_aux_fit, rho_fxc, rhoz_aux, trho
823 TYPE(
rho_atom_type),
DIMENSION(:),
POINTER :: rho1_atom_set, rho_atom_set
829 CALL timeset(routinen, handle)
832 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, ks_env=ks_env, &
833 dft_control=dft_control, para_env=para_env)
834 cpassert(
ASSOCIATED(pw_env))
835 nspins = dft_control%nspins
836 gapw = dft_control%qs_control%gapw
837 gapw_xc = dft_control%qs_control%gapw_xc
839 cpassert(.NOT. dft_control%tddfpt2_control%do_exck)
840 cpassert(.NOT. dft_control%tddfpt2_control%do_hfxsr)
841 cpassert(.NOT. dft_control%tddfpt2_control%do_hfxlr)
843 NULLIFY (auxbas_pw_pool, poisson_env)
845 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool, &
846 poisson_env=poisson_env)
848 CALL auxbas_pw_pool%create_pw(v_hartree_gspace)
849 CALL auxbas_pw_pool%create_pw(rho_tot_gspace)
850 CALL auxbas_pw_pool%create_pw(v_hartree_rspace)
853 IF (dft_control%do_admm)
THEN
855 xc_section => admm_env%xc_section_primary
861 needs_tau_response = needs%tau .OR. needs%tau_spin
863 NULLIFY (trho_tau_r, trho_tau_g, trho_xc_tau_r, trho_xc_tau_g)
864 ALLOCATE (trho_r(nspins), trho_g(nspins))
866 CALL auxbas_pw_pool%create_pw(trho_r(ispin))
867 CALL auxbas_pw_pool%create_pw(trho_g(ispin))
869 IF (needs_tau_response)
THEN
870 ALLOCATE (trho_tau_r(nspins), trho_tau_g(nspins))
872 CALL auxbas_pw_pool%create_pw(trho_tau_r(ispin))
873 CALL auxbas_pw_pool%create_pw(trho_tau_g(ispin))
877 ALLOCATE (trho_xc_r(nspins), trho_xc_g(nspins))
879 CALL auxbas_pw_pool%create_pw(trho_xc_r(ispin))
880 CALL auxbas_pw_pool%create_pw(trho_xc_g(ispin))
882 IF (needs_tau_response)
THEN
883 ALLOCATE (trho_xc_tau_r(nspins), trho_xc_tau_g(nspins))
885 CALL auxbas_pw_pool%create_pw(trho_xc_tau_r(ispin))
886 CALL auxbas_pw_pool%create_pw(trho_xc_tau_g(ispin))
892 NULLIFY (hartree_local, local_rho_set)
895 atomic_kind_set=atomic_kind_set, &
897 qs_kind_set=qs_kind_set)
900 qs_kind_set, dft_control, para_env)
901 CALL init_rho0(local_rho_set, qs_env, dft_control%qs_control%gapw_control, &
906 ELSE IF (gapw_xc)
THEN
908 atomic_kind_set=atomic_kind_set, &
909 qs_kind_set=qs_kind_set)
912 qs_kind_set, dft_control, para_env)
920 rho_gspace=trho_g(ispin), &
922 total_rho=total_rho(ispin))
923 IF (needs_tau_response)
THEN
925 rho=trho_tau_r(ispin), &
926 rho_gspace=trho_tau_g(ispin), &
930 CALL pw_axpy(trho_g(ispin), rho_tot_gspace)
933 rho=trho_xc_r(ispin), &
934 rho_gspace=trho_xc_g(ispin), &
935 soft_valid=gapw_xc, &
937 IF (needs_tau_response)
THEN
939 rho=trho_xc_tau_r(ispin), &
940 rho_gspace=trho_xc_tau_g(ispin), &
941 soft_valid=gapw_xc, &
948 IF (gapw .OR. gapw_xc)
THEN
949 CALL get_qs_env(qs_env=qs_env, oce=oce, sab_orb=sab)
951 qs_kind_set, oce, sab, para_env)
954 rhotot = sum(total_rho)
957 rhotot = rhotot + local_rho_set%rho0_mpole%total_rho0_h
958 CALL pw_axpy(local_rho_set%rho0_mpole%rho0_s_gs, rho_tot_gspace)
959 IF (
ASSOCIATED(local_rho_set%rho0_mpole%rhoz_cneo_s_gs))
THEN
960 CALL pw_axpy(local_rho_set%rho0_mpole%rhoz_cneo_s_gs, rho_tot_gspace)
964 IF (abs(rhotot) > 1.e-05_dp)
THEN
966 IF (logger%para_env%is_source())
THEN
971 cpwarn(
"Real space electron count of excitation density is non-zero.")
973 WRITE (iounit,
"(T2,A,T61,G20.10)")
"Measured electron count is ", rhotot
974 WRITE (iounit,
"(T2,A,/)") repeat(
"*", 79)
981 CALL pw_transfer(v_hartree_gspace, v_hartree_rspace)
982 CALL pw_scale(v_hartree_rspace, v_hartree_rspace%pw_grid%dvol)
985 local_rho_set, para_env, tddft=.true.)
987 calculate_forces=.false., &
988 local_rho_set=local_rho_set)
993 CALL qs_rho_get(rho, rho_r=rho_r, rho_g=rho_g)
995 NULLIFY (v_xc, v_xc_tau)
999 CALL get_qs_env(qs_env=qs_env, rho_xc=rho_fxc)
1000 IF (needs_tau_response)
THEN
1001 CALL qs_rho_set(trho, rho_r=trho_xc_r, tau_r=trho_xc_tau_r, &
1002 rho_r_valid=.true., tau_r_valid=.true.)
1004 CALL qs_rho_set(trho, rho_r=trho_xc_r, rho_r_valid=.true.)
1008 IF (needs_tau_response)
THEN
1009 CALL qs_rho_set(trho, rho_r=trho_r, tau_r=trho_tau_r, &
1010 rho_r_valid=.true., tau_r_valid=.true.)
1012 CALL qs_rho_set(trho, rho_r=trho_r, rho_r_valid=.true.)
1015 IF (gapw .OR. gapw_xc)
THEN
1016 do_onecenter = .true.
1017 CALL get_qs_env(qs_env, rho_atom_set=rho_atom_set)
1018 rho1_atom_set => local_rho_set%rho_atom_set
1020 do_onecenter = .false.
1022 CALL qs_fxc_create(qs_env, rho_fxc, trho, rho_atom_set, xc_section, &
1023 do_onecenter, v_xc, v_xc_tau, rho1_atom_set, &
1024 dispersion_env=qs_env%dispersion_env)
1027 DO ispin = 1, nspins
1028 CALL dbcsr_set(matrix_hz(ispin)%matrix, 0.0_dp)
1029 CALL pw_scale(v_xc(ispin), v_xc(ispin)%pw_grid%dvol)
1030 CALL integrate_v_rspace(qs_env=qs_env, v_rspace=v_xc(ispin), &
1031 hmat=matrix_hz(ispin), gapw=do_onecenter, &
1032 calculate_forces=.false.)
1033 IF (
ASSOCIATED(v_xc_tau))
THEN
1034 CALL pw_scale(v_xc_tau(ispin), v_xc_tau(ispin)%pw_grid%dvol)
1035 CALL integrate_v_rspace(qs_env=qs_env, v_rspace=v_xc_tau(ispin), &
1036 hmat=matrix_hz(ispin), gapw=do_onecenter, &
1037 calculate_forces=.false., compute_tau=.true.)
1039 CALL integrate_v_rspace(qs_env=qs_env, v_rspace=v_hartree_rspace, &
1040 hmat=matrix_hz(ispin), gapw=gapw, &
1041 calculate_forces=.false.)
1043 IF (gapw .OR. gapw_xc)
THEN
1044 mhz(1:nspins, 1:1) => matrix_hz(1:nspins)
1045 mpe(1:nspins, 1:1) => matrix_pe(1:nspins)
1047 rho_atom_external=local_rho_set%rho_atom_set)
1050 CALL auxbas_pw_pool%give_back_pw(v_hartree_gspace)
1051 CALL auxbas_pw_pool%give_back_pw(v_hartree_rspace)
1052 CALL auxbas_pw_pool%give_back_pw(rho_tot_gspace)
1053 DO ispin = 1, nspins
1054 CALL auxbas_pw_pool%give_back_pw(trho_r(ispin))
1055 CALL auxbas_pw_pool%give_back_pw(trho_g(ispin))
1056 CALL auxbas_pw_pool%give_back_pw(v_xc(ispin))
1058 DEALLOCATE (trho_r, trho_g, v_xc)
1059 IF (
ASSOCIATED(trho_tau_r))
THEN
1060 DO ispin = 1, nspins
1061 CALL auxbas_pw_pool%give_back_pw(trho_tau_r(ispin))
1062 CALL auxbas_pw_pool%give_back_pw(trho_tau_g(ispin))
1064 DEALLOCATE (trho_tau_r, trho_tau_g)
1067 DO ispin = 1, nspins
1068 CALL auxbas_pw_pool%give_back_pw(trho_xc_r(ispin))
1069 CALL auxbas_pw_pool%give_back_pw(trho_xc_g(ispin))
1071 DEALLOCATE (trho_xc_r, trho_xc_g)
1072 IF (
ASSOCIATED(trho_xc_tau_r))
THEN
1073 DO ispin = 1, nspins
1074 CALL auxbas_pw_pool%give_back_pw(trho_xc_tau_r(ispin))
1075 CALL auxbas_pw_pool%give_back_pw(trho_xc_tau_g(ispin))
1077 DEALLOCATE (trho_xc_tau_r, trho_xc_tau_g)
1080 IF (
ASSOCIATED(v_xc_tau))
THEN
1081 DO ispin = 1, nspins
1082 CALL auxbas_pw_pool%give_back_pw(v_xc_tau(ispin))
1084 DEALLOCATE (v_xc_tau)
1086 IF (dft_control%do_admm)
THEN
1090 CALL get_admm_env(admm_env, rho_aux_fit=rho_aux_fit, matrix_s_aux_fit=msaux, &
1091 task_list_aux_fit=task_list)
1092 basis_type =
"AUX_FIT"
1095 ALLOCATE (mpe(nspins, 1))
1097 DO ispin = 1, nspins
1098 ALLOCATE (mhz(ispin, 1)%matrix)
1099 CALL dbcsr_create(mhz(ispin, 1)%matrix, template=msaux(1)%matrix)
1100 CALL dbcsr_copy(mhz(ispin, 1)%matrix, msaux(1)%matrix)
1101 CALL dbcsr_set(mhz(ispin, 1)%matrix, 0.0_dp)
1102 mpe(ispin, 1)%matrix => matrix_pe_admm(ispin)%matrix
1106 NULLIFY (local_rho_set_admm)
1107 IF (admm_env%do_gapw)
THEN
1108 basis_type =
"AUX_FIT_SOFT"
1109 task_list => admm_env%admm_gapw_env%task_list
1110 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set)
1114 admm_env%admm_gapw_env%admm_kind_set, dft_control, para_env)
1116 rho_atom_set=local_rho_set_admm%rho_atom_set, &
1117 qs_kind_set=admm_env%admm_gapw_env%admm_kind_set, &
1118 oce=admm_env%admm_gapw_env%oce, sab=sab_aux_fit, para_env=para_env)
1120 do_rho0=.false., kind_set_external=admm_env%admm_gapw_env%admm_kind_set)
1123 xc_section => admm_env%xc_section_aux
1126 needs_tau_response = needs%tau .OR. needs%tau_spin
1128 NULLIFY (rho_g_aux, rho_r_aux, rhoz_g_aux, rhoz_r_aux, rhoz_tau_g_aux, rhoz_tau_r_aux)
1129 CALL qs_rho_get(rho_aux_fit, rho_r=rho_r_aux, rho_g=rho_g_aux)
1131 ALLOCATE (rhoz_r_aux(nspins), rhoz_g_aux(nspins))
1132 DO ispin = 1, nspins
1133 CALL auxbas_pw_pool%create_pw(rhoz_r_aux(ispin))
1134 CALL auxbas_pw_pool%create_pw(rhoz_g_aux(ispin))
1136 IF (needs_tau_response)
THEN
1137 ALLOCATE (rhoz_tau_r_aux(nspins), rhoz_tau_g_aux(nspins))
1138 DO ispin = 1, nspins
1139 CALL auxbas_pw_pool%create_pw(rhoz_tau_r_aux(ispin))
1140 CALL auxbas_pw_pool%create_pw(rhoz_tau_g_aux(ispin))
1143 DO ispin = 1, nspins
1145 rho=rhoz_r_aux(ispin), rho_gspace=rhoz_g_aux(ispin), &
1146 basis_type=basis_type, &
1147 task_list_external=task_list)
1148 IF (needs_tau_response)
THEN
1150 rho=rhoz_tau_r_aux(ispin), rho_gspace=rhoz_tau_g_aux(ispin), &
1151 basis_type=basis_type, task_list_external=task_list, &
1156 NULLIFY (v_xc, v_xc_tau)
1159 IF (needs_tau_response)
THEN
1160 CALL qs_rho_set(rhoz_aux, rho_r=rhoz_r_aux, tau_r=rhoz_tau_r_aux, &
1161 rho_r_valid=.true., tau_r_valid=.true.)
1163 CALL qs_rho_set(rhoz_aux, rho_r=rhoz_r_aux, rho_r_valid=.true.)
1165 IF (admm_env%do_gapw)
THEN
1166 do_onecenter = .true.
1167 rho_atom_set => admm_env%admm_gapw_env%local_rho_set%rho_atom_set
1168 rho1_atom_set => local_rho_set_admm%rho_atom_set
1169 qs_kind_set => admm_env%admm_gapw_env%admm_kind_set
1171 do_onecenter = .false.
1172 CALL get_qs_env(qs_env, qs_kind_set=qs_kind_set)
1174 CALL qs_fxc_create(qs_env, rho_aux_fit, rhoz_aux, rho_atom_set, xc_section, &
1175 do_onecenter, v_xc, v_xc_tau, rho1_atom_set, &
1176 kind_set_external=qs_kind_set)
1177 DEALLOCATE (rhoz_aux)
1179 DO ispin = 1, nspins
1180 CALL pw_scale(v_xc(ispin), v_xc(ispin)%pw_grid%dvol)
1181 CALL integrate_v_rspace(qs_env=qs_env, v_rspace=v_xc(ispin), &
1182 hmat=mhz(ispin, 1), basis_type=basis_type, &
1183 calculate_forces=.false., &
1184 task_list_external=task_list)
1186 DO ispin = 1, nspins
1187 CALL auxbas_pw_pool%give_back_pw(v_xc(ispin))
1188 CALL auxbas_pw_pool%give_back_pw(rhoz_r_aux(ispin))
1189 CALL auxbas_pw_pool%give_back_pw(rhoz_g_aux(ispin))
1191 DEALLOCATE (v_xc, rhoz_r_aux, rhoz_g_aux)
1192 IF (
ASSOCIATED(v_xc_tau))
THEN
1193 DO ispin = 1, nspins
1194 CALL auxbas_pw_pool%give_back_pw(v_xc_tau(ispin))
1196 DEALLOCATE (v_xc_tau)
1198 IF (
ASSOCIATED(rhoz_tau_r_aux))
THEN
1199 DO ispin = 1, nspins
1200 CALL auxbas_pw_pool%give_back_pw(rhoz_tau_r_aux(ispin))
1201 CALL auxbas_pw_pool%give_back_pw(rhoz_tau_g_aux(ispin))
1203 DEALLOCATE (rhoz_tau_r_aux, rhoz_tau_g_aux)
1206 IF (admm_env%do_gapw)
THEN
1207 rho_atom_set => admm_env%admm_gapw_env%local_rho_set%rho_atom_set
1208 rho1_atom_set => local_rho_set_admm%rho_atom_set
1209 CALL update_ks_atom(qs_env, mhz(:, 1), matrix_pe_admm, forces=.false., tddft=.false., &
1210 rho_atom_external=rho1_atom_set, &
1211 kind_set_external=admm_env%admm_gapw_env%admm_kind_set, &
1212 oce_external=admm_env%admm_gapw_env%oce, &
1213 sab_external=sab_aux_fit)
1216 nao = admm_env%nao_orb
1217 nao_aux = admm_env%nao_aux_fit
1219 CALL dbcsr_create(dbwork, template=matrix_hz(1)%matrix)
1220 DO ispin = 1, nspins
1222 admm_env%work_aux_orb, nao)
1224 1.0_dp, admm_env%A, admm_env%work_aux_orb, 0.0_dp, &
1225 admm_env%work_orb_orb)
1229 CALL dbcsr_add(matrix_hz(ispin)%matrix, dbwork, 1.0_dp, 1.0_dp)
1235 IF (admm_env%do_gapw)
THEN
1240 IF (gapw .OR. gapw_xc)
THEN
1250 cpassert(n_rep_hf == 1)
1254 IF (hfx_treat_lsd_in_core) mspin = nspins
1256 CALL get_qs_env(qs_env=qs_env, rho=rho, x_data=x_data, para_env=para_env, &
1257 s_mstruct_changed=s_mstruct_changed)
1258 distribute_fock_matrix = .true.
1259 IF (dft_control%do_admm)
THEN
1263 ALLOCATE (mpe(nspins, 1))
1265 DO ispin = 1, nspins
1266 ALLOCATE (mhz(ispin, 1)%matrix)
1267 CALL dbcsr_create(mhz(ispin, 1)%matrix, template=msaux(1)%matrix)
1268 CALL dbcsr_copy(mhz(ispin, 1)%matrix, msaux(1)%matrix)
1269 CALL dbcsr_set(mhz(ispin, 1)%matrix, 0.0_dp)
1270 mpe(ispin, 1)%matrix => matrix_pe_admm(ispin)%matrix
1272 IF (x_data(1, 1)%do_hfx_ri)
THEN
1274 CALL hfx_ri_update_ks(qs_env, x_data(1, 1)%ri_data, mhz, eh1, rho_ao=mpe, &
1275 geometry_did_change=s_mstruct_changed, nspins=nspins, &
1276 hf_fraction=x_data(1, 1)%general_parameter%fraction)
1281 para_env, s_mstruct_changed, 1, distribute_fock_matrix, &
1286 cpassert(
ASSOCIATED(admm_env%work_aux_orb))
1287 cpassert(
ASSOCIATED(admm_env%work_orb_orb))
1288 nao = admm_env%nao_orb
1289 nao_aux = admm_env%nao_aux_fit
1291 CALL dbcsr_create(dbwork, template=matrix_hz(1)%matrix)
1292 DO ispin = 1, nspins
1294 admm_env%work_aux_orb, nao)
1296 1.0_dp, admm_env%A, admm_env%work_aux_orb, 0.0_dp, &
1297 admm_env%work_orb_orb)
1298 CALL dbcsr_copy(dbwork, matrix_hz(ispin)%matrix)
1301 CALL dbcsr_add(matrix_hz(ispin)%matrix, dbwork, 1.0_dp, 1.0_dp)
1309 ALLOCATE (mpe(nspins, 1), mhz(nspins, 1))
1310 DO ispin = 1, nspins
1311 mhz(ispin, 1)%matrix => matrix_hz(ispin)%matrix
1312 mpe(ispin, 1)%matrix => matrix_pe(ispin)%matrix
1314 IF (x_data(1, 1)%do_hfx_ri)
THEN
1316 CALL hfx_ri_update_ks(qs_env, x_data(1, 1)%ri_data, mhz, eh1, rho_ao=mpe, &
1317 geometry_did_change=s_mstruct_changed, nspins=nspins, &
1318 hf_fraction=x_data(1, 1)%general_parameter%fraction)
1323 para_env, s_mstruct_changed, 1, distribute_fock_matrix, &
1327 DEALLOCATE (mpe, mhz)
1332 IF (nspins == 2) focc = 2.0_dp
1333 DO ispin = 1, nspins
1334 mos => gs_mos(ispin)%mos_occ
1337 norb, alpha=focc, beta=0.0_dp)
1340 CALL timestop(handle)
1342 END SUBROUTINE tddfpt_resvec2
1352 SUBROUTINE tddfpt_resvec2_xtb(qs_env, matrix_pe, gs_mos, matrix_hz, cpmos)
1359 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(INOUT) :: cpmos
1361 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tddfpt_resvec2_xtb'
1363 INTEGER :: atom_a, handle, iatom, ikind, is, ispin, &
1364 na, natom, natorb, nkind, norb, ns, &
1366 INTEGER,
DIMENSION(25) :: lao
1367 INTEGER,
DIMENSION(5) :: occ
1368 REAL(
dp),
ALLOCATABLE,
DIMENSION(:) :: mcharge, mcharge1
1369 REAL(
dp),
ALLOCATABLE,
DIMENSION(:, :) :: aocg, aocg1, charges, charges1
1370 REAL(kind=
dp) :: focc
1374 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_p, matrix_s
1379 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1383 CALL timeset(routinen, handle)
1385 cpassert(
ASSOCIATED(matrix_pe))
1387 CALL get_qs_env(qs_env=qs_env, dft_control=dft_control)
1388 nspins = dft_control%nspins
1390 DO ispin = 1, nspins
1391 CALL dbcsr_set(matrix_hz(ispin)%matrix, 0.0_dp)
1394 IF (dft_control%qs_control%xtb_control%coulomb_interaction)
THEN
1396 CALL get_qs_env(qs_env, rho=rho, particle_set=particle_set, &
1397 matrix_s_kp=matrix_s, para_env=para_env)
1398 natom =
SIZE(particle_set)
1400 ALLOCATE (mcharge(natom), charges(natom, 5))
1401 ALLOCATE (mcharge1(natom), charges1(natom, 5))
1404 CALL get_qs_env(qs_env, atomic_kind_set=atomic_kind_set, qs_kind_set=qs_kind_set)
1405 nkind =
SIZE(atomic_kind_set)
1407 ALLOCATE (aocg(nsgf, natom))
1409 ALLOCATE (aocg1(nsgf, natom))
1411 p_matrix => matrix_p(:, 1)
1412 s_matrix => matrix_s(1, 1)%matrix
1413 CALL ao_charges(p_matrix, s_matrix, aocg, para_env)
1414 CALL ao_charges(matrix_pe, s_matrix, aocg1, para_env)
1415 IF (nspins == 2) aocg1 = 0.5_dp*aocg1
1418 CALL get_qs_kind(qs_kind_set(ikind), xtb_parameter=xtb_kind)
1421 atom_a = atomic_kind_set(ikind)%atom_list(iatom)
1422 charges(atom_a, :) = real(occ(:), kind=
dp)
1425 charges(atom_a, ns) = charges(atom_a, ns) - aocg(is, atom_a)
1426 charges1(atom_a, ns) = charges1(atom_a, ns) - aocg1(is, atom_a)
1430 DEALLOCATE (aocg, aocg1)
1432 mcharge(iatom) = sum(charges(iatom, :))
1433 mcharge1(iatom) = sum(charges1(iatom, :))
1439 DEALLOCATE (charges, mcharge, charges1, mcharge1)
1443 DO ispin = 1, nspins
1444 mos => gs_mos(ispin)%mos_occ
1447 norb, alpha=focc, beta=0.0_dp)
1450 CALL timestop(handle)
1452 END SUBROUTINE tddfpt_resvec2_xtb
1460 SUBROUTINE tddfpt_resvec3(qs_env, cpmos, work)
1463 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(IN) :: cpmos
1466 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tddfpt_resvec3'
1468 INTEGER :: handle, ispin, nao, norb, nspins
1475 CALL timeset(routinen, handle)
1477 CALL get_qs_env(qs_env, mos=mos, dft_control=dft_control)
1478 nspins = dft_control%nspins
1480 DO ispin = 1, nspins
1482 associate(rvecs => cpmos(ispin))
1485 CALL cp_fm_struct_create(fmstruct, context=rvecs%matrix_struct%context, nrow_global=norb, &
1486 ncol_global=norb, para_env=rvecs%matrix_struct%para_env)
1490 CALL parallel_gemm(
"T",
"N", norb, norb, nao, 1.0_dp, omos, work%S_C0(ispin), 0.0_dp, umat)
1492 CALL parallel_gemm(
"N",
"T", nao, norb, norb, 1.0_dp, cvec, umat, 0.0_dp, rvecs)
1498 CALL timestop(handle)
1500 END SUBROUTINE tddfpt_resvec3
1514 SUBROUTINE tddfpt_kernel_force(qs_env, ex_env, gs_mos, kernel_env, sub_env, work_matrices, debug_forces)
1516 TYPE(qs_environment_type),
POINTER :: qs_env
1517 TYPE(excited_energy_type),
POINTER :: ex_env
1518 TYPE(tddfpt_ground_state_mos),
DIMENSION(:), &
1520 TYPE(kernel_env_type),
INTENT(IN) :: kernel_env
1521 TYPE(tddfpt_subgroup_env_type) :: sub_env
1522 TYPE(tddfpt_work_matrices) :: work_matrices
1523 LOGICAL,
INTENT(IN) :: debug_forces
1525 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tddfpt_kernel_force'
1528 TYPE(dft_control_type),
POINTER :: dft_control
1529 TYPE(tddfpt2_control_type),
POINTER :: tddfpt_control
1531 CALL timeset(routinen, handle)
1533 CALL get_qs_env(qs_env, dft_control=dft_control)
1534 tddfpt_control => dft_control%tddfpt2_control
1536 IF (tddfpt_control%kernel == tddfpt_kernel_full)
THEN
1538 CALL fhxc_force(qs_env, ex_env, gs_mos, kernel_env%full_kernel, debug_forces)
1539 ELSE IF (tddfpt_control%kernel == tddfpt_kernel_stda)
THEN
1541 CALL stda_force(qs_env, ex_env, gs_mos, kernel_env%stda_kernel, sub_env, work_matrices, debug_forces)
1542 ELSE IF (tddfpt_control%kernel == tddfpt_kernel_none)
THEN
1544 ex_env%matrix_wx1 => null()
1546 cpabort(
'Unknown kernel type')
1549 CALL timestop(handle)
1551 END SUBROUTINE tddfpt_kernel_force
Types and set/get functions for auxiliary density matrix methods.
subroutine, public get_admm_env(admm_env, mo_derivs_aux_fit, mos_aux_fit, sab_aux_fit, sab_aux_fit_asymm, sab_aux_fit_vs_orb, matrix_s_aux_fit, matrix_s_aux_fit_kp, matrix_s_aux_fit_vs_orb, matrix_s_aux_fit_vs_orb_kp, task_list_aux_fit, matrix_ks_aux_fit, matrix_ks_aux_fit_kp, matrix_ks_aux_fit_im, matrix_ks_aux_fit_dft, matrix_ks_aux_fit_hfx, matrix_ks_aux_fit_dft_kp, matrix_ks_aux_fit_hfx_kp, rho_aux_fit, rho_aux_fit_buffer, admm_dm)
Get routine for the ADMM env.
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public hehn2024
integer, save, public sertcan2024
integer, save, public hehn2022
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_scale(matrix, alpha_scalar)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_complete_redistribute(matrix, redist)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
subroutine, public dbcsr_dot(matrix_a, matrix_b, trace)
Computes the dot product of two matrices, also known as the trace of their matrix product.
Routines that link DBCSR and CP2K concepts together.
subroutine, public cp_dbcsr_alloc_block_from_nbl(matrix, sab_orb, desymmetrize)
allocate the blocks of a dbcsr based on the neighbor list
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_sm_fm_multiply(matrix, fm_in, fm_out, ncol, alpha, beta)
multiply a dbcsr with a fm matrix
subroutine, public copy_dbcsr_to_fm(matrix, fm, plan, check_plan)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public cp_dbcsr_plus_fm_fm_t(sparse_matrix, matrix_v, matrix_g, ncol, alpha, keep_sparsity, symmetry_mode)
performs the multiplication sparse_matrix+dense_mat*dens_mat^T if matrix_g is not explicitly given,...
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_copy_general(source, destination, para_env)
General copy of a fm matrix to another fm matrix. Uses non-blocking MPI rather than ScaLAPACK.
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
various routines to log and control the output. The idea is that decisions about where to log should ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
Types for excited states potential energies.
subroutine, public exstate_potential_release(ex_env)
...
subroutine, public init_coulomb_local(hartree_local, natom)
...
subroutine, public vh_1c_gg_integrals(qs_env, energy_hartree_1c, ecoul_1c, local_rho_set, para_env, tddft, local_rho_set_2nd, core_2nd)
Calculates one center GAPW Hartree energies and matrix elements Hartree potentials are input Takes po...
subroutine, public hartree_local_release(hartree_local)
...
subroutine, public hartree_local_create(hartree_local)
...
Routines to calculate HFX energy and potential.
subroutine, public integrate_four_center(qs_env, x_data, ks_matrix, ehfx, rho_ao, hfx_section, para_env, geometry_did_change, irep, distribute_fock_matrix, ispin, nspins)
computes four center integrals for a full basis set and updates the Kohn-Sham-Matrix and energy....
subroutine, public hfx_ri_update_ks(qs_env, ri_data, ks_matrix, ehfx, mos, rho_ao, geometry_did_change, nspins, hf_fraction)
...
Types and set/get functions for HFX.
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Interface to the message passing library MPI.
compute mulliken charges we (currently) define them as c_i = 1/2 [ (PS)_{ii} + (SP)_{ii}...
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
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
functions related to the poisson solver on regular grids
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Calculate the plane wave density by collocating the primitive Gaussian functions (pgf).
subroutine, public calculate_rho_elec(matrix_p, matrix_p_kp, rho, rho_gspace, total_rho, ks_env, soft_valid, compute_tau, compute_grad, basis_type, der_type, idir, task_list_external, pw_env_external)
computes the density corresponding to a given density matrix on the grid
collects routines that calculate density matrices
subroutine, public calculate_xwx_matrix(mos_active, xvec, s_matrix, ks_matrix, w_matrix, eval)
Calculate the excited state W matrix from the MO eigenvectors, KS matrix.
subroutine, public calculate_wx_matrix(mos_active, xvec, ks_matrix, w_matrix)
Calculate the excited state W matrix from the MO eigenvectors, KS matrix.
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 set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, mimic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, rhoz_cneo_set, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, harris_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Set the QUICKSTEP environment.
subroutine, public sum_qs_force(qs_force_out, qs_force_in)
Sum up two qs_force entities qs_force_out = qs_force_out + qs_force_in.
subroutine, public deallocate_qs_force(qs_force)
Deallocate a Quickstep force data structure.
subroutine, public zero_qs_force(qs_force)
Initialize a Quickstep force data structure.
subroutine, public allocate_qs_force(qs_force, natom_of_kind)
Allocate a Quickstep force data structure.
subroutine, public total_qs_force(force, qs_force, atomic_kind_set)
Get current total force.
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 prepare_gapw_den(qs_env, local_rho_set, do_rho0, kind_set_external, pw_env_sub)
...
Integrate single or product functions over a potential on a RS grid.
Define the quickstep kind type and their sub types.
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.
subroutine, public get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, do_mtlr_present, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
routines that build the Kohn-Sham matrix contributions coming from local atomic densities
subroutine, public update_ks_atom(qs_env, ksmat, pmat, forces, tddft, rho_atom_external, kind_set_external, oce_external, sab_external, kscale, kintegral, kforce, fscale)
The correction to the KS matrix due to the GAPW local terms to the hartree and XC contributions is he...
Calculate the KS reference potentials.
subroutine, public ks_ref_potential_atom(qs_env, local_rho_set, local_rho_set_admm, v_hartree_rspace)
calculate the Kohn-Sham GAPW reference potentials
subroutine, public ks_ref_potential(qs_env, vh_rspace, vxc_rspace, vtau_rspace, vadmm_rspace, ehartree, exc, h_stress, vadmm_tau_rspace)
calculate the Kohn-Sham reference potential
subroutine, public local_rho_set_create(local_rho_set)
...
subroutine, public local_rho_set_release(local_rho_set)
...
Definition and initialisation of the mo data type.
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count, cmo_coeff)
Get the components of a MO set data structure.
Define the neighbor list data types and the corresponding functionality.
Calculation of overlap matrix, its derivatives and forces.
subroutine, public build_overlap_matrix(ks_env, matrix_s, matrixkp_s, matrix_name, nderivative, basis_type_a, basis_type_b, sab_nl, calculate_forces, matrix_p, matrixkp_p, ext_kpoints)
Calculation of the overlap matrix over Cartesian Gaussian functions.
subroutine, public rho0_s_grid_create(pw_env, rho0_mpole)
...
subroutine, public integrate_vhg0_rspace(qs_env, v_rspace, para_env, calculate_forces, local_rho_set, local_rho_set_2nd, atener, kforce, my_pools, my_rs_descs)
...
subroutine, public init_rho0(local_rho_set, qs_env, gapw_control, zcore)
...
subroutine, public get_rho0_mpole(rho0_mpole, g0_h, vg0_h, iat, ikind, lmax_0, l0_ikind, mp_gau_ikind, mp_rho, norm_g0l_h, qlm_gg, qlm_car, qlm_tot, zet0_h, igrid_zet0_s, rpgf0_h, rpgf0_s, max_rpgf0_s, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs)
...
subroutine, public allocate_rho_atom_internals(rho_atom_set, atomic_kind_set, qs_kind_set, dft_control, para_env)
...
subroutine, public calculate_rho_atom_coeff(qs_env, rho_ao, rho_atom_set, qs_kind_set, oce, sab, para_env)
...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_set(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)
...
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 stda_force(qs_env, ex_env, gs_mos, stda_env, sub_env, work, debug_forces)
Simplified Tamm Dancoff approach (sTDA). Kernel contribution to forces.
subroutine, public fhxc_force(qs_env, ex_env, gs_mos, full_kernel, debug_forces)
Calculate direct tddft forces. Calculate the three last terms of the response vector in equation 49 a...
subroutine, public tddfpt_forces_main(qs_env, gs_mos, ex_env, kernel_env, sub_env, work_matrices)
Perform TDDFPT gradient calculation. This routine calculates the response vector R of Eq....
type(xc_rho_cflags_type) function, public xc_functionals_get_needs(functionals, lsd, calc_potential)
...
Calculation of Coulomb Hessian contributions in xTB.
subroutine, public xtb_coulomb_hessian(qs_env, ks_matrix, charges1, mcharge1, mcharge, matrix_p1)
...
Definition of the xTB parameter types.
subroutine, public get_xtb_atom_param(xtb_parameter, symbol, aname, typ, defined, z, zeff, natorb, lmax, nao, lao, rcut, rcov, kx, eta, xgamma, alpha, zneff, nshell, nval, lval, kpoly, kappa, wall, hen, zeta, xi, kappa0, alpg, occupation, ngauss, electronegativity, chmax, en, kqat2, kcn, kq)
...
stores some data used in wavefunction fitting
Provides all information about an atomic kind.
keeps the information about the structure of a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
Contains information on the excited states energy.
stores some data used in construction of Kohn-Sham matrix
stores all the informations relevant to an mpi environment
contained for different pw related things
environment for the poisson solver
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
Type to hold environments for the different kernels.
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.
Parallel (sub)group environment.
Ground state molecular orbitals.
Set of temporary ("work") matrices.
contains a flag for each component of xc_rho_set, so that you can use it to tell which components you...