44 dbcsr_type_antisymmetric, dbcsr_type_no_symmetry, dbcsr_type_symmetric
122#include "./base/base_uses.f90"
127 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
128 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_wf_history_methods'
144 SUBROUTINE wfs_create(snapshot)
145 TYPE(qs_wf_snapshot_type),
INTENT(OUT) :: snapshot
147 NULLIFY (snapshot%wf, snapshot%rho_r, &
148 snapshot%rho_g, snapshot%rho_ao, snapshot%rho_ao_kp, &
149 snapshot%overlap, snapshot%wf_kp, snapshot%overlap_cfm_kp, &
150 snapshot%kp_pbc_shift, snapshot%rho_frozen)
152 END SUBROUTINE wfs_create
165 SUBROUTINE wfs_update(snapshot, wf_history, qs_env, dt)
166 TYPE(qs_wf_snapshot_type),
POINTER :: snapshot
167 TYPE(qs_wf_history_type),
POINTER :: wf_history
168 TYPE(qs_environment_type),
POINTER :: qs_env
169 REAL(KIND=
dp),
INTENT(in),
OPTIONAL :: dt
171 CHARACTER(len=*),
PARAMETER :: routineN =
'wfs_update'
173 INTEGER :: handle, ic, igroup, ik, ikp, img, &
174 indx_ft, ispin, kplocal, nc, nimg, &
175 nkp_all, nkp_grps, nspin_kp, nspins
176 INTEGER,
DIMENSION(2) :: kp_range
177 INTEGER,
DIMENSION(:, :),
POINTER :: kp_dist
178 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
180 REAL(KIND=
dp),
DIMENSION(:, :),
POINTER :: xkp
181 TYPE(cell_type),
POINTER :: cell
182 TYPE(copy_info_type),
ALLOCATABLE,
DIMENSION(:, :) :: info_ft
183 TYPE(cp_fm_pool_p_type),
DIMENSION(:),
POINTER :: ao_ao_fm_pools, ao_mo_pools
184 TYPE(cp_fm_struct_type),
POINTER :: ao_ao_struct_ft
185 TYPE(cp_fm_type) :: fmdummy_ft, fmlocal_ft
186 TYPE(cp_fm_type),
POINTER :: mo_coeff
187 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s, rho_ao
188 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s_kp, rho_ao_kp
189 TYPE(dbcsr_type),
POINTER :: cmat_ft, rmat_ft, tmpmat_ft
190 TYPE(dft_control_type),
POINTER :: dft_control
191 TYPE(kpoint_env_type),
POINTER :: kp
192 TYPE(kpoint_type),
POINTER :: kpoints
193 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
194 TYPE(mp_para_env_type),
POINTER :: para_env_ft
195 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
197 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
198 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g
199 TYPE(pw_env_type),
POINTER :: pw_env
200 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
201 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r
202 TYPE(qs_matrix_pools_type),
POINTER :: mpools_kp
203 TYPE(qs_rho_type),
POINTER :: rho
204 TYPE(qs_scf_env_type),
POINTER :: scf_env
206 CALL timeset(routinen, handle)
208 NULLIFY (pw_env, auxbas_pw_pool, ao_mo_pools, ao_ao_fm_pools, dft_control, mos, mo_coeff, &
209 rho, rho_r, rho_g, rho_ao, matrix_s, matrix_s_kp, kpoints, kp, cell, &
210 particle_set, kp_dist, cell_to_index, xkp, sab_nl, scf_env, mpools_kp, para_env_ft, &
211 rmat_ft, cmat_ft, tmpmat_ft, ao_ao_struct_ft)
213 dft_control=dft_control, rho=rho, cell=cell, particle_set=particle_set)
214 CALL mpools_get(qs_env%mpools, ao_mo_fm_pools=ao_mo_pools)
215 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
217 cpassert(
ASSOCIATED(wf_history))
218 cpassert(
ASSOCIATED(dft_control))
219 IF (.NOT.
ASSOCIATED(snapshot))
THEN
221 CALL wfs_create(snapshot)
223 cpassert(wf_history%ref_count > 0)
225 nspins = dft_control%nspins
227 IF (
PRESENT(dt)) snapshot%dt = dt
228 IF (wf_history%store_wf)
THEN
230 IF (.NOT.
ASSOCIATED(snapshot%wf))
THEN
233 cpassert(nspins ==
SIZE(snapshot%wf))
236 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff)
243 IF (wf_history%store_rho_r)
THEN
245 cpassert(
ASSOCIATED(rho_r))
246 IF (.NOT.
ASSOCIATED(snapshot%rho_r))
THEN
247 ALLOCATE (snapshot%rho_r(nspins))
249 CALL auxbas_pw_pool%create_pw(snapshot%rho_r(ispin))
253 CALL pw_copy(rho_r(ispin), snapshot%rho_r(ispin))
255 ELSE IF (
ASSOCIATED(snapshot%rho_r))
THEN
256 DO ispin = 1,
SIZE(snapshot%rho_r)
257 CALL auxbas_pw_pool%give_back_pw(snapshot%rho_r(ispin))
259 DEALLOCATE (snapshot%rho_r)
262 IF (wf_history%store_rho_g)
THEN
264 cpassert(
ASSOCIATED(rho_g))
265 IF (.NOT.
ASSOCIATED(snapshot%rho_g))
THEN
266 ALLOCATE (snapshot%rho_g(nspins))
268 CALL auxbas_pw_pool%create_pw(snapshot%rho_g(ispin))
272 CALL pw_copy(rho_g(ispin), snapshot%rho_g(ispin))
274 ELSE IF (
ASSOCIATED(snapshot%rho_g))
THEN
275 DO ispin = 1,
SIZE(snapshot%rho_g)
276 CALL auxbas_pw_pool%give_back_pw(snapshot%rho_g(ispin))
278 DEALLOCATE (snapshot%rho_g)
281 IF (
ASSOCIATED(snapshot%rho_ao))
THEN
285 IF (wf_history%store_rho_ao)
THEN
287 cpassert(
ASSOCIATED(rho_ao))
291 ALLOCATE (snapshot%rho_ao(ispin)%matrix)
292 CALL dbcsr_copy(snapshot%rho_ao(ispin)%matrix, rho_ao(ispin)%matrix)
296 IF (
ASSOCIATED(snapshot%rho_ao_kp))
THEN
300 IF (wf_history%store_rho_ao_kp)
THEN
302 cpassert(
ASSOCIATED(rho_ao_kp))
304 nimg = dft_control%nimages
308 ALLOCATE (snapshot%rho_ao_kp(ispin, img)%matrix)
309 CALL dbcsr_copy(snapshot%rho_ao_kp(ispin, img)%matrix, &
310 rho_ao_kp(ispin, img)%matrix)
315 IF (
ASSOCIATED(snapshot%overlap))
THEN
319 IF (wf_history%store_overlap)
THEN
321 cpassert(
ASSOCIATED(matrix_s))
322 cpassert(
ASSOCIATED(matrix_s(1)%matrix))
323 ALLOCATE (snapshot%overlap)
324 CALL dbcsr_copy(snapshot%overlap, matrix_s(1)%matrix)
328 IF (
ASSOCIATED(kpoints))
THEN
329 IF (
ASSOCIATED(kpoints%kp_env))
THEN
331 IF (wf_history%store_wf_kp)
THEN
333 kplocal = kp_range(2) - kp_range(1) + 1
334 nspin_kp =
SIZE(kpoints%kp_env(1)%kpoint_env%mos, 2)
335 nc =
SIZE(kpoints%kp_env(1)%kpoint_env%mos, 1)
337 CALL wfi_store_kp_pbc_shift(snapshot, cell, particle_set)
339 IF (
ASSOCIATED(snapshot%wf_kp))
THEN
340 DO ikp = 1,
SIZE(snapshot%wf_kp, 1)
341 DO ic = 1,
SIZE(snapshot%wf_kp, 2)
342 DO ispin = 1,
SIZE(snapshot%wf_kp, 3)
347 DEALLOCATE (snapshot%wf_kp)
350 ALLOCATE (snapshot%wf_kp(kplocal, nc, nspin_kp))
352 kp => kpoints%kp_env(ikp)%kpoint_env
353 DO ispin = 1, nspin_kp
355 CALL get_mo_set(kp%mos(ic, ispin), mo_coeff=mo_coeff)
357 mo_coeff%matrix_struct, &
359 CALL cp_fm_to_fm(mo_coeff, snapshot%wf_kp(ikp, ic, ispin))
369 IF (wf_history%store_overlap_kp)
THEN
370 CALL get_qs_env(qs_env, matrix_s_kp=matrix_s_kp, scf_env=scf_env)
371 CALL get_kpoint_info(kpoints, nkp=nkp_all, xkp=xkp, kp_range=kp_range, &
372 nkp_groups=nkp_grps, kp_dist=kp_dist, &
373 sab_nl=sab_nl, cell_to_index=cell_to_index)
374 kplocal = kp_range(2) - kp_range(1) + 1
375 para_env_ft => kpoints%blacs_env_all%para_env
378 ALLOCATE (rmat_ft, cmat_ft, tmpmat_ft)
379 CALL dbcsr_create(rmat_ft, template=matrix_s_kp(1, 1)%matrix, &
380 matrix_type=dbcsr_type_symmetric)
381 CALL dbcsr_create(cmat_ft, template=matrix_s_kp(1, 1)%matrix, &
382 matrix_type=dbcsr_type_antisymmetric)
383 CALL dbcsr_create(tmpmat_ft, template=matrix_s_kp(1, 1)%matrix, &
384 matrix_type=dbcsr_type_no_symmetry)
390 CALL mpools_get(mpools_kp, ao_ao_fm_pools=ao_ao_fm_pools)
394 IF (
ASSOCIATED(snapshot%overlap_cfm_kp))
THEN
395 DO ikp = 1,
SIZE(snapshot%overlap_cfm_kp)
398 DEALLOCATE (snapshot%overlap_cfm_kp)
400 ALLOCATE (snapshot%overlap_cfm_kp(kplocal))
405 ALLOCATE (info_ft(kplocal*nkp_grps, 2))
410 DO igroup = 1, nkp_grps
411 ik = kp_dist(1, igroup) + ikp - 1
412 my_kpgrp = (ik >= kp_range(1) .AND. ik <= kp_range(2))
413 indx_ft = indx_ft + 1
417 CALL rskp_transform(rmatrix=rmat_ft, cmatrix=cmat_ft, rsmat=matrix_s_kp, &
418 ispin=1, xkp=xkp(1:3, ik), &
419 cell_to_index=cell_to_index, sab_nl=sab_nl)
427 para_env_ft, info_ft(indx_ft, 1))
429 para_env_ft, info_ft(indx_ft, 2))
432 para_env_ft, info_ft(indx_ft, 1))
434 para_env_ft, info_ft(indx_ft, 2))
442 CALL cp_cfm_create(snapshot%overlap_cfm_kp(ikp), ao_ao_struct_ft)
444 DO igroup = 1, nkp_grps
445 ik = kp_dist(1, igroup) + ikp - 1
446 my_kpgrp = (ik >= kp_range(1) .AND. ik <= kp_range(2))
447 indx_ft = indx_ft + 1
460 DO indx_ft = 1, kplocal*nkp_grps
473 IF (wf_history%store_frozen_density)
THEN
478 CALL timestop(handle)
480 END SUBROUTINE wfs_update
494 SUBROUTINE wfi_create(wf_history, interpolation_method_nr, extrapolation_order, &
497 INTEGER,
INTENT(in) :: interpolation_method_nr, &
499 LOGICAL,
INTENT(IN) :: has_unit_metric
501 CHARACTER(len=*),
PARAMETER :: routinen =
'wfi_create'
505 CALL timeset(routinen, handle)
507 ALLOCATE (wf_history)
508 wf_history%ref_count = 1
509 wf_history%memory_depth = 0
510 wf_history%snapshot_count = 0
511 wf_history%last_state_index = 1
512 wf_history%store_wf = .false.
513 wf_history%store_rho_r = .false.
514 wf_history%store_rho_g = .false.
515 wf_history%store_rho_ao = .false.
516 wf_history%store_rho_ao_kp = .false.
517 wf_history%store_overlap = .false.
518 wf_history%store_wf_kp = .false.
519 wf_history%store_overlap_kp = .false.
520 wf_history%store_frozen_density = .false.
521 NULLIFY (wf_history%past_states)
523 wf_history%interpolation_method_nr = interpolation_method_nr
525 SELECT CASE (wf_history%interpolation_method_nr)
527 wf_history%memory_depth = 0
529 wf_history%memory_depth = 0
531 wf_history%memory_depth = 1
532 wf_history%store_rho_ao = .true.
534 wf_history%memory_depth = 2
535 wf_history%store_wf = .true.
537 wf_history%memory_depth = 2
538 wf_history%store_rho_ao = .true.
540 wf_history%memory_depth = 2
541 wf_history%store_wf = .true.
542 IF (.NOT. has_unit_metric) wf_history%store_overlap = .true.
545 wf_history%memory_depth = extrapolation_order + 1
546 wf_history%store_wf = .true.
547 wf_history%store_wf_kp = .true.
548 IF (.NOT. has_unit_metric)
THEN
549 wf_history%store_overlap = .true.
550 wf_history%store_overlap_kp = .true.
553 wf_history%memory_depth = 1
554 wf_history%store_frozen_density = .true.
556 wf_history%memory_depth = extrapolation_order + 2
557 wf_history%store_wf = .true.
558 wf_history%store_wf_kp = .true.
559 IF (.NOT. has_unit_metric)
THEN
560 wf_history%store_overlap = .true.
561 wf_history%store_overlap_kp = .true.
564 wf_history%memory_depth = extrapolation_order
565 wf_history%store_wf = .true.
566 wf_history%store_wf_kp = .true.
567 wf_history%store_overlap = .true.
568 wf_history%store_overlap_kp = .true.
570 wf_history%memory_depth = extrapolation_order
571 wf_history%store_wf = .true.
572 wf_history%store_wf_kp = .true.
573 wf_history%store_overlap = .true.
574 wf_history%store_overlap_kp = .true.
576 CALL cp_abort(__location__, &
577 "Unknown interpolation method: "// &
580 ALLOCATE (wf_history%past_states(wf_history%memory_depth))
582 DO i = 1,
SIZE(wf_history%past_states)
583 NULLIFY (wf_history%past_states(i)%snapshot)
586 CALL timestop(handle)
603 cpassert(
ASSOCIATED(wf_history))
604 IF (wf_history%store_rho_ao)
THEN
605 wf_history%store_rho_ao_kp = .true.
606 wf_history%store_rho_ao = .false.
612 wf_history%memory_depth = 1
613 wf_history%store_wf_kp = .true.
614 wf_history%store_wf = .false.
615 wf_history%store_overlap = .false.
616 IF (
ASSOCIATED(wf_history%past_states))
DEALLOCATE (wf_history%past_states)
617 ALLOCATE (wf_history%past_states(wf_history%memory_depth))
618 DO i = 1,
SIZE(wf_history%past_states)
619 NULLIFY (wf_history%past_states(i)%snapshot)
621 ELSE IF (wf_history%store_wf_kp)
THEN
622 wf_history%store_wf = .false.
623 wf_history%store_overlap = .false.
627 IF (wf_history%store_wf .OR. wf_history%store_overlap)
THEN
628 cpabort(
"Linear WFN-based extrapolation methods not implemented for k-points.")
631 IF (wf_history%store_frozen_density)
THEN
632 cpabort(
"Frozen density initialization method not possible for kpoints.")
646 INTEGER,
INTENT(in) :: method_nr
647 CHARACTER(len=30) :: res
650 SELECT CASE (method_nr)
656 res =
"initial_guess"
666 res =
"frozen density approximation"
672 res =
"GEXT_PROJ_QTR"
674 CALL cp_abort(__location__, &
675 "Unknown interpolation method: "// &
699 REAL(kind=
dp),
INTENT(IN) :: dt
700 INTEGER,
INTENT(OUT),
OPTIONAL :: extrapolation_method_nr
701 LOGICAL,
INTENT(OUT),
OPTIONAL :: orthogonal_wf
703 CHARACTER(len=*),
PARAMETER :: routinen =
'wfi_extrapolate'
705 INTEGER :: actual_extrapolation_method_nr, handle, &
706 i, img, io_unit, ispin, k, n, nmo, &
708 LOGICAL :: do_kpoints, my_orthogonal_wf, use_overlap
709 REAL(kind=
dp) :: alpha, t0, t1, t2
710 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: coeffs
716 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s, rho_ao, rho_frozen_ao
717 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_kp
722 NULLIFY (mos, ao_mo_fm_pools, t0_state, t1_state, mo_coeff, &
723 rho, rho_ao, rho_frozen_ao)
725 use_overlap = wf_history%store_overlap
727 CALL timeset(routinen, handle)
729 print_level = logger%iter_info%print_level
733 cpassert(
ASSOCIATED(wf_history))
734 cpassert(wf_history%ref_count > 0)
735 cpassert(
ASSOCIATED(qs_env))
736 CALL get_qs_env(qs_env, mos=mos, rho=rho, do_kpoints=do_kpoints)
737 CALL mpools_get(qs_env%mpools, ao_mo_fm_pools=ao_mo_fm_pools)
739 IF (wf_history%snapshot_count < 1)
THEN
742 actual_extrapolation_method_nr = wf_history%interpolation_method_nr
745 SELECT CASE (actual_extrapolation_method_nr)
747 IF (wf_history%snapshot_count < 2)
THEN
751 IF (wf_history%snapshot_count < 2)
THEN
755 IF (wf_history%snapshot_count < 2)
THEN
760 IF (
PRESENT(extrapolation_method_nr))
THEN
761 extrapolation_method_nr = actual_extrapolation_method_nr
763 my_orthogonal_wf = .false.
765 SELECT CASE (actual_extrapolation_method_nr)
767 cpassert(.NOT. do_kpoints)
769 cpassert(
ASSOCIATED(t0_state%rho_frozen))
771 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
772 CALL wfi_set_history_variables(qs_env=qs_env, nvec=nvec)
774 CALL qs_rho_get(t0_state%rho_frozen, rho_ao=rho_frozen_ao)
776 DO ispin = 1,
SIZE(rho_frozen_ao)
778 rho_frozen_ao(ispin)%matrix, &
779 keep_sparsity=.true.)
786 my_orthogonal_wf = .false.
789 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
790 CALL wfi_set_history_variables(qs_env=qs_env, nvec=nvec)
792 cpassert(
ASSOCIATED(t0_state%rho_ao_kp))
794 DO ispin = 1,
SIZE(t0_state%rho_ao_kp, 1)
795 DO img = 1,
SIZE(t0_state%rho_ao_kp, 2)
796 IF (img >
SIZE(rho_ao_kp, 2))
THEN
797 cpwarn(
"Change in cell neighborlist: might affect quality of initial guess")
799 CALL dbcsr_copy(rho_ao_kp(ispin, img)%matrix, &
800 t0_state%rho_ao_kp(ispin, img)%matrix, &
801 keep_sparsity=.true.)
806 cpassert(
ASSOCIATED(t0_state%rho_ao))
808 DO ispin = 1,
SIZE(t0_state%rho_ao)
810 t0_state%rho_ao(ispin)%matrix, &
811 keep_sparsity=.true.)
819 my_orthogonal_wf = .true.
820 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
821 CALL wfi_set_history_variables(qs_env=qs_env, nvec=nvec)
824 CALL wfi_use_prev_wf_kp(qs_env, io_unit, print_level)
827 DO ispin = 1,
SIZE(mos)
828 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
842 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
843 CALL wfi_set_history_variables(qs_env=qs_env, nvec=nvec)
845 cpassert(.NOT. do_kpoints)
848 cpassert(
ASSOCIATED(t0_state))
849 cpassert(
ASSOCIATED(t1_state))
850 cpassert(
ASSOCIATED(t0_state%wf))
851 cpassert(
ASSOCIATED(t1_state%wf))
852 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
853 CALL wfi_set_history_variables(qs_env=qs_env, nvec=nvec)
855 my_orthogonal_wf = .true.
860 DO ispin = 1,
SIZE(mos)
861 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff, &
865 matrix_b=t1_state%wf(ispin), &
866 beta=(t2 - t0)/(t1 - t0))
870 beta=(t1 - t2)/(t1 - t0), matrix_b=t0_state%wf(ispin))
875 density_matrix=rho_ao(ispin)%matrix)
884 cpassert(
ASSOCIATED(t0_state))
885 cpassert(
ASSOCIATED(t1_state))
887 cpassert(
ASSOCIATED(t0_state%rho_ao_kp))
888 cpassert(
ASSOCIATED(t1_state%rho_ao_kp))
890 cpassert(
ASSOCIATED(t0_state%rho_ao))
891 cpassert(
ASSOCIATED(t1_state%rho_ao))
893 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
894 CALL wfi_set_history_variables(qs_env=qs_env, nvec=nvec)
901 DO ispin = 1,
SIZE(rho_ao_kp, 1)
902 DO img = 1,
SIZE(rho_ao_kp, 2)
903 IF (img >
SIZE(t0_state%rho_ao_kp, 2) .OR. &
904 img >
SIZE(t1_state%rho_ao_kp, 2))
THEN
905 cpwarn(
"Change in cell neighborlist: might affect quality of initial guess")
907 CALL dbcsr_add(rho_ao_kp(ispin, img)%matrix, t1_state%rho_ao_kp(ispin, img)%matrix, &
908 alpha_scalar=0.0_dp, beta_scalar=(t2 - t0)/(t1 - t0))
909 CALL dbcsr_add(rho_ao_kp(ispin, img)%matrix, t0_state%rho_ao_kp(ispin, img)%matrix, &
910 alpha_scalar=1.0_dp, beta_scalar=(t1 - t2)/(t1 - t0))
916 DO ispin = 1,
SIZE(rho_ao)
917 CALL dbcsr_add(rho_ao(ispin)%matrix, t1_state%rho_ao(ispin)%matrix, &
918 alpha_scalar=0.0_dp, beta_scalar=(t2 - t0)/(t1 - t0))
919 CALL dbcsr_add(rho_ao(ispin)%matrix, t0_state%rho_ao(ispin)%matrix, &
920 alpha_scalar=1.0_dp, beta_scalar=(t1 - t2)/(t1 - t0))
928 cpassert(.NOT. do_kpoints)
931 cpassert(
ASSOCIATED(t0_state))
932 cpassert(
ASSOCIATED(t1_state))
933 cpassert(
ASSOCIATED(t0_state%wf))
934 cpassert(
ASSOCIATED(t1_state%wf))
935 IF (wf_history%store_overlap)
THEN
936 cpassert(
ASSOCIATED(t0_state%overlap))
937 cpassert(
ASSOCIATED(t1_state%overlap))
939 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
940 IF (nvec >= wf_history%memory_depth)
THEN
941 IF ((qs_env%scf_control%max_scf_hist /= 0) .AND. (qs_env%scf_control%eps_scf_hist /= 0))
THEN
942 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
943 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
944 qs_env%scf_control%outer_scf%have_scf = .false.
945 ELSE IF (qs_env%scf_control%max_scf_hist /= 0)
THEN
946 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
947 qs_env%scf_control%outer_scf%have_scf = .false.
948 ELSE IF (qs_env%scf_control%eps_scf_hist /= 0)
THEN
949 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
953 my_orthogonal_wf = .true.
957 DO ispin = 1,
SIZE(mos)
958 NULLIFY (mo_coeff, matrix_struct, matrix_struct_new)
959 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
961 matrix_struct=matrix_struct)
963 nrow_global=k, ncol_global=k)
967 IF (use_overlap)
THEN
969 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), mo_coeff, 0.0_dp, csc)
971 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), &
972 t1_state%wf(ispin), 0.0_dp, csc)
974 CALL parallel_gemm(
'N',
'N', n, k, k, 1.0_dp, t0_state%wf(ispin), csc, 0.0_dp, mo_coeff)
981 density_matrix=rho_ao(ispin)%matrix)
988 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
990 IF (nvec >= wf_history%memory_depth)
THEN
991 IF ((qs_env%scf_control%max_scf_hist /= 0) .AND. (qs_env%scf_control%eps_scf_hist /= 0))
THEN
992 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
993 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
994 qs_env%scf_control%outer_scf%have_scf = .false.
995 ELSE IF (qs_env%scf_control%max_scf_hist /= 0)
THEN
996 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
997 qs_env%scf_control%outer_scf%have_scf = .false.
998 ELSE IF (qs_env%scf_control%eps_scf_hist /= 0)
THEN
999 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1003 IF (do_kpoints)
THEN
1004 CALL wfi_extrapolate_ps_aspc_kp(wf_history, qs_env, nvec, io_unit, print_level)
1005 my_orthogonal_wf = .true.
1007 my_orthogonal_wf = .true.
1008 DO ispin = 1,
SIZE(mos)
1009 NULLIFY (mo_coeff, matrix_struct, matrix_struct_new)
1010 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
1012 matrix_struct=matrix_struct)
1015 nrow_global=k, ncol_global=k)
1026 IF (use_overlap)
THEN
1028 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), fm_tmp, 0.0_dp, csc)
1030 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), &
1031 t1_state%wf(ispin), 0.0_dp, csc)
1033 CALL parallel_gemm(
'N',
'N', n, k, k, 1.0_dp, t0_state%wf(ispin), csc, 0.0_dp, fm_tmp)
1034 alpha = -1.0_dp*alpha*real(nvec - i + 1,
dp)/real(i,
dp)
1041 v_matrix=mo_coeff, &
1044 density_matrix=rho_ao(ispin)%matrix)
1054 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
1056 IF (nvec >= wf_history%memory_depth)
THEN
1057 IF ((qs_env%scf_control%max_scf_hist /= 0) .AND. &
1058 (qs_env%scf_control%eps_scf_hist /= 0))
THEN
1059 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1060 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1061 qs_env%scf_control%outer_scf%have_scf = .false.
1062 ELSE IF (qs_env%scf_control%max_scf_hist /= 0)
THEN
1063 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1064 qs_env%scf_control%outer_scf%have_scf = .false.
1065 ELSE IF (qs_env%scf_control%eps_scf_hist /= 0)
THEN
1066 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1070 IF (do_kpoints)
THEN
1071 CALL wfi_extrapolate_ps_aspc_kp(wf_history, qs_env, nvec, io_unit, print_level)
1072 my_orthogonal_wf = .true.
1074 my_orthogonal_wf = .true.
1076 DO ispin = 1,
SIZE(mos)
1077 NULLIFY (mo_coeff, matrix_struct, matrix_struct_new)
1078 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
1082 matrix_struct=matrix_struct)
1083 CALL cp_fm_create(fm_tmp, matrix_struct, set_zero=.true.)
1085 template_fmstruct=matrix_struct, &
1088 CALL cp_fm_create(csc, matrix_struct_new, set_zero=.true.)
1094 alpha = real(4*nvec - 2, kind=
dp)/real(nvec + 1, kind=
dp)
1096 WRITE (unit=io_unit, fmt=
"(/,T2,A,/,/,T3,A,I0,/,/,T3,A2,I0,A4,F10.6)") &
1097 "Parameters for the always stable predictor-corrector (ASPC) method:", &
1098 "ASPC order: ", max(nvec - 2, 0), &
1099 "B(", 1,
") = ", alpha
1105 IF (use_overlap)
THEN
1107 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), fm_tmp, 0.0_dp, csc)
1109 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), &
1110 t1_state%wf(ispin), 0.0_dp, csc)
1112 CALL parallel_gemm(
'N',
'N', n, k, k, 1.0_dp, t0_state%wf(ispin), csc, 0.0_dp, fm_tmp)
1113 alpha = (-1.0_dp)**(i + 1)*real(i, kind=
dp)* &
1116 WRITE (unit=io_unit, fmt=
"(T3,A2,I0,A4,F10.6)") &
1117 "B(", i,
") = ", alpha
1124 v_matrix=mo_coeff, &
1127 density_matrix=rho_ao(ispin)%matrix)
1134 IF (do_kpoints)
THEN
1135 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
1137 CALL wfi_extrapolate_gext_proj_kp(wf_history, qs_env, nvec, io_unit, print_level)
1138 my_orthogonal_wf = .true.
1142 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
1143 IF (nvec >= wf_history%memory_depth)
THEN
1144 IF ((qs_env%scf_control%max_scf_hist /= 0) .AND. &
1145 (qs_env%scf_control%eps_scf_hist /= 0))
THEN
1146 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1147 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1148 qs_env%scf_control%outer_scf%have_scf = .false.
1149 ELSE IF (qs_env%scf_control%max_scf_hist /= 0)
THEN
1150 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1151 qs_env%scf_control%outer_scf%have_scf = .false.
1152 ELSE IF (qs_env%scf_control%eps_scf_hist /= 0)
THEN
1153 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1159 ALLOCATE (coeffs(nvec))
1162 CALL diff_fitting(wf_history, matrix_s(1)%matrix, coeffs, nvec, &
1163 1e-4_dp, io_unit, print_level)
1165 my_orthogonal_wf = .true.
1167 DO ispin = 1,
SIZE(mos)
1168 NULLIFY (mo_coeff, matrix_struct, matrix_struct_new)
1169 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
1173 matrix_struct=matrix_struct)
1176 template_fmstruct=matrix_struct, &
1189 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), fm_tmp, 0.0_dp, csc)
1190 CALL parallel_gemm(
'N',
'N', n, k, k, 1.0_dp, t0_state%wf(ispin), csc, 0.0_dp, fm_tmp)
1196 v_matrix=mo_coeff, &
1199 density_matrix=rho_ao(ispin)%matrix)
1209 IF (do_kpoints)
THEN
1210 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
1212 CALL wfi_extrapolate_gext_proj_kp(wf_history, qs_env, nvec, io_unit, print_level)
1213 my_orthogonal_wf = .true.
1217 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
1218 IF (nvec >= wf_history%memory_depth)
THEN
1219 IF ((qs_env%scf_control%max_scf_hist /= 0) .AND. &
1220 (qs_env%scf_control%eps_scf_hist /= 0))
THEN
1221 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1222 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1223 qs_env%scf_control%outer_scf%have_scf = .false.
1224 ELSE IF (qs_env%scf_control%max_scf_hist /= 0)
THEN
1225 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1226 qs_env%scf_control%outer_scf%have_scf = .false.
1227 ELSE IF (qs_env%scf_control%eps_scf_hist /= 0)
THEN
1228 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1234 ALLOCATE (coeffs(nvec))
1237 CALL tr_fitting(wf_history, matrix_s(1)%matrix, coeffs, nvec, &
1238 1e-4_dp, io_unit, print_level)
1240 my_orthogonal_wf = .true.
1242 DO ispin = 1,
SIZE(mos)
1243 NULLIFY (mo_coeff, matrix_struct, matrix_struct_new)
1244 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
1248 matrix_struct=matrix_struct)
1251 template_fmstruct=matrix_struct, &
1264 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), fm_tmp, 0.0_dp, csc)
1265 CALL parallel_gemm(
'N',
'N', n, k, k, 1.0_dp, t0_state%wf(ispin), csc, 0.0_dp, fm_tmp)
1271 v_matrix=mo_coeff, &
1274 density_matrix=rho_ao(ispin)%matrix)
1284 CALL cp_abort(__location__, &
1285 "Unknown interpolation method: "// &
1286 trim(adjustl(
cp_to_string(wf_history%interpolation_method_nr))))
1288 IF (
PRESENT(orthogonal_wf)) orthogonal_wf = my_orthogonal_wf
1290 "DFT%SCF%PRINT%PROGRAM_RUN_INFO")
1291 CALL timestop(handle)
1303 SUBROUTINE wfi_use_prev_wf_kp(qs_env, io_unit, print_level, pbc_shift_ref, load_snapshot_wf)
1305 INTEGER,
INTENT(IN) :: io_unit, print_level
1306 INTEGER,
DIMENSION(:, :),
INTENT(IN),
OPTIONAL :: pbc_shift_ref
1307 LOGICAL,
INTENT(IN),
OPTIONAL :: load_snapshot_wf
1309 CHARACTER(len=*),
PARAMETER :: routinen =
'wfi_use_prev_wf_kp'
1311 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: col_scaling
1312 INTEGER :: chol_info, handle, igroup, ik, ikp, &
1313 indx, ispin, j, kplocal, nao, nkp, &
1314 nkp_groups, nmo, nspin
1315 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: pbc_shift_cur, pbc_shift_src
1316 INTEGER,
DIMENSION(2) :: kp_range
1317 INTEGER,
DIMENSION(:, :),
POINTER :: kp_dist
1318 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1319 LOGICAL :: my_kpgrp, reload_snapshot_wf, &
1320 use_pbc_phase_ref, use_real_wfn
1321 REAL(kind=
dp) :: eval_thresh
1322 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues
1323 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1325 TYPE(
cp_cfm_type) :: cfm_evecs, cfm_mhalf, cfm_nao_nmo_work, &
1327 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: csmat_cur
1331 TYPE(
cp_fm_type),
POINTER :: imos, mo_coeff, rmos
1332 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s_kp
1333 TYPE(
dbcsr_type),
POINTER :: cmatrix_db, rmatrix, tmpmat
1344 CALL timeset(routinen, handle)
1346 NULLIFY (kpoints, matrix_s_kp, scf_env, sab_nl, kp, &
1347 mo_coeff, rmos, imos, wf_history, t1_state)
1349 CALL get_qs_env(qs_env, kpoints=kpoints, matrix_s_kp=matrix_s_kp, scf_env=scf_env)
1350 CALL get_kpoint_info(kpoints, nkp=nkp, xkp=xkp, use_real_wfn=use_real_wfn, &
1351 kp_range=kp_range, nkp_groups=nkp_groups, kp_dist=kp_dist, &
1352 sab_nl=sab_nl, cell_to_index=cell_to_index)
1353 kplocal = kp_range(2) - kp_range(1) + 1
1355 IF (use_real_wfn)
THEN
1356 CALL timestop(handle)
1360 wf_history => qs_env%wf_history
1361 reload_snapshot_wf = .false.
1362 IF (
PRESENT(load_snapshot_wf)) reload_snapshot_wf = load_snapshot_wf
1363 IF (
PRESENT(pbc_shift_ref))
THEN
1364 ALLOCATE (pbc_shift_src(3,
SIZE(pbc_shift_ref, 2)))
1365 pbc_shift_src(:, :) = pbc_shift_ref(:, :)
1366 use_pbc_phase_ref = .true.
1368 use_pbc_phase_ref = .false.
1369 IF (
ASSOCIATED(wf_history))
THEN
1370 IF (wf_history%store_wf_kp .AND. wf_history%snapshot_count > 0)
THEN
1372 cpassert(
ASSOCIATED(t1_state%wf_kp))
1373 cpassert(
ASSOCIATED(t1_state%kp_pbc_shift))
1374 reload_snapshot_wf = .true.
1375 ALLOCATE (pbc_shift_src(3,
SIZE(t1_state%kp_pbc_shift, 2)))
1376 pbc_shift_src(:, :) = t1_state%kp_pbc_shift(:, :)
1377 use_pbc_phase_ref = .true.
1381 IF (use_pbc_phase_ref)
CALL wfi_compute_kp_pbc_shift(qs_env, pbc_shift_cur)
1383 kp => kpoints%kp_env(1)%kpoint_env
1384 nspin =
SIZE(kp%mos, 2)
1385 CALL get_mo_set(kp%mos(1, 1), nao=nao, nmo=nmo, mo_coeff=mo_coeff)
1388 WRITE (unit=io_unit, fmt=
"(/,T2,A)") &
1389 "Using previous wavefunctions as initial guess for k-points (with reorthogonalization)"
1393 ALLOCATE (rmatrix, cmatrix_db, tmpmat)
1394 CALL dbcsr_create(rmatrix, template=matrix_s_kp(1, 1)%matrix, matrix_type=dbcsr_type_symmetric)
1395 CALL dbcsr_create(cmatrix_db, template=matrix_s_kp(1, 1)%matrix, matrix_type=dbcsr_type_antisymmetric)
1396 CALL dbcsr_create(tmpmat, template=matrix_s_kp(1, 1)%matrix, matrix_type=dbcsr_type_no_symmetry)
1401 CALL mpools_get(mpools_kp, ao_ao_fm_pools=ao_ao_fm_pools_kp)
1406 CALL cp_cfm_create(cfm_nao_nmo_work, mo_coeff%matrix_struct)
1408 NULLIFY (nmo_nmo_struct)
1410 nrow_global=nmo, ncol_global=nmo)
1414 para_env => kpoints%blacs_env_all%para_env
1415 ALLOCATE (info(kplocal*nkp_groups, 2))
1417 ALLOCATE (csmat_cur(kplocal))
1425 DO igroup = 1, nkp_groups
1426 ik = kp_dist(1, igroup) + ikp - 1
1427 my_kpgrp = (ik >= kp_range(1) .AND. ik <= kp_range(2))
1432 CALL rskp_transform(rmatrix=rmatrix, cmatrix=cmatrix_db, rsmat=matrix_s_kp, &
1433 ispin=1, xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
1452 DO igroup = 1, nkp_groups
1453 ik = kp_dist(1, igroup) + ikp - 1
1454 my_kpgrp = (ik >= kp_range(1) .AND. ik <= kp_range(2))
1465 DO indx = 1, kplocal*nkp_groups
1472 ALLOCATE (eigenvalues(nmo))
1473 eval_thresh = 1.0e-12_dp
1476 kp => kpoints%kp_env(ikp)%kpoint_env
1478 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos)
1479 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
1480 IF (reload_snapshot_wf)
THEN
1481 CALL cp_fm_to_fm(t1_state%wf_kp(ikp, 1, ispin), rmos)
1482 CALL cp_fm_to_fm(t1_state%wf_kp(ikp, 2, ispin), imos)
1484 IF (use_pbc_phase_ref)
THEN
1485 ik = kp_range(1) + ikp - 1
1486 CALL wfi_apply_kp_pbc_phase_fm(rmos, imos, pbc_shift_cur - pbc_shift_src, &
1487 xkp(1:3, ik), matrix_s_kp(1, 1)%matrix)
1492 csmat_cur(ikp), cmos_new,
z_zero, cfm_nao_nmo_work)
1494 cmos_new, cfm_nao_nmo_work,
z_zero, csc_cfm)
1497 IF (chol_info == 0)
THEN
1505 ALLOCATE (col_scaling(nmo))
1507 IF (eigenvalues(j) > eval_thresh)
THEN
1508 col_scaling(j) = cmplx(1.0_dp/sqrt(eigenvalues(j)), 0.0_dp, kind=
dp)
1514 DEALLOCATE (col_scaling)
1528 kp%mos_prefilled = .true.
1530 DEALLOCATE (eigenvalues)
1539 DEALLOCATE (csmat_cur)
1548 IF (
ALLOCATED(pbc_shift_cur))
DEALLOCATE (pbc_shift_cur)
1549 IF (
ALLOCATED(pbc_shift_src))
DEALLOCATE (pbc_shift_src)
1551 CALL timestop(handle)
1552 END SUBROUTINE wfi_use_prev_wf_kp
1561 SUBROUTINE wfi_store_kp_pbc_shift(snapshot, cell, particle_set)
1566 INTEGER :: iatom, natom
1567 REAL(kind=
dp),
DIMENSION(3) :: frac_pbc, frac_raw, r_pbc
1569 cpassert(
ASSOCIATED(snapshot))
1570 cpassert(
ASSOCIATED(cell))
1571 cpassert(
ASSOCIATED(particle_set))
1573 natom =
SIZE(particle_set)
1574 IF (
ASSOCIATED(snapshot%kp_pbc_shift))
THEN
1575 DEALLOCATE (snapshot%kp_pbc_shift)
1577 ALLOCATE (snapshot%kp_pbc_shift(3, natom))
1579 r_pbc(1:3) =
pbc(particle_set(iatom)%r(1:3), cell)
1582 snapshot%kp_pbc_shift(1:3, iatom) = nint(frac_pbc(1:3) - frac_raw(1:3))
1584 END SUBROUTINE wfi_store_kp_pbc_shift
1591 SUBROUTINE wfi_compute_kp_pbc_shift(qs_env, pbc_shift)
1593 INTEGER,
ALLOCATABLE,
DIMENSION(:, :),
INTENT(OUT) :: pbc_shift
1595 INTEGER :: iatom, natom
1596 REAL(kind=
dp),
DIMENSION(3) :: frac_pbc, frac_raw, r_pbc
1600 NULLIFY (cell, particle_set)
1601 CALL get_qs_env(qs_env, cell=cell, particle_set=particle_set)
1602 cpassert(
ASSOCIATED(cell))
1603 cpassert(
ASSOCIATED(particle_set))
1605 natom =
SIZE(particle_set)
1606 ALLOCATE (pbc_shift(3, natom))
1608 r_pbc(1:3) =
pbc(particle_set(iatom)%r(1:3), cell)
1611 pbc_shift(1:3, iatom) = nint(frac_pbc(1:3) - frac_raw(1:3))
1613 END SUBROUTINE wfi_compute_kp_pbc_shift
1624 SUBROUTINE wfi_apply_kp_pbc_phase_fm(rmos, imos, pbc_shift_delta, xk, matrix_template)
1626 INTEGER,
DIMENSION(:, :),
INTENT(IN) :: pbc_shift_delta
1627 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: xk
1630 INTEGER :: iatom, icol, irow, natom, nmo, nrow, &
1632 INTEGER,
DIMENSION(:),
POINTER :: row_blk_size
1633 REAL(kind=
dp) :: ci, cr, i_old, r_old, theta
1634 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: iblock, rblock
1636 cpassert(
ASSOCIATED(rmos))
1637 cpassert(
ASSOCIATED(imos))
1638 cpassert(
ASSOCIATED(matrix_template))
1640 natom =
SIZE(pbc_shift_delta, 2)
1642 NULLIFY (row_blk_size)
1644 cpassert(
SIZE(row_blk_size) >= natom)
1648 nrow = row_blk_size(iatom)
1649 IF (any(pbc_shift_delta(1:3, iatom) /= 0))
THEN
1650 theta =
twopi*sum(xk(1:3)*real(pbc_shift_delta(1:3, iatom), kind=
dp))
1653 ALLOCATE (rblock(nrow, nmo), iblock(nrow, nmo))
1658 r_old = rblock(irow, icol)
1659 i_old = iblock(irow, icol)
1660 rblock(irow, icol) = cr*r_old - ci*i_old
1661 iblock(irow, icol) = ci*r_old + cr*i_old
1666 DEALLOCATE (rblock, iblock)
1668 row_start = row_start + nrow
1670 END SUBROUTINE wfi_apply_kp_pbc_phase_fm
1680 SUBROUTINE wfi_apply_kp_pbc_phase_cfm(cmos, pbc_shift_delta, xk, matrix_template)
1682 INTEGER,
DIMENSION(:, :),
INTENT(IN) :: pbc_shift_delta
1683 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: xk
1686 COMPLEX(KIND=dp) :: phase
1687 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :) :: zblock
1688 INTEGER :: iatom, natom, nmo, nrow, row_start
1689 INTEGER,
DIMENSION(:),
POINTER :: row_blk_size
1690 REAL(kind=
dp) :: theta
1692 cpassert(
ASSOCIATED(matrix_template))
1694 natom =
SIZE(pbc_shift_delta, 2)
1696 NULLIFY (row_blk_size)
1698 cpassert(
SIZE(row_blk_size) >= natom)
1702 nrow = row_blk_size(iatom)
1703 IF (any(pbc_shift_delta(1:3, iatom) /= 0))
THEN
1704 theta =
twopi*sum(xk(1:3)*real(pbc_shift_delta(1:3, iatom), kind=
dp))
1705 phase = cmplx(cos(theta), sin(theta), kind=
dp)
1706 ALLOCATE (zblock(nrow, nmo))
1708 zblock = phase*zblock
1712 row_start = row_start + nrow
1714 END SUBROUTINE wfi_apply_kp_pbc_phase_cfm
1727 SUBROUTINE wfi_extrapolate_ps_aspc_kp(wf_history, qs_env, nvec, io_unit, print_level)
1730 INTEGER,
INTENT(IN) :: nvec, io_unit, print_level
1732 CHARACTER(len=*),
PARAMETER :: routinen =
'wfi_extrapolate_ps_aspc_kp'
1734 INTEGER :: handle, i, ik, ikp, ispin, kplocal, &
1735 method_nr, nao, nmo, nspin
1736 INTEGER,
DIMENSION(2) :: kp_range
1737 LOGICAL :: use_real_wfn
1738 REAL(kind=
dp) :: alpha_coeff
1739 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1740 TYPE(
cp_cfm_type) :: cfm_nao_nmo_work, cmos_1, cmos_i, &
1743 TYPE(
cp_fm_type),
POINTER :: imos, mo_coeff, rmos
1744 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s_kp
1749 method_nr = wf_history%interpolation_method_nr
1751 CALL timeset(routinen, handle)
1752 NULLIFY (kpoints, kp, mo_coeff, rmos, imos, t0_state, t1_state, nmo_nmo_struct, &
1755 CALL get_qs_env(qs_env, kpoints=kpoints, matrix_s_kp=matrix_s_kp)
1756 CALL get_kpoint_info(kpoints, use_real_wfn=use_real_wfn, kp_range=kp_range, xkp=xkp)
1757 kplocal = kp_range(2) - kp_range(1) + 1
1759 IF (use_real_wfn)
THEN
1761 CALL cp_warn(__location__,
"ASPC with k-points requires complex wavefunctions; "// &
1762 "falling back to USE_PREV_WF.")
1764 CALL cp_warn(__location__,
"PS with k-points requires complex wavefunctions; "// &
1765 "falling back to USE_PREV_WF.")
1767 CALL wfi_use_prev_wf_kp(qs_env, io_unit, print_level)
1768 CALL timestop(handle)
1772 kp => kpoints%kp_env(1)%kpoint_env
1773 nspin =
SIZE(kp%mos, 2)
1774 CALL get_mo_set(kp%mos(1, 1), nao=nao, nmo=nmo, mo_coeff=mo_coeff)
1778 WRITE (unit=io_unit, fmt=
"(/,T2,A,/,T3,A,I0)") &
1779 "Parameters for the always stable predictor-corrector (ASPC) method:", &
1780 "ASPC order: ", max(nvec - 2, 0)
1785 CALL cp_cfm_create(cmos_new, mo_coeff%matrix_struct, set_zero=.true.)
1786 CALL cp_cfm_create(cmos_1, mo_coeff%matrix_struct, set_zero=.true.)
1787 CALL cp_cfm_create(cmos_i, mo_coeff%matrix_struct, set_zero=.true.)
1788 CALL cp_cfm_create(cfm_nao_nmo_work, mo_coeff%matrix_struct, set_zero=.true.)
1793 CALL cp_cfm_create(cfm_nao_nmo_work, mo_coeff%matrix_struct)
1797 nrow_global=nmo, ncol_global=nmo)
1799 CALL cp_cfm_create(csc_cfm, nmo_nmo_struct, set_zero=.true.)
1808 alpha_coeff = real(4*nvec - 2, kind=
dp)/real(nvec + 1, kind=
dp)
1810 WRITE (unit=io_unit, fmt=
"(T3,A2,I0,A4,F10.6)")
"B(", 1,
") = ", alpha_coeff
1817 kp => kpoints%kp_env(ikp)%kpoint_env
1819 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos)
1820 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
1821 CALL cp_fm_to_fm(t1_state%wf_kp(ikp, 1, ispin), rmos)
1822 CALL cp_fm_to_fm(t1_state%wf_kp(ikp, 2, ispin), imos)
1832 alpha_coeff = (-1.0_dp)**(i + 1)*real(i, kind=
dp)* &
1835 WRITE (unit=io_unit, fmt=
"(T3,A2,I0,A4,F10.6)")
"B(", i,
") = ", alpha_coeff
1838 alpha_coeff = -1.0_dp*alpha_coeff*real(nvec - i + 1,
dp)/real(i,
dp)
1842 kp => kpoints%kp_env(ikp)%kpoint_env
1844 ik = kp_range(1) + ikp - 1
1845 CALL cp_fm_to_cfm(t1_state%wf_kp(ikp, 1, ispin), t1_state%wf_kp(ikp, 2, ispin), cmos_1)
1846 CALL cp_fm_to_cfm(t0_state%wf_kp(ikp, 1, ispin), t0_state%wf_kp(ikp, 2, ispin), cmos_i)
1850 CALL wfi_apply_kp_pbc_phase_cfm(cmos_1, t0_state%kp_pbc_shift - t1_state%kp_pbc_shift, &
1851 xkp(1:3, ik), matrix_s_kp(1, 1)%matrix)
1855 t0_state%overlap_cfm_kp(ikp), cmos_1,
z_zero, cfm_nao_nmo_work)
1857 cmos_i, cfm_nao_nmo_work,
z_zero, csc_cfm)
1859 cmos_i, csc_cfm,
z_zero, cfm_nao_nmo_work)
1864 CALL wfi_apply_kp_pbc_phase_cfm(cfm_nao_nmo_work, t1_state%kp_pbc_shift - t0_state%kp_pbc_shift, &
1865 xkp(1:3, ik), matrix_s_kp(1, 1)%matrix)
1867 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos)
1868 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
1886 CALL wfi_use_prev_wf_kp(qs_env, 0, print_level, pbc_shift_ref=t1_state%kp_pbc_shift, &
1887 load_snapshot_wf=.false.)
1889 CALL timestop(handle)
1891 END SUBROUTINE wfi_extrapolate_ps_aspc_kp
1903 SUBROUTINE wfi_extrapolate_gext_proj_kp(wf_history, qs_env, nvec, io_unit, print_level)
1906 INTEGER,
INTENT(IN) :: nvec, io_unit, print_level
1908 CHARACTER(len=*),
PARAMETER :: routinen =
'wfi_extrapolate_gext_proj_kp'
1910 INTEGER :: handle, i, igroup, ik, ikp, indx, ispin, &
1911 kplocal, method_nr, nao, nkp, &
1912 nkp_groups, nmo, nspin
1913 INTEGER,
DIMENSION(2) :: kp_range
1914 INTEGER,
DIMENSION(:, :),
POINTER :: kp_dist
1915 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1916 LOGICAL :: my_kpgrp, use_real_wfn
1917 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: coeffs, weight_kp
1918 REAL(kind=
dp),
DIMENSION(:),
POINTER :: wkp
1919 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1921 TYPE(
cp_cfm_type) :: cfm_nao_nmo_work, cmos_1, cmos_i, &
1923 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: csmat_cur
1927 TYPE(
cp_fm_type),
POINTER :: imos, mo_coeff, rmos
1928 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s_kp
1929 TYPE(
dbcsr_type),
POINTER :: cmatrix_db, rmatrix, tmpmat
1939 method_nr = wf_history%interpolation_method_nr
1941 CALL timeset(routinen, handle)
1942 NULLIFY (ao_ao_struct, cell_to_index, cmatrix_db, imos, kp, kpoints, matrix_s_kp, &
1943 mo_coeff, mpools_kp, para_env, para_env_inter_kp, rmatrix, rmos, sab_nl, &
1944 scf_env, t0_state, t1_state, tmpmat, xkp, kp_dist, wkp, nmo_nmo_struct, &
1947 CALL get_qs_env(qs_env, kpoints=kpoints, matrix_s_kp=matrix_s_kp, scf_env=scf_env)
1948 CALL get_kpoint_info(kpoints, use_real_wfn=use_real_wfn, kp_range=kp_range, &
1949 nkp=nkp, xkp=xkp, wkp=wkp, nkp_groups=nkp_groups, &
1950 kp_dist=kp_dist, cell_to_index=cell_to_index, sab_nl=sab_nl, &
1951 mpools=mpools_kp, para_env_inter_kp=para_env_inter_kp)
1952 kplocal = kp_range(2) - kp_range(1) + 1
1954 IF (use_real_wfn)
THEN
1955 CALL cp_warn(__location__,
"GExt with k-points requires complex wavefunctions; "// &
1956 "falling back to USE_PREV_WF.")
1957 CALL wfi_use_prev_wf_kp(qs_env, io_unit, print_level)
1958 CALL timestop(handle)
1962 IF (nvec >= wf_history%memory_depth)
THEN
1963 IF ((qs_env%scf_control%max_scf_hist /= 0) .AND. &
1964 (qs_env%scf_control%eps_scf_hist /= 0))
THEN
1965 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1966 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1967 qs_env%scf_control%outer_scf%have_scf = .false.
1968 ELSE IF (qs_env%scf_control%max_scf_hist /= 0)
THEN
1969 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1970 qs_env%scf_control%outer_scf%have_scf = .false.
1971 ELSE IF (qs_env%scf_control%eps_scf_hist /= 0)
THEN
1972 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1976 kp => kpoints%kp_env(1)%kpoint_env
1977 nspin =
SIZE(kp%mos, 2)
1978 CALL get_mo_set(kp%mos(1, 1), nao=nao, nmo=nmo, mo_coeff=mo_coeff)
1982 ALLOCATE (rmatrix, cmatrix_db, tmpmat)
1983 CALL dbcsr_create(rmatrix, template=matrix_s_kp(1, 1)%matrix, matrix_type=dbcsr_type_symmetric)
1984 CALL dbcsr_create(cmatrix_db, template=matrix_s_kp(1, 1)%matrix, matrix_type=dbcsr_type_antisymmetric)
1985 CALL dbcsr_create(tmpmat, template=matrix_s_kp(1, 1)%matrix, matrix_type=dbcsr_type_no_symmetry)
1989 CALL mpools_get(mpools_kp, ao_ao_fm_pools=ao_ao_fm_pools_kp)
1993 para_env => kpoints%blacs_env_all%para_env
1994 ALLOCATE (info(kplocal*nkp_groups, 2))
1995 ALLOCATE (csmat_cur(kplocal), weight_kp(kplocal))
1998 weight_kp(ikp) = wkp(kp_range(1) + ikp - 1)
2003 DO igroup = 1, nkp_groups
2004 ik = kp_dist(1, igroup) + ikp - 1
2005 my_kpgrp = (ik >= kp_range(1) .AND. ik <= kp_range(2))
2010 CALL rskp_transform(rmatrix=rmatrix, cmatrix=cmatrix_db, rsmat=matrix_s_kp, &
2011 ispin=1, xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
2029 DO igroup = 1, nkp_groups
2030 ik = kp_dist(1, igroup) + ikp - 1
2031 my_kpgrp = (ik >= kp_range(1) .AND. ik <= kp_range(2))
2042 DO indx = 1, kplocal*nkp_groups
2047 ALLOCATE (coeffs(nvec))
2049 CALL diff_fitting(wf_history, matrix_s_kp(1, 1)%matrix, coeffs, nvec, &
2050 1e-4_dp, io_unit, print_level, current_overlap_kp=csmat_cur, &
2051 kpoint_weights=weight_kp, para_env_inter_kp=para_env_inter_kp)
2053 CALL tr_fitting(wf_history, matrix_s_kp(1, 1)%matrix, coeffs, nvec, &
2054 1e-4_dp, io_unit, print_level, current_overlap_kp=csmat_cur, &
2055 kpoint_weights=weight_kp, para_env_inter_kp=para_env_inter_kp)
2062 CALL cp_cfm_create(cfm_nao_nmo_work, mo_coeff%matrix_struct)
2064 nrow_global=nmo, ncol_global=nmo)
2070 kp => kpoints%kp_env(ikp)%kpoint_env
2072 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos)
2073 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
2082 kp => kpoints%kp_env(ikp)%kpoint_env
2083 ik = kp_range(1) + ikp - 1
2085 CALL cp_fm_to_cfm(t1_state%wf_kp(ikp, 1, ispin), t1_state%wf_kp(ikp, 2, ispin), cmos_1)
2086 CALL cp_fm_to_cfm(t0_state%wf_kp(ikp, 1, ispin), t0_state%wf_kp(ikp, 2, ispin), cmos_i)
2088 CALL wfi_apply_kp_pbc_phase_cfm(cmos_1, t0_state%kp_pbc_shift - t1_state%kp_pbc_shift, &
2089 xkp(1:3, ik), matrix_s_kp(1, 1)%matrix)
2092 t0_state%overlap_cfm_kp(ikp), cmos_1,
z_zero, cfm_nao_nmo_work)
2094 cmos_i, cfm_nao_nmo_work,
z_zero, csc_cfm)
2096 cmos_i, csc_cfm,
z_zero, cfm_nao_nmo_work)
2098 CALL wfi_apply_kp_pbc_phase_cfm(cfm_nao_nmo_work, t1_state%kp_pbc_shift - t0_state%kp_pbc_shift, &
2099 xkp(1:3, ik), matrix_s_kp(1, 1)%matrix)
2101 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos)
2102 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
2116 CALL wfi_use_prev_wf_kp(qs_env, 0, print_level, pbc_shift_ref=t1_state%kp_pbc_shift, &
2117 load_snapshot_wf=.false.)
2122 DEALLOCATE (csmat_cur, coeffs, weight_kp, info)
2128 CALL timestop(handle)
2130 END SUBROUTINE wfi_extrapolate_gext_proj_kp
2141 ELEMENTAL SUBROUTINE wfi_set_history_variables(qs_env, nvec)
2143 INTEGER,
INTENT(IN) :: nvec
2145 IF (nvec >= qs_env%wf_history%memory_depth)
THEN
2146 IF ((qs_env%scf_control%max_scf_hist /= 0) .AND. (qs_env%scf_control%eps_scf_hist /= 0))
THEN
2147 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
2148 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
2149 qs_env%scf_control%outer_scf%have_scf = .false.
2150 ELSE IF (qs_env%scf_control%max_scf_hist /= 0)
THEN
2151 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
2152 qs_env%scf_control%outer_scf%have_scf = .false.
2153 ELSE IF (qs_env%scf_control%eps_scf_hist /= 0)
THEN
2154 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
2155 qs_env%scf_control%outer_scf%eps_scf = qs_env%scf_control%eps_scf_hist
2159 END SUBROUTINE wfi_set_history_variables
2173 REAL(kind=
dp),
INTENT(in) :: dt
2175 cpassert(
ASSOCIATED(wf_history))
2176 cpassert(wf_history%ref_count > 0)
2177 cpassert(
ASSOCIATED(qs_env))
2179 wf_history%snapshot_count = wf_history%snapshot_count + 1
2180 IF (wf_history%memory_depth > 0)
THEN
2181 wf_history%last_state_index =
modulo(wf_history%snapshot_count, &
2182 wf_history%memory_depth) + 1
2183 CALL wfs_update(snapshot=wf_history%past_states &
2184 (wf_history%last_state_index)%snapshot, wf_history=wf_history, &
2185 qs_env=qs_env, dt=dt)
2201 INTEGER,
INTENT(in),
OPTIONAL :: n_col
2203 CHARACTER(len=*),
PARAMETER :: routinen =
'reorthogonalize_vectors'
2205 INTEGER :: handle, my_n_col
2206 LOGICAL :: has_unit_metric, &
2207 ortho_contains_cholesky, &
2216 NULLIFY (scf_env, scf_control, maxao_maxmo_fm_pool, matrix_s, mpools, dft_control)
2217 CALL timeset(routinen, handle)
2219 cpassert(
ASSOCIATED(qs_env))
2222 IF (
PRESENT(n_col)) my_n_col = n_col
2225 scf_control=scf_control, &
2226 matrix_s=matrix_s, &
2227 dft_control=dft_control)
2228 CALL mpools_get(mpools, maxao_maxmo_fm_pool=maxao_maxmo_fm_pool)
2229 IF (
ASSOCIATED(scf_env))
THEN
2230 ortho_contains_cholesky = (scf_env%method /=
ot_method_nr) .AND. &
2231 (scf_env%cholesky_method > 0) .AND. &
2232 ASSOCIATED(scf_env%ortho)
2234 ortho_contains_cholesky = .false.
2237 CALL get_qs_env(qs_env, has_unit_metric=has_unit_metric)
2238 smearing_is_used = .false.
2239 IF (dft_control%smear)
THEN
2240 smearing_is_used = .true.
2243 IF (has_unit_metric)
THEN
2245 ELSE IF (smearing_is_used)
THEN
2247 matrix_s=matrix_s(1)%matrix)
2248 ELSE IF (ortho_contains_cholesky)
THEN
2250 ortho=scf_env%ortho)
2254 CALL timestop(handle)
2268 CHARACTER(len=*),
PARAMETER :: routinen =
'wfi_purge_history'
2270 INTEGER :: handle, io_unit, print_level
2275 NULLIFY (dft_control, wf_history)
2277 CALL timeset(routinen, handle)
2279 print_level = logger%iter_info%print_level
2281 extension=
".scfLog")
2283 cpassert(
ASSOCIATED(qs_env))
2284 cpassert(
ASSOCIATED(qs_env%wf_history))
2285 cpassert(qs_env%wf_history%ref_count > 0)
2286 CALL get_qs_env(qs_env, dft_control=dft_control)
2288 SELECT CASE (qs_env%wf_history%interpolation_method_nr)
2295 IF (qs_env%wf_history%snapshot_count >= 2)
THEN
2296 IF (debug_this_module .AND. io_unit > 0)
THEN
2297 WRITE (io_unit, fmt=
"(T2,A)")
"QS| Purging WFN history"
2299 CALL wfi_create(wf_history, interpolation_method_nr= &
2300 dft_control%qs_control%wf_interpolation_method_nr, &
2301 extrapolation_order=dft_control%qs_control%wf_extrapolation_order, &
2302 has_unit_metric=qs_env%has_unit_metric)
2304 wf_history=wf_history)
2306 CALL wfi_update(qs_env%wf_history, qs_env=qs_env, dt=1.0_dp)
2309 cpabort(
"Unknown extrapolation method.")
2311 CALL timestop(handle)
2334 SUBROUTINE diff_fitting(wf_history, current_overlap, coeffs, nvec, eps, io_unit, print_level, &
2335 current_overlap_kp, kpoint_weights, para_env_inter_kp)
2337 TYPE(
dbcsr_type),
INTENT(IN) :: current_overlap
2338 INTEGER,
INTENT(IN) :: nvec
2339 REAL(kind=
dp),
INTENT(OUT) :: coeffs(nvec)
2340 REAL(kind=
dp),
INTENT(IN) :: eps
2341 INTEGER,
INTENT(IN) :: io_unit, print_level
2343 OPTIONAL :: current_overlap_kp
2344 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN),
OPTIONAL :: kpoint_weights
2347 COMPLEX(KIND=dp) :: ztrace
2348 INTEGER :: i, icol_local, ikp, info, irow_local, j
2349 REAL(kind=
dp) :: error, norm_ref, weight
2350 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: b
2351 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: a
2352 TYPE(
cp_cfm_type) :: target_diff_cfm, tmp_conj_cfm, &
2353 tmp_i_cfm, tmp_j_cfm
2354 TYPE(
dbcsr_type) :: target_diff, tmp_i, tmp_j, tmp_k
2358 cpabort(
"Not enough vectors to do the fitting")
2359 ELSE IF (nvec == 1)
THEN
2364 IF (
PRESENT(current_overlap_kp))
THEN
2365 ALLOCATE (a(nvec - 1, nvec - 1), b(nvec - 1))
2370 CALL cp_cfm_create(target_diff_cfm, current_overlap_kp(1)%matrix_struct)
2371 CALL cp_cfm_create(tmp_i_cfm, current_overlap_kp(1)%matrix_struct)
2372 CALL cp_cfm_create(tmp_j_cfm, current_overlap_kp(1)%matrix_struct)
2373 CALL cp_cfm_create(tmp_conj_cfm, current_overlap_kp(1)%matrix_struct)
2375 DO ikp = 1,
SIZE(current_overlap_kp)
2377 IF (
PRESENT(kpoint_weights)) weight = kpoint_weights(ikp)
2379 CALL cp_cfm_to_cfm(current_overlap_kp(ikp), target_diff_cfm)
2381 ref_state%overlap_cfm_kp(ikp))
2386 ref_state%overlap_cfm_kp(ikp))
2388 DO icol_local = 1,
SIZE(tmp_conj_cfm%local_data, 2)
2389 DO irow_local = 1,
SIZE(tmp_conj_cfm%local_data, 1)
2390 tmp_conj_cfm%local_data(irow_local, icol_local) = &
2391 conjg(tmp_conj_cfm%local_data(irow_local, icol_local))
2394 CALL cp_cfm_trace(tmp_conj_cfm, target_diff_cfm, ztrace)
2395 b(i - 1) = b(i - 1) + weight*real(ztrace, kind=
dp)
2401 ref_state%overlap_cfm_kp(ikp))
2403 a(j - 1, i - 1) = a(j - 1, i - 1) + weight*real(ztrace, kind=
dp)
2410 a(i - 1, j - 1) = a(j - 1, i - 1)
2414 IF (
PRESENT(para_env_inter_kp))
THEN
2415 IF (
ASSOCIATED(para_env_inter_kp))
THEN
2416 CALL para_env_inter_kp%sum(a)
2417 CALL para_env_inter_kp%sum(b)
2422 a(i, i) = a(i, i) + eps**2
2425 CALL dposv(
'u', nvec - 1, 1, a, nvec - 1, b, nvec - 1, info)
2427 cpabort(
"DPOSV failed.")
2430 coeffs(1) = 1.0_dp - sum(b)
2431 coeffs(2:nvec) = b(:)
2436 DO ikp = 1,
SIZE(current_overlap_kp)
2438 IF (
PRESENT(kpoint_weights)) weight = kpoint_weights(ikp)
2443 state%overlap_cfm_kp(ikp))
2446 DO icol_local = 1,
SIZE(tmp_conj_cfm%local_data, 2)
2447 DO irow_local = 1,
SIZE(tmp_conj_cfm%local_data, 1)
2448 tmp_conj_cfm%local_data(irow_local, icol_local) = &
2449 conjg(tmp_conj_cfm%local_data(irow_local, icol_local))
2453 error = error + weight*real(ztrace, kind=
dp)
2454 CALL cp_cfm_to_cfm(ref_state%overlap_cfm_kp(ikp), tmp_conj_cfm)
2455 DO icol_local = 1,
SIZE(tmp_conj_cfm%local_data, 2)
2456 DO irow_local = 1,
SIZE(tmp_conj_cfm%local_data, 1)
2457 tmp_conj_cfm%local_data(irow_local, icol_local) = &
2458 conjg(tmp_conj_cfm%local_data(irow_local, icol_local))
2461 CALL cp_cfm_trace(tmp_conj_cfm, ref_state%overlap_cfm_kp(ikp), ztrace)
2462 norm_ref = norm_ref + weight*real(ztrace, kind=
dp)
2464 IF (
PRESENT(para_env_inter_kp))
THEN
2465 IF (
ASSOCIATED(para_env_inter_kp))
THEN
2466 CALL para_env_inter_kp%sum(error)
2467 CALL para_env_inter_kp%sum(norm_ref)
2470 IF (io_unit > 0)
THEN
2471 WRITE (unit=io_unit, fmt=
"(/,T2,A,F20.10)")
"GEXT overlap fitting error:", &
2472 sqrt(error/max(norm_ref, tiny(1.0_dp)))
2484 ALLOCATE (a(nvec - 1, nvec - 1), b(nvec - 1))
2490 CALL dbcsr_copy(target_diff, current_overlap)
2491 CALL dbcsr_add(target_diff, ref_state%overlap, 1.0_dp, -1.0_dp)
2500 CALL dbcsr_add(tmp_i, ref_state%overlap, 1.0_dp, -1.0_dp)
2501 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, tmp_i, target_diff, 0.0_dp, tmp_k)
2507 CALL dbcsr_add(tmp_j, ref_state%overlap, 1.0_dp, -1.0_dp)
2508 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, tmp_i, tmp_j, 0.0_dp, tmp_k)
2510 a(i - 1, j - 1) = a(j - 1, i - 1)
2516 a(i, i) = a(i, i) + eps**2
2520 CALL dposv(
'u', nvec - 1, 1, a, nvec - 1, b, nvec - 1, info)
2522 cpabort(
"DPOSV failed.")
2526 coeffs(1) = 1.0_dp - sum(b)
2527 coeffs(2:nvec) = b(:)
2535 CALL dbcsr_add(tmp_i, state%overlap, 1.0_dp, -coeffs(i))
2538 IF (io_unit > 0)
THEN
2539 WRITE (unit=io_unit, fmt=
"(/,T2,A,F20.10)")
"GEXT overlap fitting error:", error
2550 END SUBROUTINE diff_fitting
2572 SUBROUTINE tr_fitting(wf_history, current_overlap, coeffs, nvec, eps, io_unit, print_level, &
2573 current_overlap_kp, kpoint_weights, para_env_inter_kp)
2575 TYPE(
dbcsr_type),
INTENT(IN) :: current_overlap
2576 INTEGER,
INTENT(IN) :: nvec
2577 REAL(kind=
dp),
INTENT(OUT) :: coeffs(nvec)
2578 REAL(kind=
dp),
INTENT(IN) :: eps
2579 INTEGER,
INTENT(IN) :: io_unit, print_level
2581 OPTIONAL :: current_overlap_kp
2582 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN),
OPTIONAL :: kpoint_weights
2585 COMPLEX(KIND=dp) :: ztrace
2586 INTEGER :: i, icol_local, ikp, info, irow_local, j, &
2588 REAL(kind=
dp) :: error, norm_ref, weight
2589 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: b
2590 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: a
2591 TYPE(
cp_cfm_type) :: target_overlap_cfm, tmp_conj_cfm, &
2592 tmp_i_cfm, tmp_j_cfm
2593 TYPE(
dbcsr_type) :: target_overlap, tmp_i, tmp_j, tmp_k
2597 cpabort(
"Not enough vectors to do the fitting")
2598 ELSE IF (nvec == 1)
THEN
2603 IF (mod(nvec, 2) == 0)
THEN
2609 IF (
PRESENT(current_overlap_kp))
THEN
2610 ALLOCATE (a(ntr, ntr), b(ntr))
2615 CALL cp_cfm_create(target_overlap_cfm, current_overlap_kp(1)%matrix_struct)
2616 CALL cp_cfm_create(tmp_i_cfm, current_overlap_kp(1)%matrix_struct)
2617 CALL cp_cfm_create(tmp_j_cfm, current_overlap_kp(1)%matrix_struct)
2618 CALL cp_cfm_create(tmp_conj_cfm, current_overlap_kp(1)%matrix_struct)
2620 DO ikp = 1,
SIZE(current_overlap_kp)
2622 IF (
PRESENT(kpoint_weights)) weight = kpoint_weights(ikp)
2624 CALL cp_cfm_to_cfm(current_overlap_kp(ikp), target_overlap_cfm)
2633 DO icol_local = 1,
SIZE(tmp_conj_cfm%local_data, 2)
2634 DO irow_local = 1,
SIZE(tmp_conj_cfm%local_data, 1)
2635 tmp_conj_cfm%local_data(irow_local, icol_local) = &
2636 conjg(tmp_conj_cfm%local_data(irow_local, icol_local))
2639 CALL cp_cfm_trace(tmp_conj_cfm, target_overlap_cfm, ztrace)
2640 b(i) = b(i) + weight*real(ztrace, kind=
dp)
2647 a(j, i) = a(j, i) + weight*real(ztrace, kind=
dp)
2658 IF (
PRESENT(para_env_inter_kp))
THEN
2659 IF (
ASSOCIATED(para_env_inter_kp))
THEN
2660 CALL para_env_inter_kp%sum(a)
2661 CALL para_env_inter_kp%sum(b)
2666 a(i, i) = a(i, i) + eps**2
2669 CALL dposv(
'u', ntr, 1, a, ntr, b, ntr, info)
2671 cpabort(
"DPOSV failed.")
2675 coeffs(nvec) = -1.0_dp
2677 coeffs(i) = coeffs(i) + b(i)
2678 coeffs(nvec - i) = coeffs(nvec - i) + b(i)
2684 DO ikp = 1,
SIZE(current_overlap_kp)
2686 IF (
PRESENT(kpoint_weights)) weight = kpoint_weights(ikp)
2691 state%overlap_cfm_kp(ikp))
2694 DO icol_local = 1,
SIZE(tmp_conj_cfm%local_data, 2)
2695 DO irow_local = 1,
SIZE(tmp_conj_cfm%local_data, 1)
2696 tmp_conj_cfm%local_data(irow_local, icol_local) = &
2697 conjg(tmp_conj_cfm%local_data(irow_local, icol_local))
2701 error = error + weight*real(ztrace, kind=
dp)
2702 CALL cp_cfm_to_cfm(ref_state%overlap_cfm_kp(ikp), tmp_conj_cfm)
2703 DO icol_local = 1,
SIZE(tmp_conj_cfm%local_data, 2)
2704 DO irow_local = 1,
SIZE(tmp_conj_cfm%local_data, 1)
2705 tmp_conj_cfm%local_data(irow_local, icol_local) = &
2706 conjg(tmp_conj_cfm%local_data(irow_local, icol_local))
2709 CALL cp_cfm_trace(tmp_conj_cfm, ref_state%overlap_cfm_kp(ikp), ztrace)
2710 norm_ref = norm_ref + weight*real(ztrace, kind=
dp)
2712 IF (
PRESENT(para_env_inter_kp))
THEN
2713 IF (
ASSOCIATED(para_env_inter_kp))
THEN
2714 CALL para_env_inter_kp%sum(error)
2715 CALL para_env_inter_kp%sum(norm_ref)
2718 IF (io_unit > 0)
THEN
2719 WRITE (unit=io_unit, fmt=
"(/,T2,A,F20.10)")
"GEXT overlap fitting error:", &
2720 sqrt(error/max(norm_ref, tiny(1.0_dp)))
2732 ALLOCATE (a(ntr, ntr), b(ntr))
2738 CALL dbcsr_copy(target_overlap, current_overlap)
2739 CALL dbcsr_add(target_overlap, ref_state%overlap, 1.0_dp, 1.0_dp)
2749 CALL dbcsr_add(tmp_i, state%overlap, 1.0_dp, 1.0_dp)
2758 CALL dbcsr_add(tmp_j, state%overlap, 1.0_dp, 1.0_dp)
2759 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, tmp_i, tmp_j, 0.0_dp, tmp_k)
2767 a(i, i) = a(i, i) + eps**2
2771 CALL dposv(
'u', ntr, 1, a, ntr, b, ntr, info)
2773 cpabort(
"DPOSV failed.")
2778 coeffs(nvec) = -1.0_dp
2780 coeffs(i) = coeffs(i) + b(i)
2781 coeffs(nvec - i) = coeffs(nvec - i) + b(i)
2790 CALL dbcsr_add(tmp_i, state%overlap, 1.0_dp, -coeffs(i))
2793 IF (io_unit > 0)
THEN
2794 WRITE (unit=io_unit, fmt=
"(/,T2,A,F20.10)")
"GEXT overlap fitting error:", error
2805 END SUBROUTINE tr_fitting
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public vandevondele2005a
integer, save, public kuhne2007
integer, save, public kolafa2004
Handles all functions related to the CELL.
subroutine, public real_to_scaled(s, r, cell)
Transform real to scaled cell coordinates. s=h_inv*r.
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_gemm(transa, transb, m, n, k, alpha, matrix_a, matrix_b, beta, matrix_c, a_first_col, a_first_row, b_first_col, b_first_row, c_first_col, c_first_row)
Performs one of the matrix-matrix operations: matrix_c = alpha * op1( matrix_a ) * op2( matrix_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_triangular_multiply(triangular_matrix, matrix_b, side, transa_tr, invert_tr, uplo_tr, unit_diag_tr, n_rows, n_cols, alpha)
Multiplies in place by a triangular matrix: matrix_b = alpha op(triangular_matrix) matrix_b or (if si...
subroutine, public cp_cfm_column_scale(matrix_a, scaling)
Scales columns of the full matrix by corresponding factors.
subroutine, public cp_cfm_trace(matrix_a, matrix_b, trace)
Returns the trace of matrix_a^T matrix_b, i.e sum_{i,j}(matrix_a(i,j)*matrix_b(i,j)) .
various cholesky decomposition related routines
subroutine, public cp_cfm_cholesky_decompose(matrix, n, info_out)
Used to replace a symmetric positive definite matrix M with its Cholesky decomposition U: M = U^T * U...
used for collecting diagonalization schemes available for cp_cfm_type
subroutine, public cp_cfm_heevd(matrix, eigenvectors, eigenvalues)
Perform a diagonalisation of a complex matrix.
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
Extract a sub-matrix from the full matrix: op(target_m)(1:n_rows,1:n_cols) = fm(start_row:start_row+n...
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_fm_to_cfm(msourcer, msourcei, mtarget)
Construct a complex full matrix by taking its real and imaginary parts from two separate real-value f...
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_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, matrix_struct, para_env)
Returns information about a full matrix.
subroutine, public cp_cfm_set_submatrix(matrix, new_values, start_row, start_col, n_rows, n_cols, alpha, beta, transpose)
Set a sub-matrix of the full matrix: matrix(start_row:start_row+n_rows,start_col:start_col+n_cols) = ...
subroutine, public cp_cfm_set_all(matrix, alpha, beta)
Set all elements of the full matrix to alpha. Besides, set all diagonal matrix elements to beta (if g...
subroutine, public cp_cfm_to_fm(msource, mtargetr, mtargeti)
Copy real and imaginary parts of a complex full matrix into separate real-value full matrices.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
subroutine, public dbcsr_desymmetrize(matrix_a, matrix_b)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_multiply(transa, transb, alpha, matrix_a, matrix_b, beta, matrix_c, first_row, last_row, first_column, last_column, first_k, last_k, retain_sparsity, filter_eps, flop)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
subroutine, public dbcsr_trace(matrix, trace)
Computes the trace of the given matrix, also known as the sum of its diagonal elements.
real(dp) function, public dbcsr_frobenius_norm(matrix)
Compute the frobenius norm of a dbcsr matrix.
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.
Basic linear algebra operations for full matrices.
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_scale(alpha, matrix_a)
scales a matrix matrix_a = alpha * matrix_b
pool for for elements that are retained and released
subroutine, public fm_pool_create_fm(pool, element, name)
returns an element, allocating it if none is in the pool
subroutine, public fm_pool_give_back_fm(pool, element)
returns the element to the pool
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_start_copy_general(source, destination, para_env, info)
Initiates the copy operation: get distribution data, post MPI isend and irecvs.
subroutine, public cp_fm_cleanup_copy_general(info)
Completes the copy operation: wait for comms clean up MPI state.
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_set_submatrix(fm, new_values, start_row, start_col, n_rows, n_cols, alpha, beta, transpose)
sets a submatrix of a full matrix fm(start_row:start_row+n_rows,start_col:start_col+n_cols) = alpha*o...
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.
subroutine, public cp_fm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
gets a submatrix of a full matrix op(target_m)(1:n_rows,1:n_cols) =fm(start_row:start_row+n_rows,...
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
integer, parameter, public low_print_level
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
Defines the basic variable types.
integer, parameter, public dp
Routines needed for kpoint calculation.
subroutine, public rskp_transform(rmatrix, cmatrix, rsmat, ispin, xkp, cell_to_index, sab_nl, is_complex, rs_sign)
Transformation of real space matrices to a kpoint.
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.
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
Collection of simple mathematical functions and subroutines.
elemental real(kind=dp) function, public binomial(n, k)
The binomial coefficient n over k for 0 <= k <= n is calculated, otherwise zero is returned.
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
container for various plainwaves related things
subroutine, public pw_env_get(pw_env, pw_pools, cube_info, gridlevel_info, auxbas_pw_pool, auxbas_grid, auxbas_rs_desc, auxbas_rs_grid, rs_descs, rs_grids, xc_pw_pool, vdw_pw_pool, poisson_env, interp_section)
returns the various attributes of the pw env
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
collects routines that calculate density matrices
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 set_qs_env(qs_env, super_cell, mos, qmmm, qmmm_periodic, mimic, ewald_env, ewald_pw, mpools, rho_external, external_vxc, mask, scf_control, rel_control, qs_charges, ks_env, ks_qmmm_env, wf_history, scf_env, active_space, input, oce, rho_atom_set, rho0_atom_set, rho0_mpole, run_rtp, rtp, rhoz_set, rhoz_tot, ecoul_1c, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, efield, rhoz_cneo_set, linres_control, xas_env, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, ls_scf_env, do_transport, transport_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, harris_env, gcp_env, mp2_env, bs_env, kg_env, force, kpoints, wanniercentres, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Set the QUICKSTEP environment.
Methods for preparing and committing k-point orbital states to the QS environment.
subroutine, public qs_kpoint_state_commit(qs_env, update_occupations, separate_spin_occupations, fixed_occupations)
Rebuilds the physical density from the current k-point orbitals and occupations.
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)
collects routines that perform operations directly related to MOs
subroutine, public make_basis_simple(vmatrix, ncol)
given a set of vectors, return an orthogonal (C^T C == 1) set spanning the same space (notice,...
subroutine, public make_basis_lowdin(vmatrix, ncol, matrix_s)
return a set of S orthonormal vectors (C^T S C == 1) where a Loedwin transformation is applied to kee...
subroutine, public make_basis_cholesky(vmatrix, ncol, ortho)
return a set of S orthonormal vectors (C^T S C == 1) where the cholesky decomposed form of S is passe...
subroutine, public make_basis_sm(vmatrix, ncol, matrix_s)
returns an S-orthonormal basis v (v^T S v ==1)
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.
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 definitions of the scf types
integer, parameter, public ot_method_nr
Storage of past states of the qs_env. Methods to interpolate (or actually normally extrapolate) the n...
subroutine, public wfi_create_for_kp(wf_history)
Adapts wf_history storage flags for k-point calculations. For ASPC, switches from Gamma WFN storage t...
subroutine, public wfi_purge_history(qs_env)
purges wf_history retaining only the latest snapshot
character(len=30) function, public wfi_get_method_label(method_nr)
returns a string describing the interpolation method
subroutine, public reorthogonalize_vectors(qs_env, v_matrix, n_col)
reorthogonalizes the mos
subroutine, public wfi_update(wf_history, qs_env, dt)
updates the snapshot buffer, taking a new snapshot
subroutine, public wfi_extrapolate(wf_history, qs_env, dt, extrapolation_method_nr, orthogonal_wf)
calculates the new starting state for the scf for the next wf optimization
subroutine, public wfi_create(wf_history, interpolation_method_nr, extrapolation_order, has_unit_metric)
...
interpolate the wavefunctions to speed up the convergence when doing MD
type(qs_wf_snapshot_type) function, pointer, public wfi_get_snapshot(wf_history, wf_index)
returns a snapshot, the first being the latest snapshot
subroutine, public wfi_release(wf_history)
releases a wf_history of a wavefunction (see doc/ReferenceCounting.html)
parameters that control an scf iteration
Type defining parameters related to the simulation cell.
Represent a complex full matrix.
to create arrays of pools
represent a pool of elements with the same structure
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
contained for different pw related things
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
container for the pools of matrixes used by qs
keeps the density in various representations, keeping track of which ones are valid.
keeps track of the previous wavefunctions and can extrapolate them for the next step of md
represent a past snapshot of the wavefunction. some elements might not be associated (to spare memory...