22 USE dbcsr_api,
ONLY: &
23 dbcsr_add, dbcsr_add_on_diag, dbcsr_checksum, dbcsr_copy, dbcsr_create, &
24 dbcsr_desymmetrize, dbcsr_dot, dbcsr_filter, dbcsr_finalize, dbcsr_get_info, &
25 dbcsr_multiply, dbcsr_p_type, dbcsr_release, dbcsr_scale, dbcsr_set, dbcsr_transposed, &
26 dbcsr_type, dbcsr_type_no_symmetry
71 #include "./base/base_uses.f90"
79 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'ec_orth_solver'
107 SUBROUTINE preconditioner(qs_env, matrix_ks, matrix_p, matrix_rhs, &
108 matrix_cg_z, eps_filter, iounit)
110 TYPE(qs_environment_type),
POINTER :: qs_env
111 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(IN), &
112 POINTER :: matrix_ks, matrix_p, matrix_rhs
113 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(INOUT), &
114 POINTER :: matrix_cg_z
115 REAL(KIND=
dp),
INTENT(IN) :: eps_filter
116 INTEGER,
INTENT(IN) :: iounit
118 CHARACTER(len=*),
PARAMETER :: routineN =
'preconditioner'
120 INTEGER :: handle, i, ispin, max_iter, nao, nspins
122 REAL(KIND=
dp) :: norm_res, t1, t2
123 REAL(KIND=
dp),
DIMENSION(:),
POINTER :: alpha, beta, new_norm, norm_ca, norm_rr
124 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_Ax, matrix_b, matrix_cg, &
126 TYPE(dft_control_type),
POINTER :: dft_control
127 TYPE(linres_control_type),
POINTER :: linres_control
129 CALL timeset(routinen, handle)
131 cpassert(
ASSOCIATED(qs_env))
132 cpassert(
ASSOCIATED(matrix_ks))
133 cpassert(
ASSOCIATED(matrix_p))
134 cpassert(
ASSOCIATED(matrix_rhs))
135 cpassert(
ASSOCIATED(matrix_cg_z))
137 NULLIFY (dft_control, linres_control)
142 dft_control=dft_control, &
143 linres_control=linres_control)
144 nspins = dft_control%nspins
145 CALL dbcsr_get_info(matrix_ks(1)%matrix, nfullrows_total=nao)
147 ALLOCATE (alpha(nspins), beta(nspins), new_norm(nspins), norm_ca(nspins), norm_rr(nspins))
153 NULLIFY (matrix_ax, matrix_b, matrix_cg, matrix_res)
160 ALLOCATE (matrix_ax(ispin)%matrix)
161 ALLOCATE (matrix_b(ispin)%matrix)
162 ALLOCATE (matrix_cg(ispin)%matrix)
163 ALLOCATE (matrix_res(ispin)%matrix)
164 CALL dbcsr_create(matrix_ax(ispin)%matrix, name=
"linop MATRIX", &
165 template=matrix_ks(1)%matrix, &
166 matrix_type=dbcsr_type_no_symmetry)
167 CALL dbcsr_create(matrix_b(ispin)%matrix, name=
"MATRIX B", &
168 template=matrix_ks(1)%matrix, &
169 matrix_type=dbcsr_type_no_symmetry)
170 CALL dbcsr_create(matrix_cg(ispin)%matrix, name=
"TRIAL MATRIX", &
171 template=matrix_ks(1)%matrix, &
172 matrix_type=dbcsr_type_no_symmetry)
173 CALL dbcsr_create(matrix_res(ispin)%matrix, name=
"RESIDUE", &
174 template=matrix_ks(1)%matrix, &
175 matrix_type=dbcsr_type_no_symmetry)
184 CALL dbcsr_copy(matrix_cg_z(ispin)%matrix, matrix_rhs(ispin)%matrix)
187 CALL dbcsr_copy(matrix_res(ispin)%matrix, matrix_rhs(ispin)%matrix)
196 CALL hessian_op1(matrix_ks, matrix_p, matrix_cg_z, matrix_b, matrix_ax, eps_filter)
200 CALL dbcsr_add(matrix_res(ispin)%matrix, matrix_ax(ispin)%matrix, 1.0_dp, -1.0_dp)
204 CALL projector(qs_env, matrix_p, matrix_res, eps_filter)
208 CALL dbcsr_copy(matrix_cg(ispin)%matrix, matrix_res(ispin)%matrix)
213 WRITE (iounit,
"(/,T10,A)")
"Preconditioning of search direction"
214 WRITE (iounit,
"(/,T10,A,T25,A,T42,A,T62,A,/,T10,A)") &
215 "Iteration",
"Stepsize",
"Convergence",
"Time", &
225 iteration:
DO i = 1, max_iter
228 CALL hessian_op1(matrix_ks, matrix_p, matrix_cg, matrix_b, matrix_ax, eps_filter)
231 CALL projector(qs_env, matrix_p, matrix_ax, eps_filter)
236 CALL dbcsr_dot(matrix_res(ispin)%matrix, matrix_res(ispin)%matrix, norm_rr(ispin))
238 cpabort(
"Preconditioner: Tr[r_j*r_j] is an abnormal value (NaN/Inf)")
240 IF (norm_rr(ispin) .LT. 0.0_dp) cpabort(
"norm_rr < 0")
241 norm_res = max(norm_res, abs(norm_rr(ispin)/real(nao,
dp)))
244 CALL dbcsr_dot(matrix_cg(ispin)%matrix, matrix_ax(ispin)%matrix, norm_ca(ispin))
247 IF (norm_ca(ispin) .LT. linres_control%eps)
THEN
248 alpha(ispin) = 1.0_dp
250 alpha(ispin) = norm_rr(ispin)/norm_ca(ispin)
255 CALL dbcsr_add(matrix_cg_z(ispin)%matrix, matrix_cg(ispin)%matrix, 1.0_dp, alpha(ispin))
258 CALL dbcsr_add(matrix_res(ispin)%matrix, matrix_ax(ispin)%matrix, 1.0_dp, -alpha(ispin))
266 CALL dbcsr_dot(matrix_res(ispin)%matrix, matrix_res(ispin)%matrix, new_norm(ispin))
267 IF (new_norm(ispin) .LT. 0.0_dp) cpabort(
"tr(r_j+1*z_j+1) < 0")
269 cpabort(
"Preconditioner: Tr[r_j+1*z_j+1] is an abnormal value (NaN/Inf)")
270 norm_res = max(norm_res, new_norm(ispin)/real(nao,
dp))
272 IF (norm_rr(ispin) .LT. linres_control%eps*0.001_dp &
273 .OR. new_norm(ispin) .LT. linres_control%eps*0.001_dp)
THEN
277 beta(ispin) = new_norm(ispin)/norm_rr(ispin)
282 CALL dbcsr_add(matrix_cg(ispin)%matrix, matrix_res(ispin)%matrix, beta(ispin), 1.0_dp)
283 CALL dbcsr_filter(matrix_cg(ispin)%matrix, eps_filter)
285 norm_rr(ispin) = new_norm(ispin)
289 IF (norm_res .LT. linres_control%eps)
THEN
294 IF (i .EQ. 1 .OR. mod(i, 1) .EQ. 0 .OR. converged)
THEN
296 WRITE (iounit,
"(T10,I5,T25,1E8.2,T33,F25.14,T58,F8.2)") &
297 i, maxval(alpha), norm_res, t2 - t1
306 WRITE (iounit,
"(/,T10,A,I4,A,/)")
"The precon solver converged in ", i,
" iterations."
313 IF (i == max_iter)
THEN
315 WRITE (iounit,
"(/,T10,A/)") &
316 "The precon solver didnt converge! Maximum number of iterations reached."
325 CALL projector(qs_env, matrix_p, matrix_cg_z, eps_filter)
333 DEALLOCATE (alpha, beta, new_norm, norm_ca, norm_rr)
335 CALL timestop(handle)
356 SUBROUTINE ec_response_ao(qs_env, p_env, matrix_hz, matrix_pz, matrix_wz, iounit, should_stop)
358 TYPE(qs_environment_type),
POINTER :: qs_env
359 TYPE(qs_p_env_type),
POINTER :: p_env
360 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(IN), &
362 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(INOUT), &
363 POINTER :: matrix_pz, matrix_wz
364 INTEGER,
INTENT(IN) :: iounit
365 LOGICAL,
INTENT(OUT) :: should_stop
367 CHARACTER(len=*),
PARAMETER :: routinen =
'ec_response_ao'
369 INTEGER :: handle, i, ispin, max_iter_lanczos, nao, &
370 nspins, s_sqrt_method, s_sqrt_order
372 REAL(kind=
dp) :: eps_filter, eps_lanczos, focc, &
373 min_shift, norm_res, old_conv, shift, &
375 REAL(kind=
dp),
DIMENSION(:),
POINTER :: alpha, beta, new_norm, norm_ca, norm_rr, &
377 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: ksmat, matrix_ax, matrix_cg, matrix_cg_z, &
378 matrix_ks, matrix_nsc, matrix_p, matrix_res, matrix_s, matrix_z, matrix_z0, rho_ao
379 TYPE(dbcsr_type) :: matrix_s_sqrt, matrix_s_sqrt_inv, &
381 TYPE(dft_control_type),
POINTER :: dft_control
382 TYPE(linres_control_type),
POINTER :: linres_control
383 TYPE(qs_rho_type),
POINTER :: rho
384 TYPE(section_vals_type),
POINTER :: solver_section
386 CALL timeset(routinen, handle)
388 cpassert(
ASSOCIATED(qs_env))
389 cpassert(
ASSOCIATED(matrix_hz))
390 cpassert(
ASSOCIATED(matrix_pz))
391 cpassert(
ASSOCIATED(matrix_wz))
393 NULLIFY (dft_control, ksmat, matrix_s, linres_control, rho)
398 dft_control=dft_control, &
399 linres_control=linres_control, &
403 nspins = dft_control%nspins
405 CALL dbcsr_get_info(matrix_s(1)%matrix, nfullrows_total=nao)
413 eps_filter = linres_control%eps_filter
417 ALLOCATE (alpha(nspins), beta(nspins), new_norm(nspins), norm_ca(nspins), norm_rr(nspins))
418 ALLOCATE (tr_rz00(nspins))
422 NULLIFY (matrix_p, matrix_ks, matrix_nsc)
427 ALLOCATE (matrix_p(ispin)%matrix)
428 ALLOCATE (matrix_ks(ispin)%matrix)
429 ALLOCATE (matrix_nsc(ispin)%matrix)
430 CALL dbcsr_create(matrix_p(ispin)%matrix, name=
"P_IN ORTHO", &
431 template=ksmat(1)%matrix, &
432 matrix_type=dbcsr_type_no_symmetry)
433 CALL dbcsr_create(matrix_ks(ispin)%matrix, name=
"KS_IN ORTHO", &
434 template=ksmat(1)%matrix, &
435 matrix_type=dbcsr_type_no_symmetry)
436 CALL dbcsr_create(matrix_nsc(ispin)%matrix, name=
"NSC IN ORTHO", &
437 template=ksmat(1)%matrix, &
438 matrix_type=dbcsr_type_no_symmetry)
440 CALL dbcsr_desymmetrize(rho_ao(ispin)%matrix, matrix_p(ispin)%matrix)
441 CALL dbcsr_desymmetrize(ksmat(ispin)%matrix, matrix_ks(ispin)%matrix)
442 CALL dbcsr_desymmetrize(matrix_hz(ispin)%matrix, matrix_nsc(ispin)%matrix)
446 IF (nspins == 1)
CALL dbcsr_scale(matrix_p(1)%matrix, 0.5_dp)
449 CALL dbcsr_create(matrix_s_sqrt, template=matrix_s(1)%matrix, &
450 matrix_type=dbcsr_type_no_symmetry)
451 CALL dbcsr_create(matrix_s_sqrt_inv, template=matrix_s(1)%matrix, &
452 matrix_type=dbcsr_type_no_symmetry)
454 SELECT CASE (s_sqrt_method)
457 matrix_s(1)%matrix, eps_filter, &
458 s_sqrt_order, eps_lanczos, max_iter_lanczos, symmetrize=.true.)
461 matrix_s(1)%matrix, eps_filter, &
462 s_sqrt_order, eps_lanczos, max_iter_lanczos)
464 cpabort(
"Unknown sqrt method.")
469 CALL transform_m_orth(matrix_p(ispin)%matrix, matrix_s_sqrt, eps_filter)
470 CALL transform_m_orth(matrix_ks(ispin)%matrix, matrix_s_sqrt_inv, eps_filter)
471 CALL transform_m_orth(matrix_nsc(ispin)%matrix, matrix_s_sqrt_inv, eps_filter)
480 CALL dbcsr_create(matrix_tmp, template=matrix_s(1)%matrix, matrix_type=dbcsr_type_no_symmetry)
482 NULLIFY (matrix_ax, matrix_cg, matrix_cg_z, matrix_res, matrix_z, matrix_z0)
491 ALLOCATE (matrix_ax(ispin)%matrix)
492 ALLOCATE (matrix_cg(ispin)%matrix)
493 ALLOCATE (matrix_cg_z(ispin)%matrix)
494 ALLOCATE (matrix_res(ispin)%matrix)
495 ALLOCATE (matrix_z(ispin)%matrix)
496 ALLOCATE (matrix_z0(ispin)%matrix)
497 CALL dbcsr_create(matrix_ax(ispin)%matrix, name=
"linop MATRIX", &
498 template=matrix_s(1)%matrix, &
499 matrix_type=dbcsr_type_no_symmetry)
500 CALL dbcsr_create(matrix_cg(ispin)%matrix, name=
"TRIAL MATRIX", &
501 template=matrix_s(1)%matrix, &
502 matrix_type=dbcsr_type_no_symmetry)
503 CALL dbcsr_create(matrix_cg_z(ispin)%matrix, name=
"MATRIX CG-Z", &
504 template=matrix_s(1)%matrix, &
505 matrix_type=dbcsr_type_no_symmetry)
506 CALL dbcsr_create(matrix_res(ispin)%matrix, name=
"RESIDUE", &
507 template=matrix_s(1)%matrix, &
508 matrix_type=dbcsr_type_no_symmetry)
509 CALL dbcsr_create(matrix_z(ispin)%matrix, name=
"Z-Matrix", &
510 template=matrix_s(1)%matrix, &
511 matrix_type=dbcsr_type_no_symmetry)
512 CALL dbcsr_create(matrix_z0(ispin)%matrix, name=
"p after precondi-Matrix", &
513 template=matrix_s(1)%matrix, &
514 matrix_type=dbcsr_type_no_symmetry)
523 IF (nspins == 1) focc = -4.0_dp
526 CALL commutator(matrix_nsc, matrix_p, matrix_res, eps_filter, .false., alpha=focc)
530 CALL dbcsr_copy(matrix_cg_z(ispin)%matrix, matrix_res(ispin)%matrix)
534 CALL projector(qs_env, matrix_p, matrix_cg_z, eps_filter)
537 CALL build_hessian_op(qs_env=qs_env, &
539 matrix_ks=matrix_ks, &
541 matrix_s_sqrt_inv=matrix_s_sqrt_inv, &
542 matrix_cg=matrix_cg_z, &
543 matrix_ax=matrix_ax, &
544 eps_filter=eps_filter)
548 CALL dbcsr_add(matrix_res(ispin)%matrix, matrix_ax(ispin)%matrix, 1.0_dp, -1.0_dp)
552 CALL projector(qs_env, matrix_p, matrix_res, eps_filter)
555 linres_control%flag =
""
556 IF (linres_control%preconditioner_type ==
precond_mlp)
THEN
560 matrix_ks=matrix_ks, &
562 matrix_rhs=matrix_res, &
563 matrix_cg_z=matrix_z0, &
564 eps_filter=eps_filter, &
566 linres_control%flag =
"PCG-AO"
570 CALL dbcsr_copy(matrix_z0(ispin)%matrix, matrix_res(ispin)%matrix)
571 linres_control%flag =
"CG-AO"
579 CALL dbcsr_copy(matrix_cg(ispin)%matrix, matrix_z0(ispin)%matrix)
582 CALL dbcsr_dot(matrix_res(ispin)%matrix, matrix_cg(ispin)%matrix, norm_rr(ispin))
584 IF (norm_rr(ispin) .LT. 0.0_dp) cpabort(
"norm_rr < 0")
585 norm_res = max(norm_res, abs(norm_rr(ispin)/real(nao,
dp)))
590 old_conv = norm_rr(1)
591 shift = min(10.0_dp, max(min_shift, 0.05_dp*old_conv))
596 WRITE (iounit,
"(/,T3,A,T16,A,T25,A,T38,A,T52,A,/,T3,A)") &
597 "Iteration",
"Method",
"Stepsize",
"Convergence",
"Time", &
603 should_stop = .false.
604 linres_control%converged = .false.
607 iteration:
DO i = 1, linres_control%max_iter
611 IF (norm_res .LT. linres_control%eps)
THEN
612 linres_control%converged = .true.
616 IF (i .EQ. 1 .OR. mod(i, 1) .EQ. 0 .OR. linres_control%converged &
617 .OR. restart .OR. should_stop)
THEN
619 WRITE (iounit,
"(T5,I5,T18,A3,T28,L1,T38,1E8.2,T48,F16.10,T68,F8.2)") &
620 i, linres_control%flag, restart, maxval(alpha), norm_res, t2 - t1
624 IF (linres_control%converged)
THEN
626 WRITE (iounit,
"(/,T2,A,I4,A,/)")
"The linear solver converged in ", i,
" iterations."
630 ELSE IF (should_stop)
THEN
632 WRITE (iounit,
"(/,T2,A,I4,A,/)")
"The linear solver did NOT converge! External stop"
639 IF (i == linres_control%max_iter)
THEN
641 WRITE (iounit,
"(/,T2,A/)") &
642 "The linear solver didnt converge! Maximum number of iterations reached."
645 linres_control%converged = .false.
649 CALL build_hessian_op(qs_env=qs_env, &
651 matrix_ks=matrix_ks, &
653 matrix_s_sqrt_inv=matrix_s_sqrt_inv, &
654 matrix_cg=matrix_cg, &
655 matrix_ax=matrix_ax, &
656 eps_filter=eps_filter)
659 CALL projector(qs_env, matrix_p, matrix_ax, eps_filter)
663 CALL dbcsr_filter(matrix_ax(ispin)%matrix, eps_filter)
665 CALL dbcsr_dot(matrix_cg(ispin)%matrix, matrix_ax(ispin)%matrix, norm_ca(ispin))
667 IF (norm_ca(ispin) .LT. 0.0_dp)
THEN
672 CALL dbcsr_add(matrix_cg(ispin)%matrix, matrix_z0(ispin)%matrix, &
673 beta(ispin), -1.0_dp)
674 CALL dbcsr_dot(matrix_res(ispin)%matrix, matrix_res(ispin)%matrix, new_norm(ispin))
675 beta(ispin) = new_norm(ispin)/tr_rz00(ispin)
676 CALL dbcsr_add(matrix_cg(ispin)%matrix, matrix_res(ispin)%matrix, &
678 norm_rr(ispin) = new_norm(ispin)
680 CALL dbcsr_copy(matrix_res(ispin)%matrix, matrix_cg(ispin)%matrix)
681 CALL dbcsr_dot(matrix_res(ispin)%matrix, matrix_res(ispin)%matrix, norm_rr(ispin))
684 CALL build_hessian_op(qs_env=qs_env, &
686 matrix_ks=matrix_ks, &
688 matrix_s_sqrt_inv=matrix_s_sqrt_inv, &
689 matrix_cg=matrix_cg, &
690 matrix_ax=matrix_ax, &
691 eps_filter=eps_filter)
694 CALL projector(qs_env, matrix_p, matrix_ax, eps_filter)
696 CALL dbcsr_dot(matrix_cg(ispin)%matrix, matrix_ax(ispin)%matrix, norm_ca(ispin))
698 cpabort(
"tr(Ap_j*p_j) < 0")
700 cpabort(
"Preconditioner: Tr[Ap_j*p_j] is an abnormal value (NaN/Inf)")
708 IF (norm_ca(ispin) .LT. linres_control%eps)
THEN
709 alpha(ispin) = 1.0_dp
711 alpha(ispin) = norm_rr(ispin)/norm_ca(ispin)
716 CALL dbcsr_add(matrix_cg_z(ispin)%matrix, matrix_cg(ispin)%matrix, 1.0_dp, alpha(ispin))
721 IF (mod(i, linres_control%restart_every) .EQ. 0)
THEN
724 CALL build_hessian_op(qs_env=qs_env, &
726 matrix_ks=matrix_ks, &
728 matrix_s_sqrt_inv=matrix_s_sqrt_inv, &
729 matrix_cg=matrix_cg_z, &
730 matrix_ax=matrix_ax, &
731 eps_filter=eps_filter)
733 CALL commutator(matrix_nsc, matrix_p, matrix_res, eps_filter, .false., alpha=focc)
736 CALL dbcsr_add(matrix_res(ispin)%matrix, matrix_ax(ispin)%matrix, 1.0_dp, -1.0_dp)
739 CALL projector(qs_env, matrix_p, matrix_res, eps_filter)
744 CALL projector(qs_env, matrix_p, matrix_ax, eps_filter)
748 CALL dbcsr_add(matrix_res(ispin)%matrix, matrix_ax(ispin)%matrix, 1.0_dp, -alpha(ispin))
754 linres_control%flag =
""
755 IF (linres_control%preconditioner_type ==
precond_mlp)
THEN
759 matrix_ks=matrix_ks, &
761 matrix_rhs=matrix_res, &
762 matrix_cg_z=matrix_z0, &
763 eps_filter=eps_filter, &
765 linres_control%flag =
"PCG-AO"
768 CALL dbcsr_copy(matrix_z0(ispin)%matrix, matrix_res(ispin)%matrix)
770 linres_control%flag =
"CG-AO"
777 CALL dbcsr_dot(matrix_res(ispin)%matrix, matrix_z0(ispin)%matrix, new_norm(ispin))
778 IF (new_norm(ispin) .LT. 0.0_dp) cpabort(
"tr(r_j+1*z_j+1) < 0")
780 cpabort(
"Preconditioner: Tr[r_j+1*z_j+1] is an abnormal value (NaN/Inf)")
781 norm_res = max(norm_res, new_norm(ispin)/real(nao,
dp))
783 IF (norm_rr(ispin) .LT. linres_control%eps .OR. new_norm(ispin) .LT. linres_control%eps)
THEN
785 linres_control%converged = .true.
787 beta(ispin) = new_norm(ispin)/norm_rr(ispin)
792 CALL dbcsr_add(matrix_cg(ispin)%matrix, matrix_z0(ispin)%matrix, beta(ispin), 1.0_dp)
793 CALL dbcsr_filter(matrix_cg(ispin)%matrix, eps_filter)
795 tr_rz00(ispin) = norm_rr(ispin)
796 norm_rr(ispin) = new_norm(ispin)
800 CALL external_control(should_stop,
"LS_SOLVER", target_time=qs_env%target_time, &
801 start_time=qs_env%start_time)
806 CALL projector(qs_env, matrix_p, matrix_cg_z, eps_filter)
809 CALL commutator(matrix_cg_z, matrix_p, matrix_z, eps_filter, .true., alpha=0.5_dp)
813 CALL transform_m_orth(matrix_z(ispin)%matrix, matrix_s_sqrt_inv, eps_filter)
816 CALL dbcsr_copy(matrix_pz(ispin)%matrix, matrix_z(ispin)%matrix, keep_sparsity=.true.)
821 CALL ec_wz_matrix(qs_env, matrix_pz, matrix_wz, eps_filter)
824 CALL dbcsr_release(matrix_tmp)
826 CALL dbcsr_release(matrix_s_sqrt)
827 CALL dbcsr_release(matrix_s_sqrt_inv)
839 DEALLOCATE (alpha, beta, new_norm, norm_ca, norm_rr)
842 CALL timestop(handle)
857 SUBROUTINE ec_wz_matrix(qs_env, matrix_z, matrix_wz, eps_filter)
859 TYPE(qs_environment_type),
POINTER :: qs_env
860 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(IN), &
862 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(INOUT), &
864 REAL(kind=
dp),
INTENT(IN) :: eps_filter
866 CHARACTER(len=*),
PARAMETER :: routinen =
'ec_wz_matrix'
868 INTEGER :: handle, ispin, nspins
869 REAL(kind=
dp) :: scaling
870 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_ks, matrix_p, matrix_s
871 TYPE(dbcsr_type) :: matrix_tmp, matrix_tmp2
872 TYPE(dft_control_type),
POINTER :: dft_control
873 TYPE(qs_rho_type),
POINTER :: rho
875 CALL timeset(routinen, handle)
877 cpassert(
ASSOCIATED(qs_env))
878 cpassert(
ASSOCIATED(matrix_z))
879 cpassert(
ASSOCIATED(matrix_wz))
882 dft_control=dft_control, &
883 matrix_ks=matrix_ks, &
886 nspins = dft_control%nspins
891 CALL dbcsr_create(matrix_tmp, template=matrix_z(1)%matrix, &
892 matrix_type=dbcsr_type_no_symmetry)
893 CALL dbcsr_create(matrix_tmp2, template=matrix_z(1)%matrix, &
894 matrix_type=dbcsr_type_no_symmetry)
898 IF (nspins == 1) scaling = 0.5_dp
904 CALL dbcsr_multiply(
"N",
"N", scaling, matrix_ks(ispin)%matrix, matrix_p(ispin)%matrix, &
905 0.0_dp, matrix_tmp, filter_eps=eps_filter, retain_sparsity=.false.)
908 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, matrix_z(ispin)%matrix, matrix_tmp, &
909 0.0_dp, matrix_tmp2, filter_eps=eps_filter, retain_sparsity=.false.)
912 CALL dbcsr_transposed(matrix_tmp, matrix_tmp2)
915 CALL dbcsr_add(matrix_tmp, matrix_tmp2, 1.0_dp, 1.0_dp)
917 CALL dbcsr_filter(matrix_tmp, eps_filter)
920 CALL dbcsr_copy(matrix_wz(ispin)%matrix, matrix_tmp, keep_sparsity=.true.)
925 CALL dbcsr_release(matrix_tmp)
926 CALL dbcsr_release(matrix_tmp2)
928 CALL timestop(handle)
930 END SUBROUTINE ec_wz_matrix
949 SUBROUTINE hessian_op1(matrix_ks, matrix_p, matrix_cg, matrix_b, matrix_Ax, eps_filter)
951 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(IN), &
952 POINTER :: matrix_ks, matrix_p, matrix_cg
953 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(INOUT), &
954 POINTER :: matrix_b, matrix_ax
955 REAL(kind=
dp),
INTENT(IN) :: eps_filter
957 CHARACTER(len=*),
PARAMETER :: routinen =
'hessian_op1'
961 CALL timeset(routinen, handle)
963 cpassert(
ASSOCIATED(matrix_ks))
964 cpassert(
ASSOCIATED(matrix_p))
965 cpassert(
ASSOCIATED(matrix_cg))
966 cpassert(
ASSOCIATED(matrix_b))
967 cpassert(
ASSOCIATED(matrix_ax))
971 CALL commutator(matrix_cg, matrix_p, matrix_b, eps_filter, .true.)
975 CALL commutator(matrix_ks, matrix_b, matrix_ax, eps_filter, .false.)
977 CALL timestop(handle)
979 END SUBROUTINE hessian_op1
998 SUBROUTINE build_hessian_op(qs_env, p_env, matrix_ks, matrix_p, matrix_s_sqrt_inv, &
999 matrix_cg, matrix_Ax, eps_filter)
1001 TYPE(qs_environment_type),
POINTER :: qs_env
1002 TYPE(qs_p_env_type),
POINTER :: p_env
1003 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(IN), &
1004 POINTER :: matrix_ks, matrix_p
1005 TYPE(dbcsr_type),
INTENT(IN) :: matrix_s_sqrt_inv
1006 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(IN), &
1007 POINTER :: matrix_cg
1008 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(INOUT), &
1009 POINTER :: matrix_ax
1010 REAL(kind=
dp),
INTENT(IN) :: eps_filter
1012 CHARACTER(len=*),
PARAMETER :: routinen =
'build_hessian_op'
1014 INTEGER :: handle, ispin, nspins
1015 REAL(kind=
dp) :: chksum
1016 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_b, rho1_ao
1017 TYPE(dft_control_type),
POINTER :: dft_control
1018 TYPE(mp_para_env_type),
POINTER :: para_env
1019 TYPE(qs_rho_type),
POINTER :: rho
1021 CALL timeset(routinen, handle)
1023 cpassert(
ASSOCIATED(qs_env))
1024 cpassert(
ASSOCIATED(matrix_ks))
1025 cpassert(
ASSOCIATED(matrix_p))
1026 cpassert(
ASSOCIATED(matrix_cg))
1027 cpassert(
ASSOCIATED(matrix_ax))
1030 dft_control=dft_control, &
1031 para_env=para_env, &
1033 nspins = dft_control%nspins
1037 DO ispin = 1, nspins
1038 ALLOCATE (matrix_b(ispin)%matrix)
1039 CALL dbcsr_create(matrix_b(ispin)%matrix, name=
"[X,P] RSP DNSTY", &
1040 template=matrix_p(1)%matrix, &
1041 matrix_type=dbcsr_type_no_symmetry)
1045 CALL hessian_op1(matrix_ks, matrix_p, matrix_cg, matrix_b, matrix_ax, eps_filter)
1048 DO ispin = 1, nspins
1049 CALL dbcsr_filter(matrix_b(ispin)%matrix, eps_filter)
1053 DO ispin = 1, nspins
1054 chksum = chksum + dbcsr_checksum(matrix_b(ispin)%matrix)
1058 IF (chksum .GT. 1.0e-14_dp)
THEN
1068 DO ispin = 1, nspins
1070 CALL transform_m_orth(matrix_b(ispin)%matrix, matrix_s_sqrt_inv, eps_filter)
1072 CALL dbcsr_filter(matrix_b(ispin)%matrix, eps_filter)
1074 CALL dbcsr_copy(rho1_ao(ispin)%matrix, matrix_b(ispin)%matrix, keep_sparsity=.true.)
1075 CALL dbcsr_copy(p_env%p1(ispin)%matrix, matrix_b(ispin)%matrix, keep_sparsity=.true.)
1081 DO ispin = 1, nspins
1082 CALL dbcsr_set(p_env%kpp1(ispin)%matrix, 0.0_dp)
1083 IF (
ASSOCIATED(p_env%kpp1_admm))
CALL dbcsr_set(p_env%kpp1_admm(ispin)%matrix, 0.0_dp)
1089 CALL hessian_op2(qs_env, p_env, matrix_ax, matrix_p, matrix_s_sqrt_inv, eps_filter)
1095 CALL timestop(handle)
1097 END SUBROUTINE build_hessian_op
1115 SUBROUTINE hessian_op2(qs_env, p_env, matrix_Ax, matrix_p, matrix_s_sqrt_inv, eps_filter)
1117 TYPE(qs_environment_type),
POINTER :: qs_env
1118 TYPE(qs_p_env_type),
POINTER :: p_env
1119 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(INOUT), &
1120 POINTER :: matrix_ax
1121 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(IN), &
1123 TYPE(dbcsr_type),
INTENT(IN) :: matrix_s_sqrt_inv
1124 REAL(kind=
dp),
INTENT(IN) :: eps_filter
1126 CHARACTER(len=*),
PARAMETER :: routinen =
'hessian_op2'
1128 INTEGER :: handle, ispin, nspins
1129 REAL(kind=
dp) :: ekin_mol
1130 TYPE(admm_type),
POINTER :: admm_env
1131 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_g, matrix_s, rho1_ao, rho_ao
1132 TYPE(dft_control_type),
POINTER :: dft_control
1133 TYPE(mp_para_env_type),
POINTER :: para_env
1134 TYPE(pw_c1d_gs_type) :: rho_tot_gspace, v_hartree_gspace
1135 TYPE(pw_c1d_gs_type),
DIMENSION(:),
POINTER :: rho1_g
1136 TYPE(pw_env_type),
POINTER :: pw_env
1137 TYPE(pw_poisson_type),
POINTER :: poisson_env
1138 TYPE(pw_pool_p_type),
DIMENSION(:),
POINTER :: pw_pools
1139 TYPE(pw_pool_type),
POINTER :: auxbas_pw_pool
1140 TYPE(pw_r3d_rs_type) :: v_hartree_rspace
1141 TYPE(pw_r3d_rs_type),
DIMENSION(:),
POINTER :: rho1_r, rho_r, tau1_r, v_xc, v_xc_tau
1142 TYPE(qs_kpp1_env_type),
POINTER :: kpp1_env
1143 TYPE(qs_rho_type),
POINTER :: rho, rho_aux
1144 TYPE(section_vals_type),
POINTER :: input, xc_section, xc_section_aux
1146 CALL timeset(routinen, handle)
1148 NULLIFY (admm_env, dft_control, input, matrix_s, para_env, rho, rho_r, rho1_g, rho1_r)
1151 admm_env=admm_env, &
1152 dft_control=dft_control, &
1154 matrix_s=matrix_s, &
1155 para_env=para_env, &
1157 nspins = dft_control%nspins
1159 cpassert(
ASSOCIATED(p_env%kpp1))
1160 cpassert(
ASSOCIATED(p_env%kpp1_env))
1161 kpp1_env => p_env%kpp1_env
1166 CALL qs_rho_get(p_env%rho1, rho_g=rho1_g, rho_r=rho1_r, tau_r=tau1_r)
1170 cpassert(
ASSOCIATED(pw_env))
1172 NULLIFY (auxbas_pw_pool, poisson_env, pw_pools)
1175 auxbas_pw_pool=auxbas_pw_pool, &
1176 pw_pools=pw_pools, &
1177 poisson_env=poisson_env)
1180 CALL auxbas_pw_pool%create_pw(pw=v_hartree_gspace)
1181 CALL auxbas_pw_pool%create_pw(pw=rho_tot_gspace)
1182 CALL auxbas_pw_pool%create_pw(pw=v_hartree_rspace)
1185 NULLIFY (v_xc, v_xc_tau, xc_section)
1187 IF (dft_control%do_admm)
THEN
1188 xc_section => admm_env%xc_section_primary
1201 xc_section=xc_section)
1203 DO ispin = 1, nspins
1204 CALL pw_scale(v_xc(ispin), v_xc(ispin)%pw_grid%dvol)
1205 IF (
ASSOCIATED(v_xc_tau))
THEN
1206 CALL pw_scale(v_xc_tau(ispin), v_xc_tau(ispin)%pw_grid%dvol)
1211 IF (dft_control%do_admm)
THEN
1213 IF (.NOT.
ASSOCIATED(kpp1_env%deriv_set_admm))
THEN
1214 xc_section_aux => admm_env%xc_section_aux
1215 CALL get_admm_env(qs_env%admm_env, rho_aux_fit=rho_aux)
1217 ALLOCATE (kpp1_env%deriv_set_admm, kpp1_env%rho_set_admm)
1219 rho_r, auxbas_pw_pool, &
1220 xc_section=xc_section_aux)
1226 CALL pw_zero(rho_tot_gspace)
1227 DO ispin = 1, nspins
1228 CALL pw_axpy(rho1_g(ispin), rho_tot_gspace)
1232 CALL pw_poisson_solve(poisson_env, rho_tot_gspace, &
1233 vhartree=v_hartree_gspace)
1234 CALL pw_transfer(v_hartree_gspace, v_hartree_rspace)
1235 CALL pw_scale(v_hartree_rspace, v_hartree_rspace%pw_grid%dvol)
1238 DO ispin = 1, nspins
1239 CALL pw_axpy(v_hartree_rspace, v_xc(ispin))
1241 IF (nspins == 1)
THEN
1242 CALL pw_scale(v_xc(1), 2.0_dp)
1243 IF (
ASSOCIATED(v_xc_tau))
CALL pw_scale(v_xc_tau(1), 2.0_dp)
1246 DO ispin = 1, nspins
1248 CALL integrate_v_rspace(v_rspace=v_xc(ispin), &
1249 pmat=rho_ao(ispin), &
1250 hmat=p_env%kpp1(ispin), &
1252 calculate_forces=.false., &
1254 IF (
ASSOCIATED(v_xc_tau))
THEN
1255 CALL integrate_v_rspace(v_rspace=v_xc_tau(ispin), &
1256 pmat=rho_ao(ispin), &
1257 hmat=p_env%kpp1(ispin), &
1259 compute_tau=.true., &
1260 calculate_forces=.false., &
1273 IF (dft_control%qs_control%do_kg)
THEN
1277 cpassert(dft_control%nimages == 1)
1281 ks_matrix=p_env%kpp1, &
1282 ekin_mol=ekin_mol, &
1283 calc_force=.false., &
1293 DO ispin = 1, nspins
1294 ALLOCATE (matrix_g(ispin)%matrix)
1295 CALL dbcsr_copy(matrix_g(ispin)%matrix, p_env%kpp1(ispin)%matrix, &
1296 name=
"MATRIX Kernel")
1301 DO ispin = 1, nspins
1302 CALL transform_m_orth(matrix_g(ispin)%matrix, matrix_s_sqrt_inv, eps_filter)
1303 CALL dbcsr_filter(matrix_g(ispin)%matrix, eps_filter)
1308 CALL commutator(matrix_g, matrix_p, matrix_ax, eps_filter, .false., 1.0_dp, 1.0_dp)
1311 CALL auxbas_pw_pool%give_back_pw(v_hartree_gspace)
1312 CALL auxbas_pw_pool%give_back_pw(v_hartree_rspace)
1313 CALL auxbas_pw_pool%give_back_pw(rho_tot_gspace)
1314 DO ispin = 1, nspins
1315 CALL auxbas_pw_pool%give_back_pw(v_xc(ispin))
1318 IF (
ASSOCIATED(v_xc_tau))
THEN
1319 DO ispin = 1, nspins
1320 CALL auxbas_pw_pool%give_back_pw(v_xc_tau(ispin))
1322 DEALLOCATE (v_xc_tau)
1327 CALL timestop(handle)
1329 END SUBROUTINE hessian_op2
1347 SUBROUTINE commutator(a, b, res, eps_filter, anticomm, alpha, beta)
1349 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(IN), &
1350 POINTER :: a, b, res
1351 REAL(kind=
dp) :: eps_filter
1353 REAL(kind=
dp),
OPTIONAL :: alpha, beta
1355 CHARACTER(LEN=*),
PARAMETER :: routinen =
'commutator'
1357 INTEGER :: handle, ispin
1358 REAL(kind=
dp) :: facc, myalpha, mybeta
1359 TYPE(dbcsr_type) :: work, work2
1361 CALL timeset(routinen, handle)
1363 cpassert(
ASSOCIATED(a))
1364 cpassert(
ASSOCIATED(b))
1365 cpassert(
ASSOCIATED(res))
1367 CALL dbcsr_create(work, template=a(1)%matrix, matrix_type=dbcsr_type_no_symmetry)
1368 CALL dbcsr_create(work2, template=a(1)%matrix, matrix_type=dbcsr_type_no_symmetry)
1372 IF (
PRESENT(alpha)) myalpha = alpha
1375 IF (
PRESENT(beta)) mybeta = beta
1378 IF (anticomm) facc = 1.0_dp
1380 DO ispin = 1,
SIZE(a)
1382 CALL dbcsr_multiply(
"N",
"N", myalpha, a(ispin)%matrix, b(ispin)%matrix, &
1383 0.0_dp, work, filter_eps=eps_filter)
1384 CALL dbcsr_transposed(work2, work)
1388 CALL dbcsr_add(work, work2, 1.0_dp, facc)
1390 CALL dbcsr_add(res(ispin)%matrix, work, mybeta, 1.0_dp)
1394 CALL dbcsr_release(work)
1395 CALL dbcsr_release(work2)
1397 CALL timestop(handle)
1399 END SUBROUTINE commutator
1414 SUBROUTINE projector(qs_env, matrix_p, matrix_io, eps_filter)
1416 TYPE(qs_environment_type),
POINTER :: qs_env
1417 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(IN), &
1419 TYPE(dbcsr_p_type),
DIMENSION(:),
INTENT(INOUT), &
1420 POINTER :: matrix_io
1421 REAL(kind=
dp),
INTENT(IN) :: eps_filter
1423 CHARACTER(len=*),
PARAMETER :: routinen =
'projector'
1425 INTEGER :: handle, ispin, nspins
1426 TYPE(dbcsr_type) :: matrix_q, matrix_tmp
1427 TYPE(dft_control_type),
POINTER :: dft_control
1428 TYPE(mp_para_env_type),
POINTER :: para_env
1430 CALL timeset(routinen, handle)
1433 dft_control=dft_control, &
1435 nspins = dft_control%nspins
1437 CALL dbcsr_create(matrix_q, template=matrix_p(1)%matrix, &
1438 matrix_type=dbcsr_type_no_symmetry)
1439 CALL dbcsr_create(matrix_tmp, template=matrix_p(1)%matrix, &
1440 matrix_type=dbcsr_type_no_symmetry)
1443 CALL dbcsr_copy(matrix_q, matrix_p(1)%matrix)
1444 CALL dbcsr_scale(matrix_q, -1.0_dp)
1445 CALL dbcsr_add_on_diag(matrix_q, 1.0_dp)
1446 CALL dbcsr_finalize(matrix_q)
1451 DO ispin = 1, nspins
1454 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, matrix_p(ispin)%matrix, matrix_io(ispin)%matrix, &
1455 0.0_dp, matrix_tmp, filter_eps=eps_filter)
1457 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, matrix_tmp, matrix_q, &
1458 0.0_dp, matrix_io(ispin)%matrix, filter_eps=eps_filter)
1461 CALL dbcsr_transposed(matrix_tmp, matrix_io(ispin)%matrix)
1462 CALL dbcsr_add(matrix_io(ispin)%matrix, matrix_tmp, 1.0_dp, -1.0_dp)
1466 CALL dbcsr_release(matrix_tmp)
1467 CALL dbcsr_release(matrix_q)
1469 CALL timestop(handle)
1471 END SUBROUTINE projector
1485 SUBROUTINE transform_m_orth(matrix, matrix_trafo, eps_filter)
1486 TYPE(dbcsr_type) :: matrix, matrix_trafo
1487 REAL(kind=
dp) :: eps_filter
1489 CHARACTER(LEN=*),
PARAMETER :: routinen =
'transform_m_orth'
1492 TYPE(dbcsr_type) :: matrix_tmp, matrix_work
1494 CALL timeset(routinen, handle)
1496 CALL dbcsr_create(matrix_work, template=matrix, matrix_type=dbcsr_type_no_symmetry)
1497 CALL dbcsr_create(matrix_tmp, template=matrix, matrix_type=dbcsr_type_no_symmetry)
1499 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, matrix, matrix_trafo, &
1500 0.0_dp, matrix_work, filter_eps=eps_filter)
1501 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, matrix_trafo, matrix_work, &
1502 0.0_dp, matrix_tmp, filter_eps=eps_filter)
1504 CALL dbcsr_transposed(matrix_work, matrix_tmp)
1505 CALL dbcsr_add(matrix_tmp, matrix_work, 0.5_dp, 0.5_dp)
1506 CALL dbcsr_copy(matrix, matrix_tmp)
1509 CALL dbcsr_filter(matrix, eps_filter)
1511 CALL dbcsr_release(matrix_tmp)
1512 CALL dbcsr_release(matrix_work)
1513 CALL timestop(handle)
1515 END SUBROUTINE transform_m_orth
Types and set/get functions for auxiliary density matrix methods.
subroutine, public get_admm_env(admm_env, mo_derivs_aux_fit, mos_aux_fit, sab_aux_fit, sab_aux_fit_asymm, sab_aux_fit_vs_orb, matrix_s_aux_fit, matrix_s_aux_fit_kp, matrix_s_aux_fit_vs_orb, matrix_s_aux_fit_vs_orb_kp, task_list_aux_fit, matrix_ks_aux_fit, matrix_ks_aux_fit_kp, matrix_ks_aux_fit_im, matrix_ks_aux_fit_dft, matrix_ks_aux_fit_hfx, matrix_ks_aux_fit_dft_kp, matrix_ks_aux_fit_hfx_kp, rho_aux_fit, rho_aux_fit_buffer, admm_dm)
Get routine for the ADMM env.
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
DBCSR operations in CP2K.
Routines to handle the external control of CP2K.
subroutine, public external_control(should_stop, flag, globenv, target_time, start_time, force_check)
External manipulations during a run : when the <PROJECT_NAME>.EXIT_$runtype command is sent the progr...
Routines used for Harris functional Kohn-Sham calculation.
subroutine, public create_kernel(qs_env, vxc, vxc_tau, rho, rho1_r, rho1_g, tau1_r, xc_section, compute_virial, virial_xc)
Creation of second derivative xc-potential.
AO-based conjugate-gradient response solver routines.
subroutine, public ec_response_ao(qs_env, p_env, matrix_hz, matrix_pz, matrix_wz, iounit, should_stop)
AO-based conjugate gradient linear response solver. In goes the right hand side B of the equation AZ=...
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)
compute the sqrt of a matrix via the sign function and the corresponding Newton-Schulz iterations the...
subroutine, public matrix_sqrt_proot(matrix_sqrt, matrix_sqrt_inv, matrix, threshold, order, eps_lanczos, max_iter_lanczos, symmetrize, converged)
compute the sqrt of a matrix via the general algorithm for the p-th root of Richters et al....
Routines for a Kim-Gordon-like partitioning into molecular subunits.
subroutine, public kg_ekin_subset(qs_env, ks_matrix, ekin_mol, calc_force, do_kernel, pmat_ext)
Calculates the subsystem Hohenberg-Kohn kinetic energy and the forces.
Defines the basic variable types.
integer, parameter, public dp
Machine interface based on Fortran 2003 and POSIX.
subroutine, public m_flush(lunit)
flushes units if the &GLOBAL flag is set accordingly
real(kind=dp) function, public m_walltime()
returns time from a real-time clock, protected against rolling early/easily
Collection of simple mathematical functions and subroutines.
logical function, public abnormal_value(a)
determines if a value is not normal (e.g. for Inf and Nan) based on IO to work also under optimizatio...
Interface to the message passing library MPI.
computes preconditioners, and implements methods to apply them currently used in qs_ot
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
functions related to the poisson solver on regular grids
Manages a pool of grids (to be used for example as tmp objects), but can also be used to instantiate ...
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_RI_aux_kp, matrix_s, matrix_s_RI_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_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, 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, rhs)
Get the QUICKSTEP environment.
Integrate single or product functions over a potential on a RS grid.
basis types for the calculation of the perturbation of density theory.
subroutine, public apply_xc_admm(qs_env, p_env)
...
subroutine, public apply_hfx(qs_env, p_env)
Update action of TDDFPT operator on trial vectors by adding exact-exchange term.
Type definitiona for linear response calculations.
Utility functions for the perturbation calculations.
subroutine, public p_env_finish_kpp1(qs_env, p_env)
...
subroutine, public p_env_update_rho(p_env, qs_env)
...
subroutine, public p_env_check_i_alloc(p_env, qs_env)
checks that the intenal storage is allocated, and allocs it if needed
basis types for the calculation of the perturbation of density theory.
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...
Exchange and Correlation functional calculations.
subroutine, public xc_prep_2nd_deriv(deriv_set, rho_set, rho_r, pw_pool, xc_section, tau_r)
Prepare objects for the calculation of the 2nd derivatives of the density functional....