103#include "../base/base_uses.f90"
109 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'rt_propagation_methods'
134 CHARACTER(len=*),
PARAMETER :: routinen =
'propagation_step'
136 INTEGER :: aspc_order, handle, i, im, re, unit_nr
138 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: delta_mos, mos_new
140 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: delta_p, h_last_iter, ks_mix, ks_mix_im, &
141 matrix_ks, matrix_ks_im, matrix_s, &
145 CALL timeset(routinen, handle)
148 IF (logger%para_env%is_source())
THEN
154 NULLIFY (cell, delta_p, rho_new, delta_mos, mos_new)
155 NULLIFY (ks_mix, ks_mix_im)
157 CALL get_qs_env(qs_env, cell=cell, matrix_s=matrix_s, dft_control=dft_control)
159 IF (rtp%iter == 1)
THEN
162 IF (rtp_control%fixed_ions)
CALL set_ks_env(qs_env%ks_env, s_mstruct_changed=.false.)
167 IF (dft_control%apply_efield_field)
THEN
168 IF (any(cell%perd(1:3) /= 0)) &
169 cpabort(
"Length gauge (efield) and periodicity are not compatible")
171 ELSE IF (rtp_control%velocity_gauge)
THEN
172 IF (dft_control%apply_vector_potential) &
178 IF (.NOT. rtp_control%fixed_ions)
THEN
181 rtp%delta_iter = 100.0_dp
182 rtp%mixing_factor = 1.0_dp
184 aspc_order = rtp_control%aspc_order
185 CALL aspc_extrapolate(rtp, matrix_s, aspc_order)
186 IF (rtp%linear_scaling)
THEN
193 IF (.NOT. rtp_control%fixed_ions)
THEN
196 rtp%converged = .false.
198 IF (rtp%linear_scaling)
THEN
200 CALL get_rtp(rtp=rtp, rho_new=rho_new)
203 DO i = 1,
SIZE(rho_new)
205 CALL dbcsr_create(delta_p(i)%matrix, template=rho_new(i)%matrix)
206 CALL dbcsr_copy(delta_p(i)%matrix, rho_new(i)%matrix)
210 CALL get_rtp(rtp=rtp, mos_new=mos_new)
211 ALLOCATE (delta_mos(
SIZE(mos_new)))
212 DO i = 1,
SIZE(mos_new)
214 matrix_struct=mos_new(i)%matrix_struct, &
221 matrix_ks=matrix_ks, &
222 matrix_ks_im=matrix_ks_im)
224 CALL get_rtp(rtp=rtp, h_last_iter=h_last_iter)
226 IF (unit_nr > 0)
THEN
227 WRITE (unit_nr,
'(t3,a,2f16.8)')
"Mixing the Hamiltonians to improve robustness, mixing factor: ", rtp%mixing_factor
231 DO i = 1,
SIZE(matrix_ks)
233 CALL dbcsr_create(ks_mix(i)%matrix, template=matrix_ks(1)%matrix)
235 CALL dbcsr_create(ks_mix_im(i)%matrix, template=matrix_ks(1)%matrix, matrix_type=dbcsr_type_antisymmetric)
237 DO i = 1,
SIZE(matrix_ks)
240 CALL dbcsr_add(ks_mix(i)%matrix, matrix_ks(i)%matrix, 0.0_dp, rtp%mixing_factor)
241 CALL dbcsr_add(ks_mix(i)%matrix, h_last_iter(re)%matrix, 1.0_dp, 1.0_dp - rtp%mixing_factor)
242 IF (rtp%propagate_complex_ks)
THEN
243 CALL dbcsr_add(ks_mix_im(i)%matrix, matrix_ks_im(i)%matrix, 0.0_dp, rtp%mixing_factor)
244 CALL dbcsr_add(ks_mix_im(i)%matrix, h_last_iter(im)%matrix, 1.0_dp, 1.0_dp - rtp%mixing_factor)
247 CALL calc_sinvh(rtp, ks_mix, ks_mix_im, rtp_control)
248 DO i = 1,
SIZE(matrix_ks)
251 CALL dbcsr_copy(h_last_iter(re)%matrix, ks_mix(i)%matrix)
252 IF (rtp%propagate_complex_ks)
THEN
253 CALL dbcsr_copy(h_last_iter(im)%matrix, ks_mix_im(i)%matrix)
259 CALL calc_sinvh(rtp, matrix_ks, matrix_ks_im, rtp_control)
260 DO i = 1,
SIZE(matrix_ks)
263 CALL dbcsr_copy(h_last_iter(re)%matrix, matrix_ks(i)%matrix)
264 IF (rtp%propagate_complex_ks)
THEN
265 CALL dbcsr_copy(h_last_iter(im)%matrix, matrix_ks_im(i)%matrix)
270 CALL compute_propagator_matrix(rtp, rtp_control%propagator)
272 SELECT CASE (rtp_control%mat_exp)
274 IF (rtp%linear_scaling)
THEN
288 CALL step_finalize(qs_env, rtp_control, delta_mos, delta_p)
289 IF (rtp%linear_scaling)
THEN
295 CALL timestop(handle)
311 SUBROUTINE step_finalize(qs_env, rtp_control, delta_mos, delta_P)
314 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: delta_mos
317 CHARACTER(len=*),
PARAMETER :: routinen =
'step_finalize'
319 INTEGER :: handle, i, ihist
320 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: mos_new, mos_old
321 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: exp_h_new, exp_h_old, matrix_ks, &
322 matrix_ks_im, rho_new, rho_old, s_mat
326 CALL timeset(routinen, handle)
328 CALL get_qs_env(qs_env=qs_env, rtp=rtp, matrix_s=s_mat, &
329 matrix_ks=matrix_ks, matrix_ks_im=matrix_ks_im, energy=energy)
330 CALL get_rtp(rtp=rtp, exp_h_old=exp_h_old, exp_h_new=exp_h_new)
332 IF (rtp_control%sc_check_start < rtp%iter)
THEN
333 rtp%delta_iter_old = rtp%delta_iter
334 IF (rtp%linear_scaling)
THEN
337 CALL rt_convergence(rtp, s_mat(1)%matrix, delta_mos, rtp%delta_iter)
339 rtp%converged = (rtp%delta_iter < rtp_control%eps_ener)
344 IF (rtp_control%sc_check_start < rtp%iter + 1)
THEN
345 IF (rtp%delta_iter/rtp%delta_iter_old > 0.9)
THEN
346 rtp%mixing_factor = max(rtp%mixing_factor/2.0_dp, 0.125_dp)
352 IF (rtp%converged)
THEN
353 IF (rtp%linear_scaling)
THEN
354 CALL get_rtp(rtp=rtp, rho_old=rho_old, rho_new=rho_new)
355 CALL purify_mcweeny_complex_nonorth(rho_new, s_mat, rtp%filter_eps, rtp%filter_eps_small, &
356 rtp_control%mcweeny_max_iter, rtp_control%mcweeny_eps)
359 DO i = 1,
SIZE(rho_new)
360 CALL dbcsr_copy(rho_old(i)%matrix, rho_new(i)%matrix)
363 CALL get_rtp(rtp=rtp, mos_old=mos_old, mos_new=mos_new)
364 DO i = 1,
SIZE(mos_new)
368 IF (rtp_control%propagator ==
do_em)
CALL calc_sinvh(rtp, matrix_ks, matrix_ks_im, rtp_control)
369 DO i = 1,
SIZE(exp_h_new)
370 CALL dbcsr_copy(exp_h_old(i)%matrix, exp_h_new(i)%matrix)
372 ihist = mod(rtp%istep, rtp_control%aspc_order) + 1
373 IF (rtp_control%fixed_ions)
THEN
380 rtp%energy_new = energy%total
382 CALL timestop(handle)
384 END SUBROUTINE step_finalize
393 SUBROUTINE compute_propagator_matrix(rtp, propagator)
395 INTEGER :: propagator
397 CHARACTER(len=*),
PARAMETER :: routinen =
'compute_propagator_matrix'
400 REAL(kind=
dp) :: dt, prefac
401 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: exp_h_new, exp_h_old, propagator_matrix
403 CALL timeset(routinen, handle)
404 CALL get_rtp(rtp=rtp, exp_h_new=exp_h_new, exp_h_old=exp_h_old, &
405 propagator_matrix=propagator_matrix, dt=dt)
409 DO i = 1,
SIZE(exp_h_new)
410 CALL dbcsr_add(propagator_matrix(i)%matrix, exp_h_new(i)%matrix, 0.0_dp, prefac)
411 IF (propagator ==
do_em) &
412 CALL dbcsr_add(propagator_matrix(i)%matrix, exp_h_old(i)%matrix, 1.0_dp, prefac)
415 CALL timestop(handle)
417 END SUBROUTINE compute_propagator_matrix
429 SUBROUTINE calc_sinvh(rtp, matrix_ks, matrix_ks_im, rtp_control)
431 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_ks_im
434 CHARACTER(len=*),
PARAMETER :: routinen =
'calc_SinvH'
435 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
437 INTEGER :: handle, im, ispin, re
438 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: exp_h, sinvb, sinvh, sinvh_imag
442 CALL timeset(routinen, handle)
443 CALL get_rtp(rtp=rtp, s_inv=s_inv, exp_h_new=exp_h)
444 DO ispin = 1,
SIZE(matrix_ks)
450 CALL dbcsr_create(matrix_ks_nosym, template=matrix_ks(1)%matrix, matrix_type=
"N")
453 DO ispin = 1,
SIZE(matrix_ks)
457 CALL dbcsr_multiply(
"N",
"N", one, s_inv, matrix_ks_nosym, zero, exp_h(im)%matrix, &
458 filter_eps=rtp%filter_eps)
459 IF (.NOT. rtp_control%fixed_ions)
THEN
460 CALL get_rtp(rtp=rtp, sinvh=sinvh)
461 CALL dbcsr_copy(sinvh(ispin)%matrix, exp_h(im)%matrix)
466 IF (rtp%propagate_complex_ks)
THEN
467 DO ispin = 1,
SIZE(matrix_ks)
473 CALL dbcsr_multiply(
"N",
"N", -one, s_inv, matrix_ks_nosym, zero, exp_h(re)%matrix, &
474 filter_eps=rtp%filter_eps)
475 IF (.NOT. rtp_control%fixed_ions)
THEN
476 CALL get_rtp(rtp=rtp, sinvh_imag=sinvh_imag)
478 CALL dbcsr_copy(sinvh_imag(ispin)%matrix, exp_h(re)%matrix)
483 IF (.NOT. rtp_control%fixed_ions)
THEN
484 CALL get_rtp(rtp=rtp, b_mat=b_mat, sinvb=sinvb)
486 CALL dbcsr_multiply(
"N",
"N", one, s_inv, b_mat, zero, matrix_ks_nosym, filter_eps=rtp%filter_eps)
487 DO ispin = 1,
SIZE(matrix_ks)
491 CALL dbcsr_add(exp_h(re)%matrix, matrix_ks_nosym, 1.0_dp, 1.0_dp)
493 CALL dbcsr_copy(sinvb(ispin)%matrix, matrix_ks_nosym)
499 CALL timestop(handle)
516 CHARACTER(len=*),
PARAMETER :: routinen =
's_matrices_create'
517 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
520 TYPE(
dbcsr_type),
POINTER :: s_half, s_inv, s_minus_half
522 CALL timeset(routinen, handle)
524 CALL get_rtp(rtp=rtp, s_inv=s_inv)
526 IF (rtp%linear_scaling)
THEN
527 CALL get_rtp(rtp=rtp, s_half=s_half, s_minus_half=s_minus_half)
529 rtp%newton_schulz_order, rtp%lanzcos_threshold, rtp%lanzcos_max_iter)
530 CALL dbcsr_multiply(
"N",
"N", one, s_minus_half, s_minus_half, zero, s_inv, &
531 filter_eps=rtp%filter_eps)
535 blacs_env=rtp%ao_ao_fmstruct%context)
537 blacs_env=rtp%ao_ao_fmstruct%context, uplo_to_full=.true.)
540 CALL timestop(handle)
551 SUBROUTINE complex_frobenius_norm(frob_norm, mat_re, mat_im)
553 REAL(kind=
dp),
INTENT(out) :: frob_norm
556 CHARACTER(len=*),
PARAMETER :: routinen =
'complex_frobenius_norm'
557 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
559 INTEGER :: col_atom, handle, row_atom
561 REAL(
dp),
DIMENSION(:, :),
POINTER :: block_values, block_values2
565 CALL timeset(routinen, handle)
580 block_values = block_values2*block_values2
584 block_values = block_values + block_values2*block_values2
586 block_values = sqrt(block_values)
593 CALL timestop(handle)
595 END SUBROUTINE complex_frobenius_norm
608 SUBROUTINE purify_mcweeny_complex_nonorth(P, s_mat, eps, eps_small, max_iter, threshold)
611 REAL(kind=
dp),
INTENT(in) :: eps, eps_small
612 INTEGER,
INTENT(in) :: max_iter
613 REAL(kind=
dp),
INTENT(in) :: threshold
615 CHARACTER(len=*),
PARAMETER :: routinen =
'purify_mcweeny_complex_nonorth'
616 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
618 INTEGER :: handle, i, im,
imax, ispin, re, unit_nr
619 REAL(kind=
dp) :: frob_norm
621 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: ps, psp, tmp
623 CALL timeset(routinen, handle)
626 IF (logger%para_env%is_source())
THEN
632 NULLIFY (tmp, ps, psp)
644 IF (
SIZE(p) == 2)
THEN
648 DO ispin = 1,
SIZE(p)/2
651 imax = max(max_iter, 1)
653 CALL dbcsr_multiply(
"N",
"N", one, p(re)%matrix, s_mat(1)%matrix, &
654 zero, ps(re)%matrix, filter_eps=eps_small)
655 CALL dbcsr_multiply(
"N",
"N", one, p(im)%matrix, s_mat(1)%matrix, &
656 zero, ps(im)%matrix, filter_eps=eps_small)
658 p(re)%matrix, p(im)%matrix, zero, psp(re)%matrix, psp(im)%matrix, &
659 filter_eps=eps_small)
660 CALL dbcsr_copy(tmp(re)%matrix, psp(re)%matrix)
661 CALL dbcsr_copy(tmp(im)%matrix, psp(im)%matrix)
662 CALL dbcsr_add(tmp(re)%matrix, p(re)%matrix, 1.0_dp, -1.0_dp)
663 CALL dbcsr_add(tmp(im)%matrix, p(im)%matrix, 1.0_dp, -1.0_dp)
664 CALL complex_frobenius_norm(frob_norm, tmp(re)%matrix, tmp(im)%matrix)
665 IF (unit_nr > 0)
WRITE (unit_nr,
'(t3,a,2f16.8)')
"Deviation from idempotency: ", frob_norm
666 IF (frob_norm > threshold .AND. max_iter > 0)
THEN
670 psp(re)%matrix, psp(im)%matrix, 3.0_dp, p(re)%matrix, p(im)%matrix, &
671 filter_eps=eps_small)
676 CALL dbcsr_add(p(re)%matrix, tmp(re)%matrix, one/2, one/2)
678 CALL dbcsr_add(p(im)%matrix, tmp(im)%matrix, one/2, -one/2)
685 CALL dbcsr_add(p(re)%matrix, tmp(re)%matrix, one/2, one/2)
687 CALL dbcsr_add(p(im)%matrix, tmp(im)%matrix, one/2, -one/2)
689 IF (
SIZE(p) == 2)
THEN
697 CALL timestop(handle)
699 END SUBROUTINE purify_mcweeny_complex_nonorth
707 SUBROUTINE aspc_extrapolate(rtp, matrix_s, aspc_order)
710 INTEGER,
INTENT(in) :: aspc_order
712 CHARACTER(len=*),
PARAMETER :: routinen =
'aspc_extrapolate'
713 COMPLEX(KIND=dp),
PARAMETER :: cone = (1.0_dp, 0.0_dp), &
714 czero = (0.0_dp, 0.0_dp)
715 REAL(kind=
dp),
PARAMETER :: one = 1.0_dp, zero = 0.0_dp
717 INTEGER :: handle, i, iaspc, icol_local, ihist, &
718 imat, k, kdbl, n, naspc, ncol_local, &
720 REAL(kind=
dp) :: alpha
724 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: mos_new
725 TYPE(
cp_fm_type),
DIMENSION(:, :),
POINTER :: mo_hist
726 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: rho_new, s_hist
727 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rho_hist
730 CALL timeset(routinen, handle)
734 IF (rtp%linear_scaling)
THEN
735 CALL get_rtp(rtp=rtp, rho_new=rho_new)
737 CALL get_rtp(rtp=rtp, mos_new=mos_new)
740 naspc = min(rtp%istep, aspc_order)
741 IF (rtp%linear_scaling)
THEN
743 rho_hist => rtp%history%rho_history
746 alpha = (-1.0_dp)**(iaspc + 1)*real(iaspc, kind=
dp)* &
748 ihist = mod(rtp%istep - iaspc, aspc_order) + 1
750 CALL dbcsr_add(rho_new(imat)%matrix, rho_hist(imat, ihist)%matrix, zero, alpha)
752 CALL dbcsr_add(rho_new(imat)%matrix, rho_hist(imat, ihist)%matrix, one, alpha)
757 mo_hist => rtp%history%mo_history
761 alpha = (-1.0_dp)**(iaspc + 1)*real(iaspc, kind=
dp)* &
763 ihist = mod(rtp%istep - iaspc, aspc_order) + 1
772 mo_hist => rtp%history%mo_history
773 s_hist => rtp%history%s_history
774 DO i = 1,
SIZE(mos_new)/2
775 NULLIFY (matrix_struct, matrix_struct_new)
778 mos_new(2*i)%matrix_struct, &
779 mos_new(2*i)%matrix_struct%context, &
793 ncol_local=ncol_local)
796 template_fmstruct=mos_new(2*i)%matrix_struct, &
807 DO icol_local = 1, ncol_local
808 fm_tmp%local_data(:, icol_local) = mos_new(2*i - 1)%local_data(:, icol_local)
809 fm_tmp%local_data(:, icol_local + ncol_local) = mos_new(2*i)%local_data(:, icol_local)
814 DO icol_local = 1, ncol_local
815 cfm_tmp%local_data(:, icol_local) = cmplx(fm_tmp1%local_data(:, icol_local), &
816 fm_tmp1%local_data(:, icol_local + ncol_local),
dp)
817 cfm_tmp1%local_data(:, icol_local) = cmplx(mos_new(2*i - 1)%local_data(:, icol_local), &
818 mos_new(2*i)%local_data(:, icol_local),
dp)
820 CALL parallel_gemm(
'C',
'N', k, k, n, cone, cfm_tmp1, cfm_tmp, czero, csc)
823 DO icol_local = 1, ncol_local
824 mos_new(2*i - 1)%local_data(:, icol_local) = real(cfm_tmp1%local_data(:, icol_local),
dp)
825 mos_new(2*i)%local_data(:, icol_local) = aimag(cfm_tmp1%local_data(:, icol_local))
839 CALL timestop(handle)
841 END SUBROUTINE aspc_extrapolate
853 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: mos
861 IF (rtp%linear_scaling)
THEN
863 CALL dbcsr_copy(rtp%history%rho_history(i, ihist)%matrix, rho(i)%matrix)
867 CALL cp_fm_to_fm(mos(i), rtp%history%mo_history(i, ihist))
869 IF (
PRESENT(s_mat))
THEN
870 IF (
ASSOCIATED(rtp%history%s_history(ihist)%matrix))
THEN
874 ALLOCATE (rtp%history%s_history(ihist)%matrix)
875 CALL dbcsr_copy(rtp%history%s_history(ihist)%matrix, s_mat(1)%matrix)
894 CHARACTER(len=*),
PARAMETER :: routinen =
'rtp_localize'
896 INTEGER :: handle, ispin, output_unit
897 INTEGER,
DIMENSION(:, :, :),
POINTER :: marked_states
898 LOGICAL :: do_homo, do_mo_cubes, do_wannier_cubes, &
900 REAL(kind=
dp),
DIMENSION(:),
POINTER :: mo_eigenvalues
902 TYPE(
cp_fm_type),
ALLOCATABLE,
DIMENSION(:) :: mo_localized, occupied_orbs
903 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: mo_coeff
914 loc_section, print_key
916 CALL timeset(routinen, handle)
919 IF (rtp%linear_scaling)
THEN
920 CALL timestop(handle)
926 NULLIFY (auxbas_pw_pool, dft_control, dft_section, input, loc_print_section, &
927 loc_section, logger, marked_states, mo_coeff, mo_eigenvalues, mos, &
928 occupied_evals, particles, print_key, pw_env, qs_loc_env)
933 IF (output_unit > 0)
THEN
934 WRITE (unit=output_unit, fmt=
"(A)")
"LOCALIZE| Localizing propagated orbitals"
938 CALL get_qs_env(qs_env, dft_control=dft_control, input=input, pw_env=pw_env)
940 CALL get_rtp(rtp, mos_new=mo_coeff)
977 CALL pw_env_get(pw_env, auxbas_pw_pool=auxbas_pw_pool)
978 CALL auxbas_pw_pool%create_pw(wf_r)
979 CALL auxbas_pw_pool%create_pw(wf_g)
982 ALLOCATE (occupied_evals(dft_control%nspins))
983 ALLOCATE (occupied_orbs(
SIZE(mo_coeff)))
984 ALLOCATE (mo_localized(
SIZE(mo_coeff)))
986 CALL get_rtp(rtp, mos_new=mo_coeff)
987 DO ispin = 1,
SIZE(mo_coeff)
988 occupied_orbs(ispin) = mo_coeff(ispin)
989 CALL cp_fm_create(mo_localized(ispin), mo_coeff(ispin)%matrix_struct)
990 CALL cp_fm_to_fm(mo_coeff(ispin), mo_localized(ispin))
993 DO ispin = 1, dft_control%nspins
994 CALL get_mo_set(mos(ispin), eigenvalues=mo_eigenvalues)
995 occupied_evals(ispin)%array => mo_eigenvalues
999 ALLOCATE (qs_loc_env)
1002 CALL qs_loc_init(qs_env, qs_loc_env, loc_section, mo_localized, do_homo, do_mo_cubes)
1004 particles, occupied_orbs, occupied_evals, marked_states)
1005 CALL loc_dipole(input, dft_control, qs_loc_env, logger, qs_env)
1007 DO ispin = 1,
SIZE(mo_localized)
1010 DEALLOCATE (mo_localized)
1011 DEALLOCATE (occupied_orbs)
1012 DEALLOCATE (occupied_evals)
1014 DEALLOCATE (qs_loc_env)
1015 IF (
ASSOCIATED(marked_states))
THEN
1016 DEALLOCATE (marked_states)
1020 CALL auxbas_pw_pool%give_back_pw(wf_r)
1021 CALL auxbas_pw_pool%give_back_pw(wf_g)
1023 CALL timestop(handle)
static int imax(int x, int y)
Returns the larger of two given integers (missing from the C standard)
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public kuhne2007
integer, save, public schreder2021
integer, save, public kolafa2004
Handles all functions related to the CELL.
various utilities that regard array of different kinds: output, allocation,... maybe it is not a good...
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_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...
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...
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_cfm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
Creates a new full matrix with the given structure.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
subroutine, public dbcsr_transposed(transposed, normal, shallow_data_copy, transpose_distribution, use_distribution)
...
subroutine, public dbcsr_scale(matrix, alpha_scalar)
...
subroutine, public dbcsr_deallocate_matrix(matrix)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_desymmetrize(matrix_a, matrix_b)
...
subroutine, public dbcsr_copy(matrix_b, matrix_a, name, keep_sparsity, keep_imaginary)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
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_init_p(matrix)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset, transposed)
...
subroutine, public dbcsr_filter(matrix, eps)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_release(matrix)
...
subroutine, public dbcsr_add(matrix_a, matrix_b, alpha_scalar, beta_scalar)
...
Interface to (sca)lapack for the Cholesky based procedures.
subroutine, public cp_dbcsr_cholesky_decompose(matrix, n, para_env, blacs_env)
used to replace a symmetric positive def. matrix M with its cholesky decomposition U: M = U^T * U,...
subroutine, public cp_dbcsr_cholesky_invert(matrix, n, para_env, blacs_env, uplo_to_full)
used to replace the cholesky decomposition by the inverse
real(dp) function, public dbcsr_frobenius_norm(matrix)
Compute the frobenius norm of a dbcsr matrix.
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
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....
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_double(fmstruct, struct, context, col, row)
creates a struct with twice the number of blocks on each core. If matrix A has to be multiplied with ...
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
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, nrow, ncol, set_zero)
creates a new full matrix with the given structure
various routines to log and control the output. The idea is that decisions about where to log should ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
all routins needed for a nonperiodic electric field
subroutine, public efield_potential_lengh_gauge(qs_env)
Replace the original implementation of the electric-electronic interaction in the length gauge....
Routines useful for iterative matrix calculations.
subroutine, public matrix_sqrt_newton_schulz(matrix_sqrt, matrix_sqrt_inv, matrix, threshold, order, eps_lanczos, max_iter_lanczos, symmetrize, converged, iounit)
compute the sqrt of a matrix via the sign function and the corresponding Newton-Schulz iterations the...
Defines the basic variable types.
integer, parameter, public dp
Routines for calculating a complex matrix exponential with dbcsr matrices. Based on the code in matri...
subroutine, public cp_complex_dbcsr_gemm_3(transa, transb, alpha, a_re, a_im, b_re, b_im, beta, c_re, c_im, filter_eps)
Convenience function. Computes the matrix multiplications needed for the multiplication of complex sp...
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.
basic linear algebra operations for full matrixes
represent a simple array based list of the given type
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 ...
Utility subroutine for qs energy calculation.
subroutine, public qs_energies_init(qs_env, calc_forces)
Refactoring of qs_energies_scf. Driver routine for the initial setup and calculations for a qs energy...
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.
routines that build the Kohn-Sham matrix (i.e calculate the coulomb and xc parts
subroutine, public qs_ks_update_qs_env(qs_env, calculate_forces, just_energy, print_active)
updates the Kohn Sham matrix of the given qs_env (facility method)
subroutine, public set_ks_env(ks_env, v_hartree_rspace, s_mstruct_changed, rho_changed, exc_accint, potential_changed, forces_up_to_date, complex_ks, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, kinetic, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_ks_im_kp, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, vee, neighbor_list_id, kpoints, sab_orb, sab_all, sac_ae, sac_ppl, sac_lri, sap_ppnl, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_vdw, sab_scp, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, task_list, task_list_soft, subsys, dft_control, dbcsr_dist, distribution_2d, pw_env, para_env, blacs_env)
...
subroutine, public loc_dipole(input, dft_control, qs_loc_env, logger, qs_env)
Computes and prints the Dipole (using localized charges)
subroutine, public get_localization_info(qs_env, qs_loc_env, loc_section, mo_local, wf_r, wf_g, particles, coeff, evals, marked_states)
Performs localization of the orbitals.
New version of the module for the localization of the molecular orbitals This should be able to use d...
subroutine, public qs_loc_env_release(qs_loc_env)
...
subroutine, public qs_loc_env_create(qs_loc_env)
...
Some utilities for the construction of the localization environment.
subroutine, public qs_loc_control_init(qs_loc_env, loc_section, do_homo, do_mixed, do_xas, nloc_xas, spin_xas)
initializes everything needed for localization of the HOMOs
subroutine, public qs_loc_init(qs_env, qs_loc_env, localize_section, mos_localized, do_homo, do_mo_cubes, mo_loc_history, evals, tot_zeff_corr, do_mixed)
initializes everything needed for localization of the molecular orbitals
Definition and initialisation of the mo data type.
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count)
Get the components of a MO set data structure.
Routines for calculating a complex matrix exponential.
subroutine, public propagate_exp(rtp, rtp_control)
performs propagations if explicit matrix exponentials are used ETRS: exp(i*H(t+dt)*dt/2)*exp(i*H(t)*d...
subroutine, public propagate_bch(rtp, rtp_control)
Propagation using the Baker-Campbell-Hausdorff expansion, currently only works for rtp.
subroutine, public propagate_exp_density(rtp, rtp_control)
Propagation of the density matrix instead of the atomic orbitals via a matrix exponential.
subroutine, public propagate_arnoldi(rtp, rtp_control)
computes U_prop*MOs using arnoldi subspace algorithm
Routines for propagating the orbitals.
subroutine, public rtp_localize(qs_env, rtp)
Computes Maximally localised Wannier functions and print properties according to FORCE_EVALDFTLOCALIZ...
subroutine, public calc_sinvh(rtp, matrix_ks, matrix_ks_im, rtp_control)
computes S_inv*H, if needed Sinv*B and S_inv*H_imag and store these quantities to the
subroutine, public propagation_step(qs_env, rtp, rtp_control)
performs a single propagation step a(t+Dt)=U(t+Dt,t)*a(0) and calculates the new exponential
subroutine, public put_data_to_history(rtp, mos, rho, s_mat, ihist)
...
subroutine, public s_matrices_create(s_mat, rtp)
calculates the needed overlap-like matrices depending on the way the exponential is calculated,...
Routine for the real time propagation output.
subroutine, public report_density_occupation(filter_eps, rho)
Reports the sparsity pattern of the complex density matrix.
subroutine, public rt_convergence(rtp, matrix_s, delta_mos, delta_eps)
computes the convergence criterion for RTP and EMD
subroutine, public rt_convergence_density(rtp, delta_p, delta_eps)
computes the convergence criterion for RTP and EMD based on the density matrix
Types and set_get for real time propagation depending on runtype and diagonalization method different...
subroutine, public get_rtp(rtp, exp_h_old, exp_h_new, h_last_iter, rho_old, rho_next, rho_new, mos, mos_new, mos_old, mos_next, s_inv, s_half, s_minus_half, b_mat, c_mat, propagator_matrix, mixing, mixing_factor, s_der, dt, nsteps, sinvh, sinvh_imag, sinvb, admm_mos)
...
subroutine, public calc_update_rho_sparse(qs_env)
Copies the density matrix back into the qs_envrhorho_ao.
subroutine, public calc_s_derivs(qs_env)
Calculates dS/dR respectily the velocity weighted derivatves only needed for ehrenfest MD.
subroutine, public calc_update_rho(qs_env)
calculates the density from the complex MOs and passes the density to qs_env.
Routines to perform the RTP in the velocity gauge.
subroutine, public velocity_gauge_ks_matrix(qs_env, subtract_nl_term)
...
subroutine, public update_vector_potential(qs_env, dft_control)
Update the vector potential in the case where a time-dependant electric field is apply.
Type defining parameters related to the simulation cell.
represent a pointer to a 1d array
Represent a complex full matrix.
keeps the information about the structure of a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...
represent a list of objects
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 ...
contains all the info needed by quickstep to calculate the spread of a selected set of orbitals and i...