Fix GW if nmo < nao

This commit is contained in:
Frederick Stein 2025-01-29 18:02:55 +01:00 committed by Frederick Stein
parent 775670a48a
commit a24614b15a
2 changed files with 13 additions and 7 deletions

View file

@ -2661,8 +2661,8 @@ CONTAINS
CHARACTER(LEN=*), PARAMETER :: routineN = 'compute_eps_head_Berry'
INTEGER :: col, col_end_in_block, col_offset, col_size, handle, i_col, i_row, ikp, nkp, row, &
row_offset, row_size, row_start_in_block
INTEGER :: col, col_end_in_block, col_offset, col_size, handle, i_col, i_row, ikp, nkp, nmo, &
row, row_offset, row_size, row_start_in_block
REAL(KIND=dp) :: abs_k_square, cell_volume, &
correct_kpoint(3), cos_square, &
eigen_diff, relative_kpoint(3), &
@ -2681,6 +2681,8 @@ CONTAINS
nkp = kpoints%nkp
nmo = SIZE(Eigenval)
ALLOCATE (P_head(nkp))
P_head(:) = 0.0_dp
@ -2717,9 +2719,9 @@ CONTAINS
col_end_in_block = col_size
END IF
DO i_row = row_start_in_block, row_size
DO i_row = row_start_in_block, MIN(row_size, nmo - row_offset + 1)
DO i_col = 1, col_end_in_block
DO i_col = 1, MIN(col_end_in_block, nmo - col_offset + 1)
eigen_diff = Eigenval(i_col + col_offset - 1) - Eigenval(i_row + row_offset - 1)
@ -2757,9 +2759,9 @@ CONTAINS
col_end_in_block = col_size
END IF
DO i_row = row_start_in_block, row_size
DO i_row = row_start_in_block, MIN(row_size, nmo - row_offset + 1)
DO i_col = 1, col_end_in_block
DO i_col = 1, MIN(col_end_in_block, nmo - col_offset + 1)
eigen_diff = Eigenval(i_col + col_offset - 1) - Eigenval(i_row + row_offset - 1)

View file

@ -130,6 +130,7 @@ CONTAINS
REAL(KIND=dp) :: E_GAP_GW, E_HOMO_GW, E_LUMO_GW, eh1, ehfx, eigval_dft, eigval_hf_at_dft, &
energy_exc, energy_exc1, energy_exc1_aux_fit, energy_exc_aux_fit, energy_total, &
exx_minus_vxc, hfx_fraction, min_direct_HF_at_DFT_gap, t1, t2, tmp
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: matrix_tmp_2_diag
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :) :: Eigenval_kp_HF_at_DFT, vec_Sigma_x
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:, :, :) :: Eigenval_kp, vec_Sigma_x_minus_vxc_gw, &
vec_Sigma_x_minus_vxc_gw_im
@ -535,6 +536,8 @@ CONTAINS
ALLOCATE (vec_Sigma_x_minus_vxc_gw(nmo, nspins, nkp))
vec_Sigma_x_minus_vxc_gw = 0.0_dp
ALLOCATE (matrix_tmp_2_diag(dimen))
END IF
CALL dbcsr_set(mo_coeff_b, 0.0_dp)
@ -620,7 +623,8 @@ CONTAINS
matrix_tmp, 0.0_dp, matrix_tmp_2, first_row=homo + 1 - gw_corr_lev_occ, &
last_row=homo + gw_corr_lev_virt)
CALL dbcsr_get_diag(matrix_tmp_2, vec_Sigma_x_minus_vxc_gw(:, ispin, 1))
CALL dbcsr_get_diag(matrix_tmp_2, matrix_tmp_2_diag)
vec_Sigma_x_minus_vxc_gw(1:nmo, ispin, 1) = matrix_tmp_2_diag(1:nmo)
CALL dbcsr_set(matrix_tmp, 0.0_dp)
CALL dbcsr_set(matrix_tmp_2, 0.0_dp)