23 USE dbcsr_api,
ONLY: &
24 dbcsr_add, dbcsr_copy, dbcsr_create, dbcsr_p_type, dbcsr_scale, dbcsr_set, dbcsr_type, &
25 dbcsr_type_antisymmetric, dbcsr_type_symmetric
62 #include "./base/base_uses.f90"
67 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
68 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_rho_methods'
95 SUBROUTINE qs_rho_rebuild(rho, qs_env, rebuild_ao, rebuild_grids, admm, pw_env_external)
96 TYPE(qs_rho_type),
INTENT(INOUT) :: rho
97 TYPE(qs_environment_type),
POINTER :: qs_env
98 LOGICAL,
INTENT(in),
OPTIONAL :: rebuild_ao, rebuild_grids, admm
99 TYPE(pw_env_type),
OPTIONAL,
POINTER :: pw_env_external
101 CHARACTER(LEN=*),
PARAMETER :: routinen =
'qs_rho_rebuild'
103 CHARACTER(LEN=default_string_length) :: headline
104 INTEGER :: handle, i, ic, j, nimg, nspins
105 LOGICAL :: do_kpoints, my_admm, my_rebuild_ao, &
106 my_rebuild_grids, rho_ao_is_complex
107 REAL(kind=
dp),
DIMENSION(:),
POINTER :: tot_rho_r
108 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s_kp, rho_ao_im_kp, rho_ao_kp
109 TYPE(dbcsr_type),
POINTER :: refmatrix, tmatrix
110 TYPE(dft_control_type),
POINTER :: dft_control
111 TYPE(kpoint_type),
POINTER :: kpoints
112 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
114 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g, tau_g
115 TYPE(pw_c1d_gs_type),
DIMENSION(:, :),
POINTER :: drho_g
116 TYPE(pw_env_type),
POINTER :: pw_env
117 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
118 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r, tau_r
119 TYPE(pw_r3d_rs_type),
DIMENSION(:, :),
POINTER :: drho_r
120 TYPE(pw_r3d_rs_type),
POINTER :: rho_r_sccs
122 CALL timeset(routinen, handle)
124 NULLIFY (pw_env, auxbas_pw_pool, matrix_s_kp, dft_control)
125 NULLIFY (tot_rho_r, rho_ao_kp, rho_r, rho_g, drho_r, drho_g, tau_r, tau_g, rho_ao_im_kp)
128 my_rebuild_ao = .true.
129 my_rebuild_grids = .true.
131 IF (
PRESENT(rebuild_ao)) my_rebuild_ao = rebuild_ao
132 IF (
PRESENT(rebuild_grids)) my_rebuild_grids = rebuild_grids
133 IF (
PRESENT(admm)) my_admm = admm
137 do_kpoints=do_kpoints, &
139 dft_control=dft_control)
140 IF (
PRESENT(pw_env_external)) &
141 pw_env => pw_env_external
143 nimg = dft_control%nimages
146 CALL get_admm_env(qs_env%admm_env, sab_aux_fit=sab_orb, matrix_s_aux_fit_kp=matrix_s_kp)
148 CALL get_qs_env(qs_env, matrix_s_kp=matrix_s_kp)
156 refmatrix => matrix_s_kp(1, 1)%matrix
158 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
159 nspins = dft_control%nspins
162 tot_rho_r=tot_rho_r, &
163 rho_ao_kp=rho_ao_kp, &
164 rho_ao_im_kp=rho_ao_im_kp, &
171 rho_r_sccs=rho_r_sccs, &
172 complex_rho_ao=rho_ao_is_complex)
174 IF (.NOT.
ASSOCIATED(tot_rho_r))
THEN
175 ALLOCATE (tot_rho_r(nspins))
181 IF (my_rebuild_ao .OR. (.NOT.
ASSOCIATED(rho_ao_kp)))
THEN
182 IF (
ASSOCIATED(rho_ao_kp)) &
191 headline =
"DENSITY MATRIX FOR ALPHA SPIN"
193 headline =
"DENSITY MATRIX FOR BETA SPIN"
196 headline =
"DENSITY MATRIX"
198 ALLOCATE (rho_ao_kp(i, ic)%matrix)
199 tmatrix => rho_ao_kp(i, ic)%matrix
200 CALL dbcsr_create(matrix=tmatrix, template=refmatrix, name=trim(headline), &
201 matrix_type=dbcsr_type_symmetric, nze=0)
203 CALL dbcsr_set(tmatrix, 0.0_dp)
206 IF (rho_ao_is_complex)
THEN
207 IF (
ASSOCIATED(rho_ao_im_kp))
THEN
211 CALL qs_rho_set(rho, rho_ao_im_kp=rho_ao_im_kp)
216 headline =
"IMAGINARY PART OF DENSITY MATRIX FOR ALPHA SPIN"
218 headline =
"IMAGINARY PART OF DENSITY MATRIX FOR BETA SPIN"
221 headline =
"IMAGINARY PART OF DENSITY MATRIX"
223 ALLOCATE (rho_ao_im_kp(i, ic)%matrix)
224 tmatrix => rho_ao_im_kp(i, ic)%matrix
225 CALL dbcsr_create(matrix=tmatrix, template=refmatrix, name=trim(headline), &
226 matrix_type=dbcsr_type_antisymmetric, nze=0)
228 CALL dbcsr_set(tmatrix, 0.0_dp)
235 IF (my_rebuild_grids .OR. .NOT.
ASSOCIATED(rho_r))
THEN
236 IF (
ASSOCIATED(rho_r))
THEN
237 DO i = 1,
SIZE(rho_r)
238 CALL rho_r(i)%release()
242 ALLOCATE (rho_r(nspins))
245 CALL auxbas_pw_pool%create_pw(rho_r(i))
250 IF (my_rebuild_grids .OR. .NOT.
ASSOCIATED(rho_g))
THEN
251 IF (
ASSOCIATED(rho_g))
THEN
252 DO i = 1,
SIZE(rho_g)
253 CALL rho_g(i)%release()
257 ALLOCATE (rho_g(nspins))
260 CALL auxbas_pw_pool%create_pw(rho_g(i))
265 IF (dft_control%do_sccs)
THEN
266 IF (my_rebuild_grids .OR. (.NOT.
ASSOCIATED(rho_r_sccs)))
THEN
267 IF (
ASSOCIATED(rho_r_sccs))
THEN
268 CALL rho_r_sccs%release()
269 DEALLOCATE (rho_r_sccs)
271 ALLOCATE (rho_r_sccs)
273 CALL auxbas_pw_pool%create_pw(rho_r_sccs)
274 CALL pw_zero(rho_r_sccs)
279 IF (dft_control%drho_by_collocation)
THEN
281 IF (my_rebuild_grids .OR. .NOT.
ASSOCIATED(drho_r))
THEN
282 IF (
ASSOCIATED(drho_r))
THEN
283 DO j = 1,
SIZE(drho_r, 2)
284 DO i = 1,
SIZE(drho_r, 1)
285 CALL drho_r(i, j)%release()
290 ALLOCATE (drho_r(3, nspins))
294 CALL auxbas_pw_pool%create_pw(drho_r(i, j))
299 IF (my_rebuild_grids .OR. .NOT.
ASSOCIATED(drho_g))
THEN
300 IF (
ASSOCIATED(drho_g))
THEN
301 DO j = 1,
SIZE(drho_g, 2)
302 DO i = 1,
SIZE(drho_r, 1)
303 CALL drho_g(i, j)%release()
308 ALLOCATE (drho_g(3, nspins))
312 CALL auxbas_pw_pool%create_pw(drho_g(i, j))
319 IF (dft_control%use_kinetic_energy_density)
THEN
321 IF (my_rebuild_grids .OR. .NOT.
ASSOCIATED(tau_r))
THEN
322 IF (
ASSOCIATED(tau_r))
THEN
323 DO i = 1,
SIZE(tau_r)
324 CALL tau_r(i)%release()
328 ALLOCATE (tau_r(nspins))
331 CALL auxbas_pw_pool%create_pw(tau_r(i))
336 IF (my_rebuild_grids .OR. .NOT.
ASSOCIATED(tau_g))
THEN
337 IF (
ASSOCIATED(tau_g))
THEN
338 DO i = 1,
SIZE(tau_g)
339 CALL tau_g(i)%release()
343 ALLOCATE (tau_g(nspins))
346 CALL auxbas_pw_pool%create_pw(tau_g(i))
351 CALL timestop(handle)
373 task_list_external, task_list_external_soft, &
374 pw_env_external, para_env_external)
375 TYPE(qs_rho_type),
INTENT(INOUT) :: rho_struct
376 TYPE(qs_environment_type),
POINTER :: qs_env
377 TYPE(qs_rho_type),
OPTIONAL,
POINTER :: rho_xc_external
378 TYPE(local_rho_type),
OPTIONAL,
POINTER :: local_rho_set
379 TYPE(task_list_type),
OPTIONAL,
POINTER :: task_list_external, &
380 task_list_external_soft
381 TYPE(pw_env_type),
OPTIONAL,
POINTER :: pw_env_external
382 TYPE(mp_para_env_type),
OPTIONAL,
POINTER :: para_env_external
384 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
385 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
386 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: rho_ao
387 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_kp
388 TYPE(dft_control_type),
POINTER :: dft_control
389 TYPE(kpoint_type),
POINTER :: kpoints
390 TYPE(lri_density_type),
POINTER :: lri_density
391 TYPE(lri_environment_type),
POINTER :: lri_env
392 TYPE(mp_para_env_type),
POINTER :: para_env
393 TYPE(qs_ks_env_type),
POINTER :: ks_env
395 CALL get_qs_env(qs_env, dft_control=dft_control, &
396 atomic_kind_set=atomic_kind_set, &
398 IF (
PRESENT(para_env_external)) para_env => para_env_external
400 IF (dft_control%qs_control%semi_empirical .OR. &
401 dft_control%qs_control%dftb .OR. dft_control%qs_control%xtb)
THEN
403 CALL qs_rho_set(rho_struct, rho_r_valid=.false., rho_g_valid=.false.)
405 ELSEIF (dft_control%qs_control%lrigpw)
THEN
406 cpassert(.NOT. dft_control%use_kinetic_energy_density)
407 cpassert(.NOT. dft_control%drho_by_collocation)
408 CALL qs_rho_get(rho_struct, rho_ao_kp=rho_ao_kp)
410 CALL get_ks_env(ks_env=ks_env, kpoints=kpoints)
412 CALL get_qs_env(qs_env, lri_env=lri_env, lri_density=lri_density)
414 lri_rho_struct=rho_struct, &
415 atomic_kind_set=atomic_kind_set, &
417 response_density=.false.)
418 CALL set_qs_env(qs_env, lri_density=lri_density)
419 CALL qs_rho_set(rho_struct, rho_r_valid=.true., rho_g_valid=.true.)
421 ELSEIF (dft_control%qs_control%rigpw)
THEN
422 cpassert(.NOT. dft_control%use_kinetic_energy_density)
423 cpassert(.NOT. dft_control%drho_by_collocation)
427 lri_rho_struct=rho_struct, &
428 atomic_kind_set=atomic_kind_set, &
430 CALL qs_rho_set(rho_struct, rho_r_valid=.true., rho_g_valid=.true.)
433 CALL qs_rho_update_rho_low(rho_struct=rho_struct, qs_env=qs_env, &
434 rho_xc_external=rho_xc_external, &
435 local_rho_set=local_rho_set, &
436 task_list_external=task_list_external, &
437 task_list_external_soft=task_list_external_soft, &
438 pw_env_external=pw_env_external, &
439 para_env_external=para_env_external)
461 SUBROUTINE qs_rho_update_rho_low(rho_struct, qs_env, rho_xc_external, &
462 local_rho_set, pw_env_external, &
463 task_list_external, task_list_external_soft, &
465 TYPE(qs_rho_type),
INTENT(INOUT) :: rho_struct
466 TYPE(qs_environment_type),
POINTER :: qs_env
467 TYPE(qs_rho_type),
OPTIONAL,
POINTER :: rho_xc_external
468 TYPE(local_rho_type),
OPTIONAL,
POINTER :: local_rho_set
469 TYPE(pw_env_type),
OPTIONAL,
POINTER :: pw_env_external
470 TYPE(task_list_type),
OPTIONAL,
POINTER :: task_list_external, &
471 task_list_external_soft
472 TYPE(mp_para_env_type),
OPTIONAL,
POINTER :: para_env_external
474 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_rho_update_rho_low'
476 INTEGER :: handle, img, ispin, nimg, nspins
477 LOGICAL :: gapw, gapw_xc
479 REAL(kind=
dp),
DIMENSION(:),
POINTER :: tot_rho_r, tot_rho_r_xc
480 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
481 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: rho_ao
482 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_kp, rho_xc_ao
483 TYPE(dft_control_type),
POINTER :: dft_control
484 TYPE(mp_para_env_type),
POINTER :: para_env
485 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
487 TYPE(oce_matrix_type),
POINTER :: oce
488 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g, rho_xc_g, tau_g, tau_xc_g
489 TYPE(pw_c1d_gs_type),
DIMENSION(:, :),
POINTER :: drho_g, drho_xc_g
490 TYPE(pw_env_type),
POINTER :: pw_env
491 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r, rho_xc_r, tau_r, tau_xc_r
492 TYPE(pw_r3d_rs_type),
DIMENSION(:, :),
POINTER :: drho_r, drho_xc_r
493 TYPE(qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
494 TYPE(qs_ks_env_type),
POINTER :: ks_env
495 TYPE(qs_rho_type),
POINTER :: rho_xc
496 TYPE(rho_atom_type),
DIMENSION(:),
POINTER :: rho_atom_set
497 TYPE(task_list_type),
POINTER :: task_list
499 CALL timeset(routinen, handle)
501 NULLIFY (dft_control, rho_xc, ks_env, rho_ao, rho_r, rho_g, drho_r, drho_g, tau_r, tau_g)
502 NULLIFY (rho_xc_ao, rho_xc_g, rho_xc_r, drho_xc_g, tau_xc_r, tau_xc_g, tot_rho_r, tot_rho_r_xc)
503 NULLIFY (para_env, pw_env, atomic_kind_set)
507 dft_control=dft_control, &
508 atomic_kind_set=atomic_kind_set)
513 tot_rho_r=tot_rho_r, &
519 CALL get_qs_env(qs_env, task_list=task_list, &
520 para_env=para_env, pw_env=pw_env)
521 IF (
PRESENT(pw_env_external)) pw_env => pw_env_external
522 IF (
PRESENT(task_list_external)) task_list => task_list_external
523 IF (
PRESENT(para_env_external)) para_env => para_env_external
525 nspins = dft_control%nspins
526 nimg = dft_control%nimages
527 gapw = dft_control%qs_control%gapw
528 gapw_xc = dft_control%qs_control%gapw_xc
530 CALL qs_rho_get(rho_struct, rho_ao_kp=rho_ao_kp)
532 rho_ao => rho_ao_kp(ispin, :)
535 rho_gspace=rho_g(ispin), &
536 total_rho=tot_rho_r(ispin), &
537 ks_env=ks_env, soft_valid=gapw, &
538 task_list_external=task_list_external, &
539 pw_env_external=pw_env_external)
541 CALL qs_rho_set(rho_struct, rho_r_valid=.true., rho_g_valid=.true.)
544 IF (
PRESENT(rho_xc_external))
THEN
545 rho_xc => rho_xc_external
550 rho_ao_kp=rho_xc_ao, &
553 tot_rho_r=tot_rho_r_xc)
557 CALL dbcsr_copy(rho_xc_ao(ispin, img)%matrix, rho_ao_kp(ispin, img)%matrix)
561 rho_ao => rho_xc_ao(ispin, :)
563 rho=rho_xc_r(ispin), &
564 rho_gspace=rho_xc_g(ispin), &
565 total_rho=tot_rho_r_xc(ispin), &
566 ks_env=ks_env, soft_valid=gapw_xc, &
567 task_list_external=task_list_external_soft, &
568 pw_env_external=pw_env_external)
570 CALL qs_rho_set(rho_xc, rho_r_valid=.true., rho_g_valid=.true.)
574 IF (gapw .OR. gapw_xc)
THEN
576 rho_atom_set=rho_atom_set, &
577 qs_kind_set=qs_kind_set, &
578 oce=oce, sab_orb=sab)
579 IF (
PRESENT(local_rho_set)) rho_atom_set => local_rho_set%rho_atom_set
580 cpassert(
ASSOCIATED(rho_atom_set))
581 CALL qs_rho_get(rho_struct, rho_ao_kp=rho_ao_kp)
585 IF (.NOT. gapw_xc)
THEN
587 IF (dft_control%drho_by_collocation)
THEN
588 CALL qs_rho_get(rho_struct, rho_ao_kp=rho_ao_kp)
589 cpassert(.NOT.
PRESENT(task_list_external))
591 rho_ao => rho_ao_kp(ispin, :)
593 drho=drho_r(:, ispin), &
594 drho_gspace=drho_g(:, ispin), &
595 qs_env=qs_env, soft_valid=gapw)
597 CALL qs_rho_set(rho_struct, drho_r_valid=.true., drho_g_valid=.true.)
600 IF (dft_control%use_kinetic_energy_density)
THEN
601 CALL qs_rho_get(rho_struct, rho_ao_kp=rho_ao_kp)
603 rho_ao => rho_ao_kp(ispin, :)
606 rho_gspace=tau_g(ispin), &
608 ks_env=ks_env, soft_valid=gapw, &
609 compute_tau=.true., &
610 task_list_external=task_list_external, &
611 pw_env_external=pw_env_external)
613 CALL qs_rho_set(rho_struct, tau_r_valid=.true., tau_g_valid=.true.)
622 IF (dft_control%drho_by_collocation)
THEN
623 cpassert(.NOT.
PRESENT(task_list_external))
625 rho_ao => rho_xc_ao(ispin, :)
627 drho=drho_xc_r(:, ispin), &
628 drho_gspace=drho_xc_g(:, ispin), &
629 qs_env=qs_env, soft_valid=gapw_xc)
631 CALL qs_rho_set(rho_xc, drho_r_valid=.true., drho_g_valid=.true.)
634 IF (dft_control%use_kinetic_energy_density)
THEN
636 rho_ao => rho_xc_ao(ispin, :)
638 rho=tau_xc_r(ispin), &
639 rho_gspace=tau_xc_g(ispin), &
640 ks_env=ks_env, soft_valid=gapw_xc, &
641 compute_tau=.true., &
642 task_list_external=task_list_external_soft, &
643 pw_env_external=pw_env_external)
645 CALL qs_rho_set(rho_xc, tau_r_valid=.true., tau_g_valid=.true.)
649 CALL timestop(handle)
651 END SUBROUTINE qs_rho_update_rho_low
669 para_env_external, tddfpt_lri_env, tddfpt_lri_density)
670 TYPE(qs_rho_type),
INTENT(INOUT) :: rho_struct
671 TYPE(qs_environment_type),
POINTER :: qs_env
672 TYPE(pw_env_type),
OPTIONAL,
POINTER :: pw_env_external
673 TYPE(task_list_type),
OPTIONAL,
POINTER :: task_list_external
674 TYPE(mp_para_env_type),
OPTIONAL,
POINTER :: para_env_external
675 TYPE(lri_environment_type),
OPTIONAL,
POINTER :: tddfpt_lri_env
676 TYPE(lri_density_type),
OPTIONAL,
POINTER :: tddfpt_lri_density
678 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_rho_update_tddfpt'
680 INTEGER :: handle, ispin, nspins
681 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
682 LOGICAL :: lri_response
683 REAL(kind=
dp),
DIMENSION(:),
POINTER :: tot_rho_r
684 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
685 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: rho_ao
686 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_kp
687 TYPE(dft_control_type),
POINTER :: dft_control
688 TYPE(kpoint_type),
POINTER :: kpoints
689 TYPE(mp_para_env_type),
POINTER :: para_env
690 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g
691 TYPE(pw_env_type),
POINTER :: pw_env
692 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r
693 TYPE(qs_ks_env_type),
POINTER :: ks_env
694 TYPE(task_list_type),
POINTER :: task_list
696 CALL timeset(routinen, handle)
700 dft_control=dft_control, &
701 atomic_kind_set=atomic_kind_set, &
702 task_list=task_list, &
705 IF (
PRESENT(pw_env_external)) pw_env => pw_env_external
706 IF (
PRESENT(task_list_external)) task_list => task_list_external
707 IF (
PRESENT(para_env_external)) para_env => para_env_external
714 nspins = dft_control%nspins
716 lri_response =
PRESENT(tddfpt_lri_env)
717 IF (lri_response)
THEN
718 cpassert(
PRESENT(tddfpt_lri_density))
721 cpassert(.NOT. dft_control%drho_by_collocation)
722 cpassert(.NOT. dft_control%use_kinetic_energy_density)
723 cpassert(.NOT. dft_control%qs_control%gapw)
724 cpassert(.NOT. dft_control%qs_control%gapw_xc)
726 IF (lri_response)
THEN
727 CALL get_ks_env(ks_env=ks_env, kpoints=kpoints)
729 CALL qs_rho_get(rho_struct, rho_ao_kp=rho_ao_kp)
731 lri_rho_struct=rho_struct, &
732 atomic_kind_set=atomic_kind_set, &
734 response_density=lri_response)
735 CALL qs_rho_set(rho_struct, rho_r_valid=.true., rho_g_valid=.true.)
737 CALL qs_rho_get(rho_struct, rho_ao_kp=rho_ao_kp)
739 rho_ao => rho_ao_kp(ispin, :)
742 rho_gspace=rho_g(ispin), &
743 total_rho=tot_rho_r(ispin), &
745 task_list_external=task_list_external, &
746 pw_env_external=pw_env_external)
748 CALL qs_rho_set(rho_struct, rho_r_valid=.true., rho_g_valid=.true.)
751 CALL timestop(handle)
765 SUBROUTINE qs_rho_copy(rho_input, rho_output, auxbas_pw_pool, mspin)
767 TYPE(qs_rho_type),
INTENT(IN) :: rho_input
768 TYPE(qs_rho_type),
INTENT(INOUT) :: rho_output
769 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
770 INTEGER,
INTENT(IN) :: mspin
772 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_rho_copy'
774 INTEGER :: handle, i, j, nspins
775 LOGICAL :: complex_rho_ao, drho_g_valid_in, drho_r_valid_in, rho_g_valid_in, rho_r_valid_in, &
776 soft_valid_in, tau_g_valid_in, tau_r_valid_in
777 REAL(kind=
dp) :: ospin
778 REAL(kind=
dp),
DIMENSION(:),
POINTER :: tot_rho_g_in, tot_rho_g_out, &
779 tot_rho_r_in, tot_rho_r_out
780 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: rho_ao_im_in, rho_ao_im_out, rho_ao_in, &
782 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_kp_in
783 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g_in, rho_g_out, tau_g_in, tau_g_out
784 TYPE(pw_c1d_gs_type),
DIMENSION(:, :),
POINTER :: drho_g_in, drho_g_out
785 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r_in, rho_r_out, tau_r_in, tau_r_out
786 TYPE(pw_r3d_rs_type),
DIMENSION(:, :),
POINTER :: drho_r_in, drho_r_out
787 TYPE(pw_r3d_rs_type),
POINTER :: rho_r_sccs_in, rho_r_sccs_out
789 CALL timeset(routinen, handle)
791 cpassert(mspin == 1 .OR. mspin == 2)
792 ospin = 1._dp/real(mspin, kind=
dp)
796 NULLIFY (rho_ao_in, rho_ao_kp_in, rho_ao_im_in, rho_r_in, rho_g_in, drho_r_in, &
797 drho_g_in, tau_r_in, tau_g_in, tot_rho_r_in, tot_rho_g_in, rho_r_sccs_in)
801 rho_ao_kp=rho_ao_kp_in, &
802 rho_ao_im=rho_ao_im_in, &
809 tot_rho_r=tot_rho_r_in, &
810 tot_rho_g=tot_rho_g_in, &
811 rho_g_valid=rho_g_valid_in, &
812 rho_r_valid=rho_r_valid_in, &
813 drho_g_valid=drho_g_valid_in, &
814 drho_r_valid=drho_r_valid_in, &
815 tau_r_valid=tau_r_valid_in, &
816 tau_g_valid=tau_g_valid_in, &
817 rho_r_sccs=rho_r_sccs_in, &
818 soft_valid=soft_valid_in, &
819 complex_rho_ao=complex_rho_ao)
821 NULLIFY (rho_ao_out, rho_ao_im_out, rho_r_out, rho_g_out, drho_r_out, &
822 drho_g_out, tau_r_out, tau_g_out, tot_rho_r_out, tot_rho_g_out, rho_r_sccs_out)
824 IF (
ASSOCIATED(rho_ao_in))
THEN
825 nspins =
SIZE(rho_ao_in)
826 cpassert(mspin >= nspins)
828 CALL qs_rho_set(rho_output, rho_ao=rho_ao_out)
829 IF (mspin > nspins)
THEN
831 ALLOCATE (rho_ao_out(i)%matrix)
832 CALL dbcsr_copy(rho_ao_out(i)%matrix, rho_ao_in(1)%matrix, name=
"RHO copy")
833 CALL dbcsr_scale(rho_ao_out(i)%matrix, ospin)
837 ALLOCATE (rho_ao_out(i)%matrix)
838 CALL dbcsr_copy(rho_ao_out(i)%matrix, rho_ao_in(i)%matrix, name=
"RHO copy")
850 IF (
ASSOCIATED(rho_ao_im_in))
THEN
851 nspins =
SIZE(rho_ao_im_in)
852 cpassert(mspin >= nspins)
854 CALL qs_rho_set(rho_output, rho_ao_im=rho_ao_im_out)
855 IF (mspin > nspins)
THEN
857 ALLOCATE (rho_ao_im_out(i)%matrix)
858 CALL dbcsr_copy(rho_ao_im_out(i)%matrix, rho_ao_im_in(1)%matrix, name=
"RHO copy")
859 CALL dbcsr_scale(rho_ao_im_out(i)%matrix, ospin)
863 ALLOCATE (rho_ao_im_out(i)%matrix)
864 CALL dbcsr_copy(rho_ao_im_out(i)%matrix, rho_ao_im_in(i)%matrix, name=
"RHO copy")
870 IF (
ASSOCIATED(rho_r_in))
THEN
871 nspins =
SIZE(rho_r_in)
872 cpassert(mspin >= nspins)
873 ALLOCATE (rho_r_out(mspin))
875 IF (mspin > nspins)
THEN
877 CALL auxbas_pw_pool%create_pw(rho_r_out(i))
878 CALL pw_copy(rho_r_in(1), rho_r_out(i))
879 CALL pw_scale(rho_r_out(i), ospin)
883 CALL auxbas_pw_pool%create_pw(rho_r_out(i))
884 CALL pw_copy(rho_r_in(i), rho_r_out(i))
890 IF (
ASSOCIATED(rho_g_in))
THEN
891 nspins =
SIZE(rho_g_in)
892 cpassert(mspin >= nspins)
893 ALLOCATE (rho_g_out(mspin))
895 IF (mspin > nspins)
THEN
897 CALL auxbas_pw_pool%create_pw(rho_g_out(i))
898 CALL pw_copy(rho_g_in(1), rho_g_out(i))
899 CALL pw_scale(rho_g_out(i), ospin)
903 CALL auxbas_pw_pool%create_pw(rho_g_out(i))
904 CALL pw_copy(rho_g_in(i), rho_g_out(i))
910 IF (
ASSOCIATED(rho_r_sccs_in))
THEN
911 CALL qs_rho_set(rho_output, rho_r_sccs=rho_r_sccs_out)
912 CALL auxbas_pw_pool%create_pw(rho_r_sccs_out)
913 CALL pw_copy(rho_r_sccs_in, rho_r_sccs_out)
917 IF (
ASSOCIATED(drho_r_in))
THEN
918 nspins =
SIZE(drho_r_in)
919 cpassert(mspin >= nspins)
920 ALLOCATE (drho_r_out(3, mspin))
921 CALL qs_rho_set(rho_output, drho_r=drho_r_out)
922 IF (mspin > nspins)
THEN
925 CALL auxbas_pw_pool%create_pw(drho_r_out(i, j))
926 CALL pw_copy(drho_r_in(i, 1), drho_r_out(i, j))
927 CALL pw_scale(drho_r_out(i, j), ospin)
933 CALL auxbas_pw_pool%create_pw(drho_r_out(i, j))
934 CALL pw_copy(drho_r_in(i, j), drho_r_out(i, j))
941 IF (
ASSOCIATED(drho_g_in))
THEN
942 nspins =
SIZE(drho_g_in)
943 cpassert(mspin >= nspins)
944 ALLOCATE (drho_g_out(3, mspin))
945 CALL qs_rho_set(rho_output, drho_g=drho_g_out)
946 IF (mspin > nspins)
THEN
949 CALL auxbas_pw_pool%create_pw(drho_g_out(i, j))
950 CALL pw_copy(drho_g_in(i, 1), drho_g_out(i, j))
951 CALL pw_scale(drho_g_out(i, j), ospin)
957 CALL auxbas_pw_pool%create_pw(drho_g_out(i, j))
958 CALL pw_copy(drho_g_in(i, j), drho_g_out(i, j))
965 IF (
ASSOCIATED(tau_r_in))
THEN
966 nspins =
SIZE(tau_r_in)
967 cpassert(mspin >= nspins)
968 ALLOCATE (tau_r_out(mspin))
970 IF (mspin > nspins)
THEN
972 CALL auxbas_pw_pool%create_pw(tau_r_out(i))
973 CALL pw_copy(tau_r_in(1), tau_r_out(i))
974 CALL pw_scale(tau_r_out(i), ospin)
978 CALL auxbas_pw_pool%create_pw(tau_r_out(i))
979 CALL pw_copy(tau_r_in(i), tau_r_out(i))
985 IF (
ASSOCIATED(tau_g_in))
THEN
986 nspins =
SIZE(tau_g_in)
987 cpassert(mspin >= nspins)
988 ALLOCATE (tau_g_out(mspin))
990 IF (mspin > nspins)
THEN
992 CALL auxbas_pw_pool%create_pw(tau_g_out(i))
993 CALL pw_copy(tau_g_in(1), tau_g_out(i))
994 CALL pw_scale(tau_g_out(i), ospin)
998 CALL auxbas_pw_pool%create_pw(tau_g_out(i))
999 CALL pw_copy(tau_g_in(i), tau_g_out(i))
1005 IF (
ASSOCIATED(tot_rho_r_in))
THEN
1006 nspins =
SIZE(tot_rho_r_in)
1007 cpassert(mspin >= nspins)
1008 ALLOCATE (tot_rho_r_out(mspin))
1009 CALL qs_rho_set(rho_output, tot_rho_r=tot_rho_r_out)
1010 IF (mspin > nspins)
THEN
1012 tot_rho_r_out(i) = tot_rho_r_in(1)*ospin
1016 tot_rho_r_out(i) = tot_rho_r_in(i)
1022 IF (
ASSOCIATED(tot_rho_g_in))
THEN
1023 nspins =
SIZE(tot_rho_g_in)
1024 cpassert(mspin >= nspins)
1025 ALLOCATE (tot_rho_g_out(mspin))
1026 CALL qs_rho_set(rho_output, tot_rho_g=tot_rho_g_out)
1027 IF (mspin > nspins)
THEN
1029 tot_rho_g_out(i) = tot_rho_g_in(1)*ospin
1033 tot_rho_g_out(i) = tot_rho_g_in(i)
1039 rho_g_valid=rho_g_valid_in, &
1040 rho_r_valid=rho_r_valid_in, &
1041 drho_g_valid=drho_g_valid_in, &
1042 drho_r_valid=drho_r_valid_in, &
1043 tau_r_valid=tau_r_valid_in, &
1044 tau_g_valid=tau_g_valid_in, &
1045 soft_valid=soft_valid_in, &
1046 complex_rho_ao=complex_rho_ao)
1048 CALL timestop(handle)
1061 TYPE(qs_rho_type),
INTENT(IN) :: rhoa, rhob
1062 REAL(kind=
dp),
INTENT(IN) :: alpha, beta
1064 CHARACTER(len=*),
PARAMETER :: routinen =
'qs_rho_scale_and_add'
1066 INTEGER :: handle, i, j, nspina, nspinb, nspins
1067 REAL(kind=
dp),
DIMENSION(:),
POINTER :: tot_rho_g_a, tot_rho_g_b, tot_rho_r_a, &
1069 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: rho_ao_a, rho_ao_b, rho_ao_im_a, &
1071 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g_a, rho_g_b, tau_g_a, tau_g_b
1072 TYPE(pw_c1d_gs_type),
DIMENSION(:, :),
POINTER :: drho_g_a, drho_g_b
1073 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r_a, rho_r_b, tau_r_a, tau_r_b
1074 TYPE(pw_r3d_rs_type),
DIMENSION(:, :),
POINTER :: drho_r_a, drho_r_b
1075 TYPE(pw_r3d_rs_type),
POINTER :: rho_r_sccs_a, rho_r_sccs_b
1077 CALL timeset(routinen, handle)
1079 NULLIFY (rho_ao_a, rho_ao_im_a, rho_r_a, rho_g_a, drho_r_a, &
1080 drho_g_a, tau_r_a, tau_g_a, tot_rho_r_a, tot_rho_g_a, rho_r_sccs_a)
1084 rho_ao_im=rho_ao_im_a, &
1091 tot_rho_r=tot_rho_r_a, &
1092 tot_rho_g=tot_rho_g_a, &
1093 rho_r_sccs=rho_r_sccs_a)
1095 NULLIFY (rho_ao_b, rho_ao_im_b, rho_r_b, rho_g_b, drho_r_b, &
1096 drho_g_b, tau_r_b, tau_g_b, tot_rho_r_b, tot_rho_g_b, rho_r_sccs_b)
1100 rho_ao_im=rho_ao_im_b, &
1107 tot_rho_r=tot_rho_r_b, &
1108 tot_rho_g=tot_rho_g_b, &
1109 rho_r_sccs=rho_r_sccs_b)
1111 IF (
ASSOCIATED(rho_ao_a) .AND.
ASSOCIATED(rho_ao_b))
THEN
1112 nspina =
SIZE(rho_ao_a)
1113 nspinb =
SIZE(rho_ao_b)
1114 nspins = min(nspina, nspinb)
1116 CALL dbcsr_add(rho_ao_a(i)%matrix, rho_ao_b(i)%matrix, alpha, beta)
1121 IF (
ASSOCIATED(rho_ao_im_a) .AND.
ASSOCIATED(rho_ao_im_b))
THEN
1122 nspina =
SIZE(rho_ao_im_a)
1123 nspinb =
SIZE(rho_ao_im_b)
1124 nspins = min(nspina, nspinb)
1126 CALL dbcsr_add(rho_ao_im_a(i)%matrix, rho_ao_im_b(i)%matrix, alpha, beta)
1131 IF (
ASSOCIATED(rho_r_a) .AND.
ASSOCIATED(rho_r_b))
THEN
1132 nspina =
SIZE(rho_ao_a)
1133 nspinb =
SIZE(rho_ao_b)
1134 nspins = min(nspina, nspinb)
1136 CALL pw_axpy(rho_r_b(i), rho_r_a(i), beta, alpha)
1141 IF (
ASSOCIATED(rho_g_a) .AND.
ASSOCIATED(rho_g_b))
THEN
1142 nspina =
SIZE(rho_ao_a)
1143 nspinb =
SIZE(rho_ao_b)
1144 nspins = min(nspina, nspinb)
1146 CALL pw_axpy(rho_g_b(i), rho_g_a(i), beta, alpha)
1151 IF (
ASSOCIATED(rho_r_sccs_a) .AND.
ASSOCIATED(rho_r_sccs_b))
THEN
1152 CALL pw_axpy(rho_r_sccs_b, rho_r_sccs_a, beta, alpha)
1156 IF (
ASSOCIATED(drho_r_a) .AND.
ASSOCIATED(drho_r_b))
THEN
1157 cpassert(all(shape(drho_r_a) == shape(drho_r_b)))
1158 DO j = 1,
SIZE(drho_r_a, 2)
1159 DO i = 1,
SIZE(drho_r_a, 1)
1160 CALL pw_axpy(drho_r_b(i, j), drho_r_a(i, j), beta, alpha)
1166 IF (
ASSOCIATED(drho_g_a) .AND.
ASSOCIATED(drho_g_b))
THEN
1167 cpassert(all(shape(drho_g_a) == shape(drho_g_b)))
1168 DO j = 1,
SIZE(drho_g_a, 2)
1169 DO i = 1,
SIZE(drho_g_a, 1)
1170 CALL pw_axpy(drho_g_b(i, j), drho_g_a(i, j), beta, alpha)
1176 IF (
ASSOCIATED(tau_r_a) .AND.
ASSOCIATED(tau_r_b))
THEN
1177 nspina =
SIZE(rho_ao_a)
1178 nspinb =
SIZE(rho_ao_b)
1179 nspins = min(nspina, nspinb)
1181 CALL pw_axpy(tau_r_b(i), tau_r_a(i), beta, alpha)
1186 IF (
ASSOCIATED(tau_g_a) .AND.
ASSOCIATED(tau_g_b))
THEN
1187 nspina =
SIZE(rho_ao_a)
1188 nspinb =
SIZE(rho_ao_b)
1189 nspins = min(nspina, nspinb)
1191 CALL pw_axpy(tau_g_b(i), tau_g_a(i), beta, alpha)
1196 IF (
ASSOCIATED(tot_rho_r_a) .AND.
ASSOCIATED(tot_rho_r_b))
THEN
1197 nspina =
SIZE(rho_ao_a)
1198 nspinb =
SIZE(rho_ao_b)
1199 nspins = min(nspina, nspinb)
1201 tot_rho_r_a(i) = alpha*tot_rho_r_a(i) + beta*tot_rho_r_b(i)
1206 IF (
ASSOCIATED(tot_rho_g_a) .AND.
ASSOCIATED(tot_rho_g_b))
THEN
1207 nspina =
SIZE(rho_ao_a)
1208 nspinb =
SIZE(rho_ao_b)
1209 nspins = min(nspina, nspinb)
1211 tot_rho_g_a(i) = alpha*tot_rho_g_a(i) + beta*tot_rho_g_b(i)
1215 CALL timestop(handle)
1233 TYPE(qs_rho_type),
INTENT(INOUT) :: rho_input, rho_output
1234 TYPE(qs_environment_type),
POINTER :: qs_env
1236 CHARACTER(len=*),
PARAMETER :: routinen =
'duplicate_rho_type'
1238 INTEGER :: handle, i, j, nspins
1239 LOGICAL :: complex_rho_ao_in, drho_g_valid_in, drho_r_valid_in, rho_g_valid_in, &
1240 rho_r_valid_in, soft_valid_in, tau_g_valid_in, tau_r_valid_in
1241 REAL(kind=
dp),
DIMENSION(:),
POINTER :: tot_rho_g_in, tot_rho_g_out, &
1242 tot_rho_r_in, tot_rho_r_out
1243 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: rho_ao_im_in, rho_ao_im_out, rho_ao_in, &
1245 TYPE(dft_control_type),
POINTER :: dft_control
1246 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g_in, rho_g_out, tau_g_in, tau_g_out
1247 TYPE(pw_c1d_gs_type),
DIMENSION(:, :),
POINTER :: drho_g_in, drho_g_out
1248 TYPE(pw_env_type),
POINTER :: pw_env
1249 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
1250 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r_in, rho_r_out, tau_r_in, tau_r_out
1251 TYPE(pw_r3d_rs_type),
DIMENSION(:, :),
POINTER :: drho_r_in, drho_r_out
1252 TYPE(pw_r3d_rs_type),
POINTER :: rho_r_sccs_in, rho_r_sccs_out
1254 CALL timeset(routinen, handle)
1256 NULLIFY (dft_control, pw_env, auxbas_pw_pool)
1257 NULLIFY (rho_ao_in, rho_ao_out, rho_ao_im_in, rho_ao_im_out)
1258 NULLIFY (rho_r_in, rho_r_out, rho_g_in, rho_g_out, drho_r_in, drho_r_out)
1259 NULLIFY (drho_g_in, drho_g_out, tau_r_in, tau_r_out, tau_g_in, tau_g_out)
1260 NULLIFY (tot_rho_r_in, tot_rho_r_out, tot_rho_g_in, tot_rho_g_out)
1261 NULLIFY (rho_r_sccs_in, rho_r_sccs_out)
1263 cpassert(
ASSOCIATED(qs_env))
1265 CALL get_qs_env(qs_env=qs_env, pw_env=pw_env, dft_control=dft_control)
1266 CALL pw_env_get(pw_env=pw_env, auxbas_pw_pool=auxbas_pw_pool)
1267 nspins = dft_control%nspins
1273 rho_ao_im=rho_ao_im_in, &
1280 tot_rho_r=tot_rho_r_in, &
1281 tot_rho_g=tot_rho_g_in, &
1282 rho_g_valid=rho_g_valid_in, &
1283 rho_r_valid=rho_r_valid_in, &
1284 drho_g_valid=drho_g_valid_in, &
1285 drho_r_valid=drho_r_valid_in, &
1286 tau_r_valid=tau_r_valid_in, &
1287 tau_g_valid=tau_g_valid_in, &
1288 rho_r_sccs=rho_r_sccs_in, &
1289 soft_valid=soft_valid_in, &
1290 complex_rho_ao=complex_rho_ao_in)
1293 IF (
ASSOCIATED(rho_ao_in))
THEN
1295 CALL qs_rho_set(rho_output, rho_ao=rho_ao_out)
1297 ALLOCATE (rho_ao_out(i)%matrix)
1298 CALL dbcsr_copy(rho_ao_out(i)%matrix, rho_ao_in(i)%matrix, &
1299 name=
"myDensityMatrix_for_Spin_"//trim(adjustl(cp_to_string(i))))
1300 CALL dbcsr_set(rho_ao_out(i)%matrix, 0.0_dp)
1305 IF (
ASSOCIATED(rho_ao_im_in))
THEN
1307 CALL qs_rho_set(rho_output, rho_ao=rho_ao_im_out)
1309 ALLOCATE (rho_ao_im_out(i)%matrix)
1310 CALL dbcsr_copy(rho_ao_im_out(i)%matrix, rho_ao_im_in(i)%matrix, &
1311 name=
"myImagDensityMatrix_for_Spin_"//trim(adjustl(cp_to_string(i))))
1312 CALL dbcsr_set(rho_ao_im_out(i)%matrix, 0.0_dp)
1317 IF (
ASSOCIATED(rho_r_in))
THEN
1318 ALLOCATE (rho_r_out(nspins))
1321 CALL auxbas_pw_pool%create_pw(rho_r_out(i))
1322 CALL pw_copy(rho_r_in(i), rho_r_out(i))
1327 IF (
ASSOCIATED(rho_g_in))
THEN
1328 ALLOCATE (rho_g_out(nspins))
1331 CALL auxbas_pw_pool%create_pw(rho_g_out(i))
1332 CALL pw_copy(rho_g_in(i), rho_g_out(i))
1337 IF (
ASSOCIATED(rho_r_sccs_in))
THEN
1338 CALL qs_rho_set(rho_output, rho_r_sccs=rho_r_sccs_out)
1339 CALL auxbas_pw_pool%create_pw(rho_r_sccs_out)
1340 CALL pw_copy(rho_r_sccs_in, rho_r_sccs_out)
1344 IF (dft_control%drho_by_collocation)
THEN
1346 IF (
ASSOCIATED(drho_r_in))
THEN
1347 ALLOCATE (drho_r_out(3, nspins))
1348 CALL qs_rho_set(rho_output, drho_r=drho_r_out)
1351 CALL auxbas_pw_pool%create_pw(drho_r_out(i, j))
1352 CALL pw_copy(drho_r_in(i, j), drho_r_out(i, j))
1358 IF (
ASSOCIATED(drho_g_in))
THEN
1359 ALLOCATE (drho_g_out(3, nspins))
1360 CALL qs_rho_set(rho_output, drho_g=drho_g_out)
1363 CALL auxbas_pw_pool%create_pw(drho_g_out(i, j))
1364 CALL pw_copy(drho_g_in(i, j), drho_g_out(i, j))
1373 IF (dft_control%use_kinetic_energy_density)
THEN
1375 IF (
ASSOCIATED(tau_r_in))
THEN
1376 ALLOCATE (tau_r_out(nspins))
1379 CALL auxbas_pw_pool%create_pw(tau_r_out(i))
1380 CALL pw_copy(tau_r_in(i), tau_r_out(i))
1385 IF (
ASSOCIATED(tau_g_in))
THEN
1386 ALLOCATE (tau_g_out(nspins))
1389 CALL auxbas_pw_pool%create_pw(tau_g_out(i))
1390 CALL pw_copy(tau_g_in(i), tau_g_out(i))
1396 rho_g_valid=rho_g_valid_in, &
1397 rho_r_valid=rho_r_valid_in, &
1398 drho_g_valid=drho_g_valid_in, &
1399 drho_r_valid=drho_r_valid_in, &
1400 tau_r_valid=tau_r_valid_in, &
1401 tau_g_valid=tau_g_valid_in, &
1402 soft_valid=soft_valid_in, &
1403 complex_rho_ao=complex_rho_ao_in)
1406 IF (
ASSOCIATED(tot_rho_r_in))
THEN
1407 ALLOCATE (tot_rho_r_out(nspins))
1408 CALL qs_rho_set(rho_output, tot_rho_r=tot_rho_r_out)
1410 tot_rho_r_out(i) = tot_rho_r_in(i)
1415 IF (
ASSOCIATED(tot_rho_g_in))
THEN
1416 ALLOCATE (tot_rho_g_out(nspins))
1417 CALL qs_rho_set(rho_output, tot_rho_g=tot_rho_g_out)
1419 tot_rho_g_out(i) = tot_rho_g_in(i)
1424 CALL timestop(handle)
1434 TYPE(qs_rho_type),
POINTER :: rho
1435 TYPE(qs_environment_type),
POINTER :: qs_env
1437 CHARACTER(LEN=default_string_length) :: headline
1438 INTEGER :: i, ic, nimages, nspins
1439 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_im_kp, rho_ao_kp
1440 TYPE(dbcsr_type),
POINTER :: template
1441 TYPE(dft_control_type),
POINTER :: dft_control
1442 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
1445 NULLIFY (rho_ao_im_kp, rho_ao_kp, dft_control, template, sab_orb)
1448 dft_control=dft_control, &
1451 CALL qs_rho_get(rho, rho_ao_im_kp=rho_ao_im_kp, rho_ao_kp=rho_ao_kp)
1453 nspins = dft_control%nspins
1454 nimages = dft_control%nimages
1456 cpassert(nspins .EQ.
SIZE(rho_ao_kp, 1))
1457 cpassert(nimages .EQ.
SIZE(rho_ao_kp, 2))
1460 CALL qs_rho_set(rho, rho_ao_im_kp=rho_ao_im_kp)
1463 IF (nspins > 1)
THEN
1465 headline =
"IMAGINARY PART OF DENSITY MATRIX FOR ALPHA SPIN"
1467 headline =
"IMAGINARY PART OF DENSITY MATRIX FOR BETA SPIN"
1470 headline =
"IMAGINARY PART OF DENSITY MATRIX"
1472 ALLOCATE (rho_ao_im_kp(i, ic)%matrix)
1473 template => rho_ao_kp(i, ic)%matrix
1474 CALL dbcsr_create(matrix=rho_ao_im_kp(i, ic)%matrix, template=template, &
1475 name=trim(headline), matrix_type=dbcsr_type_antisymmetric, nze=0)
1477 CALL dbcsr_set(rho_ao_im_kp(i, ic)%matrix, 0.0_dp)
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.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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.
various routines to log and control the output. The idea is that decisions about where to log should ...
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym)
Retrieve information from a kpoint environment.
Calculates integral matrices for LRIGPW method lri : local resolution of the identity.
subroutine, public calculate_lri_densities(lri_env, lri_density, qs_env, pmatrix, cell_to_index, lri_rho_struct, atomic_kind_set, para_env, response_density)
performs the fitting of the density and distributes the fitted density on the grid
contains the types and subroutines for dealing with the lri_env lri : local resolution of the identit...
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
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_drho_elec(matrix_p, matrix_p_kp, drho, drho_gspace, qs_env, soft_valid, basis_type)
computes the gradient of the density corresponding to a given density matrix on the grid
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
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.
subroutine, public set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, 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, 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, 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, rhs)
Set the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public get_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_RI_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_RI_aux_kp, matrix_ks_im_kp, rho, rho_xc, vppl, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, task_list, task_list_soft, kpoints, do_kpoints, atomic_kind_set, qs_kind_set, cell, cell_ref, use_ref_cell, particle_set, energy, force, local_particles, local_molecules, molecule_kind_set, molecule_set, subsys, cp_subsys, virial, results, atprop, nkind, natom, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env, nelectron_total, nelectron_spin)
...
Define the neighbor list data types and the corresponding functionality.
subroutine, public calculate_rho_atom_coeff(qs_env, rho_ao, rho_atom_set, qs_kind_set, oce, sab, para_env)
...
methods of the rho structure (defined in qs_rho_types)
subroutine, public qs_rho_update_tddfpt(rho_struct, qs_env, pw_env_external, task_list_external, para_env_external, tddfpt_lri_env, tddfpt_lri_density)
updates rho_r and rho_g to the rhorho_ao. if use_kinetic_energy_density also computes tau_r and tau_g
subroutine, public allocate_rho_ao_imag_from_real(rho, qs_env)
(Re-)allocates rho_ao_im from real part rho_ao
subroutine, public qs_rho_update_rho(rho_struct, qs_env, rho_xc_external, local_rho_set, task_list_external, task_list_external_soft, pw_env_external, para_env_external)
updates rho_r and rho_g to the rhorho_ao. if use_kinetic_energy_density also computes tau_r and tau_g...
subroutine, public duplicate_rho_type(rho_input, rho_output, qs_env)
Duplicates a pointer physically.
subroutine, public qs_rho_copy(rho_input, rho_output, auxbas_pw_pool, mspin)
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_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_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_clear(rho_struct)
Deallocates all components, without deallocating rho_struct itself.
Calculates integral matrices for RIGPW method.
subroutine, public calculate_ri_densities(lri_env, qs_env, pmatrix, lri_rho_struct, atomic_kind_set, para_env)
performs the fitting of the density and distributes the fitted density on the grid