-
Notifications
You must be signed in to change notification settings - Fork 1
/
rpa_gw_kpoints_util.F
1849 lines (1413 loc) · 76.7 KB
/
rpa_gw_kpoints_util.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!--------------------------------------------------------------------------------------------------!
! CP2K: A general program to perform molecular dynamics simulations !
! Copyright 2000-2024 CP2K developers group <https://cp2k.org> !
! !
! SPDX-License-Identifier: GPL-2.0-or-later !
!--------------------------------------------------------------------------------------------------!
! **************************************************************************************************
!> \brief Routines treating GW and RPA calculations with kpoints
!> \par History
!> since 2018 continuous development [J. Wilhelm]
! **************************************************************************************************
MODULE rpa_gw_kpoints_util
USE cell_types, ONLY: cell_type,&
get_cell,&
pbc
USE cp_blacs_env, ONLY: cp_blacs_env_type
USE cp_cfm_basic_linalg, ONLY: cp_cfm_column_scale,&
cp_cfm_scale_and_add_fm,&
cp_cfm_upper_to_full
USE cp_cfm_cholesky, ONLY: cp_cfm_cholesky_decompose,&
cp_cfm_cholesky_invert
USE cp_cfm_diag, ONLY: cp_cfm_geeig,&
cp_cfm_geeig_canon,&
cp_cfm_heevd
USE cp_cfm_types, ONLY: cp_cfm_create,&
cp_cfm_get_info,&
cp_cfm_release,&
cp_cfm_set_all,&
cp_cfm_to_cfm,&
cp_cfm_to_fm,&
cp_cfm_type
USE cp_control_types, ONLY: dft_control_type
USE cp_dbcsr_api, ONLY: &
dbcsr_copy, dbcsr_create, dbcsr_deallocate_matrix, dbcsr_desymmetrize, dbcsr_filter, &
dbcsr_get_block_p, dbcsr_iterator_blocks_left, dbcsr_iterator_next_block, &
dbcsr_iterator_start, dbcsr_iterator_stop, dbcsr_iterator_type, dbcsr_p_type, &
dbcsr_release, dbcsr_reserve_all_blocks, dbcsr_set, dbcsr_transposed, dbcsr_type, &
dbcsr_type_no_symmetry
USE cp_dbcsr_operations, ONLY: copy_dbcsr_to_fm,&
copy_fm_to_dbcsr,&
dbcsr_allocate_matrix_set
USE cp_fm_basic_linalg, ONLY: cp_fm_scale_and_add
USE cp_fm_struct, ONLY: cp_fm_struct_type
USE cp_fm_types, ONLY: cp_fm_copy_general,&
cp_fm_create,&
cp_fm_release,&
cp_fm_set_all,&
cp_fm_type
USE hfx_types, ONLY: hfx_release
USE input_constants, ONLY: cholesky_off,&
kp_weights_W_auto,&
kp_weights_W_tailored,&
kp_weights_W_uniform
USE kinds, ONLY: dp
USE kpoint_methods, ONLY: kpoint_env_initialize,&
kpoint_initialize_mo_set,&
kpoint_initialize_mos
USE kpoint_types, ONLY: get_kpoint_info,&
kpoint_env_type,&
kpoint_type
USE machine, ONLY: m_walltime
USE mathconstants, ONLY: gaussi,&
twopi,&
z_one,&
z_zero
USE mathlib, ONLY: invmat
USE message_passing, ONLY: mp_para_env_type
USE parallel_gemm_api, ONLY: parallel_gemm
USE particle_types, ONLY: particle_type
USE qs_band_structure, ONLY: calculate_kpoints_for_bs
USE qs_environment_types, ONLY: get_qs_env,&
qs_environment_type
USE qs_mo_types, ONLY: get_mo_set
USE qs_scf_types, ONLY: qs_scf_env_type
USE rpa_gw_im_time_util, ONLY: compute_weight_re_im,&
get_atom_index_from_basis_function_index
USE rpa_im_time, ONLY: init_cell_index_rpa
USE scf_control_types, ONLY: scf_control_type
#include "./base/base_uses.f90"
IMPLICIT NONE
PRIVATE
CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'rpa_gw_kpoints_util'
PUBLIC :: invert_eps_compute_W_and_Erpa_kp, cp_cfm_power, real_space_to_kpoint_transform_rpa, &
get_mat_cell_T_from_mat_gamma, get_bandstruc_and_k_dependent_MOs, &
compute_wkp_W, mat_kp_from_mat_gamma
CONTAINS
! **************************************************************************************************
!> \brief ...
!> \param dimen_RI ...
!> \param num_integ_points ...
!> \param jquad ...
!> \param nkp ...
!> \param count_ev_sc_GW ...
!> \param para_env ...
!> \param Erpa ...
!> \param tau_tj ...
!> \param tj ...
!> \param wj ...
!> \param weights_cos_tf_w_to_t ...
!> \param wkp_W ...
!> \param do_gw_im_time ...
!> \param do_ri_Sigma_x ...
!> \param do_kpoints_from_Gamma ...
!> \param cfm_mat_Q ...
!> \param ikp_local ...
!> \param mat_P_omega ...
!> \param mat_P_omega_kp ...
!> \param qs_env ...
!> \param eps_filter_im_time ...
!> \param unit_nr ...
!> \param kpoints ...
!> \param fm_mat_Minv_L_kpoints ...
!> \param fm_matrix_L_kpoints ...
!> \param fm_mat_W ...
!> \param fm_mat_RI_global_work ...
!> \param mat_MinvVMinv ...
!> \param fm_matrix_Minv ...
!> \param fm_matrix_Minv_Vtrunc_Minv ...
! **************************************************************************************************
SUBROUTINE invert_eps_compute_W_and_Erpa_kp(dimen_RI, num_integ_points, jquad, nkp, count_ev_sc_GW, para_env, &
Erpa, tau_tj, tj, wj, weights_cos_tf_w_to_t, wkp_W, do_gw_im_time, &
do_ri_Sigma_x, do_kpoints_from_Gamma, &
cfm_mat_Q, ikp_local, mat_P_omega, mat_P_omega_kp, &
qs_env, eps_filter_im_time, unit_nr, kpoints, fm_mat_Minv_L_kpoints, &
fm_matrix_L_kpoints, fm_mat_W, &
fm_mat_RI_global_work, mat_MinvVMinv, fm_matrix_Minv, &
fm_matrix_Minv_Vtrunc_Minv)
INTEGER, INTENT(IN) :: dimen_RI, num_integ_points, jquad, nkp, &
count_ev_sc_GW
TYPE(mp_para_env_type), POINTER :: para_env
REAL(KIND=dp), INTENT(INOUT) :: Erpa
REAL(KIND=dp), DIMENSION(0:num_integ_points), &
INTENT(IN) :: tau_tj
REAL(KIND=dp), DIMENSION(:), INTENT(IN) :: tj, wj
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :), &
INTENT(IN) :: weights_cos_tf_w_to_t
REAL(KIND=dp), DIMENSION(:), INTENT(IN) :: wkp_W
LOGICAL, INTENT(IN) :: do_gw_im_time, do_ri_Sigma_x, &
do_kpoints_from_Gamma
TYPE(cp_cfm_type), INTENT(IN) :: cfm_mat_Q
INTEGER, INTENT(IN) :: ikp_local
TYPE(dbcsr_p_type), DIMENSION(:, :), INTENT(INOUT) :: mat_P_omega, mat_P_omega_kp
TYPE(qs_environment_type), POINTER :: qs_env
REAL(KIND=dp), INTENT(IN) :: eps_filter_im_time
INTEGER, INTENT(IN) :: unit_nr
TYPE(kpoint_type), POINTER :: kpoints
TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :) :: fm_mat_Minv_L_kpoints, &
fm_matrix_L_kpoints
TYPE(cp_fm_type), DIMENSION(:), INTENT(IN) :: fm_mat_W
TYPE(cp_fm_type) :: fm_mat_RI_global_work
TYPE(dbcsr_p_type), INTENT(IN) :: mat_MinvVMinv
TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :) :: fm_matrix_Minv, &
fm_matrix_Minv_Vtrunc_Minv
CHARACTER(LEN=*), PARAMETER :: routineN = 'invert_eps_compute_W_and_Erpa_kp'
INTEGER :: handle, ikp
LOGICAL :: do_this_ikp
REAL(KIND=dp) :: t1, t2
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: trace_Qomega
CALL timeset(routineN, handle)
t1 = m_walltime()
IF (do_kpoints_from_Gamma) THEN
CALL get_mat_cell_T_from_mat_gamma(mat_P_omega(jquad, :), qs_env, kpoints, jquad, unit_nr)
END IF
CALL transform_P_from_real_space_to_kpoints(mat_P_omega, mat_P_omega_kp, &
kpoints, eps_filter_im_time, jquad)
ALLOCATE (trace_Qomega(dimen_RI))
IF (unit_nr > 0) WRITE (unit_nr, '(/T3,A,1X,I3)') &
'GW_INFO| Computing chi and W frequency point', jquad
DO ikp = 1, nkp
! parallization, we either have all kpoints on all processors or a single kpoint per group
do_this_ikp = (ikp_local == -1) .OR. (ikp_local == 0 .AND. ikp == 1) .OR. (ikp_local == ikp)
IF (.NOT. do_this_ikp) CYCLE
! 1. remove all spurious negative eigenvalues from P(iw,k), multiplication Q(iw,k) = K^H(k)P(iw,k)K(k)
CALL compute_Q_kp_RPA(cfm_mat_Q, &
mat_P_omega_kp, &
fm_mat_Minv_L_kpoints(ikp, 1), &
fm_mat_Minv_L_kpoints(ikp, 2), &
fm_mat_RI_global_work, &
dimen_RI, ikp, nkp, ikp_local, para_env, &
qs_env%mp2_env%ri_rpa_im_time%make_chi_pos_definite)
! 2. Cholesky decomposition of Id + Q(iw,k)
CALL cholesky_decomp_Q(cfm_mat_Q, para_env, trace_Qomega, dimen_RI)
! 3. Computing E_c^RPA = E_c^RPA + a_w/N_k*sum_k ln[det(1+Q(iw,k))-Tr(Q(iw,k))]
CALL frequency_and_kpoint_integration(Erpa, cfm_mat_Q, para_env, trace_Qomega, &
dimen_RI, wj(jquad), kpoints%wkp(ikp))
IF (do_gw_im_time) THEN
! compute S^-1*V*S^-1 for exchange part of the self-energy in real space as W in real space
IF (do_ri_Sigma_x .AND. jquad == 1 .AND. count_ev_sc_GW == 1 .AND. do_kpoints_from_Gamma) THEN
CALL dbcsr_set(mat_MinvVMinv%matrix, 0.0_dp)
CALL copy_fm_to_dbcsr(fm_matrix_Minv_Vtrunc_Minv(1, 1), mat_MinvVMinv%matrix, keep_sparsity=.FALSE.)
END IF
IF (do_kpoints_from_Gamma) THEN
CALL compute_Wc_real_space_tau_GW(fm_mat_W, cfm_mat_Q, &
fm_matrix_L_kpoints(ikp, 1), &
fm_matrix_L_kpoints(ikp, 2), &
dimen_RI, num_integ_points, jquad, &
ikp, tj, tau_tj, weights_cos_tf_w_to_t, &
ikp_local, para_env, kpoints, qs_env, wkp_W)
END IF
END IF
END DO
! after the transform of (eps(iw)-1)^-1 from iw to it is done, multiply with V^1/2 to obtain W(it)
IF (do_gw_im_time .AND. do_kpoints_from_Gamma .AND. jquad == num_integ_points) THEN
CALL Wc_to_Minv_Wc_Minv(fm_mat_W, fm_matrix_Minv, para_env, dimen_RI, num_integ_points)
CALL deallocate_kp_matrices(fm_matrix_L_kpoints, fm_mat_Minv_L_kpoints)
END IF
DEALLOCATE (trace_Qomega)
t2 = m_walltime()
IF (unit_nr > 0) WRITE (unit_nr, '(T6,A,T56,F25.1)') 'Execution time (s):', t2 - t1
CALL timestop(handle)
END SUBROUTINE invert_eps_compute_W_and_Erpa_kp
! **************************************************************************************************
!> \brief ...
!> \param fm_matrix_L_kpoints ...
!> \param fm_mat_Minv_L_kpoints ...
! **************************************************************************************************
SUBROUTINE deallocate_kp_matrices(fm_matrix_L_kpoints, fm_mat_Minv_L_kpoints)
TYPE(cp_fm_type), ALLOCATABLE, DIMENSION(:, :) :: fm_matrix_L_kpoints, &
fm_mat_Minv_L_kpoints
CHARACTER(LEN=*), PARAMETER :: routineN = 'deallocate_kp_matrices'
INTEGER :: handle
CALL timeset(routineN, handle)
CALL cp_fm_release(fm_mat_Minv_L_kpoints)
CALL cp_fm_release(fm_matrix_L_kpoints)
CALL timestop(handle)
END SUBROUTINE deallocate_kp_matrices
! **************************************************************************************************
!> \brief ...
!> \param matrix ...
!> \param threshold ...
!> \param exponent ...
!> \param min_eigval ...
! **************************************************************************************************
SUBROUTINE cp_cfm_power(matrix, threshold, exponent, min_eigval)
TYPE(cp_cfm_type), INTENT(INOUT) :: matrix
REAL(KIND=dp) :: threshold, exponent
REAL(KIND=dp), OPTIONAL :: min_eigval
CHARACTER(LEN=*), PARAMETER :: routineN = 'cp_cfm_power'
COMPLEX(KIND=dp), PARAMETER :: czero = CMPLX(0.0_dp, 0.0_dp, KIND=dp)
COMPLEX(KIND=dp), ALLOCATABLE, DIMENSION(:) :: eigenvalues_exponent
INTEGER :: handle, i, ncol_global, nrow_global
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: eigenvalues
TYPE(cp_cfm_type) :: cfm_work
CALL timeset(routineN, handle)
CALL cp_cfm_create(cfm_work, matrix%matrix_struct)
CALL cp_cfm_set_all(cfm_work, z_zero)
! Test that matrix is square
CALL cp_cfm_get_info(matrix, nrow_global=nrow_global, ncol_global=ncol_global)
CPASSERT(nrow_global == ncol_global)
ALLOCATE (eigenvalues(nrow_global))
eigenvalues(:) = 0.0_dp
ALLOCATE (eigenvalues_exponent(nrow_global))
eigenvalues_exponent(:) = czero
! Diagonalize matrix: get eigenvectors and eigenvalues
CALL cp_cfm_heevd(matrix, cfm_work, eigenvalues)
DO i = 1, nrow_global
IF (eigenvalues(i) > threshold) THEN
eigenvalues_exponent(i) = CMPLX((eigenvalues(i))**(0.5_dp*exponent), threshold, KIND=dp)
ELSE
IF (PRESENT(min_eigval)) THEN
eigenvalues_exponent(i) = CMPLX(min_eigval, 0.0_dp, KIND=dp)
ELSE
eigenvalues_exponent(i) = czero
END IF
END IF
END DO
CALL cp_cfm_column_scale(cfm_work, eigenvalues_exponent)
CALL parallel_gemm("N", "C", nrow_global, nrow_global, nrow_global, z_one, &
cfm_work, cfm_work, z_zero, matrix)
DEALLOCATE (eigenvalues, eigenvalues_exponent)
CALL cp_cfm_release(cfm_work)
CALL timestop(handle)
END SUBROUTINE cp_cfm_power
! **************************************************************************************************
!> \brief ...
!> \param cfm_mat_Q ...
!> \param mat_P_omega_kp ...
!> \param fm_mat_L_re ...
!> \param fm_mat_L_im ...
!> \param fm_mat_RI_global_work ...
!> \param dimen_RI ...
!> \param ikp ...
!> \param nkp ...
!> \param ikp_local ...
!> \param para_env ...
!> \param make_chi_pos_definite ...
! **************************************************************************************************
SUBROUTINE compute_Q_kp_RPA(cfm_mat_Q, mat_P_omega_kp, fm_mat_L_re, fm_mat_L_im, &
fm_mat_RI_global_work, dimen_RI, ikp, nkp, ikp_local, para_env, &
make_chi_pos_definite)
TYPE(cp_cfm_type) :: cfm_mat_Q
TYPE(dbcsr_p_type), DIMENSION(:, :), INTENT(INOUT) :: mat_P_omega_kp
TYPE(cp_fm_type) :: fm_mat_L_re, fm_mat_L_im, &
fm_mat_RI_global_work
INTEGER, INTENT(IN) :: dimen_RI, ikp, nkp, ikp_local
TYPE(mp_para_env_type), POINTER :: para_env
LOGICAL, INTENT(IN) :: make_chi_pos_definite
CHARACTER(LEN=*), PARAMETER :: routineN = 'compute_Q_kp_RPA'
INTEGER :: handle
TYPE(cp_cfm_type) :: cfm_mat_L, cfm_mat_work
TYPE(cp_fm_type) :: fm_mat_work
CALL timeset(routineN, handle)
CALL cp_cfm_create(cfm_mat_work, fm_mat_L_re%matrix_struct)
CALL cp_cfm_set_all(cfm_mat_work, z_zero)
CALL cp_cfm_create(cfm_mat_L, fm_mat_L_re%matrix_struct)
CALL cp_cfm_set_all(cfm_mat_L, z_zero)
CALL cp_fm_create(fm_mat_work, fm_mat_L_re%matrix_struct)
CALL cp_fm_set_all(fm_mat_work, 0.0_dp)
! 1. Convert the dbcsr matrix mat_P_omega_kp (that is chi(k,iw)) to a full matrix and
! distribute it to subgroups
CALL mat_P_to_subgroup(mat_P_omega_kp, fm_mat_RI_global_work, &
fm_mat_work, cfm_mat_Q, ikp, nkp, ikp_local, para_env)
! 2. Remove all negative eigenvalues from chi(k,iw)
IF (make_chi_pos_definite) THEN
CALL cp_cfm_power(cfm_mat_Q, threshold=0.0_dp, exponent=1.0_dp)
END IF
! 3. Copy fm_mat_L_re and fm_mat_L_re to cfm_mat_L
CALL cp_cfm_scale_and_add_fm(z_zero, cfm_mat_L, z_one, fm_mat_L_re)
CALL cp_cfm_scale_and_add_fm(z_one, cfm_mat_L, gaussi, fm_mat_L_im)
! 4. work = P(iw,k)*L(k)
CALL parallel_gemm('N', 'N', dimen_RI, dimen_RI, dimen_RI, z_one, cfm_mat_Q, cfm_mat_L, &
z_zero, cfm_mat_work)
! 5. Q(iw,k) = L^H(k)*work
CALL parallel_gemm('C', 'N', dimen_RI, dimen_RI, dimen_RI, z_one, cfm_mat_L, cfm_mat_work, &
z_zero, cfm_mat_Q)
CALL cp_cfm_release(cfm_mat_work)
CALL cp_cfm_release(cfm_mat_L)
CALL cp_fm_release(fm_mat_work)
CALL timestop(handle)
END SUBROUTINE compute_Q_kp_RPA
! **************************************************************************************************
!> \brief ...
!> \param mat_P_omega_kp ...
!> \param fm_mat_RI_global_work ...
!> \param fm_mat_work ...
!> \param cfm_mat_Q ...
!> \param ikp ...
!> \param nkp ...
!> \param ikp_local ...
!> \param para_env ...
! **************************************************************************************************
SUBROUTINE mat_P_to_subgroup(mat_P_omega_kp, fm_mat_RI_global_work, &
fm_mat_work, cfm_mat_Q, ikp, nkp, ikp_local, para_env)
TYPE(dbcsr_p_type), DIMENSION(:, :), INTENT(INOUT) :: mat_P_omega_kp
TYPE(cp_fm_type), INTENT(IN) :: fm_mat_RI_global_work, fm_mat_work
TYPE(cp_cfm_type), INTENT(IN) :: cfm_mat_Q
INTEGER, INTENT(IN) :: ikp, nkp, ikp_local
TYPE(mp_para_env_type), POINTER :: para_env
CHARACTER(LEN=*), PARAMETER :: routineN = 'mat_P_to_subgroup'
INTEGER :: handle, jkp
TYPE(cp_fm_type) :: fm_dummy
TYPE(dbcsr_type), POINTER :: mat_P_omega_im, mat_P_omega_re
CALL timeset(routineN, handle)
IF (ikp_local == -1) THEN
mat_P_omega_re => mat_P_omega_kp(1, ikp)%matrix
CALL cp_fm_set_all(fm_mat_work, 0.0_dp)
CALL copy_dbcsr_to_fm(mat_P_omega_re, fm_mat_work)
CALL cp_cfm_scale_and_add_fm(z_zero, cfm_mat_Q, z_one, fm_mat_work)
mat_P_omega_im => mat_P_omega_kp(2, ikp)%matrix
CALL cp_fm_set_all(fm_mat_work, 0.0_dp)
CALL copy_dbcsr_to_fm(mat_P_omega_im, fm_mat_work)
CALL cp_cfm_scale_and_add_fm(z_one, cfm_mat_Q, gaussi, fm_mat_work)
ELSE
CALL cp_fm_set_all(fm_mat_work, 0.0_dp)
DO jkp = 1, nkp
mat_P_omega_re => mat_P_omega_kp(1, jkp)%matrix
CALL cp_fm_set_all(fm_mat_RI_global_work, 0.0_dp)
CALL copy_dbcsr_to_fm(mat_P_omega_re, fm_mat_RI_global_work)
CALL para_env%sync()
IF (ikp_local == jkp) THEN
CALL cp_fm_copy_general(fm_mat_RI_global_work, fm_mat_work, para_env)
ELSE
CALL cp_fm_copy_general(fm_mat_RI_global_work, fm_dummy, para_env)
END IF
CALL para_env%sync()
END DO
CALL cp_cfm_scale_and_add_fm(z_zero, cfm_mat_Q, z_one, fm_mat_work)
CALL cp_fm_set_all(fm_mat_work, 0.0_dp)
DO jkp = 1, nkp
mat_P_omega_im => mat_P_omega_kp(2, jkp)%matrix
CALL cp_fm_set_all(fm_mat_RI_global_work, 0.0_dp)
CALL copy_dbcsr_to_fm(mat_P_omega_im, fm_mat_RI_global_work)
CALL para_env%sync()
IF (ikp_local == jkp) THEN
CALL cp_fm_copy_general(fm_mat_RI_global_work, fm_mat_work, para_env)
ELSE
CALL cp_fm_copy_general(fm_mat_RI_global_work, fm_dummy, para_env)
END IF
CALL para_env%sync()
END DO
CALL cp_cfm_scale_and_add_fm(z_one, cfm_mat_Q, gaussi, fm_mat_work)
CALL cp_fm_set_all(fm_mat_work, 0.0_dp)
END IF
CALL para_env%sync()
CALL timestop(handle)
END SUBROUTINE mat_P_to_subgroup
! **************************************************************************************************
!> \brief ...
!> \param cfm_mat_Q ...
!> \param para_env ...
!> \param trace_Qomega ...
!> \param dimen_RI ...
! **************************************************************************************************
SUBROUTINE cholesky_decomp_Q(cfm_mat_Q, para_env, trace_Qomega, dimen_RI)
TYPE(cp_cfm_type), INTENT(IN) :: cfm_mat_Q
TYPE(mp_para_env_type), INTENT(IN) :: para_env
REAL(KIND=dp), DIMENSION(:), INTENT(OUT) :: trace_Qomega
INTEGER, INTENT(IN) :: dimen_RI
CHARACTER(LEN=*), PARAMETER :: routineN = 'cholesky_decomp_Q'
INTEGER :: handle, i_global, iiB, info_chol, &
j_global, jjB, ncol_local, nrow_local
INTEGER, DIMENSION(:), POINTER :: col_indices, row_indices
TYPE(cp_cfm_type) :: cfm_mat_Q_tmp, cfm_mat_work
CALL timeset(routineN, handle)
CALL cp_cfm_create(cfm_mat_work, cfm_mat_Q%matrix_struct)
CALL cp_cfm_set_all(cfm_mat_work, z_zero)
CALL cp_cfm_create(cfm_mat_Q_tmp, cfm_mat_Q%matrix_struct)
CALL cp_cfm_set_all(cfm_mat_Q_tmp, z_zero)
! get info of fm_mat_Q
CALL cp_cfm_get_info(matrix=cfm_mat_Q, &
nrow_local=nrow_local, &
ncol_local=ncol_local, &
row_indices=row_indices, &
col_indices=col_indices)
! calculate the trace of Q and add 1 on the diagonal
trace_Qomega = 0.0_dp
!$OMP PARALLEL DO DEFAULT(NONE) PRIVATE(jjB,iiB,i_global,j_global) &
!$OMP SHARED(ncol_local,nrow_local,col_indices,row_indices,trace_Qomega,cfm_mat_Q,dimen_RI)
DO jjB = 1, ncol_local
j_global = col_indices(jjB)
DO iiB = 1, nrow_local
i_global = row_indices(iiB)
IF (j_global == i_global .AND. i_global <= dimen_RI) THEN
trace_Qomega(i_global) = REAL(cfm_mat_Q%local_data(iiB, jjB))
cfm_mat_Q%local_data(iiB, jjB) = cfm_mat_Q%local_data(iiB, jjB) + z_one
END IF
END DO
END DO
CALL para_env%sum(trace_Qomega)
CALL cp_cfm_to_cfm(cfm_mat_Q, cfm_mat_Q_tmp)
CALL cp_cfm_cholesky_decompose(matrix=cfm_mat_Q, n=dimen_RI, info_out=info_chol)
CPASSERT(info_chol == 0)
CALL cp_cfm_release(cfm_mat_work)
CALL cp_cfm_release(cfm_mat_Q_tmp)
CALL timestop(handle)
END SUBROUTINE cholesky_decomp_Q
! **************************************************************************************************
!> \brief ...
!> \param Erpa ...
!> \param cfm_mat_Q ...
!> \param para_env ...
!> \param trace_Qomega ...
!> \param dimen_RI ...
!> \param freq_weight ...
!> \param kp_weight ...
! **************************************************************************************************
SUBROUTINE frequency_and_kpoint_integration(Erpa, cfm_mat_Q, para_env, trace_Qomega, &
dimen_RI, freq_weight, kp_weight)
REAL(KIND=dp), INTENT(INOUT) :: Erpa
TYPE(cp_cfm_type), INTENT(IN) :: cfm_mat_Q
TYPE(mp_para_env_type), INTENT(IN) :: para_env
REAL(KIND=dp), DIMENSION(:), INTENT(IN) :: trace_Qomega
INTEGER, INTENT(IN) :: dimen_RI
REAL(KIND=dp), INTENT(IN) :: freq_weight, kp_weight
CHARACTER(LEN=*), PARAMETER :: routineN = 'frequency_and_kpoint_integration'
INTEGER :: handle, i_global, iiB, j_global, jjB, &
ncol_local, nrow_local
INTEGER, DIMENSION(:), POINTER :: col_indices, row_indices
REAL(KIND=dp) :: FComega
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: Q_log
CALL timeset(routineN, handle)
! get info of cholesky_decomposed(fm_mat_Q)
CALL cp_cfm_get_info(matrix=cfm_mat_Q, &
nrow_local=nrow_local, &
ncol_local=ncol_local, &
row_indices=row_indices, &
col_indices=col_indices)
ALLOCATE (Q_log(dimen_RI))
Q_log = 0.0_dp
!$OMP PARALLEL DO DEFAULT(NONE) PRIVATE(jjB,iiB,i_global,j_global) &
!$OMP SHARED(ncol_local,nrow_local,col_indices,row_indices,Q_log,cfm_mat_Q,dimen_RI)
DO jjB = 1, ncol_local
j_global = col_indices(jjB)
DO iiB = 1, nrow_local
i_global = row_indices(iiB)
IF (j_global == i_global .AND. i_global <= dimen_RI) THEN
Q_log(i_global) = 2.0_dp*LOG(REAL(cfm_mat_Q%local_data(iiB, jjB)))
END IF
END DO
END DO
CALL para_env%sum(Q_log)
FComega = 0.0_dp
DO iiB = 1, dimen_RI
IF (MODULO(iiB, para_env%num_pe) /= para_env%mepos) CYCLE
! FComega=FComega+(LOG(Q_log(iiB))-trace_Qomega(iiB))/2.0_dp
FComega = FComega + (Q_log(iiB) - trace_Qomega(iiB))/2.0_dp
END DO
Erpa = Erpa + FComega*freq_weight*kp_weight
DEALLOCATE (Q_log)
CALL timestop(handle)
END SUBROUTINE frequency_and_kpoint_integration
! **************************************************************************************************
!> \brief ...
!> \param tj_dummy ...
!> \param tau_tj_dummy ...
!> \param weights_cos_tf_w_to_t_dummy ...
! **************************************************************************************************
SUBROUTINE get_dummys(tj_dummy, tau_tj_dummy, weights_cos_tf_w_to_t_dummy)
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:), &
INTENT(INOUT) :: tj_dummy, tau_tj_dummy
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :), &
INTENT(INOUT) :: weights_cos_tf_w_to_t_dummy
CHARACTER(LEN=*), PARAMETER :: routineN = 'get_dummys'
INTEGER :: handle
CALL timeset(routineN, handle)
ALLOCATE (weights_cos_tf_w_to_t_dummy(1, 1))
ALLOCATE (tj_dummy(1))
ALLOCATE (tau_tj_dummy(1))
tj_dummy(1) = 0.0_dp
tau_tj_dummy(1) = 0.0_dp
weights_cos_tf_w_to_t_dummy(1, 1) = 1.0_dp
CALL timestop(handle)
END SUBROUTINE
! **************************************************************************************************
!> \brief ...
!> \param tj_dummy ...
!> \param tau_tj_dummy ...
!> \param weights_cos_tf_w_to_t_dummy ...
! **************************************************************************************************
SUBROUTINE release_dummys(tj_dummy, tau_tj_dummy, weights_cos_tf_w_to_t_dummy)
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:), &
INTENT(INOUT) :: tj_dummy, tau_tj_dummy
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :), &
INTENT(INOUT) :: weights_cos_tf_w_to_t_dummy
CHARACTER(LEN=*), PARAMETER :: routineN = 'release_dummys'
INTEGER :: handle
CALL timeset(routineN, handle)
DEALLOCATE (weights_cos_tf_w_to_t_dummy)
DEALLOCATE (tj_dummy)
DEALLOCATE (tau_tj_dummy)
CALL timestop(handle)
END SUBROUTINE
! **************************************************************************************************
!> \brief ...
!> \param mat_P_omega ...
!> \param qs_env ...
!> \param kpoints ...
!> \param jquad ...
!> \param unit_nr ...
! **************************************************************************************************
SUBROUTINE get_mat_cell_T_from_mat_gamma(mat_P_omega, qs_env, kpoints, jquad, unit_nr)
TYPE(dbcsr_p_type), DIMENSION(:), INTENT(IN) :: mat_P_omega
TYPE(qs_environment_type), POINTER :: qs_env
TYPE(kpoint_type), POINTER :: kpoints
INTEGER, INTENT(IN) :: jquad, unit_nr
CHARACTER(LEN=*), PARAMETER :: routineN = 'get_mat_cell_T_from_mat_gamma'
INTEGER :: col, handle, i_cell, i_dim, j_cell, &
num_cells_P, num_integ_points, row
INTEGER, DIMENSION(3) :: cell_grid_P, periodic
INTEGER, DIMENSION(:, :), POINTER :: index_to_cell_P
LOGICAL :: i_cell_is_the_minimum_image_cell
REAL(KIND=dp) :: abs_rab_cell_i, abs_rab_cell_j
REAL(KIND=dp), DIMENSION(3) :: cell_vector, cell_vector_j, rab_cell_i, &
rab_cell_j
REAL(KIND=dp), DIMENSION(3, 3) :: hmat
REAL(KIND=dp), DIMENSION(:, :), POINTER :: data_block
TYPE(cell_type), POINTER :: cell
TYPE(dbcsr_iterator_type) :: iter
TYPE(particle_type), DIMENSION(:), POINTER :: particle_set
CALL timeset(routineN, handle)
NULLIFY (cell, particle_set)
CALL get_qs_env(qs_env, cell=cell, &
particle_set=particle_set)
CALL get_cell(cell=cell, h=hmat, periodic=periodic)
DO i_dim = 1, 3
! we have at most 3 neigboring cells per dimension and at least one because
! the density response at Gamma is only divided to neighboring
IF (periodic(i_dim) == 1) THEN
cell_grid_P(i_dim) = MAX(MIN((kpoints%nkp_grid(i_dim)/2)*2 - 1, 1), 3)
ELSE
cell_grid_P(i_dim) = 1
END IF
END DO
! overwrite the cell indices in kpoints
CALL init_cell_index_rpa(cell_grid_P, kpoints%cell_to_index, kpoints%index_to_cell, cell)
index_to_cell_P => kpoints%index_to_cell
num_cells_P = SIZE(index_to_cell_P, 2)
num_integ_points = SIZE(mat_P_omega, 1)
! first, copy the Gamma-only result from mat_P_omega(1) into all other matrices and
! remove the blocks later which do not belong to the cell index
DO i_cell = 2, num_cells_P
CALL dbcsr_copy(mat_P_omega(i_cell)%matrix, &
mat_P_omega(1)%matrix)
END DO
IF (jquad == 1 .AND. unit_nr > 0) THEN
WRITE (unit_nr, '(T3,A,T66,ES15.2)') 'GW_INFO| RI regularization parameter: ', &
qs_env%mp2_env%ri_rpa_im_time%regularization_RI
WRITE (unit_nr, '(T3,A,T66,ES15.2)') 'GW_INFO| eps_eigval_S: ', &
qs_env%mp2_env%ri_rpa_im_time%eps_eigval_S
IF (qs_env%mp2_env%ri_rpa_im_time%make_chi_pos_definite) THEN
WRITE (unit_nr, '(T3,A,T81)') &
'GW_INFO| Make chi(iw,k) positive definite? TRUE'
ELSE
WRITE (unit_nr, '(T3,A,T81)') &
'GW_INFO| Make chi(iw,k) positive definite? FALSE'
END IF
END IF
DO i_cell = 1, num_cells_P
CALL dbcsr_iterator_start(iter, mat_P_omega(i_cell)%matrix)
DO WHILE (dbcsr_iterator_blocks_left(iter))
CALL dbcsr_iterator_next_block(iter, row, col, data_block)
cell_vector(1:3) = MATMUL(hmat, REAL(index_to_cell_P(1:3, i_cell), dp))
rab_cell_i(1:3) = pbc(particle_set(row)%r(1:3), cell) - &
(pbc(particle_set(col)%r(1:3), cell) + cell_vector(1:3))
abs_rab_cell_i = SQRT(rab_cell_i(1)**2 + rab_cell_i(2)**2 + rab_cell_i(3)**2)
! minimum image convention
i_cell_is_the_minimum_image_cell = .TRUE.
DO j_cell = 1, num_cells_P
cell_vector_j(1:3) = MATMUL(hmat, REAL(index_to_cell_P(1:3, j_cell), dp))
rab_cell_j(1:3) = pbc(particle_set(row)%r(1:3), cell) - &
(pbc(particle_set(col)%r(1:3), cell) + cell_vector_j(1:3))
abs_rab_cell_j = SQRT(rab_cell_j(1)**2 + rab_cell_j(2)**2 + rab_cell_j(3)**2)
IF (abs_rab_cell_i > abs_rab_cell_j + 1.0E-6_dp) THEN
i_cell_is_the_minimum_image_cell = .FALSE.
END IF
END DO
IF (.NOT. i_cell_is_the_minimum_image_cell) THEN
data_block(:, :) = data_block(:, :)*0.0_dp
END IF
END DO
CALL dbcsr_iterator_stop(iter)
END DO
CALL timestop(handle)
END SUBROUTINE get_mat_cell_T_from_mat_gamma
! **************************************************************************************************
!> \brief ...
!> \param mat_P_omega ...
!> \param mat_P_omega_kp ...
!> \param kpoints ...
!> \param eps_filter_im_time ...
!> \param jquad ...
! **************************************************************************************************
SUBROUTINE transform_P_from_real_space_to_kpoints(mat_P_omega, mat_P_omega_kp, &
kpoints, eps_filter_im_time, jquad)
TYPE(dbcsr_p_type), DIMENSION(:, :), INTENT(INOUT) :: mat_P_omega, mat_P_omega_kp
TYPE(kpoint_type), POINTER :: kpoints
REAL(kind=dp), INTENT(IN) :: eps_filter_im_time
INTEGER, INTENT(IN) :: jquad
CHARACTER(LEN=*), PARAMETER :: routineN = 'transform_P_from_real_space_to_kpoints'
INTEGER :: handle, icell, nkp, num_integ_points
CALL timeset(routineN, handle)
num_integ_points = SIZE(mat_P_omega, 1)
nkp = SIZE(mat_P_omega, 2)
CALL real_space_to_kpoint_transform_rpa(mat_P_omega_kp(1, :), mat_P_omega_kp(2, :), mat_P_omega(jquad, :), &
kpoints, eps_filter_im_time)
DO icell = 1, SIZE(mat_P_omega, 2)
CALL dbcsr_set(mat_P_omega(jquad, icell)%matrix, 0.0_dp)
CALL dbcsr_filter(mat_P_omega(jquad, icell)%matrix, 1.0_dp)
END DO
CALL timestop(handle)
END SUBROUTINE transform_P_from_real_space_to_kpoints
! **************************************************************************************************
!> \brief ...
!> \param real_mat_kp ...
!> \param imag_mat_kp ...
!> \param mat_real_space ...
!> \param kpoints ...
!> \param eps_filter_im_time ...
!> \param real_mat_real_space ...
! **************************************************************************************************
SUBROUTINE real_space_to_kpoint_transform_rpa(real_mat_kp, imag_mat_kp, mat_real_space, &
kpoints, eps_filter_im_time, real_mat_real_space)
TYPE(dbcsr_p_type), DIMENSION(:), INTENT(INOUT) :: real_mat_kp, imag_mat_kp, mat_real_space
TYPE(kpoint_type), POINTER :: kpoints
REAL(KIND=dp), INTENT(IN) :: eps_filter_im_time
LOGICAL, INTENT(IN), OPTIONAL :: real_mat_real_space
CHARACTER(LEN=*), PARAMETER :: routineN = 'real_space_to_kpoint_transform_rpa'
INTEGER :: handle, i_cell, ik, nkp, num_cells
INTEGER, DIMENSION(3) :: cell
INTEGER, DIMENSION(:, :), POINTER :: index_to_cell
LOGICAL :: my_real_mat_real_space
REAL(KIND=dp) :: arg, coskl, sinkl
REAL(KIND=dp), DIMENSION(:, :), POINTER :: xkp
TYPE(dbcsr_type) :: mat_work
CALL timeset(routineN, handle)
my_real_mat_real_space = .TRUE.
IF (PRESENT(real_mat_real_space)) my_real_mat_real_space = real_mat_real_space
CALL dbcsr_create(matrix=mat_work, &
template=real_mat_kp(1)%matrix, &
matrix_type=dbcsr_type_no_symmetry)
CALL dbcsr_reserve_all_blocks(mat_work)
CALL dbcsr_set(mat_work, 0.0_dp)
! this kpoint environme t should be the kpoints for D(it) and X(it) created in init_cell_index_rpa
CALL get_kpoint_info(kpoints, nkp=nkp, xkp=xkp)
NULLIFY (index_to_cell)
index_to_cell => kpoints%index_to_cell
num_cells = SIZE(index_to_cell, 2)
CPASSERT(SIZE(mat_real_space) >= num_cells/2 + 1)
DO ik = 1, nkp
CALL dbcsr_reserve_all_blocks(real_mat_kp(ik)%matrix)
CALL dbcsr_reserve_all_blocks(imag_mat_kp(ik)%matrix)
CALL dbcsr_set(real_mat_kp(ik)%matrix, 0.0_dp)
CALL dbcsr_set(imag_mat_kp(ik)%matrix, 0.0_dp)
DO i_cell = 1, num_cells/2 + 1
cell(:) = index_to_cell(:, i_cell)
arg = REAL(cell(1), dp)*xkp(1, ik) + REAL(cell(2), dp)*xkp(2, ik) + REAL(cell(3), dp)*xkp(3, ik)
coskl = COS(twopi*arg)
sinkl = SIN(twopi*arg)
IF (my_real_mat_real_space) THEN
CALL dbcsr_add_local(real_mat_kp(ik)%matrix, mat_real_space(i_cell)%matrix, 1.0_dp, coskl)
CALL dbcsr_add_local(imag_mat_kp(ik)%matrix, mat_real_space(i_cell)%matrix, 1.0_dp, sinkl)
ELSE
CALL dbcsr_add_local(real_mat_kp(ik)%matrix, mat_real_space(i_cell)%matrix, 1.0_dp, -sinkl)
CALL dbcsr_add_local(imag_mat_kp(ik)%matrix, mat_real_space(i_cell)%matrix, 1.0_dp, coskl)
END IF
IF (.NOT. (cell(1) == 0 .AND. cell(2) == 0 .AND. cell(3) == 0)) THEN
CALL dbcsr_transposed(mat_work, mat_real_space(i_cell)%matrix)
IF (my_real_mat_real_space) THEN
CALL dbcsr_add_local(real_mat_kp(ik)%matrix, mat_work, 1.0_dp, coskl)
CALL dbcsr_add_local(imag_mat_kp(ik)%matrix, mat_work, 1.0_dp, -sinkl)
ELSE
! for an imaginary real-space matrix, we need to consider the imaginary unit
! and we need to take into account that the transposed gives an extra "-" sign
! because the transposed is actually Hermitian conjugate
CALL dbcsr_add_local(real_mat_kp(ik)%matrix, mat_work, 1.0_dp, -sinkl)
CALL dbcsr_add_local(imag_mat_kp(ik)%matrix, mat_work, 1.0_dp, -coskl)
END IF
CALL dbcsr_set(mat_work, 0.0_dp)
END IF
END DO
CALL dbcsr_filter(real_mat_kp(ik)%matrix, eps_filter_im_time)
CALL dbcsr_filter(imag_mat_kp(ik)%matrix, eps_filter_im_time)
END DO
CALL dbcsr_release(mat_work)
CALL timestop(handle)
END SUBROUTINE real_space_to_kpoint_transform_rpa
! **************************************************************************************************
!> \brief ...
!> \param mat_a ...
!> \param mat_b ...
!> \param alpha ...
!> \param beta ...
! **************************************************************************************************
SUBROUTINE dbcsr_add_local(mat_a, mat_b, alpha, beta)
TYPE(dbcsr_type), INTENT(INOUT) :: mat_a, mat_b
REAL(kind=dp), INTENT(IN) :: alpha, beta
INTEGER :: col, row
LOGICAL :: found
REAL(KIND=dp), DIMENSION(:, :), POINTER :: block_to_compute, data_block
TYPE(dbcsr_iterator_type) :: iter
CALL dbcsr_iterator_start(iter, mat_b)
DO WHILE (dbcsr_iterator_blocks_left(iter))
CALL dbcsr_iterator_next_block(iter, row, col, data_block)
NULLIFY (block_to_compute)
CALL dbcsr_get_block_p(matrix=mat_a, &
row=row, col=col, block=block_to_compute, found=found)
CPASSERT(found)
block_to_compute(:, :) = alpha*block_to_compute(:, :) + beta*data_block(:, :)
END DO
CALL dbcsr_iterator_stop(iter)
END SUBROUTINE dbcsr_add_local
! **************************************************************************************************
!> \brief ...
!> \param fm_mat_W_tau ...
!> \param cfm_mat_Q ...
!> \param fm_mat_L_re ...
!> \param fm_mat_L_im ...
!> \param dimen_RI ...
!> \param num_integ_points ...
!> \param jquad ...
!> \param ikp ...
!> \param tj ...
!> \param tau_tj ...
!> \param weights_cos_tf_w_to_t ...
!> \param ikp_local ...
!> \param para_env ...
!> \param kpoints ...
!> \param qs_env ...
!> \param wkp_W ...
! **************************************************************************************************
SUBROUTINE compute_Wc_real_space_tau_GW(fm_mat_W_tau, cfm_mat_Q, fm_mat_L_re, fm_mat_L_im, &
dimen_RI, num_integ_points, jquad, &
ikp, tj, tau_tj, weights_cos_tf_w_to_t, ikp_local, &