Skip to content

Commit

Permalink
periodic G0W0+SOC also for open-shell
Browse files Browse the repository at this point in the history
  • Loading branch information
JWilhelm committed Nov 27, 2023
1 parent 0b3f9b5 commit 70cdbe9
Show file tree
Hide file tree
Showing 9 changed files with 473 additions and 238 deletions.
74 changes: 9 additions & 65 deletions src/gw_methods.F
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ MODULE gw_methods
de_init_bs_env
USE input_constants, ONLY: ri_rpa_g0w0_crossing_newton
USE input_section_types, ONLY: section_vals_type
USE kinds, ONLY: default_path_length,&
USE kinds, ONLY: default_string_length,&
dp,&
int_8
USE kpoint_coulomb_2c, ONLY: build_2c_coulomb_matrix_kp
Expand All @@ -78,7 +78,8 @@ MODULE gw_methods
USE particle_types, ONLY: particle_type
USE physcon, ONLY: evolt
USE post_scf_bandstructure_types, ONLY: post_scf_bandstructure_type
USE post_scf_bandstructure_utils, ONLY: cfm_ikp_from_fm_Gamma
USE post_scf_bandstructure_utils, ONLY: cfm_ikp_from_fm_Gamma,&
get_fname
USE qs_environment_types, ONLY: get_qs_env,&
qs_environment_type
USE qs_kind_types, ONLY: qs_kind_type
Expand Down Expand Up @@ -305,7 +306,7 @@ SUBROUTINE fm_read(fm, bs_env, mat_name, idx)

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

CHARACTER(LEN=default_path_length) :: f_chi
CHARACTER(LEN=default_string_length) :: f_chi
INTEGER :: handle, unit_nr

CALL timeset(routineN, handle)
Expand Down Expand Up @@ -600,7 +601,7 @@ SUBROUTINE fm_write(fm, matrix_index, matrix_name, qs_env)
CHARACTER(LEN=*), PARAMETER :: key = 'PROPERTIES%BANDSTRUCTURE%GW%PRINT%RESTART', &
routineN = 'fm_write'

CHARACTER(LEN=default_path_length) :: filename
CHARACTER(LEN=default_string_length) :: filename
INTEGER :: handle, unit_nr
TYPE(cp_logger_type), POINTER :: logger
TYPE(section_vals_type), POINTER :: input
Expand Down Expand Up @@ -2353,7 +2354,7 @@ SUBROUTINE delete_unnecessary_files(bs_env)

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

CHARACTER(LEN=default_path_length) :: f_chi, f_W_t, prefix
CHARACTER(LEN=default_string_length) :: f_chi, f_W_t, prefix
INTEGER :: handle, i_t

