51#include "./base/base_uses.f90"
57 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'kpoint_coulomb_2c'
65 REAL(KIND=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: block
66 END TYPE two_d_util_type
88 atomic_kind_set, size_lattice_sum, operator_type, ikp_start, ikp_end)
90 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_v_kp
92 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
97 INTEGER :: size_lattice_sum, operator_type, &
100 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_2c_coulomb_matrix_kp'
105 CALL timeset(routinen, handle)
107 CALL allocate_tmp(matrix_v_l_tmp, matrix_v_kp, ikp_start)
109 CALL lattice_sum(matrix_v_kp, kpoints, basis_type, cell, particle_set, &
110 qs_kind_set, atomic_kind_set, size_lattice_sum, matrix_v_l_tmp, &
111 operator_type, ikp_start, ikp_end)
113 CALL deallocate_tmp(matrix_v_l_tmp)
115 CALL timestop(handle)
134 SUBROUTINE lattice_sum(matrix_v_kp, kpoints, basis_type, cell, particle_set, &
135 qs_kind_set, atomic_kind_set, size_lattice_sum, matrix_v_L_tmp, &
136 operator_type, ikp_start, ikp_end)
138 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_v_kp
140 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
143 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
145 INTEGER :: size_lattice_sum
147 INTEGER :: operator_type, ikp_start, ikp_end
149 CHARACTER(LEN=*),
PARAMETER :: routinen =
'lattice_sum'
151 INTEGER :: factor, handle, handle2, i_block, i_x, i_x_inner, i_x_outer, ik, j_y, j_y_inner, &
152 j_y_outer, k_z, k_z_inner, k_z_outer, x_max, x_min, y_max, y_min, z_max, z_min
153 INTEGER,
DIMENSION(3) :: nkp_grid
154 REAL(kind=
dp) :: coskl, sinkl
155 REAL(kind=
dp),
DIMENSION(3) :: vec_l, vec_s
156 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
157 TYPE(two_d_util_type),
ALLOCATABLE,
DIMENSION(:) :: blocks_v_l, blocks_v_l_store
158 TYPE(two_d_util_type),
ALLOCATABLE, &
159 DIMENSION(:, :, :) :: blocks_v_kp
161 CALL timeset(routinen, handle)
163 CALL get_factor_and_xyz_min_max(cell, kpoints, size_lattice_sum, factor, hmat, &
164 x_min, x_max, y_min, y_max, z_min, z_max, nkp_grid)
166 CALL allocate_blocks_v_kp(blocks_v_kp, matrix_v_kp, ikp_start, ikp_end)
167 CALL allocate_blocks_v_l(blocks_v_l, matrix_v_l_tmp)
168 CALL allocate_blocks_v_l(blocks_v_l_store, matrix_v_l_tmp)
170 DO i_x_inner = 0, 2*nkp_grid(1) - 1
171 DO j_y_inner = 0, 2*nkp_grid(2) - 1
172 DO k_z_inner = 0, 2*nkp_grid(3) - 1
174 DO i_x_outer = x_min, x_max + nkp_grid(1), 2*nkp_grid(1)
175 DO j_y_outer = y_min, y_max + nkp_grid(2), 2*nkp_grid(2)
176 DO k_z_outer = z_min, z_max + nkp_grid(3), 2*nkp_grid(3)
178 i_x = i_x_inner + i_x_outer
179 j_y = j_y_inner + j_y_outer
180 k_z = k_z_inner + k_z_outer
182 IF (i_x > x_max .OR. i_x < x_min .OR. &
183 j_y > y_max .OR. j_y < y_min .OR. &
184 k_z > z_max .OR. k_z < z_min) cycle
186 vec_s = [real(i_x,
dp), real(j_y,
dp), real(k_z,
dp)]
188 vec_l = matmul(hmat, vec_s)
191 CALL compute_v_transl(matrix_v_l_tmp, blocks_v_l, vec_l, particle_set, &
192 qs_kind_set, atomic_kind_set, basis_type, cell, &
198 DO i_block = 1,
SIZE(blocks_v_l)
199 blocks_v_l_store(i_block)%block(:, :) = blocks_v_l_store(i_block)%block(:, :) &
200 + blocks_v_l(i_block)%block(:, :)
208 CALL timeset(routinen//
"_R_to_k", handle2)
211 DO ik = ikp_start, ikp_end
214 coskl = cos(
twopi*dot_product(vec_s(1:3), kpoints%xkp(1:3, ik)))
215 sinkl = sin(
twopi*dot_product(vec_s(1:3), kpoints%xkp(1:3, ik)))
217 DO i_block = 1,
SIZE(blocks_v_l)
219 blocks_v_kp(ik, 1, i_block)%block(:, :) = blocks_v_kp(ik, 1, i_block)%block(:, :) &
220 + coskl*blocks_v_l_store(i_block)%block(:, :)
221 blocks_v_kp(ik, 2, i_block)%block(:, :) = blocks_v_kp(ik, 2, i_block)%block(:, :) &
222 + sinkl*blocks_v_l_store(i_block)%block(:, :)
228 DO i_block = 1,
SIZE(blocks_v_l)
230 blocks_v_l_store(i_block)%block(:, :) = 0.0_dp
234 CALL timestop(handle2)
240 CALL set_blocks_to_matrix_v_kp(matrix_v_kp, blocks_v_kp, ikp_start, ikp_end)
242 CALL deallocate_blocks_v_kp(blocks_v_kp)
243 CALL deallocate_blocks_v_l(blocks_v_l)
244 CALL deallocate_blocks_v_l(blocks_v_l_store)
246 CALL timestop(handle)
248 END SUBROUTINE lattice_sum
257 SUBROUTINE set_blocks_to_matrix_v_kp(matrix_v_kp, blocks_v_kp, ikp_start, ikp_end)
259 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_v_kp
260 TYPE(two_d_util_type),
ALLOCATABLE, &
261 DIMENSION(:, :, :) :: blocks_v_kp
262 INTEGER :: ikp_start, ikp_end
264 CHARACTER(LEN=*),
PARAMETER :: routinen =
'set_blocks_to_matrix_v_kp'
266 INTEGER :: col, handle, i_block, i_real_im, ik, row
267 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: data_block
270 CALL timeset(routinen, handle)
272 DO ik = ikp_start, ikp_end
284 data_block(:, :) = blocks_v_kp(ik, i_real_im, i_block)%block(:, :)
286 i_block = i_block + 1
296 CALL timestop(handle)
298 END SUBROUTINE set_blocks_to_matrix_v_kp
312 SUBROUTINE compute_v_transl(matrix_v_L_tmp, blocks_v_L, vec_L, particle_set, &
313 qs_kind_set, atomic_kind_set, basis_type, cell, operator_type)
316 TYPE(two_d_util_type),
ALLOCATABLE,
DIMENSION(:) :: blocks_v_l
317 REAL(kind=
dp),
DIMENSION(3) :: vec_l
319 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
321 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
323 INTEGER :: operator_type
325 CHARACTER(LEN=*),
PARAMETER :: routinen =
'compute_v_transl'
327 INTEGER :: col, handle, i_block, kind_a, kind_b, row
328 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: kind_of
329 REAL(
dp),
DIMENSION(3) :: ra, rab_l, rb
330 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: data_block
331 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: contr_a, contr_b
335 CALL timeset(routinen, handle)
337 NULLIFY (basis_set_a, basis_set_b, data_block)
351 kind_a = kind_of(row)
352 kind_b = kind_of(col)
354 CALL get_qs_kind(qs_kind=qs_kind_set(kind_a), basis_set=basis_set_a, basis_type=basis_type)
355 CALL get_qs_kind(qs_kind=qs_kind_set(kind_b), basis_set=basis_set_b, basis_type=basis_type)
357 ra(1:3) =
pbc(particle_set(row)%r(1:3), cell)
358 rb(1:3) =
pbc(particle_set(col)%r(1:3), cell)
360 rab_l(1:3) = rb(1:3) - ra(1:3) + vec_l(1:3)
365 blocks_v_l(i_block)%block = 0.0_dp
368 fba=basis_set_a, fbb=basis_set_b, scona_shg=contr_a, sconb_shg=contr_b, &
369 calculate_forces=.false.)
371 i_block = i_block + 1
373 DEALLOCATE (contr_a, contr_b)
381 CALL timestop(handle)
383 END SUBROUTINE compute_v_transl
389 SUBROUTINE deallocate_blocks_v_kp(blocks_v_kp)
390 TYPE(two_d_util_type),
ALLOCATABLE, &
391 DIMENSION(:, :, :) :: blocks_v_kp
393 CHARACTER(LEN=*),
PARAMETER :: routinen =
'deallocate_blocks_v_kp'
395 INTEGER :: handle, i_block, i_real_img, ik
397 CALL timeset(routinen, handle)
399 DO ik = lbound(blocks_v_kp, 1), ubound(blocks_v_kp, 1)
400 DO i_real_img = 1,
SIZE(blocks_v_kp, 2)
401 DO i_block = 1,
SIZE(blocks_v_kp, 3)
402 DEALLOCATE (blocks_v_kp(ik, i_real_img, i_block)%block)
407 DEALLOCATE (blocks_v_kp)
409 CALL timestop(handle)
411 END SUBROUTINE deallocate_blocks_v_kp
417 SUBROUTINE deallocate_blocks_v_l(blocks_v_L)
418 TYPE(two_d_util_type),
ALLOCATABLE,
DIMENSION(:) :: blocks_v_l
420 CHARACTER(LEN=*),
PARAMETER :: routinen =
'deallocate_blocks_v_L'
422 INTEGER :: handle, i_block
424 CALL timeset(routinen, handle)
426 DO i_block = 1,
SIZE(blocks_v_l, 1)
427 DEALLOCATE (blocks_v_l(i_block)%block)
430 DEALLOCATE (blocks_v_l)
432 CALL timestop(handle)
434 END SUBROUTINE deallocate_blocks_v_l
441 SUBROUTINE allocate_blocks_v_l(blocks_v_L, matrix_v_L_tmp)
442 TYPE(two_d_util_type),
ALLOCATABLE,
DIMENSION(:) :: blocks_v_l
445 CHARACTER(LEN=*),
PARAMETER :: routinen =
'allocate_blocks_v_L'
447 INTEGER :: col, handle, i_block, nblocks, row
448 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: data_block
451 CALL timeset(routinen, handle)
461 nblocks = nblocks + 1
467 ALLOCATE (blocks_v_l(nblocks))
477 ALLOCATE (blocks_v_l(i_block)%block(
SIZE(data_block, 1),
SIZE(data_block, 2)))
478 blocks_v_l(i_block)%block = 0.0_dp
480 i_block = i_block + 1
486 CALL timestop(handle)
488 END SUBROUTINE allocate_blocks_v_l
497 SUBROUTINE allocate_blocks_v_kp(blocks_v_kp, matrix_v_kp, ikp_start, ikp_end)
498 TYPE(two_d_util_type),
ALLOCATABLE, &
499 DIMENSION(:, :, :) :: blocks_v_kp
500 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_v_kp
501 INTEGER :: ikp_start, ikp_end
503 CHARACTER(LEN=*),
PARAMETER :: routinen =
'allocate_blocks_v_kp'
505 INTEGER :: col, handle, i_block, i_real_img, ik, &
507 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: data_block
510 CALL timeset(routinen, handle)
520 nblocks = nblocks + 1
526 ALLOCATE (blocks_v_kp(ikp_start:ikp_end,
SIZE(matrix_v_kp, 2), nblocks))
528 DO ik = ikp_start, ikp_end
530 DO i_real_img = 1,
SIZE(matrix_v_kp, 2)
540 ALLOCATE (blocks_v_kp(ik, i_real_img, i_block)%block(
SIZE(data_block, 1), &
541 SIZE(data_block, 2)))
542 blocks_v_kp(ik, i_real_img, i_block)%block = 0.0_dp
544 i_block = i_block + 1
554 CALL timestop(handle)
556 END SUBROUTINE allocate_blocks_v_kp
573 SUBROUTINE get_factor_and_xyz_min_max(cell, kpoints, size_lattice_sum, factor, hmat, &
574 x_min, x_max, y_min, y_max, z_min, z_max, nkp_grid)
578 INTEGER :: size_lattice_sum, factor
579 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
580 INTEGER :: x_min, x_max, y_min, y_max, z_min, z_max
581 INTEGER,
DIMENSION(3) :: nkp_grid
583 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_factor_and_xyz_min_max'
585 INTEGER :: handle, nkp
586 INTEGER,
DIMENSION(3) :: periodic
588 CALL timeset(routinen, handle)
591 CALL get_cell(cell=cell, h=hmat, periodic=periodic)
593 IF (periodic(1) == 0)
THEN
594 cpassert(nkp_grid(1) == 1)
596 IF (periodic(2) == 0)
THEN
597 cpassert(nkp_grid(2) == 1)
599 IF (periodic(3) == 0)
THEN
600 cpassert(nkp_grid(3) == 1)
603 IF (
modulo(nkp_grid(1), 2) == 1)
THEN
604 factor = 3**(size_lattice_sum - 1)
605 ELSE IF (
modulo(nkp_grid(1), 2) == 0)
THEN
606 factor = 2**(size_lattice_sum - 1)
609 IF (
modulo(nkp_grid(1), 2) == 1)
THEN
610 x_min = -(factor*nkp_grid(1) - 1)/2
611 x_max = (factor*nkp_grid(1) - 1)/2
612 ELSE IF (
modulo(nkp_grid(1), 2) == 0)
THEN
613 x_min = -factor*nkp_grid(1)/2
614 x_max = factor*nkp_grid(1)/2 - 1
616 IF (periodic(1) == 0)
THEN
621 IF (
modulo(nkp_grid(2), 2) == 1)
THEN
622 y_min = -(factor*nkp_grid(2) - 1)/2
623 y_max = (factor*nkp_grid(2) - 1)/2
624 ELSE IF (
modulo(nkp_grid(2), 2) == 0)
THEN
625 y_min = -factor*nkp_grid(2)/2
626 y_max = factor*nkp_grid(2)/2 - 1
628 IF (periodic(2) == 0)
THEN
633 IF (
modulo(nkp_grid(3), 2) == 1)
THEN
634 z_min = -(factor*nkp_grid(3) - 1)/2
635 z_max = (factor*nkp_grid(3) - 1)/2
636 ELSE IF (
modulo(nkp_grid(3), 2) == 0)
THEN
637 z_min = -factor*nkp_grid(3)/2
638 z_max = factor*nkp_grid(3)/2 - 1
640 IF (periodic(3) == 0)
THEN
645 CALL timestop(handle)
647 END SUBROUTINE get_factor_and_xyz_min_max
655 SUBROUTINE allocate_tmp(matrix_v_L_tmp, matrix_v_kp, ikp_start)
658 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: matrix_v_kp
661 CHARACTER(LEN=*),
PARAMETER :: routinen =
'allocate_tmp'
665 CALL timeset(routinen, handle)
667 NULLIFY (matrix_v_l_tmp)
670 template=matrix_v_kp(ikp_start, 1)%matrix, &
671 matrix_type=dbcsr_type_no_symmetry)
675 CALL timestop(handle)
677 END SUBROUTINE allocate_tmp
683 SUBROUTINE deallocate_tmp(matrix_v_L_tmp)
687 CHARACTER(LEN=*),
PARAMETER :: routinen =
'deallocate_tmp'
691 CALL timeset(routinen, handle)
695 CALL timestop(handle)
697 END SUBROUTINE deallocate_tmp
710 basis_type, ikp_start, ikp_end)
711 COMPLEX(KIND=dp),
DIMENSION(:, :, :) :: v_k
714 INTEGER :: size_lattice_sum
715 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
716 INTEGER :: ikp_start, ikp_end
718 CHARACTER(LEN=*),
PARAMETER :: routinen =
'build_2c_coulomb_matrix_kp_dense'
720 INTEGER :: factor, handle, x_max, x_min, y_max, &
722 INTEGER,
DIMENSION(3) :: nkp_grid
723 REAL(kind=
dp),
DIMENSION(3, 3) :: hmat
726 CALL timeset(routinen, handle)
730 CALL get_factor_and_xyz_min_max(cell, kpoints, size_lattice_sum, factor, hmat, &
731 x_min, x_max, y_min, y_max, z_min, z_max, nkp_grid)
733 CALL lattice_sum_dense(v_k, qs_env, kpoints, basis_type, &
734 x_min, x_max, y_min, y_max, z_min, z_max, ikp_start, ikp_end)
736 CALL timestop(handle)
765 SUBROUTINE lattice_sum_dense(V_k, qs_env, kpoints, basis_type, &
766 x_min, x_max, y_min, y_max, z_min, z_max, ikp_start, ikp_end)
767 COMPLEX(KIND=dp),
DIMENSION(:, :, :) :: v_k
770 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
771 INTEGER,
INTENT(IN) :: x_min, x_max, y_min, y_max, z_min, &
772 z_max, ikp_start, ikp_end
774 CHARACTER(LEN=*),
PARAMETER :: routinen =
'lattice_sum_dense'
775 REAL(kind=
dp),
PARAMETER :: batch_bytes = 64.0_dp*1024.0_dp**2, &
776 chunk_bytes = 256.0_dp*1024.0_dp**2, complex_bytes = 2.0_dp*
dp_size, fold_eps = 1.0e-8_dp
778 COMPLEX(KIND=dp) :: phase
779 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: recv_complex, send_complex
780 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: v_part, v_q_cols
781 INTEGER :: first_k, handle, handle2, i_cell, i_class, i_own, i_rank, i_x, i_x_inner, &
782 i_x_outer, idim, ik, j_y, j_y_inner, j_y_outer, k_z, k_z_inner, k_z_outer, last_k, &
783 n_atom, n_batch, n_bf, n_block, n_cells, n_chunk, n_class, n_cols, n_k, num_pe, pos, q_col
784 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: bf_end_from_atom, bf_start_from_atom, class_first, &
785 col_first, n_own, recv_counts, recv_displs, send_counts, send_displs
786 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: cell_s
787 INTEGER,
DIMENSION(3) :: fold_sign, nkp_grid, period
789 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: cell_sign, k_times_n, recv_real, &
791 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: class_ref, cos_phase, im_part, re_part, &
793 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :) :: v_cols, v_l, v_own
794 REAL(kind=
dp),
DIMENSION(3) :: vec_l
799 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
801 CALL timeset(routinen, handle)
805 particle_set=particle_set, &
807 qs_kind_set=qs_kind_set, &
808 atomic_kind_set=atomic_kind_set)
812 CALL get_basis_sizes(qs_env, n_atom, basis_type, bf_start_from_atom, bf_end_from_atom, n_bf)
814 ALLOCATE (k_times_n(ikp_end - ikp_start + 1))
816 k_times_n(:) = kpoints%xkp(idim, ikp_start:ikp_end)*real(nkp_grid(idim),
dp)
817 period(idim) = 2*nkp_grid(idim)
819 IF (all(abs(k_times_n - anint(k_times_n)) < fold_eps))
THEN
820 period(idim) = nkp_grid(idim)
821 ELSE IF (all(abs(k_times_n - anint(k_times_n - 0.5_dp) - 0.5_dp) < fold_eps))
THEN
822 period(idim) = nkp_grid(idim)
826 DEALLOCATE (k_times_n)
830 n_cells = (x_max - x_min + 1)*(y_max - y_min + 1)*(z_max - z_min + 1)
831 ALLOCATE (cell_s(3, n_cells), cell_sign(n_cells), class_first(n_cells + 1), &
832 class_ref(3, n_cells))
835 DO i_x_inner = 0, period(1) - 1
836 DO j_y_inner = 0, period(2) - 1
837 DO k_z_inner = 0, period(3) - 1
839 DO i_x_outer = x_min, x_max, period(1)
840 DO j_y_outer = y_min, y_max, period(2)
841 DO k_z_outer = z_min, z_max, period(3)
842 i_x = i_x_inner + i_x_outer
843 j_y = j_y_inner + j_y_outer
844 k_z = k_z_inner + k_z_outer
845 IF (i_x > x_max .OR. j_y > y_max .OR. k_z > z_max) cycle
846 n_cells = n_cells + 1
847 cell_s(:, n_cells) = [i_x, j_y, k_z]
848 cell_sign(n_cells) = real(fold_sign(1)**((i_x_outer - x_min)/period(1))* &
849 fold_sign(2)**((j_y_outer - y_min)/period(2))* &
850 fold_sign(3)**((k_z_outer - z_min)/period(3)),
dp)
854 IF (n_cells > i_cell)
THEN
855 n_class = n_class + 1
856 class_first(n_class) = i_cell + 1
857 class_ref(:, n_class) = real([i_x_inner + x_min, j_y_inner + y_min, k_z_inner + z_min],
dp)
862 class_first(n_class + 1) = n_cells + 1
865 IF (ikp_end - ikp_start + 1 < n_class)
THEN
867 n_batch = max(1, min(ikp_end - ikp_start + 1, int(batch_bytes/(complex_bytes*real(n_bf,
dp)**2))))
868 ALLOCATE (v_l(n_bf, 1, n_bf), v_part(n_bf, n_bf, n_batch))
869 DO first_k = ikp_start, ikp_end, n_batch
870 last_k = min(ikp_end, first_k + n_batch - 1)
872 DO i_cell = 1, n_cells
873 IF (
modulo(i_cell, para_env%num_pe) /= para_env%mepos) cycle
874 v_l(:, :, :) = 0.0_dp
875 vec_l = matmul(cell%hmat, real(cell_s(:, i_cell),
dp))
876 CALL add_v_l(v_l(:, 1, :), 1.0_dp, vec_l, n_atom, bf_start_from_atom, bf_end_from_atom, &
877 particle_set, qs_kind_set, atomic_kind_set, basis_type, cell)
880 DO ik = first_k, last_k
881 arg =
twopi*dot_product(real(cell_s(:, i_cell),
dp), kpoints%xkp(1:3, ik))
882 phase = exp(cmplx(0.0_dp, arg, kind=
dp))
883 v_part(:, :, ik - first_k + 1) = v_part(:, :, ik - first_k + 1) + phase*v_l(:, 1, :)
887 CALL para_env%sum(v_part(:, :, 1:last_k - first_k + 1))
888 DO ik = first_k, last_k
889 IF (
modulo(ik, para_env%num_pe) /= para_env%mepos) cycle
890 v_k(:, :, (ik - 1)/para_env%num_pe + 1) = v_k(:, :, (ik - 1)/para_env%num_pe + 1) + &
891 v_part(:, :, ik - first_k + 1)
894 DEALLOCATE (v_l, v_part, cell_s, cell_sign, class_first, class_ref)
895 CALL timestop(handle)
900 num_pe = para_env%num_pe
901 ALLOCATE (col_first(0:num_pe), n_own(0:num_pe - 1))
902 DO i_rank = 0, num_pe
903 col_first(i_rank) = (i_rank*n_bf)/num_pe + 1
905 DO i_rank = 0, num_pe - 1
906 n_own(i_rank) = (n_class - i_rank + num_pe - 1)/num_pe
908 n_cols = col_first(para_env%mepos + 1) - col_first(para_env%mepos)
909 ALLOCATE (v_own(n_bf, n_bf, n_own(para_env%mepos)), source=0.0_dp)
910 DO i_own = 1, n_own(para_env%mepos)
911 i_class = para_env%mepos + 1 + (i_own - 1)*num_pe
912 DO i_cell = class_first(i_class), class_first(i_class + 1) - 1
913 vec_l = matmul(cell%hmat, real(cell_s(:, i_cell),
dp))
914 CALL add_v_l(v_own(:, :, i_own), cell_sign(i_cell), vec_l, n_atom, &
915 bf_start_from_atom, bf_end_from_atom, particle_set, qs_kind_set, &
916 atomic_kind_set, basis_type, cell)
920 CALL timeset(routinen//
"_R_to_k", handle2)
922 ALLOCATE (send_counts(0:num_pe - 1), send_displs(0:num_pe - 1), &
923 recv_counts(0:num_pe - 1), recv_displs(0:num_pe - 1))
924 DO i_rank = 0, num_pe - 1
925 send_counts(i_rank) = n_bf*(col_first(i_rank + 1) - col_first(i_rank))*n_own(para_env%mepos)
926 recv_counts(i_rank) = n_bf*n_cols*n_own(i_rank)
930 DO i_rank = 1, num_pe - 1
931 send_displs(i_rank) = send_displs(i_rank - 1) + send_counts(i_rank - 1)
932 recv_displs(i_rank) = recv_displs(i_rank - 1) + recv_counts(i_rank - 1)
934 ALLOCATE (send_real(sum(send_counts)), recv_real(sum(recv_counts)))
936 DO i_rank = 0, num_pe - 1
937 n_block = n_bf*(col_first(i_rank + 1) - col_first(i_rank))
938 DO i_own = 1, n_own(para_env%mepos)
939 send_real(pos + 1:pos + n_block) = &
940 reshape(v_own(:, col_first(i_rank):col_first(i_rank + 1) - 1, i_own), [n_block])
945 CALL para_env%alltoall(send_real, send_counts, send_displs, recv_real, recv_counts, recv_displs)
946 DEALLOCATE (send_real)
948 ALLOCATE (v_cols(n_bf, n_class, n_cols))
950 DO i_rank = 0, num_pe - 1
951 DO i_own = 1, n_own(i_rank)
952 v_cols(:, i_rank + 1 + (i_own - 1)*num_pe, :) = reshape(recv_real(pos + 1:pos + n_bf*n_cols), [n_bf, n_cols])
953 pos = pos + n_bf*n_cols
956 DEALLOCATE (recv_real)
959 n_chunk = int(min(real(ikp_end - ikp_start + 1,
dp), &
960 chunk_bytes/(complex_bytes*real(n_bf,
dp)*real((n_bf + num_pe - 1)/num_pe,
dp)), &
961 chunk_bytes/(complex_bytes*real(n_class,
dp))))
962 n_chunk = max(1, n_chunk)
963 ALLOCATE (cos_phase(n_class, n_chunk), sin_phase(n_class, n_chunk), v_q_cols(n_bf, n_chunk, n_cols))
964 DO first_k = ikp_start, ikp_end, n_chunk
965 last_k = min(ikp_end, first_k + n_chunk - 1)
966 n_k = last_k - first_k + 1
967 DO ik = first_k, last_k
968 DO i_class = 1, n_class
969 phase = exp(cmplx(0.0_dp,
twopi*dot_product(class_ref(:, i_class), kpoints%xkp(1:3, ik)), kind=
dp))
970 cos_phase(i_class, ik - first_k + 1) = real(phase, kind=
dp)
971 sin_phase(i_class, ik - first_k + 1) = aimag(phase)
977 ALLOCATE (re_part(n_bf, n_k), im_part(n_bf, n_k))
980 CALL dgemm(
'N',
'N', n_bf, n_k, n_class, 1.0_dp, v_cols(:, :, q_col), n_bf, &
981 cos_phase, n_class, 0.0_dp, re_part, n_bf)
982 CALL dgemm(
'N',
'N', n_bf, n_k, n_class, 1.0_dp, v_cols(:, :, q_col), n_bf, &
983 sin_phase, n_class, 0.0_dp, im_part, n_bf)
984 v_q_cols(:, 1:n_k, q_col) = cmplx(re_part, im_part, kind=
dp)
987 DEALLOCATE (re_part, im_part)
991 DO i_rank = 0, num_pe - 1
992 send_counts(i_rank) = n_bf*n_cols*count([(
modulo(ik, num_pe) == i_rank, ik=first_k, last_k)])
993 recv_counts(i_rank) = n_bf*(col_first(i_rank + 1) - col_first(i_rank))* &
994 count([(
modulo(ik, num_pe) == para_env%mepos, ik=first_k, last_k)])
996 DO i_rank = 1, num_pe - 1
997 send_displs(i_rank) = send_displs(i_rank - 1) + send_counts(i_rank - 1)
998 recv_displs(i_rank) = recv_displs(i_rank - 1) + recv_counts(i_rank - 1)
1000 ALLOCATE (send_complex(sum(send_counts)), recv_complex(sum(recv_counts)))
1002 DO i_rank = 0, num_pe - 1
1003 DO ik = first_k, last_k
1004 IF (
modulo(ik, num_pe) /= i_rank) cycle
1005 send_complex(pos + 1:pos + n_bf*n_cols) = reshape(v_q_cols(:, ik - first_k + 1, :), [n_bf*n_cols])
1006 pos = pos + n_bf*n_cols
1009 CALL para_env%alltoall(send_complex, send_counts, send_displs, recv_complex, recv_counts, recv_displs)
1011 DO i_rank = 0, num_pe - 1
1012 n_block = n_bf*(col_first(i_rank + 1) - col_first(i_rank))
1013 DO ik = first_k, last_k
1014 IF (
modulo(ik, num_pe) /= para_env%mepos) cycle
1015 v_k(:, col_first(i_rank):col_first(i_rank + 1) - 1, (ik - 1)/num_pe + 1) = &
1016 v_k(:, col_first(i_rank):col_first(i_rank + 1) - 1, (ik - 1)/num_pe + 1) + &
1017 reshape(recv_complex(pos + 1:pos + n_block), [n_bf, col_first(i_rank + 1) - col_first(i_rank)])
1021 DEALLOCATE (send_complex, recv_complex)
1023 CALL timestop(handle2)
1025 DEALLOCATE (v_cols, v_q_cols, cos_phase, sin_phase, col_first, n_own, send_counts, send_displs, &
1026 recv_counts, recv_displs, cell_s, cell_sign, class_first, class_ref)
1028 CALL timestop(handle)
1030 END SUBROUTINE lattice_sum_dense
1041 SUBROUTINE get_basis_sizes(qs_env, n_atom, basis_type, bf_start_from_atom, bf_end_from_atom, n_bf)
1045 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
1046 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: bf_start_from_atom, bf_end_from_atom
1049 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_basis_sizes'
1051 INTEGER :: handle, iatom, ikind, n_kind, nsgf
1052 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: kind_of
1056 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1058 CALL timeset(routinen, handle)
1060 CALL get_qs_env(qs_env=qs_env, particle_set=particle_set, &
1061 qs_kind_set=qs_kind_set, atomic_kind_set=atomic_kind_set)
1064 n_atom =
SIZE(particle_set)
1065 n_kind =
SIZE(qs_kind_set)
1067 DO ikind = 1, n_kind
1068 CALL get_qs_kind(qs_kind=qs_kind_set(ikind), basis_set=basis_set_a, &
1069 basis_type=basis_type)
1070 cpassert(
ASSOCIATED(basis_set_a))
1073 ALLOCATE (bf_start_from_atom(n_atom), bf_end_from_atom(n_atom))
1076 DO iatom = 1, n_atom
1077 bf_start_from_atom(iatom) = n_bf + 1
1078 ikind = kind_of(iatom)
1079 CALL get_qs_kind(qs_kind=qs_kind_set(ikind), nsgf=nsgf, basis_type=basis_type)
1081 bf_end_from_atom(iatom) = n_bf
1084 CALL timestop(handle)
1086 END SUBROUTINE get_basis_sizes
1102 SUBROUTINE add_v_l(V_L, factor, vec_L, n_atom, bf_start_from_atom, bf_end_from_atom, &
1103 particle_set, qs_kind_set, atomic_kind_set, basis_type, cell)
1105 REAL(kind=
dp),
DIMENSION(:, :) :: v_l
1106 REAL(kind=
dp),
INTENT(IN) :: factor
1107 REAL(kind=
dp),
DIMENSION(3) :: vec_l
1109 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: bf_start_from_atom, bf_end_from_atom
1111 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
1113 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
1116 CHARACTER(LEN=*),
PARAMETER :: routinen =
'add_V_L'
1118 INTEGER :: a_1, a_2, atom_a, atom_b, b_1, b_2, &
1119 handle, kind_a, kind_b
1120 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: kind_of
1121 REAL(
dp),
DIMENSION(3) :: ra, rab_l, rb
1122 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: v_l_ab
1123 REAL(kind=
dp),
DIMENSION(:, :, :),
POINTER :: contr_a, contr_b
1126 CALL timeset(routinen, handle)
1139 DO atom_a = 1, n_atom
1141 DO atom_b = 1, n_atom
1143 kind_a = kind_of(atom_a)
1144 kind_b = kind_of(atom_b)
1146 CALL get_qs_kind(qs_kind=qs_kind_set(kind_a), basis_set=basis_set_a, &
1147 basis_type=basis_type)
1148 CALL get_qs_kind(qs_kind=qs_kind_set(kind_b), basis_set=basis_set_b, &
1149 basis_type=basis_type)
1151 ra(1:3) =
pbc(particle_set(atom_a)%r(1:3), cell)
1152 rb(1:3) =
pbc(particle_set(atom_b)%r(1:3), cell)
1154 rab_l(1:3) = rb(1:3) - ra(1:3) + vec_l(1:3)
1159 a_1 = bf_start_from_atom(atom_a)
1160 a_2 = bf_end_from_atom(atom_a)
1161 b_1 = bf_start_from_atom(atom_b)
1162 b_2 = bf_end_from_atom(atom_b)
1164 ALLOCATE (v_l_ab(a_2 - a_1 + 1, b_2 - b_1 + 1))
1167 fba=basis_set_a, fbb=basis_set_b, &
1168 scona_shg=contr_a, sconb_shg=contr_b, &
1169 calculate_forces=.false.)
1171 v_l(a_1:a_2, b_1:b_2) = v_l(a_1:a_2, b_1:b_2) + factor*v_l_ab(:, :)
1173 DEALLOCATE (contr_a, contr_b, v_l_ab)
1180 DEALLOCATE (kind_of)
1182 CALL timestop(handle)
1184 END SUBROUTINE add_v_l
1199 COMPLEX(KIND=dp),
INTENT(INOUT) :: v_k(:, :, :)
1202 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
1203 REAL(kind=
dp),
INTENT(IN) :: omega
1204 INTEGER,
INTENT(IN) :: ikp_start, ikp_end
1206 CHARACTER(LEN=*),
PARAMETER :: routinen =
'add_ewald_reciprocal'
1207 INTEGER,
PARAMETER :: n_block = 128
1209 COMPLEX(KIND=dp),
ALLOCATABLE :: fourier_basis(:, :), scaled_basis(:, :)
1210 INTEGER :: bounds(3), handle, idim, ikp, ikp_local, &
1211 ix, iy, iz, n_atom, n_bf, n_col
1212 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: bf_end, bf_start
1213 REAL(kind=
dp) :: cutoff, p(3), p2, prefactor, q(3), &
1220 CALL timeset(routinen, handle)
1222 CALL get_qs_env(qs_env, cell=cell, para_env=para_env, particle_set=particles, qs_kind_set=qs_kinds)
1223 CALL get_basis_sizes(qs_env, n_atom, basis_type, bf_start, bf_end, n_bf)
1224 IF (count(cell%perd /= 0) == 2)
THEN
1225 CALL add_ewald_reciprocal_2d(v_k, qs_env, kpoints, basis_type, omega, &
1226 bf_start, bf_end, ikp_start, ikp_end)
1228 cpassert(count(cell%perd /= 0) == 3)
1229 reciprocal =
twopi*transpose(cell%h_inv)
1230 cutoff = 2.0_dp*omega*sqrt(
ewald_tail_exponent + ewald_lmax_margin*basis_lmax(qs_kinds, basis_type))
1237 ALLOCATE (fourier_basis(n_bf, n_block), scaled_basis(n_bf, n_block))
1239 DO ikp = ikp_start, ikp_end
1240 IF (
modulo(ikp, para_env%num_pe) /= para_env%mepos) cycle
1241 ikp_local = (ikp - para_env%mepos)/para_env%num_pe + 1
1242 IF (para_env%mepos == 0) ikp_local = ikp/para_env%num_pe
1243 q = kpoints%xkp(:, ikp)
1245 bounds(idim) = ceiling(cutoff*norm2(cell%hmat(:, idim))/
twopi + abs(q(idim)))
1248 DO ix = -bounds(1), bounds(1)
1249 DO iy = -bounds(2), bounds(2)
1250 DO iz = -bounds(3), bounds(3)
1251 p = matmul(reciprocal, q + real([ix, iy, iz],
dp))
1253 IF (p2 > cutoff**2) cycle
1255 CALL gaussian_basis_fourier(p, particles, qs_kinds, cell, basis_type, &
1256 bf_start, bf_end, fourier_basis(:, n_col))
1257 IF (p2 <= 0.0_dp)
THEN
1258 prefactor = -
pi/(cell%deth*omega**2)
1260 prefactor =
fourpi*exp(-p2/(4.0_dp*omega**2))/(cell%deth*p2)
1262 scaled_basis(:, n_col) = prefactor*fourier_basis(:, n_col)
1263 IF (n_col == n_block)
THEN
1264 CALL zgemm(
'N',
'C', n_bf, n_bf, n_col,
z_one, scaled_basis, n_bf, &
1265 fourier_basis, n_bf,
z_one, v_k(:, :, ikp_local), n_bf)
1271 CALL zgemm(
'N',
'C', n_bf, n_bf, n_col,
z_one, scaled_basis, n_bf, &
1272 fourier_basis, n_bf,
z_one, v_k(:, :, ikp_local), n_bf)
1275 DEALLOCATE (fourier_basis, scaled_basis)
1279 CALL timestop(handle)
1296 SUBROUTINE add_ewald_reciprocal_2d(V_k, qs_env, kpoints, basis_type, omega, &
1297 bf_start, bf_end, ikp_start, ikp_end)
1298 COMPLEX(KIND=dp),
INTENT(INOUT) :: v_k(:, :, :)
1301 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
1302 REAL(kind=
dp),
INTENT(IN) :: omega
1303 INTEGER,
INTENT(IN) :: bf_start(:), bf_end(:), ikp_start, &
1306 INTEGER,
PARAMETER :: n_kz = 192
1308 COMPLEX(KIND=dp),
ALLOCATABLE :: f_minus(:), f_plus(:), f_zero(:), &
1309 left(:, :), right(:, :)
1310 INTEGER :: free_axis, i_col, ikp, ikp_local, inode, &
1311 ix, iy, n_bf, nx, ny, periodic_axis(2)
1312 REAL(kind=
dp) :: a1(3), a2(3), area, b1(3), b2(3), &
1313 cutoff, factor, kz, nodes(n_kz), &
1314 normal(3), p(3), pnorm, q(3), weight, &
1321 CALL get_qs_env(qs_env, cell=cell, para_env=para_env, &
1322 particle_set=particles, qs_kind_set=qs_kinds)
1323 cpassert(count(cell%perd /= 0) == 2)
1324 periodic_axis = pack([1, 2, 3], cell%perd /= 0)
1325 free_axis = findloc(cell%perd, 0, dim=1)
1326 a1 = cell%hmat(:, periodic_axis(1))
1327 a2 = cell%hmat(:, periodic_axis(2))
1329 area = norm2(normal)
1330 cpassert(area > 0.0_dp)
1331 normal = normal/area
1335 cutoff = 2.0_dp*omega*sqrt(
ewald_tail_exponent + ewald_lmax_margin*basis_lmax(qs_kinds, basis_type))
1338 nodes(:) = 0.5_dp*cutoff*(nodes + 1.0_dp)
1339 weights(:) = 0.5_dp*cutoff*weights
1348 ALLOCATE (f_zero(n_bf), f_plus(n_bf), f_minus(n_bf), left(n_bf, 4*n_kz + 1), right(n_bf, 4*n_kz + 1))
1350 DO ikp = ikp_start, ikp_end
1351 IF (
modulo(ikp, para_env%num_pe) /= para_env%mepos) cycle
1352 ikp_local = (ikp - para_env%mepos)/para_env%num_pe + 1
1353 IF (para_env%mepos == 0) ikp_local = ikp/para_env%num_pe
1354 q = kpoints%xkp(:, ikp)
1355 IF (abs(q(free_axis)) > 0.0_dp)
THEN
1356 cpabort(
'2D reciprocal transfer has a nonzero nonperiodic component')
1358 nx = ceiling(cutoff*norm2(a1)/
twopi + abs(q(periodic_axis(1))))
1359 ny = ceiling(cutoff*norm2(a2)/
twopi + abs(q(periodic_axis(2))))
1362 p = b1*(q(periodic_axis(1)) + real(ix,
dp)) + &
1363 b2*(q(periodic_axis(2)) + real(iy,
dp))
1365 IF (pnorm > cutoff) cycle
1366 IF (pnorm <= 0.0_dp)
THEN
1367 cpabort(
'2D Coulomb at Gamma requires charge-channel separation')
1369 CALL gaussian_basis_fourier(p, particles, qs_kinds, cell, basis_type, &
1370 bf_start, bf_end, f_zero)
1371 factor =
twopi*erfc(pnorm/(2.0_dp*omega))/(area*pnorm)
1372 left(:, 1) = factor*f_zero
1373 right(:, 1) = f_zero
1376 CALL gaussian_basis_fourier(p + kz*normal, particles, qs_kinds, cell, &
1377 basis_type, bf_start, bf_end, f_plus)
1378 CALL gaussian_basis_fourier(p - kz*normal, particles, qs_kinds, cell, &
1379 basis_type, bf_start, bf_end, f_minus)
1380 weight = 2.0_dp*weights(inode)* &
1381 exp(-(pnorm**2 + kz**2)/(4.0_dp*omega**2))/ &
1382 (area*(pnorm**2 + kz**2))
1388 right(:, i_col + 2) = f_plus - f_zero
1389 right(:, i_col + 3) = f_minus - f_zero
1390 right(:, i_col) = right(:, i_col + 2) + right(:, i_col + 3)
1391 right(:, i_col + 1) = f_zero
1392 left(:, i_col) = weight*f_zero
1393 left(:, i_col + 1) = weight*right(:, i_col)
1394 left(:, i_col + 2) = weight*right(:, i_col + 2)
1395 left(:, i_col + 3) = weight*right(:, i_col + 3)
1397 CALL zgemm(
'N',
'C', n_bf, n_bf, 4*n_kz + 1,
z_one, left, n_bf, right, n_bf, &
1398 z_one, v_k(:, :, ikp_local), n_bf)
1403 DEALLOCATE (f_zero, f_plus, f_minus, left, right)
1405 END SUBROUTINE add_ewald_reciprocal_2d
1413 FUNCTION basis_lmax(qs_kinds, basis_type)
RESULT(lmax)
1415 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
1422 DO ikind = 1,
SIZE(qs_kinds)
1423 CALL get_qs_kind(qs_kinds(ikind), basis_set=basis, basis_type=basis_type)
1424 lmax = max(lmax, maxval(basis%lmax))
1426 END FUNCTION basis_lmax
1439 SUBROUTINE gaussian_basis_fourier(p, particles, qs_kinds, cell, basis_type, &
1440 bf_start, bf_end, values)
1441 REAL(kind=
dp),
INTENT(IN) :: p(3)
1445 CHARACTER(LEN=*),
INTENT(IN) :: basis_type
1446 INTEGER,
INTENT(IN) :: bf_start(:), bf_end(:)
1447 COMPLEX(KIND=dp),
INTENT(OUT) :: values(:)
1449 COMPLEX(KIND=dp) :: phase
1450 COMPLEX(KIND=dp),
ALLOCATABLE :: moments(:, :), primitive(:)
1451 INTEGER :: iatom, ico, idim, ikind, il, ipgf, iset, &
1452 isgf, lmax, ncart, offset
1453 REAL(kind=
dp) :: alpha, centre(3)
1457 DO iatom = 1,
SIZE(particles)
1458 ikind = particles(iatom)%atomic_kind%kind_number
1459 CALL get_qs_kind(qs_kinds(ikind), basis_set=basis, basis_type=basis_type)
1460 centre =
pbc(particles(iatom)%r, cell)
1461 phase = exp(
gaussi*sum(p*centre))
1462 cpassert(bf_end(iatom) - bf_start(iatom) + 1 == basis%nsgf)
1463 DO iset = 1, basis%nset
1464 lmax = basis%lmax(iset)
1466 ALLOCATE (moments(0:lmax, 3), primitive(ncart*basis%npgf(iset)))
1468 DO ipgf = 1, basis%npgf(iset)
1469 alpha = basis%zet(ipgf, iset)
1471 moments(0, idim) = sqrt(
pi/alpha)*exp(-p(idim)**2/(4.0_dp*alpha))
1472 IF (lmax > 0) moments(1, idim) =
gaussi*p(idim)*moments(0, idim)/(2.0_dp*alpha)
1474 moments(il, idim) = (
gaussi*p(idim)*moments(il - 1, idim) + &
1475 REAL(il - 1,
dp)*moments(il - 2, idim))/(2.0_dp*alpha)
1478 DO ico =
ncoset(basis%lmin(iset) - 1) + 1, ncart
1479 primitive((ipgf - 1)*ncart + ico) = &
1480 moments(
indco(1, ico), 1)*moments(
indco(2, ico), 2)*moments(
indco(3, ico), 3)
1483 offset = basis%first_sgf(1, iset)
1484 DO isgf = offset, offset + basis%nsgf_set(iset) - 1
1485 values(bf_start(iatom) + isgf - 1) = &
1486 phase*sum(basis%sphi(1:
SIZE(primitive), isgf)*primitive)
1488 DEALLOCATE (moments, primitive)
1491 END SUBROUTINE gaussian_basis_fourier
static GRID_HOST_DEVICE int modulo(int a, int m)
Equivalent of Fortran's MODULO, which always return a positive number. https://gcc....
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_set(atomic_kind_set, atom_of_kind, kind_of, natom_of_kind, maxatom, natom, nshell, fist_potential_present, shell_present, shell_adiabatic, shell_check_distance, damping_present)
Get attributes of an atomic kind set.
Handles all functions related to the CELL.
subroutine, public get_cell(cell, alpha, beta, gamma, deth, orthorhombic, abc, periodic, h, h_inv, symmetry_id, tag)
Get informations about a simulation cell.
constants for the different operators of the 2c-integrals
integer, parameter, public operator_coulomb
subroutine, public dbcsr_release_p(matrix)
...
logical function, public dbcsr_iterator_blocks_left(iterator)
...
subroutine, public dbcsr_iterator_stop(iterator)
...
subroutine, public dbcsr_init_p(matrix)
...
subroutine, public dbcsr_iterator_next_block(iterator, row, column, block, block_number_argument_has_been_removed, row_size, col_size, row_offset, col_offset, transposed)
...
subroutine, public dbcsr_iterator_start(iterator, matrix, shared, dynamic, dynamic_byrows)
...
subroutine, public dbcsr_set(matrix, alpha)
...
subroutine, public dbcsr_reserve_all_blocks(matrix)
Reserves all blocks.
Calculation of the incomplete Gamma function F_n(t) for multi-center integrals over Cartesian Gaussia...
subroutine, public init_md_ftable(nmax)
Initialize a table of F_n(t) values in the range 0 <= t <= 12 with a stepsize of 0....
Initialization for solid harmonic Gaussian (SHG) integral scheme. Scheme for calculation of contracte...
subroutine, public contraction_matrix_shg(basis, scon_shg)
contraction matrix for SHG integrals
Calculation of contracted, spherical Gaussian integrals using the solid harmonic Gaussian (SHG) integ...
subroutine, public int_operators_r12_ab_shg(r12_operator, vab, dvab, rab, fba, fbb, scona_shg, sconb_shg, omega, calculate_forces)
Calcululates the two-center integrals of the type (a|O(r12)|b) using the SHG scheme.
Defines the basic variable types.
integer, parameter, public dp_size
integer, parameter, public dp
Routines to compute the Coulomb integral V_(alpha beta)(k) for a k-point k using lattice summation in...
subroutine, public build_2c_coulomb_matrix_kp(matrix_v_kp, kpoints, basis_type, cell, particle_set, qs_kind_set, atomic_kind_set, size_lattice_sum, operator_type, ikp_start, ikp_end)
...
real(kind=dp), parameter ewald_tail_exponent
subroutine, public build_2c_coulomb_matrix_kp_dense(v_k, qs_env, kpoints, size_lattice_sum, basis_type, ikp_start, ikp_end)
Dense 2-center Coulomb matrix V_PQ(k) from a direct real-space lattice sum.
subroutine, public add_ewald_reciprocal(v_k, qs_env, kpoints, basis_type, omega, ikp_start, ikp_end)
Adds the reciprocal Ewald part sum_L exp(ik*L) (P 0 | erf(omega r)/r | Q L) to the dense V_PQ(k) of t...
Types and basic routines needed for a kpoint calculation.
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, lattice_fft)
Retrieve information from a kpoint environment.
Definition of mathematical constants and functions.
real(kind=dp), parameter, public pi
complex(kind=dp), parameter, public z_one
complex(kind=dp), parameter, public gaussi
real(kind=dp), parameter, public fourpi
real(kind=dp), parameter, public twopi
complex(kind=dp), parameter, public z_zero
Collection of simple mathematical functions and subroutines.
subroutine, public gauss_legendre(n, nodes, weights)
Gauss-Legendre nodes and weights on [-1,1], with nodes in ascending order. The Legendre roots are ref...
pure real(kind=dp) function, dimension(3), public vector_product(a, b)
Calculation of the vector product c = a x b.
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public ncoset
integer, dimension(:, :), allocatable, public indco
Define the data structure for the particle information.
subroutine, public get_qs_env(qs_env, atomic_kind_set, qs_kind_set, cell, super_cell, cell_ref, use_ref_cell, kpoints, dft_control, mos, sab_orb, sab_all, qmmm, qmmm_periodic, mimic, sac_ae, sac_ppl, sac_lri, sap_ppnl, sab_vdw, sab_scp, sap_oce, sab_lrc, sab_se, sab_xtbe, sab_tbe, sab_core, sab_xb, sab_xtb_pp, sab_xtb_nonbond, sab_almo, sab_kp, sab_kp_nosym, sab_cneo, particle_set, energy, force, matrix_h, matrix_h_im, matrix_ks, matrix_ks_im, matrix_vxc, run_rtp, rtp, matrix_h_kp, matrix_h_im_kp, matrix_ks_kp, matrix_ks_im_kp, matrix_vxc_kp, kinetic_kp, matrix_s_kp, matrix_w_kp, matrix_s_ri_aux_kp, matrix_s, matrix_s_ri_aux, matrix_w, matrix_p_mp2, matrix_p_mp2_admm, matrix_vhxc, rho, rho_xc, pw_env, ewald_env, ewald_pw, active_space, mpools, input, para_env, blacs_env, scf_control, rel_control, kinetic, qs_charges, vppl, xcint_weights, rho_core, rho_nlcc, rho_nlcc_g, ks_env, ks_qmmm_env, wf_history, scf_env, local_particles, local_molecules, distribution_2d, dbcsr_dist, molecule_kind_set, molecule_set, subsys, cp_subsys, oce, local_rho_set, rho_atom_set, task_list, task_list_soft, rho0_atom_set, rho0_mpole, rhoz_set, rhoz_cneo_set, ecoul_1c, rho0_s_rs, rho0_s_gs, rhoz_cneo_s_rs, rhoz_cneo_s_gs, do_kpoints, has_unit_metric, requires_mo_derivs, mo_derivs, mo_loc_history, nkind, natom, nelectron_total, nelectron_spin, efield, neighbor_list_id, linres_control, xas_env, virial, cp_ddapc_env, cp_ddapc_ewald, outer_scf_history, outer_scf_ihistory, x_data, et_coupling, dftb_potential, results, se_taper, se_store_int_env, se_nddo_mpole, se_nonbond_env, admm_env, lri_env, lri_density, exstate_env, ec_env, harris_env, dispersion_env, gcp_env, vee, rho_external, external_vxc, mask, mp2_env, bs_env, kg_env, wanniercentres, atprop, ls_scf_env, do_transport, transport_env, v_hartree_rspace, s_mstruct_changed, rho_changed, potential_changed, forces_up_to_date, mscfg_env, almo_scf_env, gradient_history, variable_history, embed_pot, spin_embed_pot, polar_env, mos_last_converged, eeq, rhs, do_rixs, tb_tblite)
Get the QUICKSTEP environment.
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, hund_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, proj_shell_charge, lr_atom, do_mtlr, u_j_loop, ao_coef, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
Provides all information about an atomic kind.
Type defining parameters related to the simulation cell.
Contains information about kpoints.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.