Skip to content

Commit

Permalink
GW for small unit cells with full k-points (using DFT with k-points) (c…
Browse files Browse the repository at this point in the history
…p2k#3448)

Co-authored-by: JWilhelm <[email protected]>
  • Loading branch information
JWilhelm and JWilhelm authored Jun 5, 2024
1 parent 3a64028 commit 11a343a
Show file tree
Hide file tree
Showing 25 changed files with 5,867 additions and 2,172 deletions.
6 changes: 5 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,14 @@ list(
grrm_utils.F
gapw_1c_basis_set.F
gw_communication.F
gw_methods.F
gw_main.F
gw_large_cell_gamma.F
gw_small_cell_full_kp.F
post_scf_bandstructure_types.F
post_scf_bandstructure_utils.F
gw_utils.F
gw_integrals.F
gw_kp_to_real_space_and_back.F
hartree_local_methods.F
hartree_local_types.F
header.F
Expand Down
3 changes: 3 additions & 0 deletions src/common/bibliography.F
Original file line number Diff line number Diff line change
Expand Up @@ -4901,6 +4901,9 @@ SUBROUTINE add_all_references()
" dichalcogenide heterobilayers", &
"SO Journal of Chemical Theory and Computation", &
"PY 2024", &
"VL 20", &
"BP 2202", &
"EP 2208", &
"ER"), &
DOI="10.1021/acs.jctc.3c01230")

Expand Down
87 changes: 86 additions & 1 deletion src/gw_communication.F
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@ MODULE gw_communication
dbcsr_get_stored_coordinates, dbcsr_iterator_blocks_left, dbcsr_iterator_next_block, &
dbcsr_iterator_start, dbcsr_iterator_stop, dbcsr_iterator_type, dbcsr_release, &
dbcsr_reserve_all_blocks, dbcsr_reserve_blocks, dbcsr_set, dbcsr_type
USE cp_dbcsr_operations, ONLY: copy_fm_to_dbcsr
USE cp_fm_types, ONLY: cp_fm_type
USE dbt_api, ONLY: dbt_clear,&
dbt_copy,&
dbt_copy_matrix_to_tensor,&
dbt_copy_tensor_to_matrix,&
dbt_create,&
dbt_destroy,&
dbt_type
USE kinds, ONLY: dp
USE message_passing, ONLY: mp_para_env_type,&
mp_request_type,&
mp_waitall
USE post_scf_bandstructure_types, ONLY: post_scf_bandstructure_type
#include "./base/base_uses.f90"

IMPLICIT NONE
Expand All @@ -28,7 +38,7 @@ MODULE gw_communication

CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'gw_communication'

PUBLIC :: global_matrix_to_local_matrix, local_matrix_to_global_matrix
PUBLIC :: local_dbt_to_global_mat, fm_to_local_tensor

TYPE buffer_type
REAL(KIND=dp), DIMENSION(:), POINTER :: msg => NULL()
Expand All @@ -40,6 +50,81 @@ MODULE gw_communication

CONTAINS

! **************************************************************************************************
!> \brief ...
!> \param fm_global ...
!> \param mat_global ...
!> \param mat_local ...
!> \param tensor ...
!> \param bs_env ...
!> \param atom_ranges ...
! **************************************************************************************************
SUBROUTINE fm_to_local_tensor(fm_global, mat_global, mat_local, tensor, bs_env, atom_ranges)

TYPE(cp_fm_type) :: fm_global
TYPE(dbcsr_type) :: mat_global, mat_local
TYPE(dbt_type) :: tensor
TYPE(post_scf_bandstructure_type), POINTER :: bs_env
INTEGER, DIMENSION(:, :), OPTIONAL :: atom_ranges

CHARACTER(LEN=*), PARAMETER :: routineN = 'fm_to_local_tensor'

INTEGER :: handle
TYPE(dbt_type) :: tensor_tmp

CALL timeset(routineN, handle)

CALL dbt_clear(tensor)
CALL copy_fm_to_dbcsr(fm_global, mat_global, keep_sparsity=.FALSE.)
CALL dbcsr_filter(mat_global, bs_env%eps_filter)
IF (PRESENT(atom_ranges)) THEN
CALL global_matrix_to_local_matrix(mat_global, mat_local, bs_env%para_env, &
bs_env%para_env_tensor%num_pe, atom_ranges)
ELSE
CALL global_matrix_to_local_matrix(mat_global, mat_local, bs_env%para_env, &
bs_env%para_env_tensor%num_pe)
END IF
CALL dbt_create(mat_local, tensor_tmp)
CALL dbt_copy_matrix_to_tensor(mat_local, tensor_tmp)
CALL dbt_copy(tensor_tmp, tensor, move_data=.TRUE.)
CALL dbt_destroy(tensor_tmp)
CALL dbcsr_set(mat_local, 0.0_dp)
CALL dbcsr_filter(mat_local, 1.0_dp)

CALL timestop(handle)

END SUBROUTINE fm_to_local_tensor

! **************************************************************************************************
!> \brief ...
!> \param tensor ...
!> \param mat_tensor ...
!> \param mat_global ...
!> \param para_env ...
! **************************************************************************************************
SUBROUTINE local_dbt_to_global_mat(tensor, mat_tensor, mat_global, para_env)

TYPE(dbt_type) :: tensor
TYPE(dbcsr_type) :: mat_tensor, mat_global
TYPE(mp_para_env_type), POINTER :: para_env

CHARACTER(LEN=*), PARAMETER :: routineN = 'local_dbt_to_global_mat'

INTEGER :: handle

CALL timeset(routineN, handle)

CALL dbt_copy_tensor_to_matrix(tensor, mat_tensor)
CALL dbt_clear(tensor)
! the next para_env%sync is not mandatory, but it makes the timing output
! of local_matrix_to_global_matrix correct
CALL para_env%sync()
CALL local_matrix_to_global_matrix(mat_tensor, mat_global, para_env)

CALL timestop(handle)

END SUBROUTINE local_dbt_to_global_mat

! **************************************************************************************************
!> \brief ...
!> \param mat_global ...
Expand Down
Loading

0 comments on commit 11a343a

Please sign in to comment.