48 USE dbcsr_api,
ONLY: &
49 dbcsr_deallocate_matrix, dbcsr_get_block_diag, dbcsr_get_block_p, &
50 dbcsr_iterator_blocks_left, dbcsr_iterator_next_block, dbcsr_iterator_start, &
51 dbcsr_iterator_stop, dbcsr_iterator_type, dbcsr_p_type, dbcsr_set, dbcsr_type
76#include "./base/base_uses.f90"
82 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'dft_plus_u'
97 SUBROUTINE plus_u(qs_env, matrix_h, matrix_w)
100 TYPE(dbcsr_p_type),
DIMENSION(:),
OPTIONAL, &
101 POINTER :: matrix_h, matrix_w
103 CHARACTER(LEN=*),
PARAMETER :: routinen =
'plus_u'
105 INTEGER :: handle, output_unit, print_level
106 LOGICAL :: orthonormal_basis, should_output
111 CALL timeset(routinen, handle)
113 cpassert(
ASSOCIATED(qs_env))
115 NULLIFY (input, dft_control)
121 dft_control=dft_control)
129 orthonormal_basis = .false.
133 print_level = logger%iter_info%print_level
136 (.NOT.
PRESENT(matrix_w)))
138 extension=
".plus_u", &
139 ignore_should_output=should_output, &
140 log_filename=.false.)
144 SELECT CASE (dft_control%plus_u_method_id)
146 IF (orthonormal_basis)
THEN
149 CALL mulliken(qs_env, orthonormal_basis, matrix_h, &
150 should_output, output_unit, print_level)
152 CALL lowdin(qs_env, matrix_h, matrix_w, &
153 should_output, output_unit, print_level)
156 CALL mulliken(qs_env, orthonormal_basis, matrix_h, &
157 should_output, output_unit, print_level)
159 CALL mulliken_charges(qs_env, orthonormal_basis, matrix_h, matrix_w, &
160 should_output, output_unit, print_level)
162 cpabort(
"Invalid DFT+U method requested")
166 ignore_should_output=should_output)
168 CALL timestop(handle)
201 SUBROUTINE lowdin(qs_env, matrix_h, matrix_w, should_output, output_unit, &
205 TYPE(dbcsr_p_type),
DIMENSION(:),
OPTIONAL, &
206 POINTER :: matrix_h, matrix_w
207 LOGICAL,
INTENT(IN) :: should_output
208 INTEGER,
INTENT(IN) :: output_unit, print_level
210 CHARACTER(LEN=*),
PARAMETER :: routinen =
'lowdin'
212 CHARACTER(LEN=10) :: spin_info
213 CHARACTER(LEN=6),
ALLOCATABLE,
DIMENSION(:) :: symbol
214 CHARACTER(LEN=default_string_length) :: atomic_kind_name
215 INTEGER :: atom_a, handle, i, i0, iatom, ikind, iorb, isb, iset, isgf, ishell, ispin, j, &
216 jsb, jset, jsgf, jshell, lu, m, max_scf, n, natom, natom_of_kind, nkind, norb, nsb, &
217 nsbsize, nset, nsgf, nsgf_kind, nspin
218 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_sgf_atom
219 INTEGER,
DIMENSION(1) :: iloc
220 INTEGER,
DIMENSION(:),
POINTER :: atom_list, nshell, orbitals
221 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf, l, last_sgf
222 LOGICAL :: debug, dft_plus_u_atom, &
223 fm_work1_local_alloc, &
224 fm_work2_local_alloc, found, &
226 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: orb_occ
227 REAL(kind=
dp) :: eps_scf, eps_u_ramping, fspin, occ, trq, &
228 trq2, u_minus_j, u_minus_j_target, &
230 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: q_eigval
231 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: q_eigvec, q_matrix, q_work
232 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: q_block, v_block
236 TYPE(
cp_fm_type),
POINTER :: fm_s_half, fm_work1, fm_work2
237 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_p, matrix_s
238 TYPE(dbcsr_type),
POINTER :: sm_h, sm_p, sm_q, sm_s, sm_v, sm_w
244 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
249 CALL timeset(routinen, handle)
254 NULLIFY (atomic_kind_set)
255 NULLIFY (qs_kind_set)
256 NULLIFY (dft_control)
268 NULLIFY (orb_basis_set)
270 NULLIFY (particle_set)
289 atomic_kind_set=atomic_kind_set, &
290 qs_kind_set=qs_kind_set, &
291 dft_control=dft_control, &
294 particle_set=particle_set, &
301 cpassert(
ASSOCIATED(atomic_kind_set))
302 cpassert(
ASSOCIATED(dft_control))
303 cpassert(
ASSOCIATED(energy))
304 cpassert(
ASSOCIATED(matrix_s))
305 cpassert(
ASSOCIATED(particle_set))
306 cpassert(
ASSOCIATED(rho))
308 sm_s => matrix_s(1)%matrix
311 energy%dft_plus_u = 0.0_dp
313 nspin = dft_control%nspins
327 nkind =
SIZE(atomic_kind_set)
329 ALLOCATE (first_sgf_atom(natom))
330 first_sgf_atom(:) = 0
333 first_sgf=first_sgf_atom)
335 IF (
PRESENT(matrix_h) .OR.
PRESENT(matrix_w))
THEN
336 just_energy = .false.
343 fm_s_half => scf_env%s_half
344 cpassert(
ASSOCIATED(fm_s_half))
349 fm_work1_local_alloc = .false.
350 fm_work2_local_alloc = .false.
352 IF (
ASSOCIATED(scf_env%scf_work1))
THEN
353 IF (
ASSOCIATED(scf_env%scf_work1(1)%matrix_struct))
THEN
354 fm_work1 => scf_env%scf_work1(1)
358 fm_work2 => scf_env%scf_work2
360 IF ((.NOT.
ASSOCIATED(fm_work1)) .OR. &
361 (.NOT.
ASSOCIATED(fm_work2)))
THEN
367 IF (.NOT.
ASSOCIATED(fm_work1))
THEN
370 matrix_struct=fmstruct, &
371 name=
"FULL WORK MATRIX 1")
372 fm_work1_local_alloc = .true.
374 IF (.NOT.
ASSOCIATED(fm_work2))
THEN
377 matrix_struct=fmstruct, &
378 name=
"FULL WORK MATRIX 2")
379 fm_work2_local_alloc = .true.
387 CALL dbcsr_get_block_diag(sm_s, sm_q)
390 CALL dbcsr_get_block_diag(sm_s, sm_v)
396 IF (
PRESENT(matrix_h))
THEN
398 sm_h => matrix_h(ispin)%matrix
403 IF (
PRESENT(matrix_w))
THEN
405 sm_w => matrix_w(ispin)%matrix
410 sm_p => matrix_p(ispin)%matrix
412 CALL dbcsr_set(sm_q, 0.0_dp)
413 CALL dbcsr_set(sm_v, 0.0_dp)
424 matrix_a=fm_s_half, &
430 output_unit=output_unit)
432 output_unit=output_unit)
434 output_unit=output_unit)
457 atom_list=atom_list, &
458 name=atomic_kind_name, &
462 dft_plus_u_atom=dft_plus_u_atom, &
463 l_of_dft_plus_u=lu, &
465 basis_set=orb_basis_set, &
466 u_minus_j=u_minus_j, &
467 u_minus_j_target=u_minus_j_target, &
468 u_ramping=u_ramping, &
469 eps_u_ramping=eps_u_ramping, &
477 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
478 IF (.NOT. dft_plus_u_atom) cycle
483 IF ((ispin == 1) .AND. (u_ramping > 0.0_dp))
THEN
484 IF (qs_env%scf_env%iter_delta <= eps_u_ramping)
THEN
485 u_minus_j = min(u_minus_j + u_ramping, u_minus_j_target)
486 CALL set_qs_kind(qs_kind_set(ikind), u_minus_j=u_minus_j)
488 IF (should_output .AND. (output_unit > 0))
THEN
489 WRITE (unit=output_unit, fmt=
"(T3,A,3X,A,F0.3,A)") &
490 "Kind name: "//trim(adjustl(atomic_kind_name)), &
491 "U(eff) = ", u_minus_j*
evolt,
" eV"
495 IF (u_minus_j == 0.0_dp) cycle
500 first_sgf=first_sgf, &
510 DO ishell = 1, nshell(iset)
511 IF (l(ishell, iset) == lu) nsb = nsb + 1
518 ALLOCATE (q_matrix(n, n))
519 q_matrix(:, :) = 0.0_dp
524 IF (output_unit > 0)
THEN
525 ALLOCATE (symbol(nsbsize))
530 WRITE (unit=spin_info, fmt=
"(A8,I2)")
" of spin", ispin
534 WRITE (unit=output_unit, fmt=
"(/,T3,A,I0,A,/,/,T5,A,10(2X,A6))") &
535 "DFT+U occupations"//trim(spin_info)//
" for the atoms of atomic kind ", ikind, &
536 ": "//trim(atomic_kind_name), &
537 "Atom Shell ", (adjustr(symbol(i)), i=1, nsbsize),
" Trace"
544 DO iatom = 1, natom_of_kind
546 atom_a = atom_list(iatom)
548 q_matrix(:, :) = 0.0_dp
552 CALL dbcsr_get_block_p(matrix=sm_q, &
558 IF (
ASSOCIATED(q_block))
THEN
564 DO ishell = 1, nshell(iset)
565 IF (l(ishell, iset) /= lu) cycle
566 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
570 DO jshell = 1, nshell(jset)
571 IF (l(jshell, jset) /= lu) cycle
572 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
574 IF (isgf == jsgf) q_matrix(i, j) = q_block(isgf, jsgf)
584 IF (
ASSOCIATED(orbitals))
THEN
585 IF ((qs_env%scf_env%iter_delta >= eps_scf) .OR. &
586 ((qs_env%scf_env%outer_scf%iter_count == 0) .AND. &
587 (qs_env%scf_env%iter_count <= max_scf)))
THEN
588 ALLOCATE (orb_occ(nsbsize))
589 ALLOCATE (q_eigval(n))
591 ALLOCATE (q_eigvec(n, n))
592 q_eigvec(:, :) = 0.0_dp
593 norb =
SIZE(orbitals)
594 CALL jacobi(q_matrix, q_eigval, q_eigvec)
595 q_matrix(:, :) = 0.0_dp
598 DO i = (isb - 1)*nsbsize + 1, isb*nsbsize
599 trq = trq + q_eigval(i)
602 occ = trq/real(norb, kind=
dp)
607 iloc = maxloc(q_eigvec(:, isb*nsbsize))
608 jsb = int((iloc(1) - 1)/nsbsize) + 1
610 i0 = (jsb - 1)*nsbsize + 1
612 DO j = i0, jsb*nsbsize
616 IF (.NOT. orb_occ(lu + m + 1))
THEN
618 orb_occ(lu + m + 1) = .true.
622 iorb = i0 + lu + orbitals(i)
623 orb_occ(lu + orbitals(i) + 1) = .true.
625 cpassert(iorb /= -1000)
626 iloc = maxloc(q_eigvec(iorb, :))
627 q_eigval(iloc(1)) = min(occ, trq)
628 q_matrix(:, iloc(1)) = q_eigval(iloc(1))*q_eigvec(:, iloc(1))
629 trq = trq - q_eigval(iloc(1))
632 q_matrix(:, :) = matmul(q_matrix, transpose(q_eigvec))
634 DEALLOCATE (q_eigval)
635 DEALLOCATE (q_eigvec)
643 trq = trq + q_matrix(i, i)
645 trq2 = trq2 + q_matrix(i, j)*q_matrix(j, i)
650 trq2 = fspin*fspin*trq2
654 energy%dft_plus_u = energy%dft_plus_u + 0.5_dp*u_minus_j*(trq - trq2)/fspin
658 IF (.NOT. just_energy)
THEN
660 CALL dbcsr_get_block_p(matrix=sm_v, &
665 cpassert(
ASSOCIATED(v_block))
669 DO ishell = 1, nshell(iset)
670 IF (l(ishell, iset) /= lu) cycle
671 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
675 DO jshell = 1, nshell(jset)
676 IF (l(jshell, jset) /= lu) cycle
677 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
679 IF (isgf == jsgf)
THEN
680 v_block(isgf, isgf) = u_minus_j*(0.5_dp - fspin*q_matrix(i, i))
682 cpassert(abs(q_matrix(j, i)) < 1.0e-14_dp)
683 v_block(isgf, jsgf) = -u_minus_j*fspin*q_matrix(j, i)
699 CALL para_env%sum(q_matrix)
700 IF (output_unit > 0)
THEN
701 ALLOCATE (q_work(nsb, nsbsize))
702 q_work(:, :) = 0.0_dp
705 DO i = (isb - 1)*nsbsize + 1, isb*nsbsize
707 q_work(isb, j) = q_matrix(i, i)
711 WRITE (unit=output_unit, fmt=
"(T3,I6,2X,I6,2X,10F8.3)") &
712 atom_a, isb, q_work(isb, :), sum(q_work(isb, :))
714 WRITE (unit=output_unit, fmt=
"(T12,A,2X,10F8.3)") &
715 "Total", (sum(q_work(:, i)), i=1, nsbsize), sum(q_work)
716 WRITE (unit=output_unit, fmt=
"(A)")
""
720 WRITE (unit=output_unit, fmt=
"(T9,70I10)") (i, i=1, n)
722 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_matrix(i, :)
725 ALLOCATE (q_eigval(n))
727 ALLOCATE (q_eigvec(n, n))
728 q_eigvec(:, :) = 0.0_dp
729 CALL jacobi(q_matrix, q_eigval, q_eigvec)
730 WRITE (unit=output_unit, fmt=
"(/,T9,70I10)") (i, i=1, n)
731 WRITE (unit=output_unit, fmt=
"(T9,71F10.6)") (q_eigval(i), i=1, n), &
734 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_eigvec(i, :)
736 DEALLOCATE (q_eigval)
737 DEALLOCATE (q_eigvec)
742 ALLOCATE (q_work(nsgf_kind, nsgf_kind))
743 q_work(:, :) = 0.0_dp
744 IF (
ASSOCIATED(q_block)) q_work(:, :) = q_block(:, :)
745 CALL para_env%sum(q_work)
746 IF (output_unit > 0)
THEN
747 norb =
SIZE(q_work, 1)
748 WRITE (unit=output_unit, fmt=
"(/,T9,200I10)") (i, i=1, norb)
750 WRITE (unit=output_unit, fmt=
"(T3,I6,200F10.6)") i, q_work(i, :)
752 ALLOCATE (q_eigval(norb))
754 ALLOCATE (q_eigvec(norb, norb))
755 q_eigvec(:, :) = 0.0_dp
756 CALL jacobi(q_work, q_eigval, q_eigvec)
757 WRITE (unit=output_unit, fmt=
"(/,T9,200I10)") (i, i=1, norb)
758 WRITE (unit=output_unit, fmt=
"(T9,201F10.6)") (q_eigval(i), i=1, norb), &
759 sum(q_eigval(1:norb))
761 WRITE (unit=output_unit, fmt=
"(T3,I6,200F10.6)") i, q_eigvec(i, :)
763 DEALLOCATE (q_eigval)
764 DEALLOCATE (q_eigvec)
772 IF (
ALLOCATED(q_matrix))
THEN
773 DEALLOCATE (q_matrix)
779 IF (
ASSOCIATED(sm_h))
THEN
790 IF (
ASSOCIATED(sm_w))
THEN
792 cpwarn(
"This is an experimental version of the forces calculation for the DFT+U method LOWDIN")
793 IF (virial%pv_calculate)
THEN
794 cpabort(
"The stress tensor is not implemented for the DFT+U method LOWDIN")
803 CALL para_env%sum(energy%dft_plus_u)
805 IF (energy%dft_plus_u < 0.0_dp) &
806 CALL cp_warn(__location__, &
807 "DFT+U energy contibution is negative possibly due "// &
808 "to unphysical Lowdin charges!")
813 IF (fm_work1_local_alloc)
THEN
815 DEALLOCATE (fm_work1)
817 IF (fm_work2_local_alloc)
THEN
819 DEALLOCATE (fm_work2)
824 CALL dbcsr_deallocate_matrix(sm_q)
825 CALL dbcsr_deallocate_matrix(sm_v)
827 CALL timestop(handle)
829 END SUBROUTINE lowdin
861 SUBROUTINE mulliken(qs_env, orthonormal_basis, matrix_h, should_output, &
862 output_unit, print_level)
865 LOGICAL,
INTENT(IN) :: orthonormal_basis
866 TYPE(dbcsr_p_type),
DIMENSION(:),
OPTIONAL, &
868 LOGICAL,
INTENT(IN) :: should_output
869 INTEGER,
INTENT(IN) :: output_unit, print_level
871 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mulliken'
873 CHARACTER(LEN=10) :: spin_info
874 CHARACTER(LEN=6),
ALLOCATABLE,
DIMENSION(:) :: symbol
875 CHARACTER(LEN=default_string_length) :: atomic_kind_name
876 INTEGER :: atom_a, handle, i, i0, iatom, ikind, iorb, isb, iset, isgf, ishell, ispin, j, &
877 jsb, jset, jsgf, jshell, lu, m, max_scf, n, natom, natom_of_kind, nkind, norb, nsb, &
878 nsbsize, nset, nsgf_kind, nspin
879 INTEGER,
DIMENSION(1) :: iloc
880 INTEGER,
DIMENSION(:),
POINTER :: atom_list, nshell, orbitals
881 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf, l, last_sgf
882 LOGICAL :: debug, dft_plus_u_atom, found, &
883 just_energy, occupation_enforced, smear
884 LOGICAL,
ALLOCATABLE,
DIMENSION(:) :: is_plus_u_kind, orb_occ
885 REAL(kind=
dp) :: eps_scf, eps_u_ramping, fspin, occ, trq, &
886 trq2, u_minus_j, u_minus_j_target, &
888 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: q_eigval
889 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: q_eigvec, q_matrix, q_work
890 REAL(kind=
dp),
DIMENSION(:),
POINTER :: nelec
891 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: h_block, p_block, q_block, s_block, &
895 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_p, matrix_s
896 TYPE(dbcsr_type),
POINTER :: sm_h, sm_p, sm_q, sm_s, sm_v
902 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
905 CALL timeset(routinen, handle)
910 NULLIFY (atomic_kind_set)
911 NULLIFY (qs_kind_set)
912 NULLIFY (dft_control)
922 NULLIFY (orb_basis_set)
924 NULLIFY (particle_set)
940 occupation_enforced = .false.
943 atomic_kind_set=atomic_kind_set, &
944 qs_kind_set=qs_kind_set, &
945 dft_control=dft_control, &
947 particle_set=particle_set, &
951 cpassert(
ASSOCIATED(atomic_kind_set))
952 cpassert(
ASSOCIATED(dft_control))
953 cpassert(
ASSOCIATED(energy))
954 cpassert(
ASSOCIATED(particle_set))
955 cpassert(
ASSOCIATED(rho))
957 IF (orthonormal_basis)
THEN
963 cpassert(
ASSOCIATED(matrix_s))
964 sm_s => matrix_s(1)%matrix
971 energy%dft_plus_u = 0.0_dp
973 nspin = dft_control%nspins
987 nkind =
SIZE(atomic_kind_set)
989 ALLOCATE (is_plus_u_kind(nkind))
990 is_plus_u_kind(:) = .false.
992 IF (
PRESENT(matrix_h))
THEN
993 just_energy = .false.
1002 IF (
PRESENT(matrix_h))
THEN
1004 sm_h => matrix_h(ispin)%matrix
1011 sm_p => matrix_p(ispin)%matrix
1013 IF (.NOT.
ASSOCIATED(sm_q))
THEN
1015 CALL dbcsr_get_block_diag(sm_p, sm_q)
1017 CALL dbcsr_set(sm_q, 0.0_dp)
1019 IF (.NOT.
ASSOCIATED(sm_v))
THEN
1021 CALL dbcsr_get_block_diag(sm_p, sm_v)
1023 CALL dbcsr_set(sm_v, 0.0_dp)
1027 CALL dbcsr_get_block_p(matrix=sm_p, &
1033 IF (.NOT.
ASSOCIATED(p_block)) cycle
1035 CALL dbcsr_get_block_p(matrix=sm_q, &
1040 cpassert(
ASSOCIATED(q_block))
1042 IF (orthonormal_basis)
THEN
1044 DO isgf = 1,
SIZE(q_block, 1)
1045 q_block(isgf, isgf) = p_block(isgf, isgf)
1048 CALL dbcsr_get_block_p(matrix=sm_s, &
1053 cpassert(
ASSOCIATED(s_block))
1055 DO jsgf = 1,
SIZE(p_block, 2)
1056 DO isgf = 1,
SIZE(p_block, 1)
1057 q_block(isgf, jsgf) = p_block(isgf, jsgf)*s_block(isgf, jsgf)
1078 atom_list=atom_list, &
1079 name=atomic_kind_name, &
1080 natom=natom_of_kind)
1083 dft_plus_u_atom=dft_plus_u_atom, &
1084 l_of_dft_plus_u=lu, &
1086 basis_set=orb_basis_set, &
1087 u_minus_j=u_minus_j, &
1088 u_minus_j_target=u_minus_j_target, &
1089 u_ramping=u_ramping, &
1090 eps_u_ramping=eps_u_ramping, &
1092 orbitals=orbitals, &
1099 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
1100 IF (.NOT. dft_plus_u_atom) cycle
1105 IF ((ispin == 1) .AND. (u_ramping > 0.0_dp))
THEN
1106 IF (qs_env%scf_env%iter_delta <= eps_u_ramping)
THEN
1107 u_minus_j = min(u_minus_j + u_ramping, u_minus_j_target)
1108 CALL set_qs_kind(qs_kind_set(ikind), u_minus_j=u_minus_j)
1110 IF (should_output .AND. (output_unit > 0))
THEN
1111 WRITE (unit=output_unit, fmt=
"(T3,A,3X,A,F0.3,A)") &
1112 "Kind name: "//trim(adjustl(atomic_kind_name)), &
1113 "U(eff) = ", u_minus_j*
evolt,
" eV"
1117 IF (u_minus_j == 0.0_dp) cycle
1119 is_plus_u_kind(ikind) = .true.
1124 first_sgf=first_sgf, &
1126 last_sgf=last_sgf, &
1134 DO ishell = 1, nshell(iset)
1135 IF (l(ishell, iset) == lu) nsb = nsb + 1
1139 nsbsize = (2*lu + 1)
1142 ALLOCATE (q_matrix(n, n))
1143 q_matrix(:, :) = 0.0_dp
1148 IF (output_unit > 0)
THEN
1149 ALLOCATE (symbol(nsbsize))
1154 WRITE (unit=spin_info, fmt=
"(A8,I2)")
" of spin", ispin
1158 WRITE (unit=output_unit, fmt=
"(/,T3,A,I0,A,/,/,T5,A,10(2X,A6))") &
1159 "DFT+U occupations"//trim(spin_info)//
" for the atoms of atomic kind ", ikind, &
1160 ": "//trim(atomic_kind_name), &
1161 "Atom Shell ", (adjustr(symbol(i)), i=1, nsbsize),
" Trace"
1168 DO iatom = 1, natom_of_kind
1170 atom_a = atom_list(iatom)
1172 q_matrix(:, :) = 0.0_dp
1176 CALL dbcsr_get_block_p(matrix=sm_q, &
1184 IF (
ASSOCIATED(q_block))
THEN
1188 DO ishell = 1, nshell(iset)
1189 IF (l(ishell, iset) /= lu) cycle
1190 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
1194 DO jshell = 1, nshell(jset)
1195 IF (l(jshell, jset) /= lu) cycle
1196 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
1198 q_matrix(i, j) = q_block(isgf, jsgf)
1208 IF (
ASSOCIATED(orbitals))
THEN
1209 IF ((qs_env%scf_env%iter_delta >= eps_scf) .OR. &
1210 ((qs_env%scf_env%outer_scf%iter_count == 0) .AND. &
1211 (qs_env%scf_env%iter_count <= max_scf)))
THEN
1212 ALLOCATE (orb_occ(nsbsize))
1213 ALLOCATE (q_eigval(n))
1214 q_eigval(:) = 0.0_dp
1215 ALLOCATE (q_eigvec(n, n))
1216 q_eigvec(:, :) = 0.0_dp
1217 norb =
SIZE(orbitals)
1218 CALL jacobi(q_matrix, q_eigval, q_eigvec)
1219 q_matrix(:, :) = 0.0_dp
1220 IF (nelec(ispin) >= 0.5_dp)
THEN
1221 trq = nelec(ispin)/sum(q_eigval(1:n))
1222 q_eigval(1:n) = trq*q_eigval(1:n)
1226 DO i = (isb - 1)*nsbsize + 1, isb*nsbsize
1227 trq = trq + q_eigval(i)
1230 occ = trq/real(norb, kind=
dp)
1234 orb_occ(:) = .false.
1235 iloc = maxloc(q_eigvec(:, isb*nsbsize))
1236 jsb = int((iloc(1) - 1)/nsbsize) + 1
1238 i0 = (jsb - 1)*nsbsize + 1
1240 DO j = i0, jsb*nsbsize
1244 IF (.NOT. orb_occ(lu + m + 1))
THEN
1246 orb_occ(lu + m + 1) = .true.
1250 iorb = i0 + lu + orbitals(i)
1251 orb_occ(lu + orbitals(i) + 1) = .true.
1253 cpassert(iorb /= -1000)
1254 iloc = maxloc(q_eigvec(iorb, :))
1255 q_eigval(iloc(1)) = min(occ, trq)
1256 q_matrix(:, iloc(1)) = q_eigval(iloc(1))*q_eigvec(:, iloc(1))
1257 trq = trq - q_eigval(iloc(1))
1260 q_matrix(:, :) = matmul(q_matrix, transpose(q_eigvec))
1261 DEALLOCATE (orb_occ)
1262 DEALLOCATE (q_eigval)
1263 DEALLOCATE (q_eigvec)
1264 occupation_enforced = .true.
1272 trq = trq + q_matrix(i, i)
1274 trq2 = trq2 + q_matrix(i, j)*q_matrix(j, i)
1279 trq2 = fspin*fspin*trq2
1283 energy%dft_plus_u = energy%dft_plus_u + 0.5_dp*u_minus_j*(trq - trq2)/fspin
1287 IF (.NOT. just_energy)
THEN
1289 CALL dbcsr_get_block_p(matrix=sm_v, &
1294 cpassert(
ASSOCIATED(v_block))
1298 DO ishell = 1, nshell(iset)
1299 IF (l(ishell, iset) /= lu) cycle
1300 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
1304 DO jshell = 1, nshell(jset)
1305 IF (l(jshell, jset) /= lu) cycle
1306 DO jsgf = first_sgf(jshell, jset), last_sgf(jshell, jset)
1308 IF (isgf == jsgf)
THEN
1309 v_block(isgf, isgf) = u_minus_j*(0.5_dp - fspin*q_matrix(i, i))
1311 v_block(isgf, jsgf) = -u_minus_j*fspin*q_matrix(j, i)
1327 CALL para_env%sum(q_matrix)
1328 IF (output_unit > 0)
THEN
1329 ALLOCATE (q_work(nsb, nsbsize))
1330 q_work(:, :) = 0.0_dp
1333 DO i = (isb - 1)*nsbsize + 1, isb*nsbsize
1335 q_work(isb, j) = q_matrix(i, i)
1339 WRITE (unit=output_unit, fmt=
"(T3,I6,2X,I6,2X,10F8.3)") &
1340 atom_a, isb, q_work(isb, :), sum(q_work(isb, :))
1342 WRITE (unit=output_unit, fmt=
"(T12,A,2X,10F8.3)") &
1343 "Total", (sum(q_work(:, i)), i=1, nsbsize), sum(q_work)
1344 WRITE (unit=output_unit, fmt=
"(A)")
""
1348 WRITE (unit=output_unit, fmt=
"(T9,70I10)") (i, i=1, n)
1350 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_matrix(i, :)
1353 ALLOCATE (q_eigval(n))
1354 q_eigval(:) = 0.0_dp
1355 ALLOCATE (q_eigvec(n, n))
1356 q_eigvec(:, :) = 0.0_dp
1357 CALL jacobi(q_matrix, q_eigval, q_eigvec)
1358 WRITE (unit=output_unit, fmt=
"(/,T9,70I10)") (i, i=1, n)
1359 WRITE (unit=output_unit, fmt=
"(T9,71F10.6)") (q_eigval(i), i=1, n), &
1362 WRITE (unit=output_unit, fmt=
"(T3,I6,70F10.6)") i, q_eigvec(i, :)
1364 DEALLOCATE (q_eigval)
1365 DEALLOCATE (q_eigvec)
1370 ALLOCATE (q_work(nsgf_kind, nsgf_kind))
1371 q_work(:, :) = 0.0_dp
1372 IF (
ASSOCIATED(q_block)) q_work(:, :) = q_block(:, :)
1373 CALL para_env%sum(q_work)
1374 IF (output_unit > 0)
THEN
1375 norb =
SIZE(q_work, 1)
1376 WRITE (unit=output_unit, fmt=
"(/,T9,200I10)") (i, i=1, norb)
1378 WRITE (unit=output_unit, fmt=
"(T3,I6,200F10.6)") i, q_work(i, :)
1380 ALLOCATE (q_eigval(norb))
1381 q_eigval(:) = 0.0_dp
1382 ALLOCATE (q_eigvec(norb, norb))
1383 q_eigvec(:, :) = 0.0_dp
1384 CALL jacobi(q_work, q_eigval, q_eigvec)
1385 WRITE (unit=output_unit, fmt=
"(/,T9,200I10)") (i, i=1, norb)
1386 WRITE (unit=output_unit, fmt=
"(T9,201F10.6)") (q_eigval(i), i=1, norb), &
1387 sum(q_eigval(1:norb))
1389 WRITE (unit=output_unit, fmt=
"(T3,I6,200F10.6)") i, q_eigvec(i, :)
1391 DEALLOCATE (q_eigval)
1392 DEALLOCATE (q_eigvec)
1400 IF (
ALLOCATED(q_matrix))
THEN
1401 DEALLOCATE (q_matrix)
1408 IF (
ASSOCIATED(sm_h))
THEN
1412 IF (.NOT. is_plus_u_kind(ikind)) cycle
1414 kind_a => atomic_kind_set(ikind)
1417 atom_list=atom_list, &
1418 natom=natom_of_kind)
1420 DO iatom = 1, natom_of_kind
1422 atom_a = atom_list(iatom)
1424 CALL dbcsr_get_block_p(matrix=sm_h, &
1430 IF (.NOT.
ASSOCIATED(h_block)) cycle
1432 CALL dbcsr_get_block_p(matrix=sm_v, &
1437 cpassert(
ASSOCIATED(v_block))
1439 IF (orthonormal_basis)
THEN
1440 DO isgf = 1,
SIZE(h_block, 1)
1441 h_block(isgf, isgf) = h_block(isgf, isgf) + v_block(isgf, isgf)
1444 CALL dbcsr_get_block_p(matrix=sm_s, &
1449 cpassert(
ASSOCIATED(s_block))
1450 DO jsgf = 1,
SIZE(h_block, 2)
1451 DO isgf = 1,
SIZE(h_block, 1)
1452 h_block(isgf, jsgf) = h_block(isgf, jsgf) + v_block(isgf, jsgf)*s_block(isgf, jsgf)
1467 CALL para_env%sum(energy%dft_plus_u)
1469 IF (energy%dft_plus_u < 0.0_dp)
THEN
1470 IF (.NOT. occupation_enforced)
THEN
1471 CALL cp_warn(__location__, &
1472 "DFT+U energy contibution is negative possibly due "// &
1473 "to unphysical Mulliken charges!")
1477 CALL dbcsr_deallocate_matrix(sm_q)
1478 CALL dbcsr_deallocate_matrix(sm_v)
1480 CALL timestop(handle)
1520 SUBROUTINE mulliken_charges(qs_env, orthonormal_basis, matrix_h, matrix_w, &
1521 should_output, output_unit, print_level)
1524 LOGICAL,
INTENT(IN) :: orthonormal_basis
1525 TYPE(dbcsr_p_type),
DIMENSION(:),
OPTIONAL, &
1526 POINTER :: matrix_h, matrix_w
1527 LOGICAL,
INTENT(IN) :: should_output
1528 INTEGER,
INTENT(IN) :: output_unit, print_level
1530 CHARACTER(LEN=*),
PARAMETER :: routinen =
'mulliken_charges'
1532 CHARACTER(LEN=10) :: spin_info
1533 CHARACTER(LEN=6),
ALLOCATABLE,
DIMENSION(:) :: symbol
1534 CHARACTER(LEN=default_string_length) :: atomic_kind_name
1535 INTEGER :: atom_a, blk, handle, i, iatom, ikind, isb, iset, isgf, ishell, ispin, jatom, &
1536 jsgf, lu, m, natom, natom_of_kind, nkind, nsb, nset, nsgf, nspin, sgf
1537 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: first_sgf_atom
1538 INTEGER,
DIMENSION(:),
POINTER :: atom_list, nshell
1539 INTEGER,
DIMENSION(:, :),
POINTER :: first_sgf, l, last_sgf
1540 LOGICAL :: dft_plus_u_atom, found, just_energy
1541 REAL(kind=
dp) :: eps_u_ramping, fspin, q, u_minus_j, &
1542 u_minus_j_target, u_ramping, v
1543 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: dedq, trps
1544 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: q_ii
1545 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: h_block, p_block, s_block, w_block
1547 TYPE(dbcsr_iterator_type) :: iter
1548 TYPE(dbcsr_p_type),
DIMENSION(:),
POINTER :: matrix_p, matrix_s
1549 TYPE(dbcsr_type),
POINTER :: sm_h, sm_p, sm_s, sm_w
1555 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1558 CALL timeset(routinen, handle)
1561 NULLIFY (atomic_kind_set)
1562 NULLIFY (qs_kind_set)
1563 NULLIFY (dft_control)
1572 NULLIFY (orb_basis_set)
1574 NULLIFY (particle_set)
1584 atomic_kind_set=atomic_kind_set, &
1585 qs_kind_set=qs_kind_set, &
1586 dft_control=dft_control, &
1588 particle_set=particle_set, &
1592 cpassert(
ASSOCIATED(atomic_kind_set))
1593 cpassert(
ASSOCIATED(dft_control))
1594 cpassert(
ASSOCIATED(energy))
1595 cpassert(
ASSOCIATED(particle_set))
1596 cpassert(
ASSOCIATED(rho))
1598 IF (orthonormal_basis)
THEN
1604 cpassert(
ASSOCIATED(matrix_s))
1605 sm_s => matrix_s(1)%matrix
1612 energy%dft_plus_u = 0.0_dp
1614 nspin = dft_control%nspins
1616 IF (nspin == 2)
THEN
1628 nkind =
SIZE(atomic_kind_set)
1630 ALLOCATE (first_sgf_atom(natom))
1631 first_sgf_atom(:) = 0
1634 first_sgf=first_sgf_atom)
1636 ALLOCATE (trps(nsgf))
1639 IF (
PRESENT(matrix_h) .OR.
PRESENT(matrix_w))
THEN
1640 ALLOCATE (dedq(nsgf))
1641 just_energy = .false.
1643 just_energy = .true.
1650 IF (
PRESENT(matrix_h))
THEN
1652 sm_h => matrix_h(ispin)%matrix
1658 IF (
PRESENT(matrix_w))
THEN
1660 sm_w => matrix_w(ispin)%matrix
1666 sm_p => matrix_p(ispin)%matrix
1672 CALL dbcsr_iterator_start(iter, sm_p)
1674 DO WHILE (dbcsr_iterator_blocks_left(iter))
1676 CALL dbcsr_iterator_next_block(iter, iatom, jatom, p_block, blk)
1678 IF (orthonormal_basis)
THEN
1680 IF (iatom /= jatom) cycle
1682 IF (
ASSOCIATED(p_block))
THEN
1683 sgf = first_sgf_atom(iatom)
1684 DO isgf = 1,
SIZE(p_block, 1)
1685 trps(sgf) = trps(sgf) + p_block(isgf, isgf)
1692 CALL dbcsr_get_block_p(matrix=sm_s, &
1697 cpassert(
ASSOCIATED(s_block))
1699 sgf = first_sgf_atom(jatom)
1700 DO jsgf = 1,
SIZE(p_block, 2)
1701 DO isgf = 1,
SIZE(p_block, 1)
1702 trps(sgf) = trps(sgf) + p_block(isgf, jsgf)*s_block(isgf, jsgf)
1707 IF (iatom /= jatom)
THEN
1708 sgf = first_sgf_atom(iatom)
1709 DO isgf = 1,
SIZE(p_block, 1)
1710 DO jsgf = 1,
SIZE(p_block, 2)
1711 trps(sgf) = trps(sgf) + p_block(isgf, jsgf)*s_block(isgf, jsgf)
1721 CALL dbcsr_iterator_stop(iter)
1723 CALL para_env%sum(trps)
1740 atom_list=atom_list, &
1741 name=atomic_kind_name, &
1742 natom=natom_of_kind)
1745 dft_plus_u_atom=dft_plus_u_atom, &
1746 l_of_dft_plus_u=lu, &
1747 basis_set=orb_basis_set, &
1748 u_minus_j=u_minus_j, &
1749 u_minus_j_target=u_minus_j_target, &
1750 u_ramping=u_ramping, &
1751 eps_u_ramping=eps_u_ramping)
1755 IF (.NOT.
ASSOCIATED(orb_basis_set)) cycle
1756 IF (.NOT. dft_plus_u_atom) cycle
1761 IF ((ispin == 1) .AND. (u_ramping > 0.0_dp))
THEN
1762 IF (qs_env%scf_env%iter_delta <= eps_u_ramping)
THEN
1763 u_minus_j = min(u_minus_j + u_ramping, u_minus_j_target)
1764 CALL set_qs_kind(qs_kind_set(ikind), u_minus_j=u_minus_j)
1766 IF (should_output .AND. (output_unit > 0))
THEN
1767 WRITE (unit=output_unit, fmt=
"(T3,A,3X,A,F0.3,A)") &
1768 "Kind name: "//trim(adjustl(atomic_kind_name)), &
1769 "U(eff) = ", u_minus_j*
evolt,
" eV"
1773 IF (u_minus_j == 0.0_dp) cycle
1778 first_sgf=first_sgf, &
1780 last_sgf=last_sgf, &
1788 DO ishell = 1, nshell(iset)
1789 IF (l(ishell, iset) == lu) nsb = nsb + 1
1793 ALLOCATE (q_ii(nsb, 2*lu + 1))
1798 IF (output_unit > 0)
THEN
1799 ALLOCATE (symbol(2*lu + 1))
1804 WRITE (unit=spin_info, fmt=
"(A8,I2)")
" of spin", ispin
1808 WRITE (unit=output_unit, fmt=
"(/,T3,A,I0,A,/,/,T5,A,10(2X,A6))") &
1809 "DFT+U occupations"//trim(spin_info)//
" for the atoms of atomic kind ", ikind, &
1810 ": "//trim(atomic_kind_name), &
1811 "Atom Shell ", (adjustr(symbol(i)), i=1, 2*lu + 1),
" Trace"
1818 DO iatom = 1, natom_of_kind
1820 atom_a = atom_list(iatom)
1826 CALL dbcsr_get_block_p(matrix=sm_p, &
1834 IF (
ASSOCIATED(p_block))
THEN
1836 sgf = first_sgf_atom(atom_a)
1840 DO ishell = 1, nshell(iset)
1841 IF (l(ishell, iset) == lu)
THEN
1844 DO isgf = first_sgf(ishell, iset), last_sgf(ishell, iset)
1848 energy%dft_plus_u = energy%dft_plus_u + &
1849 0.5_dp*u_minus_j*(q - q**2)/fspin
1850 IF (.NOT. just_energy)
THEN
1851 dedq(sgf) = dedq(sgf) + u_minus_j*(0.5_dp - q)
1856 sgf = sgf + last_sgf(ishell, iset) - first_sgf(ishell, iset) + 1
1866 CALL para_env%sum(q_ii)
1867 IF (output_unit > 0)
THEN
1869 WRITE (unit=output_unit, fmt=
"(T3,I6,2X,I6,2X,10F8.3)") &
1870 atom_a, isb, q_ii(isb, :), sum(q_ii(isb, :))
1872 WRITE (unit=output_unit, fmt=
"(T12,A,2X,10F8.3)") &
1873 "Total", (sum(q_ii(:, i)), i=1, 2*lu + 1), sum(q_ii)
1874 WRITE (unit=output_unit, fmt=
"(A)")
""
1880 IF (
ALLOCATED(q_ii))
THEN
1886 IF (.NOT. just_energy)
THEN
1887 CALL para_env%sum(dedq)
1892 IF (
ASSOCIATED(sm_h))
THEN
1894 CALL dbcsr_iterator_start(iter, sm_h)
1896 DO WHILE (dbcsr_iterator_blocks_left(iter))
1898 CALL dbcsr_iterator_next_block(iter, iatom, jatom, h_block, blk)
1900 IF (orthonormal_basis)
THEN
1902 IF (iatom /= jatom) cycle
1904 IF (
ASSOCIATED(h_block))
THEN
1905 sgf = first_sgf_atom(iatom)
1906 DO isgf = 1,
SIZE(h_block, 1)
1907 h_block(isgf, isgf) = h_block(isgf, isgf) + dedq(sgf)
1916 CALL dbcsr_get_block_p(matrix=sm_s, &
1921 cpassert(
ASSOCIATED(s_block))
1925 sgf = first_sgf_atom(iatom)
1927 DO isgf = 1,
SIZE(h_block, 1)
1928 IF (dedq(sgf) /= 0.0_dp)
THEN
1929 v = 0.5_dp*dedq(sgf)
1930 DO jsgf = 1,
SIZE(h_block, 2)
1931 h_block(isgf, jsgf) = h_block(isgf, jsgf) + v*s_block(isgf, jsgf)
1937 sgf = first_sgf_atom(jatom)
1939 DO jsgf = 1,
SIZE(h_block, 2)
1940 IF (dedq(sgf) /= 0.0_dp)
THEN
1941 v = 0.5_dp*dedq(sgf)
1942 DO isgf = 1,
SIZE(h_block, 1)
1943 h_block(isgf, jsgf) = h_block(isgf, jsgf) + v*s_block(isgf, jsgf)
1953 CALL dbcsr_iterator_stop(iter)
1961 IF (
ASSOCIATED(sm_w) .AND. (.NOT. orthonormal_basis))
THEN
1963 CALL dbcsr_iterator_start(iter, sm_p)
1965 DO WHILE (dbcsr_iterator_blocks_left(iter))
1967 CALL dbcsr_iterator_next_block(iter, iatom, jatom, p_block, blk)
1971 IF (iatom == jatom) cycle
1975 CALL dbcsr_get_block_p(matrix=sm_w, &
1980 cpassert(
ASSOCIATED(w_block))
1984 sgf = first_sgf_atom(iatom)
1986 DO isgf = 1,
SIZE(w_block, 1)
1987 IF (dedq(sgf) /= 0.0_dp)
THEN
1988 v = -0.5_dp*dedq(sgf)
1989 DO jsgf = 1,
SIZE(w_block, 2)
1990 w_block(isgf, jsgf) = w_block(isgf, jsgf) + v*p_block(isgf, jsgf)
1996 sgf = first_sgf_atom(jatom)
1998 DO jsgf = 1,
SIZE(w_block, 2)
1999 IF (dedq(sgf) /= 0.0_dp)
THEN
2000 v = -0.5_dp*dedq(sgf)
2001 DO isgf = 1,
SIZE(w_block, 1)
2002 w_block(isgf, jsgf) = w_block(isgf, jsgf) + v*p_block(isgf, jsgf)
2010 CALL dbcsr_iterator_stop(iter)
2018 CALL para_env%sum(energy%dft_plus_u)
2020 IF (energy%dft_plus_u < 0.0_dp) &
2021 CALL cp_warn(__location__, &
2022 "DFT+U energy contibution is negative possibly due "// &
2023 "to unphysical Mulliken charges!")
2027 IF (
ALLOCATED(first_sgf_atom))
THEN
2028 DEALLOCATE (first_sgf_atom)
2031 IF (
ALLOCATED(trps))
THEN
2035 IF (
ALLOCATED(dedq))
THEN
2039 CALL timestop(handle)
2041 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)
...
collects all references to literature in CP2K as new algorithms / method are included from literature...
integer, save, public dudarev1997
integer, save, public dudarev1998
methods related to the blacs parallel environment
Defines control structures, which contain the parameters and the settings for the DFT-based calculati...
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 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
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
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
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, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, ecoul_1c, rho0_s_rs, rho0_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, rhs)
Get the QUICKSTEP environment.
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, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, 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_r3d_rs_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, floating, name, element_symbol, pao_basis_size, 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)
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.
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
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...
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.