131#include "./base/base_uses.f90"
137 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_scf_diagonalization'
161 matrix_s, scf_control, scf_section, &
166 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
169 LOGICAL,
INTENT(INOUT) :: diis_step
171 INTEGER :: ispin, nspin
172 LOGICAL :: do_level_shift, owns_ortho, use_jacobi
173 REAL(kind=
dp) :: diis_error, eps_diis
177 nspin =
SIZE(matrix_ks)
178 NULLIFY (ortho, ortho_dbcsr)
182 scf_env%scf_work1(ispin))
185 eps_diis = scf_control%eps_diis
187 IF (scf_env%iter_count > 1 .AND. .NOT. scf_env%skip_diis)
THEN
188 CALL qs_diis_b_step(scf_env%scf_diis_buffer, mos, scf_env%scf_work1, &
189 scf_env%scf_work2, scf_env%iter_delta, diis_error, diis_step, &
190 eps_diis, scf_control%nmixing, &
192 scf_section=scf_section)
197 do_level_shift = ((scf_control%level_shift /= 0.0_dp) .AND. &
198 ((scf_control%density_guess ==
core_guess) .OR. &
199 (scf_env%iter_count > 1)))
201 IF ((scf_env%iter_count > 1) .AND. &
202 (scf_env%iter_delta < scf_control%diagonalization%eps_jacobi))
THEN
209 scf_env%iter_param = diis_error
211 scf_env%iter_method =
"DIIS/Jacobi"
213 scf_env%iter_method =
"DIIS/Diag."
216 IF (scf_env%mixing_method == 0)
THEN
217 scf_env%iter_method =
"NoMix/Diag."
218 ELSE IF (scf_env%mixing_method == 1)
THEN
219 scf_env%iter_param = scf_env%p_mix_alpha
221 scf_env%iter_method =
"P_Mix/Jacobi"
223 scf_env%iter_method =
"P_Mix/Diag."
225 ELSEIF (scf_env%mixing_method > 1)
THEN
226 scf_env%iter_param = scf_env%mixing_store%alpha
228 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Jacobi"
230 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Diag."
236 ortho_dbcsr => scf_env%ortho_dbcsr
238 CALL eigensolver_dbcsr(matrix_ks=matrix_ks(ispin)%matrix, matrix_ks_fm=scf_env%scf_work1(ispin), &
240 ortho_dbcsr=ortho_dbcsr, &
241 ksbuf1=scf_env%buf1_dbcsr, ksbuf2=scf_env%buf2_dbcsr)
246 ortho => scf_env%ortho_m1
248 ortho => scf_env%ortho
252 IF (.NOT.
ASSOCIATED(ortho))
THEN
260 matrix_s=matrix_s(ispin)%matrix, &
262 work=scf_env%scf_work2)
264 IF (do_level_shift)
THEN
265 CALL eigensolver(matrix_ks_fm=scf_env%scf_work1(ispin), &
268 work=scf_env%scf_work2, &
269 cholesky_method=scf_env%cholesky_method, &
270 do_level_shift=do_level_shift, &
271 level_shift=scf_control%level_shift, &
272 matrix_u_fm=scf_env%ortho, &
273 use_jacobi=use_jacobi)
275 CALL eigensolver(matrix_ks_fm=scf_env%scf_work1(ispin), &
278 work=scf_env%scf_work2, &
279 cholesky_method=scf_env%cholesky_method, &
280 do_level_shift=do_level_shift, &
281 level_shift=scf_control%level_shift, &
282 use_jacobi=use_jacobi)
287 IF (owns_ortho)
DEALLOCATE (ortho)
289 ortho => scf_env%ortho
292 IF (.NOT.
ASSOCIATED(ortho))
THEN
297 IF (do_level_shift)
THEN
299 IF (
ASSOCIATED(scf_env%scf_work1_red) .AND.
ASSOCIATED(scf_env%scf_work2_red) &
300 .AND.
ASSOCIATED(scf_env%ortho_red) .AND.
ASSOCIATED(scf_env%ortho_m1_red))
THEN
304 work=scf_env%scf_work2, &
305 do_level_shift=do_level_shift, &
306 level_shift=scf_control%level_shift, &
307 matrix_u_fm=scf_env%ortho_m1, &
308 use_jacobi=use_jacobi, &
309 jacobi_threshold=scf_control%diagonalization%jacobi_threshold, &
310 matrix_ks_fm_red=scf_env%scf_work1_red(ispin), &
311 ortho_red=scf_env%ortho_red, &
312 work_red=scf_env%scf_work2_red, &
313 matrix_u_fm_red=scf_env%ortho_m1_red)
318 work=scf_env%scf_work2, &
319 do_level_shift=do_level_shift, &
320 level_shift=scf_control%level_shift, &
321 matrix_u_fm=scf_env%ortho_m1, &
322 use_jacobi=use_jacobi, &
323 jacobi_threshold=scf_control%diagonalization%jacobi_threshold)
328 IF (
ASSOCIATED(scf_env%scf_work1_red) .AND.
ASSOCIATED(scf_env%scf_work2_red) &
329 .AND.
ASSOCIATED(scf_env%ortho_red))
THEN
333 work=scf_env%scf_work2, &
334 do_level_shift=do_level_shift, &
335 level_shift=scf_control%level_shift, &
336 use_jacobi=use_jacobi, &
337 jacobi_threshold=scf_control%diagonalization%jacobi_threshold, &
338 matrix_ks_fm_red=scf_env%scf_work1_red(ispin), &
339 ortho_red=scf_env%ortho_red, &
340 work_red=scf_env%scf_work2_red)
345 work=scf_env%scf_work2, &
346 do_level_shift=do_level_shift, &
347 level_shift=scf_control%level_shift, &
348 use_jacobi=use_jacobi, &
349 jacobi_threshold=scf_control%diagonalization%jacobi_threshold)
354 IF (owns_ortho)
DEALLOCATE (ortho)
371 matrix_s, scf_control, scf_section, &
375 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
376 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
379 LOGICAL,
INTENT(INOUT) :: diis_step
383 INTEGER :: ispin, nspin
384 REAL(kind=
dp) :: total_zeff_corr
386 nspin =
SIZE(matrix_ks)
389 matrix_s, scf_control, scf_section, diis_step)
391 total_zeff_corr = 0.0_dp
392 total_zeff_corr = scf_env%sum_zeff_corr
394 IF (abs(total_zeff_corr) > 0.0_dp)
THEN
396 smear=scf_control%smear, tot_zeff_corr=total_zeff_corr)
398 IF (
PRESENT(probe) .EQV. .true.)
THEN
399 scf_control%smear%do_smear = .false.
401 smear=scf_control%smear, &
405 smear=scf_control%smear)
411 scf_env%p_mix_new(ispin, 1)%matrix)
436 diis_step, diis_error, qs_env, probe)
438 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks, matrix_s
442 LOGICAL,
INTENT(IN) :: update_p
443 LOGICAL,
INTENT(INOUT) :: diis_step
444 REAL(
dp),
INTENT(INOUT),
OPTIONAL :: diis_error
449 CHARACTER(len=*),
PARAMETER :: routinen =
'do_general_diag_kp'
451 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: coeffs
452 INTEGER :: handle, ib, igroup, ik, ikp, indx, &
453 ispin, jb, kplocal, nb, nkp, &
455 INTEGER,
DIMENSION(2) :: kp_range
456 INTEGER,
DIMENSION(:, :),
POINTER :: kp_dist
457 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
458 LOGICAL :: do_diis, my_kpgrp, use_real_wfn
459 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues
460 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
465 TYPE(
cp_fm_type) :: fmdummy, fmlocal, rksmat, rsmat
466 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: fmwork
467 TYPE(
cp_fm_type),
POINTER :: imos, mo_coeff, rmos
468 TYPE(
dbcsr_type),
POINTER :: cmatrix, rmatrix, tmpmat
476 CALL timeset(routinen, handle)
479 CALL get_kpoint_info(kpoints, nkp=nkp, xkp=xkp, use_real_wfn=use_real_wfn, kp_range=kp_range, &
480 nkp_groups=nkp_groups, kp_dist=kp_dist, sab_nl=sab_nl, &
481 cell_to_index=cell_to_index)
482 cpassert(
ASSOCIATED(sab_nl))
483 kplocal = kp_range(2) - kp_range(1) + 1
487 IF (scf_env%iter_count > 1 .AND. .NOT. scf_env%skip_diis .AND. .NOT. use_real_wfn &
488 .AND.
PRESENT(diis_error) .AND.
PRESENT(qs_env)) do_diis = .true.
491 ALLOCATE (rmatrix, cmatrix, tmpmat)
492 CALL dbcsr_create(rmatrix, template=matrix_ks(1, 1)%matrix, &
493 matrix_type=dbcsr_type_symmetric)
494 CALL dbcsr_create(cmatrix, template=matrix_ks(1, 1)%matrix, &
495 matrix_type=dbcsr_type_antisymmetric)
496 CALL dbcsr_create(tmpmat, template=matrix_ks(1, 1)%matrix, &
497 matrix_type=dbcsr_type_no_symmetry)
501 fmwork => scf_env%scf_work1
505 CALL mpools_get(mpools, ao_ao_fm_pools=ao_ao_fm_pools)
510 IF (use_real_wfn)
THEN
517 kp => kpoints%kp_env(1)%kpoint_env
518 CALL get_mo_set(kp%mos(1, 1), mo_coeff=mo_coeff)
523 para_env => kpoints%blacs_env_all%para_env
524 nspin =
SIZE(matrix_ks, 1)
525 ALLOCATE (info(kplocal*nspin*nkp_groups, 4))
531 DO igroup = 1, nkp_groups
533 ik = kp_dist(1, igroup) + ikp - 1
534 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
536 IF (use_real_wfn)
THEN
539 CALL rskp_transform(rmatrix=rmatrix, rsmat=matrix_ks, ispin=ispin, &
540 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
546 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
553 CALL rskp_transform(rmatrix=rmatrix, cmatrix=cmatrix, rsmat=matrix_ks, ispin=ispin, &
554 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
562 CALL rskp_transform(rmatrix=rmatrix, cmatrix=cmatrix, rsmat=matrix_s, ispin=1, &
563 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
573 IF (use_real_wfn)
THEN
600 CALL get_qs_env(qs_env, para_env=para_env_global)
606 DO igroup = 1, nkp_groups
608 ik = kp_dist(1, igroup) + ikp - 1
609 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
623 kp => kpoints%kp_env(ikp)%kpoint_env
625 ispin, ikp, kplocal, scf_section)
630 ALLOCATE (coeffs(nb))
631 CALL qs_diis_b_step_kp(kpoints%scf_diis_buffer, coeffs, ib, nb, scf_env%iter_delta, diis_error, &
632 diis_step, scf_control%eps_diis, nspin, nkp, kplocal, scf_control%nmixing, &
633 scf_section, para_env_global)
638 kp => kpoints%kp_env(ikp)%kpoint_env
646 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos, eigenvalues=eigenvalues)
647 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
650 scf_control%eps_eigval)
652 CALL cp_cfm_geeig(cksmat, csmat, cmos, eigenvalues, cwork)
655 kp%mos(2, ispin)%eigenvalues = eigenvalues
666 DO igroup = 1, nkp_groups
668 ik = kp_dist(1, igroup) + ikp - 1
669 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
672 IF (use_real_wfn)
THEN
690 kp => kpoints%kp_env(ikp)%kpoint_env
691 IF (use_real_wfn)
THEN
692 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=mo_coeff, eigenvalues=eigenvalues)
695 scf_control%eps_eigval)
697 CALL cp_fm_geeig(rksmat, rsmat, mo_coeff, eigenvalues, fmlocal)
700 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos, eigenvalues=eigenvalues)
701 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
704 scf_control%eps_eigval)
706 CALL cp_cfm_geeig(cksmat, csmat, cmos, eigenvalues, cwork)
709 kp%mos(2, ispin)%eigenvalues = eigenvalues
721 DO igroup = 1, nkp_groups
723 ik = kp_dist(1, igroup) + ikp - 1
724 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
726 IF (use_real_wfn)
THEN
744 IF (
PRESENT(probe) .EQV. .true.)
THEN
745 scf_control%smear%do_smear = .false.
755 matrix_s(1, 1)%matrix, sab_nl, fmwork)
762 IF (use_real_wfn)
THEN
773 CALL timestop(handle)
793 ks_env, scf_section, scf_control)
798 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
804 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_scf_diag_subspace'
805 REAL(kind=
dp),
PARAMETER :: rone = 1.0_dp, rzero = 0.0_dp
807 INTEGER :: handle, i, iloop, ispin, nao, nmo, &
810 REAL(
dp) :: ene_diff, ene_old, iter_delta, max_val, &
811 sum_band, sum_val, t1, t2
812 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues, mo_occupations
813 TYPE(
cp_1d_r_p_type),
ALLOCATABLE,
DIMENSION(:) :: eval_first, occ_first
815 TYPE(
cp_fm_type),
POINTER :: c0, chc, evec, mo_coeff
817 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s, rho_ao
818 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_kp
824 CALL timeset(routinen, handle)
825 NULLIFY (c0, chc, energy, evec, matrix_ks, mo_coeff, mo_eigenvalues, &
826 mo_occupations, dft_control, rho_ao, rho_ao_kp)
834 CALL qs_rho_get(rho, rho_ao=rho_ao, rho_ao_kp=rho_ao_kp)
836 ALLOCATE (eval_first(nspin))
837 ALLOCATE (occ_first(nspin))
841 eigenvalues=mo_eigenvalues, &
842 occupation_numbers=mo_occupations)
843 ALLOCATE (eval_first(ispin)%array(nmo))
844 ALLOCATE (occ_first(ispin)%array(nmo))
845 eval_first(ispin)%array(1:nmo) = mo_eigenvalues(1:nmo)
846 occ_first(ispin)%array(1:nmo) = mo_occupations(1:nmo)
851 CALL dbcsr_copy(subspace_env%p_matrix_store(ispin)%matrix, rho_ao(ispin)%matrix)
852 CALL dbcsr_copy(rho_ao(ispin)%matrix, scf_env%p_mix_new(ispin, 1)%matrix)
855 subspace_env%p_matrix_mix => scf_env%p_mix_new
857 NULLIFY (matrix_ks, energy, para_env, matrix_s)
859 matrix_ks=matrix_ks, &
863 dft_control=dft_control)
867 CALL mixing_allocate(qs_env, subspace_env%mixing_method, scf_env%p_mix_new, &
868 scf_env%p_delta, nspin, subspace_env%mixing_store)
869 IF (dft_control%qs_control%gapw)
THEN
870 CALL get_qs_env(qs_env=qs_env, rho_atom_set=rho_atom)
871 CALL mixing_init(subspace_env%mixing_method, rho, subspace_env%mixing_store, &
872 para_env, rho_atom=rho_atom)
873 ELSEIF (dft_control%qs_control%dftb .OR. dft_control%qs_control%xtb)
THEN
875 ELSEIF (dft_control%qs_control%semi_empirical)
THEN
876 cpabort(
'SE Code not possible')
878 CALL mixing_init(subspace_env%mixing_method, rho, subspace_env%mixing_store, para_env)
884 IF (output_unit > 0)
THEN
885 WRITE (output_unit,
"(/T19,A)")
'<<<<<<<<< SUBSPACE ROTATION <<<<<<<<<<'
886 WRITE (output_unit,
"(T4,A,T13,A,T21,A,T38,A,T51,A,T65,A/,T4,A)") &
887 "In-step",
"Time",
"Convergence",
"Band ene.",
"Total ene.",
"Energy diff.", repeat(
"-", 74)
895 DO iloop = 1, subspace_env%max_iter
898 ene_old = energy%total
902 just_energy=.false., print_active=.false.)
907 DO ispin = 1,
SIZE(matrix_ks)
911 eigenvalues=mo_eigenvalues, &
912 occupation_numbers=mo_occupations, &
916 chc => subspace_env%chc_mat(ispin)
917 evec => subspace_env%c_vec(ispin)
918 c0 => subspace_env%c0(ispin)
922 CALL parallel_gemm(
'T',
'N', nmo, nmo, nao, rone, c0, work, rzero, chc)
928 CALL parallel_gemm(
'N',
'N', nao, nmo, nmo, rone, c0, evec, rzero, mo_coeff)
931 smear=scf_control%smear)
935 subspace_env%p_matrix_mix(ispin, 1)%matrix)
938 sum_band = sum_band + mo_eigenvalues(i)*mo_occupations(i)
946 scf_env%mixing_store, rho_ao_kp, para_env, iter_delta, iloop)
949 subspace_env%p_matrix_mix, delta=iter_delta)
954 CALL dbcsr_copy(rho_ao(ispin)%matrix, subspace_env%p_matrix_mix(ispin, 1)%matrix)
960 CALL gspace_mixing(qs_env, scf_env%mixing_method, subspace_env%mixing_store, &
961 rho, para_env, scf_env%iter_count)
964 ene_diff = energy%total - ene_old
965 converged = (abs(ene_diff) < subspace_env%eps_ene .AND. &
966 iter_delta < subspace_env%eps_adapt*scf_env%iter_delta)
968 IF (output_unit > 0)
THEN
969 WRITE (output_unit,
"(T4,I5,T11,F8.3,T18,E14.4,T34,F12.5,T46,F16.8,T62,E14.4)") &
970 iloop, t2 - t1, iter_delta, sum_band, energy%total, ene_diff
974 IF (output_unit > 0)
WRITE (output_unit,
"(T10,A,I6,A,/)") &
975 " Reached convergence in ", iloop,
" iterations "
981 NULLIFY (subspace_env%p_matrix_mix)
984 CALL dbcsr_copy(scf_env%p_mix_new(ispin, 1)%matrix, rho_ao(ispin)%matrix)
985 CALL dbcsr_copy(rho_ao(ispin)%matrix, subspace_env%p_matrix_store(ispin)%matrix)
987 DEALLOCATE (eval_first(ispin)%array, occ_first(ispin)%array)
989 DEALLOCATE (eval_first, occ_first)
991 CALL timestop(handle)
1005 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(IN) :: mos
1007 CHARACTER(LEN=*),
PARAMETER :: routinen =
'diag_subspace_allocate'
1009 INTEGER :: handle, i, ispin, nmo, nspin
1016 CALL timeset(routinen, handle)
1018 NULLIFY (sab_orb, matrix_s)
1019 CALL get_qs_env(qs_env=qs_env, sab_orb=sab_orb, &
1024 IF (.NOT.
ASSOCIATED(subspace_env%p_matrix_store))
THEN
1028 ALLOCATE (subspace_env%p_matrix_store(i)%matrix)
1029 CALL dbcsr_create(matrix=subspace_env%p_matrix_store(i)%matrix, template=matrix_s(1)%matrix, &
1030 name=
"DENSITY_STORE", matrix_type=dbcsr_type_symmetric)
1033 CALL dbcsr_set(subspace_env%p_matrix_store(i)%matrix, 0.0_dp)
1038 ALLOCATE (subspace_env%chc_mat(nspin))
1039 ALLOCATE (subspace_env%c_vec(nspin))
1040 ALLOCATE (subspace_env%c0(nspin))
1043 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
1044 CALL cp_fm_create(subspace_env%c0(ispin), mo_coeff%matrix_struct)
1045 NULLIFY (fm_struct_tmp)
1047 para_env=mo_coeff%matrix_struct%para_env, &
1048 context=mo_coeff%matrix_struct%context)
1049 CALL cp_fm_create(subspace_env%chc_mat(ispin), fm_struct_tmp,
"chc")
1050 CALL cp_fm_create(subspace_env%c_vec(ispin), fm_struct_tmp,
"vec")
1054 CALL timestop(handle)
1071 scf_section, diis_step)
1074 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
1078 LOGICAL,
INTENT(INOUT) :: diis_step
1080 INTEGER :: ispin, nspin
1081 LOGICAL :: do_level_shift, use_jacobi
1082 REAL(kind=
dp) :: diis_error
1084 nspin =
SIZE(matrix_ks)
1089 IF (scf_env%iter_count > 1 .AND. .NOT. scf_env%skip_diis)
THEN
1090 CALL qs_diis_b_step(scf_env%scf_diis_buffer, mos, scf_env%scf_work1, &
1091 scf_env%scf_work2, scf_env%iter_delta, diis_error, diis_step, &
1092 scf_control%eps_diis, scf_control%nmixing, &
1093 scf_section=scf_section)
1098 IF ((scf_env%iter_count > 1) .AND. (scf_env%iter_delta < scf_control%diagonalization%eps_jacobi))
THEN
1101 use_jacobi = .false.
1104 do_level_shift = ((scf_control%level_shift /= 0.0_dp) .AND. &
1105 ((scf_control%density_guess ==
core_guess) .OR. (scf_env%iter_count > 1)))
1107 scf_env%iter_param = diis_error
1108 IF (use_jacobi)
THEN
1109 scf_env%iter_method =
"DIIS/Jacobi"
1111 scf_env%iter_method =
"DIIS/Diag."
1114 IF (scf_env%mixing_method == 1)
THEN
1115 scf_env%iter_param = scf_env%p_mix_alpha
1116 IF (use_jacobi)
THEN
1117 scf_env%iter_method =
"P_Mix/Jacobi"
1119 scf_env%iter_method =
"P_Mix/Diag."
1121 ELSEIF (scf_env%mixing_method > 1)
THEN
1122 scf_env%iter_param = scf_env%mixing_store%alpha
1123 IF (use_jacobi)
THEN
1124 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Jacobi"
1126 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Diag."
1130 scf_env%iter_delta = 0.0_dp
1134 mo_set=mos(ispin), &
1135 work=scf_env%scf_work2, &
1136 do_level_shift=do_level_shift, &
1137 level_shift=scf_control%level_shift, &
1138 use_jacobi=use_jacobi, &
1139 jacobi_threshold=scf_control%diagonalization%jacobi_threshold)
1143 smear=scf_control%smear)
1148 scf_env%p_mix_new(ispin, 1)%matrix)
1167 scf_control, scf_section, diis_step)
1170 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
1171 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
1174 LOGICAL,
INTENT(INOUT) :: diis_step
1176 INTEGER :: homo, ispin, nmo, nspin
1177 REAL(kind=
dp) :: diis_error, eps_iter
1178 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues
1181 NULLIFY (eigenvalues)
1183 nspin =
SIZE(matrix_ks)
1187 scf_env%scf_work1(ispin))
1190 IF ((scf_env%iter_count > 1) .AND. (.NOT. scf_env%skip_diis))
THEN
1191 CALL qs_diis_b_step(scf_env%scf_diis_buffer, mos, scf_env%scf_work1, &
1192 scf_env%scf_work2, scf_env%iter_delta, diis_error, diis_step, &
1193 scf_control%eps_diis, scf_control%nmixing, &
1194 s_matrix=matrix_s, &
1195 scf_section=scf_section)
1200 eps_iter = scf_control%diagonalization%eps_iter
1202 scf_env%iter_param = diis_error
1203 scf_env%iter_method =
"DIIS/OTdiag"
1206 matrix_ks(ispin)%matrix, keep_sparsity=.true.)
1208 eps_iter = max(eps_iter, scf_control%diagonalization%eps_adapt*diis_error)
1210 IF (scf_env%mixing_method == 1)
THEN
1211 scf_env%iter_param = scf_env%p_mix_alpha
1212 scf_env%iter_method =
"P_Mix/OTdiag."
1213 ELSEIF (scf_env%mixing_method > 1)
THEN
1214 scf_env%iter_param = scf_env%mixing_store%alpha
1215 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/OTdiag."
1219 scf_env%iter_delta = 0.0_dp
1223 mo_coeff=mo_coeff, &
1224 eigenvalues=eigenvalues, &
1228 matrix_s=matrix_s(1)%matrix, &
1229 matrix_c_fm=mo_coeff, &
1231 eps_gradient=eps_iter, &
1232 iter_max=scf_control%diagonalization%max_iter, &
1234 ot_settings=scf_control%diagonalization%ot_settings)
1236 evals_arg=eigenvalues, &
1239 mos(ispin)%mo_coeff_b)
1244 smear=scf_control%smear)
1249 scf_env%p_mix_new(ispin, 1)%matrix)
1272 scf_control, scf_section, diis_step, &
1280 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(IN) :: mos
1281 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
1284 LOGICAL,
INTENT(INOUT) :: diis_step
1285 LOGICAL,
INTENT(IN) :: orthogonal_basis
1287 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_roks_diag'
1289 INTEGER :: handle, homoa, homob, imo, nalpha, nao, &
1291 REAL(kind=
dp) :: diis_error, level_shift_loc
1292 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eiga, eigb, occa, occb
1293 TYPE(
cp_fm_type),
POINTER :: ksa, ksb, mo2ao, moa, mob, ortho, work
1297 CALL timeset(routinen, handle)
1300 ortho => scf_env%ortho_m1
1302 ortho => scf_env%ortho
1304 work => scf_env%scf_work2
1306 ksa => scf_env%scf_work1(1)
1307 ksb => scf_env%scf_work1(2)
1320 occupation_numbers=occa, &
1327 occupation_numbers=occb, &
1332 IF ((scf_control%level_shift /= 0.0_dp) .AND. &
1333 ((scf_control%density_guess ==
core_guess) .OR. &
1335 (scf_env%iter_count > 1)))
THEN
1336 level_shift_loc = scf_control%level_shift
1338 level_shift_loc = 0.0_dp
1341 IF ((scf_env%iter_count > 1) .OR. &
1342 (scf_control%density_guess ==
core_guess) .OR. &
1348 CALL cp_fm_symm(
"L",
"U", nao, nao, 1.0_dp, ksa, moa, 0.0_dp, work)
1349 CALL parallel_gemm(
"T",
"N", nao, nao, nao, 1.0_dp, moa, work, 0.0_dp, ksa)
1351 CALL cp_fm_symm(
"L",
"U", nao, nao, 1.0_dp, ksb, moa, 0.0_dp, work)
1352 CALL parallel_gemm(
"T",
"N", nao, nao, nao, 1.0_dp, moa, work, 0.0_dp, ksb)
1363 cpabort(
"Unknown ROKS scheme requested")
1369 IF (orthogonal_basis)
THEN
1382 CALL parallel_gemm(
"N",
"T", nao, nao, nao, 1.0_dp, ksa, mo2ao, 0.0_dp, work)
1383 CALL parallel_gemm(
"N",
"N", nao, nao, nao, 1.0_dp, mo2ao, work, 0.0_dp, ksa)
1397 IF (scf_env%iter_count > 1)
THEN
1398 IF (orthogonal_basis)
THEN
1401 kc=scf_env%scf_work1, &
1403 delta=scf_env%iter_delta, &
1404 error_max=diis_error, &
1405 diis_step=diis_step, &
1406 eps_diis=scf_control%eps_diis, &
1407 scf_section=scf_section, &
1409 cpassert(scf_env%iter_delta == scf_env%iter_delta)
1413 kc=scf_env%scf_work1, &
1415 delta=scf_env%iter_delta, &
1416 error_max=diis_error, &
1417 diis_step=diis_step, &
1418 eps_diis=scf_control%eps_diis, &
1419 scf_section=scf_section, &
1420 s_matrix=matrix_s, &
1426 scf_env%iter_param = diis_error
1427 scf_env%iter_method =
"DIIS/Diag."
1429 IF (scf_env%mixing_method == 1)
THEN
1430 scf_env%iter_param = scf_env%p_mix_alpha
1431 scf_env%iter_method =
"P_Mix/Diag."
1432 ELSEIF (scf_env%mixing_method > 1)
THEN
1433 scf_env%iter_param = scf_env%mixing_store%alpha
1434 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Diag."
1438 scf_env%iter_delta = 0.0_dp
1440 IF (level_shift_loc /= 0.0_dp)
THEN
1445 CALL cp_fm_symm(
"L",
"U", nao, nao, 1.0_dp, ksa, moa, 0.0_dp, work)
1446 CALL parallel_gemm(
"T",
"N", nao, nao, nao, 1.0_dp, moa, work, 0.0_dp, ksa)
1450 DO imo = homob + 1, homoa
1453 DO imo = homoa + 1, nmo
1457 ELSE IF (.NOT. orthogonal_basis)
THEN
1460 SELECT CASE (scf_env%cholesky_method)
1466 "SOLVE", pos=
"RIGHT")
1468 "SOLVE", pos=
"LEFT", transa=
"T")
1472 "MULTIPLY", pos=
"RIGHT")
1474 "MULTIPLY", pos=
"LEFT", transa=
"T")
1476 CALL cp_fm_symm(
"L",
"U", nao, nao, 1.0_dp, ksa, ortho, 0.0_dp, work)
1477 CALL parallel_gemm(
"N",
"N", nao, nao, nao, 1.0_dp, ortho, work, 0.0_dp, ksa)
1488 IF (level_shift_loc /= 0.0_dp)
THEN
1491 CALL parallel_gemm(
"N",
"N", nao, nmo, nao, 1.0_dp, ortho, work, 0.0_dp, moa)
1493 IF (orthogonal_basis)
THEN
1496 SELECT CASE (scf_env%cholesky_method)
1502 CALL parallel_gemm(
"N",
"N", nao, nmo, nao, 1.0_dp, ortho, work, 0.0_dp, moa)
1509 IF (level_shift_loc /= 0.0_dp)
THEN
1510 DO imo = homob + 1, homoa
1511 eiga(imo) = eiga(imo) - 0.5_dp*level_shift_loc
1513 DO imo = homoa + 1, nmo
1514 eiga(imo) = eiga(imo) - level_shift_loc
1529 CALL timestop(handle)
1547 scf_control, scf_section, check_moconv_only)
1550 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
1554 LOGICAL,
INTENT(IN),
OPTIONAL :: check_moconv_only
1556 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_block_krylov_diag'
1557 REAL(kind=
dp),
PARAMETER :: rone = 1.0_dp, rzero = 0.0_dp
1559 INTEGER :: handle, homo, ispin, iter, nao, nmo, &
1561 LOGICAL :: converged, my_check_moconv_only
1562 REAL(
dp) :: eps_iter, t1, t2
1563 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues
1564 TYPE(
cp_fm_type),
POINTER :: c0, c1, chc, evec, ks, mo_coeff, ortho, &
1569 CALL timeset(routinen, handle)
1572 extension=
".scfLog")
1574 my_check_moconv_only = .false.
1575 IF (
PRESENT(check_moconv_only)) my_check_moconv_only = check_moconv_only
1577 NULLIFY (mo_coeff, ortho, work, ks)
1578 NULLIFY (mo_eigenvalues)
1582 ortho => scf_env%ortho_m1
1584 ortho => scf_env%ortho
1586 work => scf_env%scf_work2
1588 DO ispin = 1,
SIZE(matrix_ks)
1590 scf_env%scf_work1(ispin))
1593 IF (scf_env%mixing_method == 1)
THEN
1594 scf_env%iter_param = scf_env%p_mix_alpha
1595 scf_env%iter_method =
"P_Mix/Lanczos"
1598 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Lanc."
1601 DO ispin = 1,
SIZE(matrix_ks)
1603 ks => scf_env%scf_work1(ispin)
1610 eigenvalues=mo_eigenvalues, &
1614 c0 => scf_env%krylov_space%mo_conv(ispin)
1615 c1 => scf_env%krylov_space%mo_refine(ispin)
1616 SELECT CASE (scf_env%cholesky_method)
1623 "SOLVE", pos=
"RIGHT")
1625 "SOLVE", pos=
"LEFT", transa=
"T")
1629 "MULTIPLY", pos=
"RIGHT")
1631 "MULTIPLY", pos=
"LEFT", transa=
"T")
1635 scf_env%krylov_space%nmo_nc = nmo
1636 scf_env%krylov_space%nmo_conv = 0
1639 IF (output_unit > 0)
THEN
1640 WRITE (output_unit,
"(/T15,A)")
'<<<<<<<<< LANCZOS REFINEMENT <<<<<<<<<<'
1641 WRITE (output_unit,
"(T8,A,T15,A,T23,A,T36,A,T49,A,T60,A,/,T8,A)") &
1642 " Spin ",
" Cycle ", &
1643 " conv. MOS ",
" B2MAX ",
" B2MIN ",
" Time", repeat(
"-", 60)
1645 eps_iter = max(scf_env%krylov_space%eps_conv, scf_env%krylov_space%eps_adapt*scf_env%iter_delta)
1649 IF (my_check_moconv_only)
THEN
1652 nao, eps_iter, ispin, check_moconv_only=my_check_moconv_only)
1654 IF (output_unit > 0) &
1655 WRITE (output_unit,
'(T8,I3,T16,I5,T24,I6,T33,E12.4,2x,E12.4,T60,F8.3)') &
1656 ispin, iter, scf_env%krylov_space%nmo_conv, &
1657 scf_env%krylov_space%max_res_norm, scf_env%krylov_space%min_res_norm, t2 - t1
1662 DO iter = 1, scf_env%krylov_space%max_iter
1664 nao, eps_iter, ispin)
1666 IF (output_unit > 0)
THEN
1667 WRITE (output_unit,
'(T8,I3,T16,I5,T24,I6,T33,E12.4,2x,E12.4,T60,F8.3)') &
1668 ispin, iter, scf_env%krylov_space%nmo_conv, &
1669 scf_env%krylov_space%max_res_norm, scf_env%krylov_space%min_res_norm, t2 - t1
1672 IF (scf_env%krylov_space%max_res_norm < eps_iter)
THEN
1674 IF (output_unit > 0)
WRITE (output_unit, *) &
1675 " Reached convergence in ", iter,
" iterations "
1680 IF (.NOT. converged .AND. output_unit > 0)
THEN
1681 WRITE (output_unit,
"(T4, A)")
" WARNING Lanczos refinement could "// &
1682 "not converge all the mos:"
1683 WRITE (output_unit,
"(T40,A,T70,I10)")
" number of not converged mos ", &
1684 scf_env%krylov_space%nmo_nc
1685 WRITE (output_unit,
"(T40,A,T70,E10.2)")
" max norm of the residual ", &
1686 scf_env%krylov_space%max_res_norm
1694 chc => scf_env%krylov_space%chc_mat(ispin)
1695 evec => scf_env%krylov_space%c_vec(ispin)
1696 CALL parallel_gemm(
'N',
'N', nao, nmo, nao, rone, ks, c0, rzero, work)
1697 CALL parallel_gemm(
'T',
'N', nmo, nmo, nao, rone, c0, work, rzero, chc)
1701 CALL parallel_gemm(
'N',
'N', nao, nmo, nmo, rone, c0, evec, rzero, c1)
1702 c0 => scf_env%krylov_space%mo_refine(ispin)
1712 smear=scf_control%smear)
1716 scf_env%p_mix_new(ispin, 1)%matrix)
1720 IF (output_unit > 0)
THEN
1721 WRITE (output_unit,
"(T15,A/)")
'<<<<<<<<< END LANCZOS REFINEMENT <<<<<<<<<<'
1727 CALL timestop(handle)
1747 scf_control, scf_section, check_moconv_only)
1751 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
1752 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
1755 LOGICAL,
INTENT(IN),
OPTIONAL :: check_moconv_only
1757 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_block_davidson_diag'
1759 INTEGER :: handle, ispin, nspins, output_unit
1760 LOGICAL :: do_prec, my_check_moconv_only
1764 CALL timeset(routinen, handle)
1767 extension=
".scfLog")
1769 IF (output_unit > 0) &
1770 WRITE (output_unit,
"(/T15,A)")
'<<<<<<<<< DAVIDSON ITERATIONS <<<<<<<<<<'
1772 IF (scf_env%mixing_method == 1)
THEN
1773 scf_env%iter_param = scf_env%p_mix_alpha
1774 scf_env%iter_method =
"P_Mix/Dav."
1776 scf_env%iter_param = scf_env%mixing_store%alpha
1777 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Dav."
1780 my_check_moconv_only = .false.
1781 IF (
PRESENT(check_moconv_only)) my_check_moconv_only = check_moconv_only
1783 IF (scf_env%block_davidson_env(1)%prec_type /= 0 .AND. &
1784 scf_env%iter_count >= scf_env%block_davidson_env(1)%first_prec)
THEN
1788 nspins =
SIZE(matrix_ks)
1790 IF (do_prec .AND. (scf_env%iter_count == scf_env%block_davidson_env(1)%first_prec .OR. &
1791 modulo(scf_env%iter_count, scf_env%block_davidson_env(1)%niter_new_prec) == 0))
THEN
1793 prec_type=scf_env%block_davidson_env(1)%prec_type, nspins=nspins)
1795 scf_env%block_davidson_env(1)%prec_type, &
1796 scf_env%block_davidson_env(1)%solver_type, &
1797 scf_env%block_davidson_env(1)%energy_gap, nspins, &
1798 convert_to_dbcsr=scf_env%block_davidson_env(1)%use_sparse_mos, &
1802 DO ispin = 1, nspins
1803 IF (scf_env%block_davidson_env(ispin)%use_sparse_mos)
THEN
1804 IF (.NOT. do_prec)
THEN
1806 matrix_ks(ispin)%matrix, matrix_s(1)%matrix, output_unit)
1809 matrix_ks(ispin)%matrix, matrix_s(1)%matrix, output_unit, &
1810 scf_env%ot_preconditioner(ispin)%preconditioner)
1814 IF (.NOT. do_prec)
THEN
1816 matrix_ks(ispin)%matrix, matrix_s(1)%matrix, output_unit)
1819 matrix_ks(ispin)%matrix, matrix_s(1)%matrix, output_unit, &
1820 scf_env%ot_preconditioner(ispin)%preconditioner)
1826 smear=scf_control%smear)
1828 DO ispin = 1, nspins
1831 scf_env%p_mix_new(ispin, 1)%matrix)
1834 IF (output_unit > 0)
THEN
1835 WRITE (output_unit,
"(T15,A/)")
'<<<<<<<<< END DAVIDSON ITERATION <<<<<<<<<<'
1841 CALL timestop(handle)
1856 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s
1860 CHARACTER(len=*),
PARAMETER :: routinen =
'diag_kp_smat'
1861 COMPLEX(KIND=dp),
PARAMETER :: cone = (1.0_dp, 0.0_dp), &
1862 czero = (0.0_dp, 0.0_dp)
1864 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: ceig
1865 INTEGER :: handle, igroup, ik, ikp, indx, kplocal, &
1866 nao, nkp, nkp_groups
1867 INTEGER,
DIMENSION(2) :: kp_range
1868 INTEGER,
DIMENSION(:, :),
POINTER :: kp_dist
1869 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1870 LOGICAL :: my_kpgrp, use_real_wfn
1871 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues
1872 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1878 TYPE(
dbcsr_type),
POINTER :: cmatrix, rmatrix, tmpmat
1885 CALL timeset(routinen, handle)
1888 CALL get_kpoint_info(kpoints, nkp=nkp, xkp=xkp, use_real_wfn=use_real_wfn, kp_range=kp_range, &
1889 nkp_groups=nkp_groups, kp_dist=kp_dist, sab_nl=sab_nl, &
1890 cell_to_index=cell_to_index)
1891 cpassert(
ASSOCIATED(sab_nl))
1892 kplocal = kp_range(2) - kp_range(1) + 1
1895 ALLOCATE (rmatrix, cmatrix, tmpmat)
1896 CALL dbcsr_create(rmatrix, template=matrix_s(1, 1)%matrix, &
1897 matrix_type=dbcsr_type_symmetric)
1898 CALL dbcsr_create(cmatrix, template=matrix_s(1, 1)%matrix, &
1899 matrix_type=dbcsr_type_antisymmetric)
1900 CALL dbcsr_create(tmpmat, template=matrix_s(1, 1)%matrix, &
1901 matrix_type=dbcsr_type_no_symmetry)
1907 CALL mpools_get(mpools, ao_ao_fm_pools=ao_ao_fm_pools)
1912 IF (use_real_wfn)
THEN
1920 ALLOCATE (eigenvalues(nao), ceig(nao))
1922 para_env => kpoints%blacs_env_all%para_env
1923 ALLOCATE (info(kplocal*nkp_groups, 2))
1928 DO igroup = 1, nkp_groups
1930 ik = kp_dist(1, igroup) + ikp - 1
1931 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
1933 IF (use_real_wfn)
THEN
1936 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
1942 CALL rskp_transform(rmatrix=rmatrix, cmatrix=cmatrix, rsmat=matrix_s, ispin=1, &
1943 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
1952 IF (use_real_wfn)
THEN
1973 DO igroup = 1, nkp_groups
1975 ik = kp_dist(1, igroup) + ikp - 1
1976 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
1979 IF (use_real_wfn)
THEN
1992 kp => kpoints%kp_env(ikp)%kpoint_env
1993 IF (use_real_wfn)
THEN
1998 cpassert(all(eigenvalues(1:nao) >= 0.0_dp))
1999 IF (use_real_wfn)
THEN
2002 eigenvalues(1:nao) = sqrt(eigenvalues(1:nao))
2005 CALL parallel_gemm(
"N",
"T", nao, nao, nao, 1.0_dp, rsmat, fmlocal, &
2010 ceig(1:nao) = sqrt(eigenvalues(1:nao))
2013 CALL parallel_gemm(
"N",
"T", nao, nao, nao, cone, csmat, cwork, &
2021 DO igroup = 1, nkp_groups
2023 ik = kp_dist(1, igroup) + ikp - 1
2024 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
2026 IF (use_real_wfn)
THEN
2037 DEALLOCATE (eigenvalues, ceig)
2043 IF (use_real_wfn)
THEN
2051 CALL timestop(handle)
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_scale_and_add(alpha, matrix_a, beta, matrix_b)
Scale and add two BLACS matrices (a = alpha*a + beta*b).
subroutine, public cp_cfm_scale_and_add_fm(alpha, matrix_a, beta, matrix_b)
Scale and add two BLACS matrices (a = alpha*a + beta*b). where b is a real matrix (adapted from cp_cf...
subroutine, public cp_cfm_column_scale(matrix_a, scaling)
Scales columns of the full matrix by corresponding factors.
used for collecting diagonalization schemes available for cp_cfm_type
subroutine, public cp_cfm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work)
General Eigenvalue Problem AX = BXE Single option version: Cholesky decomposition of B.
subroutine, public cp_cfm_heevd(matrix, eigenvectors, eigenvalues)
Perform a diagonalisation of a complex matrix.
subroutine, public cp_cfm_geeig_canon(amatrix, bmatrix, eigenvectors, eigenvalues, work, epseig)
General Eigenvalue Problem AX = BXE Use canonical orthogonalization.
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_cfm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_set_all(matrix, alpha, beta)
Set all elements of the full matrix to alpha. Besides, set all diagonal matrix elements to beta (if g...
subroutine, public cp_cfm_to_fm(msource, mtargetr, mtargeti)
Copy real and imaginary parts of a complex full matrix into separate real-value full matrices.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
subroutine, public dbcsr_desymmetrize(matrix_a, matrix_b)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_set(matrix, alpha)
...
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)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_column_scale(matrixa, scaling)
scales column i of matrix a with scaling(i)
subroutine, public cp_fm_uplo_to_full(matrix, work, uplo)
given a triangular matrix according to uplo, computes the corresponding full matrix
subroutine, public cp_fm_symm(side, uplo, m, n, alpha, matrix_a, matrix_b, beta, matrix_c)
computes matrix_c = beta * matrix_c + alpha * matrix_a * matrix_b computes matrix_c = beta * matrix_c...
various cholesky decomposition related routines
subroutine, public cp_fm_cholesky_restore(fm_matrix, neig, fm_matrixb, fm_matrixout, op, pos, transa)
apply Cholesky decomposition op can be "SOLVE" (out = U^-1 * in) or "MULTIPLY" (out = U * in) pos can...
subroutine, public cp_fm_cholesky_reduce(matrix, matrixb, itype)
reduce a matrix pencil A,B to normal form B has to be cholesky decomposed with cp_fm_cholesky_decompo...
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
integer, parameter, public fm_diag_type_cusolver
subroutine, public cp_fm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work)
General Eigenvalue Problem AX = BXE Single option version: Cholesky decomposition of B.
subroutine, public choose_eigv_solver(matrix, eigenvectors, eigenvalues, info)
Choose the Eigensolver depending on which library is available ELPA seems to be unstable for small sy...
integer, save, public diag_type
subroutine, public cp_fm_geeig_canon(amatrix, bmatrix, eigenvectors, eigenvalues, work, epseig)
General Eigenvalue Problem AX = BXE Use canonical diagonalization : U*s**(-1/2)
logical, save, public cusolver_generalized
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_give_back_fm(pool, element)
returns the element to the pool
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_start_copy_general(source, destination, para_env, info)
Initiates the copy operation: get distribution data, post MPI isend and irecvs.
subroutine, public cp_fm_cleanup_copy_general(info)
Completes the copy operation: wait for comms clean up MPI state.
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_create(matrix, matrix_struct, name, use_sp, nrow, ncol, set_zero)
creates a new full matrix with the given structure
subroutine, public cp_fm_add_to_element(matrix, irow_global, icol_global, alpha)
...
subroutine, public cp_fm_finish_copy_general(destination, info)
Completes the copy operation: wait for comms, unpack, clean up MPI state.
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
Defines the basic variable types.
integer, parameter, public dp
Routines needed for kpoint calculation.
subroutine, public rskp_transform(rmatrix, cmatrix, rsmat, ispin, xkp, cell_to_index, sab_nl, is_complex, rs_sign)
Transformation of real space matrices to a kpoint.
subroutine, public kpoint_density_transform(kpoint, denmat, wtype, tempmat, sab_nl, fmwork, for_aux_fit, pmat_ext)
generate real space density matrices in DBCSR format
subroutine, public kpoint_density_matrices(kpoint, energy_weighted, for_aux_fit)
Calculate kpoint density matrices (rho(k), owned by kpoint groups)
subroutine, public kpoint_set_mo_occupation(kpoint, smear, probe)
Given the eigenvalues of all kpoints, calculates the occupation numbers.
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.
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public z_one
complex(kind=dp), parameter, public gaussi
complex(kind=dp), parameter, public z_zero
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
computes preconditioners, and implements methods to apply them currently used in qs_ot
subroutine, public restart_preconditioner(qs_env, preconditioner, prec_type, nspins)
Allows for a restart of the preconditioner depending on the method it purges all arrays or keeps them...
subroutine, public prepare_preconditioner(qs_env, mos, matrix_ks, matrix_s, ot_preconditioner, prec_type, solver_type, energy_gap, nspins, has_unit_metric, convert_to_dbcsr, chol_type, full_mo_set)
...
collects routines that calculate density matrices
module that contains the definitions of the scf types
integer, parameter, public direct_mixing_nr
integer, parameter, public gspace_mixing_nr
Apply the direct inversion in the iterative subspace (DIIS) of Pulay in the framework of an SCF itera...
subroutine, public qs_diis_b_info_kp(diis_buffer, ib, nb)
Update info about the current buffer step ib and the current number of buffers nb.
subroutine, public qs_diis_b_calc_err_kp(diis_buffer, ib, mos, kc, sc, ispin, ikp, nkp_local, scf_section)
Calculate and store the error for a given k-point.
subroutine, public qs_diis_b_step_kp(diis_buffer, coeffs, ib, nb, delta, error_max, diis_step, eps_diis, nspin, nkp, nkp_local, nmixing, scf_section, para_env)
Update the SCF DIIS buffer, and if appropriate does a diis step, for k-points.
subroutine, public qs_diis_b_step(diis_buffer, mo_array, kc, sc, delta, error_max, diis_step, eps_diis, nmixing, s_matrix, scf_section, roks)
Update the SCF DIIS buffer, and if appropriate does a diis step.
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, 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 gspace_mixing(qs_env, mixing_method, mixing_store, rho, para_env, iter_count)
Driver for the g-space mixing, calls the proper routine given the requested method.
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
subroutine, public qs_ks_update_qs_env(qs_env, calculate_forces, just_energy, print_active)
updates the Kohn Sham matrix of the given qs_env (facility method)
subroutine, public qs_ks_did_change(ks_env, s_mstruct_changed, rho_changed, potential_changed, full_reset)
tells that some of the things relevant to the ks calculation did change. has to be called when change...
wrapper for the pools of matrixes
subroutine, public mpools_get(mpools, ao_mo_fm_pools, ao_ao_fm_pools, mo_mo_fm_pools, ao_mosub_fm_pools, mosub_mosub_fm_pools, maxao_maxmo_fm_pool, maxao_maxao_fm_pool, maxmo_maxmo_fm_pool)
returns various attributes of the mpools (notably the pools contained in it)
elemental subroutine, public charge_mixing_init(mixing_store)
initialiation needed when charge mixing is used
subroutine, public mixing_init(mixing_method, rho, mixing_store, para_env, rho_atom)
initialiation needed when gspace mixing is used
subroutine, public mixing_allocate(qs_env, mixing_method, p_mix_new, p_delta, nspins, mixing_store)
allocation needed when density mixing is used
subroutine, public self_consistency_check(rho_ao, p_delta, para_env, p_out, delta)
...
collects routines that perform operations directly related to MOs
Set occupation of molecular orbitals.
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)
Get the components of a MO set data structure.
Define the neighbor list data types and the corresponding functionality.
an eigen-space solver for the generalised symmetric eigenvalue problem for sparse matrices,...
subroutine, public ot_eigensolver(matrix_h, matrix_s, matrix_orthogonal_space_fm, matrix_c_fm, preconditioner, eps_gradient, iter_max, size_ortho_space, silent, ot_settings)
...
methods of the rho structure (defined in qs_rho_types)
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...
superstucture that hold various representations of the density and keeps track of which ones are vali...
subroutine, public qs_rho_get(rho_struct, rho_ao, rho_ao_im, rho_ao_kp, rho_ao_im_kp, rho_r, drho_r, rho_g, drho_g, tau_r, tau_g, rho_r_valid, drho_r_valid, rho_g_valid, drho_g_valid, tau_r_valid, tau_g_valid, tot_rho_r, tot_rho_g, rho_r_sccs, soft_valid, complex_rho_ao)
returns info about the density described by this object. If some representation is not available an e...
module that contains the algorithms to perform an iterative diagonalization by the block-Davidson app...
subroutine, public generate_extended_space_sparse(bdav_env, mo_set, matrix_h, matrix_s, output_unit, preconditioner)
...
subroutine, public generate_extended_space(bdav_env, mo_set, matrix_h, matrix_s, output_unit, preconditioner)
...
Different diagonalization schemes that can be used for the iterative solution of the eigenvalue probl...
subroutine, public general_eigenproblem(scf_env, mos, matrix_ks, matrix_s, scf_control, scf_section, diis_step)
the inner loop of scf, specific to diagonalization with S matrix basically, in goes the ks matrix out...
subroutine, public diag_subspace_allocate(subspace_env, qs_env, mos)
...
subroutine, public do_ot_diag(scf_env, mos, matrix_ks, matrix_s, scf_control, scf_section, diis_step)
the inner loop of scf, specific to iterative diagonalization using OT with S matrix; basically,...
subroutine, public do_block_davidson_diag(qs_env, scf_env, mos, matrix_ks, matrix_s, scf_control, scf_section, check_moconv_only)
iterative diagonalization using the block davidson space approach
subroutine, public do_roks_diag(scf_env, mos, matrix_ks, matrix_s, scf_control, scf_section, diis_step, orthogonal_basis)
Solve a set restricted open Kohn-Sham (ROKS) equations based on the alpha and beta Kohn-Sham matrices...
subroutine, public do_scf_diag_subspace(qs_env, scf_env, subspace_env, mos, rho, ks_env, scf_section, scf_control)
inner loop within MOS subspace, to refine occupation and density, before next diagonalization of the ...
subroutine, public do_block_krylov_diag(scf_env, mos, matrix_ks, scf_control, scf_section, check_moconv_only)
iterative diagonalization using the block Krylov-space approach
subroutine, public do_special_diag(scf_env, mos, matrix_ks, scf_control, scf_section, diis_step)
the inner loop of scf, specific to diagonalization without S matrix basically, in goes the ks matrix ...
subroutine, public do_general_diag(scf_env, mos, matrix_ks, matrix_s, scf_control, scf_section, diis_step, probe)
...
subroutine, public do_general_diag_kp(matrix_ks, matrix_s, kpoints, scf_env, scf_control, update_p, diis_step, diis_error, qs_env, probe)
Kpoint diagonalization routine Transforms matrices to kpoint, distributes kpoint groups,...
subroutine, public diag_kp_smat(matrix_s, kpoints, fmwork)
Kpoint diagonalization routine Transforms matrices to kpoint, distributes kpoint groups,...
module that contains the algorithms to perform an iterative diagonalization by the block-Lanczos appr...
subroutine, public lanczos_refinement(krylov_space, ks, c0, c1, eval, nao, eps_iter, ispin, check_moconv_only)
lanczos refinement by blocks of non-converged MOs
subroutine, public lanczos_refinement_2v(krylov_space, ks, c0, c1, eval, nao, eps_iter, ispin, check_moconv_only)
...
groups fairly general SCF methods, so that modules other than qs_scf can use them too split off from ...
subroutine, public eigensolver_simple(matrix_ks, mo_set, work, do_level_shift, level_shift, use_jacobi, jacobi_threshold)
...
subroutine, public eigensolver_dbcsr(matrix_ks, matrix_ks_fm, mo_set, ortho_dbcsr, ksbuf1, ksbuf2)
...
subroutine, public scf_env_density_mixing(p_mix_new, mixing_store, rho_ao, para_env, iter_delta, iter_count, diis, invert)
perform (if requested) a density mixing
subroutine, public eigensolver(matrix_ks_fm, mo_set, ortho, work, cholesky_method, do_level_shift, level_shift, matrix_u_fm, use_jacobi)
Diagonalise the Kohn-Sham matrix to get a new set of MO eigen- vectors and MO eigenvalues....
subroutine, public eigensolver_symm(matrix_ks_fm, mo_set, ortho, work, do_level_shift, level_shift, matrix_u_fm, use_jacobi, jacobi_threshold, ortho_red, work_red, matrix_ks_fm_red, matrix_u_fm_red)
...
subroutine, public eigensolver_generalized(matrix_ks_fm, matrix_s, mo_set, work)
Solve the generalized eigenvalue problem using cusolverMpSygvd.
module that contains the definitions of the scf types
parameters that control an scf iteration
represent a pointer to a 1d array
Represent a complex full matrix.
to create arrays of pools
keeps the information about the structure of a full matrix
Stores the state of a copy between cp_fm_start_copy_general and cp_fm_finish_copy_general.
type of a logger, at the moment it contains just a print level starting at which level it should be l...
Keeps information about a specific k-point.
Contains information about kpoints.
stores all the informations relevant to an mpi environment
calculation environment to calculate the ks matrix, holds all the needed vars. assumes that the core ...
container for the pools of matrixes used by qs
keeps the density in various representations, keeping track of which ones are valid.