81#include "./base/base_uses.f90"
87 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'dft_plus_u'
102 SUBROUTINE plus_u(qs_env, matrix_h, matrix_w)
106 POINTER :: matrix_h, matrix_w
108 CHARACTER(LEN=*),
PARAMETER :: routinen =
'plus_u'
110 INTEGER :: handle, output_unit, print_level
111 LOGICAL :: orthonormal_basis, should_output
116 CALL timeset(routinen, handle)
118 cpassert(
ASSOCIATED(qs_env))
120 NULLIFY (input, dft_control)
126 dft_control=dft_control)
134 orthonormal_basis = .false.
138 print_level = logger%iter_info%print_level
141 (.NOT.
PRESENT(matrix_w)))
143 extension=
".plus_u", &
144 ignore_should_output=should_output, &
145 log_filename=.false.)
149 SELECT CASE (dft_control%plus_u_method_id)
151 IF (orthonormal_basis)
THEN
154 CALL mulliken(qs_env, orthonormal_basis, matrix_h, &
155 should_output, output_unit, print_level)
157 CALL lowdin(qs_env, matrix_h, matrix_w, &
158 should_output, output_unit, print_level)
161 CALL mulliken(qs_env, orthonormal_basis, matrix_h, &
162 should_output, output_unit, print_level)
164 CALL mulliken_charges(qs_env, orthonormal_basis, matrix_h, matrix_w, &
165 should_output, output_unit, print_level)
167 cpabort(
"Invalid DFT+U method requested")
171 ignore_should_output=should_output)
173 CALL timestop(handle)
206 SUBROUTINE lowdin(qs_env, matrix_h, matrix_w, should_output, output_unit, &
211 POINTER :: matrix_h, matrix_w
212 LOGICAL,
INTENT(IN) :: should_output
213 INTEGER,
INTENT(IN) :: output_unit, print_level
215 CHARACTER(LEN=*),
PARAMETER :: routinen =
'lowdin'
217 CHARACTER(LEN=10) :: spin_info
218 CHARACTER(LEN=6),
ALLOCATABLE,
DIMENSION(:) :: symbol
219 CHARACTER(LEN=default_string_length) :: atomic_kind_name
220 INTEGER :: atom_a, handle, i, i0, iatom, ikind, iorb, isb, iset, isgf, ishell, ispin, j, &
221 jsb, jset, jsgf, jshell, lu, m, max_scf, n, natom, natom_of_kind, nimg, nkind, norb, nsb, &
222 nsbsize, nset, nsgf, nsgf_kind, nspin
223 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_sgf_atom
224 INTEGER,
DIMENSION(1) :: iloc
225 INTEGER,
DIMENSION(:),
POINTER :: atom_list, nshell, orbitals
226 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf, l, last_sgf
227 LOGICAL :: debug, dft_plus_u_atom, do_kpoints, &
228 found, just_energy, smear
229 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: orb_occ
230 REAL(kind=
dp) :: eps_scf, eps_u_ramping, fspin, occ, sij, &
231 trq, trq2, u_minus_j, &
232 u_minus_j_target, u_ramping
233 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigval, q_eigval
234 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: q_eigvec, q_matrix, q_work, slam
235 REAL(kind=
dp),
CONTIGUOUS,
DIMENSION(:, :), &
236 POINTER :: local_data
237 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: q_block, v_block
240 TYPE(
cp_fm_type) :: fm_sev, fm_work1, fm_work2, slambda
241 TYPE(
cp_fm_type),
DIMENSION(:),
POINTER :: fm_wmat
243 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_p, matrix_s
245 TYPE(
dbcsr_type),
POINTER :: sm_h, sm_p, sm_s, sm_w
252 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
256 CALL timeset(routinen, handle)
261 NULLIFY (atomic_kind_set)
262 NULLIFY (qs_kind_set)
263 NULLIFY (dft_control)
272 NULLIFY (orb_basis_set)
274 NULLIFY (particle_set)
290 atomic_kind_set=atomic_kind_set, &
291 qs_kind_set=qs_kind_set, &
292 dft_control=dft_control, &
293 do_kpoints=do_kpoints, &
296 matrix_s_kp=matrix_s, &
297 particle_set=particle_set, &
302 cpassert(
ASSOCIATED(atomic_kind_set))
303 cpassert(
ASSOCIATED(dft_control))
304 cpassert(
ASSOCIATED(energy))
305 cpassert(
ASSOCIATED(matrix_s))
306 cpassert(
ASSOCIATED(particle_set))
307 cpassert(
ASSOCIATED(rho))
311 energy%dft_plus_u = 0.0_dp
313 nspin = dft_control%nspins
314 nimg = dft_control%nimages
328 nkind =
SIZE(atomic_kind_set)
330 ALLOCATE (first_sgf_atom(natom))
331 first_sgf_atom(:) = 0
334 first_sgf=first_sgf_atom)
336 IF (
PRESENT(matrix_h) .OR.
PRESENT(matrix_w))
THEN
337 just_energy = .false.
343 fm_wmat => scf_env%scf_work1
344 fmstruct => fm_wmat(1)%matrix_struct
347 fm_s_half => scf_env%s_half
348 cpassert(
ASSOCIATED(fm_s_half))
352 CALL cp_fm_create(matrix=fm_work1, matrix_struct=fmstruct, &
353 name=
"FULL WORK MATRIX 1")
354 CALL cp_fm_create(matrix=fm_work2, matrix_struct=fmstruct, &
355 name=
"FULL WORK MATRIX 2")
360 IF (
PRESENT(matrix_w))
THEN
361 CALL cp_fm_create(matrix=fm_sev, matrix_struct=fmstruct)
362 CALL cp_fm_create(matrix=slambda, matrix_struct=fmstruct)
363 ALLOCATE (eigval(nsgf), slam(nsgf, 1))
364 sm_s => matrix_s(1, 1)%matrix
369 IF (eigval(i) > 0._dp)
THEN
370 slam(i, 1) = sqrt(eigval(i))
372 cpabort(
"S matrix not positive definit")
382 DO i = 1,
SIZE(local_data, 2)
383 DO j = 1,
SIZE(local_data, 1)
384 sij = local_data(j, i)
385 IF (sij > 0.0_dp) sij = 1.0_dp/sij
386 local_data(j, i) = sij
389 DEALLOCATE (eigval, slam)
401 sm_s => matrix_s(1, 1)%matrix
414 cpabort(
"Lowdin option with k-points NYA in DFT+U")
416 sm_p => matrix_p(ispin, 1)%matrix
424 matrix_a=fm_s_half, &
430 output_unit=output_unit)
432 output_unit=output_unit)
434 output_unit=output_unit)
454 atom_list=atom_list, &
455 name=atomic_kind_name, &
459 dft_plus_u_atom=dft_plus_u_atom, &
460 l_of_dft_plus_u=lu, &
462 basis_set=orb_basis_set, &
463 u_minus_j=u_minus_j, &
464 u_minus_j_target=u_minus_j_target, &
465 u_ramping=u_ramping, &
466 eps_u_ramping=eps_u_ramping, &
473 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
474 IF (.NOT. dft_plus_u_atom) cycle
478 IF ((ispin == 1) .AND. (u_ramping > 0.0_dp))
THEN
479 IF (qs_env%scf_env%iter_delta <= eps_u_ramping)
THEN
480 u_minus_j = min(u_minus_j + u_ramping, u_minus_j_target)
481 CALL set_qs_kind(qs_kind_set(ikind), u_minus_j=u_minus_j)
483 IF (should_output .AND. (output_unit > 0))
THEN
484 WRITE (unit=output_unit, fmt=
"(T3,A,3X,A,F0.3,A)") &
485 "Kind name: "//trim(adjustl(atomic_kind_name)), &
486 "U(eff) = ", u_minus_j*
evolt,
" eV"
490 IF (u_minus_j == 0.0_dp) cycle
494 first_sgf=first_sgf, &
503 DO ishell = 1, nshell(iset)
504 IF (l(ishell, iset) == lu) nsb = nsb + 1
511 ALLOCATE (q_matrix(n, n))
512 q_matrix(:, :) = 0.0_dp
516 IF (output_unit > 0)
THEN
517 ALLOCATE (symbol(nsbsize))
522 WRITE (unit=spin_info, fmt=
"(A8,I2)")
" of spin", ispin
526 WRITE (unit=output_unit, fmt=
"(/,T3,A,I0,A,/,/,T5,A,10(2X,A6))") &
527 "DFT+U occupations"//trim(spin_info)//
" for the atoms of atomic kind ", ikind, &
528 ": "//trim(atomic_kind_name), &
529 "Atom Shell ", (adjustr(symbol(i)), i=1, nsbsize),
" Trace"
535 DO iatom = 1, natom_of_kind
536 atom_a = atom_list(iatom)
537 q_matrix(:, :) = 0.0_dp
546 IF (
ASSOCIATED(q_block))
THEN
550 DO ishell = 1, nshell(iset)
551 IF (l(ishell, iset) /= lu) cycle
552 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
556 DO jshell = 1, nshell(jset)
557 IF (l(jshell, jset) /= lu) cycle
558 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
560 IF (isgf == jsgf) q_matrix(i, j) = q_block(isgf, jsgf)
569 IF (
ASSOCIATED(orbitals))
THEN
570 IF ((qs_env%scf_env%iter_delta >= eps_scf) .OR. &
571 ((qs_env%scf_env%outer_scf%iter_count == 0) .AND. &
572 (qs_env%scf_env%iter_count <= max_scf)))
THEN
573 ALLOCATE (orb_occ(nsbsize))
574 ALLOCATE (q_eigval(n))
576 ALLOCATE (q_eigvec(n, n))
577 q_eigvec(:, :) = 0.0_dp
578 norb =
SIZE(orbitals)
579 CALL jacobi(q_matrix, q_eigval, q_eigvec)
580 q_matrix(:, :) = 0.0_dp
583 DO i = (isb - 1)*nsbsize + 1, isb*nsbsize
584 trq = trq + q_eigval(i)
587 occ = trq/real(norb, kind=
dp)
592 iloc = maxloc(q_eigvec(:, isb*nsbsize))
593 jsb = int((iloc(1) - 1)/nsbsize) + 1
595 i0 = (jsb - 1)*nsbsize + 1
597 DO j = i0, jsb*nsbsize
601 IF (.NOT. orb_occ(lu + m + 1))
THEN
603 orb_occ(lu + m + 1) = .true.
607 iorb = i0 + lu + orbitals(i)
608 orb_occ(lu + orbitals(i) + 1) = .true.
610 cpassert(iorb /= -1000)
611 iloc = maxloc(q_eigvec(iorb, :))
612 q_eigval(iloc(1)) = min(occ, trq)
613 q_matrix(:, iloc(1)) = q_eigval(iloc(1))*q_eigvec(:, iloc(1))
614 trq = trq - q_eigval(iloc(1))
617 q_matrix(:, :) = matmul(q_matrix, transpose(q_eigvec))
619 DEALLOCATE (q_eigval)
620 DEALLOCATE (q_eigvec)
627 trq = trq + q_matrix(i, i)
629 trq2 = trq2 + q_matrix(i, j)*q_matrix(j, i)
633 trq2 = fspin*fspin*trq2
636 energy%dft_plus_u = energy%dft_plus_u + 0.5_dp*u_minus_j*(trq - trq2)/fspin
639 IF (.NOT. just_energy)
THEN
645 cpassert(
ASSOCIATED(v_block))
649 DO ishell = 1, nshell(iset)
650 IF (l(ishell, iset) /= lu) cycle
651 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
655 DO jshell = 1, nshell(jset)
656 IF (l(jshell, jset) /= lu) cycle
657 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
659 IF (isgf == jsgf)
THEN
660 v_block(isgf, isgf) = u_minus_j*(0.5_dp - fspin*q_matrix(i, i))
662 cpassert(abs(q_matrix(j, i)) < 1.0e-14_dp)
663 v_block(isgf, jsgf) = -u_minus_j*fspin*q_matrix(j, i)
677 CALL para_env%sum(q_matrix)
678 IF (output_unit > 0)
THEN
679 ALLOCATE (q_work(nsb, nsbsize))
680 q_work(:, :) = 0.0_dp
683 DO i = (isb - 1)*nsbsize + 1, isb*nsbsize
685 q_work(isb, j) = q_matrix(i, i)
689 WRITE (unit=output_unit, fmt=
"(T3,I6,2X,I6,2X,10F8.3)") &
690 atom_a, isb, q_work(isb, :), sum(q_work(isb, :))
692 WRITE (unit=output_unit, fmt=
"(T12,A,2X,10F8.3)") &
693 "Total", (sum(q_work(:, i)), i=1, nsbsize), sum(q_work)
694 WRITE (unit=output_unit, fmt=
"(A)")
""
698 WRITE (unit=output_unit, fmt=
"(T9,70I10)") (i, i=1, n)
700 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_matrix(i, :)
703 ALLOCATE (q_eigval(n))
705 ALLOCATE (q_eigvec(n, n))
706 q_eigvec(:, :) = 0.0_dp
707 CALL jacobi(q_matrix, q_eigval, q_eigvec)
708 WRITE (unit=output_unit, fmt=
"(/,T9,70I10)") (i, i=1, n)
709 WRITE (unit=output_unit, fmt=
"(T9,71F10.6)") (q_eigval(i), i=1, n), &
712 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_eigvec(i, :)
714 DEALLOCATE (q_eigval)
715 DEALLOCATE (q_eigvec)
720 ALLOCATE (q_work(nsgf_kind, nsgf_kind))
721 q_work(:, :) = 0.0_dp
722 IF (
ASSOCIATED(q_block)) q_work(:, :) = q_block(:, :)
723 CALL para_env%sum(q_work)
724 IF (output_unit > 0)
THEN
725 norb =
SIZE(q_work, 1)
726 WRITE (unit=output_unit, fmt=
"(/,T9,200I10)") (i, i=1, norb)
728 WRITE (unit=output_unit, fmt=
"(T3,I6,200F10.6)") i, q_work(i, :)
730 ALLOCATE (q_eigval(norb))
732 ALLOCATE (q_eigvec(norb, norb))
733 q_eigvec(:, :) = 0.0_dp
734 CALL jacobi(q_work, q_eigval, q_eigvec)
735 WRITE (unit=output_unit, fmt=
"(/,T9,200I10)") (i, i=1, norb)
736 WRITE (unit=output_unit, fmt=
"(T9,201F10.6)") (q_eigval(i), i=1, norb), &
737 sum(q_eigval(1:norb))
739 WRITE (unit=output_unit, fmt=
"(T3,I6,200F10.6)") i, q_eigvec(i, :)
741 DEALLOCATE (q_eigval)
742 DEALLOCATE (q_eigvec)
750 IF (
ALLOCATED(q_matrix))
THEN
751 DEALLOCATE (q_matrix)
756 IF (
PRESENT(matrix_h))
THEN
758 cpabort(
"Lowdin option with k-points NYA in DFT+U")
760 sm_h => matrix_h(ispin, 1)%matrix
769 IF (
PRESENT(matrix_w))
THEN
771 sm_p => matrix_p(ispin, 1)%matrix
772 sm_w => matrix_w(ispin, 1)%matrix
777 CALL parallel_gemm(
'N',
'N', nsgf, nsgf, nsgf, 1.0_dp, fm_work1, fm_sev, 0.0_dp, fm_work2)
778 CALL parallel_gemm(
'T',
'N', nsgf, nsgf, nsgf, 1.0_dp, fm_sev, fm_work2, 0.0_dp, fm_work1)
782 CALL parallel_gemm(
'N',
'N', nsgf, nsgf, nsgf, -2.0_dp, fm_sev, fm_work2, 0.0_dp, fm_work1)
789 IF (
PRESENT(matrix_w))
THEN
796 CALL para_env%sum(energy%dft_plus_u)
798 IF (energy%dft_plus_u < 0.0_dp) &
799 CALL cp_warn(__location__, &
800 "DFT+U energy contribution is negative possibly due "// &
801 "to unphysical Lowdin charges!")
812 CALL timestop(handle)
814 END SUBROUTINE lowdin
846 SUBROUTINE mulliken(qs_env, orthonormal_basis, matrix_h, should_output, &
847 output_unit, print_level)
850 LOGICAL,
INTENT(IN) :: orthonormal_basis
853 LOGICAL,
INTENT(IN) :: should_output
854 INTEGER,
INTENT(IN) :: output_unit, print_level
856 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mulliken'
858 CHARACTER(LEN=10) :: spin_info
859 CHARACTER(LEN=6),
ALLOCATABLE,
DIMENSION(:) :: symbol
860 CHARACTER(LEN=default_string_length) :: atomic_kind_name
861 INTEGER :: atom_a, handle, i, i0, iatom, ic, ikind, iorb, isb, iset, isgf, ishell, ispin, j, &
862 jsb, jset, jsgf, jshell, lu, m, max_scf, n, natom, natom_of_kind, nimg, nkind, norb, nsb, &
863 nsbsize, nset, nsgf_kind, nspin
864 INTEGER,
DIMENSION(1) :: iloc
865 INTEGER,
DIMENSION(:),
POINTER :: atom_list, nshell, orbitals
866 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf, l, last_sgf
867 LOGICAL :: debug, dft_plus_u_atom, found, &
868 just_energy, occupation_enforced, smear
869 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: is_plus_u_kind, orb_occ
870 REAL(kind=
dp) :: eps_scf, eps_u_ramping, fspin, occ, trq, &
871 trq2, u_minus_j, u_minus_j_target, &
873 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: q_eigval
874 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: q_eigvec, q_matrix, q_work
875 REAL(kind=
dp),
DIMENSION(:),
POINTER :: nelec
876 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: h_block, p_block, q_block, s_block, &
880 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_p, matrix_s
881 TYPE(
dbcsr_type),
POINTER :: sm_h, sm_p, sm_q, sm_s, sm_v
887 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
890 CALL timeset(routinen, handle)
895 NULLIFY (atomic_kind_set)
896 NULLIFY (qs_kind_set)
897 NULLIFY (dft_control)
907 NULLIFY (orb_basis_set)
909 NULLIFY (particle_set)
925 occupation_enforced = .false.
928 atomic_kind_set=atomic_kind_set, &
929 qs_kind_set=qs_kind_set, &
930 dft_control=dft_control, &
932 particle_set=particle_set, &
936 cpassert(
ASSOCIATED(atomic_kind_set))
937 cpassert(
ASSOCIATED(dft_control))
938 cpassert(
ASSOCIATED(energy))
939 cpassert(
ASSOCIATED(particle_set))
940 cpassert(
ASSOCIATED(rho))
942 IF (orthonormal_basis)
THEN
947 matrix_s_kp=matrix_s)
948 cpassert(
ASSOCIATED(matrix_s))
950 nimg = dft_control%nimages
956 energy%dft_plus_u = 0.0_dp
958 nspin = dft_control%nspins
972 nkind =
SIZE(atomic_kind_set)
974 ALLOCATE (is_plus_u_kind(nkind))
975 is_plus_u_kind(:) = .false.
977 IF (
PRESENT(matrix_h))
THEN
978 just_energy = .false.
988 IF (.NOT. orthonormal_basis)
THEN
989 sm_s => matrix_s(1, ic)%matrix
992 IF (
PRESENT(matrix_h))
THEN
994 sm_h => matrix_h(ispin, ic)%matrix
1001 sm_p => matrix_p(ispin, ic)%matrix
1003 IF (.NOT.
ASSOCIATED(sm_q))
THEN
1009 IF (.NOT.
ASSOCIATED(sm_v))
THEN
1023 IF (.NOT.
ASSOCIATED(p_block)) cycle
1030 cpassert(
ASSOCIATED(q_block))
1032 IF (orthonormal_basis)
THEN
1034 DO isgf = 1,
SIZE(q_block, 1)
1035 q_block(isgf, isgf) = p_block(isgf, isgf)
1043 cpassert(
ASSOCIATED(s_block))
1045 DO jsgf = 1,
SIZE(p_block, 2)
1046 DO isgf = 1,
SIZE(p_block, 1)
1047 q_block(isgf, jsgf) = p_block(isgf, jsgf)*s_block(isgf, jsgf)
1068 atom_list=atom_list, &
1069 name=atomic_kind_name, &
1070 natom=natom_of_kind)
1073 dft_plus_u_atom=dft_plus_u_atom, &
1074 l_of_dft_plus_u=lu, &
1076 basis_set=orb_basis_set, &
1077 u_minus_j=u_minus_j, &
1078 u_minus_j_target=u_minus_j_target, &
1079 u_ramping=u_ramping, &
1080 eps_u_ramping=eps_u_ramping, &
1082 orbitals=orbitals, &
1089 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
1090 IF (.NOT. dft_plus_u_atom) cycle
1095 IF ((ispin == 1) .AND. (u_ramping > 0.0_dp))
THEN
1096 IF (qs_env%scf_env%iter_delta <= eps_u_ramping)
THEN
1097 u_minus_j = min(u_minus_j + u_ramping, u_minus_j_target)
1098 CALL set_qs_kind(qs_kind_set(ikind), u_minus_j=u_minus_j)
1100 IF (should_output .AND. (output_unit > 0))
THEN
1101 WRITE (unit=output_unit, fmt=
"(T3,A,3X,A,F0.3,A)") &
1102 "Kind name: "//trim(adjustl(atomic_kind_name)), &
1103 "U(eff) = ", u_minus_j*
evolt,
" eV"
1107 IF (u_minus_j == 0.0_dp) cycle
1109 is_plus_u_kind(ikind) = .true.
1114 first_sgf=first_sgf, &
1116 last_sgf=last_sgf, &
1124 DO ishell = 1, nshell(iset)
1125 IF (l(ishell, iset) == lu) nsb = nsb + 1
1129 nsbsize = (2*lu + 1)
1132 ALLOCATE (q_matrix(n, n))
1133 q_matrix(:, :) = 0.0_dp
1138 IF (output_unit > 0)
THEN
1139 ALLOCATE (symbol(nsbsize))
1144 WRITE (unit=spin_info, fmt=
"(A8,I2)")
" of spin", ispin
1148 WRITE (unit=output_unit, fmt=
"(/,T3,A,I0,A,/,/,T5,A,10(2X,A6))") &
1149 "DFT+U occupations"//trim(spin_info)//
" for the atoms of atomic kind ", ikind, &
1150 ": "//trim(atomic_kind_name), &
1151 "Atom Shell ", (adjustr(symbol(i)), i=1, nsbsize),
" Trace"
1158 DO iatom = 1, natom_of_kind
1160 atom_a = atom_list(iatom)
1162 q_matrix(:, :) = 0.0_dp
1174 IF (
ASSOCIATED(q_block))
THEN
1178 DO ishell = 1, nshell(iset)
1179 IF (l(ishell, iset) /= lu) cycle
1180 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
1184 DO jshell = 1, nshell(jset)
1185 IF (l(jshell, jset) /= lu) cycle
1186 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
1188 q_matrix(i, j) = q_block(isgf, jsgf)
1198 IF (
ASSOCIATED(orbitals))
THEN
1199 IF ((qs_env%scf_env%iter_delta >= eps_scf) .OR. &
1200 ((qs_env%scf_env%outer_scf%iter_count == 0) .AND. &
1201 (qs_env%scf_env%iter_count <= max_scf)))
THEN
1202 ALLOCATE (orb_occ(nsbsize))
1203 ALLOCATE (q_eigval(n))
1204 q_eigval(:) = 0.0_dp
1205 ALLOCATE (q_eigvec(n, n))
1206 q_eigvec(:, :) = 0.0_dp
1207 norb =
SIZE(orbitals)
1208 CALL jacobi(q_matrix, q_eigval, q_eigvec)
1209 q_matrix(:, :) = 0.0_dp
1210 IF (nelec(ispin) >= 0.5_dp)
THEN
1211 trq = nelec(ispin)/sum(q_eigval(1:n))
1212 q_eigval(1:n) = trq*q_eigval(1:n)
1216 DO i = (isb - 1)*nsbsize + 1, isb*nsbsize
1217 trq = trq + q_eigval(i)
1220 occ = trq/real(norb, kind=
dp)
1224 orb_occ(:) = .false.
1225 iloc = maxloc(q_eigvec(:, isb*nsbsize))
1226 jsb = int((iloc(1) - 1)/nsbsize) + 1
1228 i0 = (jsb - 1)*nsbsize + 1
1230 DO j = i0, jsb*nsbsize
1234 IF (.NOT. orb_occ(lu + m + 1))
THEN
1236 orb_occ(lu + m + 1) = .true.
1240 iorb = i0 + lu + orbitals(i)
1241 orb_occ(lu + orbitals(i) + 1) = .true.
1243 cpassert(iorb /= -1000)
1244 iloc = maxloc(q_eigvec(iorb, :))
1245 q_eigval(iloc(1)) = min(occ, trq)
1246 q_matrix(:, iloc(1)) = q_eigval(iloc(1))*q_eigvec(:, iloc(1))
1247 trq = trq - q_eigval(iloc(1))
1250 q_matrix(:, :) = matmul(q_matrix, transpose(q_eigvec))
1251 DEALLOCATE (orb_occ)
1252 DEALLOCATE (q_eigval)
1253 DEALLOCATE (q_eigvec)
1254 occupation_enforced = .true.
1262 trq = trq + q_matrix(i, i)
1264 trq2 = trq2 + q_matrix(i, j)*q_matrix(j, i)
1269 trq2 = fspin*fspin*trq2
1273 energy%dft_plus_u = energy%dft_plus_u + 0.5_dp*u_minus_j*(trq - trq2)/fspin
1277 IF (.NOT. just_energy)
THEN
1284 cpassert(
ASSOCIATED(v_block))
1288 DO ishell = 1, nshell(iset)
1289 IF (l(ishell, iset) /= lu) cycle
1290 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
1294 DO jshell = 1, nshell(jset)
1295 IF (l(jshell, jset) /= lu) cycle
1296 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
1298 IF (isgf == jsgf)
THEN
1299 v_block(isgf, isgf) = u_minus_j*(0.5_dp - fspin*q_matrix(i, i))
1301 v_block(isgf, jsgf) = -u_minus_j*fspin*q_matrix(j, i)
1317 CALL para_env%sum(q_matrix)
1318 IF (output_unit > 0)
THEN
1319 ALLOCATE (q_work(nsb, nsbsize))
1320 q_work(:, :) = 0.0_dp
1323 DO i = (isb - 1)*nsbsize + 1, isb*nsbsize
1325 q_work(isb, j) = q_matrix(i, i)
1329 WRITE (unit=output_unit, fmt=
"(T3,I6,2X,I6,2X,10F8.3)") &
1330 atom_a, isb, q_work(isb, :), sum(q_work(isb, :))
1332 WRITE (unit=output_unit, fmt=
"(T12,A,2X,10F8.3)") &
1333 "Total", (sum(q_work(:, i)), i=1, nsbsize), sum(q_work)
1334 WRITE (unit=output_unit, fmt=
"(A)")
""
1338 WRITE (unit=output_unit, fmt=
"(T9,70I10)") (i, i=1, n)
1340 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_matrix(i, :)
1343 ALLOCATE (q_eigval(n))
1344 q_eigval(:) = 0.0_dp
1345 ALLOCATE (q_eigvec(n, n))
1346 q_eigvec(:, :) = 0.0_dp
1347 CALL jacobi(q_matrix, q_eigval, q_eigvec)
1348 WRITE (unit=output_unit, fmt=
"(/,T9,70I10)") (i, i=1, n)
1349 WRITE (unit=output_unit, fmt=
"(T9,71F10.6)") (q_eigval(i), i=1, n), &
1352 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_eigvec(i, :)
1354 DEALLOCATE (q_eigval)
1355 DEALLOCATE (q_eigvec)
1360 ALLOCATE (q_work(nsgf_kind, nsgf_kind))
1361 q_work(:, :) = 0.0_dp
1362 IF (
ASSOCIATED(q_block)) q_work(:, :) = q_block(:, :)
1363 CALL para_env%sum(q_work)
1364 IF (output_unit > 0)
THEN
1365 norb =
SIZE(q_work, 1)
1366 WRITE (unit=output_unit, fmt=
"(/,T9,200I10)") (i, i=1, norb)
1368 WRITE (unit=output_unit, fmt=
"(T3,I6,200F10.6)") i, q_work(i, :)
1370 ALLOCATE (q_eigval(norb))
1371 q_eigval(:) = 0.0_dp
1372 ALLOCATE (q_eigvec(norb, norb))
1373 q_eigvec(:, :) = 0.0_dp
1374 CALL jacobi(q_work, q_eigval, q_eigvec)
1375 WRITE (unit=output_unit, fmt=
"(/,T9,200I10)") (i, i=1, norb)
1376 WRITE (unit=output_unit, fmt=
"(T9,201F10.6)") (q_eigval(i), i=1, norb), &
1377 sum(q_eigval(1:norb))
1379 WRITE (unit=output_unit, fmt=
"(T3,I6,200F10.6)") i, q_eigvec(i, :)
1381 DEALLOCATE (q_eigval)
1382 DEALLOCATE (q_eigvec)
1390 IF (
ALLOCATED(q_matrix))
THEN
1391 DEALLOCATE (q_matrix)
1398 IF (
ASSOCIATED(sm_h))
THEN
1402 IF (.NOT. is_plus_u_kind(ikind)) cycle
1404 kind_a => atomic_kind_set(ikind)
1407 atom_list=atom_list, &
1408 natom=natom_of_kind)
1410 DO iatom = 1, natom_of_kind
1412 atom_a = atom_list(iatom)
1420 IF (.NOT.
ASSOCIATED(h_block)) cycle
1427 cpassert(
ASSOCIATED(v_block))
1429 IF (orthonormal_basis)
THEN
1430 DO isgf = 1,
SIZE(h_block, 1)
1431 h_block(isgf, isgf) = h_block(isgf, isgf) + v_block(isgf, isgf)
1439 cpassert(
ASSOCIATED(s_block))
1440 DO jsgf = 1,
SIZE(h_block, 2)
1441 DO isgf = 1,
SIZE(h_block, 1)
1442 h_block(isgf, jsgf) = h_block(isgf, jsgf) + v_block(isgf, jsgf)*s_block(isgf, jsgf)
1459 CALL para_env%sum(energy%dft_plus_u)
1461 IF (energy%dft_plus_u < 0.0_dp)
THEN
1462 IF (.NOT. occupation_enforced)
THEN
1463 CALL cp_warn(__location__, &
1464 "DFT+U energy contribution is negative possibly due "// &
1465 "to unphysical Mulliken charges!")
1472 CALL timestop(handle)
1512 SUBROUTINE mulliken_charges(qs_env, orthonormal_basis, matrix_h, matrix_w, &
1513 should_output, output_unit, print_level)
1516 LOGICAL,
INTENT(IN) :: orthonormal_basis
1518 POINTER :: matrix_h, matrix_w
1519 LOGICAL,
INTENT(IN) :: should_output
1520 INTEGER,
INTENT(IN) :: output_unit, print_level
1522 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mulliken_charges'
1524 CHARACTER(LEN=10) :: spin_info
1525 CHARACTER(LEN=6),
ALLOCATABLE,
DIMENSION(:) :: symbol
1526 CHARACTER(LEN=default_string_length) :: atomic_kind_name
1527 INTEGER :: atom_a, handle, i, iatom, ic, ikind, isb, iset, isgf, ishell, ispin, jatom, jsgf, &
1528 lu, m, natom, natom_of_kind, nimg, nkind, nsb, nset, nsgf, nspin, sgf
1529 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_sgf_atom
1530 INTEGER,
DIMENSION(:),
POINTER :: atom_list, nshell
1531 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf, l, last_sgf
1532 LOGICAL :: dft_plus_u_atom, found, just_energy
1533 REAL(kind=
dp) :: eps_u_ramping, fspin, q, u_minus_j, &
1534 u_minus_j_target, u_ramping, v
1535 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: dedq, trps
1536 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: q_ii
1537 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: h_block, p_block, s_block, w_block
1540 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_p, matrix_s
1541 TYPE(
dbcsr_type),
POINTER :: sm_h, sm_p, sm_s, sm_w
1547 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1550 CALL timeset(routinen, handle)
1553 NULLIFY (atomic_kind_set)
1554 NULLIFY (qs_kind_set)
1555 NULLIFY (dft_control)
1564 NULLIFY (orb_basis_set)
1566 NULLIFY (particle_set)
1576 atomic_kind_set=atomic_kind_set, &
1577 qs_kind_set=qs_kind_set, &
1578 dft_control=dft_control, &
1580 particle_set=particle_set, &
1584 cpassert(
ASSOCIATED(atomic_kind_set))
1585 cpassert(
ASSOCIATED(dft_control))
1586 cpassert(
ASSOCIATED(energy))
1587 cpassert(
ASSOCIATED(particle_set))
1588 cpassert(
ASSOCIATED(rho))
1590 IF (orthonormal_basis)
THEN
1595 matrix_s_kp=matrix_s)
1596 cpassert(
ASSOCIATED(matrix_s))
1603 energy%dft_plus_u = 0.0_dp
1605 nspin = dft_control%nspins
1606 nimg = dft_control%nimages
1608 IF (nspin == 2)
THEN
1620 nkind =
SIZE(atomic_kind_set)
1622 ALLOCATE (first_sgf_atom(natom))
1623 first_sgf_atom(:) = 0
1626 first_sgf=first_sgf_atom)
1628 ALLOCATE (trps(nsgf))
1631 IF (
PRESENT(matrix_h) .OR.
PRESENT(matrix_w))
THEN
1632 ALLOCATE (dedq(nsgf))
1633 just_energy = .false.
1635 just_energy = .true.
1642 IF (.NOT. just_energy) dedq(:) = 0.0_dp
1649 IF (orthonormal_basis)
THEN
1652 sm_s => matrix_s(1, ic)%matrix
1654 sm_p => matrix_p(ispin, ic)%matrix
1662 IF (orthonormal_basis)
THEN
1664 IF (iatom /= jatom) cycle
1666 IF (
ASSOCIATED(p_block))
THEN
1667 sgf = first_sgf_atom(iatom)
1668 DO isgf = 1,
SIZE(p_block, 1)
1669 trps(sgf) = trps(sgf) + p_block(isgf, isgf)
1681 cpassert(
ASSOCIATED(s_block))
1683 sgf = first_sgf_atom(jatom)
1684 DO jsgf = 1,
SIZE(p_block, 2)
1685 DO isgf = 1,
SIZE(p_block, 1)
1686 trps(sgf) = trps(sgf) + p_block(isgf, jsgf)*s_block(isgf, jsgf)
1691 IF (iatom /= jatom)
THEN
1692 sgf = first_sgf_atom(iatom)
1693 DO isgf = 1,
SIZE(p_block, 1)
1694 DO jsgf = 1,
SIZE(p_block, 2)
1695 trps(sgf) = trps(sgf) + p_block(isgf, jsgf)*s_block(isgf, jsgf)
1709 CALL para_env%sum(trps)
1726 atom_list=atom_list, &
1727 name=atomic_kind_name, &
1728 natom=natom_of_kind)
1731 dft_plus_u_atom=dft_plus_u_atom, &
1732 l_of_dft_plus_u=lu, &
1733 basis_set=orb_basis_set, &
1734 u_minus_j=u_minus_j, &
1735 u_minus_j_target=u_minus_j_target, &
1736 u_ramping=u_ramping, &
1737 eps_u_ramping=eps_u_ramping)
1741 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
1742 IF (.NOT. dft_plus_u_atom) cycle
1747 IF ((ispin == 1) .AND. (u_ramping > 0.0_dp))
THEN
1748 IF (qs_env%scf_env%iter_delta <= eps_u_ramping)
THEN
1749 u_minus_j = min(u_minus_j + u_ramping, u_minus_j_target)
1750 CALL set_qs_kind(qs_kind_set(ikind), u_minus_j=u_minus_j)
1752 IF (should_output .AND. (output_unit > 0))
THEN
1753 WRITE (unit=output_unit, fmt=
"(T3,A,3X,A,F0.3,A)") &
1754 "Kind name: "//trim(adjustl(atomic_kind_name)), &
1755 "U(eff) = ", u_minus_j*
evolt,
" eV"
1759 IF (u_minus_j == 0.0_dp) cycle
1764 first_sgf=first_sgf, &
1766 last_sgf=last_sgf, &
1774 DO ishell = 1, nshell(iset)
1775 IF (l(ishell, iset) == lu) nsb = nsb + 1
1779 ALLOCATE (q_ii(nsb, 2*lu + 1))
1784 IF (output_unit > 0)
THEN
1785 ALLOCATE (symbol(2*lu + 1))
1790 WRITE (unit=spin_info, fmt=
"(A8,I2)")
" of spin", ispin
1794 WRITE (unit=output_unit, fmt=
"(/,T3,A,I0,A,/,/,T5,A,10(2X,A6))") &
1795 "DFT+U occupations"//trim(spin_info)//
" for the atoms of atomic kind ", ikind, &
1796 ": "//trim(atomic_kind_name), &
1797 "Atom Shell ", (adjustr(symbol(i)), i=1, 2*lu + 1),
" Trace"
1804 DO iatom = 1, natom_of_kind
1806 atom_a = atom_list(iatom)
1820 IF (
ASSOCIATED(p_block))
THEN
1822 sgf = first_sgf_atom(atom_a)
1826 DO ishell = 1, nshell(iset)
1827 IF (l(ishell, iset) == lu)
THEN
1830 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
1834 energy%dft_plus_u = energy%dft_plus_u + &
1835 0.5_dp*u_minus_j*(q - q**2)/fspin
1836 IF (.NOT. just_energy)
THEN
1837 dedq(sgf) = dedq(sgf) + u_minus_j*(0.5_dp - q)
1842 sgf = sgf + last_sgf(ishell, iset) - first_sgf(ishell, iset) + 1
1852 CALL para_env%sum(q_ii)
1853 IF (output_unit > 0)
THEN
1855 WRITE (unit=output_unit, fmt=
"(T3,I6,2X,I6,2X,10F8.3)") &
1856 atom_a, isb, q_ii(isb, :), sum(q_ii(isb, :))
1858 WRITE (unit=output_unit, fmt=
"(T12,A,2X,10F8.3)") &
1859 "Total", (sum(q_ii(:, i)), i=1, 2*lu + 1), sum(q_ii)
1860 WRITE (unit=output_unit, fmt=
"(A)")
""
1866 IF (
ALLOCATED(q_ii))
THEN
1872 IF (.NOT. just_energy)
THEN
1873 CALL para_env%sum(dedq)
1878 IF (
PRESENT(matrix_h))
THEN
1881 IF (orthonormal_basis)
THEN
1884 sm_s => matrix_s(1, ic)%matrix
1886 sm_h => matrix_h(ispin, ic)%matrix
1894 IF (orthonormal_basis)
THEN
1896 IF (iatom /= jatom) cycle
1898 IF (
ASSOCIATED(h_block))
THEN
1899 sgf = first_sgf_atom(iatom)
1900 DO isgf = 1,
SIZE(h_block, 1)
1901 h_block(isgf, isgf) = h_block(isgf, isgf) + dedq(sgf)
1915 cpassert(
ASSOCIATED(s_block))
1919 sgf = first_sgf_atom(iatom)
1921 DO isgf = 1,
SIZE(h_block, 1)
1922 IF (dedq(sgf) /= 0.0_dp)
THEN
1923 v = 0.5_dp*dedq(sgf)
1924 DO jsgf = 1,
SIZE(h_block, 2)
1925 h_block(isgf, jsgf) = h_block(isgf, jsgf) + v*s_block(isgf, jsgf)
1931 sgf = first_sgf_atom(jatom)
1933 DO jsgf = 1,
SIZE(h_block, 2)
1934 IF (dedq(sgf) /= 0.0_dp)
THEN
1935 v = 0.5_dp*dedq(sgf)
1936 DO isgf = 1,
SIZE(h_block, 1)
1937 h_block(isgf, jsgf) = h_block(isgf, jsgf) + v*s_block(isgf, jsgf)
1957 IF (
PRESENT(matrix_w) .AND. (.NOT. orthonormal_basis))
THEN
1960 sm_s => matrix_s(1, ic)%matrix
1961 sm_p => matrix_p(ispin, ic)%matrix
1962 sm_w => matrix_w(ispin, ic)%matrix
1972 IF (iatom == jatom) cycle
1981 cpassert(
ASSOCIATED(w_block))
1985 sgf = first_sgf_atom(iatom)
1987 DO isgf = 1,
SIZE(w_block, 1)
1988 IF (dedq(sgf) /= 0.0_dp)
THEN
1989 v = -0.5_dp*dedq(sgf)
1990 DO jsgf = 1,
SIZE(w_block, 2)
1991 w_block(isgf, jsgf) = w_block(isgf, jsgf) + v*p_block(isgf, jsgf)
1997 sgf = first_sgf_atom(jatom)
1999 DO jsgf = 1,
SIZE(w_block, 2)
2000 IF (dedq(sgf) /= 0.0_dp)
THEN
2001 v = -0.5_dp*dedq(sgf)
2002 DO isgf = 1,
SIZE(w_block, 1)
2003 w_block(isgf, jsgf) = w_block(isgf, jsgf) + v*p_block(isgf, jsgf)
2021 CALL para_env%sum(energy%dft_plus_u)
2023 IF (energy%dft_plus_u < 0.0_dp) &
2024 CALL cp_warn(__location__, &
2025 "DFT+U energy contribution is negative possibly due "// &
2026 "to unphysical Mulliken charges!")
2030 IF (
ALLOCATED(first_sgf_atom))
THEN
2031 DEALLOCATE (first_sgf_atom)
2034 IF (
ALLOCATED(trps))
THEN
2038 IF (
ALLOCATED(dedq))
THEN
2042 CALL timestop(handle)
2044 END SUBROUTINE mulliken_charges
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)
...
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)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_get_block_p(matrix, row, col, block, found, row_size, col_size)
...
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_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)
...
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_create(matrix, matrix_struct, name, use_sp, nrow, ncol, set_zero)
creates a new full matrix with the given structure
subroutine, public cp_fm_set_submatrix(fm, new_values, start_row, start_col, n_rows, n_cols, alpha, beta, transpose)
sets a submatrix of a full matrix fm(start_row:start_row+n_rows,start_col:start_col+n_cols) = alpha*o...
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(matrix_p, kpoints, ispin, fmwork)
Kpoint transformation of density matrix for Lowdin population analysis Transforms matrices to kpoint,...
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)
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, 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, 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, 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 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, basis_type, total_zeff_corr, npgf_seg, cneo_potential_present, nkind_q, natom_q)
Get attributes of an atomic kind set.
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, reltmat, dftb_parameter, xtb_parameter, elec_conf, pao_basis_size)
Set the components of an atomic kind data 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.