44 dbcsr_type_antisymmetric, dbcsr_type_no_symmetry, dbcsr_type_symmetric
124#include "./base/base_uses.f90"
129 LOGICAL,
PRIVATE,
PARAMETER :: debug_this_module = .true.
130 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'qs_wf_history_methods'
146 SUBROUTINE wfs_create(snapshot)
147 TYPE(qs_wf_snapshot_type),
INTENT(OUT) :: snapshot
149 NULLIFY (snapshot%wf, snapshot%rho_r, &
150 snapshot%rho_g, snapshot%rho_ao, snapshot%rho_ao_kp, &
151 snapshot%overlap, snapshot%wf_kp, snapshot%overlap_cfm_kp, &
152 snapshot%kp_pbc_shift, snapshot%rho_frozen)
154 END SUBROUTINE wfs_create
167 SUBROUTINE wfs_update(snapshot, wf_history, qs_env, dt)
168 TYPE(qs_wf_snapshot_type),
POINTER :: snapshot
169 TYPE(qs_wf_history_type),
POINTER :: wf_history
170 TYPE(qs_environment_type),
POINTER :: qs_env
171 REAL(KIND=
dp),
INTENT(in),
OPTIONAL :: dt
173 CHARACTER(len=*),
PARAMETER :: routineN =
'wfs_update'
175 INTEGER :: handle, ic, igroup, ik, ikp, img, &
176 indx_ft, ispin, kplocal, nc, nimg, &
177 nkp_all, nkp_grps, nspin_kp, nspins
178 INTEGER,
DIMENSION(2) :: kp_range
179 INTEGER,
DIMENSION(:, :),
POINTER :: kp_dist
180 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
182 REAL(KIND=
dp),
DIMENSION(:, :),
POINTER :: xkp
183 TYPE(cell_type),
POINTER :: cell
184 TYPE(copy_info_type),
ALLOCATABLE,
DIMENSION(:, :) :: info_ft
185 TYPE(cp_fm_pool_p_type),
DIMENSION(:),
POINTER :: ao_ao_fm_pools, ao_mo_pools
186 TYPE(cp_fm_struct_type),
POINTER :: ao_ao_struct_ft
187 TYPE(cp_fm_type) :: fmdummy_ft, fmlocal_ft
188 TYPE(cp_fm_type),
POINTER :: mo_coeff
189 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s, rho_ao
190 TYPE(dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s_kp, rho_ao_kp
191 TYPE(dbcsr_type),
POINTER :: cmat_ft, rmat_ft, tmpmat_ft
192 TYPE(dft_control_type),
POINTER :: dft_control
193 TYPE(kpoint_env_type),
POINTER :: kp
194 TYPE(kpoint_type),
POINTER :: kpoints
195 TYPE(mo_set_type),
DIMENSION(:),
POINTER :: mos
196 TYPE(mp_para_env_type),
POINTER :: para_env_ft
197 TYPE(neighbor_list_set_p_type),
DIMENSION(:), &
199 TYPE(particle_type),
DIMENSION(:),
POINTER :: particle_set
200 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho_g
201 TYPE(pw_env_type),
POINTER :: pw_env
202 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
203 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho_r
204 TYPE(qs_matrix_pools_type),
POINTER :: mpools_kp
205 TYPE(qs_rho_type),
POINTER :: rho
206 TYPE(qs_scf_env_type),
POINTER :: scf_env
208 CALL timeset(routinen, handle)
210 NULLIFY (pw_env, auxbas_pw_pool, ao_mo_pools, ao_ao_fm_pools, dft_control, mos, mo_coeff, &
211 rho, rho_r, rho_g, rho_ao, matrix_s, matrix_s_kp, kpoints, kp, cell, &
212 particle_set, kp_dist, cell_to_index, xkp, sab_nl, scf_env, mpools_kp, para_env_ft, &
213 rmat_ft, cmat_ft, tmpmat_ft, ao_ao_struct_ft)
215 dft_control=dft_control, rho=rho, cell=cell, particle_set=particle_set)
216 CALL mpools_get(qs_env%mpools, ao_mo_fm_pools=ao_mo_pools)
217 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
219 cpassert(
ASSOCIATED(wf_history))
220 cpassert(
ASSOCIATED(dft_control))
221 IF (.NOT.
ASSOCIATED(snapshot))
THEN
223 CALL wfs_create(snapshot)
225 cpassert(wf_history%ref_count > 0)
227 nspins = dft_control%nspins
229 IF (
PRESENT(dt)) snapshot%dt = dt
230 IF (wf_history%store_wf)
THEN
232 IF (.NOT.
ASSOCIATED(snapshot%wf))
THEN
235 cpassert(nspins ==
SIZE(snapshot%wf))
238 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff)
245 IF (wf_history%store_rho_r)
THEN
247 cpassert(
ASSOCIATED(rho_r))
248 IF (.NOT.
ASSOCIATED(snapshot%rho_r))
THEN
249 ALLOCATE (snapshot%rho_r(nspins))
251 CALL auxbas_pw_pool%create_pw(snapshot%rho_r(ispin))
255 CALL pw_copy(rho_r(ispin), snapshot%rho_r(ispin))
257 ELSE IF (
ASSOCIATED(snapshot%rho_r))
THEN
258 DO ispin = 1,
SIZE(snapshot%rho_r)
259 CALL auxbas_pw_pool%give_back_pw(snapshot%rho_r(ispin))
261 DEALLOCATE (snapshot%rho_r)
264 IF (wf_history%store_rho_g)
THEN
266 cpassert(
ASSOCIATED(rho_g))
267 IF (.NOT.
ASSOCIATED(snapshot%rho_g))
THEN
268 ALLOCATE (snapshot%rho_g(nspins))
270 CALL auxbas_pw_pool%create_pw(snapshot%rho_g(ispin))
274 CALL pw_copy(rho_g(ispin), snapshot%rho_g(ispin))
276 ELSE IF (
ASSOCIATED(snapshot%rho_g))
THEN
277 DO ispin = 1,
SIZE(snapshot%rho_g)
278 CALL auxbas_pw_pool%give_back_pw(snapshot%rho_g(ispin))
280 DEALLOCATE (snapshot%rho_g)
283 IF (
ASSOCIATED(snapshot%rho_ao))
THEN
287 IF (wf_history%store_rho_ao)
THEN
289 cpassert(
ASSOCIATED(rho_ao))
293 ALLOCATE (snapshot%rho_ao(ispin)%matrix)
294 CALL dbcsr_copy(snapshot%rho_ao(ispin)%matrix, rho_ao(ispin)%matrix)
298 IF (
ASSOCIATED(snapshot%rho_ao_kp))
THEN
302 IF (wf_history%store_rho_ao_kp)
THEN
304 cpassert(
ASSOCIATED(rho_ao_kp))
306 nimg = dft_control%nimages
310 ALLOCATE (snapshot%rho_ao_kp(ispin, img)%matrix)
311 CALL dbcsr_copy(snapshot%rho_ao_kp(ispin, img)%matrix, &
312 rho_ao_kp(ispin, img)%matrix)
317 IF (
ASSOCIATED(snapshot%overlap))
THEN
321 IF (wf_history%store_overlap)
THEN
323 cpassert(
ASSOCIATED(matrix_s))
324 cpassert(
ASSOCIATED(matrix_s(1)%matrix))
325 ALLOCATE (snapshot%overlap)
326 CALL dbcsr_copy(snapshot%overlap, matrix_s(1)%matrix)
330 IF (
ASSOCIATED(kpoints))
THEN
331 IF (
ASSOCIATED(kpoints%kp_env))
THEN
333 IF (wf_history%store_wf_kp)
THEN
335 kplocal = kp_range(2) - kp_range(1) + 1
336 nspin_kp =
SIZE(kpoints%kp_env(1)%kpoint_env%mos, 2)
337 nc =
SIZE(kpoints%kp_env(1)%kpoint_env%mos, 1)
339 CALL wfi_store_kp_pbc_shift(snapshot, cell, particle_set)
341 IF (
ASSOCIATED(snapshot%wf_kp))
THEN
342 DO ikp = 1,
SIZE(snapshot%wf_kp, 1)
343 DO ic = 1,
SIZE(snapshot%wf_kp, 2)
344 DO ispin = 1,
SIZE(snapshot%wf_kp, 3)
349 DEALLOCATE (snapshot%wf_kp)
352 ALLOCATE (snapshot%wf_kp(kplocal, nc, nspin_kp))
354 kp => kpoints%kp_env(ikp)%kpoint_env
355 DO ispin = 1, nspin_kp
357 CALL get_mo_set(kp%mos(ic, ispin), mo_coeff=mo_coeff)
359 mo_coeff%matrix_struct, &
361 CALL cp_fm_to_fm(mo_coeff, snapshot%wf_kp(ikp, ic, ispin))
371 IF (wf_history%store_overlap_kp)
THEN
372 CALL get_qs_env(qs_env, matrix_s_kp=matrix_s_kp, scf_env=scf_env)
373 CALL get_kpoint_info(kpoints, nkp=nkp_all, xkp=xkp, kp_range=kp_range, &
374 nkp_groups=nkp_grps, kp_dist=kp_dist, &
375 sab_nl=sab_nl, cell_to_index=cell_to_index)
376 kplocal = kp_range(2) - kp_range(1) + 1
377 para_env_ft => kpoints%blacs_env_all%para_env
380 ALLOCATE (rmat_ft, cmat_ft, tmpmat_ft)
381 CALL dbcsr_create(rmat_ft, template=matrix_s_kp(1, 1)%matrix, &
382 matrix_type=dbcsr_type_symmetric)
383 CALL dbcsr_create(cmat_ft, template=matrix_s_kp(1, 1)%matrix, &
384 matrix_type=dbcsr_type_antisymmetric)
385 CALL dbcsr_create(tmpmat_ft, template=matrix_s_kp(1, 1)%matrix, &
386 matrix_type=dbcsr_type_no_symmetry)
392 CALL mpools_get(mpools_kp, ao_ao_fm_pools=ao_ao_fm_pools)
396 IF (
ASSOCIATED(snapshot%overlap_cfm_kp))
THEN
397 DO ikp = 1,
SIZE(snapshot%overlap_cfm_kp)
400 DEALLOCATE (snapshot%overlap_cfm_kp)
402 ALLOCATE (snapshot%overlap_cfm_kp(kplocal))
407 ALLOCATE (info_ft(kplocal*nkp_grps, 2))
412 DO igroup = 1, nkp_grps
413 ik = kp_dist(1, igroup) + ikp - 1
414 my_kpgrp = (ik >= kp_range(1) .AND. ik <= kp_range(2))
415 indx_ft = indx_ft + 1
419 CALL rskp_transform(rmatrix=rmat_ft, cmatrix=cmat_ft, rsmat=matrix_s_kp, &
420 ispin=1, xkp=xkp(1:3, ik), &
421 cell_to_index=cell_to_index, sab_nl=sab_nl)
429 para_env_ft, info_ft(indx_ft, 1))
431 para_env_ft, info_ft(indx_ft, 2))
434 para_env_ft, info_ft(indx_ft, 1))
436 para_env_ft, info_ft(indx_ft, 2))
444 CALL cp_cfm_create(snapshot%overlap_cfm_kp(ikp), ao_ao_struct_ft)
446 DO igroup = 1, nkp_grps
447 ik = kp_dist(1, igroup) + ikp - 1
448 my_kpgrp = (ik >= kp_range(1) .AND. ik <= kp_range(2))
449 indx_ft = indx_ft + 1
462 DO indx_ft = 1, kplocal*nkp_grps
475 IF (wf_history%store_frozen_density)
THEN
480 CALL timestop(handle)
482 END SUBROUTINE wfs_update
496 SUBROUTINE wfi_create(wf_history, interpolation_method_nr, extrapolation_order, &
499 INTEGER,
INTENT(in) :: interpolation_method_nr, &
501 LOGICAL,
INTENT(IN) :: has_unit_metric
503 CHARACTER(len=*),
PARAMETER :: routinen =
'wfi_create'
507 CALL timeset(routinen, handle)
509 ALLOCATE (wf_history)
510 wf_history%ref_count = 1
511 wf_history%memory_depth = 0
512 wf_history%snapshot_count = 0
513 wf_history%last_state_index = 1
514 wf_history%store_wf = .false.
515 wf_history%store_rho_r = .false.
516 wf_history%store_rho_g = .false.
517 wf_history%store_rho_ao = .false.
518 wf_history%store_rho_ao_kp = .false.
519 wf_history%store_overlap = .false.
520 wf_history%store_wf_kp = .false.
521 wf_history%store_overlap_kp = .false.
522 wf_history%store_frozen_density = .false.
523 NULLIFY (wf_history%past_states)
525 wf_history%interpolation_method_nr = interpolation_method_nr
527 SELECT CASE (wf_history%interpolation_method_nr)
529 wf_history%memory_depth = 0
531 wf_history%memory_depth = 0
533 wf_history%memory_depth = 1
534 wf_history%store_rho_ao = .true.
536 wf_history%memory_depth = 2
537 wf_history%store_wf = .true.
539 wf_history%memory_depth = 2
540 wf_history%store_rho_ao = .true.
542 wf_history%memory_depth = 2
543 wf_history%store_wf = .true.
544 IF (.NOT. has_unit_metric) wf_history%store_overlap = .true.
547 wf_history%memory_depth = extrapolation_order + 1
548 wf_history%store_wf = .true.
549 wf_history%store_wf_kp = .true.
550 IF (.NOT. has_unit_metric)
THEN
551 wf_history%store_overlap = .true.
552 wf_history%store_overlap_kp = .true.
555 wf_history%memory_depth = 1
556 wf_history%store_frozen_density = .true.
558 wf_history%memory_depth = extrapolation_order + 2
559 wf_history%store_wf = .true.
560 wf_history%store_wf_kp = .true.
561 IF (.NOT. has_unit_metric)
THEN
562 wf_history%store_overlap = .true.
563 wf_history%store_overlap_kp = .true.
566 wf_history%memory_depth = extrapolation_order
567 wf_history%store_wf = .true.
568 wf_history%store_wf_kp = .true.
569 wf_history%store_overlap = .true.
570 wf_history%store_overlap_kp = .true.
572 wf_history%memory_depth = extrapolation_order
573 wf_history%store_wf = .true.
574 wf_history%store_wf_kp = .true.
575 wf_history%store_overlap = .true.
576 wf_history%store_overlap_kp = .true.
578 CALL cp_abort(__location__, &
579 "Unknown interpolation method: "// &
582 ALLOCATE (wf_history%past_states(wf_history%memory_depth))
584 DO i = 1,
SIZE(wf_history%past_states)
585 NULLIFY (wf_history%past_states(i)%snapshot)
588 CALL timestop(handle)
605 cpassert(
ASSOCIATED(wf_history))
606 IF (wf_history%store_rho_ao)
THEN
607 wf_history%store_rho_ao_kp = .true.
608 wf_history%store_rho_ao = .false.
614 wf_history%memory_depth = 1
615 wf_history%store_wf_kp = .true.
616 wf_history%store_wf = .false.
617 wf_history%store_overlap = .false.
618 IF (
ASSOCIATED(wf_history%past_states))
DEALLOCATE (wf_history%past_states)
619 ALLOCATE (wf_history%past_states(wf_history%memory_depth))
620 DO i = 1,
SIZE(wf_history%past_states)
621 NULLIFY (wf_history%past_states(i)%snapshot)
623 ELSE IF (wf_history%store_wf_kp)
THEN
624 wf_history%store_wf = .false.
625 wf_history%store_overlap = .false.
629 IF (wf_history%store_wf .OR. wf_history%store_overlap)
THEN
630 cpabort(
"Linear WFN-based extrapolation methods not implemented for k-points.")
633 IF (wf_history%store_frozen_density)
THEN
634 cpabort(
"Frozen density initialization method not possible for kpoints.")
648 INTEGER,
INTENT(in) :: method_nr
649 CHARACTER(len=30) :: res
652 SELECT CASE (method_nr)
658 res =
"previous_rho_r"
660 res =
"initial_guess"
670 res =
"frozen density approximation"
676 res =
"GEXT_PROJ_QTR"
678 CALL cp_abort(__location__, &
679 "Unknown interpolation method: "// &
703 REAL(kind=
dp),
INTENT(IN) :: dt
704 INTEGER,
INTENT(OUT),
OPTIONAL :: extrapolation_method_nr
705 LOGICAL,
INTENT(OUT),
OPTIONAL :: orthogonal_wf
707 CHARACTER(len=*),
PARAMETER :: routinen =
'wfi_extrapolate'
709 INTEGER :: actual_extrapolation_method_nr, handle, &
710 i, img, io_unit, ispin, k, n, nmo, &
712 LOGICAL :: do_kpoints, my_orthogonal_wf, use_overlap
713 REAL(kind=
dp) :: alpha, t0, t1, t2
714 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: coeffs
720 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_s, rho_ao, rho_frozen_ao
721 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_ao_kp
726 NULLIFY (mos, ao_mo_fm_pools, t0_state, t1_state, mo_coeff, &
727 rho, rho_ao, rho_frozen_ao)
729 use_overlap = wf_history%store_overlap
731 CALL timeset(routinen, handle)
733 print_level = logger%iter_info%print_level
737 cpassert(
ASSOCIATED(wf_history))
738 cpassert(wf_history%ref_count > 0)
739 cpassert(
ASSOCIATED(qs_env))
740 CALL get_qs_env(qs_env, mos=mos, rho=rho, do_kpoints=do_kpoints)
741 CALL mpools_get(qs_env%mpools, ao_mo_fm_pools=ao_mo_fm_pools)
743 IF (wf_history%snapshot_count < 1)
THEN
746 actual_extrapolation_method_nr = wf_history%interpolation_method_nr
749 SELECT CASE (actual_extrapolation_method_nr)
751 IF (wf_history%snapshot_count < 2)
THEN
755 IF (wf_history%snapshot_count < 2)
THEN
759 IF (wf_history%snapshot_count < 2)
THEN
764 IF (
PRESENT(extrapolation_method_nr)) &
765 extrapolation_method_nr = actual_extrapolation_method_nr
766 my_orthogonal_wf = .false.
768 SELECT CASE (actual_extrapolation_method_nr)
770 cpassert(.NOT. do_kpoints)
772 cpassert(
ASSOCIATED(t0_state%rho_frozen))
774 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
775 CALL wfi_set_history_variables(qs_env=qs_env, nvec=nvec)
777 CALL qs_rho_get(t0_state%rho_frozen, rho_ao=rho_frozen_ao)
779 DO ispin = 1,
SIZE(rho_frozen_ao)
781 rho_frozen_ao(ispin)%matrix, &
782 keep_sparsity=.true.)
789 my_orthogonal_wf = .false.
792 CALL cp_warn(__location__, &
793 "USE_PREV_RHO_R is deprecated and will be removed in a future "// &
794 "release; it is now an alias of USE_PREV_P.")
797 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
798 CALL wfi_set_history_variables(qs_env=qs_env, nvec=nvec)
800 cpassert(
ASSOCIATED(t0_state%rho_ao_kp))
802 DO ispin = 1,
SIZE(t0_state%rho_ao_kp, 1)
803 DO img = 1,
SIZE(t0_state%rho_ao_kp, 2)
804 IF (img >
SIZE(rho_ao_kp, 2))
THEN
805 cpwarn(
"Change in cell neighborlist: might affect quality of initial guess")
807 CALL dbcsr_copy(rho_ao_kp(ispin, img)%matrix, &
808 t0_state%rho_ao_kp(ispin, img)%matrix, &
809 keep_sparsity=.true.)
814 cpassert(
ASSOCIATED(t0_state%rho_ao))
816 DO ispin = 1,
SIZE(t0_state%rho_ao)
818 t0_state%rho_ao(ispin)%matrix, &
819 keep_sparsity=.true.)
827 my_orthogonal_wf = .true.
828 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
829 CALL wfi_set_history_variables(qs_env=qs_env, nvec=nvec)
832 CALL wfi_use_prev_wf_kp(qs_env, io_unit, print_level)
835 DO ispin = 1,
SIZE(mos)
836 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff, nmo=nmo)
850 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
851 CALL wfi_set_history_variables(qs_env=qs_env, nvec=nvec)
853 cpassert(.NOT. do_kpoints)
856 cpassert(
ASSOCIATED(t0_state))
857 cpassert(
ASSOCIATED(t1_state))
858 cpassert(
ASSOCIATED(t0_state%wf))
859 cpassert(
ASSOCIATED(t1_state%wf))
860 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
861 CALL wfi_set_history_variables(qs_env=qs_env, nvec=nvec)
863 my_orthogonal_wf = .true.
868 DO ispin = 1,
SIZE(mos)
869 CALL get_mo_set(mos(ispin), mo_coeff=mo_coeff, &
873 matrix_b=t1_state%wf(ispin), &
874 beta=(t2 - t0)/(t1 - t0))
878 beta=(t1 - t2)/(t1 - t0), matrix_b=t0_state%wf(ispin))
883 density_matrix=rho_ao(ispin)%matrix)
892 cpassert(
ASSOCIATED(t0_state))
893 cpassert(
ASSOCIATED(t1_state))
895 cpassert(
ASSOCIATED(t0_state%rho_ao_kp))
896 cpassert(
ASSOCIATED(t1_state%rho_ao_kp))
898 cpassert(
ASSOCIATED(t0_state%rho_ao))
899 cpassert(
ASSOCIATED(t1_state%rho_ao))
901 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
902 CALL wfi_set_history_variables(qs_env=qs_env, nvec=nvec)
909 DO ispin = 1,
SIZE(rho_ao_kp, 1)
910 DO img = 1,
SIZE(rho_ao_kp, 2)
911 IF (img >
SIZE(t0_state%rho_ao_kp, 2) .OR. &
912 img >
SIZE(t1_state%rho_ao_kp, 2))
THEN
913 cpwarn(
"Change in cell neighborlist: might affect quality of initial guess")
915 CALL dbcsr_add(rho_ao_kp(ispin, img)%matrix, t1_state%rho_ao_kp(ispin, img)%matrix, &
916 alpha_scalar=0.0_dp, beta_scalar=(t2 - t0)/(t1 - t0))
917 CALL dbcsr_add(rho_ao_kp(ispin, img)%matrix, t0_state%rho_ao_kp(ispin, img)%matrix, &
918 alpha_scalar=1.0_dp, beta_scalar=(t1 - t2)/(t1 - t0))
924 DO ispin = 1,
SIZE(rho_ao)
925 CALL dbcsr_add(rho_ao(ispin)%matrix, t1_state%rho_ao(ispin)%matrix, &
926 alpha_scalar=0.0_dp, beta_scalar=(t2 - t0)/(t1 - t0))
927 CALL dbcsr_add(rho_ao(ispin)%matrix, t0_state%rho_ao(ispin)%matrix, &
928 alpha_scalar=1.0_dp, beta_scalar=(t1 - t2)/(t1 - t0))
936 cpassert(.NOT. do_kpoints)
939 cpassert(
ASSOCIATED(t0_state))
940 cpassert(
ASSOCIATED(t1_state))
941 cpassert(
ASSOCIATED(t0_state%wf))
942 cpassert(
ASSOCIATED(t1_state%wf))
943 IF (wf_history%store_overlap)
THEN
944 cpassert(
ASSOCIATED(t0_state%overlap))
945 cpassert(
ASSOCIATED(t1_state%overlap))
947 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
948 IF (nvec >= wf_history%memory_depth)
THEN
949 IF ((qs_env%scf_control%max_scf_hist /= 0) .AND. (qs_env%scf_control%eps_scf_hist /= 0))
THEN
950 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
951 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
952 qs_env%scf_control%outer_scf%have_scf = .false.
953 ELSE IF (qs_env%scf_control%max_scf_hist /= 0)
THEN
954 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
955 qs_env%scf_control%outer_scf%have_scf = .false.
956 ELSE IF (qs_env%scf_control%eps_scf_hist /= 0)
THEN
957 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
961 my_orthogonal_wf = .true.
965 DO ispin = 1,
SIZE(mos)
966 NULLIFY (mo_coeff, matrix_struct, matrix_struct_new)
967 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
969 matrix_struct=matrix_struct)
971 nrow_global=k, ncol_global=k)
975 IF (use_overlap)
THEN
977 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), mo_coeff, 0.0_dp, csc)
979 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), &
980 t1_state%wf(ispin), 0.0_dp, csc)
982 CALL parallel_gemm(
'N',
'N', n, k, k, 1.0_dp, t0_state%wf(ispin), csc, 0.0_dp, mo_coeff)
989 density_matrix=rho_ao(ispin)%matrix)
996 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
998 IF (nvec >= wf_history%memory_depth)
THEN
999 IF ((qs_env%scf_control%max_scf_hist /= 0) .AND. (qs_env%scf_control%eps_scf_hist /= 0))
THEN
1000 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1001 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1002 qs_env%scf_control%outer_scf%have_scf = .false.
1003 ELSE IF (qs_env%scf_control%max_scf_hist /= 0)
THEN
1004 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1005 qs_env%scf_control%outer_scf%have_scf = .false.
1006 ELSE IF (qs_env%scf_control%eps_scf_hist /= 0)
THEN
1007 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1011 IF (do_kpoints)
THEN
1012 CALL wfi_extrapolate_ps_aspc_kp(wf_history, qs_env, nvec, io_unit, print_level)
1013 my_orthogonal_wf = .true.
1015 my_orthogonal_wf = .true.
1016 DO ispin = 1,
SIZE(mos)
1017 NULLIFY (mo_coeff, matrix_struct, matrix_struct_new)
1018 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
1020 matrix_struct=matrix_struct)
1023 nrow_global=k, ncol_global=k)
1034 IF (use_overlap)
THEN
1036 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), fm_tmp, 0.0_dp, csc)
1038 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), &
1039 t1_state%wf(ispin), 0.0_dp, csc)
1041 CALL parallel_gemm(
'N',
'N', n, k, k, 1.0_dp, t0_state%wf(ispin), csc, 0.0_dp, fm_tmp)
1042 alpha = -1.0_dp*alpha*real(nvec - i + 1,
dp)/real(i,
dp)
1049 v_matrix=mo_coeff, &
1052 density_matrix=rho_ao(ispin)%matrix)
1062 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
1064 IF (nvec >= wf_history%memory_depth)
THEN
1065 IF ((qs_env%scf_control%max_scf_hist /= 0) .AND. &
1066 (qs_env%scf_control%eps_scf_hist /= 0))
THEN
1067 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1068 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1069 qs_env%scf_control%outer_scf%have_scf = .false.
1070 ELSE IF (qs_env%scf_control%max_scf_hist /= 0)
THEN
1071 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1072 qs_env%scf_control%outer_scf%have_scf = .false.
1073 ELSE IF (qs_env%scf_control%eps_scf_hist /= 0)
THEN
1074 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1078 IF (do_kpoints)
THEN
1079 CALL wfi_extrapolate_ps_aspc_kp(wf_history, qs_env, nvec, io_unit, print_level)
1080 my_orthogonal_wf = .true.
1082 my_orthogonal_wf = .true.
1084 DO ispin = 1,
SIZE(mos)
1085 NULLIFY (mo_coeff, matrix_struct, matrix_struct_new)
1086 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
1090 matrix_struct=matrix_struct)
1091 CALL cp_fm_create(fm_tmp, matrix_struct, set_zero=.true.)
1093 template_fmstruct=matrix_struct, &
1096 CALL cp_fm_create(csc, matrix_struct_new, set_zero=.true.)
1102 alpha = real(4*nvec - 2, kind=
dp)/real(nvec + 1, kind=
dp)
1104 WRITE (unit=io_unit, fmt=
"(/,T2,A,/,/,T3,A,I0,/,/,T3,A2,I0,A4,F10.6)") &
1105 "Parameters for the always stable predictor-corrector (ASPC) method:", &
1106 "ASPC order: ", max(nvec - 2, 0), &
1107 "B(", 1,
") = ", alpha
1113 IF (use_overlap)
THEN
1115 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), fm_tmp, 0.0_dp, csc)
1117 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), &
1118 t1_state%wf(ispin), 0.0_dp, csc)
1120 CALL parallel_gemm(
'N',
'N', n, k, k, 1.0_dp, t0_state%wf(ispin), csc, 0.0_dp, fm_tmp)
1121 alpha = (-1.0_dp)**(i + 1)*real(i, kind=
dp)* &
1124 WRITE (unit=io_unit, fmt=
"(T3,A2,I0,A4,F10.6)") &
1125 "B(", i,
") = ", alpha
1132 v_matrix=mo_coeff, &
1135 density_matrix=rho_ao(ispin)%matrix)
1142 IF (do_kpoints)
THEN
1143 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
1145 CALL wfi_extrapolate_gext_proj_kp(wf_history, qs_env, nvec, io_unit, print_level)
1149 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
1150 IF (nvec >= wf_history%memory_depth)
THEN
1151 IF ((qs_env%scf_control%max_scf_hist /= 0) .AND. &
1152 (qs_env%scf_control%eps_scf_hist /= 0))
THEN
1153 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1154 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1155 qs_env%scf_control%outer_scf%have_scf = .false.
1156 ELSE IF (qs_env%scf_control%max_scf_hist /= 0)
THEN
1157 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1158 qs_env%scf_control%outer_scf%have_scf = .false.
1159 ELSE IF (qs_env%scf_control%eps_scf_hist /= 0)
THEN
1160 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1166 ALLOCATE (coeffs(nvec))
1169 CALL diff_fitting(wf_history, matrix_s(1)%matrix, coeffs, nvec, &
1170 1e-4_dp, io_unit, print_level)
1172 my_orthogonal_wf = .true.
1174 DO ispin = 1,
SIZE(mos)
1175 NULLIFY (mo_coeff, matrix_struct, matrix_struct_new)
1176 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
1180 matrix_struct=matrix_struct)
1183 template_fmstruct=matrix_struct, &
1196 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), fm_tmp, 0.0_dp, csc)
1197 CALL parallel_gemm(
'N',
'N', n, k, k, 1.0_dp, t0_state%wf(ispin), csc, 0.0_dp, fm_tmp)
1203 v_matrix=mo_coeff, &
1206 density_matrix=rho_ao(ispin)%matrix)
1216 IF (do_kpoints)
THEN
1217 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
1219 CALL wfi_extrapolate_gext_proj_kp(wf_history, qs_env, nvec, io_unit, print_level)
1223 nvec = min(wf_history%memory_depth, wf_history%snapshot_count)
1224 IF (nvec >= wf_history%memory_depth)
THEN
1225 IF ((qs_env%scf_control%max_scf_hist /= 0) .AND. &
1226 (qs_env%scf_control%eps_scf_hist /= 0))
THEN
1227 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1228 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1229 qs_env%scf_control%outer_scf%have_scf = .false.
1230 ELSE IF (qs_env%scf_control%max_scf_hist /= 0)
THEN
1231 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1232 qs_env%scf_control%outer_scf%have_scf = .false.
1233 ELSE IF (qs_env%scf_control%eps_scf_hist /= 0)
THEN
1234 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1240 ALLOCATE (coeffs(nvec))
1243 CALL tr_fitting(wf_history, matrix_s(1)%matrix, coeffs, nvec, &
1244 1e-4_dp, io_unit, print_level)
1246 my_orthogonal_wf = .true.
1248 DO ispin = 1,
SIZE(mos)
1249 NULLIFY (mo_coeff, matrix_struct, matrix_struct_new)
1250 CALL get_mo_set(mo_set=mos(ispin), mo_coeff=mo_coeff)
1254 matrix_struct=matrix_struct)
1257 template_fmstruct=matrix_struct, &
1270 CALL parallel_gemm(
'T',
'N', k, k, n, 1.0_dp, t0_state%wf(ispin), fm_tmp, 0.0_dp, csc)
1271 CALL parallel_gemm(
'N',
'N', n, k, k, 1.0_dp, t0_state%wf(ispin), csc, 0.0_dp, fm_tmp)
1277 v_matrix=mo_coeff, &
1280 density_matrix=rho_ao(ispin)%matrix)
1290 CALL cp_abort(__location__, &
1291 "Unknown interpolation method: "// &
1292 trim(adjustl(
cp_to_string(wf_history%interpolation_method_nr))))
1294 IF (
PRESENT(orthogonal_wf)) orthogonal_wf = my_orthogonal_wf
1296 "DFT%SCF%PRINT%PROGRAM_RUN_INFO")
1297 CALL timestop(handle)
1309 SUBROUTINE wfi_use_prev_wf_kp(qs_env, io_unit, print_level, pbc_shift_ref, load_snapshot_wf)
1311 INTEGER,
INTENT(IN) :: io_unit, print_level
1312 INTEGER,
DIMENSION(:, :),
INTENT(IN),
OPTIONAL :: pbc_shift_ref
1313 LOGICAL,
INTENT(IN),
OPTIONAL :: load_snapshot_wf
1315 CHARACTER(len=*),
PARAMETER :: routinen =
'wfi_use_prev_wf_kp'
1317 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: col_scaling
1318 INTEGER :: chol_info, handle, igroup, ik, ikp, &
1319 indx, ispin, j, kplocal, nao, nkp, &
1320 nkp_groups, nmo, nspin
1321 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: pbc_shift_cur, pbc_shift_src
1322 INTEGER,
DIMENSION(2) :: kp_range
1323 INTEGER,
DIMENSION(:, :),
POINTER :: kp_dist
1324 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1325 LOGICAL :: my_kpgrp, reload_snapshot_wf, &
1326 use_pbc_phase_ref, use_real_wfn
1327 REAL(kind=
dp) :: eval_thresh
1328 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues
1329 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1331 TYPE(
cp_cfm_type) :: cfm_evecs, cfm_mhalf, cfm_nao_nmo_work, &
1333 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: csmat_cur
1337 TYPE(
cp_fm_type),
POINTER :: imos, mo_coeff, rmos
1338 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s_kp, rho_ao_kp
1339 TYPE(
dbcsr_type),
POINTER :: cmatrix_db, rmatrix, tmpmat
1353 CALL timeset(routinen, handle)
1355 NULLIFY (kpoints, dft_control, matrix_s_kp, scf_env, scf_control, rho, sab_nl, kp, &
1356 mo_coeff, rmos, imos, wf_history, t1_state)
1358 CALL get_qs_env(qs_env, kpoints=kpoints, dft_control=dft_control, &
1359 matrix_s_kp=matrix_s_kp, scf_env=scf_env, &
1360 scf_control=scf_control, rho=rho)
1361 CALL get_kpoint_info(kpoints, nkp=nkp, xkp=xkp, use_real_wfn=use_real_wfn, &
1362 kp_range=kp_range, nkp_groups=nkp_groups, kp_dist=kp_dist, &
1363 sab_nl=sab_nl, cell_to_index=cell_to_index)
1364 kplocal = kp_range(2) - kp_range(1) + 1
1366 IF (use_real_wfn)
THEN
1367 CALL timestop(handle)
1371 wf_history => qs_env%wf_history
1372 reload_snapshot_wf = .false.
1373 IF (
PRESENT(load_snapshot_wf)) reload_snapshot_wf = load_snapshot_wf
1374 IF (
PRESENT(pbc_shift_ref))
THEN
1375 ALLOCATE (pbc_shift_src(3,
SIZE(pbc_shift_ref, 2)))
1376 pbc_shift_src(:, :) = pbc_shift_ref(:, :)
1377 use_pbc_phase_ref = .true.
1379 use_pbc_phase_ref = .false.
1380 IF (
ASSOCIATED(wf_history))
THEN
1381 IF (wf_history%store_wf_kp .AND. wf_history%snapshot_count > 0)
THEN
1383 cpassert(
ASSOCIATED(t1_state%wf_kp))
1384 cpassert(
ASSOCIATED(t1_state%kp_pbc_shift))
1385 reload_snapshot_wf = .true.
1386 ALLOCATE (pbc_shift_src(3,
SIZE(t1_state%kp_pbc_shift, 2)))
1387 pbc_shift_src(:, :) = t1_state%kp_pbc_shift(:, :)
1388 use_pbc_phase_ref = .true.
1392 IF (use_pbc_phase_ref)
CALL wfi_compute_kp_pbc_shift(qs_env, pbc_shift_cur)
1394 kp => kpoints%kp_env(1)%kpoint_env
1395 nspin =
SIZE(kp%mos, 2)
1396 CALL get_mo_set(kp%mos(1, 1), nao=nao, nmo=nmo, mo_coeff=mo_coeff)
1399 WRITE (unit=io_unit, fmt=
"(/,T2,A)") &
1400 "Using previous wavefunctions as initial guess for k-points (with reorthogonalization)"
1404 ALLOCATE (rmatrix, cmatrix_db, tmpmat)
1405 CALL dbcsr_create(rmatrix, template=matrix_s_kp(1, 1)%matrix, matrix_type=dbcsr_type_symmetric)
1406 CALL dbcsr_create(cmatrix_db, template=matrix_s_kp(1, 1)%matrix, matrix_type=dbcsr_type_antisymmetric)
1407 CALL dbcsr_create(tmpmat, template=matrix_s_kp(1, 1)%matrix, matrix_type=dbcsr_type_no_symmetry)
1412 CALL mpools_get(mpools_kp, ao_ao_fm_pools=ao_ao_fm_pools_kp)
1417 CALL cp_cfm_create(cfm_nao_nmo_work, mo_coeff%matrix_struct)
1419 NULLIFY (nmo_nmo_struct)
1421 nrow_global=nmo, ncol_global=nmo)
1425 para_env => kpoints%blacs_env_all%para_env
1426 ALLOCATE (info(kplocal*nkp_groups, 2))
1428 ALLOCATE (csmat_cur(kplocal))
1436 DO igroup = 1, nkp_groups
1437 ik = kp_dist(1, igroup) + ikp - 1
1438 my_kpgrp = (ik >= kp_range(1) .AND. ik <= kp_range(2))
1443 CALL rskp_transform(rmatrix=rmatrix, cmatrix=cmatrix_db, rsmat=matrix_s_kp, &
1444 ispin=1, xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
1463 DO igroup = 1, nkp_groups
1464 ik = kp_dist(1, igroup) + ikp - 1
1465 my_kpgrp = (ik >= kp_range(1) .AND. ik <= kp_range(2))
1476 DO indx = 1, kplocal*nkp_groups
1483 ALLOCATE (eigenvalues(nmo))
1484 eval_thresh = 1.0e-12_dp
1487 kp => kpoints%kp_env(ikp)%kpoint_env
1489 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos)
1490 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
1491 IF (reload_snapshot_wf)
THEN
1492 CALL cp_fm_to_fm(t1_state%wf_kp(ikp, 1, ispin), rmos)
1493 CALL cp_fm_to_fm(t1_state%wf_kp(ikp, 2, ispin), imos)
1495 IF (use_pbc_phase_ref)
THEN
1496 ik = kp_range(1) + ikp - 1
1497 CALL wfi_apply_kp_pbc_phase_fm(rmos, imos, pbc_shift_cur - pbc_shift_src, &
1498 xkp(1:3, ik), matrix_s_kp(1, 1)%matrix)
1503 csmat_cur(ikp), cmos_new,
z_zero, cfm_nao_nmo_work)
1505 cmos_new, cfm_nao_nmo_work,
z_zero, csc_cfm)
1508 IF (chol_info == 0)
THEN
1516 ALLOCATE (col_scaling(nmo))
1518 IF (eigenvalues(j) > eval_thresh)
THEN
1519 col_scaling(j) = cmplx(1.0_dp/sqrt(eigenvalues(j)), 0.0_dp, kind=
dp)
1525 DEALLOCATE (col_scaling)
1535 DEALLOCATE (eigenvalues)
1542 matrix_s_kp(1, 1)%matrix, sab_nl, scf_env%scf_work1)
1550 DEALLOCATE (csmat_cur)
1559 IF (
ALLOCATED(pbc_shift_cur))
DEALLOCATE (pbc_shift_cur)
1560 IF (
ALLOCATED(pbc_shift_src))
DEALLOCATE (pbc_shift_src)
1562 CALL timestop(handle)
1563 END SUBROUTINE wfi_use_prev_wf_kp
1572 SUBROUTINE wfi_store_kp_pbc_shift(snapshot, cell, particle_set)
1577 INTEGER :: iatom, natom
1578 REAL(kind=
dp),
DIMENSION(3) :: frac_pbc, frac_raw, r_pbc
1580 cpassert(
ASSOCIATED(snapshot))
1581 cpassert(
ASSOCIATED(cell))
1582 cpassert(
ASSOCIATED(particle_set))
1584 natom =
SIZE(particle_set)
1585 IF (
ASSOCIATED(snapshot%kp_pbc_shift))
THEN
1586 DEALLOCATE (snapshot%kp_pbc_shift)
1588 ALLOCATE (snapshot%kp_pbc_shift(3, natom))
1590 r_pbc(1:3) =
pbc(particle_set(iatom)%r(1:3), cell)
1593 snapshot%kp_pbc_shift(1:3, iatom) = nint(frac_pbc(1:3) - frac_raw(1:3))
1595 END SUBROUTINE wfi_store_kp_pbc_shift
1602 SUBROUTINE wfi_compute_kp_pbc_shift(qs_env, pbc_shift)
1604 INTEGER,
ALLOCATABLE,
DIMENSION(:, :),
INTENT(OUT) :: pbc_shift
1606 INTEGER :: iatom, natom
1607 REAL(kind=
dp),
DIMENSION(3) :: frac_pbc, frac_raw, r_pbc
1611 NULLIFY (cell, particle_set)
1612 CALL get_qs_env(qs_env, cell=cell, particle_set=particle_set)
1613 cpassert(
ASSOCIATED(cell))
1614 cpassert(
ASSOCIATED(particle_set))
1616 natom =
SIZE(particle_set)
1617 ALLOCATE (pbc_shift(3, natom))
1619 r_pbc(1:3) =
pbc(particle_set(iatom)%r(1:3), cell)
1622 pbc_shift(1:3, iatom) = nint(frac_pbc(1:3) - frac_raw(1:3))
1624 END SUBROUTINE wfi_compute_kp_pbc_shift
1635 SUBROUTINE wfi_apply_kp_pbc_phase_fm(rmos, imos, pbc_shift_delta, xk, matrix_template)
1637 INTEGER,
DIMENSION(:, :),
INTENT(IN) :: pbc_shift_delta
1638 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: xk
1641 INTEGER :: iatom, icol, irow, natom, nmo, nrow, &
1643 INTEGER,
DIMENSION(:),
POINTER :: row_blk_size
1644 REAL(kind=
dp) :: ci, cr, i_old, r_old, theta
1645 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: iblock, rblock
1647 cpassert(
ASSOCIATED(rmos))
1648 cpassert(
ASSOCIATED(imos))
1649 cpassert(
ASSOCIATED(matrix_template))
1651 natom =
SIZE(pbc_shift_delta, 2)
1653 NULLIFY (row_blk_size)
1655 cpassert(
SIZE(row_blk_size) >= natom)
1659 nrow = row_blk_size(iatom)
1660 IF (any(pbc_shift_delta(1:3, iatom) /= 0))
THEN
1661 theta =
twopi*sum(xk(1:3)*real(pbc_shift_delta(1:3, iatom), kind=
dp))
1664 ALLOCATE (rblock(nrow, nmo), iblock(nrow, nmo))
1669 r_old = rblock(irow, icol)
1670 i_old = iblock(irow, icol)
1671 rblock(irow, icol) = cr*r_old - ci*i_old
1672 iblock(irow, icol) = ci*r_old + cr*i_old
1677 DEALLOCATE (rblock, iblock)
1679 row_start = row_start + nrow
1681 END SUBROUTINE wfi_apply_kp_pbc_phase_fm
1691 SUBROUTINE wfi_apply_kp_pbc_phase_cfm(cmos, pbc_shift_delta, xk, matrix_template)
1693 INTEGER,
DIMENSION(:, :),
INTENT(IN) :: pbc_shift_delta
1694 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: xk
1697 COMPLEX(KIND=dp) :: phase
1698 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :) :: zblock
1699 INTEGER :: iatom, natom, nmo, nrow, row_start
1700 INTEGER,
DIMENSION(:),
POINTER :: row_blk_size
1701 REAL(kind=
dp) :: theta
1703 cpassert(
ASSOCIATED(matrix_template))
1705 natom =
SIZE(pbc_shift_delta, 2)
1707 NULLIFY (row_blk_size)
1709 cpassert(
SIZE(row_blk_size) >= natom)
1713 nrow = row_blk_size(iatom)
1714 IF (any(pbc_shift_delta(1:3, iatom) /= 0))
THEN
1715 theta =
twopi*sum(xk(1:3)*real(pbc_shift_delta(1:3, iatom), kind=
dp))
1716 phase = cmplx(cos(theta), sin(theta), kind=
dp)
1717 ALLOCATE (zblock(nrow, nmo))
1719 zblock = phase*zblock
1723 row_start = row_start + nrow
1725 END SUBROUTINE wfi_apply_kp_pbc_phase_cfm
1738 SUBROUTINE wfi_extrapolate_ps_aspc_kp(wf_history, qs_env, nvec, io_unit, print_level)
1741 INTEGER,
INTENT(IN) :: nvec, io_unit, print_level
1743 CHARACTER(len=*),
PARAMETER :: routinen =
'wfi_extrapolate_ps_aspc_kp'
1745 INTEGER :: handle, i, ik, ikp, ispin, kplocal, &
1746 method_nr, nao, nmo, nspin
1747 INTEGER,
DIMENSION(2) :: kp_range
1748 LOGICAL :: use_real_wfn
1749 REAL(kind=
dp) :: alpha_coeff
1750 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1751 TYPE(
cp_cfm_type) :: cfm_nao_nmo_work, cmos_1, cmos_i, &
1754 TYPE(
cp_fm_type),
POINTER :: imos, mo_coeff, rmos
1755 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s_kp
1760 method_nr = wf_history%interpolation_method_nr
1762 CALL timeset(routinen, handle)
1763 NULLIFY (kpoints, kp, mo_coeff, rmos, imos, t0_state, t1_state, nmo_nmo_struct, &
1766 CALL get_qs_env(qs_env, kpoints=kpoints, matrix_s_kp=matrix_s_kp)
1767 CALL get_kpoint_info(kpoints, use_real_wfn=use_real_wfn, kp_range=kp_range, xkp=xkp)
1768 kplocal = kp_range(2) - kp_range(1) + 1
1770 IF (use_real_wfn)
THEN
1772 CALL cp_warn(__location__,
"ASPC with k-points requires complex wavefunctions; "// &
1773 "falling back to USE_PREV_WF.")
1775 CALL cp_warn(__location__,
"PS with k-points requires complex wavefunctions; "// &
1776 "falling back to USE_PREV_WF.")
1778 CALL wfi_use_prev_wf_kp(qs_env, io_unit, print_level)
1779 CALL timestop(handle)
1783 kp => kpoints%kp_env(1)%kpoint_env
1784 nspin =
SIZE(kp%mos, 2)
1785 CALL get_mo_set(kp%mos(1, 1), nao=nao, nmo=nmo, mo_coeff=mo_coeff)
1789 WRITE (unit=io_unit, fmt=
"(/,T2,A,/,T3,A,I0)") &
1790 "Parameters for the always stable predictor-corrector (ASPC) method:", &
1791 "ASPC order: ", max(nvec - 2, 0)
1796 CALL cp_cfm_create(cmos_new, mo_coeff%matrix_struct, set_zero=.true.)
1797 CALL cp_cfm_create(cmos_1, mo_coeff%matrix_struct, set_zero=.true.)
1798 CALL cp_cfm_create(cmos_i, mo_coeff%matrix_struct, set_zero=.true.)
1799 CALL cp_cfm_create(cfm_nao_nmo_work, mo_coeff%matrix_struct, set_zero=.true.)
1804 CALL cp_cfm_create(cfm_nao_nmo_work, mo_coeff%matrix_struct)
1808 nrow_global=nmo, ncol_global=nmo)
1810 CALL cp_cfm_create(csc_cfm, nmo_nmo_struct, set_zero=.true.)
1819 alpha_coeff = real(4*nvec - 2, kind=
dp)/real(nvec + 1, kind=
dp)
1821 WRITE (unit=io_unit, fmt=
"(T3,A2,I0,A4,F10.6)")
"B(", 1,
") = ", alpha_coeff
1828 kp => kpoints%kp_env(ikp)%kpoint_env
1830 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos)
1831 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
1832 CALL cp_fm_to_fm(t1_state%wf_kp(ikp, 1, ispin), rmos)
1833 CALL cp_fm_to_fm(t1_state%wf_kp(ikp, 2, ispin), imos)
1843 alpha_coeff = (-1.0_dp)**(i + 1)*real(i, kind=
dp)* &
1846 WRITE (unit=io_unit, fmt=
"(T3,A2,I0,A4,F10.6)")
"B(", i,
") = ", alpha_coeff
1849 alpha_coeff = -1.0_dp*alpha_coeff*real(nvec - i + 1,
dp)/real(i,
dp)
1853 kp => kpoints%kp_env(ikp)%kpoint_env
1855 ik = kp_range(1) + ikp - 1
1856 CALL cp_fm_to_cfm(t1_state%wf_kp(ikp, 1, ispin), t1_state%wf_kp(ikp, 2, ispin), cmos_1)
1857 CALL cp_fm_to_cfm(t0_state%wf_kp(ikp, 1, ispin), t0_state%wf_kp(ikp, 2, ispin), cmos_i)
1861 CALL wfi_apply_kp_pbc_phase_cfm(cmos_1, t0_state%kp_pbc_shift - t1_state%kp_pbc_shift, &
1862 xkp(1:3, ik), matrix_s_kp(1, 1)%matrix)
1866 t0_state%overlap_cfm_kp(ikp), cmos_1,
z_zero, cfm_nao_nmo_work)
1868 cmos_i, cfm_nao_nmo_work,
z_zero, csc_cfm)
1870 cmos_i, csc_cfm,
z_zero, cfm_nao_nmo_work)
1875 CALL wfi_apply_kp_pbc_phase_cfm(cfm_nao_nmo_work, t1_state%kp_pbc_shift - t0_state%kp_pbc_shift, &
1876 xkp(1:3, ik), matrix_s_kp(1, 1)%matrix)
1878 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos)
1879 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
1897 CALL wfi_use_prev_wf_kp(qs_env, 0, print_level, pbc_shift_ref=t1_state%kp_pbc_shift, &
1898 load_snapshot_wf=.false.)
1900 CALL timestop(handle)
1902 END SUBROUTINE wfi_extrapolate_ps_aspc_kp
1914 SUBROUTINE wfi_extrapolate_gext_proj_kp(wf_history, qs_env, nvec, io_unit, print_level)
1917 INTEGER,
INTENT(IN) :: nvec, io_unit, print_level
1919 CHARACTER(len=*),
PARAMETER :: routinen =
'wfi_extrapolate_gext_proj_kp'
1921 INTEGER :: handle, i, igroup, ik, ikp, indx, ispin, &
1922 kplocal, method_nr, nao, nkp, &
1923 nkp_groups, nmo, nspin
1924 INTEGER,
DIMENSION(2) :: kp_range
1925 INTEGER,
DIMENSION(:, :),
POINTER :: kp_dist
1926 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1927 LOGICAL :: my_kpgrp, use_real_wfn
1928 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: coeffs, weight_kp
1929 REAL(kind=
dp),
DIMENSION(:),
POINTER :: wkp
1930 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1932 TYPE(
cp_cfm_type) :: cfm_nao_nmo_work, cmos_1, cmos_i, &
1934 TYPE(
cp_cfm_type),
ALLOCATABLE,
DIMENSION(:) :: csmat_cur
1938 TYPE(
cp_fm_type),
POINTER :: imos, mo_coeff, rmos
1939 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_s_kp
1940 TYPE(
dbcsr_type),
POINTER :: cmatrix_db, rmatrix, tmpmat
1950 method_nr = wf_history%interpolation_method_nr
1952 CALL timeset(routinen, handle)
1953 NULLIFY (ao_ao_struct, cell_to_index, cmatrix_db, imos, kp, kpoints, matrix_s_kp, &
1954 mo_coeff, mpools_kp, para_env, para_env_inter_kp, rmatrix, rmos, sab_nl, &
1955 scf_env, t0_state, t1_state, tmpmat, xkp, kp_dist, wkp, nmo_nmo_struct, &
1958 CALL get_qs_env(qs_env, kpoints=kpoints, matrix_s_kp=matrix_s_kp, scf_env=scf_env)
1959 CALL get_kpoint_info(kpoints, use_real_wfn=use_real_wfn, kp_range=kp_range, &
1960 nkp=nkp, xkp=xkp, wkp=wkp, nkp_groups=nkp_groups, &
1961 kp_dist=kp_dist, cell_to_index=cell_to_index, sab_nl=sab_nl, &
1962 mpools=mpools_kp, para_env_inter_kp=para_env_inter_kp)
1963 kplocal = kp_range(2) - kp_range(1) + 1
1965 IF (use_real_wfn)
THEN
1966 CALL cp_warn(__location__,
"GExt with k-points requires complex wavefunctions; "// &
1967 "falling back to USE_PREV_WF.")
1968 CALL wfi_use_prev_wf_kp(qs_env, io_unit, print_level)
1969 CALL timestop(handle)
1973 IF (nvec >= wf_history%memory_depth)
THEN
1974 IF ((qs_env%scf_control%max_scf_hist /= 0) .AND. &
1975 (qs_env%scf_control%eps_scf_hist /= 0))
THEN
1976 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1977 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1978 qs_env%scf_control%outer_scf%have_scf = .false.
1979 ELSE IF (qs_env%scf_control%max_scf_hist /= 0)
THEN
1980 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
1981 qs_env%scf_control%outer_scf%have_scf = .false.
1982 ELSE IF (qs_env%scf_control%eps_scf_hist /= 0)
THEN
1983 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
1987 kp => kpoints%kp_env(1)%kpoint_env
1988 nspin =
SIZE(kp%mos, 2)
1989 CALL get_mo_set(kp%mos(1, 1), nao=nao, nmo=nmo, mo_coeff=mo_coeff)
1993 ALLOCATE (rmatrix, cmatrix_db, tmpmat)
1994 CALL dbcsr_create(rmatrix, template=matrix_s_kp(1, 1)%matrix, matrix_type=dbcsr_type_symmetric)
1995 CALL dbcsr_create(cmatrix_db, template=matrix_s_kp(1, 1)%matrix, matrix_type=dbcsr_type_antisymmetric)
1996 CALL dbcsr_create(tmpmat, template=matrix_s_kp(1, 1)%matrix, matrix_type=dbcsr_type_no_symmetry)
2000 CALL mpools_get(mpools_kp, ao_ao_fm_pools=ao_ao_fm_pools_kp)
2004 para_env => kpoints%blacs_env_all%para_env
2005 ALLOCATE (info(kplocal*nkp_groups, 2))
2006 ALLOCATE (csmat_cur(kplocal), weight_kp(kplocal))
2009 weight_kp(ikp) = wkp(kp_range(1) + ikp - 1)
2014 DO igroup = 1, nkp_groups
2015 ik = kp_dist(1, igroup) + ikp - 1
2016 my_kpgrp = (ik >= kp_range(1) .AND. ik <= kp_range(2))
2021 CALL rskp_transform(rmatrix=rmatrix, cmatrix=cmatrix_db, rsmat=matrix_s_kp, &
2022 ispin=1, xkp=xkp(1:3, ik), cell_to_index=cell_to_index, sab_nl=sab_nl)
2040 DO igroup = 1, nkp_groups
2041 ik = kp_dist(1, igroup) + ikp - 1
2042 my_kpgrp = (ik >= kp_range(1) .AND. ik <= kp_range(2))
2053 DO indx = 1, kplocal*nkp_groups
2058 ALLOCATE (coeffs(nvec))
2060 CALL diff_fitting(wf_history, matrix_s_kp(1, 1)%matrix, coeffs, nvec, &
2061 1e-4_dp, io_unit, print_level, current_overlap_kp=csmat_cur, &
2062 kpoint_weights=weight_kp, para_env_inter_kp=para_env_inter_kp)
2064 CALL tr_fitting(wf_history, matrix_s_kp(1, 1)%matrix, coeffs, nvec, &
2065 1e-4_dp, io_unit, print_level, current_overlap_kp=csmat_cur, &
2066 kpoint_weights=weight_kp, para_env_inter_kp=para_env_inter_kp)
2073 CALL cp_cfm_create(cfm_nao_nmo_work, mo_coeff%matrix_struct)
2075 nrow_global=nmo, ncol_global=nmo)
2081 kp => kpoints%kp_env(ikp)%kpoint_env
2083 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos)
2084 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
2093 kp => kpoints%kp_env(ikp)%kpoint_env
2094 ik = kp_range(1) + ikp - 1
2096 CALL cp_fm_to_cfm(t1_state%wf_kp(ikp, 1, ispin), t1_state%wf_kp(ikp, 2, ispin), cmos_1)
2097 CALL cp_fm_to_cfm(t0_state%wf_kp(ikp, 1, ispin), t0_state%wf_kp(ikp, 2, ispin), cmos_i)
2099 CALL wfi_apply_kp_pbc_phase_cfm(cmos_1, t0_state%kp_pbc_shift - t1_state%kp_pbc_shift, &
2100 xkp(1:3, ik), matrix_s_kp(1, 1)%matrix)
2103 t0_state%overlap_cfm_kp(ikp), cmos_1,
z_zero, cfm_nao_nmo_work)
2105 cmos_i, cfm_nao_nmo_work,
z_zero, csc_cfm)
2107 cmos_i, csc_cfm,
z_zero, cfm_nao_nmo_work)
2109 CALL wfi_apply_kp_pbc_phase_cfm(cfm_nao_nmo_work, t1_state%kp_pbc_shift - t0_state%kp_pbc_shift, &
2110 xkp(1:3, ik), matrix_s_kp(1, 1)%matrix)
2112 CALL get_mo_set(kp%mos(1, ispin), mo_coeff=rmos)
2113 CALL get_mo_set(kp%mos(2, ispin), mo_coeff=imos)
2127 CALL wfi_use_prev_wf_kp(qs_env, 0, print_level, pbc_shift_ref=t1_state%kp_pbc_shift, &
2128 load_snapshot_wf=.false.)
2133 DEALLOCATE (csmat_cur, coeffs, weight_kp, info)
2139 CALL timestop(handle)
2141 END SUBROUTINE wfi_extrapolate_gext_proj_kp
2152 ELEMENTAL SUBROUTINE wfi_set_history_variables(qs_env, nvec)
2154 INTEGER,
INTENT(IN) :: nvec
2156 IF (nvec >= qs_env%wf_history%memory_depth)
THEN
2157 IF ((qs_env%scf_control%max_scf_hist /= 0) .AND. (qs_env%scf_control%eps_scf_hist /= 0))
THEN
2158 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
2159 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
2160 qs_env%scf_control%outer_scf%have_scf = .false.
2161 ELSE IF (qs_env%scf_control%max_scf_hist /= 0)
THEN
2162 qs_env%scf_control%max_scf = qs_env%scf_control%max_scf_hist
2163 qs_env%scf_control%outer_scf%have_scf = .false.
2164 ELSE IF (qs_env%scf_control%eps_scf_hist /= 0)
THEN
2165 qs_env%scf_control%eps_scf = qs_env%scf_control%eps_scf_hist
2166 qs_env%scf_control%outer_scf%eps_scf = qs_env%scf_control%eps_scf_hist
2170 END SUBROUTINE wfi_set_history_variables
2184 REAL(kind=
dp),
INTENT(in) :: dt
2186 cpassert(
ASSOCIATED(wf_history))
2187 cpassert(wf_history%ref_count > 0)
2188 cpassert(
ASSOCIATED(qs_env))
2190 wf_history%snapshot_count = wf_history%snapshot_count + 1
2191 IF (wf_history%memory_depth > 0)
THEN
2192 wf_history%last_state_index =
modulo(wf_history%snapshot_count, &
2193 wf_history%memory_depth) + 1
2194 CALL wfs_update(snapshot=wf_history%past_states &
2195 (wf_history%last_state_index)%snapshot, wf_history=wf_history, &
2196 qs_env=qs_env, dt=dt)
2212 INTEGER,
INTENT(in),
OPTIONAL :: n_col
2214 CHARACTER(len=*),
PARAMETER :: routinen =
'reorthogonalize_vectors'
2216 INTEGER :: handle, my_n_col
2217 LOGICAL :: has_unit_metric, &
2218 ortho_contains_cholesky, &
2227 NULLIFY (scf_env, scf_control, maxao_maxmo_fm_pool, matrix_s, mpools, dft_control)
2228 CALL timeset(routinen, handle)
2230 cpassert(
ASSOCIATED(qs_env))
2233 IF (
PRESENT(n_col)) my_n_col = n_col
2236 scf_control=scf_control, &
2237 matrix_s=matrix_s, &
2238 dft_control=dft_control)
2239 CALL mpools_get(mpools, maxao_maxmo_fm_pool=maxao_maxmo_fm_pool)
2240 IF (
ASSOCIATED(scf_env))
THEN
2241 ortho_contains_cholesky = (scf_env%method /=
ot_method_nr) .AND. &
2242 (scf_env%cholesky_method > 0) .AND. &
2243 ASSOCIATED(scf_env%ortho)
2245 ortho_contains_cholesky = .false.
2248 CALL get_qs_env(qs_env, has_unit_metric=has_unit_metric)
2249 smearing_is_used = .false.
2250 IF (dft_control%smear)
THEN
2251 smearing_is_used = .true.
2254 IF (has_unit_metric)
THEN
2256 ELSE IF (smearing_is_used)
THEN
2258 matrix_s=matrix_s(1)%matrix)
2259 ELSE IF (ortho_contains_cholesky)
THEN
2261 ortho=scf_env%ortho)
2265 CALL timestop(handle)
2279 CHARACTER(len=*),
PARAMETER :: routinen =
'wfi_purge_history'
2281 INTEGER :: handle, io_unit, print_level
2286 NULLIFY (dft_control, wf_history)
2288 CALL timeset(routinen, handle)
2290 print_level = logger%iter_info%print_level
2292 extension=
".scfLog")
2294 cpassert(
ASSOCIATED(qs_env))
2295 cpassert(
ASSOCIATED(qs_env%wf_history))
2296 cpassert(qs_env%wf_history%ref_count > 0)
2297 CALL get_qs_env(qs_env, dft_control=dft_control)
2299 SELECT CASE (qs_env%wf_history%interpolation_method_nr)
2307 IF (qs_env%wf_history%snapshot_count >= 2)
THEN
2308 IF (debug_this_module .AND. io_unit > 0) &
2309 WRITE (io_unit, fmt=
"(T2,A)")
"QS| Purging WFN history"
2310 CALL wfi_create(wf_history, interpolation_method_nr= &
2311 dft_control%qs_control%wf_interpolation_method_nr, &
2312 extrapolation_order=dft_control%qs_control%wf_extrapolation_order, &
2313 has_unit_metric=qs_env%has_unit_metric)
2315 wf_history=wf_history)
2317 CALL wfi_update(qs_env%wf_history, qs_env=qs_env, dt=1.0_dp)
2320 cpabort(
"Unknown extrapolation method.")
2322 CALL timestop(handle)
2345 SUBROUTINE diff_fitting(wf_history, current_overlap, coeffs, nvec, eps, io_unit, print_level, &
2346 current_overlap_kp, kpoint_weights, para_env_inter_kp)
2348 TYPE(
dbcsr_type),
INTENT(IN) :: current_overlap
2349 INTEGER,
INTENT(IN) :: nvec
2350 REAL(kind=
dp),
INTENT(OUT) :: coeffs(nvec)
2351 REAL(kind=
dp),
INTENT(IN) :: eps
2352 INTEGER,
INTENT(IN) :: io_unit, print_level
2354 OPTIONAL :: current_overlap_kp
2355 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN),
OPTIONAL :: kpoint_weights
2358 COMPLEX(KIND=dp) :: ztrace
2359 INTEGER :: i, icol_local, ikp, info, irow_local, j
2360 REAL(kind=
dp) :: error, norm_ref, weight
2361 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: b
2362 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: a
2363 TYPE(
cp_cfm_type) :: target_diff_cfm, tmp_conj_cfm, &
2364 tmp_i_cfm, tmp_j_cfm
2365 TYPE(
dbcsr_type) :: target_diff, tmp_i, tmp_j, tmp_k
2369 cpabort(
"Not enough vectors to do the fitting")
2370 ELSE IF (nvec == 1)
THEN
2375 IF (
PRESENT(current_overlap_kp))
THEN
2376 ALLOCATE (a(nvec - 1, nvec - 1), b(nvec - 1))
2381 CALL cp_cfm_create(target_diff_cfm, current_overlap_kp(1)%matrix_struct)
2382 CALL cp_cfm_create(tmp_i_cfm, current_overlap_kp(1)%matrix_struct)
2383 CALL cp_cfm_create(tmp_j_cfm, current_overlap_kp(1)%matrix_struct)
2384 CALL cp_cfm_create(tmp_conj_cfm, current_overlap_kp(1)%matrix_struct)
2386 DO ikp = 1,
SIZE(current_overlap_kp)
2388 IF (
PRESENT(kpoint_weights)) weight = kpoint_weights(ikp)
2390 CALL cp_cfm_to_cfm(current_overlap_kp(ikp), target_diff_cfm)
2392 ref_state%overlap_cfm_kp(ikp))
2397 ref_state%overlap_cfm_kp(ikp))
2399 DO icol_local = 1,
SIZE(tmp_conj_cfm%local_data, 2)
2400 DO irow_local = 1,
SIZE(tmp_conj_cfm%local_data, 1)
2401 tmp_conj_cfm%local_data(irow_local, icol_local) = &
2402 conjg(tmp_conj_cfm%local_data(irow_local, icol_local))
2405 CALL cp_cfm_trace(tmp_conj_cfm, target_diff_cfm, ztrace)
2406 b(i - 1) = b(i - 1) + weight*real(ztrace, kind=
dp)
2412 ref_state%overlap_cfm_kp(ikp))
2414 a(j - 1, i - 1) = a(j - 1, i - 1) + weight*real(ztrace, kind=
dp)
2421 a(i - 1, j - 1) = a(j - 1, i - 1)
2425 IF (
PRESENT(para_env_inter_kp))
THEN
2426 IF (
ASSOCIATED(para_env_inter_kp))
THEN
2427 CALL para_env_inter_kp%sum(a)
2428 CALL para_env_inter_kp%sum(b)
2433 a(i, i) = a(i, i) + eps**2
2436 CALL dposv(
'u', nvec - 1, 1, a, nvec - 1, b, nvec - 1, info)
2438 cpabort(
"DPOSV failed.")
2441 coeffs(1) = 1.0_dp - sum(b)
2442 coeffs(2:nvec) = b(:)
2447 DO ikp = 1,
SIZE(current_overlap_kp)
2449 IF (
PRESENT(kpoint_weights)) weight = kpoint_weights(ikp)
2454 state%overlap_cfm_kp(ikp))
2457 DO icol_local = 1,
SIZE(tmp_conj_cfm%local_data, 2)
2458 DO irow_local = 1,
SIZE(tmp_conj_cfm%local_data, 1)
2459 tmp_conj_cfm%local_data(irow_local, icol_local) = &
2460 conjg(tmp_conj_cfm%local_data(irow_local, icol_local))
2464 error = error + weight*real(ztrace, kind=
dp)
2465 CALL cp_cfm_to_cfm(ref_state%overlap_cfm_kp(ikp), tmp_conj_cfm)
2466 DO icol_local = 1,
SIZE(tmp_conj_cfm%local_data, 2)
2467 DO irow_local = 1,
SIZE(tmp_conj_cfm%local_data, 1)
2468 tmp_conj_cfm%local_data(irow_local, icol_local) = &
2469 conjg(tmp_conj_cfm%local_data(irow_local, icol_local))
2472 CALL cp_cfm_trace(tmp_conj_cfm, ref_state%overlap_cfm_kp(ikp), ztrace)
2473 norm_ref = norm_ref + weight*real(ztrace, kind=
dp)
2475 IF (
PRESENT(para_env_inter_kp))
THEN
2476 IF (
ASSOCIATED(para_env_inter_kp))
THEN
2477 CALL para_env_inter_kp%sum(error)
2478 CALL para_env_inter_kp%sum(norm_ref)
2481 IF (io_unit > 0)
THEN
2482 WRITE (unit=io_unit, fmt=
"(/,T2,A,F20.10)")
"GEXT overlap fitting error:", &
2483 sqrt(error/max(norm_ref, tiny(1.0_dp)))
2495 ALLOCATE (a(nvec - 1, nvec - 1), b(nvec - 1))
2501 CALL dbcsr_copy(target_diff, current_overlap)
2502 CALL dbcsr_add(target_diff, ref_state%overlap, 1.0_dp, -1.0_dp)
2511 CALL dbcsr_add(tmp_i, ref_state%overlap, 1.0_dp, -1.0_dp)
2512 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, tmp_i, target_diff, 0.0_dp, tmp_k)
2518 CALL dbcsr_add(tmp_j, ref_state%overlap, 1.0_dp, -1.0_dp)
2519 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, tmp_i, tmp_j, 0.0_dp, tmp_k)
2521 a(i - 1, j - 1) = a(j - 1, i - 1)
2527 a(i, i) = a(i, i) + eps**2
2531 CALL dposv(
'u', nvec - 1, 1, a, nvec - 1, b, nvec - 1, info)
2533 cpabort(
"DPOSV failed.")
2537 coeffs(1) = 1.0_dp - sum(b)
2538 coeffs(2:nvec) = b(:)
2546 CALL dbcsr_add(tmp_i, state%overlap, 1.0_dp, -coeffs(i))
2549 IF (io_unit > 0)
THEN
2550 WRITE (unit=io_unit, fmt=
"(/,T2,A,F20.10)")
"GEXT overlap fitting error:", error
2561 END SUBROUTINE diff_fitting
2583 SUBROUTINE tr_fitting(wf_history, current_overlap, coeffs, nvec, eps, io_unit, print_level, &
2584 current_overlap_kp, kpoint_weights, para_env_inter_kp)
2586 TYPE(
dbcsr_type),
INTENT(IN) :: current_overlap
2587 INTEGER,
INTENT(IN) :: nvec
2588 REAL(kind=
dp),
INTENT(OUT) :: coeffs(nvec)
2589 REAL(kind=
dp),
INTENT(IN) :: eps
2590 INTEGER,
INTENT(IN) :: io_unit, print_level
2592 OPTIONAL :: current_overlap_kp
2593 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN),
OPTIONAL :: kpoint_weights
2596 COMPLEX(KIND=dp) :: ztrace
2597 INTEGER :: i, icol_local, ikp, info, irow_local, j, &
2599 REAL(kind=
dp) :: error, norm_ref, weight
2600 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: b
2601 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: a
2602 TYPE(
cp_cfm_type) :: target_overlap_cfm, tmp_conj_cfm, &
2603 tmp_i_cfm, tmp_j_cfm
2604 TYPE(
dbcsr_type) :: target_overlap, tmp_i, tmp_j, tmp_k
2608 cpabort(
"Not enough vectors to do the fitting")
2609 ELSE IF (nvec == 1)
THEN
2614 IF (mod(nvec, 2) == 0)
THEN
2620 IF (
PRESENT(current_overlap_kp))
THEN
2621 ALLOCATE (a(ntr, ntr), b(ntr))
2626 CALL cp_cfm_create(target_overlap_cfm, current_overlap_kp(1)%matrix_struct)
2627 CALL cp_cfm_create(tmp_i_cfm, current_overlap_kp(1)%matrix_struct)
2628 CALL cp_cfm_create(tmp_j_cfm, current_overlap_kp(1)%matrix_struct)
2629 CALL cp_cfm_create(tmp_conj_cfm, current_overlap_kp(1)%matrix_struct)
2631 DO ikp = 1,
SIZE(current_overlap_kp)
2633 IF (
PRESENT(kpoint_weights)) weight = kpoint_weights(ikp)
2635 CALL cp_cfm_to_cfm(current_overlap_kp(ikp), target_overlap_cfm)
2644 DO icol_local = 1,
SIZE(tmp_conj_cfm%local_data, 2)
2645 DO irow_local = 1,
SIZE(tmp_conj_cfm%local_data, 1)
2646 tmp_conj_cfm%local_data(irow_local, icol_local) = &
2647 conjg(tmp_conj_cfm%local_data(irow_local, icol_local))
2650 CALL cp_cfm_trace(tmp_conj_cfm, target_overlap_cfm, ztrace)
2651 b(i) = b(i) + weight*real(ztrace, kind=
dp)
2658 a(j, i) = a(j, i) + weight*real(ztrace, kind=
dp)
2669 IF (
PRESENT(para_env_inter_kp))
THEN
2670 IF (
ASSOCIATED(para_env_inter_kp))
THEN
2671 CALL para_env_inter_kp%sum(a)
2672 CALL para_env_inter_kp%sum(b)
2677 a(i, i) = a(i, i) + eps**2
2680 CALL dposv(
'u', ntr, 1, a, ntr, b, ntr, info)
2682 cpabort(
"DPOSV failed.")
2686 coeffs(nvec) = -1.0_dp
2688 coeffs(i) = coeffs(i) + b(i)
2689 coeffs(nvec - i) = coeffs(nvec - i) + b(i)
2695 DO ikp = 1,
SIZE(current_overlap_kp)
2697 IF (
PRESENT(kpoint_weights)) weight = kpoint_weights(ikp)
2702 state%overlap_cfm_kp(ikp))
2705 DO icol_local = 1,
SIZE(tmp_conj_cfm%local_data, 2)
2706 DO irow_local = 1,
SIZE(tmp_conj_cfm%local_data, 1)
2707 tmp_conj_cfm%local_data(irow_local, icol_local) = &
2708 conjg(tmp_conj_cfm%local_data(irow_local, icol_local))
2712 error = error + weight*real(ztrace, kind=
dp)
2713 CALL cp_cfm_to_cfm(ref_state%overlap_cfm_kp(ikp), tmp_conj_cfm)
2714 DO icol_local = 1,
SIZE(tmp_conj_cfm%local_data, 2)
2715 DO irow_local = 1,
SIZE(tmp_conj_cfm%local_data, 1)
2716 tmp_conj_cfm%local_data(irow_local, icol_local) = &
2717 conjg(tmp_conj_cfm%local_data(irow_local, icol_local))
2720 CALL cp_cfm_trace(tmp_conj_cfm, ref_state%overlap_cfm_kp(ikp), ztrace)
2721 norm_ref = norm_ref + weight*real(ztrace, kind=
dp)
2723 IF (
PRESENT(para_env_inter_kp))
THEN
2724 IF (
ASSOCIATED(para_env_inter_kp))
THEN
2725 CALL para_env_inter_kp%sum(error)
2726 CALL para_env_inter_kp%sum(norm_ref)
2729 IF (io_unit > 0)
THEN
2730 WRITE (unit=io_unit, fmt=
"(/,T2,A,F20.10)")
"GEXT overlap fitting error:", &
2731 sqrt(error/max(norm_ref, tiny(1.0_dp)))
2743 ALLOCATE (a(ntr, ntr), b(ntr))
2749 CALL dbcsr_copy(target_overlap, current_overlap)
2750 CALL dbcsr_add(target_overlap, ref_state%overlap, 1.0_dp, 1.0_dp)
2760 CALL dbcsr_add(tmp_i, state%overlap, 1.0_dp, 1.0_dp)
2769 CALL dbcsr_add(tmp_j, state%overlap, 1.0_dp, 1.0_dp)
2770 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, tmp_i, tmp_j, 0.0_dp, tmp_k)
2778 a(i, i) = a(i, i) + eps**2
2782 CALL dposv(
'u', ntr, 1, a, ntr, b, ntr, info)
2784 cpabort(
"DPOSV failed.")
2789 coeffs(nvec) = -1.0_dp
2791 coeffs(i) = coeffs(i) + b(i)
2792 coeffs(nvec - i) = coeffs(nvec - i) + b(i)
2801 CALL dbcsr_add(tmp_i, state%overlap, 1.0_dp, -coeffs(i))
2804 IF (io_unit > 0)
THEN
2805 WRITE (unit=io_unit, fmt=
"(/,T2,A,F20.10)")
"GEXT overlap fitting error:", error
2816 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_create(matrix, matrix_struct, name, use_sp, nrow, ncol, set_zero)
creates a new full matrix with the given structure
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_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.
subroutine, public kpoint_density_transform(kpoint, denmat, wtype, tempmat, sab_nl, fmwork, for_aux_fit, pmat_ext)
generate real space density matrices in DBCSR format
subroutine, public kpoint_density_matrices(kpoint, energy_weighted, for_aux_fit)
Calculate kpoint density matrices (rho(k), owned by kpoint groups)
subroutine, public kpoint_set_mo_occupation(kpoint, smear, probe)
Given the eigenvalues of all kpoints, calculates the occupation numbers.
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method, gamma_centered)
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, 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.
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...