91#include "./base/base_uses.f90"
97 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'kpoint_methods'
120 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_initialize'
122 INTEGER :: handle, i, ic, ik, iounit, ir, ira, is, &
123 j, natom, nkind, nr, ns
124 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atype
126 REAL(kind=
dp) :: wsum
127 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: coord, scoord
131 CALL timeset(routinen, handle)
133 cpassert(
ASSOCIATED(kpoint))
135 SELECT CASE (kpoint%kp_scheme)
140 ALLOCATE (kpoint%xkp(3, 1), kpoint%wkp(1))
141 kpoint%xkp(1:3, 1) = 0.0_dp
142 kpoint%wkp(1) = 1.0_dp
143 ALLOCATE (kpoint%kp_sym(1))
144 NULLIFY (kpoint%kp_sym(1)%kpoint_sym)
146 CASE (
"MONKHORST-PACK",
"MACDONALD")
148 IF (.NOT. kpoint%symmetry)
THEN
151 ALLOCATE (coord(3, natom), scoord(3, natom), atype(natom))
154 coord(1, i) = sin(i*0.12345_dp)
155 coord(2, i) = cos(i*0.23456_dp)
156 coord(3, i) = sin(i*0.34567_dp)
160 natom =
SIZE(particle_set)
161 ALLOCATE (scoord(3, natom), atype(natom))
163 CALL get_atomic_kind(atomic_kind=particle_set(i)%atomic_kind, kind_number=atype(i))
167 IF (kpoint%verbose)
THEN
173 ALLOCATE (kpoint%atype(natom))
176 CALL crys_sym_gen(crys_sym, scoord, atype, cell%hmat, delta=kpoint%eps_geo, iounit=iounit)
177 CALL kpoint_gen(crys_sym, kpoint%nkp_grid, symm=kpoint%symmetry, shift=kpoint%kp_shift, &
178 full_grid=kpoint%full_grid)
179 kpoint%nkp = crys_sym%nkpoint
180 ALLOCATE (kpoint%xkp(3, kpoint%nkp), kpoint%wkp(kpoint%nkp))
181 wsum = sum(crys_sym%wkpoint)
182 DO ik = 1, kpoint%nkp
183 kpoint%xkp(1:3, ik) = crys_sym%xkpoint(1:3, ik)
184 kpoint%wkp(ik) = crys_sym%wkpoint(ik)/wsum
192 ALLOCATE (kpoint%kp_sym(kpoint%nkp))
193 DO ik = 1, kpoint%nkp
194 NULLIFY (kpoint%kp_sym(ik)%kpoint_sym)
196 kpsym => kpoint%kp_sym(ik)%kpoint_sym
197 IF (crys_sym%symlib .AND. .NOT. crys_sym%fullgrid .AND. crys_sym%istriz == 1)
THEN
199 kpsym%nwght = nint(crys_sym%wkpoint(ik))
203 kpsym%apply_symmetry = .true.
204 natom =
SIZE(particle_set)
205 ALLOCATE (
kpsym%rot(3, 3, ns))
206 ALLOCATE (
kpsym%xkp(3, ns))
207 ALLOCATE (
kpsym%rotp(ns))
208 ALLOCATE (
kpsym%f0(natom, ns))
210 DO is = 1,
SIZE(crys_sym%kplink, 2)
211 IF (crys_sym%kplink(2, is) == ik)
THEN
213 ir = crys_sym%kpop(is)
217 kpsym%rot(1:3, 1:3, nr) = crys_sym%rt(1:3, 1:3, ira)
219 kpsym%rot(1:3, 1:3, nr) = -crys_sym%rt(1:3, 1:3, ira)
221 kpsym%xkp(1:3, nr) = crys_sym%kpmesh(1:3, is)
222 DO ic = 1, crys_sym%nrtot
223 IF (crys_sym%ibrot(ic) == ira)
THEN
224 kpsym%f0(1:natom, nr) = crys_sym%f0(1:natom, ic)
235 IF (kpoint%symmetry)
THEN
236 nkind = maxval(atype)
238 ALLOCATE (kpoint%kind_rotmat(ns, nkind))
241 NULLIFY (kpoint%kind_rotmat(i, j)%rmat)
244 ALLOCATE (kpoint%ibrot(ns))
245 kpoint%ibrot(1:ns) = crys_sym%ibrot(1:ns)
249 DEALLOCATE (scoord, atype)
253 ALLOCATE (kpoint%kp_sym(kpoint%nkp))
255 NULLIFY (kpoint%kp_sym(i)%kpoint_sym)
263 SELECT CASE (kpoint%kp_scheme)
267 cpassert(kpoint%nkp == 1)
268 cpassert(sum(abs(kpoint%xkp)) <= 1.e-12_dp)
269 cpassert(kpoint%wkp(1) == 1.0_dp)
270 cpassert(.NOT. kpoint%symmetry)
272 cpassert(.NOT. kpoint%symmetry)
273 cpassert(kpoint%nkp >= 1)
274 CASE (
"MONKHORST-PACK",
"MACDONALD")
275 cpassert(kpoint%nkp >= 1)
277 IF (kpoint%use_real_wfn)
THEN
279 ikloop:
DO ik = 1, kpoint%nkp
281 spez = (kpoint%xkp(i, ik) == 0.0_dp .OR. kpoint%xkp(i, ik) == 0.5_dp)
282 IF (.NOT. spez)
EXIT ikloop
287 CALL cp_warn(__location__, &
288 "A calculation using real wavefunctions is requested. "// &
289 "We could not determine if the symmetry of the system allows real wavefunctions. ")
293 CALL timestop(handle)
309 LOGICAL,
INTENT(IN),
OPTIONAL :: with_aux_fit
311 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_env_initialize'
313 INTEGER :: handle, igr, ik, ikk, ngr, niogrp, nkp, &
314 nkp_grp, nkp_loc, npe, unit_nr
315 INTEGER,
DIMENSION(2) :: dims, pos
322 CALL timeset(routinen, handle)
324 IF (
PRESENT(with_aux_fit))
THEN
325 aux_fit = with_aux_fit
330 kpoint%para_env => para_env
331 CALL kpoint%para_env%retain()
332 kpoint%blacs_env_all => blacs_env
333 CALL kpoint%blacs_env_all%retain()
335 cpassert(.NOT.
ASSOCIATED(kpoint%kp_env))
337 cpassert(.NOT.
ASSOCIATED(kpoint%kp_aux_env))
340 NULLIFY (kp_env, kp_aux_env)
342 npe = para_env%num_pe
345 ALLOCATE (kp_env(nkp))
347 NULLIFY (kp_env(ik)%kpoint_env)
349 kp => kp_env(ik)%kpoint_env
351 kp%wkp = kpoint%wkp(ik)
352 kp%xkp(1:3) = kpoint%xkp(1:3, ik)
355 kpoint%kp_env => kp_env
358 ALLOCATE (kp_aux_env(nkp))
360 NULLIFY (kp_aux_env(ik)%kpoint_env)
362 kp => kp_aux_env(ik)%kpoint_env
364 kp%wkp = kpoint%wkp(ik)
365 kp%xkp(1:3) = kpoint%xkp(1:3, ik)
369 kpoint%kp_aux_env => kp_aux_env
372 ALLOCATE (kpoint%kp_dist(2, 1))
373 kpoint%kp_dist(1, 1) = 1
374 kpoint%kp_dist(2, 1) = nkp
375 kpoint%kp_range(1) = 1
376 kpoint%kp_range(2) = nkp
379 kpoint%para_env_kp => para_env
380 CALL kpoint%para_env_kp%retain()
381 kpoint%para_env_inter_kp => para_env
382 CALL kpoint%para_env_inter_kp%retain()
383 kpoint%iogrp = .true.
384 kpoint%nkp_groups = 1
386 IF (kpoint%parallel_group_size == -1)
THEN
391 IF (mod(npe, igr) /= 0) cycle
393 IF (mod(nkp, nkp_grp) /= 0) cycle
396 ELSE IF (kpoint%parallel_group_size == 0)
THEN
399 ELSE IF (kpoint%parallel_group_size > 0)
THEN
400 ngr = min(kpoint%parallel_group_size, npe)
408 cpassert(mod(nkp, nkp_grp) == 0)
409 nkp_loc = nkp/nkp_grp
411 IF ((dims(1)*dims(2) /= npe))
THEN
412 cpabort(
"Number of processors is not divisible by the kpoint group size.")
416 CALL comm_cart%create(comm_old=para_env, ndims=2, dims=dims)
417 pos = comm_cart%mepos_cart
418 ALLOCATE (para_env_kp)
419 CALL para_env_kp%from_split(comm_cart, pos(2))
420 ALLOCATE (para_env_inter_kp)
421 CALL para_env_inter_kp%from_split(comm_cart, pos(1))
422 CALL comm_cart%free()
425 IF (para_env%is_source()) niogrp = 1
426 CALL para_env_kp%sum(niogrp)
427 kpoint%iogrp = (niogrp == 1)
430 kpoint%para_env_kp => para_env_kp
431 kpoint%para_env_inter_kp => para_env_inter_kp
434 ALLOCATE (kpoint%kp_dist(2, nkp_grp))
436 kpoint%kp_dist(1:2, igr) =
get_limit(nkp, nkp_grp, igr - 1)
439 kpoint%kp_range(1:2) = kpoint%kp_dist(1:2, para_env_inter_kp%mepos + 1)
441 ALLOCATE (kp_env(nkp_loc))
443 NULLIFY (kp_env(ik)%kpoint_env)
444 ikk = kpoint%kp_range(1) + ik - 1
446 kp => kp_env(ik)%kpoint_env
448 kp%wkp = kpoint%wkp(ikk)
449 kp%xkp(1:3) = kpoint%xkp(1:3, ikk)
450 kp%is_local = (ngr == 1)
452 kpoint%kp_env => kp_env
455 ALLOCATE (kp_aux_env(nkp_loc))
457 NULLIFY (kp_aux_env(ik)%kpoint_env)
458 ikk = kpoint%kp_range(1) + ik - 1
460 kp => kp_aux_env(ik)%kpoint_env
462 kp%wkp = kpoint%wkp(ikk)
463 kp%xkp(1:3) = kpoint%xkp(1:3, ikk)
464 kp%is_local = (ngr == 1)
466 kpoint%kp_aux_env => kp_aux_env
471 IF (unit_nr > 0 .AND. kpoint%verbose)
THEN
473 WRITE (unit_nr, fmt=
"(T2,A,T71,I10)")
"KPOINTS| Number of kpoint groups ", nkp_grp
474 WRITE (unit_nr, fmt=
"(T2,A,T71,I10)")
"KPOINTS| Size of each kpoint group", ngr
475 WRITE (unit_nr, fmt=
"(T2,A,T71,I10)")
"KPOINTS| Number of kpoints per group", nkp_loc
477 kpoint%nkp_groups = nkp_grp
481 CALL timestop(handle)
495 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
496 INTEGER,
INTENT(IN),
OPTIONAL :: added_mos
497 LOGICAL,
OPTIONAL :: for_aux_fit
499 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_initialize_mos'
501 INTEGER :: handle, ic, ik, is, nadd, nao, nc, &
502 nelectron, nkp_loc, nmo, nmorig(2), &
505 REAL(kind=
dp) :: flexible_electron_count, maxocc, n_el_f
513 CALL timeset(routinen, handle)
515 IF (
PRESENT(for_aux_fit))
THEN
516 aux_fit = for_aux_fit
521 cpassert(
ASSOCIATED(kpoint))
523 IF (.true. .OR.
ASSOCIATED(mos(1)%mo_coeff))
THEN
525 cpassert(
ASSOCIATED(kpoint%kp_aux_env))
528 IF (
PRESENT(added_mos))
THEN
534 IF (kpoint%use_real_wfn)
THEN
540 nkp_loc = kpoint%kp_range(2) - kpoint%kp_range(1) + 1
541 IF (nkp_loc > 0)
THEN
543 cpassert(
SIZE(kpoint%kp_aux_env) == nkp_loc)
545 cpassert(
SIZE(kpoint%kp_env) == nkp_loc)
550 kp => kpoint%kp_aux_env(ik)%kpoint_env
552 kp => kpoint%kp_env(ik)%kpoint_env
554 ALLOCATE (kp%mos(nc, nspin))
556 CALL get_mo_set(mos(is), nao=nao, nmo=nmo, nelectron=nelectron, &
557 n_el_f=n_el_f, maxocc=maxocc, flexible_electron_count=flexible_electron_count)
558 nmo = min(nao, nmo + nadd)
560 CALL allocate_mo_set(kp%mos(ic, is), nao, nmo, nelectron, n_el_f, maxocc, &
561 flexible_electron_count)
571 IF (
ASSOCIATED(kpoint%blacs_env))
THEN
572 blacs_env => kpoint%blacs_env
575 kpoint%blacs_env => blacs_env
581 nmo = min(nao, nmorig(is) + nadd)
589 blacs_env=blacs_env, para_env=kpoint%para_env_kp)
592 kpoint%mpools_aux_fit => mpools
594 kpoint%mpools => mpools
603 CALL mpools_get(mpools, ao_ao_fm_pools=ao_ao_fm_pools)
609 kp => kpoint%kp_aux_env(ik)%kpoint_env
611 kp => kpoint%kp_env(ik)%kpoint_env
615 ALLOCATE (kp%pmat(nc, nspin))
623 ALLOCATE (kp%wmat(nc, nspin))
637 CALL timestop(handle)
648 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_initialize_mo_set'
650 INTEGER :: handle, ic, ik, ikk, ispin
653 TYPE(
mo_set_type),
DIMENSION(:, :),
POINTER :: moskp
655 CALL timeset(routinen, handle)
657 DO ik = 1,
SIZE(kpoint%kp_env)
658 CALL mpools_get(kpoint%mpools, ao_mo_fm_pools=ao_mo_fm_pools)
659 moskp => kpoint%kp_env(ik)%kpoint_env%mos
660 ikk = kpoint%kp_range(1) + ik - 1
661 cpassert(
ASSOCIATED(moskp))
662 DO ispin = 1,
SIZE(moskp, 2)
663 DO ic = 1,
SIZE(moskp, 1)
664 CALL get_mo_set(moskp(ic, ispin), mo_coeff=mo_coeff)
665 IF (.NOT.
ASSOCIATED(mo_coeff))
THEN
667 fm_pool=ao_mo_fm_pools(ispin)%pool, name=
"kpoints")
673 CALL timestop(handle)
691 INTEGER,
INTENT(OUT) :: nimages
693 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_init_cell_index'
695 INTEGER :: handle, i1, i2, i3, ic, icount, it, &
697 INTEGER,
DIMENSION(3) :: cell, itm
698 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell,
list
699 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index, cti
702 DIMENSION(:),
POINTER :: nl_iterator
704 NULLIFY (cell_to_index, index_to_cell)
706 CALL timeset(routinen, handle)
708 cpassert(
ASSOCIATED(kpoint))
710 ALLOCATE (
list(3, 125))
720 IF (cell(1) ==
list(1, ic) .AND. cell(2) ==
list(2, ic) .AND. &
721 cell(3) ==
list(3, ic))
THEN
728 IF (icount >
SIZE(
list, 2))
THEN
731 list(1:3, icount) = cell(1:3)
737 itm(1) = maxval(abs(
list(1, 1:icount)))
738 itm(2) = maxval(abs(
list(2, 1:icount)))
739 itm(3) = maxval(abs(
list(3, 1:icount)))
740 CALL para_env%max(itm)
741 it = maxval(itm(1:3))
742 IF (
ASSOCIATED(kpoint%cell_to_index))
THEN
743 DEALLOCATE (kpoint%cell_to_index)
745 ALLOCATE (kpoint%cell_to_index(-itm(1):itm(1), -itm(2):itm(2), -itm(3):itm(3)))
746 cell_to_index => kpoint%cell_to_index
755 CALL para_env%sum(cti)
757 DO i1 = -itm(1), itm(1)
758 DO i2 = -itm(2), itm(2)
759 DO i3 = -itm(3), itm(3)
760 IF (cti(i1, i2, i3) == 0)
THEN
761 cti(i1, i2, i3) = 1000000
764 cti(i1, i2, i3) = (abs(i1) + abs(i2) + abs(i3))*1000 + abs(i3)*100 + abs(i2)*10 + abs(i1)
765 cti(i1, i2, i3) = cti(i1, i2, i3) + (i1 + i2 + i3)
771 IF (
ASSOCIATED(kpoint%index_to_cell))
THEN
772 DEALLOCATE (kpoint%index_to_cell)
774 ALLOCATE (kpoint%index_to_cell(3, ncount))
775 index_to_cell => kpoint%index_to_cell
778 i1 = cell(1) - 1 - itm(1)
779 i2 = cell(2) - 1 - itm(2)
780 i3 = cell(3) - 1 - itm(3)
781 cti(i1, i2, i3) = 1000000
782 index_to_cell(1, ic) = i1
783 index_to_cell(2, ic) = i2
784 index_to_cell(3, ic) = i3
788 i1 = index_to_cell(1, ic)
789 i2 = index_to_cell(2, ic)
790 i3 = index_to_cell(3, ic)
795 kpoint%sab_nl => sab_nl
798 nimages =
SIZE(index_to_cell, 2)
802 CALL timestop(handle)
819 xkp, cell_to_index, sab_nl, is_complex, rs_sign)
824 INTEGER,
INTENT(IN) :: ispin
825 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: xkp
826 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
829 LOGICAL,
INTENT(IN),
OPTIONAL :: is_complex
830 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: rs_sign
832 CHARACTER(LEN=*),
PARAMETER :: routinen =
'rskp_transform'
834 INTEGER :: handle, iatom, ic, icol, irow, jatom, &
836 INTEGER,
DIMENSION(3) :: cell
837 LOGICAL :: do_symmetric, found, my_complex, &
839 REAL(kind=
dp) :: arg, coskl, fsign, fsym, sinkl
840 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: cblock, rblock, rsblock
842 DIMENSION(:),
POINTER :: nl_iterator
844 CALL timeset(routinen, handle)
847 IF (
PRESENT(is_complex)) my_complex = is_complex
850 IF (
PRESENT(rs_sign)) fsign = rs_sign
852 wfn_real_only = .true.
853 IF (
PRESENT(cmatrix)) wfn_real_only = .false.
855 nimg =
SIZE(rsmat, 2)
868 IF (do_symmetric .AND. (iatom > jatom))
THEN
874 ic = cell_to_index(cell(1), cell(2), cell(3))
875 IF (ic < 1 .OR. ic > nimg) cycle
877 arg = real(cell(1),
dp)*xkp(1) + real(cell(2),
dp)*xkp(2) + real(cell(3),
dp)*xkp(3)
879 coskl = fsign*fsym*cos(
twopi*arg)
880 sinkl = fsign*sin(
twopi*arg)
882 coskl = fsign*cos(
twopi*arg)
883 sinkl = fsign*fsym*sin(
twopi*arg)
887 block=rsblock, found=found)
888 IF (.NOT. found) cycle
890 IF (wfn_real_only)
THEN
892 block=rblock, found=found)
893 IF (.NOT. found) cycle
894 rblock = rblock + coskl*rsblock
897 block=rblock, found=found)
898 IF (.NOT. found) cycle
900 block=cblock, found=found)
901 IF (.NOT. found) cycle
902 rblock = rblock + coskl*rsblock
903 cblock = cblock + sinkl*rsblock
909 CALL timestop(handle)
926 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_set_mo_occupation'
928 INTEGER :: handle, ik, ikpgr, ispin, kplocal, nao, &
929 nb, ncol_global, ne_a, ne_b, &
930 nelectron, nkp, nmo, nrow_global, nspin
931 INTEGER,
DIMENSION(2) :: kp_range
932 REAL(kind=
dp) :: kts, mu, mus(2), nel
933 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: smatrix
934 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: weig, wocc
935 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: icoeff, rcoeff
936 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues, occupation, wkp
942 CALL timeset(routinen, handle)
946 kp => kpoint%kp_env(1)%kpoint_env
947 nspin =
SIZE(kp%mos, 2)
948 mo_set => kp%mos(1, 1)
949 CALL get_mo_set(mo_set, nmo=nmo, nao=nao, nelectron=nelectron)
952 CALL get_mo_set(kp%mos(1, 2), nmo=nb, nelectron=ne_b)
955 ALLOCATE (weig(nmo, nkp, nspin), wocc(nmo, nkp, nspin))
958 IF (
PRESENT(probe))
THEN
959 ALLOCATE (rcoeff(nao, nmo, nkp, nspin), icoeff(nao, nmo, nkp, nspin))
964 kplocal = kp_range(2) - kp_range(1) + 1
965 DO ikpgr = 1, kplocal
966 ik = kp_range(1) + ikpgr - 1
967 kp => kpoint%kp_env(ikpgr)%kpoint_env
969 mo_set => kp%mos(1, ispin)
970 CALL get_mo_set(mo_set, eigenvalues=eigenvalues)
971 weig(1:nmo, ik, ispin) = eigenvalues(1:nmo)
972 IF (
PRESENT(probe))
THEN
975 nrow_global=nrow_global, &
976 ncol_global=ncol_global)
977 ALLOCATE (smatrix(nrow_global, ncol_global))
980 rcoeff(1:nao, 1:nmo, ik, ispin) = smatrix(1:nrow_global, 1:ncol_global)
984 mo_set => kp%mos(2, ispin)
988 nrow_global=nrow_global, &
989 ncol_global=ncol_global)
990 ALLOCATE (smatrix(nrow_global, ncol_global))
993 icoeff(1:nao, 1:nmo, ik, ispin) = smatrix(1:nrow_global, 1:ncol_global)
995 mo_set => kp%mos(1, ispin)
1002 CALL para_env_inter_kp%sum(weig)
1004 IF (
PRESENT(probe))
THEN
1005 CALL para_env_inter_kp%sum(rcoeff)
1006 CALL para_env_inter_kp%sum(icoeff)
1012 IF (
PRESENT(probe))
THEN
1013 smear%do_smear = .false.
1015 IF (nspin == 1)
THEN
1016 nel = real(nelectron, kind=
dp)
1017 CALL probe_occupancy_kp(wocc(:, :, :), mus(1), kts, weig(:, :, :), rcoeff(:, :, :, :), icoeff(:, :, :, :), 2.0d0, &
1020 nel = real(ne_a, kind=
dp) + real(ne_b, kind=
dp)
1021 CALL probe_occupancy_kp(wocc(:, :, :), mu, kts, weig(:, :, :), rcoeff(:, :, :, :), icoeff(:, :, :, :), 1.0d0, &
1027 DO ikpgr = 1, kplocal
1028 ik = kp_range(1) + ikpgr - 1
1029 kp => kpoint%kp_env(ikpgr)%kpoint_env
1031 mo_set => kp%mos(1, ispin)
1032 CALL get_mo_set(mo_set, eigenvalues=eigenvalues, occupation_numbers=occupation)
1033 eigenvalues(1:nmo) = weig(1:nmo, ik, ispin)
1034 occupation(1:nmo) = wocc(1:nmo, ik, ispin)
1036 mo_set%mu = mus(ispin)
1041 nrow_global=nrow_global, &
1042 ncol_global=ncol_global)
1043 ALLOCATE (smatrix(nrow_global, ncol_global))
1046 smatrix(1:nrow_global, 1:ncol_global) = rcoeff(1:nao, 1:nmo, ik, ispin)
1047 DEALLOCATE (smatrix)
1049 mo_set => kp%mos(2, ispin)
1054 nrow_global=nrow_global, &
1055 ncol_global=ncol_global)
1056 ALLOCATE (smatrix(nrow_global, ncol_global))
1059 smatrix(1:nrow_global, 1:ncol_global) = icoeff(1:nao, 1:nmo, ik, ispin)
1060 DEALLOCATE (smatrix)
1062 mo_set => kp%mos(1, ispin)
1067 DEALLOCATE (weig, wocc, rcoeff, icoeff)
1071 IF (
PRESENT(probe) .EQV. .false.)
THEN
1072 IF (smear%do_smear)
THEN
1073 SELECT CASE (smear%method)
1076 IF (nspin == 1)
THEN
1077 nel = real(nelectron, kind=
dp)
1078 CALL smearkp(wocc(:, :, 1), mus(1), kts, weig(:, :, 1), nel, wkp, &
1080 ELSE IF (smear%fixed_mag_mom > 0.0_dp)
THEN
1081 nel = real(ne_a, kind=
dp)
1082 CALL smearkp(wocc(:, :, 1), mus(1), kts, weig(:, :, 1), nel, wkp, &
1084 nel = real(ne_b, kind=
dp)
1085 CALL smearkp(wocc(:, :, 2), mus(2), kts, weig(:, :, 2), nel, wkp, &
1088 nel = real(ne_a, kind=
dp) + real(ne_b, kind=
dp)
1089 CALL smearkp2(wocc(:, :, :), mu, kts, weig(:, :, :), nel, wkp, &
1095 IF (nspin == 1)
THEN
1096 nel = real(nelectron, kind=
dp)
1097 CALL smearkp(wocc(:, :, 1), mus(1), kts, weig(:, :, 1), nel, wkp, &
1098 smear%smearing_width, 2.0_dp, smear%method)
1099 ELSE IF (smear%fixed_mag_mom > 0.0_dp)
THEN
1100 nel = real(ne_a, kind=
dp)
1101 CALL smearkp(wocc(:, :, 1), mus(1), kts, weig(:, :, 1), nel, wkp, &
1102 smear%smearing_width, 1.0_dp, smear%method)
1103 nel = real(ne_b, kind=
dp)
1104 CALL smearkp(wocc(:, :, 2), mus(2), kts, weig(:, :, 2), nel, wkp, &
1105 smear%smearing_width, 1.0_dp, smear%method)
1107 nel = real(ne_a, kind=
dp) + real(ne_b, kind=
dp)
1108 CALL smearkp2(wocc(:, :, :), mu, kts, weig(:, :, :), nel, wkp, &
1109 smear%smearing_width, smear%method)
1114 cpabort(
"kpoints: Selected smearing not (yet) supported")
1118 IF (nspin == 1)
THEN
1119 nel = real(nelectron, kind=
dp)
1120 CALL smearkp(wocc(:, :, 1), mus(1), kts, weig(:, :, 1), nel, wkp, &
1123 nel = real(ne_a, kind=
dp)
1124 CALL smearkp(wocc(:, :, 1), mus(1), kts, weig(:, :, 1), nel, wkp, &
1126 nel = real(ne_b, kind=
dp)
1127 CALL smearkp(wocc(:, :, 2), mus(2), kts, weig(:, :, 2), nel, wkp, &
1131 DO ikpgr = 1, kplocal
1132 ik = kp_range(1) + ikpgr - 1
1133 kp => kpoint%kp_env(ikpgr)%kpoint_env
1135 mo_set => kp%mos(1, ispin)
1136 CALL get_mo_set(mo_set, eigenvalues=eigenvalues, occupation_numbers=occupation)
1137 eigenvalues(1:nmo) = weig(1:nmo, ik, ispin)
1138 occupation(1:nmo) = wocc(1:nmo, ik, ispin)
1140 mo_set%mu = mus(ispin)
1144 DEALLOCATE (weig, wocc)
1148 CALL timestop(handle)
1161 LOGICAL,
OPTIONAL :: energy_weighted, for_aux_fit
1163 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_density_matrices'
1165 INTEGER :: handle, ikpgr, ispin, kplocal, nao, nmo, &
1167 INTEGER,
DIMENSION(2) :: kp_range
1168 LOGICAL :: aux_fit, wtype
1169 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues, occupation
1172 TYPE(
cp_fm_type),
POINTER :: cpmat, pmat, rpmat
1176 CALL timeset(routinen, handle)
1178 IF (
PRESENT(energy_weighted))
THEN
1179 wtype = energy_weighted
1185 IF (
PRESENT(for_aux_fit))
THEN
1186 aux_fit = for_aux_fit
1192 cpassert(
ASSOCIATED(kpoint%kp_aux_env))
1197 mo_set => kpoint%kp_aux_env(1)%kpoint_env%mos(1, 1)
1199 mo_set => kpoint%kp_env(1)%kpoint_env%mos(1, 1)
1202 CALL cp_fm_get_info(mo_set%mo_coeff, matrix_struct=matrix_struct)
1206 kplocal = kp_range(2) - kp_range(1) + 1
1207 DO ikpgr = 1, kplocal
1209 kp => kpoint%kp_aux_env(ikpgr)%kpoint_env
1211 kp => kpoint%kp_env(ikpgr)%kpoint_env
1213 nspin =
SIZE(kp%mos, 2)
1215 mo_set => kp%mos(1, ispin)
1217 CALL get_mo_set(mo_set, eigenvalues=eigenvalues)
1219 IF (kpoint%use_real_wfn)
THEN
1221 pmat => kp%wmat(1, ispin)
1223 pmat => kp%pmat(1, ispin)
1225 CALL get_mo_set(mo_set, occupation_numbers=occupation)
1231 CALL parallel_gemm(
"N",
"T", nao, nao, nmo, 1.0_dp, mo_set%mo_coeff, fwork, 0.0_dp, pmat)
1234 rpmat => kp%wmat(1, ispin)
1235 cpmat => kp%wmat(2, ispin)
1237 rpmat => kp%pmat(1, ispin)
1238 cpmat => kp%pmat(2, ispin)
1240 CALL get_mo_set(mo_set, occupation_numbers=occupation)
1247 CALL parallel_gemm(
"N",
"T", nao, nao, nmo, 1.0_dp, mo_set%mo_coeff, fwork, 0.0_dp, rpmat)
1248 mo_set => kp%mos(2, ispin)
1250 CALL parallel_gemm(
"N",
"T", nao, nao, nmo, 1.0_dp, mo_set%mo_coeff, fwork, 0.0_dp, cpmat)
1252 CALL parallel_gemm(
"N",
"T", nao, nao, nmo, -1.0_dp, fwork, mo_set%mo_coeff, 1.0_dp, cpmat)
1259 CALL parallel_gemm(
"N",
"T", nao, nao, nmo, 1.0_dp, mo_set%mo_coeff, fwork, 1.0_dp, rpmat)
1266 CALL timestop(handle)
1281 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(INOUT) :: pmat_diag
1283 CHARACTER(LEN=*),
PARAMETER :: routinen =
'lowdin_kp_trans'
1284 COMPLEX(KIND=dp),
PARAMETER :: cone = (1.0_dp, 0.0_dp), &
1285 czero = (0.0_dp, 0.0_dp)
1287 INTEGER :: handle, ikpgr, ispin, kplocal, nao, nspin
1288 INTEGER,
DIMENSION(2) :: kp_range
1289 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: dele
1294 TYPE(
cp_fm_type),
POINTER :: cpmat, pmat, rpmat, shalf
1298 CALL timeset(routinen, handle)
1300 nspin =
SIZE(pmat_diag, 2)
1305 matrix_struct=matrix_struct, nrow_global=nao)
1306 IF (kpoint%use_real_wfn)
THEN
1307 CALL cp_fm_create(f1work, matrix_struct, nrow=nao, ncol=nao)
1308 CALL cp_fm_create(f2work, matrix_struct, nrow=nao, ncol=nao)
1310 CALL cp_fm_create(f2work, matrix_struct, nrow=nao, ncol=nao)
1311 CALL cp_cfm_create(cf1work, matrix_struct, nrow=nao, ncol=nao)
1312 CALL cp_cfm_create(cf2work, matrix_struct, nrow=nao, ncol=nao)
1314 ALLOCATE (dele(nao))
1317 kplocal = kp_range(2) - kp_range(1) + 1
1318 DO ikpgr = 1, kplocal
1319 kp => kpoint%kp_env(ikpgr)%kpoint_env
1321 IF (kpoint%use_real_wfn)
THEN
1322 pmat => kp%pmat(1, ispin)
1324 CALL parallel_gemm(
"N",
"N", nao, nao, nao, 1.0_dp, pmat, shalf, 0.0_dp, f1work)
1325 CALL parallel_gemm(
"N",
"N", nao, nao, nao, 1.0_dp, shalf, f1work, 0.0_dp, f2work)
1327 rpmat => kp%pmat(1, ispin)
1328 cpmat => kp%pmat(2, ispin)
1331 CALL parallel_gemm(
"N",
"N", nao, nao, nao, cone, cf1work, cshalf, czero, cf2work)
1332 CALL parallel_gemm(
"N",
"N", nao, nao, nao, cone, cshalf, cf2work, czero, cf1work)
1336 pmat_diag(1:nao, ispin) = pmat_diag(1:nao, ispin) + kp%wkp*dele(1:nao)
1341 CALL para_env_inter_kp%sum(pmat_diag)
1343 IF (kpoint%use_real_wfn)
THEN
1353 CALL timestop(handle)
1373 LOGICAL,
INTENT(IN) :: wtype
1377 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(IN) :: fmwork
1378 LOGICAL,
OPTIONAL :: for_aux_fit
1379 TYPE(
cp_fm_type),
DIMENSION(:, :, :),
INTENT(IN), &
1380 OPTIONAL :: pmat_ext
1382 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_density_transform'
1384 INTEGER :: handle, ic, ik, ikk, indx, ir, ira, is, &
1385 ispin, jr, nc, nimg, nkp, nspin
1386 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1387 LOGICAL :: aux_fit, do_ext, do_symmetric, my_kpgrp, &
1389 REAL(kind=
dp) :: wkpx
1390 REAL(kind=
dp),
DIMENSION(:),
POINTER :: wkp
1391 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1394 TYPE(
dbcsr_type),
POINTER :: cpmat, rpmat, scpmat, srpmat
1400 CALL timeset(routinen, handle)
1404 IF (
PRESENT(for_aux_fit))
THEN
1405 aux_fit = for_aux_fit
1411 IF (
PRESENT(pmat_ext)) do_ext = .true.
1414 cpassert(
ASSOCIATED(kpoint%kp_aux_env))
1420 matrix_type=merge(dbcsr_type_symmetric, dbcsr_type_no_symmetry, do_symmetric))
1425 matrix_type=merge(dbcsr_type_antisymmetric, dbcsr_type_no_symmetry, do_symmetric))
1428 IF (.NOT. kpoint%full_grid)
THEN
1440 cell_to_index=cell_to_index)
1443 kp => kpoint%kp_aux_env(1)%kpoint_env
1445 kp => kpoint%kp_env(1)%kpoint_env
1447 nspin =
SIZE(kp%mos, 2)
1448 nc =
SIZE(kp%mos, 1)
1449 nimg =
SIZE(denmat, 2)
1450 real_only = (nc == 1)
1452 para_env => kpoint%blacs_env_all%para_env
1453 ALLOCATE (info(nspin*nkp*nc))
1459 CALL dbcsr_set(denmat(ispin, ic)%matrix, 0.0_dp)
1463 my_kpgrp = (ik >= kpoint%kp_range(1) .AND. ik <= kpoint%kp_range(2))
1465 ikk = ik - kpoint%kp_range(1) + 1
1467 kp => kpoint%kp_aux_env(ikk)%kpoint_env
1469 kp => kpoint%kp_env(ikk)%kpoint_env
1475 cpassert(
SIZE(fmwork) >= nc)
1517 kpsym => kpoint%kp_sym(ik)%kpoint_sym
1518 cpassert(
ASSOCIATED(
kpsym))
1520 IF (
kpsym%apply_symmetry)
THEN
1521 wkpx = wkp(ik)/real(
kpsym%nwght, kind=
dp)
1522 DO is = 1,
kpsym%nwght
1523 ir = abs(
kpsym%rotp(is))
1525 DO jr = 1,
SIZE(kpoint%ibrot)
1526 IF (ir == kpoint%ibrot(jr)) ira = jr
1529 kind_rot => kpoint%kind_rotmat(ira, :)
1531 CALL symtrans(srpmat, rpmat, kind_rot,
kpsym%rot(1:3, 1:3, is), &
1532 kpsym%f0(:, is), kpoint%atype, symmetric=.true.)
1534 CALL symtrans(srpmat, rpmat, kind_rot,
kpsym%rot(1:3, 1:3, is), &
1535 kpsym%f0(:, is), kpoint%atype, symmetric=.true.)
1536 CALL symtrans(scpmat, cpmat, kind_rot,
kpsym%rot(1:3, 1:3, is), &
1537 kpsym%f0(:, is), kpoint%atype, antisymmetric=.true.)
1539 CALL transform_dmat(denmat, srpmat, scpmat, ispin, real_only, sab_nl, &
1540 cell_to_index,
kpsym%xkp(1:3, is), wkpx)
1544 CALL transform_dmat(denmat, rpmat, cpmat, ispin, real_only, sab_nl, &
1545 cell_to_index, xkp(1:3, ik), wkp(ik))
1554 my_kpgrp = (ik >= kpoint%kp_range(1) .AND. ik <= kpoint%kp_range(2))
1556 ikk = ik - kpoint%kp_range(1) + 1
1558 kp => kpoint%kp_aux_env(ikk)%kpoint_env
1560 kp => kpoint%kp_env(ikk)%kpoint_env
1580 IF (.NOT. kpoint%full_grid)
THEN
1585 CALL timestop(handle)
1601 SUBROUTINE transform_dmat(denmat, rpmat, cpmat, ispin, real_only, sab_nl, cell_to_index, xkp, wkp)
1605 INTEGER,
INTENT(IN) :: ispin
1606 LOGICAL,
INTENT(IN) :: real_only
1609 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1610 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: xkp
1611 REAL(kind=
dp),
INTENT(IN) :: wkp
1613 CHARACTER(LEN=*),
PARAMETER :: routinen =
'transform_dmat'
1615 INTEGER :: handle, iatom, icell, icol, irow, jatom, &
1617 INTEGER,
DIMENSION(3) :: cell
1618 LOGICAL :: do_symmetric, found
1619 REAL(kind=
dp) :: arg, coskl, fc, sinkl
1620 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: cblock, dblock, rblock
1622 DIMENSION(:),
POINTER :: nl_iterator
1624 CALL timeset(routinen, handle)
1626 nimg =
SIZE(denmat, 2)
1642 IF (do_symmetric .AND. iatom > jatom)
THEN
1648 icell = cell_to_index(cell(1), cell(2), cell(3))
1649 IF (icell < 1 .OR. icell > nimg) cycle
1651 arg = real(cell(1),
dp)*xkp(1) + real(cell(2),
dp)*xkp(2) + real(cell(3),
dp)*xkp(3)
1652 coskl = wkp*cos(
twopi*arg)
1653 sinkl = wkp*fc*sin(
twopi*arg)
1655 CALL dbcsr_get_block_p(matrix=denmat(ispin, icell)%matrix, row=irow, col=icol, &
1656 block=dblock, found=found)
1657 IF (.NOT. found) cycle
1660 CALL dbcsr_get_block_p(matrix=rpmat, row=irow, col=icol, block=rblock, found=found)
1661 IF (.NOT. found) cycle
1662 dblock = dblock + coskl*rblock
1664 CALL dbcsr_get_block_p(matrix=rpmat, row=irow, col=icol, block=rblock, found=found)
1665 IF (.NOT. found) cycle
1666 CALL dbcsr_get_block_p(matrix=cpmat, row=irow, col=icol, block=cblock, found=found)
1667 IF (.NOT. found) cycle
1668 dblock = dblock + coskl*rblock
1669 dblock = dblock + sinkl*cblock
1674 CALL timestop(handle)
1676 END SUBROUTINE transform_dmat
1689 SUBROUTINE symtrans(smat, pmat, kmat, rot, f0, atype, symmetric, antisymmetric)
1692 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: rot
1693 INTEGER,
DIMENSION(:),
INTENT(IN) :: f0, atype
1694 LOGICAL,
INTENT(IN),
OPTIONAL :: symmetric, antisymmetric
1696 CHARACTER(LEN=*),
PARAMETER :: routinen =
'symtrans'
1698 INTEGER :: handle, iatom, icol, ikind, ip, irow, &
1699 jcol, jkind, jp, jrow, natom, numnodes
1700 LOGICAL :: asym, dorot, found, perm, sym, trans
1701 REAL(kind=
dp) :: dr, fsign
1702 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: kroti, krotj, pblock, sblock
1706 CALL timeset(routinen, handle)
1710 IF (
PRESENT(symmetric)) sym = symmetric
1712 IF (
PRESENT(antisymmetric)) asym = antisymmetric
1714 cpassert(.NOT. (sym .AND. asym))
1715 cpassert((sym .OR. asym))
1721 IF (f0(iatom) == iatom) cycle
1728 IF (abs(sum(abs(rot)) - 3.0_dp) > 1.e-12_dp) dorot = .true.
1729 dr = abs(rot(1, 1) - 1.0_dp) + abs(rot(2, 2) - 1.0_dp) + abs(rot(3, 3) - 1.0_dp)
1730 IF (abs(dr) > 1.e-12_dp) dorot = .true.
1733 IF (asym) fsign = -1.0_dp
1735 IF (dorot .OR. perm)
THEN
1736 CALL cp_abort(__location__,
"k-points need FULL_GRID currently. "// &
1737 "Reduced grids not yet working correctly")
1742 IF (numnodes == 1)
THEN
1758 CALL dbcsr_get_block_p(matrix=smat, row=jrow, col=jcol, block=sblock, found=found)
1762 kroti => kmat(ikind)%rmat
1763 krotj => kmat(jkind)%rmat
1766 sblock = fsign*matmul(transpose(krotj), matmul(transpose(pblock), kroti))
1768 sblock = fsign*matmul(transpose(kroti), matmul(pblock, krotj))
1775 CALL cp_abort(__location__,
"k-points need FULL_GRID currently. "// &
1776 "Reduced grids not yet working correctly")
1797 kroti => kmat(ikind)%rmat
1798 krotj => kmat(jkind)%rmat
1801 sblock = fsign*matmul(transpose(krotj), matmul(transpose(sblock), kroti))
1803 sblock = fsign*matmul(transpose(kroti), matmul(sblock, krotj))
1814 CALL timestop(handle)
1816 END SUBROUTINE symtrans
1822 SUBROUTINE matprint(mat)
1825 INTEGER :: i, icol, iounit, irow
1826 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: mblock
1834 IF (iounit > 0)
THEN
1835 WRITE (iounit,
'(A,2I4)')
'BLOCK ', irow, icol
1836 DO i = 1,
SIZE(mblock, 1)
1837 WRITE (iounit,
'(8F12.6)') mblock(i, :)
1844 END SUBROUTINE matprint
Define the atomic kind types and their sub types.
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.
Handles all functions related to the CELL.
subroutine, public real_to_scaled(s, r, cell)
Transform real to scaled cell coordinates. s=h_inv*r.
methods related to the blacs parallel environment
subroutine, public cp_blacs_env_create(blacs_env, para_env, blacs_grid_layout, blacs_repeatable, row_major, grid_2d)
allocates and initializes a type that represent a blacs context
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_fm_to_cfm(msourcer, msourcei, mtarget)
Construct a complex full matrix by taking its real and imaginary parts from two separate real-value f...
subroutine, public cp_cfm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_to_fm(msource, mtargetr, mtargeti)
Copy real and imaginary parts of a complex full matrix into separate real-value full matrices.
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_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_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_distribution_get(dist, row_dist, col_dist, nrows, ncols, has_threads, group, mynode, numnodes, nprows, npcols, myprow, mypcol, pgrid, subgroups_defined, prow_group, pcol_group)
...
Routines that link DBCSR and CP2K concepts together.
subroutine, public cp_dbcsr_alloc_block_from_nbl(matrix, sab_orb, desymmetrize)
allocate the blocks of a dbcsr based on the neighbor list
DBCSR operations in CP2K.
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_column_scale(matrixa, scaling)
scales column i of matrix a with scaling(i)
pool for for elements that are retained and released
subroutine, public fm_pool_create_fm(pool, element, name)
returns an element, allocating it if none is in the pool
subroutine, public fm_pool_give_back_fm(pool, element)
returns the element to the pool
represent the structure of a full matrix
represent a full matrix distributed on many processors
subroutine, public cp_fm_get_diag(matrix, diag)
returns the diagonal elements of a fm
subroutine, public cp_fm_start_copy_general(source, destination, para_env, info)
Initiates the copy operation: get distribution data, post MPI isend and irecvs.
subroutine, public cp_fm_cleanup_copy_general(info)
Completes the copy operation: wait for comms clean up MPI state.
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_finish_copy_general(destination, info)
Completes the copy operation: wait for comms, unpack, clean up MPI state.
subroutine, public cp_fm_get_submatrix(fm, target_m, start_row, start_col, n_rows, n_cols, transpose)
gets a submatrix of a full matrix op(target_m)(1:n_rows,1:n_cols) =fm(start_row:start_row+n_rows,...
various routines to log and control the output. The idea is that decisions about where to log should ...
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
K-points and crystal symmetry routines.
subroutine, public print_crys_symmetry(csym)
...
subroutine, public crys_sym_gen(csym, scoor, types, hmat, delta, iounit)
...
subroutine, public release_csym_type(csym)
Release the CSYM type.
subroutine, public kpoint_gen(csym, nk, symm, shift, full_grid)
...
subroutine, public print_kp_symmetry(csym)
...
subroutine, public probe_occupancy_kp(occ, fermi, kts, energies, rcoeff, icoeff, maxocc, probe, n, wk)
subroutine to calculate occupation number and 'Fermi' level using the
Defines the basic variable types.
integer, parameter, public dp
Routines needed for kpoint calculation.
subroutine, public kpoint_initialize_mo_set(kpoint)
...
subroutine, public rskp_transform(rmatrix, cmatrix, rsmat, ispin, xkp, cell_to_index, sab_nl, is_complex, rs_sign)
Transformation of real space matrices to a kpoint.
subroutine, public kpoint_init_cell_index(kpoint, sab_nl, para_env, nimages)
Generates the mapping of cell indices and linear RS index CELL (0,0,0) is always mapped to index 1.
subroutine, public kpoint_initialize_mos(kpoint, mos, added_mos, for_aux_fit)
Initialize a set of MOs and density matrix for each kpoint (kpoint group)
subroutine, public kpoint_initialize(kpoint, particle_set, cell)
Generate the kpoints and initialize the kpoint environment.
subroutine, public kpoint_density_transform(kpoint, denmat, wtype, tempmat, sab_nl, fmwork, for_aux_fit, pmat_ext)
generate real space density matrices in DBCSR format
subroutine, public kpoint_density_matrices(kpoint, energy_weighted, for_aux_fit)
Calculate kpoint density matrices (rho(k), owned by kpoint groups)
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...
subroutine, public kpoint_env_initialize(kpoint, para_env, blacs_env, with_aux_fit)
Initialize the kpoint environment.
subroutine, public kpoint_set_mo_occupation(kpoint, smear, probe)
Given the eigenvalues of all kpoints, calculates the occupation numbers.
Types and basic routines needed for a kpoint calculation.
subroutine, public kpoint_sym_create(kp_sym)
Create a single kpoint symmetry environment.
subroutine, public kpoint_env_create(kp_env)
Create a single kpoint environment.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym)
Retrieve information from a kpoint environment.
K-points and crystal symmetry routines based on.
An array-based list which grows on demand. When the internal array is full, a new array of twice the ...
Definition of mathematical constants and functions.
real(kind=dp), parameter, public twopi
Utility routines for the memory handling.
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
Define the data structure for the particle information.
wrapper for the pools of matrixes
subroutine, public mpools_create(mpools)
creates a mpools
subroutine, public mpools_rebuild_fm_pools(mpools, mos, blacs_env, para_env, nmosub)
rebuilds the pools of the (ao x mo, ao x ao , mo x mo) full matrixes
subroutine, public mpools_get(mpools, ao_mo_fm_pools, ao_ao_fm_pools, mo_mo_fm_pools, ao_mosub_fm_pools, mosub_mosub_fm_pools, maxao_maxmo_fm_pool, maxao_maxao_fm_pool, maxmo_maxmo_fm_pool)
returns various attributes of the mpools (notably the pools contained in it)
Definition and initialisation of the mo data type.
subroutine, public set_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, uniform_occupation, kts, mu, flexible_electron_count)
Set the components of a MO set data structure.
subroutine, public allocate_mo_set(mo_set, nao, nmo, nelectron, n_el_f, maxocc, flexible_electron_count)
Allocates a mo set and partially initializes it (nao,nmo,nelectron, and flexible_electron_count are v...
subroutine, public get_mo_set(mo_set, maxocc, homo, lfomo, nao, nelectron, n_el_f, nmo, eigenvalues, occupation_numbers, mo_coeff, mo_coeff_b, uniform_occupation, kts, mu, flexible_electron_count)
Get the components of a MO set data structure.
subroutine, public init_mo_set(mo_set, fm_pool, fm_ref, fm_struct, name)
initializes an allocated mo_set. eigenvalues, mo_coeff, occupation_numbers are valid only after this ...
Define the neighbor list data types and the corresponding functionality.
subroutine, public neighbor_list_iterator_create(iterator_set, nl, search, nthread)
Neighbor list iterator functions.
subroutine, public neighbor_list_iterator_release(iterator_set)
...
subroutine, public get_neighbor_list_set_p(neighbor_list_sets, nlist, symmetric)
Return the components of the first neighbor list set.
integer function, public neighbor_list_iterate(iterator_set, mepos)
...
subroutine, public get_iterator_info(iterator_set, mepos, ikind, jkind, nkind, ilist, nlist, inode, nnode, iatom, jatom, r, cell)
...
parameters that control an scf iteration
Unified smearing module supporting four methods: smear_fermi_dirac — Fermi-Dirac distribution smear_g...
subroutine, public smearkp(f, mu, kts, e, nel, wk, sigma, maxocc, method)
Bisection search for mu given a target electron count (k-point case, single spin channel or spin-dege...
subroutine, public smearkp2(f, mu, kts, e, nel, wk, sigma, method)
Bisection search for mu (k-point, spin-polarised with a shared chemical potential across both spin ch...
All kind of helpful little routines.
pure integer function, dimension(2), public get_limit(m, n, me)
divide m entries into n parts, return size of part me
Type defining parameters related to the simulation cell.
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
Represent a complex full matrix.
to create arrays of pools
keeps the information about the structure of a full matrix
Stores the state of a copy between cp_fm_start_copy_general and cp_fm_finish_copy_general.
Rotation matrices for basis sets.
Keeps information about a specific k-point.
Keeps symmetry information about a specific k-point.
Contains information about kpoints.
stores all the informations relevant to an mpi environment
container for the pools of matrixes used by qs
contains the parameters needed by a scf run