22 dbcsr_type_no_symmetry
35#include "./base/base_uses.f90"
41 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'kpoint_k_r_trafo_simple'
63 TYPE(
dbcsr_p_type),
DIMENSION(:, :),
POINTER :: rs_dbcsr_in
65 REAL(kind=
dp),
DIMENSION(:, :, :, :) :: rs_array_out
66 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index_out
68 CHARACTER(len=*),
PARAMETER :: routinen =
'replicate_rs_matrices'
70 CHARACTER :: matrix_sym
71 INTEGER :: handle, iatom, ispin, jatom, n_spin, &
73 INTEGER,
DIMENSION(3) :: cell
76 DIMENSION(:),
POINTER :: iterator
80 CALL timeset(routinen, handle)
82 IF (
SIZE(rs_dbcsr_in, 2) < 1)
THEN
83 CALL cp_abort(__location__,
"No source image cells provided!")
86 sab_kp_src => kpoint_in%sab_nl
89 n_spin =
SIZE(rs_dbcsr_in, 1)
90 CALL dbcsr_get_info(rs_dbcsr_in(1, 1)%matrix, group=group, matrix_type=matrix_sym)
95 src_index = kpoint_in%cell_to_index(cell(1), cell(2), cell(3))
96 IF (src_index == 0)
THEN
97 CALL cp_abort(__location__,
"Image not found in the source array.")
100 IF (matrix_sym == dbcsr_type_no_symmetry)
THEN
101 CALL write_block_no_sym(iatom, jatom, cell, rs_dbcsr_in(ispin, src_index)%matrix, &
102 rs_array_out(ispin, :, :, :), cell_to_index_out)
104 CALL write_block_symmetric(iatom, jatom, cell, rs_dbcsr_in(ispin, src_index)%matrix, &
105 rs_array_out(ispin, :, :, :), cell_to_index_out)
110 CALL group%sum(rs_array_out(:, :, :, :))
111 CALL timestop(handle)
124 SUBROUTINE write_block_symmetric(iatom, jatom, cell, matrix_in, array_out, cell_to_index_out)
125 INTEGER,
INTENT(IN) :: iatom, jatom
126 INTEGER,
DIMENSION(3),
INTENT(IN) :: cell
128 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(INOUT) :: array_out
129 INTEGER,
DIMENSION(:, :, :),
INTENT(IN),
POINTER :: cell_to_index_out
131 INTEGER :: col_offset, col_size, dest_index, &
132 dest_index_t, i, i_g, j, j_g, &
134 INTEGER,
DIMENSION(:),
POINTER :: col_offsets, row_offsets
136 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: block
138 CALL dbcsr_get_info(matrix_in, row_blk_offset=row_offsets, col_blk_offset=col_offsets)
139 IF (iatom > jatom)
THEN
141 row_size=row_size, col_size=col_size, found=found)
142 IF (.NOT. found)
RETURN
144 dest_index = cell_to_index_out(-cell(1), -cell(2), -cell(3))
145 IF (dest_index == 0) cpabort(
"Mirror image index not present.")
146 dest_index_t = cell_to_index_out(cell(1), cell(2), cell(3))
147 IF (dest_index_t == 0) cpabort(
"Image index not present.")
148 row_offset = row_offsets(jatom)
149 col_offset = col_offsets(iatom)
152 row_size=row_size, col_size=col_size, found=found)
153 IF (.NOT. found)
RETURN
155 dest_index = cell_to_index_out(cell(1), cell(2), cell(3))
156 IF (dest_index == 0) cpabort(
"Image index not present.")
157 dest_index_t = cell_to_index_out(-cell(1), -cell(2), -cell(3))
158 IF (dest_index_t == 0) cpabort(
"Mirror image index not present.")
159 row_offset = row_offsets(iatom)
160 col_offset = col_offsets(jatom)
167 i_g = i + row_offset - 1
169 j_g = j + col_offset - 1
170 array_out(i_g, j_g, dest_index) = block(i, j)
171 IF (iatom /= jatom) array_out(j_g, i_g, dest_index_t) = block(i, j)
175 END SUBROUTINE write_block_symmetric
187 SUBROUTINE write_block_no_sym(iatom, jatom, cell, matrix_in, array_out, cell_to_index_out)
188 INTEGER,
INTENT(IN) :: iatom, jatom
189 INTEGER,
DIMENSION(3),
INTENT(IN) :: cell
191 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(INOUT) :: array_out
192 INTEGER,
DIMENSION(:, :, :),
INTENT(IN),
POINTER :: cell_to_index_out
194 INTEGER :: col_offset, col_size, dest_index, i, &
195 i_g, j, j_g, row_offset, row_size
196 INTEGER,
DIMENSION(:),
POINTER :: col_offsets, row_offsets
198 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: block
200 dest_index = cell_to_index_out(cell(1), cell(2), cell(3))
201 IF (dest_index == 0) cpabort(
"Image index not present.")
202 CALL dbcsr_get_info(matrix_in, row_blk_offset=row_offsets, col_blk_offset=col_offsets)
203 row_offset = row_offsets(iatom)
204 col_offset = col_offsets(jatom)
206 row_size=row_size, col_size=col_size)
210 i_g = i + row_offset - 1
212 j_g = j + col_offset - 1
213 array_out(i_g, j_g, dest_index) = block(i, j)
217 END SUBROUTINE write_block_no_sym
229 SUBROUTINE rs_to_kp(rs_real, ks_complex, index_to_cell, xkp, deriv_direction, hmat)
230 REAL(kind=
dp),
DIMENSION(:, :, :),
INTENT(IN) :: rs_real
231 COMPLEX(kind=dp),
DIMENSION(:, :),
INTENT(OUT) :: ks_complex
232 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell
233 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: xkp
234 INTEGER,
INTENT(IN),
OPTIONAL :: deriv_direction
235 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN), &
238 CHARACTER(len=*),
PARAMETER :: routinen =
'rs_to_kp'
240 INTEGER :: handle, i, n_images
242 CALL timeset(routinen, handle)
244 n_images =
SIZE(rs_real, 3)
246 IF (
PRESENT(deriv_direction))
THEN
247 IF (.NOT.
PRESENT(hmat) .AND. deriv_direction /= 0)
THEN
248 CALL cp_abort(__location__,
"Derivative requested but h matrix not provided!")
252 ks_complex(:, :) = cmplx(0.0, 0.0, kind=
dp)
254 CALL add_rs_to_kp(ks_complex, rs_real(:, :, i), xkp, i, index_to_cell, deriv_direction, hmat)
256 CALL timestop(handle)
274 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_rs_to_kp'
276 INTEGER :: handle, img, nimages, nimages_fm_rs
278 CALL timeset(routinen, handle)
280 nimages =
SIZE(kpoints%index_to_cell, 2)
281 nimages_fm_rs =
SIZE(fm_rs)
283 IF (nimages /= nimages_fm_rs)
CALL cp_abort(__location__,
"Index to cell and provided fm "// &
284 "array are inconsistent.")
286 cfm_kp%local_data(:, :) =
z_zero
289 CALL add_rs_to_kp(cfm_kp%local_data, fm_rs(img)%local_data, kpoints%xkp(1:3, ikp), &
290 img, kpoints%index_to_cell)
294 CALL timestop(handle)
311 SUBROUTINE add_rs_to_kp(ks_array_out, rs_array_in, xkp, imindex, index_to_cell, deriv_direction, hmat)
312 COMPLEX(kind=dp),
DIMENSION(:, :),
INTENT(INOUT) :: ks_array_out
313 REAL(kind=
dp),
DIMENSION(:, :),
INTENT(IN) :: rs_array_in
314 REAL(kind=
dp),
DIMENSION(3),
INTENT(IN) :: xkp
315 INTEGER,
INTENT(IN) :: imindex
316 INTEGER,
DIMENSION(:, :),
INTENT(IN) :: index_to_cell
317 INTEGER,
INTENT(IN),
OPTIONAL :: deriv_direction
318 REAL(kind=
dp),
DIMENSION(3, 3),
INTENT(IN), &
321 COMPLEX(kind=dp) :: phase_factor
323 REAL(kind=
dp) :: deriv_factor
324 REAL(kind=
dp),
DIMENSION(3) :: cell_vector
326 IF (
PRESENT(deriv_direction) .AND. (.NOT.
PRESENT(hmat)))
THEN
327 CALL cp_abort(__location__,
"Deriv. direction given but no hmat provided")
330 deriv_factor = 1.0_dp
331 IF (
PRESENT(deriv_direction))
THEN
332 cell_vector = matmul(hmat, index_to_cell(1:3, imindex))
333 deriv_factor = cell_vector(deriv_direction)
336 phase_factor = cmplx(cos(
twopi*sum(xkp(:)*index_to_cell(:, imindex))), &
337 sin(
twopi*sum(xkp(:)*index_to_cell(:, imindex))), kind=
dp)
339 DO i = 1,
SIZE(ks_array_out, 1)
340 DO j = 1,
SIZE(ks_array_out, 2)
341 ks_array_out(i, j) = ks_array_out(i, j) + &
342 deriv_factor*phase_factor*rs_array_in(i, j)
345 END SUBROUTINE add_rs_to_kp
359 COMPLEX(kind=dp),
DIMENSION(:, :) :: array_kp
360 REAL(kind=
dp),
DIMENSION(:, :, :) :: array_rs
363 INTEGER,
DIMENSION(:, :),
OPTIONAL,
POINTER :: index_to_cell_ext
365 CHARACTER(len=*),
PARAMETER :: routinen =
'add_kp_to_all_rs'
367 INTEGER :: handle, img
368 INTEGER,
DIMENSION(3) :: cell
369 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell
371 index_to_cell => kpoints%index_to_cell
372 IF (
PRESENT(index_to_cell_ext)) index_to_cell => index_to_cell_ext
374 CALL timeset(routinen, handle)
376 IF (
SIZE(array_rs, 3) /=
SIZE(index_to_cell, 2))
CALL cp_abort(__location__, &
377 "The provided RS array and cell_to_index array are inconsistent.")
379 DO img = 1,
SIZE(array_rs, 3)
380 cell(:) = index_to_cell(:, img)
381 CALL add_kp_to_rs(array_kp, array_rs(:, :, img), cell, kpoints, ikp)
384 CALL timestop(handle)
403 CHARACTER(len=*),
PARAMETER :: routinen =
'fm_add_kp_to_all_rs'
405 INTEGER :: handle, img
406 INTEGER,
DIMENSION(3) :: cell
408 CALL timeset(routinen, handle)
410 IF (
SIZE(fm_rs, 1) /=
SIZE(kpoints%index_to_cell, 2))
CALL cp_abort(__location__, &
411 "The provided RS array and cell_to_index array are inconsistent.")
413 DO img = 1,
SIZE(fm_rs, 1)
414 cell(:) = kpoints%index_to_cell(:, img)
415 CALL add_kp_to_rs(cfm_kp%local_data, fm_rs(img)%local_data, cell, kpoints, ikp)
417 CALL timestop(handle)
432 COMPLEX(kind=dp),
DIMENSION(:, :) :: array_kp
433 REAL(kind=
dp),
DIMENSION(:, :) :: array_rs
434 INTEGER,
DIMENSION(3) :: cell
438 REAL(kind=
dp) :: phase
441 phase =
twopi*sum(kpoints%xkp(:, ikp)*cell(:))
445 array_rs(:, :) = array_rs(:, :) + (real(array_kp(:, :))*cos(phase) + &
446 aimag(array_kp(:, :))*sin(phase))*kpoints%wkp(ikp)
459 SUBROUTINE kp_to_rs(array_kp, array_rs, cell, kpoints)
460 COMPLEX(kind=dp),
DIMENSION(:, :, :) :: array_kp
461 REAL(kind=
dp),
DIMENSION(:, :) :: array_rs
462 INTEGER,
DIMENSION(3) :: cell
465 CHARACTER(len=*),
PARAMETER :: routinen =
'kp_to_rs'
467 INTEGER :: handle, ikp
469 IF (kpoints%nkp /=
SIZE(array_kp, 3))
CALL cp_abort(__location__, &
470 "Provided kpoints and array_kp are inconsistent.")
472 CALL timeset(routinen, handle)
474 array_rs(:, :) = 0.0_dp
475 DO ikp = 1, kpoints%nkp
476 CALL add_kp_to_rs(array_kp(:, :, ikp), array_rs, cell, kpoints, ikp)
479 CALL timestop(handle)
480 END SUBROUTINE kp_to_rs
Represents a complex full matrix distributed on many processors.
subroutine, public dbcsr_get_readonly_block_p(matrix, row, col, block, found, row_size, col_size)
Like dbcsr_get_block_p() but with matrix being INTENT(IN). When invoking this routine,...
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)
...
represent a full matrix distributed on many processors
Defines the basic variable types.
integer, parameter, public dp
Implements transformations from k-space to R-space for Fortran array matrices.
subroutine, public rs_to_kp(rs_real, ks_complex, index_to_cell, xkp, deriv_direction, hmat)
Integrate RS matrices (stored as Fortran array) into a kpoint matrix at given kp.
subroutine, public fm_add_kp_to_all_rs(cfm_kp, fm_rs, kpoints, ikp)
Adds given kpoint matrix to a single rs matrix.
subroutine, public add_kp_to_rs(array_kp, array_rs, cell, kpoints, ikp)
Adds given kpoint matrix to a single rs matrix.
subroutine, public add_kp_to_all_rs(array_kp, array_rs, kpoints, ikp, index_to_cell_ext)
Adds given kpoint matrix to all rs matrices.
subroutine, public replicate_rs_matrices(rs_dbcsr_in, kpoint_in, rs_array_out, cell_to_index_out)
Convert dbcsr matrices representing operators in real-space image cells to arrays.
subroutine, public fm_rs_to_kp(cfm_kp, fm_rs, kpoints, ikp)
Transforms array of fm RS matrices into cfm k-space matrix, at given kpoint index.
Types and basic routines needed for a kpoint calculation.
Definition of mathematical constants and functions.
real(kind=dp), parameter, public twopi
complex(kind=dp), parameter, public z_zero
Interface to the message passing library MPI.
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)
...
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)
...
Represent a complex full matrix.
Contains information about kpoints.