124#include "./base/base_uses.f90"
130 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_scf_diagonalization'
153 matrix_s, scf_control, scf_section, &
158 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
161 LOGICAL,
INTENT(INOUT) :: diis_step
163 INTEGER :: ispin, nspin
164 LOGICAL :: do_level_shift, owns_ortho, use_jacobi
165 REAL(kind=
dp) :: diis_error, eps_diis
169 nspin =
SIZE(matrix_ks)
170 NULLIFY (ortho, ortho_dbcsr)
174 scf_env%scf_work1(ispin))
177 eps_diis = scf_control%eps_diis
179 IF (scf_env%iter_count > 1 .AND. .NOT. scf_env%skip_diis)
THEN
180 CALL qs_diis_b_step(scf_env%scf_diis_buffer, mos, scf_env%scf_work1, &
181 scf_env%scf_work2, scf_env%iter_delta, diis_error, diis_step, &
182 eps_diis, scf_control%nmixing, &
184 scf_section=scf_section)
189 do_level_shift = ((scf_control%level_shift /= 0.0_dp) .AND. &
190 ((scf_control%density_guess ==
core_guess) .OR. &
191 (scf_env%iter_count > 1)))
193 IF ((scf_env%iter_count > 1) .AND. &
194 (scf_env%iter_delta < scf_control%diagonalization%eps_jacobi))
THEN
201 scf_env%iter_param = diis_error
203 scf_env%iter_method =
"DIIS/Jacobi"
205 scf_env%iter_method =
"DIIS/Diag."
208 IF (scf_env%mixing_method == 0)
THEN
209 scf_env%iter_method =
"NoMix/Diag."
210 ELSE IF (scf_env%mixing_method == 1)
THEN
211 scf_env%iter_param = scf_env%p_mix_alpha
213 scf_env%iter_method =
"P_Mix/Jacobi"
215 scf_env%iter_method =
"P_Mix/Diag."
217 ELSEIF (scf_env%mixing_method > 1)
THEN
218 scf_env%iter_param = scf_env%mixing_store%alpha
220 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Jacobi"
222 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Diag."
228 ortho_dbcsr => scf_env%ortho_dbcsr
230 CALL eigensolver_dbcsr(matrix_ks=matrix_ks(ispin)%matrix, matrix_ks_fm=scf_env%scf_work1(ispin), &
232 ortho_dbcsr=ortho_dbcsr, &
233 ksbuf1=scf_env%buf1_dbcsr, ksbuf2=scf_env%buf2_dbcsr)
238 ortho => scf_env%ortho_m1
240 ortho => scf_env%ortho
244 IF (.NOT.
ASSOCIATED(ortho))
THEN
250 IF (do_level_shift)
THEN
251 CALL eigensolver(matrix_ks_fm=scf_env%scf_work1(ispin), &
254 work=scf_env%scf_work2, &
255 cholesky_method=scf_env%cholesky_method, &
256 do_level_shift=do_level_shift, &
257 level_shift=scf_control%level_shift, &
258 matrix_u_fm=scf_env%ortho, &
259 use_jacobi=use_jacobi)
261 CALL eigensolver(matrix_ks_fm=scf_env%scf_work1(ispin), &
264 work=scf_env%scf_work2, &
265 cholesky_method=scf_env%cholesky_method, &
266 do_level_shift=do_level_shift, &
267 level_shift=scf_control%level_shift, &
268 use_jacobi=use_jacobi)
272 IF (owns_ortho)
DEALLOCATE (ortho)
274 ortho => scf_env%ortho
277 IF (.NOT.
ASSOCIATED(ortho))
THEN
282 IF (do_level_shift)
THEN
284 IF (
ASSOCIATED(scf_env%scf_work1_red) .AND.
ASSOCIATED(scf_env%scf_work2_red) &
285 .AND.
ASSOCIATED(scf_env%ortho_red) .AND.
ASSOCIATED(scf_env%ortho_m1_red))
THEN
289 work=scf_env%scf_work2, &
290 do_level_shift=do_level_shift, &
291 level_shift=scf_control%level_shift, &
292 matrix_u_fm=scf_env%ortho_m1, &
293 use_jacobi=use_jacobi, &
294 jacobi_threshold=scf_control%diagonalization%jacobi_threshold, &
295 matrix_ks_fm_red=scf_env%scf_work1_red(ispin), &
296 ortho_red=scf_env%ortho_red, &
297 work_red=scf_env%scf_work2_red, &
298 matrix_u_fm_red=scf_env%ortho_m1_red)
303 work=scf_env%scf_work2, &
304 do_level_shift=do_level_shift, &
305 level_shift=scf_control%level_shift, &
306 matrix_u_fm=scf_env%ortho_m1, &
307 use_jacobi=use_jacobi, &
308 jacobi_threshold=scf_control%diagonalization%jacobi_threshold)
313 IF (
ASSOCIATED(scf_env%scf_work1_red) .AND.
ASSOCIATED(scf_env%scf_work2_red) &
314 .AND.
ASSOCIATED(scf_env%ortho_red))
THEN
318 work=scf_env%scf_work2, &
319 do_level_shift=do_level_shift, &
320 level_shift=scf_control%level_shift, &
321 use_jacobi=use_jacobi, &
322 jacobi_threshold=scf_control%diagonalization%jacobi_threshold, &
323 matrix_ks_fm_red=scf_env%scf_work1_red(ispin), &
324 ortho_red=scf_env%ortho_red, &
325 work_red=scf_env%scf_work2_red)
330 work=scf_env%scf_work2, &
331 do_level_shift=do_level_shift, &
332 level_shift=scf_control%level_shift, &
333 use_jacobi=use_jacobi, &
334 jacobi_threshold=scf_control%diagonalization%jacobi_threshold)
339 IF (owns_ortho)
DEALLOCATE (ortho)
356 matrix_s, scf_control, scf_section, &
360 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
361 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
364 LOGICAL,
INTENT(INOUT) :: diis_step
368 INTEGER :: ispin, nspin
369 REAL(kind=
dp) :: total_zeff_corr
371 nspin =
SIZE(matrix_ks)
374 matrix_s, scf_control, scf_section, diis_step)
376 total_zeff_corr = 0.0_dp
377 total_zeff_corr = scf_env%sum_zeff_corr
379 IF (abs(total_zeff_corr) > 0.0_dp)
THEN
381 smear=scf_control%smear, tot_zeff_corr=total_zeff_corr)
383 IF (
PRESENT(probe) .EQV. .true.)
THEN
384 scf_control%smear%do_smear = .false.
386 smear=scf_control%smear, &
390 smear=scf_control%smear)
396 scf_env%p_mix_new(ispin, 1)%matrix)
421 diis_step, diis_error, qs_env, probe)
423 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks, matrix_s
427 LOGICAL,
INTENT(IN) :: update_p
428 LOGICAL,
INTENT(INOUT) :: diis_step
429 REAL(
dp),
INTENT(INOUT),
OPTIONAL :: diis_error
434 CHARACTER(len=*),
PARAMETER :: routinen =
'do_general_diag_kp'
436 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: coeffs
437 INTEGER :: handle, ib, igroup, ik, ikp, indx, &
438 ispin, jb, kplocal, nb, nkp, &
440 INTEGER,
DIMENSION(2) :: kp_range
441 INTEGER,
DIMENSION(:, :),
POINTER :: kp_dist
442 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
443 LOGICAL :: do_diis, my_kpgrp, use_real_wfn
444 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues
445 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
450 TYPE(
cp_fm_type) :: fmdummy, fmlocal, rksmat, rsmat
451 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: fmwork
452 TYPE(
cp_fm_type),
POINTER :: imos, mo_coeff, rmos
453 TYPE(
dbcsr_type),
POINTER :: cmatrix, rmatrix, tmpmat
461 CALL timeset(routinen, handle)
464 CALL get_kpoint_info(kpoints, nkp=nkp, xkp=xkp, use_real_wfn=use_real_wfn, kp_range=kp_range, &
465 nkp_groups=nkp_groups, kp_dist=kp_dist, sab_nl=sab_nl, &
466 cell_to_index=cell_to_index)
467 cpassert(
ASSOCIATED(sab_nl))
468 kplocal = kp_range(2) - kp_range(1) + 1
472 IF (scf_env%iter_count > 1 .AND. .NOT. scf_env%skip_diis .AND. .NOT. use_real_wfn &
473 .AND.
PRESENT(diis_error) .AND.
PRESENT(qs_env)) do_diis = .true.
476 ALLOCATE (rmatrix, cmatrix, tmpmat)
477 CALL dbcsr_create(rmatrix, template=matrix_ks(1, 1)%matrix, &
478 matrix_type=dbcsr_type_symmetric)
479 CALL dbcsr_create(cmatrix, template=matrix_ks(1, 1)%matrix, &
480 matrix_type=dbcsr_type_antisymmetric)
481 CALL dbcsr_create(tmpmat, template=matrix_ks(1, 1)%matrix, &
482 matrix_type=dbcsr_type_no_symmetry)
486 fmwork => scf_env%scf_work1
490 CALL mpools_get(mpools, ao_ao_fm_pools=ao_ao_fm_pools)
495 IF (use_real_wfn)
THEN
502 kp => kpoints%kp_env(1)%kpoint_env
503 CALL get_mo_set(kp%mos(1, 1), mo_coeff=mo_coeff)
508 para_env => kpoints%blacs_env_all%para_env
509 nspin =
SIZE(matrix_ks, 1)
510 ALLOCATE (info(kplocal*nspin*nkp_groups, 4))
516 DO igroup = 1, nkp_groups
518 ik = kp_dist(1, igroup) + ikp - 1
519 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
521 IF (use_real_wfn)
THEN
524 CALL rskp_transform(rmatrix=rmatrix, rsmat=matrix_ks, ispin=ispin, &
525 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
531 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
538 CALL rskp_transform(rmatrix=rmatrix, cmatrix=cmatrix, rsmat=matrix_ks, ispin=ispin, &
539 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
547 CALL rskp_transform(rmatrix=rmatrix, cmatrix=cmatrix, rsmat=matrix_s, ispin=1, &
548 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
558 IF (use_real_wfn)
THEN
585 CALL get_qs_env(qs_env, para_env=para_env_global)
591 DO igroup = 1, nkp_groups
593 ik = kp_dist(1, igroup) + ikp - 1
594 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
608 kp => kpoints%kp_env(ikp)%kpoint_env
610 ispin, ikp, kplocal, scf_section)
615 ALLOCATE (coeffs(nb))
616 CALL qs_diis_b_step_kp(kpoints%scf_diis_buffer, coeffs, ib, nb, scf_env%iter_delta, diis_error, &
617 diis_step, scf_control%eps_diis, nspin, nkp, kplocal, scf_control%nmixing, &
618 scf_section, para_env_global)
623 kp => kpoints%kp_env(ikp)%kpoint_env
631 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos, eigenvalues=eigenvalues)
632 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
635 scf_control%eps_eigval)
637 CALL cp_cfm_geeig(cksmat, csmat, cmos, eigenvalues, cwork)
640 kp%mos(2, ispin)%eigenvalues = eigenvalues
651 DO igroup = 1, nkp_groups
653 ik = kp_dist(1, igroup) + ikp - 1
654 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
657 IF (use_real_wfn)
THEN
675 kp => kpoints%kp_env(ikp)%kpoint_env
676 IF (use_real_wfn)
THEN
677 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=mo_coeff, eigenvalues=eigenvalues)
680 scf_control%eps_eigval)
682 CALL cp_fm_geeig(rksmat, rsmat, mo_coeff, eigenvalues, fmlocal)
685 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos, eigenvalues=eigenvalues)
686 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
689 scf_control%eps_eigval)
691 CALL cp_cfm_geeig(cksmat, csmat, cmos, eigenvalues, cwork)
694 kp%mos(2, ispin)%eigenvalues = eigenvalues
706 DO igroup = 1, nkp_groups
708 ik = kp_dist(1, igroup) + ikp - 1
709 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
711 IF (use_real_wfn)
THEN
729 IF (
PRESENT(probe) .EQV. .true.)
THEN
730 scf_control%smear%do_smear = .false.
740 matrix_s(1, 1)%matrix, sab_nl, fmwork)
747 IF (use_real_wfn)
THEN
758 CALL timestop(handle)
778 ks_env, scf_section, scf_control)
783 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
789 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_scf_diag_subspace'
790 REAL(kind=
dp),
PARAMETER :: rone = 1.0_dp, rzero = 0.0_dp
792 INTEGER :: handle, i, iloop, ispin, nao, nmo, &
795 REAL(
dp) :: ene_diff, ene_old, iter_delta, max_val, &
796 sum_band, sum_val, t1, t2
797 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues, mo_occupations
798 TYPE(
cp_1d_r_p_type),
ALLOCATABLE,
DIMENSION(:) :: eval_first, occ_first
800 TYPE(
cp_fm_type),
POINTER :: c0, chc, evec, mo_coeff
802 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s, rho_ao
803 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_kp
809 CALL timeset(routinen, handle)
810 NULLIFY (c0, chc, energy, evec, matrix_ks, mo_coeff, mo_eigenvalues, &
811 mo_occupations, dft_control, rho_ao, rho_ao_kp)
819 CALL qs_rho_get(rho, rho_ao=rho_ao, rho_ao_kp=rho_ao_kp)
821 ALLOCATE (eval_first(nspin))
822 ALLOCATE (occ_first(nspin))
826 eigenvalues=mo_eigenvalues, &
827 occupation_numbers=mo_occupations)
828 ALLOCATE (eval_first(ispin)%array(nmo))
829 ALLOCATE (occ_first(ispin)%array(nmo))
830 eval_first(ispin)%array(1:nmo) = mo_eigenvalues(1:nmo)
831 occ_first(ispin)%array(1:nmo) = mo_occupations(1:nmo)
836 CALL dbcsr_copy(subspace_env%p_matrix_store(ispin)%matrix, rho_ao(ispin)%matrix)
837 CALL dbcsr_copy(rho_ao(ispin)%matrix, scf_env%p_mix_new(ispin, 1)%matrix)
840 subspace_env%p_matrix_mix => scf_env%p_mix_new
842 NULLIFY (matrix_ks, energy, para_env, matrix_s)
844 matrix_ks=matrix_ks, &
848 dft_control=dft_control)
852 CALL mixing_allocate(qs_env, subspace_env%mixing_method, scf_env%p_mix_new, &
853 scf_env%p_delta, nspin, subspace_env%mixing_store)
854 IF (dft_control%qs_control%gapw)
THEN
855 CALL get_qs_env(qs_env=qs_env, rho_atom_set=rho_atom)
856 CALL mixing_init(subspace_env%mixing_method, rho, subspace_env%mixing_store, &
857 para_env, rho_atom=rho_atom)
858 ELSEIF (dft_control%qs_control%dftb .OR. dft_control%qs_control%xtb)
THEN
860 ELSEIF (dft_control%qs_control%semi_empirical)
THEN
861 cpabort(
'SE Code not possible')
863 CALL mixing_init(subspace_env%mixing_method, rho, subspace_env%mixing_store, para_env)
869 IF (output_unit > 0)
THEN
870 WRITE (output_unit,
"(/T19,A)")
'<<<<<<<<< SUBSPACE ROTATION <<<<<<<<<<'
871 WRITE (output_unit,
"(T4,A,T13,A,T21,A,T38,A,T51,A,T65,A/,T4,A)") &
872 "In-step",
"Time",
"Convergence",
"Band ene.",
"Total ene.",
"Energy diff.", repeat(
"-", 74)
880 DO iloop = 1, subspace_env%max_iter
883 ene_old = energy%total
887 just_energy=.false., print_active=.false.)
892 DO ispin = 1,
SIZE(matrix_ks)
896 eigenvalues=mo_eigenvalues, &
897 occupation_numbers=mo_occupations, &
901 chc => subspace_env%chc_mat(ispin)
902 evec => subspace_env%c_vec(ispin)
903 c0 => subspace_env%c0(ispin)
907 CALL parallel_gemm(
'T',
'N', nmo, nmo, nao, rone, c0, work, rzero, chc)
913 CALL parallel_gemm(
'N',
'N', nao, nmo, nmo, rone, c0, evec, rzero, mo_coeff)
916 smear=scf_control%smear)
920 subspace_env%p_matrix_mix(ispin, 1)%matrix)
923 sum_band = sum_band + mo_eigenvalues(i)*mo_occupations(i)
931 scf_env%mixing_store, rho_ao_kp, para_env, iter_delta, iloop)
934 subspace_env%p_matrix_mix, delta=iter_delta)
939 CALL dbcsr_copy(rho_ao(ispin)%matrix, subspace_env%p_matrix_mix(ispin, 1)%matrix)
945 CALL gspace_mixing(qs_env, scf_env%mixing_method, subspace_env%mixing_store, &
946 rho, para_env, scf_env%iter_count)
949 ene_diff = energy%total - ene_old
950 converged = (abs(ene_diff) < subspace_env%eps_ene .AND. &
951 iter_delta < subspace_env%eps_adapt*scf_env%iter_delta)
953 IF (output_unit > 0)
THEN
954 WRITE (output_unit,
"(T4,I5,T11,F8.3,T18,E14.4,T34,F12.5,T46,F16.8,T62,E14.4)") &
955 iloop, t2 - t1, iter_delta, sum_band, energy%total, ene_diff
959 IF (output_unit > 0)
WRITE (output_unit,
"(T10,A,I6,A,/)") &
960 " Reached convergence in ", iloop,
" iterations "
966 NULLIFY (subspace_env%p_matrix_mix)
969 CALL dbcsr_copy(scf_env%p_mix_new(ispin, 1)%matrix, rho_ao(ispin)%matrix)
970 CALL dbcsr_copy(rho_ao(ispin)%matrix, subspace_env%p_matrix_store(ispin)%matrix)
972 DEALLOCATE (eval_first(ispin)%array, occ_first(ispin)%array)
974 DEALLOCATE (eval_first, occ_first)
976 CALL timestop(handle)
992 CHARACTER(LEN=*),
PARAMETER :: routinen =
'diag_subspace_allocate'
994 INTEGER :: handle, i, ispin, nmo, nspin
1001 CALL timeset(routinen, handle)
1003 NULLIFY (sab_orb, matrix_s)
1004 CALL get_qs_env(qs_env=qs_env, sab_orb=sab_orb, &
1009 IF (.NOT.
ASSOCIATED(subspace_env%p_matrix_store))
THEN
1013 ALLOCATE (subspace_env%p_matrix_store(i)%matrix)
1014 CALL dbcsr_create(matrix=subspace_env%p_matrix_store(i)%matrix, template=matrix_s(1)%matrix, &
1015 name=
"DENSITY_STORE", matrix_type=dbcsr_type_symmetric)
1018 CALL dbcsr_set(subspace_env%p_matrix_store(i)%matrix, 0.0_dp)
1023 ALLOCATE (subspace_env%chc_mat(nspin))
1024 ALLOCATE (subspace_env%c_vec(nspin))
1025 ALLOCATE (subspace_env%c0(nspin))
1028 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
1029 CALL cp_fm_create(subspace_env%c0(ispin), mo_coeff%matrix_struct)
1030 NULLIFY (fm_struct_tmp)
1032 para_env=mo_coeff%matrix_struct%para_env, &
1033 context=mo_coeff%matrix_struct%context)
1034 CALL cp_fm_create(subspace_env%chc_mat(ispin), fm_struct_tmp,
"chc")
1035 CALL cp_fm_create(subspace_env%c_vec(ispin), fm_struct_tmp,
"vec")
1039 CALL timestop(handle)
1056 scf_section, diis_step)
1059 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
1063 LOGICAL,
INTENT(INOUT) :: diis_step
1065 INTEGER :: ispin, nspin
1066 LOGICAL :: do_level_shift, use_jacobi
1067 REAL(kind=
dp) :: diis_error
1069 nspin =
SIZE(matrix_ks)
1074 IF (scf_env%iter_count > 1 .AND. .NOT. scf_env%skip_diis)
THEN
1075 CALL qs_diis_b_step(scf_env%scf_diis_buffer, mos, scf_env%scf_work1, &
1076 scf_env%scf_work2, scf_env%iter_delta, diis_error, diis_step, &
1077 scf_control%eps_diis, scf_control%nmixing, &
1078 scf_section=scf_section)
1083 IF ((scf_env%iter_count > 1) .AND. (scf_env%iter_delta < scf_control%diagonalization%eps_jacobi))
THEN
1086 use_jacobi = .false.
1089 do_level_shift = ((scf_control%level_shift /= 0.0_dp) .AND. &
1090 ((scf_control%density_guess ==
core_guess) .OR. (scf_env%iter_count > 1)))
1092 scf_env%iter_param = diis_error
1093 IF (use_jacobi)
THEN
1094 scf_env%iter_method =
"DIIS/Jacobi"
1096 scf_env%iter_method =
"DIIS/Diag."
1099 IF (scf_env%mixing_method == 1)
THEN
1100 scf_env%iter_param = scf_env%p_mix_alpha
1101 IF (use_jacobi)
THEN
1102 scf_env%iter_method =
"P_Mix/Jacobi"
1104 scf_env%iter_method =
"P_Mix/Diag."
1106 ELSEIF (scf_env%mixing_method > 1)
THEN
1107 scf_env%iter_param = scf_env%mixing_store%alpha
1108 IF (use_jacobi)
THEN
1109 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Jacobi"
1111 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Diag."
1115 scf_env%iter_delta = 0.0_dp
1119 mo_set=mos(ispin), &
1120 work=scf_env%scf_work2, &
1121 do_level_shift=do_level_shift, &
1122 level_shift=scf_control%level_shift, &
1123 use_jacobi=use_jacobi, &
1124 jacobi_threshold=scf_control%diagonalization%jacobi_threshold)
1128 smear=scf_control%smear)
1133 scf_env%p_mix_new(ispin, 1)%matrix)
1152 scf_control, scf_section, diis_step)
1155 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
1156 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
1159 LOGICAL,
INTENT(INOUT) :: diis_step
1161 INTEGER :: homo, ispin, nmo, nspin
1162 REAL(kind=
dp) :: diis_error, eps_iter
1163 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues
1166 NULLIFY (eigenvalues)
1168 nspin =
SIZE(matrix_ks)
1172 scf_env%scf_work1(ispin))
1175 IF ((scf_env%iter_count > 1) .AND. (.NOT. scf_env%skip_diis))
THEN
1176 CALL qs_diis_b_step(scf_env%scf_diis_buffer, mos, scf_env%scf_work1, &
1177 scf_env%scf_work2, scf_env%iter_delta, diis_error, diis_step, &
1178 scf_control%eps_diis, scf_control%nmixing, &
1179 s_matrix=matrix_s, &
1180 scf_section=scf_section)
1185 eps_iter = scf_control%diagonalization%eps_iter
1187 scf_env%iter_param = diis_error
1188 scf_env%iter_method =
"DIIS/OTdiag"
1191 matrix_ks(ispin)%matrix, keep_sparsity=.true.)
1193 eps_iter = max(eps_iter, scf_control%diagonalization%eps_adapt*diis_error)
1195 IF (scf_env%mixing_method == 1)
THEN
1196 scf_env%iter_param = scf_env%p_mix_alpha
1197 scf_env%iter_method =
"P_Mix/OTdiag."
1198 ELSEIF (scf_env%mixing_method > 1)
THEN
1199 scf_env%iter_param = scf_env%mixing_store%alpha
1200 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/OTdiag."
1204 scf_env%iter_delta = 0.0_dp
1208 mo_coeff=mo_coeff, &
1209 eigenvalues=eigenvalues, &
1213 matrix_s=matrix_s(1)%matrix, &
1214 matrix_c_fm=mo_coeff, &
1216 eps_gradient=eps_iter, &
1217 iter_max=scf_control%diagonalization%max_iter, &
1219 ot_settings=scf_control%diagonalization%ot_settings)
1221 evals_arg=eigenvalues, &
1224 mos(ispin)%mo_coeff_b)
1229 smear=scf_control%smear)
1234 scf_env%p_mix_new(ispin, 1)%matrix)
1257 scf_control, scf_section, diis_step, &
1265 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(IN) :: mos
1266 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
1269 LOGICAL,
INTENT(INOUT) :: diis_step
1270 LOGICAL,
INTENT(IN) :: orthogonal_basis
1272 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_roks_diag'
1274 INTEGER :: handle, homoa, homob, imo, nalpha, nao, &
1276 REAL(kind=
dp) :: diis_error, level_shift_loc
1277 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eiga, eigb, occa, occb
1278 TYPE(
cp_fm_type),
POINTER :: ksa, ksb, mo2ao, moa, mob, ortho, work
1282 CALL timeset(routinen, handle)
1285 ortho => scf_env%ortho_m1
1287 ortho => scf_env%ortho
1289 work => scf_env%scf_work2
1291 ksa => scf_env%scf_work1(1)
1292 ksb => scf_env%scf_work1(2)
1305 occupation_numbers=occa, &
1312 occupation_numbers=occb, &
1317 IF ((scf_control%level_shift /= 0.0_dp) .AND. &
1318 ((scf_control%density_guess ==
core_guess) .OR. &
1320 (scf_env%iter_count > 1)))
THEN
1321 level_shift_loc = scf_control%level_shift
1323 level_shift_loc = 0.0_dp
1326 IF ((scf_env%iter_count > 1) .OR. &
1327 (scf_control%density_guess ==
core_guess) .OR. &
1333 CALL cp_fm_symm(
"L",
"U", nao, nao, 1.0_dp, ksa, moa, 0.0_dp, work)
1334 CALL parallel_gemm(
"T",
"N", nao, nao, nao, 1.0_dp, moa, work, 0.0_dp, ksa)
1336 CALL cp_fm_symm(
"L",
"U", nao, nao, 1.0_dp, ksb, moa, 0.0_dp, work)
1337 CALL parallel_gemm(
"T",
"N", nao, nao, nao, 1.0_dp, moa, work, 0.0_dp, ksb)
1348 cpabort(
"Unknown ROKS scheme requested")
1354 IF (orthogonal_basis)
THEN
1367 CALL parallel_gemm(
"N",
"T", nao, nao, nao, 1.0_dp, ksa, mo2ao, 0.0_dp, work)
1368 CALL parallel_gemm(
"N",
"N", nao, nao, nao, 1.0_dp, mo2ao, work, 0.0_dp, ksa)
1382 IF (scf_env%iter_count > 1)
THEN
1383 IF (orthogonal_basis)
THEN
1386 kc=scf_env%scf_work1, &
1388 delta=scf_env%iter_delta, &
1389 error_max=diis_error, &
1390 diis_step=diis_step, &
1391 eps_diis=scf_control%eps_diis, &
1392 scf_section=scf_section, &
1394 cpassert(scf_env%iter_delta == scf_env%iter_delta)
1398 kc=scf_env%scf_work1, &
1400 delta=scf_env%iter_delta, &
1401 error_max=diis_error, &
1402 diis_step=diis_step, &
1403 eps_diis=scf_control%eps_diis, &
1404 scf_section=scf_section, &
1405 s_matrix=matrix_s, &
1411 scf_env%iter_param = diis_error
1412 scf_env%iter_method =
"DIIS/Diag."
1414 IF (scf_env%mixing_method == 1)
THEN
1415 scf_env%iter_param = scf_env%p_mix_alpha
1416 scf_env%iter_method =
"P_Mix/Diag."
1417 ELSEIF (scf_env%mixing_method > 1)
THEN
1418 scf_env%iter_param = scf_env%mixing_store%alpha
1419 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Diag."
1423 scf_env%iter_delta = 0.0_dp
1425 IF (level_shift_loc /= 0.0_dp)
THEN
1430 CALL cp_fm_symm(
"L",
"U", nao, nao, 1.0_dp, ksa, moa, 0.0_dp, work)
1431 CALL parallel_gemm(
"T",
"N", nao, nao, nao, 1.0_dp, moa, work, 0.0_dp, ksa)
1435 DO imo = homob + 1, homoa
1438 DO imo = homoa + 1, nmo
1442 ELSE IF (.NOT. orthogonal_basis)
THEN
1445 SELECT CASE (scf_env%cholesky_method)
1451 "SOLVE", pos=
"RIGHT")
1453 "SOLVE", pos=
"LEFT", transa=
"T")
1457 "MULTIPLY", pos=
"RIGHT")
1459 "MULTIPLY", pos=
"LEFT", transa=
"T")
1461 CALL cp_fm_symm(
"L",
"U", nao, nao, 1.0_dp, ksa, ortho, 0.0_dp, work)
1462 CALL parallel_gemm(
"N",
"N", nao, nao, nao, 1.0_dp, ortho, work, 0.0_dp, ksa)
1473 IF (level_shift_loc /= 0.0_dp)
THEN
1476 CALL parallel_gemm(
"N",
"N", nao, nmo, nao, 1.0_dp, ortho, work, 0.0_dp, moa)
1478 IF (orthogonal_basis)
THEN
1481 SELECT CASE (scf_env%cholesky_method)
1487 CALL parallel_gemm(
"N",
"N", nao, nmo, nao, 1.0_dp, ortho, work, 0.0_dp, moa)
1494 IF (level_shift_loc /= 0.0_dp)
THEN
1495 DO imo = homob + 1, homoa
1496 eiga(imo) = eiga(imo) - 0.5_dp*level_shift_loc
1498 DO imo = homoa + 1, nmo
1499 eiga(imo) = eiga(imo) - level_shift_loc
1514 CALL timestop(handle)
1532 scf_control, scf_section, check_moconv_only)
1535 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
1539 LOGICAL,
INTENT(IN),
OPTIONAL :: check_moconv_only
1541 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_block_krylov_diag'
1542 REAL(kind=
dp),
PARAMETER :: rone = 1.0_dp, rzero = 0.0_dp
1544 INTEGER :: handle, homo, ispin, iter, nao, nmo, &
1546 LOGICAL :: converged, my_check_moconv_only
1547 REAL(
dp) :: eps_iter, t1, t2
1548 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues
1549 TYPE(
cp_fm_type),
POINTER :: c0, c1, chc, evec, ks, mo_coeff, ortho, &
1554 CALL timeset(routinen, handle)
1557 extension=
".scfLog")
1559 my_check_moconv_only = .false.
1560 IF (
PRESENT(check_moconv_only)) my_check_moconv_only = check_moconv_only
1562 NULLIFY (mo_coeff, ortho, work, ks)
1563 NULLIFY (mo_eigenvalues)
1567 ortho => scf_env%ortho_m1
1569 ortho => scf_env%ortho
1571 work => scf_env%scf_work2
1573 DO ispin = 1,
SIZE(matrix_ks)
1575 scf_env%scf_work1(ispin))
1578 IF (scf_env%mixing_method == 1)
THEN
1579 scf_env%iter_param = scf_env%p_mix_alpha
1580 scf_env%iter_method =
"P_Mix/Lanczos"
1583 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Lanc."
1586 DO ispin = 1,
SIZE(matrix_ks)
1588 ks => scf_env%scf_work1(ispin)
1595 eigenvalues=mo_eigenvalues, &
1599 c0 => scf_env%krylov_space%mo_conv(ispin)
1600 c1 => scf_env%krylov_space%mo_refine(ispin)
1601 SELECT CASE (scf_env%cholesky_method)
1608 "SOLVE", pos=
"RIGHT")
1610 "SOLVE", pos=
"LEFT", transa=
"T")
1614 "MULTIPLY", pos=
"RIGHT")
1616 "MULTIPLY", pos=
"LEFT", transa=
"T")
1620 scf_env%krylov_space%nmo_nc = nmo
1621 scf_env%krylov_space%nmo_conv = 0
1624 IF (output_unit > 0)
THEN
1625 WRITE (output_unit,
"(/T15,A)")
'<<<<<<<<< LANCZOS REFINEMENT <<<<<<<<<<'
1626 WRITE (output_unit,
"(T8,A,T15,A,T23,A,T36,A,T49,A,T60,A,/,T8,A)") &
1627 " Spin ",
" Cycle ", &
1628 " conv. MOS ",
" B2MAX ",
" B2MIN ",
" Time", repeat(
"-", 60)
1630 eps_iter = max(scf_env%krylov_space%eps_conv, scf_env%krylov_space%eps_adapt*scf_env%iter_delta)
1634 IF (my_check_moconv_only)
THEN
1637 nao, eps_iter, ispin, check_moconv_only=my_check_moconv_only)
1639 IF (output_unit > 0) &
1640 WRITE (output_unit,
'(T8,I3,T16,I5,T24,I6,T33,E12.4,2x,E12.4,T60,F8.3)') &
1641 ispin, iter, scf_env%krylov_space%nmo_conv, &
1642 scf_env%krylov_space%max_res_norm, scf_env%krylov_space%min_res_norm, t2 - t1
1647 DO iter = 1, scf_env%krylov_space%max_iter
1649 nao, eps_iter, ispin)
1651 IF (output_unit > 0)
THEN
1652 WRITE (output_unit,
'(T8,I3,T16,I5,T24,I6,T33,E12.4,2x,E12.4,T60,F8.3)') &
1653 ispin, iter, scf_env%krylov_space%nmo_conv, &
1654 scf_env%krylov_space%max_res_norm, scf_env%krylov_space%min_res_norm, t2 - t1
1657 IF (scf_env%krylov_space%max_res_norm < eps_iter)
THEN
1659 IF (output_unit > 0)
WRITE (output_unit, *) &
1660 " Reached convergence in ", iter,
" iterations "
1665 IF (.NOT. converged .AND. output_unit > 0)
THEN
1666 WRITE (output_unit,
"(T4, A)")
" WARNING Lanczos refinement could "// &
1667 "not converge all the mos:"
1668 WRITE (output_unit,
"(T40,A,T70,I10)")
" number of not converged mos ", &
1669 scf_env%krylov_space%nmo_nc
1670 WRITE (output_unit,
"(T40,A,T70,E10.2)")
" max norm of the residual ", &
1671 scf_env%krylov_space%max_res_norm
1679 chc => scf_env%krylov_space%chc_mat(ispin)
1680 evec => scf_env%krylov_space%c_vec(ispin)
1681 CALL parallel_gemm(
'N',
'N', nao, nmo, nao, rone, ks, c0, rzero, work)
1682 CALL parallel_gemm(
'T',
'N', nmo, nmo, nao, rone, c0, work, rzero, chc)
1686 CALL parallel_gemm(
'N',
'N', nao, nmo, nmo, rone, c0, evec, rzero, c1)
1687 c0 => scf_env%krylov_space%mo_refine(ispin)
1697 smear=scf_control%smear)
1701 scf_env%p_mix_new(ispin, 1)%matrix)
1705 IF (output_unit > 0)
THEN
1706 WRITE (output_unit,
"(T15,A/)")
'<<<<<<<<< END LANCZOS REFINEMENT <<<<<<<<<<'
1712 CALL timestop(handle)
1732 scf_control, scf_section, check_moconv_only)
1736 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
1737 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
1740 LOGICAL,
INTENT(IN),
OPTIONAL :: check_moconv_only
1742 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_block_davidson_diag'
1744 INTEGER :: handle, ispin, nspins, output_unit
1745 LOGICAL :: do_prec, my_check_moconv_only
1749 CALL timeset(routinen, handle)
1752 extension=
".scfLog")
1754 IF (output_unit > 0) &
1755 WRITE (output_unit,
"(/T15,A)")
'<<<<<<<<< DAVIDSON ITERATIONS <<<<<<<<<<'
1757 IF (scf_env%mixing_method == 1)
THEN
1758 scf_env%iter_param = scf_env%p_mix_alpha
1759 scf_env%iter_method =
"P_Mix/Dav."
1761 scf_env%iter_param = scf_env%mixing_store%alpha
1762 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Dav."
1765 my_check_moconv_only = .false.
1766 IF (
PRESENT(check_moconv_only)) my_check_moconv_only = check_moconv_only
1768 IF (scf_env%block_davidson_env(1)%prec_type /= 0 .AND. &
1769 scf_env%iter_count >= scf_env%block_davidson_env(1)%first_prec)
THEN
1773 nspins =
SIZE(matrix_ks)
1775 IF (do_prec .AND. (scf_env%iter_count == scf_env%block_davidson_env(1)%first_prec .OR. &
1776 modulo(scf_env%iter_count, scf_env%block_davidson_env(1)%niter_new_prec) == 0))
THEN
1778 prec_type=scf_env%block_davidson_env(1)%prec_type, nspins=nspins)
1780 scf_env%block_davidson_env(1)%prec_type, &
1781 scf_env%block_davidson_env(1)%solver_type, &
1782 scf_env%block_davidson_env(1)%energy_gap, nspins, &
1783 convert_to_dbcsr=scf_env%block_davidson_env(1)%use_sparse_mos, &
1787 DO ispin = 1, nspins
1788 IF (scf_env%block_davidson_env(ispin)%use_sparse_mos)
THEN
1789 IF (.NOT. do_prec)
THEN
1791 matrix_ks(ispin)%matrix, matrix_s(1)%matrix, output_unit)
1794 matrix_ks(ispin)%matrix, matrix_s(1)%matrix, output_unit, &
1795 scf_env%ot_preconditioner(ispin)%preconditioner)
1799 IF (.NOT. do_prec)
THEN
1801 matrix_ks(ispin)%matrix, matrix_s(1)%matrix, output_unit)
1804 matrix_ks(ispin)%matrix, matrix_s(1)%matrix, output_unit, &
1805 scf_env%ot_preconditioner(ispin)%preconditioner)
1811 smear=scf_control%smear)
1813 DO ispin = 1, nspins
1816 scf_env%p_mix_new(ispin, 1)%matrix)
1819 IF (output_unit > 0)
THEN
1820 WRITE (output_unit,
"(T15,A/)")
'<<<<<<<<< END DAVIDSON ITERATION <<<<<<<<<<'
1826 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...
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_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_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.
subroutine, public cp_cfm_create(matrix, matrix_struct, name, set_zero)
Creates a new full matrix with the given structure.
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_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...
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...
subroutine, public cp_fm_geeig_canon(amatrix, bmatrix, eigenvectors, eigenvalues, work, epseig)
General Eigenvalue Problem AX = BXE Use canonical diagonalization : U*s**(-1/2)
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_create(matrix, matrix_struct, name, use_sp, set_zero)
creates a new full matrix with the given structure
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_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, 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, 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,...
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)
...
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.