37 dbcsr_type, dbcsr_type_antisymmetric, dbcsr_type_no_symmetry, dbcsr_type_symmetric
75 USE ieee_arithmetic,
ONLY: ieee_is_finite
170#include "./base/base_uses.f90"
176 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_scf_diagonalization'
178 TYPE,
PRIVATE :: kp_diag_omp_workspace_type
179 TYPE(cp_cfm_type) :: cksmat, cmos, csmat, csmat_base, cwork
180 END TYPE kp_diag_omp_workspace_type
206 matrix_re, matrix_im)
207 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_rs
210 INTEGER,
INTENT(IN) :: ispin
211 TYPE(
cp_fm_type),
INTENT(IN) :: cache_re, cache_im
212 TYPE(
dbcsr_type),
POINTER :: matrix_re, matrix_im
214 INTEGER :: nkp_groups
215 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
216 REAL(
dp),
DIMENSION(:, :),
POINTER :: xkp
220 NULLIFY (cell_to_index, sab_nl, xkp)
221 cpassert(
ASSOCIATED(matrix_rs))
222 cpassert(ispin >= 1 .AND. ispin <=
SIZE(matrix_rs, 1))
223 cpassert(
ASSOCIATED(kpoints))
224 cpassert(
ASSOCIATED(kp))
229 cell_to_index=cell_to_index, sab_nl=sab_nl)
230 IF (nkp_groups == 1)
THEN
231 cpassert(
ASSOCIATED(xkp))
232 cpassert(
ASSOCIATED(cell_to_index))
233 cpassert(
ASSOCIATED(sab_nl))
234 CALL dbcsr_create(matrix_re, template=matrix_rs(1, 1)%matrix, &
235 matrix_type=dbcsr_type_symmetric)
236 CALL dbcsr_create(matrix_im, template=matrix_rs(1, 1)%matrix, &
237 matrix_type=dbcsr_type_antisymmetric)
242 CALL rskp_transform(rmatrix=matrix_re, cmatrix=matrix_im, rsmat=matrix_rs, ispin=ispin, &
243 xkp=xkp(1:3, kp%nkpoint), cell_to_index=cell_to_index, sab_nl=sab_nl)
265 matrix_s, scf_control, scf_section, &
270 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
273 LOGICAL,
INTENT(INOUT) :: diis_step
275 INTEGER :: cdiis_cholesky_method, cdiis_ncall, &
277 LOGICAL :: cdiis_step, do_level_shift, owns_ortho, &
278 use_adiis, use_cdiis, use_jacobi, &
280 REAL(kind=
dp) :: cdiis_error, diis_error, diis_weight, &
283 TYPE(
dbcsr_type),
POINTER :: effective_ks_dbcsr, ortho_dbcsr
285 nspin =
SIZE(matrix_ks)
286 NULLIFY (effective_ks_dbcsr, ortho, ortho_dbcsr)
289 use_subspace_fock = .false.
291 IF (.NOT.
ASSOCIATED(scf_env%scf_subspace_buffer))
THEN
292 cpabort(
"ADIIS is only available in the main Quickstep SCF workflow")
294 use_subspace_fock = scf_env%scf_subspace_buffer%use_combined_fock
297 eps_diis = scf_control%eps_diis
299 IF (use_adiis .AND.
ASSOCIATED(scf_env%scf_diis_buffer))
THEN
300 IF (.NOT. scf_env%skip_diis .AND. scf_env%iter_count > 1 .AND. &
301 .NOT. scf_env%adiis_check_next .AND. &
302 scf_env%scf_subspace_buffer%diis_state_valid .AND. &
303 scf_env%scf_subspace_buffer%nstored > 0)
THEN
304 use_cdiis = scf_env%iter_delta < eps_diis .OR. scf_env%scf_diis_buffer%ncall > 0
311 ELSE IF (use_subspace_fock)
THEN
312 CALL copy_dbcsr_to_fm(scf_env%scf_subspace_buffer%combined_fock(ispin, 1)%matrix, &
313 scf_env%scf_work1(ispin))
321 diis_error = scf_env%scf_subspace_buffer%last_old_fock_weight
322 diis_weight = scf_env%scf_subspace_buffer%diis_weight
324 cdiis_ncall = scf_env%scf_diis_buffer%ncall
325 CALL qs_diis_b_step(scf_env%scf_diis_buffer, mos, scf_env%scf_work1, &
326 scf_env%scf_work2, scf_env%iter_delta, cdiis_error, cdiis_step, &
327 eps_diis, 2, s_matrix=matrix_s, scf_section=scf_section)
328 IF (.NOT. ieee_is_finite(cdiis_error) .OR. cdiis_error >= eps_diis)
THEN
330 IF (cdiis_ncall < scf_env%scf_diis_buffer%nbuffer)
THEN
332 scf_env%scf_diis_buffer%ncall = cdiis_ncall
340 diis_weight = min(1.0_dp, diis_weight + 0.5_dp)
345 IF (diis_weight < 1.0_dp)
THEN
347 IF (use_subspace_fock)
THEN
349 scf_env%scf_subspace_buffer%combined_fock(ispin, 1)%matrix, scf_env%scf_work2)
354 1.0_dp - diis_weight, scf_env%scf_work2)
357 diis_step = cdiis_step .AND. diis_weight >= 1.0_dp
358 IF (diis_step) diis_error = cdiis_error
359 ELSE IF (
ASSOCIATED(scf_env%scf_diis_buffer))
THEN
360 IF (scf_env%scf_diis_buffer%ncall > 0)
CALL qs_diis_b_clear(scf_env%scf_diis_buffer)
363 scf_env%scf_subspace_buffer%diis_weight = diis_weight
365 IF (scf_env%iter_count > 1 .AND. .NOT. scf_env%skip_diis)
THEN
366 CALL qs_diis_b_step(scf_env%scf_diis_buffer, mos, scf_env%scf_work1, &
367 scf_env%scf_work2, scf_env%iter_delta, diis_error, diis_step, &
368 eps_diis, scf_control%nmixing, &
370 scf_section=scf_section)
376 do_level_shift = ((scf_control%level_shift /= 0.0_dp) .AND. &
377 ((scf_control%density_guess ==
core_guess) .OR. &
378 (scf_env%iter_count > 1)))
380 IF (.NOT. use_adiis .AND. (scf_env%iter_count > 1) .AND. &
381 (scf_env%iter_delta < scf_control%diagonalization%eps_jacobi))
THEN
387 IF (use_adiis .AND. .NOT. diis_step)
THEN
388 scf_env%iter_param = diis_error
389 IF (scf_env%scf_subspace_buffer%last_restart)
THEN
390 scf_env%iter_method =
"ADIIS/Rst."
392 scf_env%iter_method =
"ADIIS/Diag."
394 ELSE IF (diis_step)
THEN
395 scf_env%iter_param = diis_error
397 scf_env%iter_method =
"DIIS/Jacobi"
399 scf_env%iter_method =
"DIIS/Diag."
402 IF (scf_env%mixing_method == 0)
THEN
403 scf_env%iter_method =
"NoMix/Diag."
404 ELSE IF (scf_env%mixing_method == 1)
THEN
405 scf_env%iter_param = scf_env%p_mix_alpha
407 scf_env%iter_method =
"P_Mix/Jacobi"
409 scf_env%iter_method =
"P_Mix/Diag."
411 ELSE IF (scf_env%mixing_method > 1)
THEN
412 scf_env%iter_param = scf_env%mixing_store%alpha
414 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Jacobi"
416 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Diag."
421 IF (scf_env%cholesky_method ==
cholesky_dbcsr .AND. .NOT. use_cdiis)
THEN
422 ortho_dbcsr => scf_env%ortho_dbcsr
424 effective_ks_dbcsr => matrix_ks(ispin)%matrix
425 IF (use_subspace_fock)
THEN
426 effective_ks_dbcsr => scf_env%scf_subspace_buffer%combined_fock(ispin, 1)%matrix
428 CALL eigensolver_dbcsr(matrix_ks=effective_ks_dbcsr, matrix_ks_fm=scf_env%scf_work1(ispin), &
430 ortho_dbcsr=ortho_dbcsr, &
431 ksbuf1=scf_env%buf1_dbcsr, ksbuf2=scf_env%buf2_dbcsr)
435 cdiis_cholesky_method = scf_env%cholesky_method
440 ortho => scf_env%ortho_m1
442 ortho => scf_env%ortho
446 IF (.NOT.
ASSOCIATED(ortho))
THEN
454 matrix_s=matrix_s(ispin)%matrix, &
456 work=scf_env%scf_work2)
458 IF (do_level_shift)
THEN
459 CALL eigensolver(matrix_ks_fm=scf_env%scf_work1(ispin), &
462 work=scf_env%scf_work2, &
463 cholesky_method=cdiis_cholesky_method, &
464 do_level_shift=do_level_shift, &
465 level_shift=scf_control%level_shift, &
466 matrix_u_fm=scf_env%ortho, &
467 use_jacobi=use_jacobi)
469 CALL eigensolver(matrix_ks_fm=scf_env%scf_work1(ispin), &
472 work=scf_env%scf_work2, &
473 cholesky_method=cdiis_cholesky_method, &
474 do_level_shift=do_level_shift, &
475 level_shift=scf_control%level_shift, &
476 use_jacobi=use_jacobi)
482 scf_env%cholesky_method = cdiis_cholesky_method
485 IF (owns_ortho)
DEALLOCATE (ortho)
487 ortho => scf_env%ortho
490 IF (.NOT.
ASSOCIATED(ortho))
THEN
495 IF (do_level_shift)
THEN
497 IF (
ASSOCIATED(scf_env%scf_work1_red) .AND.
ASSOCIATED(scf_env%scf_work2_red) &
498 .AND.
ASSOCIATED(scf_env%ortho_red) .AND.
ASSOCIATED(scf_env%ortho_m1_red))
THEN
502 work=scf_env%scf_work2, &
503 do_level_shift=do_level_shift, &
504 level_shift=scf_control%level_shift, &
505 matrix_u_fm=scf_env%ortho_m1, &
506 use_jacobi=use_jacobi, &
507 jacobi_threshold=scf_control%diagonalization%jacobi_threshold, &
508 matrix_ks_fm_red=scf_env%scf_work1_red(ispin), &
509 ortho_red=scf_env%ortho_red, &
510 work_red=scf_env%scf_work2_red, &
511 matrix_u_fm_red=scf_env%ortho_m1_red)
516 work=scf_env%scf_work2, &
517 do_level_shift=do_level_shift, &
518 level_shift=scf_control%level_shift, &
519 matrix_u_fm=scf_env%ortho_m1, &
520 use_jacobi=use_jacobi, &
521 jacobi_threshold=scf_control%diagonalization%jacobi_threshold)
526 IF (
ASSOCIATED(scf_env%scf_work1_red) .AND.
ASSOCIATED(scf_env%scf_work2_red) &
527 .AND.
ASSOCIATED(scf_env%ortho_red))
THEN
531 work=scf_env%scf_work2, &
532 do_level_shift=do_level_shift, &
533 level_shift=scf_control%level_shift, &
534 use_jacobi=use_jacobi, &
535 jacobi_threshold=scf_control%diagonalization%jacobi_threshold, &
536 matrix_ks_fm_red=scf_env%scf_work1_red(ispin), &
537 ortho_red=scf_env%ortho_red, &
538 work_red=scf_env%scf_work2_red)
543 work=scf_env%scf_work2, &
544 do_level_shift=do_level_shift, &
545 level_shift=scf_control%level_shift, &
546 use_jacobi=use_jacobi, &
547 jacobi_threshold=scf_control%diagonalization%jacobi_threshold)
552 IF (owns_ortho)
DEALLOCATE (ortho)
569 matrix_s, scf_control, scf_section, &
573 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
574 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
577 LOGICAL,
INTENT(INOUT) :: diis_step
581 INTEGER :: ispin, nspin
582 REAL(kind=
dp) :: total_zeff_corr
584 nspin =
SIZE(matrix_ks)
587 matrix_s, scf_control, scf_section, diis_step)
589 total_zeff_corr = 0.0_dp
590 total_zeff_corr = scf_env%sum_zeff_corr
592 IF (abs(total_zeff_corr) > 0.0_dp)
THEN
594 smear=scf_control%smear, tot_zeff_corr=total_zeff_corr)
596 IF (
PRESENT(probe) .EQV. .true.)
THEN
597 scf_control%smear%do_smear = .false.
599 smear=scf_control%smear, &
602 IF (.NOT. scf_control%gce%do_gce)
THEN
604 smear=scf_control%smear)
607 smear=scf_control%smear, &
615 scf_env%p_mix_new(ispin, 1)%matrix)
644 diis_step, diis_error, qs_env, probe, matrix_t, &
645 store_ot_matrices, transfer_only, added_mos_auto_grow)
647 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks, matrix_s
651 LOGICAL,
INTENT(IN) :: update_p
652 LOGICAL,
INTENT(INOUT) :: diis_step
653 REAL(
dp),
INTENT(INOUT),
OPTIONAL :: diis_error
659 LOGICAL,
INTENT(IN),
OPTIONAL :: store_ot_matrices, transfer_only
660 LOGICAL,
INTENT(OUT),
OPTIONAL :: added_mos_auto_grow
662 CHARACTER(len=*),
PARAMETER :: routinen =
'do_general_diag_kp'
664 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: coeffs
665 INTEGER :: cdiis_ncall, handle, ib, ic, igroup, ik, ikp, indx, ispin, jb, kplocal, &
666 lattice_fft, nb, ninfo, nkp, nkp_groups, nspin, omp_threads, ot_components
667 INTEGER,
DIMENSION(2) :: kp_range
668 INTEGER,
DIMENSION(3) :: nkp_grid
669 INTEGER,
DIMENSION(:, :),
POINTER :: kp_dist
670 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
671 LOGICAL :: adiis_cdiis, cdiis_step, do_diis, my_added_mos_auto_grow, my_kpgrp, &
672 my_store_ot_kinetic, my_store_ot_matrices, my_transfer_only, spin_grid_fft, use_adiis, &
674 REAL(kind=
dp) :: diis_weight
675 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues
676 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
678 TYPE(
cp_cfm_type) :: cksmat, cmos, csmat, ctmat, cwork
681 TYPE(
cp_fm_type) :: fmdummy, fmlocal, rksmat, rsmat, rtmat
682 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: fmwork
684 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: adiis_ks, effective_ks
685 TYPE(
dbcsr_type),
POINTER :: cmatrix, rmatrix, tmpmat
696 CALL timeset(routinen, handle)
698 my_store_ot_matrices = .false.
699 IF (
PRESENT(store_ot_matrices)) my_store_ot_matrices = store_ot_matrices
700 my_transfer_only = .false.
701 IF (
PRESENT(transfer_only)) my_transfer_only = transfer_only
702 IF (my_transfer_only) my_store_ot_matrices = .true.
703 my_store_ot_kinetic =
PRESENT(matrix_t)
704 IF (my_store_ot_kinetic) my_store_ot_kinetic =
ASSOCIATED(matrix_t)
705 cpassert(.NOT. my_transfer_only .OR. .NOT. update_p)
706 cpassert(.NOT. my_store_ot_kinetic .OR. my_transfer_only)
707 my_added_mos_auto_grow = .false.
708 IF (
PRESENT(added_mos_auto_grow)) added_mos_auto_grow = .false.
710 NULLIFY (adiis_ks, effective_ks, sab_nl)
712 nkp_groups=nkp_groups, kp_dist=kp_dist, sab_nl=sab_nl, &
713 cell_to_index=cell_to_index, nkp_grid=nkp_grid, lattice_fft=lattice_fft)
714 cpassert(
ASSOCIATED(sab_nl))
715 kplocal = kp_range(2) - kp_range(1) + 1
721 cpassert(
ASSOCIATED(scf_env%scf_subspace_buffer))
723 adiis_cdiis = .false.
724 IF (use_adiis .AND.
ASSOCIATED(kpoints%scf_diis_buffer))
THEN
725 IF (scf_env%iter_count > 1 .AND. .NOT. scf_env%skip_diis .AND. &
726 .NOT. scf_env%adiis_check_next .AND. &
727 scf_env%scf_subspace_buffer%diis_state_valid .AND. &
728 scf_env%scf_subspace_buffer%nstored > 0 .AND. &
729 PRESENT(diis_error) .AND.
PRESENT(qs_env))
THEN
730 adiis_cdiis = scf_env%iter_delta < scf_control%eps_diis .OR. &
731 kpoints%scf_diis_buffer%ncall > 0
734 IF ((.NOT. use_adiis .AND. scf_env%iter_count > 1 .AND. .NOT. scf_env%skip_diis .AND. &
735 .NOT.
use_real_wfn .AND.
PRESENT(diis_error) .AND.
PRESENT(qs_env)) .OR. &
736 adiis_cdiis) do_diis = .true.
737 IF (my_transfer_only) do_diis = .false.
739 adiis_ks => matrix_ks
741 IF (scf_env%scf_subspace_buffer%use_combined_fock)
THEN
742 adiis_ks => scf_env%scf_subspace_buffer%combined_fock
745 effective_ks => matrix_ks
746 IF (use_adiis .AND. .NOT. adiis_cdiis)
THEN
747 effective_ks => adiis_ks
749 IF (use_adiis .AND. .NOT. do_diis)
THEN
750 scf_env%scf_subspace_buffer%diis_weight = 0.0_dp
751 IF (
ASSOCIATED(kpoints%scf_diis_buffer))
THEN
752 IF (kpoints%scf_diis_buffer%ncall > 0)
CALL qs_diis_b_clear_kp(kpoints%scf_diis_buffer)
756 para_env => kpoints%blacs_env_all%para_env
757 nspin =
SIZE(matrix_ks, 1)
761 use_omp_kpoints = para_env%num_pe == 1 .AND. omp_threads > 1 .AND. kplocal > 1 .AND. &
766 use_omp_kpoints = use_omp_kpoints .AND. adiis_cdiis
770 use_omp_kpoints = .false.
774 IF (use_omp_kpoints)
THEN
775 CALL do_general_diag_kp_omp(effective_ks, matrix_s, adiis_ks, kpoints, scf_env, scf_control, update_p, &
776 diis_step, do_diis, qs_env, diis_error, probe, sab_nl, &
778 CALL timestop(handle)
783 ALLOCATE (rmatrix, cmatrix, tmpmat)
784 CALL dbcsr_create(rmatrix, template=matrix_ks(1, 1)%matrix, &
785 matrix_type=dbcsr_type_symmetric)
786 CALL dbcsr_create(cmatrix, template=matrix_ks(1, 1)%matrix, &
787 matrix_type=dbcsr_type_antisymmetric)
788 CALL dbcsr_create(tmpmat, template=matrix_ks(1, 1)%matrix, &
789 matrix_type=dbcsr_type_no_symmetry)
793 fmwork => scf_env%scf_work1
797 nspin =
SIZE(matrix_ks, 1)
802 CALL mpools_get(mpools, ao_ao_fm_pools=ao_ao_fm_pools)
810 IF (my_store_ot_kinetic)
CALL cp_fm_create(rtmat, matrix_struct)
816 IF (my_store_ot_kinetic)
CALL cp_cfm_create(ctmat, matrix_struct)
818 kp => kpoints%kp_env(1)%kpoint_env
819 CALL get_mo_set(kp%mos(1, 1), mo_coeff=mo_coeff)
825 para_env => kpoints%blacs_env_all%para_env
830 ALLOCATE (ks_grid(nspin))
831 SELECT CASE (lattice_fft)
833 use_grid_fft = nkp >= 27
835 use_grid_fft = .true.
837 use_grid_fft = .false.
839 cpabort(
"Unknown lattice FFT selection mode")
841 IF (use_grid_fft)
THEN
843 cell_to_index, sab_nl, use_grid_fft, &
844 max_storage_bytes=512_int_8*1024_int_8**2/int(nspin + 1,
int_8))
846 IF (use_grid_fft)
THEN
849 cell_to_index, sab_nl, spin_grid_fft, &
850 max_storage_bytes=512_int_8*1024_int_8**2/int(nspin + 1,
int_8))
851 use_grid_fft = use_grid_fft .AND. spin_grid_fft
854 IF (.NOT. use_grid_fft)
THEN
861 IF (my_store_ot_matrices)
THEN
864 kp => kpoints%kp_env(ikp)%kpoint_env
867 ALLOCATE (kp%ot_hmat(ot_components, nspin), kp%ot_smat(ot_components))
868 DO ic = 1, ot_components
874 IF (my_store_ot_kinetic)
THEN
876 ALLOCATE (kp%ot_tmat(ot_components))
877 DO ic = 1, ot_components
887 IF (my_store_ot_kinetic) ninfo = 6
888 ALLOCATE (info(kplocal*nspin*nkp_groups, ninfo))
896 DO igroup = 1, nkp_groups
898 ik = kp_dist(1, igroup) + ikp - 1
899 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
902 IF (use_grid_fft)
THEN
906 CALL rskp_transform(rmatrix=rmatrix, rsmat=effective_ks, ispin=ispin, &
907 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
912 IF (use_grid_fft)
THEN
917 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
929 IF (my_store_ot_kinetic)
THEN
932 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
946 ks_grid(ispin), use_grid_fft, matrix_row=ispin)
949 IF (my_store_ot_kinetic)
THEN
960 cdiis_ncall = kpoints%scf_diis_buffer%ncall
966 DO igroup = 1, nkp_groups
968 ik = kp_dist(1, igroup) + ikp - 1
969 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
974 IF (my_store_ot_kinetic)
THEN
984 IF (my_store_ot_kinetic)
THEN
989 kp => kpoints%kp_env(ikp)%kpoint_env
991 ispin, ikp, kplocal, scf_section, real_wfn=
use_real_wfn)
996 ALLOCATE (coeffs(nb))
997 CALL qs_diis_b_step_kp(kpoints%scf_diis_buffer, coeffs, ib, nb, scf_env%iter_delta, diis_error, &
998 cdiis_step, scf_control%eps_diis, nspin, nkp, kplocal, &
999 merge(2, scf_control%nmixing, use_adiis), &
1000 scf_section, kpoints%para_env_inter_kp)
1001 diis_weight = 1.0_dp
1003 diis_weight = scf_env%scf_subspace_buffer%diis_weight
1004 IF (.NOT. ieee_is_finite(diis_error) .OR. diis_error >= scf_control%eps_diis)
THEN
1005 cdiis_step = .false.
1006 IF (cdiis_ncall < kpoints%scf_diis_buffer%nbuffer)
THEN
1008 kpoints%scf_diis_buffer%ncall = cdiis_ncall
1011 diis_weight = 0.0_dp
1014 IF (cdiis_step)
THEN
1016 diis_weight = min(1.0_dp, diis_weight + 0.5_dp)
1019 diis_weight = 0.0_dp
1021 scf_env%scf_subspace_buffer%diis_weight = diis_weight
1022 diis_step = cdiis_step .AND. diis_weight >= 1.0_dp
1023 IF (.NOT. diis_step) diis_error = scf_env%scf_subspace_buffer%last_old_fock_weight
1025 diis_step = cdiis_step
1032 IF (diis_weight < 1.0_dp)
THEN
1036 use_grid=.false., matrix_row=ispin)
1040 kp => kpoints%kp_env(ikp)%kpoint_env
1041 CALL cp_cfm_to_cfm(kpoints%scf_diis_buffer%smat(ikp), csmat)
1048 IF (diis_weight < 1.0_dp)
THEN
1050 cmplx(1.0_dp - diis_weight, kind=
dp), cwork)
1057 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=mo_coeff, eigenvalues=eigenvalues)
1060 scf_control%eps_eigval)
1062 CALL cp_fm_geeig(rksmat, rsmat, mo_coeff, eigenvalues, fmlocal)
1065 CALL get_mo_set(kp%mos(1, ispin), eigenvalues=eigenvalues)
1068 scf_control%eps_eigval)
1070 CALL cp_cfm_geeig(cksmat, csmat, cmos, eigenvalues, cwork)
1079 IF (.NOT. update_p .OR. use_adiis) diis_step = .false.
1084 DO igroup = 1, nkp_groups
1086 ik = kp_dist(1, igroup) + ikp - 1
1087 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
1092 IF (my_store_ot_kinetic)
THEN
1100 IF (my_store_ot_kinetic)
THEN
1107 kp => kpoints%kp_env(ikp)%kpoint_env
1109 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=mo_coeff, eigenvalues=eigenvalues)
1110 IF (my_store_ot_matrices)
THEN
1112 IF (ispin == 1)
CALL cp_fm_to_fm(rsmat, kp%ot_smat(1))
1113 IF (ispin == 1 .AND. my_store_ot_kinetic)
THEN
1117 IF (.NOT. my_transfer_only)
THEN
1120 scf_control%eps_eigval)
1122 CALL cp_fm_geeig(rksmat, rsmat, mo_coeff, eigenvalues, fmlocal)
1126 CALL get_mo_set(kp%mos(1, ispin), eigenvalues=eigenvalues)
1127 IF (my_store_ot_matrices)
THEN
1128 CALL cp_cfm_to_fm(cksmat, kp%ot_hmat(1, ispin), kp%ot_hmat(2, ispin))
1129 IF (ispin == 1)
THEN
1131 IF (my_store_ot_kinetic)
THEN
1136 IF (.NOT. my_transfer_only)
THEN
1139 scf_control%eps_eigval)
1141 CALL cp_cfm_geeig(cksmat, csmat, cmos, eigenvalues, cwork)
1158 DO igroup = 1, nkp_groups
1160 ik = kp_dist(1, igroup) + ikp - 1
1161 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
1165 IF (my_store_ot_kinetic)
THEN
1176 IF (
ALLOCATED(info))
DEALLOCATE (info)
1178 IF (update_p .AND. .NOT. my_transfer_only)
THEN
1180 IF (
PRESENT(probe) .EQV. .true.)
THEN
1181 scf_control%smear%do_smear = .false.
1186 added_mos_auto=scf_control%added_mos_auto, &
1187 added_mos_auto_grow=my_added_mos_auto_grow)
1189 IF (my_added_mos_auto_grow)
THEN
1190 IF (
PRESENT(added_mos_auto_grow)) added_mos_auto_grow = .true.
1196 matrix_s(1, 1)%matrix, sab_nl, fmwork, overlap_rs=matrix_s)
1207 DEALLOCATE (ks_grid)
1225 CALL timestop(handle)
1250 SUBROUTINE do_general_diag_kp_omp(matrix_ks, matrix_s, adiis_ks, kpoints, scf_env, scf_control, update_p, &
1251 diis_step, do_diis, qs_env, diis_error, probe, sab_nl, &
1254 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks, matrix_s, adiis_ks
1258 LOGICAL,
INTENT(IN) :: update_p
1259 LOGICAL,
INTENT(INOUT) :: diis_step
1260 LOGICAL,
INTENT(IN) :: do_diis
1262 REAL(
dp),
INTENT(INOUT),
OPTIONAL :: diis_error
1267 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1268 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1270 CHARACTER(len=*),
PARAMETER :: routinen =
'do_general_diag_kp_omp'
1272 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: coeffs
1273 INTEGER :: cdiis_ncall, handle, ib, ikp, kplocal, &
1274 nb, nspin, nworkers, thread
1275 LOGICAL :: cdiis_step, use_adiis
1276 REAL(kind=
dp) :: diis_weight
1279 TYPE(kp_diag_omp_workspace_type),
ALLOCATABLE, &
1280 DIMENSION(:) :: workspace
1285 CALL timeset(routinen, handle)
1286 NULLIFY (matrix_struct, mo_struct, mo_coeff, kp, scf_section)
1288 kplocal =
SIZE(xkp, 2)
1289 nspin =
SIZE(matrix_ks, 1)
1290 use_adiis = update_p .AND. &
1294 CALL cp_fm_get_info(scf_env%scf_work1(1), matrix_struct=matrix_struct)
1295 kp => kpoints%kp_env(1)%kpoint_env
1296 CALL get_mo_set(kp%mos(1, 1), mo_coeff=mo_coeff)
1298 CALL kp_diag_omp_workspaces_create(workspace, nworkers, matrix_struct, mo_struct)
1300 matrix_ks(1, 1)%matrix)
1304 cdiis_ncall = kpoints%scf_diis_buffer%ncall
1315 CALL kp_diis_error_job_local(ikp, workspace(thread), matrix_ks, matrix_s, kpoints, &
1316 ib, transform_plan, xkp, nspin)
1320 ALLOCATE (coeffs(nb))
1321 CALL qs_diis_b_step_kp(kpoints%scf_diis_buffer, coeffs, ib, nb, scf_env%iter_delta, diis_error, &
1322 cdiis_step, scf_control%eps_diis, nspin, kplocal, kplocal, &
1323 merge(2, scf_control%nmixing, use_adiis), &
1324 scf_section, kpoints%para_env_inter_kp)
1325 diis_weight = 1.0_dp
1327 diis_weight = scf_env%scf_subspace_buffer%diis_weight
1328 IF (.NOT. ieee_is_finite(diis_error) .OR. diis_error >= scf_control%eps_diis)
THEN
1329 cdiis_step = .false.
1330 IF (cdiis_ncall < kpoints%scf_diis_buffer%nbuffer)
THEN
1331 kpoints%scf_diis_buffer%ncall = cdiis_ncall
1334 diis_weight = 0.0_dp
1337 IF (cdiis_step)
THEN
1338 diis_weight = min(1.0_dp, diis_weight + 0.5_dp)
1341 diis_weight = 0.0_dp
1343 scf_env%scf_subspace_buffer%diis_weight = diis_weight
1344 diis_step = cdiis_step .AND. diis_weight >= 1.0_dp
1345 IF (.NOT. diis_step) diis_error = scf_env%scf_subspace_buffer%last_old_fock_weight
1347 diis_step = cdiis_step
1356 CALL kp_diis_diag_job(ikp, workspace(thread), kpoints, coeffs, nb, scf_env, &
1357 scf_control, nspin, adiis_ks, transform_plan, xkp, &
1358 use_adiis, diis_weight)
1370 CALL kp_diag_job(ikp, workspace(thread), matrix_ks, matrix_s, kpoints, scf_env, scf_control, &
1371 transform_plan, xkp, nspin)
1377 IF (
PRESENT(probe))
THEN
1378 scf_control%smear%do_smear = .false.
1385 matrix_s(1, 1)%matrix, sab_nl, scf_env%scf_work1, &
1386 overlap_rs=matrix_s)
1390 CALL kp_diag_omp_workspaces_release(workspace)
1391 CALL timestop(handle)
1393 END SUBROUTINE do_general_diag_kp_omp
1402 SUBROUTINE kp_diag_omp_workspaces_create(workspace, nworkers, matrix_struct, mo_struct)
1404 TYPE(kp_diag_omp_workspace_type),
ALLOCATABLE, &
1405 DIMENSION(:),
INTENT(OUT) :: workspace
1406 INTEGER,
INTENT(IN) :: nworkers
1411 ALLOCATE (workspace(nworkers))
1420 END SUBROUTINE kp_diag_omp_workspaces_create
1426 SUBROUTINE kp_diag_omp_workspaces_release(workspace)
1428 TYPE(kp_diag_omp_workspace_type),
ALLOCATABLE, &
1429 DIMENSION(:),
INTENT(INOUT) :: workspace
1433 DO i = 1,
SIZE(workspace)
1440 DEALLOCATE (workspace)
1442 END SUBROUTINE kp_diag_omp_workspaces_release
1453 SUBROUTINE kp_build_cfm(source, ispin, xkp, plan, TARGET)
1456 INTEGER,
INTENT(IN) :: ispin
1457 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: xkp
1461 COMPLEX(KIND=dp) :: phase
1462 COMPLEX(KIND=dp),
DIMENSION(:, :),
POINTER :: full
1463 INTEGER :: col_offset, i, row_offset
1465 REAL(kind=
dp) :: arg
1466 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: block
1468 full =>
target%local_data
1470 DO i = 1, plan%nentry
1472 plan%row(i), plan%col(i), block, found)
1473 IF (.NOT. found) cycle
1474 row_offset = plan%row_offset(i)
1475 col_offset = plan%col_offset(i)
1476 arg = dot_product(real(plan%cell(:, i), kind=
dp), xkp)
1477 phase = cmplx(cos(
twopi*arg), plan%symmetry_sign(i)*sin(
twopi*arg), kind=
dp)
1478 full(row_offset:row_offset +
SIZE(block, 1) - 1, &
1479 col_offset:col_offset +
SIZE(block, 2) - 1) = &
1480 full(row_offset:row_offset +
SIZE(block, 1) - 1, &
1481 col_offset:col_offset +
SIZE(block, 2) - 1) + phase*block
1482 IF (plan%symmetric .AND. plan%row(i) /= plan%col(i))
THEN
1483 full(col_offset:col_offset +
SIZE(block, 2) - 1, &
1484 row_offset:row_offset +
SIZE(block, 1) - 1) = &
1485 full(col_offset:col_offset +
SIZE(block, 2) - 1, &
1486 row_offset:row_offset +
SIZE(block, 1) - 1) + conjg(phase)*transpose(block)
1490 END SUBROUTINE kp_build_cfm
1505 SUBROUTINE kp_diag_job(ikp, workspace, matrix_ks, matrix_s, kpoints, scf_env, scf_control, &
1506 transform_plan, xkp, nspin)
1508 INTEGER,
INTENT(IN) :: ikp
1509 TYPE(kp_diag_omp_workspace_type),
INTENT(INOUT) :: workspace
1510 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks, matrix_s
1515 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1516 INTEGER,
INTENT(IN) :: nspin
1519 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues
1523 kp => kpoints%kp_env(ikp)%kpoint_env
1524 CALL kp_build_cfm(matrix_s, 1, xkp(1:3, ikp), transform_plan, workspace%csmat_base)
1526 CALL kp_build_cfm(matrix_ks, ispin, xkp(1:3, ikp), transform_plan, workspace%cksmat)
1528 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos, eigenvalues=eigenvalues)
1529 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
1532 eigenvalues, workspace%cwork, scf_control%eps_eigval)
1534 CALL cp_cfm_geeig_local(workspace%cksmat, workspace%csmat, workspace%cmos, eigenvalues)
1536 kp%mos(2, ispin)%eigenvalues = eigenvalues
1540 END SUBROUTINE kp_diag_job
1556 SUBROUTINE kp_diis_error_job_local(ikp, workspace, matrix_ks, matrix_s, kpoints, ib, &
1557 transform_plan, xkp, nspin)
1559 INTEGER,
INTENT(IN) :: ikp
1560 TYPE(kp_diag_omp_workspace_type),
INTENT(INOUT) :: workspace
1561 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks, matrix_s
1563 INTEGER,
INTENT(IN) :: ib
1565 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1566 INTEGER,
INTENT(IN) :: nspin
1571 kp => kpoints%kp_env(ikp)%kpoint_env
1572 CALL kp_build_cfm(matrix_s, 1, xkp(1:3, ikp), transform_plan, &
1573 workspace%csmat_base)
1575 CALL kp_build_cfm(matrix_ks, ispin, xkp(1:3, ikp), transform_plan, &
1578 CALL kp_diis_calc_err_local(kpoints, kp, workspace, ib, ispin, ikp)
1581 END SUBROUTINE kp_diis_error_job_local
1592 SUBROUTINE kp_diis_calc_err_local(kpoints, kp, workspace, ib, ispin, ikp)
1596 TYPE(kp_diag_omp_workspace_type),
INTENT(INOUT) :: workspace
1597 INTEGER,
INTENT(IN) :: ib, ispin, ikp
1599 COMPLEX(KIND=dp),
DIMENSION(:, :),
POINTER :: c, error, h, kc, s, sc
1600 INTEGER :: homo, nao, nmo
1601 REAL(kind=
dp) :: maxocc
1602 REAL(kind=
dp),
CONTIGUOUS,
DIMENSION(:, :), &
1606 CALL get_mo_set(kp%mos(1, ispin), nao=nao, nmo=nmo, homo=homo, &
1607 mo_coeff=rmos, maxocc=maxocc)
1608 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
1612 c => workspace%cmos%local_data
1613 c(1:nao, 1:nmo) = cmplx(cr(1:nao, 1:nmo), ci(1:nao, 1:nmo), kind=
dp)
1615 h => kpoints%scf_diis_buffer%param(ib, ispin, ikp)%local_data
1616 s => kpoints%scf_diis_buffer%smat(ikp)%local_data
1617 h(:, :) = workspace%cksmat%local_data(:, :)
1618 s(:, :) = workspace%csmat%local_data(:, :)
1620 kc => workspace%cksmat%local_data
1621 sc => workspace%csmat%local_data
1622 CALL zgemm(
'N',
'N', nao, homo, nao, cmplx(maxocc, 0.0_dp, kind=
dp), &
1623 h(1, 1),
SIZE(h, 1), c(1, 1),
SIZE(c, 1),
z_zero, kc(1, 1),
SIZE(kc, 1))
1624 CALL zgemm(
'N',
'N', nao, homo, nao, cmplx(2.0_dp, 0.0_dp, kind=
dp), &
1625 s(1, 1),
SIZE(s, 1), c(1, 1),
SIZE(c, 1),
z_zero, sc(1, 1),
SIZE(sc, 1))
1627 error => kpoints%scf_diis_buffer%error(ib, ispin, ikp)%local_data
1628 CALL zgemm(
'N',
'T', nao, nao, homo,
z_one, sc(1, 1),
SIZE(sc, 1), &
1629 kc(1, 1),
SIZE(kc, 1),
z_zero, error(1, 1),
SIZE(error, 1))
1630 CALL zgemm(
'N',
'T', nao, nao, homo,
z_one, kc(1, 1),
SIZE(kc, 1), &
1631 sc(1, 1),
SIZE(sc, 1), -
z_one, error(1, 1),
SIZE(error, 1))
1633 END SUBROUTINE kp_diis_calc_err_local
1651 SUBROUTINE kp_diis_diag_job(ikp, workspace, kpoints, coeffs, nb, scf_env, scf_control, nspin, &
1652 adiis_ks, transform_plan, xkp, use_adiis, diis_weight)
1654 INTEGER,
INTENT(IN) :: ikp
1655 TYPE(kp_diag_omp_workspace_type),
INTENT(INOUT) :: workspace
1657 COMPLEX(KIND=dp),
DIMENSION(:),
INTENT(IN) :: coeffs
1658 INTEGER,
INTENT(IN) :: nb
1661 INTEGER,
INTENT(IN) :: nspin
1662 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: adiis_ks
1664 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1665 LOGICAL,
INTENT(IN) :: use_adiis
1666 REAL(kind=
dp),
INTENT(IN) :: diis_weight
1668 INTEGER :: ispin, jb
1669 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues
1673 kp => kpoints%kp_env(ikp)%kpoint_env
1675 CALL cp_cfm_to_cfm(kpoints%scf_diis_buffer%smat(ikp), workspace%csmat)
1679 kpoints%scf_diis_buffer%param(jb, ispin, ikp))
1681 IF (use_adiis .AND. diis_weight < 1.0_dp)
THEN
1682 CALL kp_build_cfm(adiis_ks, ispin, xkp(1:3, ikp), transform_plan, workspace%csmat_base)
1683 workspace%cksmat%local_data(:, :) = &
1684 diis_weight*workspace%cksmat%local_data(:, :) + &
1685 (1.0_dp - diis_weight)*workspace%csmat_base%local_data(:, :)
1687 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos, eigenvalues=eigenvalues)
1688 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
1691 eigenvalues, workspace%cwork, scf_control%eps_eigval)
1693 CALL cp_cfm_geeig_local(workspace%cksmat, workspace%csmat, workspace%cmos, eigenvalues)
1695 kp%mos(2, ispin)%eigenvalues = eigenvalues
1699 END SUBROUTINE kp_diis_diag_job
1716 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks, matrix_s
1718 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: fmwork
1720 CHARACTER(len=*),
PARAMETER :: routinen =
'diag_kp_basic'
1722 INTEGER :: handle, igroup, ik, ikp, indx, ispin, &
1723 kplocal, nkp, nkp_groups, nspin
1724 INTEGER,
DIMENSION(2) :: kp_range
1725 INTEGER,
DIMENSION(:, :),
POINTER :: kp_dist
1726 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1728 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues
1729 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1734 TYPE(
cp_fm_type) :: fmdummy, fmlocal, rksmat, rsmat
1736 TYPE(
dbcsr_type),
POINTER :: cmatrix, rmatrix, tempmat, tmpmat
1744 CALL timeset(routinen, handle)
1748 nkp_groups=nkp_groups, kp_dist=kp_dist, sab_nl=sab_nl, &
1749 cell_to_index=cell_to_index)
1750 cpassert(
ASSOCIATED(sab_nl))
1751 kplocal = kp_range(2) - kp_range(1) + 1
1754 tempmat => matrix_ks(1, 1)%matrix
1757 ALLOCATE (rmatrix, cmatrix, tmpmat)
1758 CALL dbcsr_create(rmatrix, template=tempmat, matrix_type=dbcsr_type_symmetric)
1759 CALL dbcsr_create(cmatrix, template=tempmat, matrix_type=dbcsr_type_antisymmetric)
1760 CALL dbcsr_create(tmpmat, template=tempmat, matrix_type=dbcsr_type_no_symmetry)
1766 CALL mpools_get(mpools, ao_ao_fm_pools=ao_ao_fm_pools)
1778 kp => kpoints%kp_env(1)%kpoint_env
1779 CALL get_mo_set(kp%mos(1, 1), mo_coeff=mo_coeff)
1784 para_env => kpoints%blacs_env_all%para_env
1785 nspin =
SIZE(matrix_ks, 1)
1788 IF (
use_real_wfn)
ALLOCATE (info(kplocal*nspin*nkp_groups, 2))
1795 DO igroup = 1, nkp_groups
1797 ik = kp_dist(1, igroup) + ikp - 1
1798 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
1802 CALL rskp_transform(rmatrix=rmatrix, rsmat=matrix_ks, ispin=ispin, &
1803 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
1809 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
1825 use_grid=.false., matrix_row=ispin)
1837 DO igroup = 1, nkp_groups
1839 ik = kp_dist(1, igroup) + ikp - 1
1840 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
1854 kp => kpoints%kp_env(ikp)%kpoint_env
1856 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=mo_coeff, eigenvalues=eigenvalues)
1857 CALL cp_fm_geeig(rksmat, rsmat, mo_coeff, eigenvalues, fmlocal)
1859 CALL get_mo_set(kp%mos(1, ispin), eigenvalues=eigenvalues)
1860 CALL cp_cfm_geeig(cksmat, csmat, cmos, eigenvalues, cwork)
1874 DO igroup = 1, nkp_groups
1876 ik = kp_dist(1, igroup) + ikp - 1
1877 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
1889 IF (
ALLOCATED(info))
DEALLOCATE (info)
1906 CALL timestop(handle)
1926 ks_env, scf_section, scf_control)
1931 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
1937 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_scf_diag_subspace'
1938 REAL(kind=
dp),
PARAMETER :: rone = 1.0_dp, rzero = 0.0_dp
1940 INTEGER :: handle, i, iloop, ispin, nao, nmo, &
1942 LOGICAL :: converged
1943 REAL(
dp) :: ene_diff, ene_old, iter_delta, max_val, &
1944 sum_band, sum_val, t1, t2
1945 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues, mo_occupations
1946 TYPE(
cp_1d_r_p_type),
ALLOCATABLE,
DIMENSION(:) :: eval_first, occ_first
1948 TYPE(
cp_fm_type),
POINTER :: c0, chc, evec, mo_coeff
1950 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s, rho_ao
1951 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_kp
1957 CALL timeset(routinen, handle)
1958 NULLIFY (c0, chc, energy, evec, matrix_ks, mo_coeff, mo_eigenvalues, &
1959 mo_occupations, dft_control, rho_ao, rho_ao_kp)
1963 extension=
".scfLog")
1967 CALL qs_rho_get(rho, rho_ao=rho_ao, rho_ao_kp=rho_ao_kp)
1969 ALLOCATE (eval_first(nspin))
1970 ALLOCATE (occ_first(nspin))
1974 eigenvalues=mo_eigenvalues, &
1975 occupation_numbers=mo_occupations)
1976 ALLOCATE (eval_first(ispin)%array(nmo))
1977 ALLOCATE (occ_first(ispin)%array(nmo))
1978 eval_first(ispin)%array(1:nmo) = mo_eigenvalues(1:nmo)
1979 occ_first(ispin)%array(1:nmo) = mo_occupations(1:nmo)
1984 CALL dbcsr_copy(subspace_env%p_matrix_store(ispin)%matrix, rho_ao(ispin)%matrix)
1985 CALL dbcsr_copy(rho_ao(ispin)%matrix, scf_env%p_mix_new(ispin, 1)%matrix)
1988 subspace_env%p_matrix_mix => scf_env%p_mix_new
1990 NULLIFY (matrix_ks, energy, para_env, matrix_s)
1992 matrix_ks=matrix_ks, &
1994 matrix_s=matrix_s, &
1995 para_env=para_env, &
1996 dft_control=dft_control)
2000 CALL mixing_allocate(qs_env, subspace_env%mixing_method, scf_env%p_mix_new, &
2001 scf_env%p_delta, nspin, subspace_env%mixing_store)
2002 IF (dft_control%qs_control%gapw)
THEN
2003 CALL get_qs_env(qs_env=qs_env, rho_atom_set=rho_atom)
2004 CALL mixing_init(subspace_env%mixing_method, rho, subspace_env%mixing_store, &
2005 para_env, rho_atom=rho_atom)
2006 ELSE IF (dft_control%qs_control%dftb .OR. dft_control%qs_control%xtb)
THEN
2008 ELSE IF (dft_control%qs_control%semi_empirical)
THEN
2009 cpabort(
'SE Code not possible')
2011 CALL mixing_init(subspace_env%mixing_method, rho, subspace_env%mixing_store, para_env)
2017 IF (output_unit > 0)
THEN
2018 WRITE (output_unit,
"(/T19,A)")
'<<<<<<<<< SUBSPACE ROTATION <<<<<<<<<<'
2019 WRITE (output_unit,
"(T4,A,T13,A,T21,A,T38,A,T51,A,T65,A/,T4,A)") &
2020 "In-step",
"Time",
"Convergence",
"Band ene.",
"Total ene.",
"Energy diff.", repeat(
"-", 74)
2028 DO iloop = 1, subspace_env%max_iter
2031 ene_old = energy%total
2035 just_energy=.false., print_active=.false.)
2040 DO ispin = 1,
SIZE(matrix_ks)
2044 eigenvalues=mo_eigenvalues, &
2045 occupation_numbers=mo_occupations, &
2049 chc => subspace_env%chc_mat(ispin)
2050 evec => subspace_env%c_vec(ispin)
2051 c0 => subspace_env%c0(ispin)
2055 CALL parallel_gemm(
'T',
'N', nmo, nmo, nao, rone, c0, work, rzero, chc)
2061 CALL parallel_gemm(
'N',
'N', nao, nmo, nmo, rone, c0, evec, rzero, mo_coeff)
2063 IF (.NOT. scf_control%gce%do_gce)
THEN
2065 smear=scf_control%smear)
2068 smear=scf_control%smear, &
2069 gce=scf_control%gce)
2074 subspace_env%p_matrix_mix(ispin, 1)%matrix)
2077 sum_band = sum_band + mo_eigenvalues(i)*mo_occupations(i)
2085 scf_env%mixing_store, rho_ao_kp, para_env, iter_delta, iloop)
2088 subspace_env%p_matrix_mix, delta=iter_delta)
2093 CALL dbcsr_copy(rho_ao(ispin)%matrix, subspace_env%p_matrix_mix(ispin, 1)%matrix)
2099 CALL gspace_mixing(qs_env, scf_env%mixing_method, subspace_env%mixing_store, &
2100 rho, para_env, scf_env%iter_count)
2103 ene_diff = energy%total - ene_old
2104 converged = (abs(ene_diff) < subspace_env%eps_ene .AND. &
2105 iter_delta < subspace_env%eps_adapt*scf_env%iter_delta)
2107 IF (output_unit > 0)
THEN
2108 WRITE (output_unit,
"(T4,I5,T11,F8.3,T18,E14.4,T34,F12.5,T46,F16.8,T62,E14.4)") &
2109 iloop, t2 - t1, iter_delta, sum_band, energy%total, ene_diff
2113 IF (output_unit > 0)
WRITE (output_unit,
"(T10,A,I6,A,/)") &
2114 " Reached convergence in ", iloop,
" iterations "
2120 NULLIFY (subspace_env%p_matrix_mix)
2123 CALL dbcsr_copy(scf_env%p_mix_new(ispin, 1)%matrix, rho_ao(ispin)%matrix)
2124 CALL dbcsr_copy(rho_ao(ispin)%matrix, subspace_env%p_matrix_store(ispin)%matrix)
2126 DEALLOCATE (eval_first(ispin)%array, occ_first(ispin)%array)
2128 DEALLOCATE (eval_first, occ_first)
2130 CALL timestop(handle)
2144 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(IN) :: mos
2146 CHARACTER(LEN=*),
PARAMETER :: routinen =
'diag_subspace_allocate'
2148 INTEGER :: handle, i, ispin, nmo, nspin
2155 CALL timeset(routinen, handle)
2157 NULLIFY (sab_orb, matrix_s)
2158 CALL get_qs_env(qs_env=qs_env, sab_orb=sab_orb, &
2163 IF (.NOT.
ASSOCIATED(subspace_env%p_matrix_store))
THEN
2167 ALLOCATE (subspace_env%p_matrix_store(i)%matrix)
2168 CALL dbcsr_create(matrix=subspace_env%p_matrix_store(i)%matrix, template=matrix_s(1)%matrix, &
2169 name=
"DENSITY_STORE", matrix_type=dbcsr_type_symmetric)
2172 CALL dbcsr_set(subspace_env%p_matrix_store(i)%matrix, 0.0_dp)
2177 ALLOCATE (subspace_env%chc_mat(nspin))
2178 ALLOCATE (subspace_env%c_vec(nspin))
2179 ALLOCATE (subspace_env%c0(nspin))
2182 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
2183 CALL cp_fm_create(subspace_env%c0(ispin), mo_coeff%matrix_struct)
2184 NULLIFY (fm_struct_tmp)
2186 para_env=mo_coeff%matrix_struct%para_env, &
2187 context=mo_coeff%matrix_struct%context)
2188 CALL cp_fm_create(subspace_env%chc_mat(ispin), fm_struct_tmp,
"chc")
2189 CALL cp_fm_create(subspace_env%c_vec(ispin), fm_struct_tmp,
"vec")
2193 CALL timestop(handle)
2210 scf_section, diis_step)
2213 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
2217 LOGICAL,
INTENT(INOUT) :: diis_step
2219 INTEGER :: ispin, nspin
2220 LOGICAL :: do_level_shift, use_jacobi
2221 REAL(kind=
dp) :: diis_error
2223 nspin =
SIZE(matrix_ks)
2228 IF (scf_env%iter_count > 1 .AND. .NOT. scf_env%skip_diis)
THEN
2229 CALL qs_diis_b_step(scf_env%scf_diis_buffer, mos, scf_env%scf_work1, &
2230 scf_env%scf_work2, scf_env%iter_delta, diis_error, diis_step, &
2231 scf_control%eps_diis, scf_control%nmixing, &
2232 scf_section=scf_section)
2237 IF ((scf_env%iter_count > 1) .AND. (scf_env%iter_delta < scf_control%diagonalization%eps_jacobi))
THEN
2240 use_jacobi = .false.
2243 do_level_shift = ((scf_control%level_shift /= 0.0_dp) .AND. &
2244 ((scf_control%density_guess ==
core_guess) .OR. (scf_env%iter_count > 1)))
2246 scf_env%iter_param = diis_error
2247 IF (use_jacobi)
THEN
2248 scf_env%iter_method =
"DIIS/Jacobi"
2250 scf_env%iter_method =
"DIIS/Diag."
2253 IF (scf_env%mixing_method == 1)
THEN
2254 scf_env%iter_param = scf_env%p_mix_alpha
2255 IF (use_jacobi)
THEN
2256 scf_env%iter_method =
"P_Mix/Jacobi"
2258 scf_env%iter_method =
"P_Mix/Diag."
2260 ELSE IF (scf_env%mixing_method > 1)
THEN
2261 scf_env%iter_param = scf_env%mixing_store%alpha
2262 IF (use_jacobi)
THEN
2263 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Jacobi"
2265 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Diag."
2269 scf_env%iter_delta = 0.0_dp
2273 mo_set=mos(ispin), &
2274 work=scf_env%scf_work2, &
2275 do_level_shift=do_level_shift, &
2276 level_shift=scf_control%level_shift, &
2277 use_jacobi=use_jacobi, &
2278 jacobi_threshold=scf_control%diagonalization%jacobi_threshold)
2281 IF (.NOT. scf_control%gce%do_gce)
THEN
2283 smear=scf_control%smear)
2286 smear=scf_control%smear, &
2287 gce=scf_control%gce)
2293 scf_env%p_mix_new(ispin, 1)%matrix)
2312 scf_control, scf_section, diis_step)
2315 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
2316 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
2319 LOGICAL,
INTENT(INOUT) :: diis_step
2321 INTEGER :: homo, ispin, nmo, nspin
2322 REAL(kind=
dp) :: diis_error, eps_iter
2323 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues
2326 NULLIFY (eigenvalues)
2328 nspin =
SIZE(matrix_ks)
2332 scf_env%scf_work1(ispin))
2335 IF ((scf_env%iter_count > 1) .AND. (.NOT. scf_env%skip_diis))
THEN
2336 CALL qs_diis_b_step(scf_env%scf_diis_buffer, mos, scf_env%scf_work1, &
2337 scf_env%scf_work2, scf_env%iter_delta, diis_error, diis_step, &
2338 scf_control%eps_diis, scf_control%nmixing, &
2339 s_matrix=matrix_s, &
2340 scf_section=scf_section)
2345 eps_iter = scf_control%diagonalization%eps_iter
2347 scf_env%iter_param = diis_error
2348 scf_env%iter_method =
"DIIS/OTdiag"
2351 matrix_ks(ispin)%matrix, keep_sparsity=.true.)
2353 eps_iter = max(eps_iter, scf_control%diagonalization%eps_adapt*diis_error)
2355 IF (scf_env%mixing_method == 1)
THEN
2356 scf_env%iter_param = scf_env%p_mix_alpha
2357 scf_env%iter_method =
"P_Mix/OTdiag."
2358 ELSE IF (scf_env%mixing_method > 1)
THEN
2359 scf_env%iter_param = scf_env%mixing_store%alpha
2360 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/OTdiag."
2364 scf_env%iter_delta = 0.0_dp
2368 mo_coeff=mo_coeff, &
2369 eigenvalues=eigenvalues, &
2373 matrix_s=matrix_s(1)%matrix, &
2374 matrix_c_fm=mo_coeff, &
2376 min(ispin,
SIZE(scf_env%ot_preconditioner)))%preconditioner, &
2377 eps_gradient=eps_iter, &
2378 iter_max=scf_control%diagonalization%max_iter, &
2380 ot_settings=scf_control%diagonalization%ot_settings)
2382 evals_arg=eigenvalues, &
2385 mos(ispin)%mo_coeff_b)
2390 smear=scf_control%smear)
2395 scf_env%p_mix_new(ispin, 1)%matrix)
2411 SUBROUTINE do_ot_diag_kp(matrix_ks, matrix_s, matrix_t, kpoints, scf_env, scf_control, &
2412 diis_step, added_mos_auto_grow)
2413 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks, matrix_s, matrix_t
2417 LOGICAL,
INTENT(INOUT) :: diis_step
2418 LOGICAL,
INTENT(OUT) :: added_mos_auto_grow
2420 INTEGER :: ikp, ispin, ks_spin, nspin
2422 REAL(kind=
dp) :: eps_iter
2423 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues
2425 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: fmwork
2426 TYPE(
cp_fm_type),
POINTER :: coeff_im, coeff_re
2427 TYPE(
dbcsr_type),
POINTER :: matrix_h_im, matrix_h_re, matrix_s_im, &
2428 matrix_s_re, matrix_t_im, matrix_t_re
2433 NULLIFY (coeff_im, coeff_re, eigenvalues, fmwork, kp, matrix_h_im, matrix_h_re, &
2434 matrix_s_im, matrix_s_re, matrix_t_im, matrix_t_re, sab_nl)
2435 added_mos_auto_grow = .false.
2437 eps_iter = scf_control%diagonalization%eps_iter
2438 nspin =
SIZE(matrix_ks, 1)
2439 store_kinetic = scf_control%diagonalization%ot_settings%preconditioner_type == &
2441 IF (store_kinetic)
THEN
2442 cpassert(
ASSOCIATED(matrix_t))
2445 cpassert(
ASSOCIATED(sab_nl))
2449 IF (scf_env%iter_count <= 1)
THEN
2453 IF (store_kinetic)
THEN
2455 .false., diis_step, matrix_t=matrix_t, &
2456 store_ot_matrices=.true., transfer_only=.true.)
2459 .false., diis_step, store_ot_matrices=.true., transfer_only=.true.)
2462 scf_env%iter_delta = 0.0_dp
2463 DO ikp = 1,
SIZE(kpoints%kp_env)
2464 kp => kpoints%kp_env(ikp)%kpoint_env
2465 cpassert(
ASSOCIATED(kp%ot_hmat) .AND.
ASSOCIATED(kp%ot_smat))
2466 IF (
SIZE(kp%ot_smat) >= 2)
THEN
2468 kp%ot_smat(1), kp%ot_smat(2), &
2469 matrix_s_re, matrix_s_im)
2472 kp%ot_smat(1), kp%ot_smat(1), &
2473 matrix_s_re, matrix_s_im)
2476 IF (store_kinetic)
THEN
2477 cpassert(
ASSOCIATED(kp%ot_tmat))
2478 IF (
SIZE(kp%ot_tmat) >= 2)
THEN
2480 kp%ot_tmat(1), kp%ot_tmat(2), &
2481 matrix_t_re, matrix_t_im)
2484 kp%ot_tmat(1), kp%ot_tmat(1), &
2485 matrix_t_re, matrix_t_im)
2490 ks_spin = min(ispin,
SIZE(kp%ot_hmat, 2))
2491 IF (
SIZE(kp%ot_hmat, 1) >= 2)
THEN
2493 kp%ot_hmat(1, ks_spin), kp%ot_hmat(2, ks_spin), &
2494 matrix_h_re, matrix_h_im)
2497 kp%ot_hmat(1, ks_spin), kp%ot_hmat(1, ks_spin), &
2498 matrix_h_re, matrix_h_im)
2501 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=coeff_re, eigenvalues=eigenvalues)
2503 CALL cp_fm_create(coeff_im_work, coeff_re%matrix_struct, &
2504 name=
'real k-point OT imaginary work')
2507 matrix_s=matrix_s_re, matrix_s_im=matrix_s_im, &
2508 matrix_c_fm=coeff_re, matrix_c_fm_im=coeff_im_work, &
2509 eps_gradient=eps_iter, &
2510 iter_max=scf_control%diagonalization%max_iter, &
2511 eigenvalues=eigenvalues, silent=.true., &
2512 ot_settings=scf_control%diagonalization%ot_settings, &
2513 matrix_t=matrix_t_re, matrix_t_im=matrix_t_im, &
2514 mo_set=kp%mos(1, ispin))
2517 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=coeff_im)
2519 matrix_s=matrix_s_re, matrix_s_im=matrix_s_im, &
2520 matrix_c_fm=coeff_re, matrix_c_fm_im=coeff_im, &
2521 eps_gradient=eps_iter, &
2522 iter_max=scf_control%diagonalization%max_iter, &
2523 eigenvalues=eigenvalues, silent=.true., &
2524 ot_settings=scf_control%diagonalization%ot_settings, &
2525 matrix_t=matrix_t_re, matrix_t_im=matrix_t_im, &
2526 mo_set=kp%mos(1, ispin))
2527 kp%mos(2, ispin)%eigenvalues = eigenvalues
2539 added_mos_auto=scf_control%added_mos_auto, &
2540 added_mos_auto_grow=added_mos_auto_grow)
2541 IF (added_mos_auto_grow)
RETURN
2544 fmwork => scf_env%scf_work1
2546 matrix_s(1, 1)%matrix, sab_nl, fmwork, overlap_rs=matrix_s)
2547 IF (scf_env%mixing_method == 0)
THEN
2548 scf_env%iter_method =
'NoMix/OTdiag.'
2549 ELSE IF (scf_env%mixing_method == 1)
THEN
2550 scf_env%iter_param = scf_env%p_mix_alpha
2551 scf_env%iter_method =
'P_Mix/OTdiag.'
2553 scf_env%iter_param = scf_env%mixing_store%alpha
2554 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
'/OTdiag.'
2576 scf_control, scf_section, diis_step, &
2584 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(IN) :: mos
2585 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
2588 LOGICAL,
INTENT(INOUT) :: diis_step
2589 LOGICAL,
INTENT(IN) :: orthogonal_basis
2591 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_roks_diag'
2593 INTEGER :: handle, homoa, homob, imo, nalpha, nao, &
2595 REAL(kind=
dp) :: diis_error, level_shift_loc
2596 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eiga, eigb, occa, occb
2597 TYPE(
cp_fm_type),
POINTER :: ksa, ksb, mo2ao, moa, mob, ortho, work
2601 CALL timeset(routinen, handle)
2604 ortho => scf_env%ortho_m1
2606 ortho => scf_env%ortho
2608 work => scf_env%scf_work2
2610 ksa => scf_env%scf_work1(1)
2611 ksb => scf_env%scf_work1(2)
2624 occupation_numbers=occa, &
2631 occupation_numbers=occb, &
2636 IF ((scf_control%level_shift /= 0.0_dp) .AND. &
2637 ((scf_control%density_guess ==
core_guess) .OR. &
2639 (scf_env%iter_count > 1)))
THEN
2640 level_shift_loc = scf_control%level_shift
2642 level_shift_loc = 0.0_dp
2645 IF ((scf_env%iter_count > 1) .OR. &
2646 (scf_control%density_guess ==
core_guess) .OR. &
2652 CALL cp_fm_symm(
"L",
"U", nao, nao, 1.0_dp, ksa, moa, 0.0_dp, work)
2653 CALL parallel_gemm(
"T",
"N", nao, nao, nao, 1.0_dp, moa, work, 0.0_dp, ksa)
2655 CALL cp_fm_symm(
"L",
"U", nao, nao, 1.0_dp, ksb, moa, 0.0_dp, work)
2656 CALL parallel_gemm(
"T",
"N", nao, nao, nao, 1.0_dp, moa, work, 0.0_dp, ksb)
2667 cpabort(
"Unknown ROKS scheme requested")
2673 IF (orthogonal_basis)
THEN
2686 CALL parallel_gemm(
"N",
"T", nao, nao, nao, 1.0_dp, ksa, mo2ao, 0.0_dp, work)
2687 CALL parallel_gemm(
"N",
"N", nao, nao, nao, 1.0_dp, mo2ao, work, 0.0_dp, ksa)
2701 IF (scf_env%iter_count > 1)
THEN
2702 IF (orthogonal_basis)
THEN
2705 kc=scf_env%scf_work1, &
2707 delta=scf_env%iter_delta, &
2708 error_max=diis_error, &
2709 diis_step=diis_step, &
2710 eps_diis=scf_control%eps_diis, &
2711 scf_section=scf_section, &
2713 cpassert(scf_env%iter_delta == scf_env%iter_delta)
2717 kc=scf_env%scf_work1, &
2719 delta=scf_env%iter_delta, &
2720 error_max=diis_error, &
2721 diis_step=diis_step, &
2722 eps_diis=scf_control%eps_diis, &
2723 scf_section=scf_section, &
2724 s_matrix=matrix_s, &
2730 scf_env%iter_param = diis_error
2731 scf_env%iter_method =
"DIIS/Diag."
2733 IF (scf_env%mixing_method == 1)
THEN
2734 scf_env%iter_param = scf_env%p_mix_alpha
2735 scf_env%iter_method =
"P_Mix/Diag."
2736 ELSE IF (scf_env%mixing_method > 1)
THEN
2737 scf_env%iter_param = scf_env%mixing_store%alpha
2738 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Diag."
2742 scf_env%iter_delta = 0.0_dp
2744 IF (level_shift_loc /= 0.0_dp)
THEN
2749 CALL cp_fm_symm(
"L",
"U", nao, nao, 1.0_dp, ksa, moa, 0.0_dp, work)
2750 CALL parallel_gemm(
"T",
"N", nao, nao, nao, 1.0_dp, moa, work, 0.0_dp, ksa)
2754 DO imo = homob + 1, homoa
2757 DO imo = homoa + 1, nmo
2761 ELSE IF (.NOT. orthogonal_basis)
THEN
2764 SELECT CASE (scf_env%cholesky_method)
2770 "SOLVE", pos=
"RIGHT")
2772 "SOLVE", pos=
"LEFT", transa=
"T")
2776 "MULTIPLY", pos=
"RIGHT")
2778 "MULTIPLY", pos=
"LEFT", transa=
"T")
2780 CALL cp_fm_symm(
"L",
"U", nao, nao, 1.0_dp, ksa, ortho, 0.0_dp, work)
2781 CALL parallel_gemm(
"N",
"N", nao, nao, nao, 1.0_dp, ortho, work, 0.0_dp, ksa)
2792 IF (level_shift_loc /= 0.0_dp)
THEN
2795 CALL parallel_gemm(
"N",
"N", nao, nmo, nao, 1.0_dp, ortho, work, 0.0_dp, moa)
2797 IF (orthogonal_basis)
THEN
2800 SELECT CASE (scf_env%cholesky_method)
2806 CALL parallel_gemm(
"N",
"N", nao, nmo, nao, 1.0_dp, ortho, work, 0.0_dp, moa)
2813 IF (level_shift_loc /= 0.0_dp)
THEN
2814 DO imo = homob + 1, homoa
2815 eiga(imo) = eiga(imo) - 0.5_dp*level_shift_loc
2817 DO imo = homoa + 1, nmo
2818 eiga(imo) = eiga(imo) - level_shift_loc
2833 CALL timestop(handle)
2851 scf_control, scf_section, check_moconv_only)
2854 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
2858 LOGICAL,
INTENT(IN),
OPTIONAL :: check_moconv_only
2860 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_block_krylov_diag'
2861 REAL(kind=
dp),
PARAMETER :: rone = 1.0_dp, rzero = 0.0_dp
2863 INTEGER :: handle, homo, ispin, iter, nao, nmo, &
2865 LOGICAL :: converged, my_check_moconv_only
2866 REAL(
dp) :: eps_iter, t1, t2
2867 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues
2868 TYPE(
cp_fm_type),
POINTER :: c0, c1, chc, evec, ks, mo_coeff, ortho, &
2873 CALL timeset(routinen, handle)
2876 extension=
".scfLog")
2878 my_check_moconv_only = .false.
2879 IF (
PRESENT(check_moconv_only)) my_check_moconv_only = check_moconv_only
2881 NULLIFY (mo_coeff, ortho, work, ks)
2882 NULLIFY (mo_eigenvalues)
2886 ortho => scf_env%ortho_m1
2888 ortho => scf_env%ortho
2890 work => scf_env%scf_work2
2892 DO ispin = 1,
SIZE(matrix_ks)
2894 scf_env%scf_work1(ispin))
2897 IF (scf_env%mixing_method == 1)
THEN
2898 scf_env%iter_param = scf_env%p_mix_alpha
2899 scf_env%iter_method =
"P_Mix/Lanczos"
2902 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Lanc."
2905 DO ispin = 1,
SIZE(matrix_ks)
2907 ks => scf_env%scf_work1(ispin)
2914 eigenvalues=mo_eigenvalues, &
2918 c0 => scf_env%krylov_space%mo_conv(ispin)
2919 c1 => scf_env%krylov_space%mo_refine(ispin)
2920 SELECT CASE (scf_env%cholesky_method)
2927 "SOLVE", pos=
"RIGHT")
2929 "SOLVE", pos=
"LEFT", transa=
"T")
2933 "MULTIPLY", pos=
"RIGHT")
2935 "MULTIPLY", pos=
"LEFT", transa=
"T")
2939 scf_env%krylov_space%nmo_nc = nmo
2940 scf_env%krylov_space%nmo_conv = 0
2943 IF (output_unit > 0)
THEN
2944 WRITE (output_unit,
"(/T15,A)")
'<<<<<<<<< LANCZOS REFINEMENT <<<<<<<<<<'
2945 WRITE (output_unit,
"(T8,A,T15,A,T23,A,T36,A,T49,A,T60,A,/,T8,A)") &
2946 " Spin ",
" Cycle ", &
2947 " conv. MOS ",
" B2MAX ",
" B2MIN ",
" Time", repeat(
"-", 60)
2949 eps_iter = max(scf_env%krylov_space%eps_conv, scf_env%krylov_space%eps_adapt*scf_env%iter_delta)
2953 IF (my_check_moconv_only)
THEN
2956 nao, eps_iter, ispin, check_moconv_only=my_check_moconv_only)
2958 IF (output_unit > 0)
THEN
2959 WRITE (output_unit,
'(T8,I3,T16,I5,T24,I6,T33,E12.4,2x,E12.4,T60,F8.3)') &
2960 ispin, iter, scf_env%krylov_space%nmo_conv, &
2961 scf_env%krylov_space%max_res_norm, scf_env%krylov_space%min_res_norm, t2 - t1
2967 DO iter = 1, scf_env%krylov_space%max_iter
2969 nao, eps_iter, ispin)
2971 IF (output_unit > 0)
THEN
2972 WRITE (output_unit,
'(T8,I3,T16,I5,T24,I6,T33,E12.4,2x,E12.4,T60,F8.3)') &
2973 ispin, iter, scf_env%krylov_space%nmo_conv, &
2974 scf_env%krylov_space%max_res_norm, scf_env%krylov_space%min_res_norm, t2 - t1
2977 IF (scf_env%krylov_space%max_res_norm < eps_iter)
THEN
2979 IF (output_unit > 0)
WRITE (output_unit, *) &
2980 " Reached convergence in ", iter,
" iterations "
2985 IF (.NOT. converged .AND. output_unit > 0)
THEN
2986 WRITE (output_unit,
"(T4, A)")
" WARNING Lanczos refinement could "// &
2987 "not converge all the mos:"
2988 WRITE (output_unit,
"(T40,A,T70,I10)")
" number of not converged mos ", &
2989 scf_env%krylov_space%nmo_nc
2990 WRITE (output_unit,
"(T40,A,T70,E10.2)")
" max norm of the residual ", &
2991 scf_env%krylov_space%max_res_norm
2999 chc => scf_env%krylov_space%chc_mat(ispin)
3000 evec => scf_env%krylov_space%c_vec(ispin)
3001 CALL parallel_gemm(
'N',
'N', nao, nmo, nao, rone, ks, c0, rzero, work)
3002 CALL parallel_gemm(
'T',
'N', nmo, nmo, nao, rone, c0, work, rzero, chc)
3006 CALL parallel_gemm(
'N',
'N', nao, nmo, nmo, rone, c0, evec, rzero, c1)
3007 c0 => scf_env%krylov_space%mo_refine(ispin)
3016 IF (.NOT. scf_control%gce%do_gce)
THEN
3018 smear=scf_control%smear)
3021 smear=scf_control%smear, &
3022 gce=scf_control%gce)
3027 scf_env%p_mix_new(ispin, 1)%matrix)
3031 IF (output_unit > 0)
THEN
3032 WRITE (output_unit,
"(T15,A/)")
'<<<<<<<<< END LANCZOS REFINEMENT <<<<<<<<<<'
3038 CALL timestop(handle)
3058 scf_control, scf_section, check_moconv_only)
3062 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
3063 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_s
3066 LOGICAL,
INTENT(IN),
OPTIONAL :: check_moconv_only
3068 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_block_davidson_diag'
3070 INTEGER :: handle, ispin, nspins, output_unit
3071 LOGICAL :: do_prec, my_check_moconv_only
3075 CALL timeset(routinen, handle)
3078 extension=
".scfLog")
3080 IF (output_unit > 0)
THEN
3081 WRITE (output_unit,
"(/T15,A)")
'<<<<<<<<< DAVIDSON ITERATIONS <<<<<<<<<<'
3084 IF (scf_env%mixing_method == 1)
THEN
3085 scf_env%iter_param = scf_env%p_mix_alpha
3086 scf_env%iter_method =
"P_Mix/Dav."
3088 scf_env%iter_param = scf_env%mixing_store%alpha
3089 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Dav."
3092 my_check_moconv_only = .false.
3093 IF (
PRESENT(check_moconv_only)) my_check_moconv_only = check_moconv_only
3095 IF (scf_env%block_davidson_env(1)%prec_type /= 0 .AND. &
3096 scf_env%iter_count >= scf_env%block_davidson_env(1)%first_prec)
THEN
3100 nspins =
SIZE(matrix_ks)
3102 IF (do_prec .AND. (scf_env%iter_count == scf_env%block_davidson_env(1)%first_prec .OR. &
3103 modulo(scf_env%iter_count, scf_env%block_davidson_env(1)%niter_new_prec) == 0))
THEN
3105 prec_type=scf_env%block_davidson_env(1)%prec_type, nspins=nspins)
3107 scf_env%block_davidson_env(1)%prec_type, &
3108 scf_env%block_davidson_env(1)%solver_type, &
3109 scf_env%block_davidson_env(1)%energy_gap, nspins, &
3110 convert_to_dbcsr=scf_env%block_davidson_env(1)%use_sparse_mos, &
3114 DO ispin = 1, nspins
3115 IF (scf_env%block_davidson_env(ispin)%use_sparse_mos)
THEN
3116 IF (.NOT. do_prec)
THEN
3118 matrix_ks(ispin)%matrix, matrix_s(1)%matrix, output_unit)
3121 matrix_ks(ispin)%matrix, matrix_s(1)%matrix, output_unit, &
3122 scf_env%ot_preconditioner(ispin)%preconditioner)
3126 IF (.NOT. do_prec)
THEN
3128 matrix_ks(ispin)%matrix, matrix_s(1)%matrix, output_unit)
3131 matrix_ks(ispin)%matrix, matrix_s(1)%matrix, output_unit, &
3132 scf_env%ot_preconditioner(ispin)%preconditioner)
3137 IF (.NOT. scf_control%gce%do_gce)
THEN
3139 smear=scf_control%smear)
3142 smear=scf_control%smear, &
3143 gce=scf_control%gce)
3146 DO ispin = 1, nspins
3149 scf_env%p_mix_new(ispin, 1)%matrix)
3152 IF (output_unit > 0)
THEN
3153 WRITE (output_unit,
"(T15,A/)")
'<<<<<<<<< END DAVIDSON ITERATION <<<<<<<<<<'
3159 CALL timestop(handle)
3180 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks_kp, matrix_s_kp
3184 CHARACTER(LEN=*),
PARAMETER :: routinen =
'do_block_davidson_diag_kp'
3185 REAL(kind=
dp),
PARAMETER :: empty_factor = 5.0_dp, &
3186 eps_iter_cap = 1.0e-4_dp
3188 INTEGER :: channel, first_prec, handle, ispin, iw, &
3189 iwork, kplocal, local_kpoint, &
3190 nchannels, nspin, output_unit
3191 INTEGER,
DIMENSION(2) :: kp_range
3192 INTEGER,
DIMENSION(:, :),
POINTER :: kp_dist
3193 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
3195 REAL(kind=
dp) :: eps_iter, eps_iter_empty
3196 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
3198 TYPE(
cp_fm_pool_p_type),
DIMENSION(:),
POINTER :: ao_ao_fm_pools, kp_ao_ao_fm_pools
3200 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: fmwork
3221 CALL timeset(routinen, handle)
3225 extension=
".scfLog")
3226 IF (output_unit > 0)
THEN
3227 WRITE (output_unit,
"(/T15,A)")
'<<<<<<<<< DAVIDSON ITERATIONS <<<<<<<<<<'
3230 CALL get_kpoint_info(kpoints, kp_range=kp_range, kp_dist=kp_dist, xkp=xkp, &
3232 cell_to_index=cell_to_index, mpools=kp_mpools)
3234 cpabort(
'Davidson Kp requires complex K-point MOS')
3236 para_env => kpoints%blacs_env_all%para_env
3237 kplocal = kp_range(2) - kp_range(1) + 1
3238 nspin =
SIZE(matrix_ks_kp, 1)
3239 nchannels = kplocal*nspin
3241 IF (scf_env%mixing_method == 1)
THEN
3242 scf_env%iter_param = scf_env%p_mix_alpha
3243 scf_env%iter_method =
"P_Mix/Dav."
3244 ELSE IF (scf_env%mixing_method > 1)
THEN
3245 scf_env%iter_param = scf_env%mixing_store%alpha
3246 scf_env%iter_method = trim(scf_env%mixing_store%iter_method)//
"/Dav."
3256 first_prec = max(scf_env%block_davidson_env(1)%first_prec, 2)
3258 IF (scf_env%block_davidson_env(1)%prec_type /=
ot_precond_none .AND. &
3259 scf_env%iter_count >= first_prec)
THEN
3276 eps_iter = scf_env%block_davidson_env(1)%eps_iter
3277 eps_iter_empty = eps_iter
3278 IF (scf_control%diagonalization%eps_adapt > 0.0_dp .AND. scf_env%iter_delta > 0.0_dp)
THEN
3288 IF (scf_env%iter_delta < scf_env%block_davidson_env(1)%eps_iter_used)
THEN
3289 scf_env%block_davidson_env(1)%eps_iter_prev = &
3290 min(scf_env%block_davidson_env(1)%eps_iter_prev, &
3291 max(scf_env%block_davidson_env(1)%eps_iter, &
3292 0.1_dp*scf_env%block_davidson_env(1)%eps_iter_used))
3298 eps_iter = min(max(eps_iter, min(scf_control%diagonalization%eps_adapt*scf_env%iter_delta/ &
3299 scf_env%block_davidson_env(1)%noise_scale, &
3300 eps_iter_cap)), scf_env%block_davidson_env(1)%eps_iter_prev)
3301 eps_iter_empty = empty_factor*eps_iter
3304 scf_env%block_davidson_env(1)%eps_iter_prev = eps_iter
3305 scf_env%block_davidson_env(1)%eps_iter_used = eps_iter
3309 IF (scf_control%diagonalization%eps_adapt > 0.0_dp .AND. para_env%is_source() .AND. &
3313 WRITE (unit=iw, fmt=
"(T3,'EPS_ADAPT step',I5,' delta=',ES9.2,' eps_occ=',ES9.2,' eps_empty=',ES9.2)") &
3314 scf_env%iter_count, scf_env%iter_delta, eps_iter, eps_iter_empty
3322 CALL mpools_get(mpools, ao_ao_fm_pools=ao_ao_fm_pools)
3323 ALLOCATE (fmwork(4))
3328 CALL mpools_get(kp_mpools, ao_ao_fm_pools=kp_ao_ao_fm_pools)
3332 CALL cp_cfm_create(csmat_base, matrix_struct, name=
"dav_sk_base")
3334 IF (do_prec .AND. (scf_env%iter_count == first_prec .OR. &
3335 modulo(scf_env%iter_count, &
3336 scf_env%block_davidson_env(1)%niter_new_prec) == 0))
THEN
3337 CALL davidson_kp_prepare_preconditioners( &
3338 qs_env, scf_env, matrix_ks_kp, matrix_s_kp, kpoints, op_ctx)
3341 DO local_kpoint = 1, kplocal
3342 kp => kpoints%kp_env(local_kpoint)%kpoint_env
3352 cmat=cksmat, matrix_row=ispin)
3355 IF (scf_env%iter_count == 1 .AND. .NOT. kp%mos_prefilled)
THEN
3359 CALL cold_start_mo_init(kp, ispin, cksmat, csmat)
3361 channel = (local_kpoint - 1)*nspin + ispin
3364 kp%mos(1:2, ispin), cksmat, csmat, output_unit, &
3365 eps_iter, eps_iter_empty, &
3366 scf_env%ot_preconditioner(channel)%preconditioner)
3369 kp%mos(1:2, ispin), cksmat, csmat, output_unit, &
3370 eps_iter, eps_iter_empty)
3380 matrix_s_kp(1, 1)%matrix, sab_nl, fmwork, overlap_rs=matrix_s_kp)
3391 IF (output_unit > 0)
THEN
3392 WRITE (output_unit,
"(T15,A/)")
'<<<<<<<<< END DAVIDSON ITERATION <<<<<<<<<<'
3397 CALL timestop(handle)
3410 SUBROUTINE cold_start_mo_init(kp, ispin, cksmat, csmat)
3413 INTEGER,
INTENT(IN) :: ispin
3416 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cold_start_mo_init'
3419 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues
3423 CALL timeset(routinen, handle)
3425 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos, eigenvalues=eigenvalues)
3426 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
3427 CALL cp_cfm_create(cmos, rmos%matrix_struct, name=
"dav_cold_cmos")
3428 CALL cp_cfm_create(cwork, cksmat%matrix_struct, name=
"dav_cold_cwork")
3429 CALL cp_cfm_geeig(cksmat, csmat, cmos, eigenvalues, cwork)
3430 kp%mos(2, ispin)%eigenvalues = eigenvalues
3435 CALL timestop(handle)
3437 END SUBROUTINE cold_start_mo_init
3449 SUBROUTINE davidson_kp_prepare_preconditioners( &
3450 qs_env, scf_env, matrix_ks_kp, matrix_s_kp, kpoints, op_ctx)
3454 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_ks_kp, matrix_s_kp
3458 CHARACTER(LEN=*),
PARAMETER :: routinen =
'davidson_kp_prepare_preconditioners'
3460 INTEGER :: channel, handle, ispin, kplocal, &
3461 local_kpoint, nchannels, nmo, nspin, &
3462 prec_type, solver_type
3463 INTEGER,
DIMENSION(2) :: kp_range
3464 INTEGER,
DIMENSION(:, :),
POINTER :: kp_dist
3465 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
3466 REAL(kind=
dp) :: energy_gap
3467 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues
3468 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
3471 TYPE(
cp_fm_type),
POINTER :: mo_coeff_im, mo_coeff_re
3472 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_t_kp
3473 TYPE(
dbcsr_type),
POINTER :: matrix_h_im, matrix_h_re, matrix_s_im, &
3474 matrix_s_re, matrix_t_im, matrix_t_re
3480 CALL timeset(routinen, handle)
3482 CALL get_kpoint_info(kpoints, kp_range=kp_range, kp_dist=kp_dist, xkp=xkp, sab_nl=sab_nl, &
3483 cell_to_index=cell_to_index)
3484 CALL get_qs_env(qs_env, kinetic_kp=matrix_t_kp)
3487 blacs_env => kpoints%blacs_env
3488 para_env => kpoints%para_env_kp
3489 kplocal = kp_range(2) - kp_range(1) + 1
3490 nspin =
SIZE(matrix_ks_kp, 1)
3491 nchannels = kplocal*nspin
3492 prec_type = scf_env%block_davidson_env(1)%prec_type
3493 solver_type = scf_env%block_davidson_env(1)%solver_type
3494 energy_gap = scf_env%block_davidson_env(1)%energy_gap
3500 IF (
ASSOCIATED(scf_env%ot_preconditioner))
THEN
3501 DO channel = 1,
SIZE(scf_env%ot_preconditioner)
3502 IF (
ASSOCIATED(scf_env%ot_preconditioner(channel)%preconditioner))
THEN
3504 DEALLOCATE (scf_env%ot_preconditioner(channel)%preconditioner)
3507 DEALLOCATE (scf_env%ot_preconditioner)
3508 NULLIFY (scf_env%ot_preconditioner)
3510 ALLOCATE (scf_env%ot_preconditioner(nchannels))
3511 DO channel = 1, nchannels
3512 ALLOCATE (scf_env%ot_preconditioner(channel)%preconditioner)
3514 para_env, blacs_env)
3517 NULLIFY (eigenvalues, matrix_h_im, matrix_h_re, matrix_s_im, matrix_s_re, &
3518 matrix_t_im, matrix_t_re, mo_coeff_im, mo_coeff_re)
3520 cpassert(
ASSOCIATED(matrix_t_kp))
3523 DO local_kpoint = 1, kplocal
3524 kp => kpoints%kp_env(local_kpoint)%kpoint_env
3533 mat_re=matrix_s_re, mat_im=matrix_s_im, &
3540 mat_re=matrix_t_re, mat_im=matrix_t_im, &
3545 channel = (local_kpoint - 1)*nspin + ispin
3550 mat_re=matrix_h_re, mat_im=matrix_h_im, matrix_row=ispin)
3557 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=mo_coeff_re, eigenvalues=eigenvalues, &
3559 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=mo_coeff_im)
3560 CALL cp_cfm_create(matrix_c, mo_coeff_re%matrix_struct, name=
"dav pc C")
3564 scf_env%ot_preconditioner(channel)%preconditioner, &
3565 'dav pc H', matrix_h)
3567 scf_env%ot_preconditioner(channel)%preconditioner, &
3568 'dav pc S', matrix_s)
3571 matrix_c, matrix_h, matrix_s, eigenvalues(1:nmo), &
3575 scf_env%ot_preconditioner(channel)%preconditioner, &
3576 matrix_c, matrix_h, matrix_s, energy_gap)
3585 scf_env%ot_preconditioner(channel)%preconditioner, &
3586 matrix_t_re, matrix_t_im, matrix_s_re, matrix_s_im, energy_gap, solver_type)
3589 scf_env%ot_preconditioner(channel)%preconditioner, &
3590 matrix_s_re, matrix_s_im, solver_type)
3602 CALL timestop(handle)
3604 END SUBROUTINE davidson_kp_prepare_preconditioners
3617 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s
3621 CHARACTER(len=*),
PARAMETER :: routinen =
'diag_kp_smat'
3622 COMPLEX(KIND=dp),
PARAMETER :: cone = (1.0_dp, 0.0_dp), &
3623 czero = (0.0_dp, 0.0_dp)
3625 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: ceig
3626 INTEGER :: handle, igroup, ik, ikp, indx, kplocal, &
3627 nao, nkp, nkp_groups
3628 INTEGER,
DIMENSION(2) :: kp_range
3629 INTEGER,
DIMENSION(:, :),
POINTER :: kp_dist
3630 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
3632 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues
3633 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
3639 TYPE(
dbcsr_type),
POINTER :: cmatrix, rmatrix, tmpmat
3647 CALL timeset(routinen, handle)
3651 nkp_groups=nkp_groups, kp_dist=kp_dist, sab_nl=sab_nl, &
3652 cell_to_index=cell_to_index)
3653 cpassert(
ASSOCIATED(sab_nl))
3654 kplocal = kp_range(2) - kp_range(1) + 1
3657 ALLOCATE (rmatrix, cmatrix, tmpmat)
3658 CALL dbcsr_create(rmatrix, template=matrix_s(1, 1)%matrix, &
3659 matrix_type=dbcsr_type_symmetric)
3660 CALL dbcsr_create(cmatrix, template=matrix_s(1, 1)%matrix, &
3661 matrix_type=dbcsr_type_antisymmetric)
3662 CALL dbcsr_create(tmpmat, template=matrix_s(1, 1)%matrix, &
3663 matrix_type=dbcsr_type_no_symmetry)
3669 CALL mpools_get(mpools, ao_ao_fm_pools=ao_ao_fm_pools)
3682 ALLOCATE (eigenvalues(nao), ceig(nao))
3684 para_env => kpoints%blacs_env_all%para_env
3689 IF (
use_real_wfn)
ALLOCATE (info(kplocal*nkp_groups, 1))
3695 DO igroup = 1, nkp_groups
3697 ik = kp_dist(1, igroup) + ikp - 1
3698 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
3702 xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
3724 DO igroup = 1, nkp_groups
3726 ik = kp_dist(1, igroup) + ikp - 1
3727 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
3739 kp => kpoints%kp_env(ikp)%kpoint_env
3745 cpassert(all(eigenvalues(1:nao) >= 0.0_dp))
3749 eigenvalues(1:nao) = sqrt(eigenvalues(1:nao))
3752 CALL parallel_gemm(
"N",
"T", nao, nao, nao, 1.0_dp, rsmat, fmlocal, &
3757 ceig(1:nao) = sqrt(eigenvalues(1:nao))
3760 CALL parallel_gemm(
"N",
"C", nao, nao, nao, cone, csmat, cwork, &
3771 DO igroup = 1, nkp_groups
3773 ik = kp_dist(1, igroup) + ikp - 1
3774 my_kpgrp = (ik >= kpoints%kp_range(1) .AND. ik <= kpoints%kp_range(2))
3784 IF (
ALLOCATED(info))
DEALLOCATE (info)
3785 DEALLOCATE (eigenvalues, ceig)
3799 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...
methods related to the blacs parallel environment
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_canon(amatrix, bmatrix, eigenvectors, eigenvalues, work, epseig, nmo_retained)
General Eigenvalue Problem AX = BXE Use canonical orthogonalization.
subroutine, public cp_cfm_geeig_canon_local(amatrix, bmatrix, eigenvectors, eigenvalues, work, epseig)
Canonical generalized complex diagonalization on a one-rank BLACS grid.
subroutine, public cp_cfm_heevd(matrix, eigenvectors, eigenvalues)
Perform a diagonalisation of a complex matrix.
subroutine, public cp_cfm_geeig_local(amatrix, bmatrix, eigenvectors, eigenvalues)
Solve a generalized complex eigenproblem using the local LAPACK backend. This routine is restricted t...
subroutine, public cp_cfm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work, lowest_subset)
General Eigenvalue Problem AX = BXE Single option version: Cholesky decomposition of B.
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_release_p(matrix)
...
subroutine, public dbcsr_get_readonly_block_p(matrix, row, col, block, found, row_size, col_size)
Like dbcsr_get_block_p() but with matrix being INTENT(IN). When invoking this routine,...
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_init_p(matrix)
...
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_bc(fm, bc_mat)
Copy a BLACS matrix to a dbcsr matrix with a special block-cyclic distribution, which requires no com...
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_scale_and_add(alpha, matrix_a, beta, matrix_b)
calc A <- alpha*A + beta*B optimized for alpha == 1.0 (just add beta*B) and beta == 0....
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_canon(amatrix, bmatrix, eigenvectors, eigenvalues, work, epseig, nmo_retained)
General Eigenvalue Problem AX = BXE Use canonical diagonalization : U*s**(-1/2).
integer, parameter, public fm_diag_type_dlaf
logical, save, public direct_generalized_diagonalization
subroutine, public cp_fm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work)
General Eigenvalue Problem AX = BXE. Use cuSOLVERMp directly when requested and large enough; otherwi...
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
logical function, public diag_check_requested()
Return whether diagonalization checks should be performed.
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
type(cp_fm_struct_type) function, pointer, public fm_pool_get_el_struct(pool)
returns the structure of the elements in this 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_add_to_element(matrix, irow_global, icol_global, alpha)
...
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
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 ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer, parameter, public debug_print_level
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 int_8
integer, parameter, public dp
Routines needed for kpoint calculation.
subroutine, public kpoint_density_transform(kpoint, denmat, wtype, tempmat, sab_nl, fmwork, for_aux_fit, pmat_ext, overlap_rs)
generate real space density matrices in DBCSR format
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 kp_transform_plan_release(plan)
Release a K-to-R traversal plan.
subroutine, public kpoint_set_mo_occupation(kpoint, smear, probe, added_mos_auto, added_mos_auto_grow, separate_spin_occupations)
Given the eigenvalues of all kpoints, calculates the occupation numbers.
subroutine, public rskp_transform_grid_extract(grid, ikp, rmatrix, cmatrix)
Extract one reciprocal-grid matrix from a prepared local DBCSR block cache.
subroutine, public rskp_transform_grid_release(grid)
Release a reciprocal-grid transformation cache.
subroutine, public kp_transform_plan_create(plan, sab_nl, cell_to_index, nimg, block_template, group_entries)
Build the immutable neighbor-list traversal shared by R-to-K and K-to-R transforms.
subroutine, public rskp_transform_grid_prepare(grid, rmatrix, rsmat, ispin, xkp, nkp_grid, cell_to_index, sab_nl, used_fft, is_complex, rs_sign, max_storage_bytes)
Prepare a batched real-cell to complete reciprocal-grid transform for local DBCSR blocks....
subroutine, public kpoint_density_matrices(kpoint, energy_weighted, for_aux_fit)
Calculate kpoint density matrices (rho(k), owned by kpoint groups).
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, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method, gamma_centered, lattice_fft)
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
real(kind=dp), parameter, public twopi
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 make_complex_full_single_inverse(preconditioner_env, matrix_c0, matrix_h, matrix_s, energy_gap)
Build a gauge-covariant FULL_SINGLE_INVERSE operator for a complex k-point channel.
subroutine, public make_complex_full_all(preconditioner_env, matrix_c0, matrix_h, matrix_s, c0_evals, energy_gap)
Build the state-selective FULL_ALL operator for a complex k-point channel. The occupied/reference sub...
subroutine, public init_preconditioner(preconditioner_env, para_env, blacs_env)
...
subroutine, public destroy_preconditioner(preconditioner_env)
...
computes preconditioners, and implements methods to apply them currently used in qs_ot
subroutine, public make_preconditioner_complex_full_s_inverse(preconditioner_env, matrix_s_re, matrix_s_im, solver_type)
Construct a complex FULL_S_INVERSE preconditioner.
subroutine, public dbcsr_pair_to_cfm(matrix_re, matrix_im, preconditioner_env, matrix_name, matrix)
Copy a real/imaginary DBCSR pair to one distributed complex full matrix.
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, chebyshev_degree, low_rank_base, fermi_low_rank_max_rank, lattice_fft, lattice_fft_local_cells)
...
subroutine, public make_preconditioner_complex_full_kinetic(preconditioner_env, matrix_t_re, matrix_t_im, matrix_s_re, matrix_s_im, energy_gap, solver_type)
Construct a complex FULL_KINETIC preconditioner.
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.
pure subroutine, public qs_diis_b_clear(diis_buffer)
clears the buffer
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_inter_kp)
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.
pure subroutine, public qs_diis_b_clear_kp(diis_buffer)
clears the buffer
subroutine, public qs_diis_b_check_i_alloc_kp(diis_buffer, matrix_struct, nspin, nkp, scf_section)
Allocate and initialize a DIIS buffer for nao*nao parameter variables and with a buffer size of nbuff...
subroutine, public qs_diis_b_calc_err_kp(diis_buffer, ib, mos, kc, sc, ispin, ikp, nkp_local, scf_section, real_wfn)
Calculate and store the error for a given k-point.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
subroutine, public 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.
Assembly of complex k-point operators from real-space DBCSR matrices. The output is a complex full ma...
subroutine, public kpoint_operator_context_create(ctx, kpoints, ao_ao_fm, nspin)
Create an empty operator context. The context owns no buffers after this call; they are created on fi...
subroutine, public kpoint_operator_cfm_to_mo(cmat, mo_re, mo_im, eigenvalues)
Split a complex matrix into the real and imaginary MO sets and copy the eigenvalues to the imaginary ...
integer, parameter, public kpoint_spin_free
Row of rsmat that carries the spin-free operator image. S and T carry no spin copies: drivers launch ...
subroutine, public kpoint_operator_get(ctx, ikp, ispin, rsmat, cmat, fm_re, fm_im, mat_re, mat_im, matrix_row)
Assemble one operator for one local k point and spin in one call: run the single-group transfer of th...
integer, parameter, public kpoint_slot_s
integer, parameter, public kpoint_slot_t
integer, parameter, public kpoint_slot_ks
subroutine, public kpoint_operator_finish(ctx, ikp, ispin, slot, cmat)
Finish the transfers of one started instance: on the group that owns the k point, merge the received ...
subroutine, public kpoint_operator_start(ctx, ikp, ispin, rsmat, slot, grid, use_grid, matrix_row)
Start the assembly of one operator for one local k point and spin and launch its transfers to every k...
subroutine, public kpoint_operator_context_release(ctx)
Release the context together with every buffer it created. Call once, at the exit of the routine that...
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_complex(matrix_h, matrix_h_im, matrix_s, matrix_s_im, matrix_c_fm, matrix_c_fm_im, preconditioner, eps_gradient, iter_max, eigenvalues, silent, ot_settings, matrix_t, matrix_t_im, mo_set)
solve a fixed complex Hermitian generalized eigenproblem by OT
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_c(bdav_env, mos, matrix_h, matrix_s, output_unit, eps_iter, eps_iter_empty, preconditioner)
iterative diagonalization by the block-Davidson approach for one complex K point; complex counterpart...
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 qs_scf_get_ot_kpoint_operator(matrix_rs, kpoints, kp, ispin, cache_re, cache_im, matrix_re, matrix_im)
Build one complex k-point operator for OT in the local k-point-group context. A single group keeps th...
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 diag_kp_basic(matrix_ks, matrix_s, kpoints, fmwork)
Kpoint diagonalization routine Transforms matrices to kpoint, distributes kpoint groups,...
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_block_davidson_diag_kp(qs_env, scf_env, matrix_ks_kp, matrix_s_kp, kpoints, scf_control)
block-Davidson SCF step for complex K points, one channel per (local kpoint, spin); mirrors do_block_...
subroutine, public do_ot_diag_kp(matrix_ks, matrix_s, matrix_t, kpoints, scf_env, scf_control, diis_step, added_mos_auto_grow)
fixed-H OT diagonalization for real or complex K-point channels
subroutine, public do_general_diag(scf_env, mos, matrix_ks, matrix_s, scf_control, scf_section, diis_step, probe)
...
subroutine, public diag_kp_smat(matrix_s, kpoints, fmwork)
Kpoint diagonalization routine Transforms matrices to kpoint, distributes kpoint groups,...
subroutine, public do_general_diag_kp(matrix_ks, matrix_s, kpoints, scf_env, scf_control, update_p, diis_step, diis_error, qs_env, probe, matrix_t, store_ot_matrices, transfer_only, added_mos_auto_grow)
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.
module that contains the definitions of the scf types
parameters that control an scf iteration
represent a pointer to a 1d array
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
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
Caller-owned assembly context for one driver call. Created and released in the same driver routine an...
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.