load_qr_allk.F Source File


Source Code

!
! License-Identifier: GPL
!
! Copyright (C) 2015 The Yambo Team
!
! Authors (see AUTHORS file for details): DS TQ
!
! headers
!
#include<y_memory.h>
!
subroutine load_qr_allk(Xen,Xk,Dipband,deg_thresh)
 !
 ! From the overlaps DIP_S, construct rotation matrix to fix phases Qr 
 ! see Phys. Rev. B 76, 035213 (2007) and  Phys. Rev. Research 2, 013357 (2020)
 !
 use pars,           ONLY:SP,cI,cZERO,pi,cONE
 use units,          ONLY:HA2EV
 use LIVE_t,         ONLY:live_timing
 use electrons,      ONLY:levels,n_sp_pol
 use DIPOLES,        ONLY:DIPOLE_t,DIP_S,DIP_iR,DIP_v,l_force_SndOrd,&
                          der_k_obs,x_space_obs
 use R_lattice,      ONLY:bz_samp,k_map
 use vec_operate,    ONLY:k_periodic_idx,degeneration_finder
 use matrix_operate, ONLY:hermitian
 use parallel_m,     ONLY:PAR_IND_DIPk_ibz,PAR_DIPk_ibz_index,PAR_IND_DIPk_ibz_ID,&
&                         PAR_DIPk_nbz,PAR_IND_CON_BANDS_DIP, PAR_IND_VAL_BANDS_DIP, &
&                         PAR_IND_DIPk_bz,PAR_DIPk_bz_index,PAR_IND_DIPk_bz_ID,PAR_COM_DIPk_ibz_INDEX
 use parallel_int,   ONLY:PP_redux_wait
 use BS,             ONLY:BS_bands,BS_K_dim
 use BS_solvers,     ONLY:BSS_eh_table_m1,BSS_n_eig
 use YPP_post_bse,   ONLY:Q_r,Q_l
 use com,            ONLY:msg
 use D_lattice,      ONLY:a
 use parser_m,       ONLY:parser
 use timing_m,       ONLY:timing
 use stderr,         ONLY:STRING_match
 use com,            ONLY:msg,of_open_close
 use y_memory_alloc
 !
 implicit none
 !
 type(levels),           intent(in)     :: Xen
 type(bz_samp),          intent(inout)  :: Xk
 integer,                intent(in)     :: Dipband
 real(SP),               intent(in)     :: deg_thresh
 !
 ! Work Space
 !
 integer     :: i_sp_pol,id_red,idx(3),idir,ik_mem,ikbz,ikibz,ic,iv,icp,ivp,iH,iHp,iHm,iHpp,iHmp
 integer     :: ikm1,ikp1,aa
 logical     :: direction_is_todo(3)
 complex(SP), allocatable :: U_l(:,:,:,:,:),U_r(:,:,:,:,:)
 !
 integer     :: ib,ibp
 character(1)::str(3)=(/'x','y','z'/)
 character(len=20) :: aa_str,iv_str,ic_str,ikbz_str
 !
 call timing("load_qr_allk",OPR="start")
 !
 !
 if(.not.allocated(k_map%k_map_dir)) call k_map_nearest_by_dir(Xk,k_map)
 if(.not.allocated(Xk%k_table))      call k_build_up_BZ_tables(Xk)
 !
 direction_is_todo(:)= (k_map%max_kdir(:)==1)
 !
 if(any(direction_is_todo)) call warning(' Der-k not in 3d. Assuming non periodic system.')
 !
 call live_timing("Build Rotation Matrices:",PAR_IND_DIPk_bz%n_of_elements(PAR_IND_DIPk_bz_ID+1)*n_sp_pol)
 !
 YAMBO_ALLOC(U_l,(Dipband,Dipband,3,1,3))
 YAMBO_ALLOC(U_r,(Dipband,Dipband,3,1,3))
 !
 YAMBO_ALLOC(Q_r,(BS_bands(2)-BS_bands(1)+1,BS_bands(2)-BS_bands(1)+1,Xk%nbz,3))
 YAMBO_ALLOC(Q_l,(BS_bands(2)-BS_bands(1)+1,BS_bands(2)-BS_bands(1)+1,Xk%nbz,3))
 !
 do i_sp_pol=1,n_sp_pol
   !
   do ikbz=1,Xk%nbz 
     !
     if (.not.PAR_IND_DIPk_bz%element_1D(ikbz)) cycle
     !
     ik_mem=PAR_DIPk_bz_index(ikbz)
     ikibz=Xk%sstar(ikbz,1)
     !
     call build_qr_matrices_ik(i_sp_pol,ikbz,U_r,U_l,Dipband,3,1,Xen,Xk,deg_thresh)
     !
     do id_red=1,3  ! Loop on the three crystal directions in the BZ
       !
       if(k_map%max_kdir(id_red)==1) cycle ! Non-periodic direction, skip calculation
       !
       Q_r(:,:,ikbz,id_red)=U_r(BS_bands(1):BS_bands(2),BS_bands(1):BS_bands(2),3,1,id_red)
       Q_l(:,:,ikbz,id_red)=U_l(BS_bands(1):BS_bands(2),BS_bands(1):BS_bands(2),3,1,id_red)
       !
     enddo  ! id_red loop on crystal directions 
     call live_timing(steps=1)
     !
   enddo ! ik BZ loop
   !
 enddo ! i_sp_pol
 !
 call live_timing()
 !
 YAMBO_FREE(U_l)
 YAMBO_FREE(U_r)
 !
 call timing("load_qr_allk",OPR="stop")
 !
 return
 !
end subroutine load_qr_allk

📚 Documentation Pages
⏱️ Real-Time
🔗 Code API