23#include "./base/base_uses.f90"
29 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'gw_kp_to_real_space_and_back'
49 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_trafo_rs_to_ikp'
51 INTEGER :: handle, img, nimages, nimages_fm_rs
53 CALL timeset(routinen, handle)
55 nimages =
SIZE(kpoints%index_to_cell, 1)
56 nimages_fm_rs =
SIZE(fm_rs)
58 cpassert(nimages == nimages_fm_rs)
60 cfm_ikp%local_data(:, :) =
z_zero
63 CALL add_rs_to_ikp(fm_rs(img)%local_data, cfm_ikp%local_data, kpoints%index_to_cell, &
64 kpoints%xkp(1:3, ikp), img)
80 REAL(kind=
dp),
DIMENSION(:, :, :) :: array_rs
81 COMPLEX(KIND=dp),
DIMENSION(:, :) :: array_kp
82 INTEGER,
DIMENSION(:, :) :: index_to_cell
83 REAL(kind=
dp) :: xkp(3)
85 CHARACTER(LEN=*),
PARAMETER :: routinen =
'trafo_rs_to_ikp'
87 INTEGER :: handle, i_cell, nimages
89 CALL timeset(routinen, handle)
91 nimages =
SIZE(index_to_cell, 1)
93 cpassert(nimages ==
SIZE(array_rs, 3))
95 array_kp(:, :) = 0.0_dp
96 DO i_cell = 1, nimages
98 CALL add_rs_to_ikp(array_rs(:, :, i_cell), array_kp, index_to_cell, xkp, i_cell)
102 CALL timestop(handle)
114 SUBROUTINE add_rs_to_ikp(array_rs, array_kp, index_to_cell, xkp, i_cell)
115 REAL(kind=
dp),
DIMENSION(:, :) :: array_rs
116 COMPLEX(KIND=dp),
DIMENSION(:, :) :: array_kp
117 INTEGER,
DIMENSION(:, :) :: index_to_cell
118 REAL(kind=
dp) :: xkp(3)
121 CHARACTER(LEN=*),
PARAMETER :: routinen =
'add_rs_to_ikp'
123 COMPLEX(KIND=dp) :: expikr
127 CALL timeset(routinen, handle)
129 arg = real(index_to_cell(i_cell, 1),
dp)*xkp(1) + &
130 REAL(index_to_cell(i_cell, 2),
dp)*xkp(2) + &
131 REAL(index_to_cell(i_cell, 3),
dp)*xkp(3)
135 array_kp(:, :) = array_kp(:, :) + expikr*array_rs(:, :)
137 CALL timestop(handle)
139 END SUBROUTINE add_rs_to_ikp
149 COMPLEX(KIND=dp),
DIMENSION(:, :, :) :: array_kp
150 REAL(kind=
dp),
DIMENSION(:, :) :: array_rs
154 CHARACTER(LEN=*),
PARAMETER :: routinen =
'trafo_ikp_to_rs'
156 INTEGER :: handle, ikp
158 CALL timeset(routinen, handle)
160 cpassert(kpoints%nkp ==
SIZE(array_kp, 3))
162 array_rs(:, :) = 0.0_dp
164 DO ikp = 1, kpoints%nkp
166 CALL add_ikp_to_rs(array_kp(:, :, ikp), array_rs, cell, kpoints, ikp)
170 CALL timestop(handle)
187 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm_add_ikp_to_rs'
189 INTEGER :: handle, img, nimages, nimages_fm_rs
190 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: index_to_cell
192 CALL timeset(routinen, handle)
194 nimages =
SIZE(kpoints%index_to_cell, 1)
195 nimages_fm_rs =
SIZE(fm_rs)
197 cpassert(nimages == nimages_fm_rs)
199 ALLOCATE (index_to_cell(nimages, 3))
200 index_to_cell(1:nimages, 1:3) = kpoints%index_to_cell(1:nimages, 1:3)
206 CALL add_ikp_to_rs(cfm_ikp%local_data(:, :), fm_rs(img)%local_data, &
207 index_to_cell(img, 1:3), kpoints, ikp)
211 CALL timestop(handle)
224 COMPLEX(KIND=dp),
DIMENSION(:, :) :: array_kp
225 REAL(kind=
dp),
DIMENSION(:, :, :) :: array_rs
228 INTEGER,
DIMENSION(:, :),
OPTIONAL,
POINTER :: index_to_cell_ext
230 CHARACTER(LEN=*),
PARAMETER :: routinen =
'add_ikp_to_all_rs'
232 INTEGER :: cell(3), handle, img, nimages
233 INTEGER,
DIMENSION(:, :),
POINTER :: index_to_cell
235 CALL timeset(routinen, handle)
237 IF (
PRESENT(index_to_cell_ext))
THEN
238 index_to_cell => index_to_cell_ext
240 index_to_cell => kpoints%index_to_cell
243 nimages =
SIZE(index_to_cell, 1)
244 cpassert(
SIZE(array_rs, 3) == nimages)
247 cell(1:3) = index_to_cell(img, 1:3)
249 CALL add_ikp_to_rs(array_kp, array_rs(:, :, img), cell, kpoints, ikp)
253 CALL timestop(handle)
265 SUBROUTINE add_ikp_to_rs(array_kp, array_rs, cell, kpoints, ikp)
266 COMPLEX(KIND=dp),
DIMENSION(:, :) :: array_kp
267 REAL(kind=
dp),
DIMENSION(:, :) :: array_rs
272 CHARACTER(LEN=*),
PARAMETER :: routinen =
'add_ikp_to_rs'
275 REAL(kind=
dp) :: arg, im, re
277 CALL timeset(routinen, handle)
279 arg = real(cell(1),
dp)*kpoints%xkp(1, ikp) + &
280 REAL(cell(2),
dp)*kpoints%xkp(2, ikp) + &
281 REAL(cell(3),
dp)*kpoints%xkp(3, ikp)
283 re = cos(
twopi*arg)*kpoints%wkp(ikp)
284 im = sin(
twopi*arg)*kpoints%wkp(ikp)
286 array_rs(:, :) = array_rs(:, :) + re*real(array_kp(:, :)) + im*aimag(array_kp(:, :))
288 CALL timestop(handle)
290 END SUBROUTINE add_ikp_to_rs
Represents a complex full matrix distributed on many processors.
represent a full matrix distributed on many processors
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public trafo_ikp_to_rs(array_kp, array_rs, cell, kpoints)
...
subroutine, public add_ikp_to_all_rs(array_kp, array_rs, kpoints, ikp, index_to_cell_ext)
...
subroutine, public fm_trafo_rs_to_ikp(cfm_ikp, fm_rs, kpoints, ikp)
...
subroutine, public fm_add_ikp_to_rs(cfm_ikp, fm_rs, kpoints, ikp)
...
subroutine, public trafo_rs_to_ikp(array_rs, array_kp, index_to_cell, xkp)
...
Defines the basic variable types.
integer, parameter, public dp
Types and basic routines needed for a kpoint calculation.
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public z_one
complex(kind=dp), parameter, public gaussi
real(kind=dp), parameter, public twopi
complex(kind=dp), parameter, public z_zero
Represent a complex full matrix.
Contains information about kpoints.