85#include "./base/base_uses.f90"
91 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'dft_plus_u'
106 SUBROUTINE plus_u(qs_env, matrix_h, matrix_w)
110 POINTER :: matrix_h, matrix_w
112 CHARACTER(LEN=*),
PARAMETER :: routinen =
'plus_u'
114 INTEGER :: handle, output_unit, print_level
115 LOGICAL :: orthonormal_basis, should_output
120 CALL timeset(routinen, handle)
122 cpassert(
ASSOCIATED(qs_env))
124 NULLIFY (input, dft_control)
130 dft_control=dft_control)
138 orthonormal_basis = .false.
142 print_level = logger%iter_info%print_level
145 (.NOT.
PRESENT(matrix_w)))
147 extension=
".plus_u", &
148 ignore_should_output=should_output, &
149 log_filename=.false.)
153 SELECT CASE (dft_control%plus_u_method_id)
155 IF (orthonormal_basis)
THEN
158 CALL mulliken(qs_env, orthonormal_basis, matrix_h, &
159 should_output, output_unit, print_level)
161 CALL lowdin(qs_env, matrix_h, matrix_w, &
162 should_output, output_unit, print_level)
165 CALL mulliken(qs_env, orthonormal_basis, matrix_h, &
166 should_output, output_unit, print_level)
168 CALL mulliken_charges(qs_env, orthonormal_basis, matrix_h, matrix_w, &
169 should_output, output_unit, print_level)
171 CALL tensorial(qs_env, matrix_h, matrix_w, &
172 should_output, output_unit, print_level)
174 cpabort(
"Invalid DFT+U method requested")
178 ignore_should_output=should_output)
180 CALL timestop(handle)
213 SUBROUTINE lowdin(qs_env, matrix_h, matrix_w, should_output, output_unit, &
218 POINTER :: matrix_h, matrix_w
219 LOGICAL,
INTENT(IN) :: should_output
220 INTEGER,
INTENT(IN) :: output_unit, print_level
222 CHARACTER(LEN=*),
PARAMETER :: routinen =
'lowdin'
224 CHARACTER(LEN=10) :: spin_info
225 CHARACTER(LEN=6),
ALLOCATABLE,
DIMENSION(:) :: symbol
226 CHARACTER(LEN=default_string_length) :: atomic_kind_name
227 INTEGER :: atom_a, handle, i, i0, iatom, ikind, iorb, isb, iset, isgf, ishell, ispin, j, &
228 jsb, jset, jsgf, jshell, lu, m, max_scf, n, natom, natom_of_kind, nimg, nkind, norb, nsb, &
229 nsbsize, nset, nsgf, nsgf_kind, nspin
230 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_sgf_atom
231 INTEGER,
DIMENSION(1) :: iloc
232 INTEGER,
DIMENSION(:),
POINTER :: atom_list, nshell, orbitals
233 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf, l, last_sgf
234 LOGICAL :: debug, dft_plus_u_atom, do_kpoints, &
235 found, if_plus_j, just_energy, smear
236 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: orb_occ
237 REAL(kind=
dp) :: eps_scf, eps_u_ramping, fspin, hund_j, occ, perturbation_strength, sij, &
238 trq, trq2, trqxq_hund_j, u_minus_j, u_minus_j_target, u_ramping
239 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigval, q_eigval
240 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: orbq, q_eigvec, q_matrix, q_opp_matrix, &
242 REAL(kind=
dp),
CONTIGUOUS,
DIMENSION(:, :), &
243 POINTER :: local_data
244 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: q_block, q_opp_block, v_block, vhxc_block
247 TYPE(
cp_fm_type) :: fm_sev, fm_work1, fm_work2, slambda
248 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: fm_wmat
250 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_vhxc
251 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_p, matrix_s
253 TYPE(
dbcsr_type),
POINTER :: sm_h, sm_p, sm_p_opp, sm_s, sm_vhxc, sm_w
260 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
264 CALL timeset(routinen, handle)
268 NULLIFY (sm_h, sm_p, sm_p_opp, sm_s, sm_w, vhxc_block, sm_vhxc, matrix_vhxc)
276 atomic_kind_set=atomic_kind_set, &
277 qs_kind_set=qs_kind_set, &
278 dft_control=dft_control, &
279 do_kpoints=do_kpoints, &
282 matrix_s_kp=matrix_s, &
283 matrix_vhxc=matrix_vhxc, &
284 particle_set=particle_set, &
291 energy%dft_plus_u = 0.0_dp
293 nspin = dft_control%nspins
294 nimg = dft_control%nimages
295 IF (dft_control%mtlr_dft_with_perturbation)
THEN
296 IF (.NOT.
ASSOCIATED(matrix_vhxc))
THEN
297 cpabort(
"MTLR requires the projected Hxc matrix for every spin channel.")
299 IF (
SIZE(matrix_vhxc) /= nspin)
THEN
300 cpabort(
"The number of projected Hxc matrices does not match the spin channels.")
316 nkind =
SIZE(atomic_kind_set)
318 ALLOCATE (first_sgf_atom(natom))
319 first_sgf_atom(:) = 0
322 first_sgf=first_sgf_atom)
324 IF (
PRESENT(matrix_h) .OR.
PRESENT(matrix_w))
THEN
325 just_energy = .false.
337 IF (hund_j /= 0.0_dp)
THEN
339 IF (
ASSOCIATED(orbitals))
THEN
340 CALL cp_abort(__location__,
"ENFORCE_OCCUPATION is incompatible with a nonzero Hund J "// &
341 "in the Lowdin DFT+U+J method.")
349 fm_wmat => scf_env%scf_work1
350 fmstruct => fm_wmat(1)%matrix_struct
353 fm_s_half => scf_env%s_half
354 cpassert(
ASSOCIATED(fm_s_half))
358 CALL cp_fm_create(matrix=fm_work1, matrix_struct=fmstruct, &
359 name=
"FULL WORK MATRIX 1")
360 CALL cp_fm_create(matrix=fm_work2, matrix_struct=fmstruct, &
361 name=
"FULL WORK MATRIX 2")
366 IF (
PRESENT(matrix_w))
THEN
368 cpabort(
"Lowdin forces with k-points NYA in DFT+U")
370 CALL cp_fm_create(matrix=fm_sev, matrix_struct=fmstruct)
371 CALL cp_fm_create(matrix=slambda, matrix_struct=fmstruct)
372 ALLOCATE (eigval(nsgf), slam(nsgf, 1))
373 sm_s => matrix_s(1, 1)%matrix
378 IF (eigval(i) > 0._dp)
THEN
379 slam(i, 1) = sqrt(eigval(i))
381 cpabort(
"S matrix not positive definit")
391 DO i = 1,
SIZE(local_data, 2)
392 DO j = 1,
SIZE(local_data, 1)
393 sij = local_data(j, i)
394 IF (sij > 0.0_dp) sij = 1.0_dp/sij
395 local_data(j, i) = sij
398 DEALLOCATE (eigval, slam)
403 cpabort(
"Lowdin option with k-points NYA in DFT+U")
404 ALLOCATE (orbq(nsgf, nspin))
410 sm_s => matrix_s(1, 1)%matrix
412 IF (if_plus_j .AND. nspin == 2)
THEN
421 IF (if_plus_j .AND. nspin == 2)
THEN
426 IF (dft_control%mtlr_dft_with_perturbation)
THEN
427 IF (ispin == 1) perturbation_strength = 0.9_dp*dft_control%perturbation_strength
428 IF (ispin == 2) perturbation_strength = 1.1_dp*dft_control%perturbation_strength
429 IF (.NOT.
ASSOCIATED(matrix_vhxc(ispin)%matrix))
THEN
430 cpabort(
"MTLR projected Hxc matrix is not initialized.")
432 sm_vhxc => matrix_vhxc(ispin)%matrix
436 cpabort(
"Lowdin option with k-points NYA in DFT+U")
439 sm_p => matrix_p(ispin, 1)%matrix
447 matrix_a=fm_s_half, &
453 output_unit=output_unit)
455 output_unit=output_unit)
457 output_unit=output_unit)
466 IF (if_plus_j .AND. nspin == 2)
THEN
469 sm_p_opp => matrix_p(3 - ispin, 1)%matrix
477 matrix_a=fm_s_half, &
497 atom_list=atom_list, &
498 name=atomic_kind_name, &
502 dft_plus_u_atom=dft_plus_u_atom, &
503 l_of_dft_plus_u=lu, &
505 basis_set=orb_basis_set, &
506 u_minus_j=u_minus_j, &
508 u_minus_j_target=u_minus_j_target, &
509 u_ramping=u_ramping, &
510 eps_u_ramping=eps_u_ramping, &
517 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
518 IF (.NOT. dft_plus_u_atom) cycle
522 IF ((ispin == 1) .AND. (u_ramping > 0.0_dp))
THEN
523 IF (qs_env%scf_env%iter_delta <= eps_u_ramping)
THEN
524 u_minus_j = min(u_minus_j + u_ramping, u_minus_j_target)
525 CALL set_qs_kind(qs_kind_set(ikind), u_minus_j=u_minus_j)
527 IF (should_output .AND. (output_unit > 0))
THEN
528 WRITE (unit=output_unit, fmt=
"(T3,A,3X,A,F0.3,A)") &
529 "Kind name: "//trim(adjustl(atomic_kind_name)), &
530 "U(eff) = ", u_minus_j*
evolt,
" eV"
534 IF (u_minus_j == 0.0_dp .AND. hund_j == 0.0_dp) cycle
538 first_sgf=first_sgf, &
547 DO ishell = 1, nshell(iset)
548 IF (l(ishell, iset) == lu) nsb = nsb + 1
555 ALLOCATE (q_matrix(n, n))
556 q_matrix(:, :) = 0.0_dp
558 IF (hund_j /= 0.0_dp .AND. nspin == 2)
THEN
559 ALLOCATE (q_opp_matrix(n, n))
560 q_opp_matrix(:, :) = 0.0_dp
563 IF (dft_control%mtlr_dft_with_perturbation .AND. &
564 dft_control%mtlr_ikind == ikind)
THEN
565 dft_control%vhxc(ispin) = 0.0_dp
566 dft_control%trq(ispin) = 0.0_dp
571 IF (output_unit > 0)
THEN
572 ALLOCATE (symbol(nsbsize))
577 WRITE (unit=spin_info, fmt=
"(A8,I2)")
" of spin", ispin
581 WRITE (unit=output_unit, fmt=
"(/,T3,A,I0,A,/,/,T5,A,10(2X,A6))") &
582 "DFT+U occupations"//trim(spin_info)//
" for the atoms of atomic kind ", ikind, &
583 ": "//trim(atomic_kind_name), &
584 "Atom Shell ", (adjustr(symbol(i)), i=1, nsbsize),
" Trace"
590 DO iatom = 1, natom_of_kind
591 atom_a = atom_list(iatom)
592 q_matrix(:, :) = 0.0_dp
593 IF (
ALLOCATED(q_opp_matrix))
THEN
594 q_opp_matrix(:, :) = 0.0_dp
603 IF (hund_j /= 0.0_dp .AND. nspin == 2)
THEN
610 IF (dft_control%mtlr_dft_with_perturbation .AND. &
611 dft_control%mtlr_ikind == ikind .AND. &
612 qs_kind_set(ikind)%dft_plus_u%lr_atom == atom_a)
THEN
620 IF (
ASSOCIATED(q_block))
THEN
624 DO ishell = 1, nshell(iset)
625 IF (l(ishell, iset) /= lu) cycle
626 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
630 DO jshell = 1, nshell(jset)
631 IF (l(jshell, jset) /= lu) cycle
632 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
634 IF (isgf == jsgf) q_matrix(i, j) = q_block(isgf, jsgf)
635 IF (hund_j /= 0.0_dp .AND. nspin == 2 .AND.
ASSOCIATED(q_opp_block))
THEN
636 IF (isgf == jsgf) q_opp_matrix(i, j) = q_opp_block(isgf, jsgf)
638 IF (
ASSOCIATED(vhxc_block) .AND. &
639 dft_control%mtlr_dft_with_perturbation .AND. &
640 dft_control%mtlr_ikind == ikind .AND. &
641 qs_kind_set(ikind)%dft_plus_u%lr_atom == atom_a .AND. &
643 dft_control%vhxc(ispin) = dft_control%vhxc(ispin) + vhxc_block(isgf, isgf)
644 dft_control%trq(ispin) = dft_control%trq(ispin) + q_block(isgf, isgf)
654 IF (
ASSOCIATED(orbitals))
THEN
655 IF ((qs_env%scf_env%iter_delta >= eps_scf) .OR. &
656 ((qs_env%scf_env%outer_scf%iter_count == 0) .AND. &
657 (qs_env%scf_env%iter_count <= max_scf)))
THEN
658 ALLOCATE (orb_occ(nsbsize))
659 ALLOCATE (q_eigval(n))
661 ALLOCATE (q_eigvec(n, n))
662 q_eigvec(:, :) = 0.0_dp
663 norb =
SIZE(orbitals)
664 CALL jacobi(q_matrix, q_eigval, q_eigvec)
665 q_matrix(:, :) = 0.0_dp
668 DO i = (isb - 1)*nsbsize + 1, isb*nsbsize
669 trq = trq + q_eigval(i)
672 occ = trq/real(norb, kind=
dp)
677 iloc = maxloc(q_eigvec(:, isb*nsbsize))
678 jsb = int((iloc(1) - 1)/nsbsize) + 1
680 i0 = (jsb - 1)*nsbsize + 1
682 DO j = i0, jsb*nsbsize
686 IF (.NOT. orb_occ(lu + m + 1))
THEN
688 orb_occ(lu + m + 1) = .true.
692 iorb = i0 + lu + orbitals(i)
693 orb_occ(lu + orbitals(i) + 1) = .true.
695 cpassert(iorb /= -1000)
696 iloc = maxloc(q_eigvec(iorb, :))
697 q_eigval(iloc(1)) = min(occ, trq)
698 q_matrix(:, iloc(1)) = q_eigval(iloc(1))*q_eigvec(:, iloc(1))
699 trq = trq - q_eigval(iloc(1))
702 q_matrix(:, :) = matmul(q_matrix, transpose(q_eigvec))
704 DEALLOCATE (q_eigval)
705 DEALLOCATE (q_eigvec)
711 trqxq_hund_j = 0.0_dp
713 trq = trq + q_matrix(i, i)
715 trq2 = trq2 + q_matrix(i, j)*q_matrix(j, i)
716 IF (hund_j /= 0.0_dp)
THEN
718 trqxq_hund_j = trqxq_hund_j + q_matrix(i, j)*q_opp_matrix(j, i)
720 trqxq_hund_j = trqxq_hund_j + q_matrix(i, j)*q_matrix(j, i)
726 trq2 = fspin*fspin*trq2
729 energy%dft_plus_u = energy%dft_plus_u + 0.5_dp*u_minus_j*(trq - trq2)/fspin
730 IF (hund_j /= 0.0_dp)
THEN
731 trqxq_hund_j = fspin*fspin*trqxq_hund_j
732 energy%dft_plus_u = energy%dft_plus_u + 0.5_dp*hund_j*trqxq_hund_j/fspin
736 IF (.NOT. just_energy)
THEN
742 cpassert(
ASSOCIATED(v_block))
746 DO ishell = 1, nshell(iset)
747 IF (l(ishell, iset) /= lu) cycle
748 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
752 DO jshell = 1, nshell(jset)
753 IF (l(jshell, jset) /= lu) cycle
754 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
756 IF (isgf == jsgf)
THEN
757 v_block(isgf, isgf) = u_minus_j*(0.5_dp - fspin*q_matrix(i, i))
758 IF (dft_control%mtlr_dft_with_perturbation .AND. &
759 dft_control%mtlr_ikind == ikind .AND. &
760 qs_kind_set(ikind)%dft_plus_u%lr_atom == atom_a)
THEN
761 v_block(isgf, isgf) = v_block(isgf, isgf) + perturbation_strength
764 cpassert(abs(q_matrix(j, i)) < 1.0e-14_dp)
765 IF (hund_j /= 0.0_dp .AND. nspin == 2)
THEN
766 cpassert(abs(q_opp_matrix(j, i)) < 1.0e-14_dp)
768 v_block(isgf, jsgf) = -u_minus_j*fspin*q_matrix(j, i)
770 IF (hund_j /= 0.0_dp)
THEN
772 v_block(isgf, jsgf) = v_block(isgf, jsgf) + hund_j*fspin*q_opp_matrix(j, i)
774 v_block(isgf, jsgf) = v_block(isgf, jsgf) + hund_j*fspin*q_matrix(j, i)
789 CALL para_env%sum(q_matrix)
790 IF (output_unit > 0)
THEN
791 ALLOCATE (q_work(nsb, nsbsize))
792 q_work(:, :) = 0.0_dp
795 DO i = (isb - 1)*nsbsize + 1, isb*nsbsize
797 q_work(isb, j) = q_matrix(i, i)
801 WRITE (unit=output_unit, fmt=
"(T3,I6,2X,I6,2X,10F8.3)") &
802 atom_a, isb, q_work(isb, :), sum(q_work(isb, :))
804 WRITE (unit=output_unit, fmt=
"(T12,A,2X,10F8.3)") &
805 "Total", (sum(q_work(:, i)), i=1, nsbsize), sum(q_work)
806 WRITE (unit=output_unit, fmt=
"(A)")
""
810 WRITE (unit=output_unit, fmt=
"(T9,70I10)") (i, i=1, n)
812 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_matrix(i, :)
815 ALLOCATE (q_eigval(n))
817 ALLOCATE (q_eigvec(n, n))
818 q_eigvec(:, :) = 0.0_dp
819 CALL jacobi(q_matrix, q_eigval, q_eigvec)
820 WRITE (unit=output_unit, fmt=
"(/,T9,70I10)") (i, i=1, n)
821 WRITE (unit=output_unit, fmt=
"(T9,71F10.6)") (q_eigval(i), i=1, n), &
824 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_eigvec(i, :)
826 DEALLOCATE (q_eigval)
827 DEALLOCATE (q_eigvec)
832 ALLOCATE (q_work(nsgf_kind, nsgf_kind))
833 q_work(:, :) = 0.0_dp
834 IF (
ASSOCIATED(q_block)) q_work(:, :) = q_block(:, :)
835 CALL para_env%sum(q_work)
836 IF (output_unit > 0)
THEN
837 norb =
SIZE(q_work, 1)
838 WRITE (unit=output_unit, fmt=
"(/,T9,200I10)") (i, i=1, norb)
840 WRITE (unit=output_unit, fmt=
"(T3,I6,200F10.6)") i, q_work(i, :)
842 ALLOCATE (q_eigval(norb))
844 ALLOCATE (q_eigvec(norb, norb))
845 q_eigvec(:, :) = 0.0_dp
846 CALL jacobi(q_work, q_eigval, q_eigvec)
847 WRITE (unit=output_unit, fmt=
"(/,T9,200I10)") (i, i=1, norb)
848 WRITE (unit=output_unit, fmt=
"(T9,201F10.6)") (q_eigval(i), i=1, norb), &
849 sum(q_eigval(1:norb))
851 WRITE (unit=output_unit, fmt=
"(T3,I6,200F10.6)") i, q_eigvec(i, :)
853 DEALLOCATE (q_eigval)
854 DEALLOCATE (q_eigvec)
862 IF (dft_control%mtlr_dft_with_perturbation .AND. &
863 dft_control%mtlr_ikind == ikind)
THEN
864 dft_control%vhxc(ispin) = dft_control%vhxc(ispin)/real(n,
dp)
865 CALL para_env%sum(dft_control%vhxc(ispin))
866 CALL para_env%sum(dft_control%trq(ispin))
869 IF (
ALLOCATED(q_matrix))
THEN
870 DEALLOCATE (q_matrix)
873 IF (
ALLOCATED(q_opp_matrix))
THEN
874 DEALLOCATE (q_opp_matrix)
880 IF (
PRESENT(matrix_h))
THEN
882 cpabort(
"Lowdin option with k-points NYA in DFT+U")
884 sm_h => matrix_h(ispin, 1)%matrix
893 IF (
PRESENT(matrix_w))
THEN
895 sm_p => matrix_p(ispin, 1)%matrix
896 sm_w => matrix_w(ispin, 1)%matrix
901 CALL parallel_gemm(
'N',
'N', nsgf, nsgf, nsgf, 1.0_dp, fm_work1, fm_sev, 0.0_dp, fm_work2)
902 CALL parallel_gemm(
'T',
'N', nsgf, nsgf, nsgf, 1.0_dp, fm_sev, fm_work2, 0.0_dp, fm_work1)
906 CALL parallel_gemm(
'N',
'N', nsgf, nsgf, nsgf, -2.0_dp, fm_sev, fm_work2, 0.0_dp, fm_work1)
913 IF (
PRESENT(matrix_w))
THEN
920 CALL para_env%sum(energy%dft_plus_u)
922 IF (energy%dft_plus_u < 0.0_dp)
THEN
923 CALL cp_warn(__location__, &
924 "DFT+U energy contribution is negative possibly due "// &
925 "to unphysical Lowdin charges!")
937 IF (if_plus_j .AND. nspin == 2)
THEN
941 CALL timestop(handle)
943 END SUBROUTINE lowdin
975 SUBROUTINE mulliken(qs_env, orthonormal_basis, matrix_h, should_output, &
976 output_unit, print_level)
979 LOGICAL,
INTENT(IN) :: orthonormal_basis
982 LOGICAL,
INTENT(IN) :: should_output
983 INTEGER,
INTENT(IN) :: output_unit, print_level
985 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mulliken'
987 CHARACTER(LEN=10) :: spin_info
988 CHARACTER(LEN=6),
ALLOCATABLE,
DIMENSION(:) :: symbol
989 CHARACTER(LEN=default_string_length) :: atomic_kind_name
990 INTEGER :: atom_a, handle, i, i0, iatom, ic, ikind, iorb, isb, iset, isgf, ishell, ispin, j, &
991 jsb, jset, jsgf, jshell, lu, m, max_scf, n, natom, natom_of_kind, nimg, nkind, norb, nsb, &
992 nsbsize, nset, nsgf_kind, nspin
993 INTEGER,
DIMENSION(1) :: iloc
994 INTEGER,
DIMENSION(:),
POINTER :: atom_list, nshell, orbitals
995 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf, l, last_sgf
996 LOGICAL :: debug, dft_plus_u_atom, found, &
997 just_energy, occupation_enforced, smear
998 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: is_plus_u_kind, orb_occ
999 REAL(kind=
dp) :: eps_scf, eps_u_ramping, fspin, occ, trq, &
1000 trq2, u_minus_j, u_minus_j_target, &
1002 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: q_eigval
1003 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: q_eigvec, q_matrix, q_work
1004 REAL(kind=
dp),
DIMENSION(:),
POINTER :: nelec
1005 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: h_block, p_block, q_block, s_block, &
1009 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_p, matrix_s
1010 TYPE(
dbcsr_type),
POINTER :: sm_h, sm_p, sm_q, sm_s, sm_v
1016 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1019 CALL timeset(routinen, handle)
1024 NULLIFY (atomic_kind_set)
1025 NULLIFY (qs_kind_set)
1026 NULLIFY (dft_control)
1036 NULLIFY (orb_basis_set)
1038 NULLIFY (particle_set)
1054 occupation_enforced = .false.
1057 atomic_kind_set=atomic_kind_set, &
1058 qs_kind_set=qs_kind_set, &
1059 dft_control=dft_control, &
1061 particle_set=particle_set, &
1065 cpassert(
ASSOCIATED(atomic_kind_set))
1066 cpassert(
ASSOCIATED(dft_control))
1067 cpassert(
ASSOCIATED(energy))
1068 cpassert(
ASSOCIATED(particle_set))
1069 cpassert(
ASSOCIATED(rho))
1071 IF (orthonormal_basis)
THEN
1076 matrix_s_kp=matrix_s)
1077 cpassert(
ASSOCIATED(matrix_s))
1079 nimg = dft_control%nimages
1085 energy%dft_plus_u = 0.0_dp
1087 nspin = dft_control%nspins
1089 IF (nspin == 2)
THEN
1101 nkind =
SIZE(atomic_kind_set)
1103 ALLOCATE (is_plus_u_kind(nkind))
1104 is_plus_u_kind(:) = .false.
1106 IF (
PRESENT(matrix_h))
THEN
1107 just_energy = .false.
1109 just_energy = .true.
1117 IF (.NOT. orthonormal_basis)
THEN
1118 sm_s => matrix_s(1, ic)%matrix
1121 IF (
PRESENT(matrix_h))
THEN
1123 sm_h => matrix_h(ispin, ic)%matrix
1130 sm_p => matrix_p(ispin, ic)%matrix
1132 IF (.NOT.
ASSOCIATED(sm_q))
THEN
1138 IF (.NOT.
ASSOCIATED(sm_v))
THEN
1152 IF (.NOT.
ASSOCIATED(p_block)) cycle
1159 cpassert(
ASSOCIATED(q_block))
1161 IF (orthonormal_basis)
THEN
1163 DO isgf = 1,
SIZE(q_block, 1)
1164 q_block(isgf, isgf) = p_block(isgf, isgf)
1172 cpassert(
ASSOCIATED(s_block))
1174 DO jsgf = 1,
SIZE(p_block, 2)
1175 DO isgf = 1,
SIZE(p_block, 1)
1176 q_block(isgf, jsgf) = p_block(isgf, jsgf)*s_block(isgf, jsgf)
1197 atom_list=atom_list, &
1198 name=atomic_kind_name, &
1199 natom=natom_of_kind)
1202 dft_plus_u_atom=dft_plus_u_atom, &
1203 l_of_dft_plus_u=lu, &
1205 basis_set=orb_basis_set, &
1206 u_minus_j=u_minus_j, &
1207 u_minus_j_target=u_minus_j_target, &
1208 u_ramping=u_ramping, &
1209 eps_u_ramping=eps_u_ramping, &
1211 orbitals=orbitals, &
1218 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
1219 IF (.NOT. dft_plus_u_atom) cycle
1224 IF ((ispin == 1) .AND. (u_ramping > 0.0_dp))
THEN
1225 IF (qs_env%scf_env%iter_delta <= eps_u_ramping)
THEN
1226 u_minus_j = min(u_minus_j + u_ramping, u_minus_j_target)
1227 CALL set_qs_kind(qs_kind_set(ikind), u_minus_j=u_minus_j)
1229 IF (should_output .AND. (output_unit > 0))
THEN
1230 WRITE (unit=output_unit, fmt=
"(T3,A,3X,A,F0.3,A)") &
1231 "Kind name: "//trim(adjustl(atomic_kind_name)), &
1232 "U(eff) = ", u_minus_j*
evolt,
" eV"
1236 IF (u_minus_j == 0.0_dp) cycle
1238 is_plus_u_kind(ikind) = .true.
1243 first_sgf=first_sgf, &
1245 last_sgf=last_sgf, &
1253 DO ishell = 1, nshell(iset)
1254 IF (l(ishell, iset) == lu) nsb = nsb + 1
1258 nsbsize = (2*lu + 1)
1261 ALLOCATE (q_matrix(n, n))
1262 q_matrix(:, :) = 0.0_dp
1267 IF (output_unit > 0)
THEN
1268 ALLOCATE (symbol(nsbsize))
1273 WRITE (unit=spin_info, fmt=
"(A8,I2)")
" of spin", ispin
1277 WRITE (unit=output_unit, fmt=
"(/,T3,A,I0,A,/,/,T5,A,10(2X,A6))") &
1278 "DFT+U occupations"//trim(spin_info)//
" for the atoms of atomic kind ", ikind, &
1279 ": "//trim(atomic_kind_name), &
1280 "Atom Shell ", (adjustr(symbol(i)), i=1, nsbsize),
" Trace"
1287 DO iatom = 1, natom_of_kind
1289 atom_a = atom_list(iatom)
1291 q_matrix(:, :) = 0.0_dp
1303 IF (
ASSOCIATED(q_block))
THEN
1307 DO ishell = 1, nshell(iset)
1308 IF (l(ishell, iset) /= lu) cycle
1309 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
1313 DO jshell = 1, nshell(jset)
1314 IF (l(jshell, jset) /= lu) cycle
1315 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
1317 q_matrix(i, j) = q_block(isgf, jsgf)
1327 IF (
ASSOCIATED(orbitals))
THEN
1328 IF ((qs_env%scf_env%iter_delta >= eps_scf) .OR. &
1329 ((qs_env%scf_env%outer_scf%iter_count == 0) .AND. &
1330 (qs_env%scf_env%iter_count <= max_scf)))
THEN
1331 ALLOCATE (orb_occ(nsbsize))
1332 ALLOCATE (q_eigval(n))
1333 q_eigval(:) = 0.0_dp
1334 ALLOCATE (q_eigvec(n, n))
1335 q_eigvec(:, :) = 0.0_dp
1336 norb =
SIZE(orbitals)
1337 CALL jacobi(q_matrix, q_eigval, q_eigvec)
1338 q_matrix(:, :) = 0.0_dp
1339 IF (nelec(ispin) >= 0.5_dp)
THEN
1340 trq = nelec(ispin)/sum(q_eigval(1:n))
1341 q_eigval(1:n) = trq*q_eigval(1:n)
1345 DO i = (isb - 1)*nsbsize + 1, isb*nsbsize
1346 trq = trq + q_eigval(i)
1349 occ = trq/real(norb, kind=
dp)
1353 orb_occ(:) = .false.
1354 iloc = maxloc(q_eigvec(:, isb*nsbsize))
1355 jsb = int((iloc(1) - 1)/nsbsize) + 1
1357 i0 = (jsb - 1)*nsbsize + 1
1359 DO j = i0, jsb*nsbsize
1363 IF (.NOT. orb_occ(lu + m + 1))
THEN
1365 orb_occ(lu + m + 1) = .true.
1369 iorb = i0 + lu + orbitals(i)
1370 orb_occ(lu + orbitals(i) + 1) = .true.
1372 cpassert(iorb /= -1000)
1373 iloc = maxloc(q_eigvec(iorb, :))
1374 q_eigval(iloc(1)) = min(occ, trq)
1375 q_matrix(:, iloc(1)) = q_eigval(iloc(1))*q_eigvec(:, iloc(1))
1376 trq = trq - q_eigval(iloc(1))
1379 q_matrix(:, :) = matmul(q_matrix, transpose(q_eigvec))
1380 DEALLOCATE (orb_occ)
1381 DEALLOCATE (q_eigval)
1382 DEALLOCATE (q_eigvec)
1383 occupation_enforced = .true.
1391 trq = trq + q_matrix(i, i)
1393 trq2 = trq2 + q_matrix(i, j)*q_matrix(j, i)
1398 trq2 = fspin*fspin*trq2
1402 energy%dft_plus_u = energy%dft_plus_u + 0.5_dp*u_minus_j*(trq - trq2)/fspin
1406 IF (.NOT. just_energy)
THEN
1413 cpassert(
ASSOCIATED(v_block))
1417 DO ishell = 1, nshell(iset)
1418 IF (l(ishell, iset) /= lu) cycle
1419 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
1423 DO jshell = 1, nshell(jset)
1424 IF (l(jshell, jset) /= lu) cycle
1425 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
1427 IF (isgf == jsgf)
THEN
1428 v_block(isgf, isgf) = u_minus_j*(0.5_dp - fspin*q_matrix(i, i))
1430 v_block(isgf, jsgf) = -u_minus_j*fspin*q_matrix(j, i)
1446 CALL para_env%sum(q_matrix)
1447 IF (output_unit > 0)
THEN
1448 ALLOCATE (q_work(nsb, nsbsize))
1449 q_work(:, :) = 0.0_dp
1452 DO i = (isb - 1)*nsbsize + 1, isb*nsbsize
1454 q_work(isb, j) = q_matrix(i, i)
1458 WRITE (unit=output_unit, fmt=
"(T3,I6,2X,I6,2X,10F8.3)") &
1459 atom_a, isb, q_work(isb, :), sum(q_work(isb, :))
1461 WRITE (unit=output_unit, fmt=
"(T12,A,2X,10F8.3)") &
1462 "Total", (sum(q_work(:, i)), i=1, nsbsize), sum(q_work)
1463 WRITE (unit=output_unit, fmt=
"(A)")
""
1467 WRITE (unit=output_unit, fmt=
"(T9,70I10)") (i, i=1, n)
1469 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_matrix(i, :)
1472 ALLOCATE (q_eigval(n))
1473 q_eigval(:) = 0.0_dp
1474 ALLOCATE (q_eigvec(n, n))
1475 q_eigvec(:, :) = 0.0_dp
1476 CALL jacobi(q_matrix, q_eigval, q_eigvec)
1477 WRITE (unit=output_unit, fmt=
"(/,T9,70I10)") (i, i=1, n)
1478 WRITE (unit=output_unit, fmt=
"(T9,71F10.6)") (q_eigval(i), i=1, n), &
1481 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_eigvec(i, :)
1483 DEALLOCATE (q_eigval)
1484 DEALLOCATE (q_eigvec)
1489 ALLOCATE (q_work(nsgf_kind, nsgf_kind))
1490 q_work(:, :) = 0.0_dp
1491 IF (
ASSOCIATED(q_block)) q_work(:, :) = q_block(:, :)
1492 CALL para_env%sum(q_work)
1493 IF (output_unit > 0)
THEN
1494 norb =
SIZE(q_work, 1)
1495 WRITE (unit=output_unit, fmt=
"(/,T9,200I10)") (i, i=1, norb)
1497 WRITE (unit=output_unit, fmt=
"(T3,I6,200F10.6)") i, q_work(i, :)
1499 ALLOCATE (q_eigval(norb))
1500 q_eigval(:) = 0.0_dp
1501 ALLOCATE (q_eigvec(norb, norb))
1502 q_eigvec(:, :) = 0.0_dp
1503 CALL jacobi(q_work, q_eigval, q_eigvec)
1504 WRITE (unit=output_unit, fmt=
"(/,T9,200I10)") (i, i=1, norb)
1505 WRITE (unit=output_unit, fmt=
"(T9,201F10.6)") (q_eigval(i), i=1, norb), &
1506 sum(q_eigval(1:norb))
1508 WRITE (unit=output_unit, fmt=
"(T3,I6,200F10.6)") i, q_eigvec(i, :)
1510 DEALLOCATE (q_eigval)
1511 DEALLOCATE (q_eigvec)
1519 IF (
ALLOCATED(q_matrix))
THEN
1520 DEALLOCATE (q_matrix)
1527 IF (
ASSOCIATED(sm_h))
THEN
1531 IF (.NOT. is_plus_u_kind(ikind)) cycle
1533 kind_a => atomic_kind_set(ikind)
1536 atom_list=atom_list, &
1537 natom=natom_of_kind)
1539 DO iatom = 1, natom_of_kind
1541 atom_a = atom_list(iatom)
1549 IF (.NOT.
ASSOCIATED(h_block)) cycle
1556 cpassert(
ASSOCIATED(v_block))
1558 IF (orthonormal_basis)
THEN
1559 DO isgf = 1,
SIZE(h_block, 1)
1560 h_block(isgf, isgf) = h_block(isgf, isgf) + v_block(isgf, isgf)
1568 cpassert(
ASSOCIATED(s_block))
1569 DO jsgf = 1,
SIZE(h_block, 2)
1570 DO isgf = 1,
SIZE(h_block, 1)
1571 h_block(isgf, jsgf) = h_block(isgf, jsgf) + v_block(isgf, jsgf)*s_block(isgf, jsgf)
1588 CALL para_env%sum(energy%dft_plus_u)
1590 IF (energy%dft_plus_u < 0.0_dp)
THEN
1591 IF (.NOT. occupation_enforced)
THEN
1592 CALL cp_warn(__location__, &
1593 "DFT+U energy contribution is negative possibly due "// &
1594 "to unphysical Mulliken charges!")
1601 CALL timestop(handle)
1641 SUBROUTINE mulliken_charges(qs_env, orthonormal_basis, matrix_h, matrix_w, &
1642 should_output, output_unit, print_level)
1645 LOGICAL,
INTENT(IN) :: orthonormal_basis
1647 POINTER :: matrix_h, matrix_w
1648 LOGICAL,
INTENT(IN) :: should_output
1649 INTEGER,
INTENT(IN) :: output_unit, print_level
1651 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mulliken_charges'
1653 CHARACTER(LEN=10) :: spin_info
1654 CHARACTER(LEN=6),
ALLOCATABLE,
DIMENSION(:) :: symbol
1655 CHARACTER(LEN=default_string_length) :: atomic_kind_name
1656 INTEGER :: atom_a, handle, i, iatom, ic, ikind, isb, iset, isgf, ishell, ispin, jatom, jsgf, &
1657 lu, m, natom, natom_of_kind, nimg, nkind, nsb, nset, nsgf, nspin, sgf
1658 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_sgf_atom
1659 INTEGER,
DIMENSION(:),
POINTER :: atom_list, nshell
1660 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf, l, last_sgf
1661 LOGICAL :: dft_plus_u_atom, found, just_energy
1662 REAL(kind=
dp) :: eps_u_ramping, fspin, q, u_minus_j, &
1663 u_minus_j_target, u_ramping, v
1664 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: dedq, trps
1665 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: q_ii
1666 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: h_block, p_block, s_block, w_block
1669 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_p, matrix_s
1670 TYPE(
dbcsr_type),
POINTER :: sm_h, sm_p, sm_s, sm_w
1676 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1679 CALL timeset(routinen, handle)
1682 NULLIFY (atomic_kind_set)
1683 NULLIFY (qs_kind_set)
1684 NULLIFY (dft_control)
1693 NULLIFY (orb_basis_set)
1695 NULLIFY (particle_set)
1705 atomic_kind_set=atomic_kind_set, &
1706 qs_kind_set=qs_kind_set, &
1707 dft_control=dft_control, &
1709 particle_set=particle_set, &
1713 cpassert(
ASSOCIATED(atomic_kind_set))
1714 cpassert(
ASSOCIATED(dft_control))
1715 cpassert(
ASSOCIATED(energy))
1716 cpassert(
ASSOCIATED(particle_set))
1717 cpassert(
ASSOCIATED(rho))
1719 IF (orthonormal_basis)
THEN
1724 matrix_s_kp=matrix_s)
1725 cpassert(
ASSOCIATED(matrix_s))
1732 energy%dft_plus_u = 0.0_dp
1734 nspin = dft_control%nspins
1735 nimg = dft_control%nimages
1737 IF (nspin == 2)
THEN
1749 nkind =
SIZE(atomic_kind_set)
1751 ALLOCATE (first_sgf_atom(natom))
1752 first_sgf_atom(:) = 0
1755 first_sgf=first_sgf_atom)
1757 ALLOCATE (trps(nsgf))
1760 IF (
PRESENT(matrix_h) .OR.
PRESENT(matrix_w))
THEN
1761 ALLOCATE (dedq(nsgf))
1762 just_energy = .false.
1764 just_energy = .true.
1771 IF (.NOT. just_energy) dedq(:) = 0.0_dp
1778 IF (orthonormal_basis)
THEN
1781 sm_s => matrix_s(1, ic)%matrix
1783 sm_p => matrix_p(ispin, ic)%matrix
1791 IF (orthonormal_basis)
THEN
1793 IF (iatom /= jatom) cycle
1795 IF (
ASSOCIATED(p_block))
THEN
1796 sgf = first_sgf_atom(iatom)
1797 DO isgf = 1,
SIZE(p_block, 1)
1798 trps(sgf) = trps(sgf) + p_block(isgf, isgf)
1810 cpassert(
ASSOCIATED(s_block))
1812 sgf = first_sgf_atom(jatom)
1813 DO jsgf = 1,
SIZE(p_block, 2)
1814 DO isgf = 1,
SIZE(p_block, 1)
1815 trps(sgf) = trps(sgf) + p_block(isgf, jsgf)*s_block(isgf, jsgf)
1820 IF (iatom /= jatom)
THEN
1821 sgf = first_sgf_atom(iatom)
1822 DO isgf = 1,
SIZE(p_block, 1)
1823 DO jsgf = 1,
SIZE(p_block, 2)
1824 trps(sgf) = trps(sgf) + p_block(isgf, jsgf)*s_block(isgf, jsgf)
1838 CALL para_env%sum(trps)
1855 atom_list=atom_list, &
1856 name=atomic_kind_name, &
1857 natom=natom_of_kind)
1860 dft_plus_u_atom=dft_plus_u_atom, &
1861 l_of_dft_plus_u=lu, &
1862 basis_set=orb_basis_set, &
1863 u_minus_j=u_minus_j, &
1864 u_minus_j_target=u_minus_j_target, &
1865 u_ramping=u_ramping, &
1866 eps_u_ramping=eps_u_ramping)
1870 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
1871 IF (.NOT. dft_plus_u_atom) cycle
1876 IF ((ispin == 1) .AND. (u_ramping > 0.0_dp))
THEN
1877 IF (qs_env%scf_env%iter_delta <= eps_u_ramping)
THEN
1878 u_minus_j = min(u_minus_j + u_ramping, u_minus_j_target)
1879 CALL set_qs_kind(qs_kind_set(ikind), u_minus_j=u_minus_j)
1881 IF (should_output .AND. (output_unit > 0))
THEN
1882 WRITE (unit=output_unit, fmt=
"(T3,A,3X,A,F0.3,A)") &
1883 "Kind name: "//trim(adjustl(atomic_kind_name)), &
1884 "U(eff) = ", u_minus_j*
evolt,
" eV"
1888 IF (u_minus_j == 0.0_dp) cycle
1893 first_sgf=first_sgf, &
1895 last_sgf=last_sgf, &
1903 DO ishell = 1, nshell(iset)
1904 IF (l(ishell, iset) == lu) nsb = nsb + 1
1908 ALLOCATE (q_ii(nsb, 2*lu + 1))
1913 IF (output_unit > 0)
THEN
1914 ALLOCATE (symbol(2*lu + 1))
1919 WRITE (unit=spin_info, fmt=
"(A8,I2)")
" of spin", ispin
1923 WRITE (unit=output_unit, fmt=
"(/,T3,A,I0,A,/,/,T5,A,10(2X,A6))") &
1924 "DFT+U occupations"//trim(spin_info)//
" for the atoms of atomic kind ", ikind, &
1925 ": "//trim(atomic_kind_name), &
1926 "Atom Shell ", (adjustr(symbol(i)), i=1, 2*lu + 1),
" Trace"
1933 DO iatom = 1, natom_of_kind
1935 atom_a = atom_list(iatom)
1949 IF (
ASSOCIATED(p_block))
THEN
1951 sgf = first_sgf_atom(atom_a)
1955 DO ishell = 1, nshell(iset)
1956 IF (l(ishell, iset) == lu)
THEN
1959 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
1963 energy%dft_plus_u = energy%dft_plus_u + &
1964 0.5_dp*u_minus_j*(q - q**2)/fspin
1965 IF (.NOT. just_energy)
THEN
1966 dedq(sgf) = dedq(sgf) + u_minus_j*(0.5_dp - q)
1971 sgf = sgf + last_sgf(ishell, iset) - first_sgf(ishell, iset) + 1
1981 CALL para_env%sum(q_ii)
1982 IF (output_unit > 0)
THEN
1984 WRITE (unit=output_unit, fmt=
"(T3,I6,2X,I6,2X,10F8.3)") &
1985 atom_a, isb, q_ii(isb, :), sum(q_ii(isb, :))
1987 WRITE (unit=output_unit, fmt=
"(T12,A,2X,10F8.3)") &
1988 "Total", (sum(q_ii(:, i)), i=1, 2*lu + 1), sum(q_ii)
1989 WRITE (unit=output_unit, fmt=
"(A)")
""
1995 IF (
ALLOCATED(q_ii))
THEN
2001 IF (.NOT. just_energy)
THEN
2002 CALL para_env%sum(dedq)
2007 IF (
PRESENT(matrix_h))
THEN
2010 IF (orthonormal_basis)
THEN
2013 sm_s => matrix_s(1, ic)%matrix
2015 sm_h => matrix_h(ispin, ic)%matrix
2023 IF (orthonormal_basis)
THEN
2025 IF (iatom /= jatom) cycle
2027 IF (
ASSOCIATED(h_block))
THEN
2028 sgf = first_sgf_atom(iatom)
2029 DO isgf = 1,
SIZE(h_block, 1)
2030 h_block(isgf, isgf) = h_block(isgf, isgf) + dedq(sgf)
2044 cpassert(
ASSOCIATED(s_block))
2048 sgf = first_sgf_atom(iatom)
2050 DO isgf = 1,
SIZE(h_block, 1)
2051 IF (dedq(sgf) /= 0.0_dp)
THEN
2052 v = 0.5_dp*dedq(sgf)
2053 DO jsgf = 1,
SIZE(h_block, 2)
2054 h_block(isgf, jsgf) = h_block(isgf, jsgf) + v*s_block(isgf, jsgf)
2060 sgf = first_sgf_atom(jatom)
2062 DO jsgf = 1,
SIZE(h_block, 2)
2063 IF (dedq(sgf) /= 0.0_dp)
THEN
2064 v = 0.5_dp*dedq(sgf)
2065 DO isgf = 1,
SIZE(h_block, 1)
2066 h_block(isgf, jsgf) = h_block(isgf, jsgf) + v*s_block(isgf, jsgf)
2086 IF (
PRESENT(matrix_w) .AND. (.NOT. orthonormal_basis))
THEN
2089 sm_s => matrix_s(1, ic)%matrix
2090 sm_p => matrix_p(ispin, ic)%matrix
2091 sm_w => matrix_w(ispin, ic)%matrix
2101 IF (iatom == jatom) cycle
2110 cpassert(
ASSOCIATED(w_block))
2114 sgf = first_sgf_atom(iatom)
2116 DO isgf = 1,
SIZE(w_block, 1)
2117 IF (dedq(sgf) /= 0.0_dp)
THEN
2118 v = -0.5_dp*dedq(sgf)
2119 DO jsgf = 1,
SIZE(w_block, 2)
2120 w_block(isgf, jsgf) = w_block(isgf, jsgf) + v*p_block(isgf, jsgf)
2126 sgf = first_sgf_atom(jatom)
2128 DO jsgf = 1,
SIZE(w_block, 2)
2129 IF (dedq(sgf) /= 0.0_dp)
THEN
2130 v = -0.5_dp*dedq(sgf)
2131 DO isgf = 1,
SIZE(w_block, 1)
2132 w_block(isgf, jsgf) = w_block(isgf, jsgf) + v*p_block(isgf, jsgf)
2150 CALL para_env%sum(energy%dft_plus_u)
2152 IF (energy%dft_plus_u < 0.0_dp)
THEN
2153 CALL cp_warn(__location__, &
2154 "DFT+U energy contribution is negative possibly due "// &
2155 "to unphysical Mulliken charges!")
2160 IF (
ALLOCATED(first_sgf_atom))
THEN
2161 DEALLOCATE (first_sgf_atom)
2164 IF (
ALLOCATED(trps))
THEN
2168 IF (
ALLOCATED(dedq))
THEN
2172 CALL timestop(handle)
2174 END SUBROUTINE mulliken_charges
2188 SUBROUTINE tensorial(qs_env, matrix_h, matrix_w, should_output, output_unit, print_level)
2192 POINTER :: matrix_h, matrix_w
2193 LOGICAL,
INTENT(IN) :: should_output
2194 INTEGER,
INTENT(IN) :: output_unit, print_level
2196 CHARACTER(LEN=*),
PARAMETER :: routinen =
'tensorial'
2198 CHARACTER(LEN=10) :: spin_info
2199 CHARACTER(LEN=6),
ALLOCATABLE :: symbol(:)
2200 CHARACTER(LEN=default_string_length) :: atomic_kind_name
2201 INTEGER :: atom_a, atom_aa, handle, i, i0, iatom, ikind, iorb, isb, iset, isgf, ishell, &
2202 ispin, j, jatom, jj, jkind, jsb, jset, jsgf, jshell, katom, lu, m, matom_of_kind, &
2203 max_scf, n, natom, natom_of_kind, nkind, norb, nsb, nsbsize, nset, nsgf, nsgf_kind, &
2204 nsgf_kind2, nspin, timevalues(8)
2205 INTEGER,
ALLOCATABLE :: first_sgf_atom(:)
2206 INTEGER,
DIMENSION(1) :: iloc
2207 INTEGER,
DIMENSION(:),
POINTER :: atom_list, atom_list2, nshell, orbitals
2208 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf, l, last_sgf
2209 LOGICAL :: debug, dft_plus_u_atom, found, &
2211 LOGICAL,
ALLOCATABLE :: orb_occ(:)
2212 REAL(kind=
dp) :: eps_scf, eps_u_ramping, fspin, hund_j, occ, perturbation_strength, &
2213 some_real, trq, trq2, trqxq_hund_j, u_minus_j, u_minus_j_target, u_ramping
2214 REAL(kind=
dp),
ALLOCATABLE :: a(:), q_a_matrix(:, :), q_b_matrix(:, :), q_eigval(:), &
2215 q_eigvec(:, :), q_work(:, :), s_inv_matrix(:, :), s_matrix(:, :), tmp_matrix1(:, :), &
2216 tmp_matrix2(:, :), tmp_matrix3(:, :), v_matrix(:, :), vhxc_matrix(:, :)
2219 REAL(kind=
dp),
ALLOCATABLE :: matrix(:, :, :)
2222 REAL(kind=
dp),
ALLOCATABLE :: matrix(:, :, :, :)
2224 TYPE(block3d),
ALLOCATABLE :: a_matrix(:, :), d_matrix(:, :), &
2225 e_matrix(:, :), i_matrix(:, :), &
2227 TYPE(block4d),
ALLOCATABLE :: dd_matrix(:, :), ee_matrix(:, :), &
2229 REAL(kind=
dp),
DIMENSION(:),
POINTER :: ao_coef
2230 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a_block, d_block, e_block, f_block, &
2231 i_block, j_block, q_a_block, q_b_block, &
2232 s_block, tmp_block, v_block, vhxc_block
2236 TYPE(
dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_p, matrix_s, matrix_vhxc
2237 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrixkp_s
2238 TYPE(
dbcsr_type),
POINTER :: sm_a, sm_b, sm_c, sm_d, sm_e, sm_f, &
2239 sm_h, sm_i, sm_j, sm_k, sm_q_a, sm_q_b, &
2240 sm_s, sm_v, sm_w, sm_mid, sm_vhxc, sm_p
2247 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
2251 CALL timeset(routinen, handle)
2259 NULLIFY (atom_list2)
2260 NULLIFY (atomic_kind_set)
2261 NULLIFY (qs_kind_set)
2262 NULLIFY (dft_control)
2268 NULLIFY (matrix_vhxc)
2272 NULLIFY (orb_basis_set)
2275 NULLIFY (particle_set)
2278 NULLIFY (vhxc_block)
2310 atomic_kind_set=atomic_kind_set, &
2311 qs_kind_set=qs_kind_set, &
2312 dft_control=dft_control, &
2314 matrix_s=matrix_s, &
2315 matrix_vhxc=matrix_vhxc, &
2316 matrix_s_kp=matrixkp_s, &
2317 particle_set=particle_set, &
2322 cpassert(
ASSOCIATED(atomic_kind_set))
2323 cpassert(
ASSOCIATED(dft_control))
2324 cpassert(
ASSOCIATED(energy))
2325 cpassert(
ASSOCIATED(matrix_s))
2326 cpassert(
ASSOCIATED(particle_set))
2327 cpassert(
ASSOCIATED(rho))
2329 sm_s => matrix_s(1)%matrix
2332 energy%dft_plus_u = 0.0_dp
2334 nspin = dft_control%nspins
2335 IF (dft_control%mtlr_dft_with_perturbation)
THEN
2336 IF (.NOT.
ASSOCIATED(matrix_vhxc))
THEN
2337 cpabort(
"MTLR requires the projected Hxc matrix for every spin channel.")
2339 IF (
SIZE(matrix_vhxc) /= nspin)
THEN
2340 cpabort(
"The number of projected Hxc matrices does not match the spin channels.")
2344 IF (nspin == 2)
THEN
2356 nkind =
SIZE(atomic_kind_set)
2358 ALLOCATE (first_sgf_atom(natom))
2359 first_sgf_atom(:) = 0
2363 IF (
PRESENT(matrix_h) .OR.
PRESENT(matrix_w))
THEN
2364 just_energy = .false.
2366 just_energy = .true.
2370 CALL dbcsr_create(sm_mid, template=sm_s, matrix_type=
"N")
2387 sm_p => matrix_p(ispin)%matrix
2389 IF (nspin == 2)
THEN
2390 IF (ispin == 1)
THEN
2391 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, sm_s, sm_p, 0.0_dp, sm_mid)
2392 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, sm_mid, sm_s, 0.0_dp, sm_q_a)
2394 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, sm_s, sm_p, 0.0_dp, sm_mid)
2395 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, sm_mid, sm_s, 0.0_dp, sm_q_b)
2398 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, sm_s, sm_p, 0.0_dp, sm_mid)
2399 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, sm_mid, sm_s, 0.0_dp, sm_q_a)
2408 IF (
PRESENT(matrix_w))
THEN
2411 CALL dbcsr_create(sm_b, template=matrix_s(1)%matrix, matrix_type=
"N")
2414 CALL dbcsr_create(sm_d, template=matrix_s(1)%matrix, matrix_type=
"N")
2417 CALL dbcsr_create(sm_c, template=matrix_s(1)%matrix, matrix_type=
"N")
2420 CALL dbcsr_create(sm_e, template=matrix_s(1)%matrix, matrix_type=
"N")
2423 CALL dbcsr_create(sm_f, template=matrix_s(1)%matrix, matrix_type=
"N")
2426 CALL dbcsr_create(sm_i, template=matrix_s(1)%matrix, matrix_type=
"N")
2429 CALL dbcsr_create(sm_j, template=matrix_s(1)%matrix, matrix_type=
"N")
2432 CALL dbcsr_create(sm_k, template=matrix_s(1)%matrix, matrix_type=
"N")
2443 IF (
PRESENT(matrix_h))
THEN
2444 sm_h => matrix_h(ispin, 1)%matrix
2449 IF (
PRESENT(matrix_w))
THEN
2450 sm_w => matrix_w(ispin, 1)%matrix
2458 IF (dft_control%mtlr_dft_with_perturbation)
THEN
2459 IF (ispin == 1) perturbation_strength = 0.9_dp*dft_control%perturbation_strength
2460 IF (ispin == 2) perturbation_strength = 1.1_dp*dft_control%perturbation_strength
2461 IF (.NOT.
ASSOCIATED(matrix_vhxc(ispin)%matrix))
THEN
2462 cpabort(
"MTLR projected Hxc matrix is not initialized.")
2464 sm_vhxc => matrix_vhxc(ispin)%matrix
2472 atom_list=atom_list, &
2473 name=atomic_kind_name, &
2474 natom=natom_of_kind)
2477 dft_plus_u_atom=dft_plus_u_atom, &
2478 l_of_dft_plus_u=lu, &
2480 basis_set=orb_basis_set, &
2481 u_minus_j=u_minus_j, &
2484 u_minus_j_target=u_minus_j_target, &
2485 u_ramping=u_ramping, &
2486 eps_u_ramping=eps_u_ramping, &
2487 orbitals=orbitals, &
2492 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
2493 IF (.NOT. dft_plus_u_atom) cycle
2495 IF (u_minus_j == 0.0_dp .AND. hund_j == 0.0_dp) cycle
2496 IF (.NOT.
ASSOCIATED(ao_coef))
THEN
2497 cpabort(
"Tensorial DFT+U requires associated ao_coef")
2500 ALLOCATE (a(
SIZE(ao_coef)))
2505 IF ((ispin == 1) .AND. (u_ramping > 0.0_dp))
THEN
2506 IF (qs_env%scf_env%iter_delta <= eps_u_ramping)
THEN
2507 u_minus_j = min(u_minus_j + u_ramping, u_minus_j_target)
2508 CALL set_qs_kind(qs_kind_set(ikind), u_minus_j=u_minus_j)
2511 IF (should_output .AND. (output_unit > 0))
THEN
2512 WRITE (unit=output_unit, fmt=
"(T3,A,3X,A,F0.3,A)") &
2513 "Kind name: "//trim(adjustl(atomic_kind_name)), &
2514 "U(eff) = ", u_minus_j*
evolt,
" eV"
2519 first_sgf=first_sgf, &
2521 last_sgf=last_sgf, &
2526 nsbsize = (2*lu + 1)
2529 ALLOCATE (q_a_matrix(n, n))
2530 ALLOCATE (q_b_matrix(n, n))
2531 ALLOCATE (s_matrix(n, n))
2532 ALLOCATE (s_inv_matrix(n, n))
2533 ALLOCATE (v_matrix(n, n))
2535 q_a_matrix(:, :) = 0.0_dp
2536 q_b_matrix(:, :) = 0.0_dp
2537 s_matrix(:, :) = 0.0_dp
2538 s_inv_matrix(:, :) = 0.0_dp
2539 v_matrix(:, :) = 0.0_dp
2544 IF (output_unit > 0)
THEN
2545 ALLOCATE (symbol(nsbsize))
2551 WRITE (unit=spin_info, fmt=
"(A8,I2)")
" of spin", ispin
2556 WRITE (unit=output_unit, fmt=
"(/,T3,A,I0,A,/,/,T5,A,10(2X,A6))") &
2557 "DFT+U occupations"//trim(spin_info)//
" for the atoms of atomic kind ", ikind, &
2558 ": "//trim(atomic_kind_name), &
2559 "Atom Shell ", (adjustr(symbol(i)), i=1, nsbsize),
" Trace"
2565 IF (dft_control%mtlr_dft_with_perturbation .AND. &
2566 dft_control%mtlr_ikind == ikind)
THEN
2567 dft_control%vhxc(ispin) = 0.0_dp
2568 dft_control%trq(ispin) = 0.0_dp
2569 ALLOCATE (vhxc_matrix(n, n))
2570 vhxc_matrix(:, :) = 0.0_dp
2575 DO iatom = 1, natom_of_kind
2577 atom_a = atom_list(iatom)
2579 q_a_matrix(:, :) = 0.0_dp
2580 q_b_matrix(:, :) = 0.0_dp
2581 s_matrix(:, :) = 0.0_dp
2582 s_inv_matrix(:, :) = 0.0_dp
2583 v_matrix(:, :) = 0.0_dp
2603 IF (dft_control%mtlr_dft_with_perturbation .AND. &
2604 dft_control%mtlr_ikind == ikind .AND. &
2605 qs_kind_set(ikind)%dft_plus_u%lr_atom == atom_a)
THEN
2613 IF (
ASSOCIATED(q_a_block) .AND.
ASSOCIATED(q_b_block) .AND.
ASSOCIATED(s_block))
THEN
2617 DO ishell = 1, nshell(iset)
2618 IF (l(ishell, iset) /= lu) cycle
2621 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
2625 DO jshell = 1, nshell(jset)
2626 IF (l(jshell, jset) /= lu) cycle
2629 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
2631 q_a_matrix(i, j) = q_a_matrix(i, j) + q_a_block(isgf, jsgf)*a(isb)*a(jsb)
2632 q_b_matrix(i, j) = q_b_matrix(i, j) + q_b_block(isgf, jsgf)*a(isb)*a(jsb)
2633 s_matrix(i, j) = s_matrix(i, j) + s_block(isgf, jsgf)*a(isb)*a(jsb)
2634 IF (
ASSOCIATED(vhxc_block) .AND. &
2635 dft_control%mtlr_dft_with_perturbation .AND. &
2636 dft_control%mtlr_ikind == ikind .AND. &
2637 qs_kind_set(ikind)%dft_plus_u%lr_atom == atom_a)
THEN
2638 vhxc_matrix(i, j) = vhxc_matrix(i, j) + vhxc_block(isgf, jsgf)*a(isb)*a(jsb)
2649 q_a_matrix(:, :) = matmul(q_a_matrix, s_inv_matrix)
2650 q_b_matrix(:, :) = matmul(q_b_matrix, s_inv_matrix)
2652 IF (
ASSOCIATED(vhxc_block) .AND. &
2653 dft_control%mtlr_dft_with_perturbation .AND. &
2654 dft_control%mtlr_ikind == ikind .AND. &
2655 qs_kind_set(ikind)%dft_plus_u%lr_atom == atom_a)
THEN
2656 vhxc_matrix(:, :) = matmul(vhxc_matrix, s_inv_matrix)
2658 dft_control%vhxc(ispin) = dft_control%vhxc(ispin) + vhxc_matrix(i, i)
2659 IF (ispin == 1) dft_control%trq(1) = dft_control%trq(1) + q_a_matrix(i, i)
2660 IF (ispin == 2) dft_control%trq(2) = dft_control%trq(2) + q_b_matrix(i, i)
2666 IF (
ASSOCIATED(orbitals))
THEN
2667 IF ((qs_env%scf_env%iter_delta >= eps_scf) .OR. &
2668 ((qs_env%scf_env%outer_scf%iter_count == 0) .AND. &
2669 (qs_env%scf_env%iter_count <= max_scf)))
THEN
2671 ALLOCATE (orb_occ(nsbsize))
2672 ALLOCATE (q_eigval(n))
2673 ALLOCATE (q_eigvec(n, n))
2675 q_eigval(:) = 0.0_dp
2676 q_eigvec(:, :) = 0.0_dp
2677 norb =
SIZE(orbitals)
2679 IF (ispin == 1)
THEN
2680 CALL jacobi(q_a_matrix, q_eigval, q_eigvec)
2681 q_a_matrix(:, :) = 0.0_dp
2683 CALL jacobi(q_b_matrix, q_eigval, q_eigvec)
2684 q_b_matrix(:, :) = 0.0_dp
2689 DO i = (isb - 1)*nsbsize + 1, isb*nsbsize
2690 trq = trq + q_eigval(i)
2694 occ = trq/real(norb, kind=
dp)
2699 orb_occ(:) = .false.
2700 iloc = maxloc(q_eigvec(:, isb*nsbsize))
2701 jsb = int((iloc(1) - 1)/nsbsize) + 1
2703 i0 = (jsb - 1)*nsbsize + 1
2706 DO j = i0, jsb*nsbsize
2710 IF (.NOT. orb_occ(lu + m + 1))
THEN
2712 orb_occ(lu + m + 1) = .true.
2716 iorb = i0 + lu + orbitals(i)
2717 orb_occ(lu + orbitals(i) + 1) = .true.
2720 cpassert(iorb /= -1000)
2722 iloc = maxloc(q_eigvec(iorb, :))
2723 q_eigval(iloc(1)) = min(occ, trq)
2725 IF (ispin == 1)
THEN
2726 q_a_matrix(:, iloc(1)) = q_eigval(iloc(1))*q_eigvec(:, iloc(1))
2728 q_b_matrix(:, iloc(1)) = q_eigval(iloc(1))*q_eigvec(:, iloc(1))
2731 trq = trq - q_eigval(iloc(1))
2735 IF (ispin == 1)
THEN
2736 q_a_matrix(:, :) = matmul(q_a_matrix, transpose(q_eigvec))
2738 q_b_matrix(:, :) = matmul(q_b_matrix, transpose(q_eigvec))
2741 DEALLOCATE (orb_occ)
2742 DEALLOCATE (q_eigval)
2743 DEALLOCATE (q_eigvec)
2749 trqxq_hund_j = 0.0_dp
2751 IF (ispin == 1)
THEN
2753 trq = trq + q_a_matrix(i, i)
2755 trq2 = trq2 + q_a_matrix(i, j)*q_a_matrix(j, i)
2756 trqxq_hund_j = trqxq_hund_j + q_a_matrix(i, j)*q_b_matrix(j, i)
2759 v_matrix(i, i) = u_minus_j*(0.5_dp - fspin*q_a_matrix(i, i))
2760 v_matrix(i, i) = v_matrix(i, i) + hund_j*fspin*q_b_matrix(i, i)
2761 IF (dft_control%mtlr_dft_with_perturbation .AND. &
2762 dft_control%mtlr_ikind == ikind .AND. &
2763 qs_kind_set(ikind)%dft_plus_u%lr_atom == atom_a)
THEN
2764 v_matrix(i, i) = v_matrix(i, i) + perturbation_strength
2767 v_matrix(i, j) = -u_minus_j*fspin*q_a_matrix(j, i)
2768 v_matrix(i, j) = v_matrix(i, j) + hund_j*fspin*q_b_matrix(j, i)
2774 trq = trq + q_b_matrix(i, i)
2776 trq2 = trq2 + q_b_matrix(i, j)*q_b_matrix(j, i)
2777 trqxq_hund_j = trqxq_hund_j + q_b_matrix(i, j)*q_a_matrix(j, i)
2780 v_matrix(i, i) = u_minus_j*(0.5_dp - fspin*q_b_matrix(i, i))
2781 v_matrix(i, i) = v_matrix(i, i) + hund_j*fspin*q_a_matrix(i, i)
2782 IF (dft_control%mtlr_dft_with_perturbation .AND. &
2783 dft_control%mtlr_ikind == ikind .AND. &
2784 qs_kind_set(ikind)%dft_plus_u%lr_atom == atom_a)
THEN
2785 v_matrix(i, i) = v_matrix(i, i) + perturbation_strength
2788 v_matrix(i, j) = -u_minus_j*fspin*q_b_matrix(j, i)
2789 v_matrix(i, j) = v_matrix(i, j) + hund_j*fspin*q_a_matrix(j, i)
2795 v_matrix(:, :) = matmul(s_inv_matrix, v_matrix)
2798 trq2 = fspin*fspin*trq2
2799 trqxq_hund_j = fspin*fspin*trqxq_hund_j
2801 energy%dft_plus_u = energy%dft_plus_u + 0.5_dp*u_minus_j*(trq - trq2)/fspin
2802 energy%dft_plus_u = energy%dft_plus_u + 0.5_dp*hund_j*trqxq_hund_j/fspin
2806 IF (.NOT. just_energy)
THEN
2813 cpassert(
ASSOCIATED(v_block))
2820 cpassert(
ASSOCIATED(a_block))
2824 DO ishell = 1, nshell(iset)
2825 IF (l(ishell, iset) /= lu) cycle
2828 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
2832 DO jshell = 1, nshell(jset)
2833 IF (l(jshell, jset) /= lu) cycle
2836 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
2838 v_block(isgf, jsgf) = v_matrix(i, j)*a(isb)*a(jsb)
2839 a_block(isgf, jsgf) = s_inv_matrix(i, j)*a(isb)*a(jsb)
2854 IF (ispin == 1)
THEN
2855 CALL para_env%sum(q_a_matrix)
2857 CALL para_env%sum(q_b_matrix)
2860 IF (output_unit > 0)
THEN
2861 ALLOCATE (q_work(nsb, nsbsize))
2862 q_work(:, :) = 0.0_dp
2866 DO i = (isb - 1)*nsbsize + 1, isb*nsbsize
2868 IF (ispin == 1)
THEN
2869 q_work(isb, j) = q_a_matrix(i, i)
2871 q_work(isb, j) = q_b_matrix(i, i)
2877 WRITE (unit=output_unit, fmt=
"(T3,I6,2X,I6,2X,10F8.3)") &
2878 atom_a, isb, q_work(isb, :), sum(q_work(isb, :))
2881 WRITE (unit=output_unit, fmt=
"(T12,A,2X,10F8.3)") &
2882 "Total", (sum(q_work(:, i)), i=1, nsbsize), sum(q_work)
2883 WRITE (unit=output_unit, fmt=
"(A)")
""
2888 WRITE (unit=output_unit, fmt=
"(T9,70I10)") (i, i=1, n)
2890 IF (ispin == 1)
THEN
2891 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_a_matrix(i, :)
2893 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_b_matrix(i, :)
2897 ALLOCATE (q_eigval(n))
2898 ALLOCATE (q_eigvec(n, n))
2899 q_eigval(:) = 0.0_dp
2900 q_eigvec(:, :) = 0.0_dp
2902 IF (ispin == 1)
THEN
2903 CALL jacobi(q_a_matrix, q_eigval, q_eigvec)
2905 CALL jacobi(q_b_matrix, q_eigval, q_eigvec)
2908 WRITE (unit=output_unit, fmt=
"(/,T9,70I10)") (i, i=1, n)
2909 WRITE (unit=output_unit, fmt=
"(T9,71F10.6)") (q_eigval(i), i=1, n), sum(q_eigval(1:n))
2912 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_eigvec(i, :)
2915 DEALLOCATE (q_eigval)
2916 DEALLOCATE (q_eigvec)
2921 ALLOCATE (q_work(nsgf_kind, nsgf_kind))
2922 q_work(:, :) = 0.0_dp
2924 IF (ispin == 1)
THEN
2925 IF (
ASSOCIATED(q_a_block)) q_work(:, :) = q_a_block(:, :)
2927 IF (
ASSOCIATED(q_b_block)) q_work(:, :) = q_b_block(:, :)
2930 CALL para_env%sum(q_work)
2932 IF (output_unit > 0)
THEN
2933 norb =
SIZE(q_work, 1)
2935 WRITE (unit=output_unit, fmt=
"(/,T9,200I10)") (i, i=1, norb)
2937 WRITE (unit=output_unit, fmt=
"(T3,I6,200F10.6)") i, q_work(i, :)
2940 ALLOCATE (q_eigval(norb))
2941 ALLOCATE (q_eigvec(norb, norb))
2942 q_eigval(:) = 0.0_dp
2943 q_eigvec(:, :) = 0.0_dp
2945 CALL jacobi(q_work, q_eigval, q_eigvec)
2947 WRITE (unit=output_unit, fmt=
"(/,T9,200I10)") (i, i=1, norb)
2948 WRITE (unit=output_unit, fmt=
"(T9,201F10.6)") (q_eigval(i), i=1, norb), sum(q_eigval(1:norb))
2951 WRITE (unit=output_unit, fmt=
"(T3,I6,200F10.6)") i, q_eigvec(i, :)
2954 DEALLOCATE (q_eigval)
2955 DEALLOCATE (q_eigvec)
2964 IF (
ALLOCATED(q_a_matrix))
DEALLOCATE (q_a_matrix)
2965 IF (
ALLOCATED(q_b_matrix))
DEALLOCATE (q_b_matrix)
2966 IF (
ALLOCATED(s_matrix))
DEALLOCATE (s_matrix)
2967 IF (
ALLOCATED(s_inv_matrix))
DEALLOCATE (s_inv_matrix)
2968 IF (
ALLOCATED(v_matrix))
DEALLOCATE (v_matrix)
2972 IF (dft_control%mtlr_dft_with_perturbation .AND. &
2973 dft_control%mtlr_ikind == ikind)
THEN
2974 dft_control%vhxc(ispin) = dft_control%vhxc(ispin)/real(n,
dp)
2975 CALL para_env%sum(dft_control%vhxc(ispin))
2976 CALL para_env%sum(dft_control%trq(ispin))
2977 DEALLOCATE (vhxc_matrix)
2984 IF (
ASSOCIATED(sm_h))
THEN
2985 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, sm_s, sm_v, 0.0_dp, sm_mid)
2986 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, sm_mid, sm_s, 1.0_dp, sm_h)
2993 IF (
PRESENT(matrix_w))
THEN
2997 force(ikind)%tensorial_u(:, :) = 0.0_dp
2999 IF (nspin == 2)
THEN
3000 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, sm_s, matrix_p(1)%matrix, 0.0_dp, sm_b)
3001 CALL dbcsr_multiply(
"N",
"N", 1.0_dp, sm_s, matrix_p(2)%matrix, 0.0_dp, sm_c)
3003 CALL dbcsr_multiply(
"N",
"N", 0.5_dp, sm_s, matrix_p(1)%matrix, 0.0_dp, sm_b)
3004 CALL dbcsr_multiply(
"N",
"N", 0.5_dp, sm_s, matrix_p(1)%matrix, 0.0_dp, sm_c)
3018 IF (jatom == katom) cycle
3019 CALL dbcsr_put_block(matrix=sm_f, row=jatom, col=katom, block=tmp_block)
3027 ALLOCATE (a_matrix(nkind, nkind))
3028 ALLOCATE (d_matrix(nkind, nkind))
3029 ALLOCATE (e_matrix(nkind, nkind))
3030 ALLOCATE (i_matrix(nkind, nkind))
3031 ALLOCATE (j_matrix(nkind, nkind))
3032 ALLOCATE (dd_matrix(nkind, nkind))
3033 ALLOCATE (ee_matrix(nkind, nkind))
3034 ALLOCATE (ff_matrix(nkind, nkind))
3039 atom_list=atom_list, &
3040 natom=natom_of_kind)
3043 u_minus_j=u_minus_j, &
3044 l_of_dft_plus_u=lu, &
3045 basis_set=orb_basis_set, &
3048 dft_plus_u_atom=dft_plus_u_atom)
3050 IF (.NOT. dft_plus_u_atom) cycle
3051 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
3053 IF (u_minus_j == 0.0_dp .AND. hund_j == 0.0_dp) cycle
3056 first_sgf=first_sgf, &
3058 last_sgf=last_sgf, &
3064 DO ishell = 1, nshell(iset)
3065 IF (l(ishell, iset) == lu) nsb = nsb + 1
3069 nsbsize = (2*lu + 1)
3072 ALLOCATE (a_matrix(ikind, ikind)%matrix(n, n, natom_of_kind))
3073 ALLOCATE (d_matrix(ikind, ikind)%matrix(n, n, natom_of_kind))
3074 ALLOCATE (e_matrix(ikind, ikind)%matrix(n, n, natom_of_kind))
3075 ALLOCATE (i_matrix(ikind, ikind)%matrix(n, n, natom_of_kind))
3076 ALLOCATE (j_matrix(ikind, ikind)%matrix(n, n, natom_of_kind))
3078 a_matrix(ikind, ikind)%matrix(:, :, :) = 0.0_dp
3079 d_matrix(ikind, ikind)%matrix(:, :, :) = 0.0_dp
3080 e_matrix(ikind, ikind)%matrix(:, :, :) = 0.0_dp
3081 i_matrix(ikind, ikind)%matrix(:, :, :) = 0.0_dp
3082 j_matrix(ikind, ikind)%matrix(:, :, :) = 0.0_dp
3084 DO iatom = 1, natom_of_kind
3086 atom_aa = atom_list(iatom)
3123 IF (
ASSOCIATED(a_block) .AND.
ASSOCIATED(d_block) .AND.
ASSOCIATED(e_block) &
3124 .AND.
ASSOCIATED(i_block) .AND.
ASSOCIATED(j_block))
THEN
3128 DO ishell = 1, nshell(iset)
3129 IF (l(ishell, iset) /= lu) cycle
3130 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
3134 DO jshell = 1, nshell(jset)
3135 IF (l(jshell, jset) /= lu) cycle
3136 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
3138 a_matrix(ikind, ikind)%matrix(i, j, iatom) = a_block(isgf, jsgf)
3139 d_matrix(ikind, ikind)%matrix(i, j, iatom) = -d_block(isgf, jsgf)
3140 e_matrix(ikind, ikind)%matrix(i, j, iatom) = -e_block(isgf, jsgf)
3141 i_matrix(ikind, ikind)%matrix(i, j, iatom) = i_block(isgf, jsgf)
3142 j_matrix(ikind, ikind)%matrix(i, j, iatom) = j_block(isgf, jsgf)
3155 atom_list=atom_list2, &
3156 natom=matom_of_kind)
3158 CALL get_qs_kind(qs_kind_set(jkind), nsgf=nsgf_kind2)
3160 IF (.NOT.
ALLOCATED(dd_matrix(ikind, jkind)%matrix))
THEN
3161 ALLOCATE (dd_matrix(ikind, jkind)%matrix(n, nsgf_kind2, natom_of_kind, matom_of_kind))
3162 dd_matrix(ikind, jkind)%matrix(:, :, :, :) = 0.0_dp
3165 IF (.NOT.
ALLOCATED(ee_matrix(ikind, jkind)%matrix))
THEN
3166 ALLOCATE (ee_matrix(ikind, jkind)%matrix(n, nsgf_kind2, natom_of_kind, matom_of_kind))
3167 ee_matrix(ikind, jkind)%matrix(:, :, :, :) = 0.0_dp
3170 IF (.NOT.
ALLOCATED(ff_matrix(ikind, jkind)%matrix))
THEN
3171 ALLOCATE (ff_matrix(ikind, jkind)%matrix(nsgf_kind2, n, natom_of_kind, matom_of_kind))
3172 ff_matrix(ikind, jkind)%matrix(:, :, :, :) = 0.0_dp
3175 DO jatom = 1, matom_of_kind
3177 atom_a = atom_list2(jatom)
3193 IF (
ASSOCIATED(d_block) .AND.
ASSOCIATED(e_block))
THEN
3196 DO ishell = 1, nshell(iset)
3197 IF (l(ishell, iset) /= lu) cycle
3198 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
3200 dd_matrix(ikind, jkind)%matrix(i, :, iatom, jatom) = d_block(isgf, :)
3201 ee_matrix(ikind, jkind)%matrix(i, :, iatom, jatom) = e_block(isgf, :)
3214 IF (
ASSOCIATED(f_block))
THEN
3217 DO ishell = 1, nshell(iset)
3218 IF (l(ishell, iset) /= lu) cycle
3219 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
3221 ff_matrix(ikind, jkind)%matrix(:, i, iatom, jatom) = f_block(:, isgf)
3235 atom_list=atom_list, &
3236 natom=natom_of_kind)
3239 u_minus_j=u_minus_j, &
3240 l_of_dft_plus_u=lu, &
3241 basis_set=orb_basis_set, &
3244 dft_plus_u_atom=dft_plus_u_atom)
3246 IF (.NOT. dft_plus_u_atom) cycle
3247 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
3249 IF (u_minus_j == 0.0_dp .AND. hund_j == 0.0_dp) cycle
3252 first_sgf=first_sgf, &
3254 last_sgf=last_sgf, &
3258 CALL para_env%sum(a_matrix(ikind, ikind)%matrix(:, :, :))
3259 CALL para_env%sum(d_matrix(ikind, ikind)%matrix(:, :, :))
3260 CALL para_env%sum(e_matrix(ikind, ikind)%matrix(:, :, :))
3261 CALL para_env%sum(i_matrix(ikind, ikind)%matrix(:, :, :))
3262 CALL para_env%sum(j_matrix(ikind, ikind)%matrix(:, :, :))
3265 CALL para_env%sum(dd_matrix(ikind, jkind)%matrix(:, :, :, :))
3266 CALL para_env%sum(ee_matrix(ikind, jkind)%matrix(:, :, :, :))
3267 CALL para_env%sum(ff_matrix(ikind, jkind)%matrix(:, :, :, :))
3277 atom_list=atom_list, &
3278 natom=natom_of_kind)
3281 u_minus_j=u_minus_j, &
3282 l_of_dft_plus_u=lu, &
3283 basis_set=orb_basis_set, &
3286 dft_plus_u_atom=dft_plus_u_atom)
3288 IF (.NOT. dft_plus_u_atom) cycle
3289 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
3291 IF (u_minus_j == 0.0_dp .AND. hund_j == 0.0_dp) cycle
3294 first_sgf=first_sgf, &
3296 last_sgf=last_sgf, &
3302 DO ishell = 1, nshell(iset)
3303 IF (l(ishell, iset) == lu) nsb = nsb + 1
3307 nsbsize = (2*lu + 1)
3310 ALLOCATE (tmp_matrix1(n, n))
3311 ALLOCATE (tmp_matrix2(n, n))
3312 ALLOCATE (tmp_matrix3(n, n))
3314 DO iatom = 1, natom_of_kind
3316 atom_aa = atom_list(iatom)
3318 tmp_matrix1(:, :) = matmul(d_matrix(ikind, ikind)%matrix(:, :, iatom), &
3319 a_matrix(ikind, ikind)%matrix(:, :, iatom))
3320 tmp_matrix2(:, :) = matmul(e_matrix(ikind, ikind)%matrix(:, :, iatom), &
3321 a_matrix(ikind, ikind)%matrix(:, :, iatom))
3323 i_matrix(ikind, ikind)%matrix(:, :, iatom) = matmul(i_matrix(ikind, ikind)%matrix(:, :, iatom), &
3324 a_matrix(ikind, ikind)%matrix(:, :, iatom))
3325 j_matrix(ikind, ikind)%matrix(:, :, iatom) = matmul(j_matrix(ikind, ikind)%matrix(:, :, iatom), &
3326 a_matrix(ikind, ikind)%matrix(:, :, iatom))
3328 tmp_matrix3(:, :) = 0.5_dp*u_minus_j*tmp_matrix1 - &
3329 u_minus_j*matmul(tmp_matrix1, i_matrix(ikind, ikind)%matrix(:, :, iatom)) &
3330 + hund_j*matmul(tmp_matrix2, i_matrix(ikind, ikind)%matrix(:, :, iatom))
3331 tmp_matrix3(:, :) = tmp_matrix3 + 0.5_dp*u_minus_j*tmp_matrix2 - &
3332 u_minus_j*matmul(tmp_matrix2, j_matrix(ikind, ikind)%matrix(:, :, iatom)) &
3333 + hund_j*matmul(tmp_matrix1, j_matrix(ikind, ikind)%matrix(:, :, iatom))
3336 force(ikind)%tensorial_u(jj, iatom) = force(ikind)%tensorial_u(jj, iatom) + tmp_matrix3(i, i)
3342 atom_list=atom_list2, &
3343 natom=matom_of_kind)
3345 CALL get_qs_kind(qs_kind_set(jkind), nsgf=nsgf_kind2)
3347 DO jatom = 1, matom_of_kind
3349 atom_a = atom_list2(jatom)
3351 tmp_matrix1(:, :) = matmul(dd_matrix(ikind, jkind)%matrix(:, :, iatom, jatom), &
3352 ff_matrix(ikind, jkind)%matrix(:, :, iatom, jatom))
3353 tmp_matrix1(:, :) = matmul(tmp_matrix1, a_matrix(ikind, ikind)%matrix(:, :, iatom))
3355 tmp_matrix2(:, :) = matmul(ee_matrix(ikind, jkind)%matrix(:, :, iatom, jatom), &
3356 ff_matrix(ikind, jkind)%matrix(:, :, iatom, jatom))
3357 tmp_matrix2(:, :) = matmul(tmp_matrix2, a_matrix(ikind, ikind)%matrix(:, :, iatom))
3359 tmp_matrix3(:, :) = 0.5_dp*u_minus_j*tmp_matrix1 - &
3360 u_minus_j*matmul(tmp_matrix1, i_matrix(ikind, ikind)%matrix(:, :, iatom)) &
3361 + hund_j*matmul(tmp_matrix2, i_matrix(ikind, ikind)%matrix(:, :, iatom))
3362 tmp_matrix3(:, :) = tmp_matrix3 + 0.5_dp*u_minus_j*tmp_matrix2 - &
3363 u_minus_j*matmul(tmp_matrix2, j_matrix(ikind, ikind)%matrix(:, :, iatom)) &
3364 + hund_j*matmul(tmp_matrix1, j_matrix(ikind, ikind)%matrix(:, :, iatom))
3366 IF (atom_a /= atom_aa)
THEN
3368 force(jkind)%tensorial_u(jj, jatom) = force(jkind)%tensorial_u(jj, jatom) &
3377 DEALLOCATE (tmp_matrix1)
3378 DEALLOCATE (tmp_matrix2)
3379 DEALLOCATE (tmp_matrix3)
3385 IF (
ALLOCATED(a_matrix(ikind, ikind)%matrix))
DEALLOCATE (a_matrix(ikind, ikind)%matrix)
3386 IF (
ALLOCATED(d_matrix(ikind, ikind)%matrix))
DEALLOCATE (d_matrix(ikind, ikind)%matrix)
3387 IF (
ALLOCATED(e_matrix(ikind, ikind)%matrix))
DEALLOCATE (e_matrix(ikind, ikind)%matrix)
3388 IF (
ALLOCATED(i_matrix(ikind, ikind)%matrix))
DEALLOCATE (i_matrix(ikind, ikind)%matrix)
3389 IF (
ALLOCATED(j_matrix(ikind, ikind)%matrix))
DEALLOCATE (j_matrix(ikind, ikind)%matrix)
3392 IF (
ALLOCATED(dd_matrix(ikind, jkind)%matrix))
DEALLOCATE (dd_matrix(ikind, jkind)%matrix)
3393 IF (
ALLOCATED(ee_matrix(ikind, jkind)%matrix))
DEALLOCATE (ee_matrix(ikind, jkind)%matrix)
3394 IF (
ALLOCATED(ff_matrix(ikind, jkind)%matrix))
DEALLOCATE (ff_matrix(ikind, jkind)%matrix)
3399 DEALLOCATE (a_matrix)
3400 DEALLOCATE (d_matrix)
3401 DEALLOCATE (e_matrix)
3402 DEALLOCATE (i_matrix)
3403 DEALLOCATE (j_matrix)
3404 DEALLOCATE (dd_matrix)
3405 DEALLOCATE (ee_matrix)
3406 DEALLOCATE (ff_matrix)
3411 force(ikind)%tensorial_u(:, :) = force(ikind)%tensorial_u(:, :)*2.0_dp
3414 CALL date_and_time(values=timevalues)
3420 CALL para_env%sum(energy%dft_plus_u)
3422 IF (energy%dft_plus_u < 0.0_dp)
THEN
3423 CALL cp_warn(__location__, &
3424 "DFT+U energy contibution is negative possibly due "// &
3425 "to unphysical Lowdin charges. Check your input, "// &
3426 "if this warning persists or try a different method!")
3436 IF (
PRESENT(matrix_w))
THEN
3447 CALL timestop(handle)
3449 END SUBROUTINE tensorial
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum, ccon)
...
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public dudarev1997
integer, save, public dudarev1998
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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_finalize(matrix)
...
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_put_block(matrix, row, col, block, summation)
...
subroutine, public dbcsr_get_block_diag(matrix, diag)
Copies the diagonal blocks of matrix into diag.
DBCSR operations in CP2K.
subroutine, public cp_dbcsr_sm_fm_multiply(matrix, fm_in, fm_out, ncol, alpha, beta)
multiply a dbcsr with a fm matrix
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public cp_dbcsr_plus_fm_fm_t(sparse_matrix, matrix_v, matrix_g, ncol, alpha, keep_sparsity, symmetry_mode)
performs the multiplication sparse_matrix+dense_mat*dens_mat^T if matrix_g is not explicitly given,...
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
subroutine, public write_fm_with_basis_info(blacs_matrix, before, after, qs_env, para_env, first_row, last_row, first_col, last_col, output_unit, omit_headers)
Print a spherical matrix of blacs type.
subroutine, public cp_dbcsr_write_sparse_matrix(sparse_matrix, before, after, qs_env, para_env, first_row, last_row, first_col, last_col, scale, output_unit, omit_headers, cartesian_basis)
...
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_transpose(matrix, matrixt)
transposes a matrix matrixt = matrix ^ T
subroutine, public cp_fm_schur_product(matrix_a, matrix_b, matrix_c)
computes the schur product of two matrices c_ij = a_ij * b_ij
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....
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
subroutine, public choose_eigv_solver(matrix, eigenvectors, eigenvalues, info)
Choose the Eigensolver depending on which library is available ELPA seems to be unstable for small sy...
represent the structure of a full matrix
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_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_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 ...
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,...
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...
Add the DFT+U contribution to the Hamiltonian matrix.
subroutine, public plus_u(qs_env, matrix_h, matrix_w)
Add the DFT+U contribution to the Hamiltonian matrix. Wrapper routine for all "+U" methods.
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Routines needed for kpoint calculation.
subroutine, public lowdin_kp_trans(kpoint, pmat_diag)
Calculate Lowdin transformation of density matrix S^1/2 P S^1/2 Integrate diagonal elements over k-po...
Types and basic routines needed for a kpoint calculation.
Collection of simple mathematical functions and subroutines.
subroutine, public jacobi(a, d, v)
Jacobi matrix diagonalization. The eigenvalues are returned in vector d and the eigenvectors are retu...
Interface to the message passing library MPI.
compute mulliken charges we (currently) define them as c_i = 1/2 [ (PS)_{ii} + (SP)_{ii} ]
character(len=6) function, public sgf_symbol(n, l, m)
Build a spherical orbital symbol (orbital labels for printing).
basic linear algebra operations for full matrixes
Define methods related to particle_type.
subroutine, public get_particle_set(particle_set, qs_kind_set, first_sgf, last_sgf, nsgf, nmao, basis, ncgf)
Get the components of a particle set.
Define the data structure for the particle information.
Definition of physical constants:
real(kind=dp), parameter, public evolt
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, hund_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
subroutine, public set_qs_kind(qs_kind, paw_atom, ghost, floating, hard_radius, hard0_radius, covalent_radius, vdw_radius, lmax_rho0, zeff, no_optimize, dispersion, u_minus_j, hund_j, reltmat, dftb_parameter, xtb_parameter, elec_conf, pao_basis_size)
Set the components of an atomic kind data set.
subroutine, public get_qs_kind_set(qs_kind_set, all_potential_present, tnadd_potential_present, gth_potential_present, sgp_potential_present, paw_atom_present, dft_plus_u_atom_present, maxcgf, maxsgf, maxco, maxco_proj, maxgtops, maxlgto, maxlprj, maxnset, maxsgf_set, ncgf, npgf, nset, nsgf, nshell, maxpol, maxlppl, maxlppnl, maxppnl, nelectron, maxder, max_ngrid_rad, max_sph_harm, maxg_iso_not0, lmax_rho0, basis_rcut, do_mtlr_present, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
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
Provides all information about an atomic kind.
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...
Contains information about kpoints.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.
keeps the density in various representations, keeping track of which ones are valid.