28 USE dbcsr_api,
ONLY: &
29 dbcsr_complete_redistribute, dbcsr_create, dbcsr_deallocate_matrix, &
30 dbcsr_distribution_type, dbcsr_get_info, dbcsr_init_p, dbcsr_p_type, dbcsr_release_p, &
31 dbcsr_type, dbcsr_type_antisymmetric
33 ewald_environment_type
63 tddfpt_subgroup_env_type
64 #include "./base/base_uses.f90"
70 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_tddfpt2_types'
72 LOGICAL,
PARAMETER,
PRIVATE :: debug_this_module = .false.
74 INTEGER,
PARAMETER,
PRIVATE :: nderivs = 3
75 INTEGER,
PARAMETER,
PRIVATE :: maxspins = 2
77 PUBLIC :: tddfpt_ground_state_mos, tddfpt_work_matrices
86 TYPE tddfpt_ground_state_mos
88 TYPE(cp_fm_type),
POINTER :: mos_occ
90 TYPE(cp_fm_type),
POINTER :: mos_virt
94 TYPE(cp_fm_type),
POINTER :: evals_occ_matrix
96 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: evals_occ
98 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: evals_virt
101 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: phases_occ
102 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: phases_virt
103 END TYPE tddfpt_ground_state_mos
110 TYPE tddfpt_work_matrices
116 TYPE(cp_fm_pool_p_type),
ALLOCATABLE,
DIMENSION(:) :: fm_pool_ao_mo_occ
118 TYPE(cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: S_C0
120 TYPE(cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: S_C0_C0T
129 TYPE(cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: evects_sub
131 TYPE(cp_fm_type),
ALLOCATABLE,
DIMENSION(:, :) :: Aop_evects_sub
133 TYPE(cp_fm_type),
POINTER :: rho_ao_orb_fm_sub
139 TYPE(cp_fm_type),
POINTER :: rho_ao_aux_fit_fm_sub
141 TYPE(cp_fm_type),
POINTER :: wfm_aux_orb_sub
147 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: A_ia_munu_sub
152 TYPE(qs_rho_type),
POINTER :: rho_orb_struct_sub
154 TYPE(qs_rho_type),
POINTER :: rho_xc_struct_sub
156 TYPE(qs_rho_type),
POINTER :: rho_aux_fit_struct_sub
158 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: A_ia_rspace_sub
160 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: wpw_gspace_sub
162 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: wpw_rspace_sub
164 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: wpw_tau_rspace_sub
168 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: fxc_rspace_sub
173 TYPE(cp_fm_type),
POINTER :: hfx_fm_ao_ao
176 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: hfx_rho_ao_symm, hfx_rho_ao_asymm
178 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: hfx_hmat_symm, hfx_hmat_asymm
180 TYPE(cp_fm_type),
POINTER :: hfxsr_fm_ao_ao
181 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: hfxsr_rho_ao_symm, hfxsr_rho_ao_asymm
182 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: hfxsr_hmat_symm, hfxsr_hmat_asymm
187 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: gamma_exchange
189 TYPE(cp_fm_type),
DIMENSION(:),
POINTER :: ctransformed
191 TYPE(dbcsr_type),
POINTER :: shalf
193 REAL(KIND=
dp),
DIMENSION(:),
POINTER :: s_eigenvalues
194 TYPE(cp_fm_type),
POINTER :: S_eigenvectors
195 TYPE(cp_fm_type),
POINTER :: slambda
197 TYPE(ewald_environment_type),
POINTER :: ewald_env
198 TYPE(ewald_pw_type),
POINTER :: ewald_pw
200 TYPE(hartree_local_type),
POINTER :: hartree_local
201 TYPE(local_rho_type),
POINTER :: local_rho_set
202 TYPE(local_rho_type),
POINTER :: local_rho_set_admm
203 END TYPE tddfpt_work_matrices
223 do_hfxlr, do_exck, qs_env, sub_env)
224 TYPE(tddfpt_work_matrices),
INTENT(out) :: work_matrices
225 TYPE(tddfpt_ground_state_mos),
DIMENSION(:), &
227 INTEGER,
INTENT(in) :: nstates
228 LOGICAL,
INTENT(in) :: do_hfx, do_admm, do_hfxlr, do_exck
229 TYPE(qs_environment_type),
POINTER :: qs_env
230 TYPE(tddfpt_subgroup_env_type),
INTENT(in) :: sub_env
232 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tddfpt_create_work_matrices'
234 INTEGER :: handle, igroup, ispin, istate, nao, &
235 nao_aux, natom, ngroups, nspins
236 INTEGER,
DIMENSION(maxspins) :: nmo_occ, nmo_virt
237 TYPE(admm_type),
POINTER :: admm_env
238 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
239 TYPE(cp_blacs_env_type),
POINTER :: blacs_env
240 TYPE(cp_fm_struct_p_type),
DIMENSION(maxspins) :: fm_struct_evects
241 TYPE(cp_fm_struct_type),
POINTER :: fm_struct
242 TYPE(dbcsr_distribution_type),
POINTER :: dbcsr_dist
243 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s, matrix_s_aux_fit, rho_ia_ao, &
245 TYPE(dbcsr_type),
POINTER :: dbcsr_template_hfx
246 TYPE(dft_control_type),
POINTER :: dft_control
247 TYPE(mp_para_env_type),
POINTER :: para_env
248 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
250 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
251 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
253 CALL timeset(routinen, handle)
256 NULLIFY (work_matrices%shalf)
257 NULLIFY (work_matrices%ewald_env)
258 NULLIFY (work_matrices%ewald_pw)
259 NULLIFY (work_matrices%gamma_exchange)
260 NULLIFY (work_matrices%ctransformed)
261 NULLIFY (work_matrices%S_eigenvalues)
262 NULLIFY (work_matrices%S_eigenvectors)
263 NULLIFY (work_matrices%slambda)
266 NULLIFY (work_matrices%hartree_local)
267 NULLIFY (work_matrices%local_rho_set)
268 NULLIFY (work_matrices%local_rho_set_admm)
271 NULLIFY (work_matrices%rho_xc_struct_sub)
273 nspins =
SIZE(gs_mos)
274 CALL get_qs_env(qs_env, blacs_env=blacs_env, matrix_s=matrix_s)
275 CALL dbcsr_get_info(matrix_s(1)%matrix, nfullrows_total=nao)
278 nmo_occ(ispin) =
SIZE(gs_mos(ispin)%evals_occ)
279 nmo_virt(ispin) =
SIZE(gs_mos(ispin)%evals_virt)
284 cpassert(
ASSOCIATED(sub_env%admm_A))
285 CALL get_admm_env(qs_env%admm_env, matrix_s_aux_fit=matrix_s_aux_fit)
286 CALL dbcsr_get_info(matrix_s_aux_fit(1)%matrix, nfullrows_total=nao_aux)
290 ALLOCATE (work_matrices%fm_pool_ao_mo_occ(nspins))
292 NULLIFY (work_matrices%fm_pool_ao_mo_occ(ispin)%pool)
293 CALL cp_fm_struct_create(fm_struct, nrow_global=nao, ncol_global=nmo_occ(ispin), context=blacs_env)
294 CALL fm_pool_create(work_matrices%fm_pool_ao_mo_occ(ispin)%pool, fm_struct)
298 ALLOCATE (work_matrices%S_C0_C0T(nspins))
301 CALL cp_fm_create(work_matrices%S_C0_C0T(ispin), fm_struct)
305 ALLOCATE (work_matrices%S_C0(nspins))
307 CALL fm_pool_create_fm(work_matrices%fm_pool_ao_mo_occ(ispin)%pool, work_matrices%S_C0(ispin))
310 ncol=nmo_occ(ispin), alpha=1.0_dp, beta=0.0_dp)
311 CALL parallel_gemm(
'N',
'T', nao, nao, nmo_occ(ispin), 1.0_dp, work_matrices%S_C0(ispin), &
312 gs_mos(ispin)%mos_occ, 0.0_dp, work_matrices%S_C0_C0T(ispin))
315 IF (sub_env%is_split)
THEN
318 ncol_global=nmo_occ(ispin), context=sub_env%blacs_env)
321 ALLOCATE (work_matrices%evects_sub(nspins, nstates), work_matrices%Aop_evects_sub(nspins, nstates))
323 CALL blacs_env%get(para_env=para_env)
324 igroup = sub_env%group_distribution(para_env%mepos)
325 ngroups = sub_env%ngroups
327 DO istate = ngroups - igroup, nstates, ngroups
329 CALL cp_fm_create(work_matrices%evects_sub(ispin, istate), fm_struct_evects(ispin)%struct)
330 CALL cp_fm_create(work_matrices%Aop_evects_sub(ispin, istate), fm_struct_evects(ispin)%struct)
334 DO ispin = nspins, 1, -1
339 CALL cp_fm_struct_create(fm_struct, nrow_global=nao, ncol_global=nao, context=sub_env%blacs_env)
340 ALLOCATE (work_matrices%rho_ao_orb_fm_sub)
341 CALL cp_fm_create(work_matrices%rho_ao_orb_fm_sub, fm_struct)
344 NULLIFY (work_matrices%rho_ao_aux_fit_fm_sub, work_matrices%wfm_aux_orb_sub)
346 CALL cp_fm_struct_create(fm_struct, nrow_global=nao_aux, ncol_global=nao_aux, context=sub_env%blacs_env)
347 ALLOCATE (work_matrices%rho_ao_aux_fit_fm_sub)
348 CALL cp_fm_create(work_matrices%rho_ao_aux_fit_fm_sub, fm_struct)
351 CALL cp_fm_struct_create(fm_struct, nrow_global=nao_aux, ncol_global=nao, context=sub_env%blacs_env)
352 ALLOCATE (work_matrices%wfm_aux_orb_sub)
353 CALL cp_fm_create(work_matrices%wfm_aux_orb_sub, fm_struct)
358 NULLIFY (work_matrices%A_ia_munu_sub)
361 CALL dbcsr_init_p(work_matrices%A_ia_munu_sub(ispin)%matrix)
363 dbcsr_dist=sub_env%dbcsr_dist, sab=sub_env%sab_orb)
370 CALL dbcsr_init_p(rho_ia_ao(ispin)%matrix)
372 dbcsr_dist=sub_env%dbcsr_dist, sab=sub_env%sab_orb)
375 NULLIFY (work_matrices%rho_orb_struct_sub)
376 ALLOCATE (work_matrices%rho_orb_struct_sub)
378 CALL qs_rho_set(work_matrices%rho_orb_struct_sub, rho_ao=rho_ia_ao)
379 CALL qs_rho_rebuild(work_matrices%rho_orb_struct_sub, qs_env, rebuild_ao=.false., &
380 rebuild_grids=.true., pw_env_external=sub_env%pw_env)
381 CALL get_qs_env(qs_env, dft_control=dft_control)
382 IF (dft_control%qs_control%gapw_xc)
THEN
386 CALL dbcsr_init_p(rho_xc_ao(ispin)%matrix)
388 dbcsr_dist=sub_env%dbcsr_dist, sab=sub_env%sab_orb)
390 NULLIFY (work_matrices%rho_xc_struct_sub)
391 ALLOCATE (work_matrices%rho_xc_struct_sub)
393 CALL qs_rho_set(work_matrices%rho_xc_struct_sub, rho_ao=rho_xc_ao)
394 CALL qs_rho_rebuild(work_matrices%rho_xc_struct_sub, qs_env, rebuild_ao=.false., &
395 rebuild_grids=.true., pw_env_external=sub_env%pw_env)
398 NULLIFY (work_matrices%rho_aux_fit_struct_sub)
403 CALL dbcsr_init_p(rho_ia_ao(ispin)%matrix)
405 dbcsr_dist=sub_env%dbcsr_dist, sab=sub_env%sab_aux_fit)
408 ALLOCATE (work_matrices%rho_aux_fit_struct_sub)
410 CALL qs_rho_set(work_matrices%rho_aux_fit_struct_sub, rho_ao=rho_ia_ao)
411 CALL qs_rho_rebuild(work_matrices%rho_aux_fit_struct_sub, qs_env, rebuild_ao=.false., &
412 rebuild_grids=.true., pw_env_external=sub_env%pw_env)
416 CALL pw_env_get(sub_env%pw_env, auxbas_pw_pool=auxbas_pw_pool)
417 ALLOCATE (work_matrices%A_ia_rspace_sub(nspins))
418 ALLOCATE (work_matrices%wpw_gspace_sub(nspins), work_matrices%wpw_rspace_sub(nspins), &
419 work_matrices%wpw_tau_rspace_sub(nspins))
421 CALL auxbas_pw_pool%create_pw(work_matrices%A_ia_rspace_sub(ispin))
422 CALL auxbas_pw_pool%create_pw(work_matrices%wpw_gspace_sub(ispin))
423 CALL auxbas_pw_pool%create_pw(work_matrices%wpw_rspace_sub(ispin))
424 CALL auxbas_pw_pool%create_pw(work_matrices%wpw_tau_rspace_sub(ispin))
430 ALLOCATE (work_matrices%fxc_rspace_sub(3))
432 CALL auxbas_pw_pool%create_pw(work_matrices%fxc_rspace_sub(ispin))
435 NULLIFY (work_matrices%fxc_rspace_sub)
439 IF (dft_control%qs_control%gapw)
THEN
441 atomic_kind_set=atomic_kind_set, &
443 qs_kind_set=qs_kind_set)
446 qs_kind_set, dft_control, sub_env%para_env)
447 CALL init_rho0(work_matrices%local_rho_set, qs_env, dft_control%qs_control%gapw_control, &
452 ELSEIF (dft_control%qs_control%gapw_xc)
THEN
454 atomic_kind_set=atomic_kind_set, &
455 qs_kind_set=qs_kind_set)
458 qs_kind_set, dft_control, sub_env%para_env)
462 NULLIFY (work_matrices%hfx_fm_ao_ao, work_matrices%hfx_rho_ao_symm, work_matrices%hfx_hmat_symm, &
463 work_matrices%hfx_rho_ao_asymm, work_matrices%hfx_hmat_asymm)
466 CALL get_qs_env(qs_env, dbcsr_dist=dbcsr_dist)
468 dbcsr_template_hfx => matrix_s_aux_fit(1)%matrix
469 IF (dft_control%qs_control%gapw .OR. dft_control%qs_control%gapw_xc)
THEN
470 CALL get_qs_env(qs_env, admm_env=admm_env, atomic_kind_set=atomic_kind_set)
473 atomic_kind_set, admm_env%admm_gapw_env%admm_kind_set, &
474 dft_control, sub_env%para_env)
477 CALL get_qs_env(qs_env, dbcsr_dist=dbcsr_dist, sab_orb=sab_hfx)
478 dbcsr_template_hfx => matrix_s(1)%matrix
482 ALLOCATE (work_matrices%hfx_fm_ao_ao)
483 CALL cp_fm_create(work_matrices%hfx_fm_ao_ao, fm_struct)
489 CALL dbcsr_init_p(work_matrices%hfx_rho_ao_symm(ispin)%matrix)
491 template=dbcsr_template_hfx, dbcsr_dist=dbcsr_dist, sab=sab_hfx)
493 CALL dbcsr_init_p(work_matrices%hfx_rho_ao_asymm(ispin)%matrix)
494 CALL dbcsr_create(work_matrices%hfx_rho_ao_asymm(ispin)%matrix, matrix_type=dbcsr_type_antisymmetric, &
495 template=work_matrices%hfx_rho_ao_symm(ispin)%matrix)
496 CALL dbcsr_complete_redistribute(work_matrices%hfx_rho_ao_symm(ispin)%matrix, &
497 work_matrices%hfx_rho_ao_asymm(ispin)%matrix)
503 CALL dbcsr_init_p(work_matrices%hfx_hmat_symm(ispin)%matrix)
505 template=dbcsr_template_hfx, dbcsr_dist=dbcsr_dist, sab=sab_hfx)
507 CALL dbcsr_init_p(work_matrices%hfx_hmat_asymm(ispin)%matrix)
508 CALL dbcsr_create(work_matrices%hfx_hmat_asymm(ispin)%matrix, matrix_type=dbcsr_type_antisymmetric, &
509 template=work_matrices%hfx_hmat_symm(ispin)%matrix)
510 CALL dbcsr_complete_redistribute(work_matrices%hfx_hmat_symm(ispin)%matrix, &
511 work_matrices%hfx_hmat_asymm(ispin)%matrix)
516 NULLIFY (work_matrices%hfxsr_fm_ao_ao, work_matrices%hfxsr_rho_ao_symm, work_matrices%hfxsr_hmat_symm, &
517 work_matrices%hfxsr_rho_ao_asymm, work_matrices%hfxsr_hmat_asymm)
522 ncol_global=nmo_occ(ispin), context=sub_env%blacs_env)
524 CALL dbcsr_init_p(work_matrices%shalf)
525 CALL dbcsr_create(work_matrices%shalf, template=matrix_s(1)%matrix)
526 ALLOCATE (work_matrices%ctransformed(nspins))
528 CALL cp_fm_create(work_matrices%ctransformed(ispin), fm_struct_evects(ispin)%struct)
531 ALLOCATE (work_matrices%S_eigenvalues(nao))
534 ALLOCATE (work_matrices%S_eigenvectors, work_matrices%slambda)
535 CALL cp_fm_create(work_matrices%S_eigenvectors, fm_struct)
544 CALL timestop(handle)
555 TYPE(tddfpt_work_matrices),
INTENT(inout) :: work_matrices
556 TYPE(qs_environment_type),
POINTER :: qs_env
557 TYPE(admm_type),
POINTER :: admm_env
559 CHARACTER(LEN=*),
PARAMETER :: routinen =
'hfxsr_create_work_matrices'
561 INTEGER :: handle, ispin, nao, nao_aux, nspins
562 TYPE(cp_blacs_env_type),
POINTER :: blacs_env
563 TYPE(cp_fm_struct_type),
POINTER :: fm_struct
564 TYPE(dbcsr_distribution_type),
POINTER :: dbcsr_dist
565 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s, matrix_s_aux_fit
566 TYPE(dbcsr_type),
POINTER :: dbcsr_template_hfx
567 TYPE(dft_control_type),
POINTER :: dft_control
568 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
571 CALL timeset(routinen, handle)
574 NULLIFY (work_matrices%hfxsr_fm_ao_ao, work_matrices%hfxsr_rho_ao_symm, work_matrices%hfxsr_hmat_symm, &
575 work_matrices%hfxsr_rho_ao_asymm, work_matrices%hfxsr_hmat_asymm)
577 CALL get_qs_env(qs_env, dft_control=dft_control, matrix_s=matrix_s, &
578 blacs_env=blacs_env, dbcsr_dist=dbcsr_dist)
579 nspins = dft_control%nspins
580 CALL dbcsr_get_info(matrix_s(1)%matrix, nfullrows_total=nao)
581 CALL get_admm_env(admm_env, matrix_s_aux_fit=matrix_s_aux_fit)
582 dbcsr_template_hfx => matrix_s_aux_fit(1)%matrix
583 CALL dbcsr_get_info(dbcsr_template_hfx, nfullrows_total=nao_aux)
586 ALLOCATE (work_matrices%hfxsr_fm_ao_ao)
587 CALL cp_fm_create(work_matrices%hfxsr_fm_ao_ao, fm_struct)
594 CALL dbcsr_init_p(work_matrices%hfxsr_rho_ao_symm(ispin)%matrix)
596 template=dbcsr_template_hfx, dbcsr_dist=dbcsr_dist, sab=sab_hfx)
598 CALL dbcsr_init_p(work_matrices%hfxsr_rho_ao_asymm(ispin)%matrix)
599 CALL dbcsr_create(work_matrices%hfxsr_rho_ao_asymm(ispin)%matrix, matrix_type=dbcsr_type_antisymmetric, &
600 template=work_matrices%hfxsr_rho_ao_symm(ispin)%matrix)
601 CALL dbcsr_complete_redistribute(work_matrices%hfxsr_rho_ao_symm(ispin)%matrix, &
602 work_matrices%hfxsr_rho_ao_asymm(ispin)%matrix)
608 CALL dbcsr_init_p(work_matrices%hfxsr_hmat_symm(ispin)%matrix)
610 template=dbcsr_template_hfx, dbcsr_dist=dbcsr_dist, sab=sab_hfx)
612 CALL dbcsr_init_p(work_matrices%hfxsr_hmat_asymm(ispin)%matrix)
613 CALL dbcsr_create(work_matrices%hfxsr_hmat_asymm(ispin)%matrix, matrix_type=dbcsr_type_antisymmetric, &
614 template=work_matrices%hfxsr_hmat_symm(ispin)%matrix)
615 CALL dbcsr_complete_redistribute(work_matrices%hfxsr_hmat_symm(ispin)%matrix, &
616 work_matrices%hfxsr_hmat_asymm(ispin)%matrix)
619 CALL timestop(handle)
634 TYPE(tddfpt_work_matrices),
INTENT(out) :: work_matrices
635 TYPE(tddfpt_ground_state_mos),
DIMENSION(:), &
637 INTEGER,
INTENT(in) :: nstates
638 TYPE(qs_environment_type),
POINTER :: qs_env
639 TYPE(tddfpt_subgroup_env_type),
INTENT(in) :: sub_env
641 CHARACTER(LEN=*),
PARAMETER :: routinen =
'stda_create_work_matrices'
643 INTEGER :: handle, igroup, ispin, istate, nao, &
645 INTEGER,
DIMENSION(maxspins) :: nmo_occ, nmo_virt
646 TYPE(cp_blacs_env_type),
POINTER :: blacs_env
647 TYPE(cp_fm_struct_p_type),
DIMENSION(maxspins) :: fm_struct_evects
648 TYPE(cp_fm_struct_type),
POINTER :: fm_struct
649 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s
650 TYPE(mp_para_env_type),
POINTER :: para_env
652 CALL timeset(routinen, handle)
654 NULLIFY (work_matrices%gamma_exchange, work_matrices%ctransformed)
656 nspins =
SIZE(gs_mos)
657 CALL get_qs_env(qs_env, blacs_env=blacs_env, matrix_s=matrix_s)
658 CALL dbcsr_get_info(matrix_s(1)%matrix, nfullrows_total=nao)
661 nmo_occ(ispin) =
SIZE(gs_mos(ispin)%evals_occ)
662 nmo_virt(ispin) =
SIZE(gs_mos(ispin)%evals_virt)
666 ALLOCATE (work_matrices%fm_pool_ao_mo_occ(nspins))
668 NULLIFY (work_matrices%fm_pool_ao_mo_occ(ispin)%pool)
669 CALL cp_fm_struct_create(fm_struct, nrow_global=nao, ncol_global=nmo_occ(ispin), context=blacs_env)
670 CALL fm_pool_create(work_matrices%fm_pool_ao_mo_occ(ispin)%pool, fm_struct)
674 ALLOCATE (work_matrices%S_C0_C0T(nspins))
677 CALL cp_fm_create(work_matrices%S_C0_C0T(ispin), fm_struct)
681 ALLOCATE (work_matrices%S_C0(nspins))
683 CALL fm_pool_create_fm(work_matrices%fm_pool_ao_mo_occ(ispin)%pool, work_matrices%S_C0(ispin))
686 ncol=nmo_occ(ispin), alpha=1.0_dp, beta=0.0_dp)
687 CALL parallel_gemm(
'N',
'T', nao, nao, nmo_occ(ispin), 1.0_dp, work_matrices%S_C0(ispin), &
688 gs_mos(ispin)%mos_occ, 0.0_dp, work_matrices%S_C0_C0T(ispin))
693 ncol_global=nmo_occ(ispin), context=sub_env%blacs_env)
696 IF (sub_env%is_split)
THEN
697 ALLOCATE (work_matrices%evects_sub(nspins, nstates), work_matrices%Aop_evects_sub(nspins, nstates))
699 CALL blacs_env%get(para_env=para_env)
700 igroup = sub_env%group_distribution(para_env%mepos)
701 ngroups = sub_env%ngroups
703 DO istate = ngroups - igroup, nstates, ngroups
705 CALL cp_fm_create(work_matrices%evects_sub(ispin, istate), fm_struct_evects(ispin)%struct)
706 CALL cp_fm_create(work_matrices%Aop_evects_sub(ispin, istate), fm_struct_evects(ispin)%struct)
712 ALLOCATE (work_matrices%ctransformed(nspins))
714 CALL cp_fm_create(work_matrices%ctransformed(ispin), fm_struct_evects(ispin)%struct)
716 NULLIFY (work_matrices%shalf)
717 CALL dbcsr_init_p(work_matrices%shalf)
718 CALL dbcsr_create(work_matrices%shalf, template=matrix_s(1)%matrix)
720 ALLOCATE (work_matrices%S_eigenvalues(nao))
723 ALLOCATE (work_matrices%S_eigenvectors, work_matrices%slambda)
724 CALL cp_fm_create(work_matrices%S_eigenvectors, fm_struct)
728 DO ispin = nspins, 1, -1
732 NULLIFY (work_matrices%rho_ao_orb_fm_sub)
733 NULLIFY (work_matrices%rho_ao_aux_fit_fm_sub, work_matrices%wfm_aux_orb_sub)
734 NULLIFY (work_matrices%rho_aux_fit_struct_sub)
735 NULLIFY (work_matrices%rho_orb_struct_sub)
736 NULLIFY (work_matrices%hfx_fm_ao_ao, work_matrices%hfx_rho_ao_symm, work_matrices%hfx_hmat_symm, &
737 work_matrices%hfx_rho_ao_asymm, work_matrices%hfx_hmat_asymm)
738 NULLIFY (work_matrices%hfxsr_fm_ao_ao, work_matrices%hfxsr_rho_ao_symm, work_matrices%hfxsr_hmat_symm, &
739 work_matrices%hfxsr_rho_ao_asymm, work_matrices%hfxsr_hmat_asymm)
740 NULLIFY (work_matrices%A_ia_rspace_sub, work_matrices%wpw_gspace_sub, &
741 work_matrices%wpw_rspace_sub)
742 NULLIFY (work_matrices%fxc_rspace_sub)
743 NULLIFY (work_matrices%A_ia_munu_sub)
745 NULLIFY (work_matrices%ewald_env)
746 NULLIFY (work_matrices%ewald_pw)
748 NULLIFY (work_matrices%hartree_local)
749 NULLIFY (work_matrices%local_rho_set)
750 NULLIFY (work_matrices%local_rho_set_admm)
751 NULLIFY (work_matrices%rho_xc_struct_sub)
753 CALL timestop(handle)
765 TYPE(tddfpt_work_matrices),
INTENT(inout) :: work_matrices
766 TYPE(tddfpt_subgroup_env_type),
INTENT(in) :: sub_env
768 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tddfpt_release_work_matrices'
770 INTEGER :: handle, ispin
771 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
773 CALL timeset(routinen, handle)
776 IF (
ASSOCIATED(work_matrices%hfx_hmat_symm))
THEN
777 DO ispin =
SIZE(work_matrices%hfx_hmat_symm), 1, -1
778 CALL dbcsr_deallocate_matrix(work_matrices%hfx_hmat_symm(ispin)%matrix)
780 DEALLOCATE (work_matrices%hfx_hmat_symm)
783 IF (
ASSOCIATED(work_matrices%hfx_hmat_asymm))
THEN
784 DO ispin =
SIZE(work_matrices%hfx_hmat_asymm), 1, -1
785 CALL dbcsr_deallocate_matrix(work_matrices%hfx_hmat_asymm(ispin)%matrix)
787 DEALLOCATE (work_matrices%hfx_hmat_asymm)
790 IF (
ASSOCIATED(work_matrices%hfx_rho_ao_symm))
THEN
791 DO ispin =
SIZE(work_matrices%hfx_rho_ao_symm), 1, -1
792 CALL dbcsr_deallocate_matrix(work_matrices%hfx_rho_ao_symm(ispin)%matrix)
794 DEALLOCATE (work_matrices%hfx_rho_ao_symm)
797 IF (
ASSOCIATED(work_matrices%hfx_rho_ao_asymm))
THEN
798 DO ispin =
SIZE(work_matrices%hfx_rho_ao_asymm), 1, -1
799 CALL dbcsr_deallocate_matrix(work_matrices%hfx_rho_ao_asymm(ispin)%matrix)
801 DEALLOCATE (work_matrices%hfx_rho_ao_asymm)
804 IF (
ASSOCIATED(work_matrices%hfx_fm_ao_ao))
THEN
805 CALL cp_fm_release(work_matrices%hfx_fm_ao_ao)
806 DEALLOCATE (work_matrices%hfx_fm_ao_ao)
810 IF (
ASSOCIATED(work_matrices%hfxsr_hmat_symm))
THEN
811 DO ispin =
SIZE(work_matrices%hfxsr_hmat_symm), 1, -1
812 CALL dbcsr_deallocate_matrix(work_matrices%hfxsr_hmat_symm(ispin)%matrix)
814 DEALLOCATE (work_matrices%hfxsr_hmat_symm)
817 IF (
ASSOCIATED(work_matrices%hfxsr_hmat_asymm))
THEN
818 DO ispin =
SIZE(work_matrices%hfxsr_hmat_asymm), 1, -1
819 CALL dbcsr_deallocate_matrix(work_matrices%hfxsr_hmat_asymm(ispin)%matrix)
821 DEALLOCATE (work_matrices%hfxsr_hmat_asymm)
824 IF (
ASSOCIATED(work_matrices%hfxsr_rho_ao_symm))
THEN
825 DO ispin =
SIZE(work_matrices%hfxsr_rho_ao_symm), 1, -1
826 CALL dbcsr_deallocate_matrix(work_matrices%hfxsr_rho_ao_symm(ispin)%matrix)
828 DEALLOCATE (work_matrices%hfxsr_rho_ao_symm)
831 IF (
ASSOCIATED(work_matrices%hfxsr_rho_ao_asymm))
THEN
832 DO ispin =
SIZE(work_matrices%hfxsr_rho_ao_asymm), 1, -1
833 CALL dbcsr_deallocate_matrix(work_matrices%hfxsr_rho_ao_asymm(ispin)%matrix)
835 DEALLOCATE (work_matrices%hfxsr_rho_ao_asymm)
838 IF (
ASSOCIATED(work_matrices%hfxsr_fm_ao_ao))
THEN
839 CALL cp_fm_release(work_matrices%hfxsr_fm_ao_ao)
840 DEALLOCATE (work_matrices%hfxsr_fm_ao_ao)
844 IF (
ASSOCIATED(sub_env%pw_env))
THEN
845 CALL pw_env_get(sub_env%pw_env, auxbas_pw_pool=auxbas_pw_pool)
846 DO ispin =
SIZE(work_matrices%wpw_rspace_sub), 1, -1
847 CALL auxbas_pw_pool%give_back_pw(work_matrices%wpw_rspace_sub(ispin))
848 CALL auxbas_pw_pool%give_back_pw(work_matrices%wpw_tau_rspace_sub(ispin))
849 CALL auxbas_pw_pool%give_back_pw(work_matrices%wpw_gspace_sub(ispin))
850 CALL auxbas_pw_pool%give_back_pw(work_matrices%A_ia_rspace_sub(ispin))
852 DEALLOCATE (work_matrices%A_ia_rspace_sub, work_matrices%wpw_gspace_sub, &
853 work_matrices%wpw_rspace_sub, work_matrices%wpw_tau_rspace_sub)
854 IF (
ASSOCIATED(work_matrices%fxc_rspace_sub))
THEN
855 DO ispin =
SIZE(work_matrices%fxc_rspace_sub), 1, -1
856 CALL auxbas_pw_pool%give_back_pw(work_matrices%fxc_rspace_sub(ispin))
858 DEALLOCATE (work_matrices%fxc_rspace_sub)
862 IF (
ASSOCIATED(work_matrices%rho_aux_fit_struct_sub))
THEN
864 DEALLOCATE (work_matrices%rho_aux_fit_struct_sub)
866 IF (
ASSOCIATED(work_matrices%rho_orb_struct_sub))
THEN
868 DEALLOCATE (work_matrices%rho_orb_struct_sub)
871 IF (
ASSOCIATED(work_matrices%A_ia_munu_sub))
THEN
872 DO ispin =
SIZE(work_matrices%A_ia_munu_sub), 1, -1
873 CALL dbcsr_deallocate_matrix(work_matrices%A_ia_munu_sub(ispin)%matrix)
875 DEALLOCATE (work_matrices%A_ia_munu_sub)
878 IF (
ASSOCIATED(work_matrices%wfm_aux_orb_sub))
THEN
879 CALL cp_fm_release(work_matrices%wfm_aux_orb_sub)
880 DEALLOCATE (work_matrices%wfm_aux_orb_sub)
881 NULLIFY (work_matrices%wfm_aux_orb_sub)
883 IF (
ASSOCIATED(work_matrices%rho_ao_aux_fit_fm_sub))
THEN
884 CALL cp_fm_release(work_matrices%rho_ao_aux_fit_fm_sub)
885 DEALLOCATE (work_matrices%rho_ao_aux_fit_fm_sub)
886 NULLIFY (work_matrices%rho_ao_aux_fit_fm_sub)
888 IF (
ASSOCIATED(work_matrices%rho_ao_orb_fm_sub))
THEN
889 CALL cp_fm_release(work_matrices%rho_ao_orb_fm_sub)
890 DEALLOCATE (work_matrices%rho_ao_orb_fm_sub)
891 NULLIFY (work_matrices%rho_ao_orb_fm_sub)
894 CALL cp_fm_release(work_matrices%Aop_evects_sub)
895 CALL cp_fm_release(work_matrices%evects_sub)
897 CALL cp_fm_release(work_matrices%S_C0)
898 CALL cp_fm_release(work_matrices%S_C0_C0T)
900 DO ispin =
SIZE(work_matrices%fm_pool_ao_mo_occ), 1, -1
903 DEALLOCATE (work_matrices%fm_pool_ao_mo_occ)
906 IF (
ASSOCIATED(work_matrices%gamma_exchange))
THEN
908 NULLIFY (work_matrices%gamma_exchange)
910 IF (
ASSOCIATED(work_matrices%ctransformed))
THEN
911 CALL cp_fm_release(work_matrices%ctransformed)
912 NULLIFY (work_matrices%ctransformed)
914 CALL dbcsr_release_p(work_matrices%shalf)
916 IF (
ASSOCIATED(work_matrices%S_eigenvectors))
THEN
917 CALL cp_fm_release(work_matrices%S_eigenvectors)
918 DEALLOCATE (work_matrices%S_eigenvectors)
920 IF (
ASSOCIATED(work_matrices%slambda))
THEN
921 CALL cp_fm_release(work_matrices%slambda)
922 DEALLOCATE (work_matrices%slambda)
924 IF (
ASSOCIATED(work_matrices%S_eigenvalues)) &
925 DEALLOCATE (work_matrices%S_eigenvalues)
927 IF (
ASSOCIATED(work_matrices%ewald_env))
THEN
929 DEALLOCATE (work_matrices%ewald_env)
931 IF (
ASSOCIATED(work_matrices%ewald_pw))
THEN
933 DEALLOCATE (work_matrices%ewald_pw)
936 IF (
ASSOCIATED(work_matrices%local_rho_set))
THEN
939 IF (
ASSOCIATED(work_matrices%local_rho_set_admm))
THEN
942 IF (
ASSOCIATED(work_matrices%hartree_local))
THEN
946 IF (
ASSOCIATED(work_matrices%rho_xc_struct_sub))
THEN
948 DEALLOCATE (work_matrices%rho_xc_struct_sub)
951 CALL timestop(handle)
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.
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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
pool for for elements that are retained and released
subroutine, public fm_pool_create_fm(pool, element, name)
returns an element, allocating it if none is in the pool
subroutine, public fm_pool_create(pool, el_struct)
creates a pool of elements
subroutine, public fm_pool_release(pool)
releases the given pool (see cp2k/doc/ReferenceCounting.html)
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_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
subroutine, public ewald_env_release(ewald_env)
releases the given ewald_env (see doc/ReferenceCounting.html)
subroutine, public ewald_pw_release(ewald_pw)
releases the memory used by the ewald_pw
subroutine, public init_coulomb_local(hartree_local, natom)
...
subroutine, public hartree_local_release(hartree_local)
...
subroutine, public hartree_local_create(hartree_local)
...
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
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
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, 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_nonbond, sab_almo, sab_kp, sab_kp_nosym, 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, 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, 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, ecoul_1c, rho0_s_rs, rho0_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, 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, rhs)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public local_rho_set_create(local_rho_set)
...
subroutine, public local_rho_set_release(local_rho_set)
...
Define the neighbor list data types and the corresponding functionality.
subroutine, public rho0_s_grid_create(pw_env, rho0_mpole)
...
subroutine, public init_rho0(local_rho_set, qs_env, gapw_control, zcore)
...
subroutine, public allocate_rho_atom_internals(rho_atom_set, atomic_kind_set, qs_kind_set, dft_control, para_env)
...
methods of the rho structure (defined in qs_rho_types)
subroutine, public qs_rho_rebuild(rho, qs_env, rebuild_ao, rebuild_grids, admm, pw_env_external)
rebuilds rho (if necessary allocating and initializing it)
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_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 tddfpt_dbcsr_create_by_dist(matrix, template, dbcsr_dist, sab)
Create a DBCSR matrix based on a template matrix, distribution object, and the list of neighbours.
subroutine, public hfxsr_create_work_matrices(work_matrices, qs_env, admm_env)
Allocate work matrices for hfxsr.
subroutine, public tddfpt_release_work_matrices(work_matrices, sub_env)
Release work matrices.
subroutine, public stda_create_work_matrices(work_matrices, gs_mos, nstates, qs_env, sub_env)
Allocate work matrices for sTDA kernel.
subroutine, public tddfpt_create_work_matrices(work_matrices, gs_mos, nstates, do_hfx, do_admm, do_hfxlr, do_exck, qs_env, sub_env)
Allocate work matrices for full kernel.