33 dbcsr_type_no_symmetry, dbcsr_type_symmetric
96#include "./base/base_uses.f90"
102 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'kpoint_methods'
125 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_initialize'
127 INTEGER :: handle, i, ic, ik, iounit, ir, ira, is, &
128 isign, j, natom, nkind, nr, ns
129 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: atype
130 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: agauge
131 INTEGER,
DIMENSION(3, 3) :: frot, krot
133 REAL(kind=
dp) :: eps_kpoint, wsum
134 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: coord, scoord
135 REAL(kind=
dp),
DIMENSION(3) :: diff, kgvec, srot
136 REAL(kind=
dp),
DIMENSION(3, 3) :: srotmat
137 REAL(kind=
dp),
DIMENSION(:),
POINTER :: wkp_full
138 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp_full
142 CALL timeset(routinen, handle)
144 cpassert(
ASSOCIATED(kpoint))
146 SELECT CASE (kpoint%kp_scheme)
151 ALLOCATE (kpoint%xkp(3, 1), kpoint%wkp(1))
152 kpoint%xkp(1:3, 1) = 0.0_dp
153 kpoint%wkp(1) = 1.0_dp
154 ALLOCATE (kpoint%kp_sym(1))
155 NULLIFY (kpoint%kp_sym(1)%kpoint_sym)
157 CASE (
"MONKHORST-PACK",
"MACDONALD")
159 IF (.NOT. kpoint%symmetry)
THEN
162 ALLOCATE (coord(3, natom), scoord(3, natom), atype(natom))
165 coord(1, i) = sin(i*0.12345_dp)
166 coord(2, i) = cos(i*0.23456_dp)
167 coord(3, i) = sin(i*0.34567_dp)
171 natom =
SIZE(particle_set)
172 ALLOCATE (scoord(3, natom), atype(natom))
174 CALL get_atomic_kind(atomic_kind=particle_set(i)%atomic_kind, kind_number=atype(i))
178 IF (kpoint%verbose)
THEN
184 ALLOCATE (kpoint%atype(natom))
187 ALLOCATE (agauge(3, natom))
189 agauge(1:3, i) = -floor(scoord(1:3, i) + 0.5_dp - kpoint%eps_geo)
192 CALL crys_sym_gen(crys_sym, scoord, atype, cell%hmat, delta=kpoint%eps_geo, iounit=iounit, &
193 use_spglib=kpoint%symmetry)
194 CALL kpoint_gen(crys_sym, kpoint%nkp_grid, symm=kpoint%symmetry, shift=kpoint%kp_shift, &
195 full_grid=kpoint%full_grid, gamma_centered=kpoint%gamma_centered, &
196 inversion_symmetry_only=kpoint%inversion_symmetry_only, &
197 use_spglib_reduction= &
200 kpoint%nkp = crys_sym%nkpoint
201 ALLOCATE (kpoint%xkp(3, kpoint%nkp), kpoint%wkp(kpoint%nkp))
202 wsum = sum(crys_sym%wkpoint)
203 DO ik = 1, kpoint%nkp
204 kpoint%xkp(1:3, ik) = crys_sym%xkpoint(1:3, ik)
205 kpoint%wkp(ik) = crys_sym%wkpoint(ik)/wsum
208 eps_kpoint = max(1.e-12_dp, 10.0_dp*kpoint%eps_geo)
214 ALLOCATE (kpoint%kp_sym(kpoint%nkp))
215 DO ik = 1, kpoint%nkp
216 NULLIFY (kpoint%kp_sym(ik)%kpoint_sym)
218 kpsym => kpoint%kp_sym(ik)%kpoint_sym
219 IF (crys_sym%nrtot > 0 .AND. .NOT. crys_sym%fullgrid .AND. &
220 crys_sym%istriz == 1 .AND. .NOT. crys_sym%inversion_only)
THEN
222 kpsym%nwght = nint(crys_sym%wkpoint(ik))
226 DO is = 1,
SIZE(crys_sym%kplink, 2)
227 IF (crys_sym%kplink(2, is) == ik)
THEN
228 DO ic = 1, crys_sym%nrtot
229 srotmat = matmul(cell%h_inv, matmul(crys_sym%rt(1:3, 1:3, ic), cell%hmat))
230 frot(1:3, 1:3) = nint(srotmat(1:3, 1:3))
231 krot(1:3, 1:3) = nint(transpose(
inv_3x3(real(frot(1:3, 1:3), kind=
dp))))
233 ir = merge(crys_sym%ibrot(ic), -crys_sym%ibrot(ic), isign == 1)
234 IF (ir == crys_sym%kpop(is)) cycle
235 kgvec(1:3) = crys_sym%kpmesh(1:3, is) - &
236 matmul(real(merge(krot(1:3, 1:3), -krot(1:3, 1:3), &
237 isign == 1), kind=
dp), &
239 diff(1:3) = kgvec(1:3) - anint(kgvec(1:3))
240 IF (all(abs(diff(1:3)) < eps_kpoint)) ns = ns + 1
245 kpsym%apply_symmetry = .true.
246 natom =
SIZE(particle_set)
247 ALLOCATE (
kpsym%rot(3, 3, ns))
248 ALLOCATE (
kpsym%xkp(3, ns))
249 ALLOCATE (
kpsym%rotp(ns))
250 ALLOCATE (
kpsym%f0(natom, ns))
251 ALLOCATE (
kpsym%fcell(3, natom, ns))
252 ALLOCATE (
kpsym%kgphase(natom, ns))
254 DO is = 1,
SIZE(crys_sym%kplink, 2)
255 IF (crys_sym%kplink(2, is) == ik)
THEN
257 ir = crys_sym%kpop(is)
259 DO ic = 1, crys_sym%nrtot
260 IF (crys_sym%ibrot(ic) == ira)
THEN
262 kpsym%rot(1:3, 1:3, nr) = crys_sym%rt(1:3, 1:3, ic)
263 srotmat = matmul(cell%h_inv, matmul(crys_sym%rt(1:3, 1:3, ic), cell%hmat))
264 frot(1:3, 1:3) = nint(srotmat(1:3, 1:3))
265 kpsym%xkp(1:3, nr) = crys_sym%kpmesh(1:3, is)
266 krot(1:3, 1:3) = nint(transpose(
inv_3x3(real(frot(1:3, 1:3), kind=
dp))))
267 IF (ir < 0) krot(1:3, 1:3) = -krot(1:3, 1:3)
268 kgvec(1:3) =
kpsym%xkp(1:3, nr) - &
269 matmul(real(krot(1:3, 1:3), kind=
dp), &
271 kgvec(1:3) = anint(kgvec(1:3))
272 kpsym%f0(1:natom, nr) = crys_sym%f0(1:natom, ic)
274 srot(1:3) = matmul(srotmat, scoord(1:3, j)) + crys_sym%vt(1:3, ic)
275 kpsym%fcell(1:3, j, nr) = &
276 nint(srot(1:3) - scoord(1:3,
kpsym%f0(j, nr))) + &
277 matmul(frot(1:3, 1:3), agauge(1:3, j)) - &
278 agauge(1:3,
kpsym%f0(j, nr))
279 kpsym%kgphase(j, nr) = dot_product(kgvec(1:3), &
281 REAL(agauge(1:3, j), kind=
dp))
286 cpassert(ic <= crys_sym%nrtot)
289 DO is = 1,
SIZE(crys_sym%kplink, 2)
290 IF (crys_sym%kplink(2, is) == ik)
THEN
291 DO ic = 1, crys_sym%nrtot
292 srotmat = matmul(cell%h_inv, matmul(crys_sym%rt(1:3, 1:3, ic), cell%hmat))
293 frot(1:3, 1:3) = nint(srotmat(1:3, 1:3))
294 krot(1:3, 1:3) = nint(transpose(
inv_3x3(real(frot(1:3, 1:3), kind=
dp))))
296 ir = merge(crys_sym%ibrot(ic), -crys_sym%ibrot(ic), isign == 1)
297 IF (ir == crys_sym%kpop(is)) cycle
298 kgvec(1:3) = crys_sym%kpmesh(1:3, is) - &
299 matmul(real(merge(krot(1:3, 1:3), -krot(1:3, 1:3), &
300 isign == 1), kind=
dp), &
302 diff(1:3) = kgvec(1:3) - anint(kgvec(1:3))
303 IF (all(abs(diff(1:3)) < eps_kpoint))
THEN
306 kpsym%rot(1:3, 1:3, nr) = crys_sym%rt(1:3, 1:3, ic)
307 kpsym%xkp(1:3, nr) = crys_sym%kpmesh(1:3, is)
308 kgvec(1:3) = anint(kgvec(1:3))
309 kpsym%f0(1:natom, nr) = crys_sym%f0(1:natom, ic)
311 srot(1:3) = matmul(srotmat, scoord(1:3, j)) + crys_sym%vt(1:3, ic)
312 kpsym%fcell(1:3, j, nr) = &
313 nint(srot(1:3) - scoord(1:3,
kpsym%f0(j, nr))) + &
314 matmul(frot(1:3, 1:3), agauge(1:3, j)) - &
315 agauge(1:3,
kpsym%f0(j, nr))
316 kpsym%kgphase(j, nr) = dot_product(kgvec(1:3), &
318 REAL(agauge(1:3, j), kind=
dp))
329 IF (kpoint%symmetry)
THEN
330 nkind = maxval(atype)
332 ALLOCATE (kpoint%kind_rotmat(ns, nkind))
335 NULLIFY (kpoint%kind_rotmat(i, j)%rmat)
338 ALLOCATE (kpoint%ibrot(ns))
339 kpoint%ibrot(1:ns) = crys_sym%ibrot(1:ns)
343 DEALLOCATE (scoord, atype)
347 NULLIFY (xkp_full, wkp_full)
348 IF (
ASSOCIATED(kpoint%xkp_input))
THEN
349 xkp_full => kpoint%xkp_input
350 wkp_full => kpoint%wkp_input
352 xkp_full => kpoint%xkp
353 wkp_full => kpoint%wkp
355 cpassert(
ASSOCIATED(xkp_full))
356 cpassert(
ASSOCIATED(wkp_full))
357 IF (.NOT.
ASSOCIATED(kpoint%xkp_input))
THEN
358 ALLOCATE (kpoint%xkp_input(3,
SIZE(wkp_full)), kpoint%wkp_input(
SIZE(wkp_full)))
359 kpoint%xkp_input(1:3, 1:
SIZE(wkp_full)) = xkp_full(1:3, 1:
SIZE(wkp_full))
360 kpoint%wkp_input(1:
SIZE(wkp_full)) = wkp_full(1:
SIZE(wkp_full))
361 xkp_full => kpoint%xkp_input
362 wkp_full => kpoint%wkp_input
364 IF (.NOT. kpoint%symmetry)
THEN
365 IF (.NOT.
ASSOCIATED(kpoint%xkp))
THEN
366 kpoint%nkp =
SIZE(wkp_full)
367 ALLOCATE (kpoint%xkp(3, kpoint%nkp), kpoint%wkp(kpoint%nkp))
368 kpoint%xkp(1:3, 1:kpoint%nkp) = xkp_full(1:3, 1:kpoint%nkp)
369 kpoint%wkp(1:kpoint%nkp) = wkp_full(1:kpoint%nkp)
372 ALLOCATE (kpoint%kp_sym(kpoint%nkp))
374 NULLIFY (kpoint%kp_sym(i)%kpoint_sym)
378 IF (kpoint%verbose)
THEN
383 natom =
SIZE(particle_set)
384 ALLOCATE (scoord(3, natom), atype(natom))
386 CALL get_atomic_kind(atomic_kind=particle_set(i)%atomic_kind, kind_number=atype(i))
389 ALLOCATE (kpoint%atype(natom))
391 ALLOCATE (agauge(3, natom))
393 agauge(1:3, i) = -floor(scoord(1:3, i) + 0.5_dp - kpoint%eps_geo)
396 CALL crys_sym_gen(crys_sym, scoord, atype, cell%hmat, delta=kpoint%eps_geo, iounit=iounit, &
400 full_grid=kpoint%full_grid, &
401 inversion_symmetry_only=kpoint%inversion_symmetry_only, &
402 use_spglib_reduction= &
405 IF (
ASSOCIATED(kpoint%xkp))
THEN
406 DEALLOCATE (kpoint%xkp)
409 IF (
ASSOCIATED(kpoint%wkp))
THEN
410 DEALLOCATE (kpoint%wkp)
413 kpoint%nkp = crys_sym%nkpoint
414 ALLOCATE (kpoint%xkp(3, kpoint%nkp), kpoint%wkp(kpoint%nkp))
415 wsum = sum(crys_sym%wkpoint)
416 DO ik = 1, kpoint%nkp
417 kpoint%xkp(1:3, ik) = crys_sym%xkpoint(1:3, ik)
418 kpoint%wkp(ik) = crys_sym%wkpoint(ik)/wsum
421 eps_kpoint = max(1.e-12_dp, 10.0_dp*kpoint%eps_geo)
425 ALLOCATE (kpoint%kp_sym(kpoint%nkp))
426 DO ik = 1, kpoint%nkp
427 NULLIFY (kpoint%kp_sym(ik)%kpoint_sym)
429 kpsym => kpoint%kp_sym(ik)%kpoint_sym
430 IF (crys_sym%nrtot > 0 .AND. .NOT. crys_sym%fullgrid .AND. &
431 crys_sym%istriz == 1 .AND. .NOT. crys_sym%inversion_only)
THEN
432 kpsym%nwght = nint(crys_sym%wkpoint(ik))
435 DO is = 1,
SIZE(crys_sym%kplink, 2)
436 IF (crys_sym%kplink(2, is) == ik)
THEN
437 DO ic = 1, crys_sym%nrtot
438 srotmat = matmul(cell%h_inv, matmul(crys_sym%rt(1:3, 1:3, ic), cell%hmat))
439 frot(1:3, 1:3) = nint(srotmat(1:3, 1:3))
440 krot(1:3, 1:3) = nint(transpose(
inv_3x3(real(frot(1:3, 1:3), kind=
dp))))
442 ir = merge(crys_sym%ibrot(ic), -crys_sym%ibrot(ic), isign == 1)
443 IF (ir == crys_sym%kpop(is)) cycle
444 kgvec(1:3) = crys_sym%kpmesh(1:3, is) - &
445 matmul(real(merge(krot(1:3, 1:3), -krot(1:3, 1:3), &
446 isign == 1), kind=
dp), &
448 diff(1:3) = kgvec(1:3) - anint(kgvec(1:3))
449 IF (all(abs(diff(1:3)) < eps_kpoint)) ns = ns + 1
454 kpsym%apply_symmetry = .true.
455 ALLOCATE (
kpsym%rot(3, 3, ns))
456 ALLOCATE (
kpsym%xkp(3, ns))
457 ALLOCATE (
kpsym%rotp(ns))
458 ALLOCATE (
kpsym%f0(natom, ns))
459 ALLOCATE (
kpsym%fcell(3, natom, ns))
460 ALLOCATE (
kpsym%kgphase(natom, ns))
462 DO is = 1,
SIZE(crys_sym%kplink, 2)
463 IF (crys_sym%kplink(2, is) == ik)
THEN
465 ir = crys_sym%kpop(is)
467 DO ic = 1, crys_sym%nrtot
468 IF (crys_sym%ibrot(ic) == ira)
THEN
470 kpsym%rot(1:3, 1:3, nr) = crys_sym%rt(1:3, 1:3, ic)
471 srotmat = matmul(cell%h_inv, matmul(crys_sym%rt(1:3, 1:3, ic), cell%hmat))
472 frot(1:3, 1:3) = nint(srotmat(1:3, 1:3))
473 kpsym%xkp(1:3, nr) = crys_sym%kpmesh(1:3, is)
474 krot(1:3, 1:3) = nint(transpose(
inv_3x3(real(frot(1:3, 1:3), kind=
dp))))
475 IF (ir < 0) krot(1:3, 1:3) = -krot(1:3, 1:3)
476 kgvec(1:3) =
kpsym%xkp(1:3, nr) - &
477 matmul(real(krot(1:3, 1:3), kind=
dp), &
479 kgvec(1:3) = anint(kgvec(1:3))
480 kpsym%f0(1:natom, nr) = crys_sym%f0(1:natom, ic)
482 srot(1:3) = matmul(srotmat, scoord(1:3, j)) + crys_sym%vt(1:3, ic)
483 kpsym%fcell(1:3, j, nr) = &
484 nint(srot(1:3) - scoord(1:3,
kpsym%f0(j, nr))) + &
485 matmul(frot(1:3, 1:3), agauge(1:3, j)) - &
486 agauge(1:3,
kpsym%f0(j, nr))
487 kpsym%kgphase(j, nr) = dot_product(kgvec(1:3), &
489 REAL(agauge(1:3, j), kind=
dp))
494 cpassert(ic <= crys_sym%nrtot)
497 DO is = 1,
SIZE(crys_sym%kplink, 2)
498 IF (crys_sym%kplink(2, is) == ik)
THEN
499 DO ic = 1, crys_sym%nrtot
500 srotmat = matmul(cell%h_inv, matmul(crys_sym%rt(1:3, 1:3, ic), cell%hmat))
501 frot(1:3, 1:3) = nint(srotmat(1:3, 1:3))
502 krot(1:3, 1:3) = nint(transpose(
inv_3x3(real(frot(1:3, 1:3), kind=
dp))))
504 ir = merge(crys_sym%ibrot(ic), -crys_sym%ibrot(ic), isign == 1)
505 IF (ir == crys_sym%kpop(is)) cycle
506 kgvec(1:3) = crys_sym%kpmesh(1:3, is) - &
507 matmul(real(merge(krot(1:3, 1:3), -krot(1:3, 1:3), &
508 isign == 1), kind=
dp), &
510 diff(1:3) = kgvec(1:3) - anint(kgvec(1:3))
511 IF (all(abs(diff(1:3)) < eps_kpoint))
THEN
514 kpsym%rot(1:3, 1:3, nr) = crys_sym%rt(1:3, 1:3, ic)
515 kpsym%xkp(1:3, nr) = crys_sym%kpmesh(1:3, is)
516 kgvec(1:3) = anint(kgvec(1:3))
517 kpsym%f0(1:natom, nr) = crys_sym%f0(1:natom, ic)
519 srot(1:3) = matmul(srotmat, scoord(1:3, j)) + crys_sym%vt(1:3, ic)
520 kpsym%fcell(1:3, j, nr) = &
521 nint(srot(1:3) - scoord(1:3,
kpsym%f0(j, nr))) + &
522 matmul(frot(1:3, 1:3), agauge(1:3, j)) - &
523 agauge(1:3,
kpsym%f0(j, nr))
524 kpsym%kgphase(j, nr) = dot_product(kgvec(1:3), &
526 REAL(agauge(1:3, j), kind=
dp))
537 nkind = maxval(atype)
539 ALLOCATE (kpoint%kind_rotmat(ns, nkind))
542 NULLIFY (kpoint%kind_rotmat(i, j)%rmat)
545 ALLOCATE (kpoint%ibrot(ns))
546 kpoint%ibrot(1:ns) = crys_sym%ibrot(1:ns)
549 DEALLOCATE (scoord, atype)
557 SELECT CASE (kpoint%kp_scheme)
561 cpassert(kpoint%nkp == 1)
562 cpassert(sum(abs(kpoint%xkp)) <= 1.e-12_dp)
563 cpassert(kpoint%wkp(1) == 1.0_dp)
564 cpassert(.NOT. kpoint%symmetry)
566 cpassert(kpoint%nkp >= 1)
567 CASE (
"MONKHORST-PACK",
"MACDONALD")
568 cpassert(kpoint%nkp >= 1)
570 IF (kpoint%use_real_wfn)
THEN
572 ikloop:
DO ik = 1, kpoint%nkp
574 spez = (kpoint%xkp(i, ik) == 0.0_dp .OR. kpoint%xkp(i, ik) == 0.5_dp)
575 IF (.NOT. spez)
EXIT ikloop
580 CALL cp_warn(__location__, &
581 "A calculation using real wavefunctions is requested. "// &
582 "We could not determine if the symmetry of the system allows real wavefunctions. ")
586 CALL timestop(handle)
602 LOGICAL,
INTENT(IN),
OPTIONAL :: with_aux_fit
604 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_env_initialize'
606 INTEGER :: handle, igr, ik, ikk, ngr, niogrp, nkp, &
607 nkp_grp, nkp_loc, npe, unit_nr
608 INTEGER,
DIMENSION(2) :: dims, pos
615 CALL timeset(routinen, handle)
617 IF (
PRESENT(with_aux_fit))
THEN
618 aux_fit = with_aux_fit
623 kpoint%para_env => para_env
624 CALL kpoint%para_env%retain()
625 kpoint%blacs_env_all => blacs_env
626 CALL kpoint%blacs_env_all%retain()
628 cpassert(.NOT.
ASSOCIATED(kpoint%kp_env))
630 cpassert(.NOT.
ASSOCIATED(kpoint%kp_aux_env))
633 NULLIFY (kp_env, kp_aux_env)
635 npe = para_env%num_pe
638 ALLOCATE (kp_env(nkp))
640 NULLIFY (kp_env(ik)%kpoint_env)
642 kp => kp_env(ik)%kpoint_env
644 kp%wkp = kpoint%wkp(ik)
645 kp%xkp(1:3) = kpoint%xkp(1:3, ik)
648 kpoint%kp_env => kp_env
651 ALLOCATE (kp_aux_env(nkp))
653 NULLIFY (kp_aux_env(ik)%kpoint_env)
655 kp => kp_aux_env(ik)%kpoint_env
657 kp%wkp = kpoint%wkp(ik)
658 kp%xkp(1:3) = kpoint%xkp(1:3, ik)
662 kpoint%kp_aux_env => kp_aux_env
665 ALLOCATE (kpoint%kp_dist(2, 1))
666 kpoint%kp_dist(1, 1) = 1
667 kpoint%kp_dist(2, 1) = nkp
668 kpoint%kp_range(1) = 1
669 kpoint%kp_range(2) = nkp
672 kpoint%para_env_kp => para_env
673 CALL kpoint%para_env_kp%retain()
674 kpoint%para_env_inter_kp => para_env
675 CALL kpoint%para_env_inter_kp%retain()
676 kpoint%iogrp = .true.
677 kpoint%nkp_groups = 1
679 IF (kpoint%parallel_group_size == -1)
THEN
684 IF (mod(npe, igr) /= 0) cycle
686 IF (mod(nkp, nkp_grp) /= 0) cycle
689 ELSE IF (kpoint%parallel_group_size == 0)
THEN
692 ELSE IF (kpoint%parallel_group_size > 0)
THEN
693 ngr = min(kpoint%parallel_group_size, npe)
701 cpassert(mod(nkp, nkp_grp) == 0)
702 nkp_loc = nkp/nkp_grp
704 IF ((dims(1)*dims(2) /= npe))
THEN
705 cpabort(
"Number of processors is not divisible by the kpoint group size.")
709 CALL comm_cart%create(comm_old=para_env, ndims=2, dims=dims)
710 pos = comm_cart%mepos_cart
711 ALLOCATE (para_env_kp)
712 CALL para_env_kp%from_split(comm_cart, pos(2))
713 ALLOCATE (para_env_inter_kp)
714 CALL para_env_inter_kp%from_split(comm_cart, pos(1))
715 CALL comm_cart%free()
718 IF (para_env%is_source()) niogrp = 1
719 CALL para_env_kp%sum(niogrp)
720 kpoint%iogrp = (niogrp == 1)
723 kpoint%para_env_kp => para_env_kp
724 kpoint%para_env_inter_kp => para_env_inter_kp
727 ALLOCATE (kpoint%kp_dist(2, nkp_grp))
729 kpoint%kp_dist(1:2, igr) =
get_limit(nkp, nkp_grp, igr - 1)
732 kpoint%kp_range(1:2) = kpoint%kp_dist(1:2, para_env_inter_kp%mepos + 1)
734 ALLOCATE (kp_env(nkp_loc))
736 NULLIFY (kp_env(ik)%kpoint_env)
737 ikk = kpoint%kp_range(1) + ik - 1
739 kp => kp_env(ik)%kpoint_env
741 kp%wkp = kpoint%wkp(ikk)
742 kp%xkp(1:3) = kpoint%xkp(1:3, ikk)
743 kp%is_local = (ngr == 1)
745 kpoint%kp_env => kp_env
748 ALLOCATE (kp_aux_env(nkp_loc))
750 NULLIFY (kp_aux_env(ik)%kpoint_env)
751 ikk = kpoint%kp_range(1) + ik - 1
753 kp => kp_aux_env(ik)%kpoint_env
755 kp%wkp = kpoint%wkp(ikk)
756 kp%xkp(1:3) = kpoint%xkp(1:3, ikk)
757 kp%is_local = (ngr == 1)
759 kpoint%kp_aux_env => kp_aux_env
764 IF (unit_nr > 0 .AND. kpoint%verbose)
THEN
766 WRITE (unit_nr, fmt=
"(T2,A,T71,I10)")
"KPOINTS| Number of kpoint groups ", nkp_grp
767 WRITE (unit_nr, fmt=
"(T2,A,T71,I10)")
"KPOINTS| Size of each kpoint group", ngr
768 WRITE (unit_nr, fmt=
"(T2,A,T71,I10)")
"KPOINTS| Number of kpoints per group", nkp_loc
770 kpoint%nkp_groups = nkp_grp
774 CALL timestop(handle)
788 TYPE(
mo_set_type),
DIMENSION(:),
INTENT(INOUT) :: mos
789 INTEGER,
INTENT(IN),
OPTIONAL :: added_mos
790 LOGICAL,
OPTIONAL :: for_aux_fit
792 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_initialize_mos'
794 INTEGER :: handle, ic, ik, is, nadd, nao, nc, &
795 nelectron, nkp_loc, nmo, nmorig(2), &
798 REAL(kind=
dp) :: flexible_electron_count, maxocc, n_el_f
806 CALL timeset(routinen, handle)
808 IF (
PRESENT(for_aux_fit))
THEN
809 aux_fit = for_aux_fit
814 cpassert(
ASSOCIATED(kpoint))
816 IF (.true. .OR.
ASSOCIATED(mos(1)%mo_coeff))
THEN
818 cpassert(
ASSOCIATED(kpoint%kp_aux_env))
821 IF (
PRESENT(added_mos))
THEN
827 IF (kpoint%use_real_wfn)
THEN
833 nkp_loc = kpoint%kp_range(2) - kpoint%kp_range(1) + 1
834 IF (nkp_loc > 0)
THEN
836 cpassert(
SIZE(kpoint%kp_aux_env) == nkp_loc)
838 cpassert(
SIZE(kpoint%kp_env) == nkp_loc)
843 kp => kpoint%kp_aux_env(ik)%kpoint_env
845 kp => kpoint%kp_env(ik)%kpoint_env
847 ALLOCATE (kp%mos(nc, nspin))
849 CALL get_mo_set(mos(is), nao=nao, nmo=nmo, nelectron=nelectron, &
850 n_el_f=n_el_f, maxocc=maxocc, flexible_electron_count=flexible_electron_count)
851 nmo = min(nao, nmo + nadd)
853 CALL allocate_mo_set(kp%mos(ic, is), nao, nmo, nelectron, n_el_f, maxocc, &
854 flexible_electron_count)
864 IF (
ASSOCIATED(kpoint%blacs_env))
THEN
865 blacs_env => kpoint%blacs_env
868 kpoint%blacs_env => blacs_env
874 nmo = min(nao, nmorig(is) + nadd)
882 blacs_env=blacs_env, para_env=kpoint%para_env_kp)
885 kpoint%mpools_aux_fit => mpools
887 kpoint%mpools => mpools
896 CALL mpools_get(mpools, ao_ao_fm_pools=ao_ao_fm_pools)
902 kp => kpoint%kp_aux_env(ik)%kpoint_env
904 kp => kpoint%kp_env(ik)%kpoint_env
908 ALLOCATE (kp%pmat(nc, nspin))
916 ALLOCATE (kp%wmat(nc, nspin))
930 CALL timestop(handle)
941 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_initialize_mo_set'
943 INTEGER :: handle, ic, ik, ikk, ispin
946 TYPE(
mo_set_type),
DIMENSION(:, :),
POINTER :: moskp
948 CALL timeset(routinen, handle)
950 DO ik = 1,
SIZE(kpoint%kp_env)
951 CALL mpools_get(kpoint%mpools, ao_mo_fm_pools=ao_mo_fm_pools)
952 moskp => kpoint%kp_env(ik)%kpoint_env%mos
953 ikk = kpoint%kp_range(1) + ik - 1
954 cpassert(
ASSOCIATED(moskp))
955 DO ispin = 1,
SIZE(moskp, 2)
956 DO ic = 1,
SIZE(moskp, 1)
957 CALL get_mo_set(moskp(ic, ispin), mo_coeff=mo_coeff)
958 IF (.NOT.
ASSOCIATED(mo_coeff))
THEN
960 fm_pool=ao_mo_fm_pools(ispin)%pool, name=
"kpoints")
966 CALL timestop(handle)
984 INTEGER,
INTENT(OUT) :: nimages
986 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_init_cell_index'
988 INTEGER :: handle, i1, i2, i3, ic, icount, it, &
990 INTEGER,
DIMENSION(3) :: cell, itm
991 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell,
list
992 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index, cti
995 DIMENSION(:),
POINTER :: nl_iterator
997 NULLIFY (cell_to_index, index_to_cell)
999 CALL timeset(routinen, handle)
1001 cpassert(
ASSOCIATED(kpoint))
1003 ALLOCATE (
list(3, 125))
1013 IF (cell(1) ==
list(1, ic) .AND. cell(2) ==
list(2, ic) .AND. &
1014 cell(3) ==
list(3, ic))
THEN
1021 IF (icount >
SIZE(
list, 2))
THEN
1024 list(1:3, icount) = cell(1:3)
1030 itm(1) = maxval(abs(
list(1, 1:icount)))
1031 itm(2) = maxval(abs(
list(2, 1:icount)))
1032 itm(3) = maxval(abs(
list(3, 1:icount)))
1033 CALL para_env%max(itm)
1034 it = maxval(itm(1:3))
1035 IF (
ASSOCIATED(kpoint%cell_to_index))
THEN
1036 DEALLOCATE (kpoint%cell_to_index)
1038 ALLOCATE (kpoint%cell_to_index(-itm(1):itm(1), -itm(2):itm(2), -itm(3):itm(3)))
1039 cell_to_index => kpoint%cell_to_index
1040 cti => cell_to_index
1046 cti(i1, i2, i3) = ic
1048 CALL para_env%sum(cti)
1050 DO i1 = -itm(1), itm(1)
1051 DO i2 = -itm(2), itm(2)
1052 DO i3 = -itm(3), itm(3)
1053 IF (cti(i1, i2, i3) == 0)
THEN
1054 cti(i1, i2, i3) = 1000000
1057 cti(i1, i2, i3) = (abs(i1) + abs(i2) + abs(i3))*1000 + abs(i3)*100 + abs(i2)*10 + abs(i1)
1058 cti(i1, i2, i3) = cti(i1, i2, i3) + (i1 + i2 + i3)
1064 IF (
ASSOCIATED(kpoint%index_to_cell))
THEN
1065 DEALLOCATE (kpoint%index_to_cell)
1067 ALLOCATE (kpoint%index_to_cell(3, ncount))
1068 index_to_cell => kpoint%index_to_cell
1071 i1 = cell(1) - 1 - itm(1)
1072 i2 = cell(2) - 1 - itm(2)
1073 i3 = cell(3) - 1 - itm(3)
1074 cti(i1, i2, i3) = 1000000
1075 index_to_cell(1, ic) = i1
1076 index_to_cell(2, ic) = i2
1077 index_to_cell(3, ic) = i3
1081 i1 = index_to_cell(1, ic)
1082 i2 = index_to_cell(2, ic)
1083 i3 = index_to_cell(3, ic)
1084 cti(i1, i2, i3) = ic
1088 kpoint%sab_nl => sab_nl
1091 nimages =
SIZE(index_to_cell, 2)
1095 CALL timestop(handle)
1112 xkp, cell_to_index, sab_nl, is_complex, rs_sign)
1117 INTEGER,
INTENT(IN) :: ispin
1118 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: xkp
1119 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1122 LOGICAL,
INTENT(IN),
OPTIONAL :: is_complex
1123 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: rs_sign
1125 CHARACTER(LEN=*),
PARAMETER :: routinen =
'rskp_transform'
1127 INTEGER :: handle, iatom, ic, icol, irow, jatom, &
1129 INTEGER,
DIMENSION(3) :: cell
1130 LOGICAL :: do_symmetric, found, my_complex, &
1132 REAL(kind=
dp) :: arg, coskl, fsign, fsym, sinkl
1133 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: cblock, rblock, rsblock
1135 DIMENSION(:),
POINTER :: nl_iterator
1137 CALL timeset(routinen, handle)
1139 my_complex = .false.
1140 IF (
PRESENT(is_complex)) my_complex = is_complex
1143 IF (
PRESENT(rs_sign)) fsign = rs_sign
1145 wfn_real_only = .true.
1146 IF (
PRESENT(cmatrix)) wfn_real_only = .false.
1148 nimg =
SIZE(rsmat, 2)
1161 IF (do_symmetric .AND. (iatom > jatom))
THEN
1167 ic = cell_to_index(cell(1), cell(2), cell(3))
1168 IF (ic < 1 .OR. ic > nimg) cycle
1170 arg = real(cell(1),
dp)*xkp(1) + real(cell(2),
dp)*xkp(2) + real(cell(3),
dp)*xkp(3)
1171 IF (my_complex)
THEN
1172 coskl = fsign*fsym*cos(
twopi*arg)
1173 sinkl = fsign*sin(
twopi*arg)
1175 coskl = fsign*cos(
twopi*arg)
1176 sinkl = fsign*fsym*sin(
twopi*arg)
1180 block=rsblock, found=found)
1181 IF (.NOT. found) cycle
1183 IF (wfn_real_only)
THEN
1185 block=rblock, found=found)
1186 IF (.NOT. found) cycle
1187 rblock = rblock + coskl*rsblock
1190 block=rblock, found=found)
1191 IF (.NOT. found) cycle
1193 block=cblock, found=found)
1194 IF (.NOT. found) cycle
1195 rblock = rblock + coskl*rsblock
1196 cblock = cblock + sinkl*rsblock
1202 CALL timestop(handle)
1219 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_set_mo_occupation'
1221 INTEGER :: handle, ik, ikpgr, ispin, kplocal, nao, &
1222 nb, ncol_global, ne_a, ne_b, &
1223 nelectron, nkp, nmo, nrow_global, nspin
1224 INTEGER,
DIMENSION(2) :: kp_range
1225 REAL(kind=
dp) :: kts, mu, mus(2), nel
1226 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: smatrix
1227 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: weig, wocc
1228 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :, :) :: icoeff, rcoeff
1229 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues, occupation, wkp
1235 CALL timeset(routinen, handle)
1239 kp => kpoint%kp_env(1)%kpoint_env
1240 nspin =
SIZE(kp%mos, 2)
1241 mo_set => kp%mos(1, 1)
1242 CALL get_mo_set(mo_set, nmo=nmo, nao=nao, nelectron=nelectron)
1244 IF (nspin == 2)
THEN
1245 CALL get_mo_set(kp%mos(1, 2), nmo=nb, nelectron=ne_b)
1248 ALLOCATE (weig(nmo, nkp, nspin), wocc(nmo, nkp, nspin))
1251 IF (
PRESENT(probe))
THEN
1252 ALLOCATE (rcoeff(nao, nmo, nkp, nspin), icoeff(nao, nmo, nkp, nspin))
1257 kplocal = kp_range(2) - kp_range(1) + 1
1258 DO ikpgr = 1, kplocal
1259 ik = kp_range(1) + ikpgr - 1
1260 kp => kpoint%kp_env(ikpgr)%kpoint_env
1262 mo_set => kp%mos(1, ispin)
1263 CALL get_mo_set(mo_set, eigenvalues=eigenvalues)
1264 weig(1:nmo, ik, ispin) = eigenvalues(1:nmo)
1265 IF (
PRESENT(probe))
THEN
1268 nrow_global=nrow_global, &
1269 ncol_global=ncol_global)
1270 ALLOCATE (smatrix(nrow_global, ncol_global))
1273 rcoeff(1:nao, 1:nmo, ik, ispin) = smatrix(1:nrow_global, 1:ncol_global)
1275 DEALLOCATE (smatrix)
1277 mo_set => kp%mos(2, ispin)
1281 nrow_global=nrow_global, &
1282 ncol_global=ncol_global)
1283 ALLOCATE (smatrix(nrow_global, ncol_global))
1286 icoeff(1:nao, 1:nmo, ik, ispin) = smatrix(1:nrow_global, 1:ncol_global)
1288 mo_set => kp%mos(1, ispin)
1290 DEALLOCATE (smatrix)
1295 CALL para_env_inter_kp%sum(weig)
1297 IF (
PRESENT(probe))
THEN
1298 CALL para_env_inter_kp%sum(rcoeff)
1299 CALL para_env_inter_kp%sum(icoeff)
1305 IF (
PRESENT(probe))
THEN
1306 smear%do_smear = .false.
1308 IF (nspin == 1)
THEN
1309 nel = real(nelectron, kind=
dp)
1310 CALL probe_occupancy_kp(wocc(:, :, :), mus(1), kts, weig(:, :, :), rcoeff(:, :, :, :), icoeff(:, :, :, :), 2.0d0, &
1313 nel = real(ne_a, kind=
dp) + real(ne_b, kind=
dp)
1314 CALL probe_occupancy_kp(wocc(:, :, :), mu, kts, weig(:, :, :), rcoeff(:, :, :, :), icoeff(:, :, :, :), 1.0d0, &
1320 DO ikpgr = 1, kplocal
1321 ik = kp_range(1) + ikpgr - 1
1322 kp => kpoint%kp_env(ikpgr)%kpoint_env
1324 mo_set => kp%mos(1, ispin)
1325 CALL get_mo_set(mo_set, eigenvalues=eigenvalues, occupation_numbers=occupation)
1326 eigenvalues(1:nmo) = weig(1:nmo, ik, ispin)
1327 occupation(1:nmo) = wocc(1:nmo, ik, ispin)
1329 mo_set%mu = mus(ispin)
1334 nrow_global=nrow_global, &
1335 ncol_global=ncol_global)
1336 ALLOCATE (smatrix(nrow_global, ncol_global))
1339 smatrix(1:nrow_global, 1:ncol_global) = rcoeff(1:nao, 1:nmo, ik, ispin)
1340 DEALLOCATE (smatrix)
1342 mo_set => kp%mos(2, ispin)
1347 nrow_global=nrow_global, &
1348 ncol_global=ncol_global)
1349 ALLOCATE (smatrix(nrow_global, ncol_global))
1352 smatrix(1:nrow_global, 1:ncol_global) = icoeff(1:nao, 1:nmo, ik, ispin)
1353 DEALLOCATE (smatrix)
1355 mo_set => kp%mos(1, ispin)
1360 DEALLOCATE (weig, wocc, rcoeff, icoeff)
1364 IF (
PRESENT(probe) .EQV. .false.)
THEN
1365 IF (smear%do_smear)
THEN
1366 SELECT CASE (smear%method)
1369 IF (nspin == 1)
THEN
1370 nel = real(nelectron, kind=
dp)
1371 CALL smearkp(wocc(:, :, 1), mus(1), kts, weig(:, :, 1), nel, wkp, &
1373 ELSE IF (smear%fixed_mag_mom > 0.0_dp)
THEN
1374 nel = real(ne_a, kind=
dp)
1375 CALL smearkp(wocc(:, :, 1), mus(1), kts, weig(:, :, 1), nel, wkp, &
1377 nel = real(ne_b, kind=
dp)
1378 CALL smearkp(wocc(:, :, 2), mus(2), kts, weig(:, :, 2), nel, wkp, &
1381 nel = real(ne_a, kind=
dp) + real(ne_b, kind=
dp)
1382 CALL smearkp2(wocc(:, :, :), mu, kts, weig(:, :, :), nel, wkp, &
1388 IF (nspin == 1)
THEN
1389 nel = real(nelectron, kind=
dp)
1390 CALL smearkp(wocc(:, :, 1), mus(1), kts, weig(:, :, 1), nel, wkp, &
1391 smear%smearing_width, 2.0_dp, smear%method)
1392 ELSE IF (smear%fixed_mag_mom > 0.0_dp)
THEN
1393 nel = real(ne_a, kind=
dp)
1394 CALL smearkp(wocc(:, :, 1), mus(1), kts, weig(:, :, 1), nel, wkp, &
1395 smear%smearing_width, 1.0_dp, smear%method)
1396 nel = real(ne_b, kind=
dp)
1397 CALL smearkp(wocc(:, :, 2), mus(2), kts, weig(:, :, 2), nel, wkp, &
1398 smear%smearing_width, 1.0_dp, smear%method)
1400 nel = real(ne_a, kind=
dp) + real(ne_b, kind=
dp)
1401 CALL smearkp2(wocc(:, :, :), mu, kts, weig(:, :, :), nel, wkp, &
1402 smear%smearing_width, smear%method)
1407 cpabort(
"kpoints: Selected smearing not (yet) supported")
1411 IF (nspin == 1)
THEN
1412 nel = real(nelectron, kind=
dp)
1413 CALL smearkp(wocc(:, :, 1), mus(1), kts, weig(:, :, 1), nel, wkp, &
1416 nel = real(ne_a, kind=
dp)
1417 CALL smearkp(wocc(:, :, 1), mus(1), kts, weig(:, :, 1), nel, wkp, &
1419 nel = real(ne_b, kind=
dp)
1420 CALL smearkp(wocc(:, :, 2), mus(2), kts, weig(:, :, 2), nel, wkp, &
1424 DO ikpgr = 1, kplocal
1425 ik = kp_range(1) + ikpgr - 1
1426 kp => kpoint%kp_env(ikpgr)%kpoint_env
1428 mo_set => kp%mos(1, ispin)
1429 CALL get_mo_set(mo_set, eigenvalues=eigenvalues, occupation_numbers=occupation)
1430 eigenvalues(1:nmo) = weig(1:nmo, ik, ispin)
1431 occupation(1:nmo) = wocc(1:nmo, ik, ispin)
1433 mo_set%mu = mus(ispin)
1437 DEALLOCATE (weig, wocc)
1441 CALL timestop(handle)
1454 LOGICAL,
OPTIONAL :: energy_weighted, for_aux_fit
1456 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_density_matrices'
1458 INTEGER :: handle, ikpgr, ispin, kplocal, nao, nmo, &
1460 INTEGER,
DIMENSION(2) :: kp_range
1461 LOGICAL :: aux_fit, wtype
1462 REAL(kind=
dp),
DIMENSION(:),
POINTER :: eigenvalues, occupation
1465 TYPE(
cp_fm_type),
POINTER :: cpmat, pmat, rpmat
1469 CALL timeset(routinen, handle)
1471 IF (
PRESENT(energy_weighted))
THEN
1472 wtype = energy_weighted
1478 IF (
PRESENT(for_aux_fit))
THEN
1479 aux_fit = for_aux_fit
1485 cpassert(
ASSOCIATED(kpoint%kp_aux_env))
1490 mo_set => kpoint%kp_aux_env(1)%kpoint_env%mos(1, 1)
1492 mo_set => kpoint%kp_env(1)%kpoint_env%mos(1, 1)
1495 CALL cp_fm_get_info(mo_set%mo_coeff, matrix_struct=matrix_struct)
1499 kplocal = kp_range(2) - kp_range(1) + 1
1500 DO ikpgr = 1, kplocal
1502 kp => kpoint%kp_aux_env(ikpgr)%kpoint_env
1504 kp => kpoint%kp_env(ikpgr)%kpoint_env
1506 nspin =
SIZE(kp%mos, 2)
1508 mo_set => kp%mos(1, ispin)
1510 CALL get_mo_set(mo_set, eigenvalues=eigenvalues)
1512 IF (kpoint%use_real_wfn)
THEN
1514 pmat => kp%wmat(1, ispin)
1516 pmat => kp%pmat(1, ispin)
1518 CALL get_mo_set(mo_set, occupation_numbers=occupation)
1524 CALL parallel_gemm(
"N",
"T", nao, nao, nmo, 1.0_dp, mo_set%mo_coeff, fwork, 0.0_dp, pmat)
1527 rpmat => kp%wmat(1, ispin)
1528 cpmat => kp%wmat(2, ispin)
1530 rpmat => kp%pmat(1, ispin)
1531 cpmat => kp%pmat(2, ispin)
1533 CALL get_mo_set(mo_set, occupation_numbers=occupation)
1540 CALL parallel_gemm(
"N",
"T", nao, nao, nmo, 1.0_dp, mo_set%mo_coeff, fwork, 0.0_dp, rpmat)
1541 mo_set => kp%mos(2, ispin)
1543 CALL parallel_gemm(
"N",
"T", nao, nao, nmo, 1.0_dp, mo_set%mo_coeff, fwork, 0.0_dp, cpmat)
1545 CALL parallel_gemm(
"N",
"T", nao, nao, nmo, -1.0_dp, fwork, mo_set%mo_coeff, 1.0_dp, cpmat)
1552 CALL parallel_gemm(
"N",
"T", nao, nao, nmo, 1.0_dp, mo_set%mo_coeff, fwork, 1.0_dp, rpmat)
1559 CALL timestop(handle)
1574 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(INOUT) :: pmat_diag
1576 CHARACTER(LEN=*),
PARAMETER :: routinen =
'lowdin_kp_trans'
1577 COMPLEX(KIND=dp),
PARAMETER :: cone = (1.0_dp, 0.0_dp), &
1578 czero = (0.0_dp, 0.0_dp)
1580 INTEGER :: handle, ikpgr, ispin, kplocal, nao, nspin
1581 INTEGER,
DIMENSION(2) :: kp_range
1582 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: dele
1587 TYPE(
cp_fm_type),
POINTER :: cpmat, pmat, rpmat, shalf
1591 CALL timeset(routinen, handle)
1593 nspin =
SIZE(pmat_diag, 2)
1598 matrix_struct=matrix_struct, nrow_global=nao)
1599 IF (kpoint%use_real_wfn)
THEN
1600 CALL cp_fm_create(f1work, matrix_struct, nrow=nao, ncol=nao)
1601 CALL cp_fm_create(f2work, matrix_struct, nrow=nao, ncol=nao)
1603 CALL cp_fm_create(f2work, matrix_struct, nrow=nao, ncol=nao)
1604 CALL cp_cfm_create(cf1work, matrix_struct, nrow=nao, ncol=nao)
1605 CALL cp_cfm_create(cf2work, matrix_struct, nrow=nao, ncol=nao)
1607 ALLOCATE (dele(nao))
1610 kplocal = kp_range(2) - kp_range(1) + 1
1611 DO ikpgr = 1, kplocal
1612 kp => kpoint%kp_env(ikpgr)%kpoint_env
1614 IF (kpoint%use_real_wfn)
THEN
1615 pmat => kp%pmat(1, ispin)
1617 CALL parallel_gemm(
"N",
"N", nao, nao, nao, 1.0_dp, pmat, shalf, 0.0_dp, f1work)
1618 CALL parallel_gemm(
"N",
"N", nao, nao, nao, 1.0_dp, shalf, f1work, 0.0_dp, f2work)
1620 rpmat => kp%pmat(1, ispin)
1621 cpmat => kp%pmat(2, ispin)
1624 CALL parallel_gemm(
"N",
"N", nao, nao, nao, cone, cf1work, cshalf, czero, cf2work)
1625 CALL parallel_gemm(
"N",
"N", nao, nao, nao, cone, cshalf, cf2work, czero, cf1work)
1629 pmat_diag(1:nao, ispin) = pmat_diag(1:nao, ispin) + kp%wkp*dele(1:nao)
1634 CALL para_env_inter_kp%sum(pmat_diag)
1636 IF (kpoint%use_real_wfn)
THEN
1646 CALL timestop(handle)
1666 LOGICAL,
INTENT(IN) :: wtype
1670 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(IN) :: fmwork
1671 LOGICAL,
OPTIONAL :: for_aux_fit
1672 TYPE(
cp_fm_type),
DIMENSION(:, :, :),
INTENT(IN), &
1673 OPTIONAL :: pmat_ext
1675 CHARACTER(LEN=*),
PARAMETER :: routinen =
'kpoint_density_transform'
1677 INTEGER :: handle, ic, ik, ikk, indx, ir, ira, is, &
1678 ispin, jr, nc, nimg, nkp, nspin
1679 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1680 LOGICAL :: aux_fit, do_ext, do_symmetric, my_kpgrp, &
1681 real_only, reverse_phase
1682 REAL(kind=
dp) :: wkpx
1683 REAL(kind=
dp),
DIMENSION(:),
POINTER :: wkp
1684 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: xkp
1687 TYPE(
dbcsr_type),
POINTER :: cpmat, rpmat, scpmat, srpmat
1693 CALL timeset(routinen, handle)
1697 IF (
PRESENT(for_aux_fit))
THEN
1698 aux_fit = for_aux_fit
1704 IF (
PRESENT(pmat_ext)) do_ext = .true.
1707 cpassert(
ASSOCIATED(kpoint%kp_aux_env))
1713 matrix_type=merge(dbcsr_type_symmetric, dbcsr_type_no_symmetry, do_symmetric))
1718 matrix_type=merge(dbcsr_type_antisymmetric, dbcsr_type_no_symmetry, do_symmetric))
1721 IF (.NOT. kpoint%full_grid)
THEN
1733 cell_to_index=cell_to_index)
1736 kp => kpoint%kp_aux_env(1)%kpoint_env
1738 kp => kpoint%kp_env(1)%kpoint_env
1740 nspin =
SIZE(kp%mos, 2)
1741 nc =
SIZE(kp%mos, 1)
1742 nimg =
SIZE(denmat, 2)
1743 real_only = (nc == 1)
1745 reverse_phase = kpoint%gamma_centered .AND. any(mod(kpoint%nkp_grid(1:3), 2) == 0)
1747 para_env => kpoint%blacs_env_all%para_env
1748 ALLOCATE (info(nspin*nkp*nc))
1754 CALL dbcsr_set(denmat(ispin, ic)%matrix, 0.0_dp)
1758 my_kpgrp = (ik >= kpoint%kp_range(1) .AND. ik <= kpoint%kp_range(2))
1760 ikk = ik - kpoint%kp_range(1) + 1
1762 kp => kpoint%kp_aux_env(ikk)%kpoint_env
1764 kp => kpoint%kp_env(ikk)%kpoint_env
1770 cpassert(
SIZE(fmwork) >= nc)
1812 kpsym => kpoint%kp_sym(ik)%kpoint_sym
1813 cpassert(
ASSOCIATED(
kpsym))
1815 IF (
kpsym%apply_symmetry)
THEN
1816 wkpx = wkp(ik)/real(
kpsym%nwght, kind=
dp)
1817 DO is = 1,
kpsym%nwght
1818 ir = abs(
kpsym%rotp(is))
1820 DO jr = 1,
SIZE(kpoint%ibrot)
1821 IF (ir == kpoint%ibrot(jr)) ira = jr
1824 kind_rot => kpoint%kind_rotmat(ira, :)
1825 CALL symtrans_phase(srpmat, scpmat, rpmat, cpmat, real_only, kind_rot, &
1827 kpsym%fcell(:, :, is), kpoint%atype,
kpsym%xkp(1:3, is), &
1828 kpsym%rotp(is) < 0, reverse_phase)
1829 CALL transform_dmat(denmat, srpmat, scpmat, ispin, real_only, sab_nl, &
1830 cell_to_index,
kpsym%xkp(1:3, is), wkpx)
1834 CALL transform_dmat(denmat, rpmat, cpmat, ispin, real_only, sab_nl, &
1835 cell_to_index, xkp(1:3, ik), wkp(ik))
1844 my_kpgrp = (ik >= kpoint%kp_range(1) .AND. ik <= kpoint%kp_range(2))
1846 ikk = ik - kpoint%kp_range(1) + 1
1848 kp => kpoint%kp_aux_env(ikk)%kpoint_env
1850 kp => kpoint%kp_env(ikk)%kpoint_env
1870 IF (.NOT. kpoint%full_grid)
THEN
1875 CALL timestop(handle)
1891 SUBROUTINE transform_dmat(denmat, rpmat, cpmat, ispin, real_only, sab_nl, cell_to_index, xkp, wkp)
1895 INTEGER,
INTENT(IN) :: ispin
1896 LOGICAL,
INTENT(IN) :: real_only
1899 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
1900 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: xkp
1901 REAL(kind=
dp),
INTENT(IN) :: wkp
1903 CHARACTER(LEN=*),
PARAMETER :: routinen =
'transform_dmat'
1905 INTEGER :: handle, iatom, icell, icol, irow, jatom, &
1907 INTEGER,
DIMENSION(3) :: cell
1908 LOGICAL :: do_symmetric, found
1909 REAL(kind=
dp) :: arg, coskl, fc, sinkl
1910 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: cblock, dblock, rblock
1912 DIMENSION(:),
POINTER :: nl_iterator
1914 CALL timeset(routinen, handle)
1916 nimg =
SIZE(denmat, 2)
1932 IF (do_symmetric .AND. iatom > jatom)
THEN
1938 icell = cell_to_index(cell(1), cell(2), cell(3))
1939 IF (icell < 1 .OR. icell > nimg) cycle
1941 arg = real(cell(1),
dp)*xkp(1) + real(cell(2),
dp)*xkp(2) + real(cell(3),
dp)*xkp(3)
1942 coskl = wkp*cos(
twopi*arg)
1943 sinkl = wkp*fc*sin(
twopi*arg)
1945 CALL dbcsr_get_block_p(matrix=denmat(ispin, icell)%matrix, row=irow, col=icol, &
1946 block=dblock, found=found)
1947 IF (.NOT. found) cycle
1950 CALL dbcsr_get_block_p(matrix=rpmat, row=irow, col=icol, block=rblock, found=found)
1951 IF (.NOT. found) cycle
1952 dblock = dblock + coskl*rblock
1954 CALL dbcsr_get_block_p(matrix=rpmat, row=irow, col=icol, block=rblock, found=found)
1955 IF (.NOT. found) cycle
1956 CALL dbcsr_get_block_p(matrix=cpmat, row=irow, col=icol, block=cblock, found=found)
1957 IF (.NOT. found) cycle
1958 dblock = dblock + coskl*rblock
1959 dblock = dblock + sinkl*cblock
1964 CALL timestop(handle)
1966 END SUBROUTINE transform_dmat
1974 SUBROUTINE ensure_work_matrix(work, nrow, ncol)
1976 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :), &
1977 INTENT(INOUT) :: work
1978 INTEGER,
INTENT(IN) :: nrow, ncol
1980 IF (
ALLOCATED(work))
THEN
1981 IF (
SIZE(work, 1) == nrow .AND.
SIZE(work, 2) == ncol)
RETURN
1984 ALLOCATE (work(nrow, ncol))
1986 END SUBROUTINE ensure_work_matrix
2004 SUBROUTINE symtrans_phase(srpmat, scpmat, rpmat, cpmat, real_only, kmat, rot, f0, fcell, atype, &
2005 xkp, time_reversal, reverse_phase)
2007 TYPE(
dbcsr_type),
POINTER :: srpmat, scpmat, rpmat, cpmat
2008 LOGICAL,
INTENT(IN) :: real_only
2010 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: rot
2011 INTEGER,
DIMENSION(:),
INTENT(IN) :: f0
2012 INTEGER,
DIMENSION(:, :),
INTENT(IN) :: fcell
2013 INTEGER,
DIMENSION(:),
INTENT(IN) :: atype
2014 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: xkp
2015 LOGICAL,
INTENT(IN) :: time_reversal, reverse_phase
2017 CHARACTER(LEN=*),
PARAMETER :: routinen =
'symtrans_phase'
2019 INTEGER :: handle, iatom, icol, ikind, ip, irow, &
2020 jcol, jkind, jp, jrow, mynode, natom, &
2022 INTEGER,
DIMENSION(3) :: shift
2023 LOGICAL :: dorot, found, has_phase, perm, trans
2024 REAL(kind=
dp) :: arg, coskl, dr, sinkl
2025 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: cwork, rwork, twork
2026 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: cblock, kroti, krotj, rblock, scblock, &
2031 CALL timeset(routinen, handle)
2036 IF (f0(iatom) == iatom) cycle
2042 IF (abs(sum(abs(rot)) - 3.0_dp) > 1.e-12_dp) dorot = .true.
2043 dr = abs(rot(1, 1) - 1.0_dp) + abs(rot(2, 2) - 1.0_dp) + abs(rot(3, 3) - 1.0_dp)
2044 IF (abs(dr) > 1.e-12_dp) dorot = .true.
2045 has_phase = any(fcell /= 0) .OR. time_reversal
2047 IF (.NOT. (dorot .OR. perm .OR. has_phase))
THEN
2049 IF (.NOT. real_only)
CALL dbcsr_copy(scpmat, cpmat)
2050 CALL timestop(handle)
2056 IF (numnodes /= 1 .AND. (perm .OR. has_phase))
THEN
2062 IF (.NOT. real_only)
CALL dbcsr_set(scpmat, 0.0_dp)
2067 IF (.NOT.
ALLOCATED(rwork))
THEN
2068 ALLOCATE (rwork(
SIZE(rblock, 1),
SIZE(rblock, 2)))
2069 ELSEIF (
SIZE(rwork, 1) /=
SIZE(rblock, 1) .OR.
SIZE(rwork, 2) /=
SIZE(rblock, 2))
THEN
2071 ALLOCATE (rwork(
SIZE(rblock, 1),
SIZE(rblock, 2)))
2073 IF (.NOT. real_only)
THEN
2074 IF (.NOT.
ALLOCATED(cwork))
THEN
2075 ALLOCATE (cwork(
SIZE(rblock, 1),
SIZE(rblock, 2)))
2076 ELSEIF (
SIZE(cwork, 1) /=
SIZE(rblock, 1) .OR.
SIZE(cwork, 2) /=
SIZE(rblock, 2))
THEN
2078 ALLOCATE (cwork(
SIZE(rblock, 1),
SIZE(rblock, 2)))
2084 kroti => kmat(ikind)%rmat
2085 krotj => kmat(jkind)%rmat
2087 IF (reverse_phase)
THEN
2088 shift = fcell(1:3, irow) - fcell(1:3, icol)
2090 shift = fcell(1:3, icol) - fcell(1:3, irow)
2092 arg = real(shift(1),
dp)*xkp(1) + real(shift(2),
dp)*xkp(2) + real(shift(3),
dp)*xkp(3)
2094 coskl = cos(
twopi*arg)
2095 sinkl = sin(
twopi*arg)
2097 IF (abs(sinkl) > 1.e-12_dp)
THEN
2098 CALL cp_abort(__location__,
"Real k-point wavefunctions cannot represent symmetry phases")
2100 rwork(:, :) = coskl*rblock
2102 CALL dbcsr_get_block_p(matrix=cpmat, row=irow, col=icol, block=cblock, found=found)
2103 rwork(:, :) = coskl*rblock
2104 IF (time_reversal)
THEN
2105 cwork(:, :) = -sinkl*rblock
2107 rwork(:, :) = rwork - sinkl*cblock
2108 cwork(:, :) = cwork - coskl*cblock
2111 cwork(:, :) = -sinkl*rblock
2113 rwork(:, :) = rwork + sinkl*cblock
2114 cwork(:, :) = cwork + coskl*cblock
2131 CALL dbcsr_get_block_p(matrix=srpmat, row=jrow, col=jcol, block=srblock, found=found)
2132 IF (.NOT. found)
THEN
2134 cpassert(owner /= mynode)
2138 CALL ensure_work_matrix(twork,
SIZE(krotj, 1),
SIZE(rwork, 1))
2139 CALL dgemm(
'N',
'T',
SIZE(krotj, 1),
SIZE(rwork, 1),
SIZE(krotj, 2), &
2140 1.0_dp, krotj,
SIZE(krotj, 1), rwork,
SIZE(rwork, 1), &
2141 0.0_dp, twork,
SIZE(twork, 1))
2142 CALL dgemm(
'N',
'T',
SIZE(twork, 1),
SIZE(kroti, 1),
SIZE(twork, 2), &
2143 1.0_dp, twork,
SIZE(twork, 1), kroti,
SIZE(kroti, 1), &
2144 1.0_dp, srblock,
SIZE(srblock, 1))
2146 CALL ensure_work_matrix(twork,
SIZE(kroti, 1),
SIZE(rwork, 2))
2147 CALL dgemm(
'N',
'N',
SIZE(kroti, 1),
SIZE(rwork, 2),
SIZE(kroti, 2), &
2148 1.0_dp, kroti,
SIZE(kroti, 1), rwork,
SIZE(rwork, 1), &
2149 0.0_dp, twork,
SIZE(twork, 1))
2150 CALL dgemm(
'N',
'T',
SIZE(twork, 1),
SIZE(krotj, 1),
SIZE(twork, 2), &
2151 1.0_dp, twork,
SIZE(twork, 1), krotj,
SIZE(krotj, 1), &
2152 1.0_dp, srblock,
SIZE(srblock, 1))
2155 IF (.NOT. real_only)
THEN
2156 CALL dbcsr_get_block_p(matrix=scpmat, row=jrow, col=jcol, block=scblock, found=found)
2159 CALL ensure_work_matrix(twork,
SIZE(krotj, 1),
SIZE(cwork, 1))
2160 CALL dgemm(
'N',
'T',
SIZE(krotj, 1),
SIZE(cwork, 1),
SIZE(krotj, 2), &
2161 1.0_dp, krotj,
SIZE(krotj, 1), cwork,
SIZE(cwork, 1), &
2162 0.0_dp, twork,
SIZE(twork, 1))
2163 CALL dgemm(
'N',
'T',
SIZE(twork, 1),
SIZE(kroti, 1),
SIZE(twork, 2), &
2164 -1.0_dp, twork,
SIZE(twork, 1), kroti,
SIZE(kroti, 1), &
2165 1.0_dp, scblock,
SIZE(scblock, 1))
2167 CALL ensure_work_matrix(twork,
SIZE(kroti, 1),
SIZE(cwork, 2))
2168 CALL dgemm(
'N',
'N',
SIZE(kroti, 1),
SIZE(cwork, 2),
SIZE(kroti, 2), &
2169 1.0_dp, kroti,
SIZE(kroti, 1), cwork,
SIZE(cwork, 1), &
2170 0.0_dp, twork,
SIZE(twork, 1))
2171 CALL dgemm(
'N',
'T',
SIZE(twork, 1),
SIZE(krotj, 1),
SIZE(twork, 2), &
2172 1.0_dp, twork,
SIZE(twork, 1), krotj,
SIZE(krotj, 1), &
2173 1.0_dp, scblock,
SIZE(scblock, 1))
2178 IF (numnodes /= 1 .AND. (perm .OR. has_phase))
THEN
2183 CALL timestop(handle)
2185 END SUBROUTINE symtrans_phase
2198 SUBROUTINE symtrans(smat, pmat, kmat, rot, f0, atype, symmetric, antisymmetric)
2201 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN) :: rot
2202 INTEGER,
DIMENSION(:),
INTENT(IN) :: f0, atype
2203 LOGICAL,
INTENT(IN),
OPTIONAL :: symmetric, antisymmetric
2205 CHARACTER(LEN=*),
PARAMETER :: routinen =
'symtrans'
2207 INTEGER :: handle, iatom, icol, ikind, ip, irow, &
2208 jcol, jkind, jp, jrow, natom, numnodes
2209 LOGICAL :: asym, dorot, found, perm, sym, trans
2210 REAL(kind=
dp) :: dr, fsign
2211 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: work
2212 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: kroti, krotj, pblock, sblock
2216 CALL timeset(routinen, handle)
2220 IF (
PRESENT(symmetric)) sym = symmetric
2222 IF (
PRESENT(antisymmetric)) asym = antisymmetric
2224 cpassert(.NOT. (sym .AND. asym))
2225 cpassert((sym .OR. asym))
2231 IF (f0(iatom) == iatom) cycle
2238 IF (abs(sum(abs(rot)) - 3.0_dp) > 1.e-12_dp) dorot = .true.
2239 dr = abs(rot(1, 1) - 1.0_dp) + abs(rot(2, 2) - 1.0_dp) + abs(rot(3, 3) - 1.0_dp)
2240 IF (abs(dr) > 1.e-12_dp) dorot = .true.
2243 IF (asym) fsign = -1.0_dp
2245 IF (dorot .OR. perm)
THEN
2246 CALL cp_abort(__location__,
"k-points need FULL_GRID currently. "// &
2247 "Reduced grids not yet working correctly")
2252 IF (numnodes == 1)
THEN
2268 CALL dbcsr_get_block_p(matrix=smat, row=jrow, col=jcol, block=sblock, found=found)
2272 kroti => kmat(ikind)%rmat
2273 krotj => kmat(jkind)%rmat
2276 CALL ensure_work_matrix(work,
SIZE(krotj, 2),
SIZE(pblock, 1))
2277 CALL dgemm(
'T',
'T',
SIZE(krotj, 2),
SIZE(pblock, 1),
SIZE(krotj, 1), &
2278 1.0_dp, krotj,
SIZE(krotj, 1), pblock,
SIZE(pblock, 1), &
2279 0.0_dp, work,
SIZE(work, 1))
2280 CALL dgemm(
'N',
'N',
SIZE(work, 1),
SIZE(kroti, 2),
SIZE(work, 2), &
2281 fsign, work,
SIZE(work, 1), kroti,
SIZE(kroti, 1), &
2282 0.0_dp, sblock,
SIZE(sblock, 1))
2284 CALL ensure_work_matrix(work,
SIZE(kroti, 2),
SIZE(pblock, 2))
2285 CALL dgemm(
'T',
'N',
SIZE(kroti, 2),
SIZE(pblock, 2),
SIZE(kroti, 1), &
2286 1.0_dp, kroti,
SIZE(kroti, 1), pblock,
SIZE(pblock, 1), &
2287 0.0_dp, work,
SIZE(work, 1))
2288 CALL dgemm(
'N',
'N',
SIZE(work, 1),
SIZE(krotj, 2),
SIZE(work, 2), &
2289 fsign, work,
SIZE(work, 1), krotj,
SIZE(krotj, 1), &
2290 0.0_dp, sblock,
SIZE(sblock, 1))
2297 CALL cp_abort(__location__,
"k-points need FULL_GRID currently. "// &
2298 "Reduced grids not yet working correctly")
2319 kroti => kmat(ikind)%rmat
2320 krotj => kmat(jkind)%rmat
2323 CALL ensure_work_matrix(work,
SIZE(krotj, 2),
SIZE(sblock, 1))
2324 CALL dgemm(
'T',
'T',
SIZE(krotj, 2),
SIZE(sblock, 1),
SIZE(krotj, 1), &
2325 1.0_dp, krotj,
SIZE(krotj, 1), sblock,
SIZE(sblock, 1), &
2326 0.0_dp, work,
SIZE(work, 1))
2327 CALL dgemm(
'N',
'N',
SIZE(work, 1),
SIZE(kroti, 2),
SIZE(work, 2), &
2328 fsign, work,
SIZE(work, 1), kroti,
SIZE(kroti, 1), &
2329 0.0_dp, sblock,
SIZE(sblock, 1))
2331 CALL ensure_work_matrix(work,
SIZE(kroti, 2),
SIZE(sblock, 2))
2332 CALL dgemm(
'T',
'N',
SIZE(kroti, 2),
SIZE(sblock, 2),
SIZE(kroti, 1), &
2333 1.0_dp, kroti,
SIZE(kroti, 1), sblock,
SIZE(sblock, 1), &
2334 0.0_dp, work,
SIZE(work, 1))
2335 CALL dgemm(
'N',
'N',
SIZE(work, 1),
SIZE(krotj, 2),
SIZE(work, 2), &
2336 fsign, work,
SIZE(work, 1), krotj,
SIZE(krotj, 1), &
2337 0.0_dp, sblock,
SIZE(sblock, 1))
2348 CALL timestop(handle)
2350 END SUBROUTINE symtrans
2356 SUBROUTINE matprint(mat)
2359 INTEGER :: i, icol, iounit, irow
2360 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: mblock
2368 IF (iounit > 0)
THEN
2369 WRITE (iounit,
'(A,2I4)')
'BLOCK ', irow, icol
2370 DO i = 1,
SIZE(mblock, 1)
2371 WRITE (iounit,
'(8F12.6)') mblock(i, :)
2378 END SUBROUTINE matprint
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
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)
...
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_replicate_all(matrix)
...
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_get_stored_coordinates(matrix, row, column, processor)
...
subroutine, public dbcsr_distribute(matrix)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset, transposed)
...
subroutine, public dbcsr_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 kpoint_gen(csym, nk, symm, shift, full_grid, gamma_centered, inversion_symmetry_only, use_spglib_reduction, use_spglib_backend)
...
subroutine, public release_csym_type(csym)
Release the CSYM type.
subroutine, public kpoint_gen_general(csym, xkp_in, wkp_in, symm, full_grid, inversion_symmetry_only, use_spglib_reduction, use_spglib_backend)
Reduce an explicitly supplied GENERAL k-point set.
subroutine, public print_kp_symmetry(csym)
...
subroutine, public crys_sym_gen(csym, scoor, types, hmat, delta, iounit, use_spglib)
...
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, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method, gamma_centered)
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
Collection of simple mathematical functions and subroutines.
pure real(kind=dp) function, dimension(3, 3), public inv_3x3(a)
Returns the inverse of the 3 x 3 matrix a.
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