CALL timeset(routineN, handle)
Expand Down Expand Up @@ -2661,10 +2662,9 @@ SUBROUTINE analyt_conti_and_print(bs_env, Sigma_c_ikp_n_freq, Sigma_x_ikp_n, V_x

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

CHARACTER(len=1) :: digits_ikp
CHARACTER(len=3) :: occ_vir
CHARACTER(len=default_path_length) :: fname
INTEGER :: handle, i_mo, iunit, n_mo, n_zeros
CHARACTER(len=default_string_length) :: fname
INTEGER :: handle, i_mo, iunit, n_mo
REAL(KIND=dp), ALLOCATABLE, DIMENSION(:) :: dummy, Sigma_c_ikp_n_qp

CALL timeset(routineN, handle)
Expand Down Expand Up @@ -2698,29 +2698,7 @@ SUBROUTINE analyt_conti_and_print(bs_env, Sigma_c_ikp_n_freq, Sigma_x_ikp_n, V_x
Sigma_x_ikp_n(:) - &
V_xc_ikp_n(:)

n_zeros = count_digits(bs_env%kpoints_DOS%nkp) - count_digits(ikp)

WRITE (digits_ikp, '(I1)') count_digits(ikp)

SELECT CASE (n_zeros)
CASE (0)
WRITE (fname, "(A39,I"//digits_ikp//")") "SCF_and_G0W0_band_structure_for_kpoint_", ikp
CASE (1)
WRITE (fname, "(A40,I"//digits_ikp//")") "SCF_and_G0W0_band_structure_for_kpoint_0", ikp
CASE (2)
WRITE (fname, "(A41,I"//digits_ikp//")") "SCF_and_G0W0_band_structure_for_kpoint_00", ikp
CASE (3)
WRITE (fname, "(A42,I"//digits_ikp//")") "SCF_and_G0W0_band_structure_for_kpoint_000", ikp
END SELECT

! for molecules, we don't have any k-points
IF (ikp == 1 .AND. bs_env%kpoints_DOS%nkp == 1) THEN
WRITE (fname, "(A)") "SCF_and_G0W0_band_structure"
END IF
IF (bs_env%n_spin == 2) THEN
WRITE (fname, "(2A,I1)") TRIM(fname), "_spin_", ispin
END IF
CALL get_fname(fname, bs_env, ikp, "SCF_and_G0W0", ispin=ispin)

IF (bs_env%para_env%is_source()) THEN

Expand Down Expand Up @@ -2752,31 +2730,6 @@ SUBROUTINE analyt_conti_and_print(bs_env, Sigma_c_ikp_n_freq, Sigma_x_ikp_n, V_x

END SUBROUTINE analyt_conti_and_print

! **************************************************************************************************
!> \brief ...
!> \param int_number ...
!> \return ...
! **************************************************************************************************
PURE FUNCTION count_digits(int_number)
INTEGER, INTENT(IN) :: int_number
INTEGER :: count_digits
INTEGER :: digitCount, tempInt
digitCount = 0
tempInt = int_number
DO WHILE (tempInt /= 0)
tempInt = tempInt/10
digitCount = digitCount + 1
END DO
count_digits = digitCount
END FUNCTION count_digits
! **************************************************************************************************
!> \brief ...
!> \param bs_env ...
Expand Down Expand Up @@ -2908,15 +2861,6 @@ SUBROUTINE G0W0_hamiltonian(bs_env)
matrix_a=bs_env%fm_work_mo(1), matrix_b=bs_env%fm_s_Gamma, &
beta=0.0_dp, matrix_c=bs_env%fm_h_G0W0_Gamma)

! JW think again how to best incorporate SOC in GW...
! IF (bs_env%do_soc) THEN
! ! Spinor G0W0-matrix
! ! H^G0W0_µν,σσ' = h^G0W0_µν,σ*δ_σσ' + sum_α V^SOC_µν^(α)*Pauli-matrix^(α)_σσ',
! ! see Hartwigsen, Goedecker, Hutter, Eq.(18) (doi.org/10.1103/PhysRevB.58.3641)
! CALL H_KS_spinor(bs_env%cfm_h_G0W0_spinor_ao_Gamma, bs_env%fm_h_G0W0_Gamma, &
! bs_env%mat_V_SOC_xyz(:, 1))
! END IF

CALL timestop(handle)

END SUBROUTINE G0W0_hamiltonian
Expand Down
16 changes: 8 additions & 8 deletions src/gw_utils.F
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ MODULE gw_utils
section_vals_type,&
section_vals_val_get,&
section_vals_val_set
USE kinds, ONLY: default_path_length,&
USE kinds, ONLY: default_string_length,&
dp,&
int_8
USE kpoint_methods, ONLY: kpoint_init_cell_index
Expand Down Expand Up @@ -152,11 +152,11 @@ SUBROUTINE create_and_init_bs_env_for_gw(qs_env, bs_env, bs_sec)

CALL setup_time_and_frequency_minimax_grid(bs_env)

! free memory in qs_env; only if one is not doing local VBM, CBM, gap because
! we need real-space grid operations in pw_env, task_list there
! Recommendation: perform GW calculation without calculating local VBM, CBM, gap
! to deallocate qs_env (and safe memory). Then use GW restart files
! in a subsequent calculation to calculate local VBM, CBM, gap
! free memory in qs_env; only if one is not calculating the LDOS because
! we need real-space grid operations in pw_env, task_list for the LDOS
! Recommendation in case of memory issues: first perform GW calculation without calculating
! LDOS (to safe memor). Then, use GW restart files
! in a subsequent calculation to calculate the LDOS
IF (.NOT. bs_env%do_ldos) THEN
CALL qs_env_part_release(qs_env)
END IF
Expand Down Expand Up @@ -472,7 +472,7 @@ SUBROUTINE setup_kpoints_chi_eps_W(qs_env, bs_env, kpoints)
WRITE (UNIT=u, FMT="(T2,1A,T71,3I4)") "K-point mesh 1 for χ, ε, W", nkp_grid(1:3)
WRITE (UNIT=u, FMT="(T2,2A,T71,3I4)") "K-point mesh 2 for χ, ε, W ", &
"(for k-point extrapolation of W)", nkp_grid_extra(1:3)
WRITE (UNIT=u, FMT="(T2,A,T79,L)") "Approximate the k-point extrapolation", &
WRITE (UNIT=u, FMT="(T2,A,T80,L)") "Approximate the k-point extrapolation", &
bs_env%approx_kp_extrapol
END IF

Expand Down Expand Up @@ -1053,7 +1053,7 @@ SUBROUTINE check_for_restart_files(qs_env, bs_env)
CHARACTER(LEN=*), PARAMETER :: routineN = 'check_for_restart_files'

CHARACTER(LEN=9) :: frmt
CHARACTER(LEN=default_path_length) :: f_chi, f_S_n, f_S_p, f_S_x, f_W_t, &
CHARACTER(LEN=default_string_length) :: f_chi, f_S_n, f_S_p, f_S_x, f_W_t, &
prefix, project_name
INTEGER :: handle, i_spin, i_t_or_w, ind, n_spin, &
num_time_freq_points
Expand Down
24 changes: 3 additions & 21 deletions src/post_scf_bandstructure_methods.F
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
MODULE post_scf_bandstructure_methods
USE gw_methods, ONLY: gw
USE input_section_types, ONLY: section_vals_type
USE kinds, ONLY: dp
USE post_scf_bandstructure_types, ONLY: post_scf_bandstructure_type
USE post_scf_bandstructure_utils, ONLY: bandstructure_primitive_cell,&
bandstructure_primitive_cell_spinor,&
Expand All @@ -17,8 +16,7 @@ MODULE post_scf_bandstructure_methods
USE qs_environment_types, ONLY: qs_environment_type
USE qs_scf, ONLY: scf
USE soc_pseudopotential_methods, ONLY: H_KS_spinor,&
V_SOC_xyz_from_pseudopotential,&
remove_soc_outside_energy_window
V_SOC_xyz_from_pseudopotential
#include "./base/base_uses.f90"

IMPLICIT NONE
Expand Down Expand Up @@ -94,19 +92,11 @@ SUBROUTINE soc(qs_env, bs_env)
! Hartwigsen, Goedecker, Hutter, Eq.(18), (19) (doi.org/10.1103/PhysRevB.58.3641)
CALL V_SOC_xyz_from_pseudopotential(qs_env, bs_env%mat_V_SOC_xyz)
IF (bs_env%energy_window_soc > 0.0_dp) THEN
CALL remove_soc_outside_energy_window(bs_env%mat_V_SOC_xyz(:, 1), &
bs_env%energy_window_soc, &
bs_env%fm_mo_coeff_Gamma(1), &
bs_env%n_occ(1), &
bs_env%eigenval_scf_Gamma(:, 1), &
bs_env%fm_s_Gamma)
END IF
! Spinor KS-matrix H_µν,σσ' = h^SCF_µν*δ_σσ' + sum_α V^SOC_µν^(α)*Pauli-matrix^(α)_σσ', see
! Hartwigsen, Goedecker, Hutter, Eq.(18) (doi.org/10.1103/PhysRevB.58.3641)
CALL H_KS_spinor(bs_env%cfm_ks_spinor_ao_Gamma, bs_env%fm_ks_Gamma(1:2), bs_env%n_spin, &
bs_env%mat_V_SOC_xyz(:, 1), bs_env%cfm_s_spinor_Gamma, bs_env%fm_s_Gamma)
bs_env%mat_V_SOC_xyz(:, 1), bs_env%cfm_s_spinor_Gamma, bs_env%fm_s_Gamma, &
bs_env%cfm_SOC_spinor_ao_Gamma)

CALL timestop(handle)

Expand Down Expand Up @@ -144,14 +134,6 @@ SUBROUTINE bandstructure_primitive_cell_all_methods(qs_env, bs_env)
bs_env%eigenval_prim_cell_scf_soc, &
"bandstructure_SCF_SOC.bs", &
bs_env%cfm_ks_spinor_ao_Gamma)

! JW todo later: GW+SOC band structure of primitive cell
! IF (bs_env%do_gw) THEN
! CALL bandstructure_primitive_cell_spinor(qs_env, bs_env, &
! bs_env%eigenval_prim_cell_G0W0_soc, &
! "bandstructure_G0W0_SOC.bs", &
! bs_env%cfm_h_G0W0_spinor_ao_Gamma)
! END IF
END IF

CALL timestop(handle)
Expand Down
9 changes: 4 additions & 5 deletions src/post_scf_bandstructure_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ MODULE post_scf_bandstructure_types
dbcsr_release
USE dbt_api, ONLY: dbt_destroy,&
dbt_type
USE kinds, ONLY: default_path_length,&
default_string_length,&
USE kinds, ONLY: default_string_length,&
dp,&
int_8
USE kpoint_types, ONLY: kpoint_release,&
Expand Down Expand Up @@ -231,7 +230,7 @@ MODULE post_scf_bandstructure_types
CHARACTER(LEN=7) :: Sigma_x_name = "Sigma_x"
CHARACTER(LEN=13) :: Sigma_p_name = "Sigma_pos_tau", &
Sigma_n_name = "Sigma_neg_tau"
CHARACTER(LEN=default_path_length) :: prefix = ""
CHARACTER(LEN=default_string_length) :: prefix = ""

REAL(KIND=dp) :: t1 = -1.0_dp, &
t2 = -1.0_dp
Expand All @@ -252,7 +251,7 @@ MODULE post_scf_bandstructure_types
TYPE(dbcsr_p_type), DIMENSION(:, :), POINTER :: mat_V_SOC_xyz => NULL()
TYPE(cp_fm_type), DIMENSION(3) :: fm_V_SOC_xyz_mo
TYPE(cp_cfm_type) :: cfm_ks_spinor_ao_Gamma, &
cfm_h_G0W0_spinor_ao_Gamma, &
cfm_SOC_spinor_ao_Gamma, &
cfm_s_spinor_Gamma
TYPE(band_edges_type) :: band_edges_scf_SOC, &
band_edges_G0W0_SOC
Expand Down Expand Up @@ -373,7 +372,7 @@ SUBROUTINE bs_env_release(bs_env)
CALL cp_fm_release(bs_env%fm_V_SOC_xyz_mo(2))
CALL cp_fm_release(bs_env%fm_V_SOC_xyz_mo(3))
CALL cp_cfm_release(bs_env%cfm_ks_spinor_ao_Gamma)
CALL cp_cfm_release(bs_env%cfm_h_G0W0_spinor_ao_Gamma)
CALL cp_cfm_release(bs_env%cfm_SOC_spinor_ao_Gamma)
CALL cp_cfm_release(bs_env%cfm_s_spinor_Gamma)

DEALLOCATE (bs_env)
Expand Down

0 comments on commit 70cdbe9

Please sign in to comment.