Commit 9123f441 authored by giannozz's avatar giannozz

Merge branch 'develop' into 'develop'

Select q-point extension to random grids.

See merge request !211
parents 50ed8228 145fc74d
This diff is collapsed.
......@@ -99,6 +99,8 @@
!! Check wheter this is the first cycle after a restart.
LOGICAL :: first_time
!! Check wheter this is the first timeafter a restart.
LOGICAL :: homogeneous
!! Check if the k and q grids are homogenous and commensurate.
!
CHARACTER (len=256) :: filint
!! Name of the file to write/read
......@@ -840,46 +842,45 @@
! Determines which q-points falls within the fsthick windows
! Store the result in the selecq.fmt file
! If the file exists, automatically restart from the file
! This is only done in the case of homogeneous grids.
! -----------------------------------------------------------------------
!
! Check if the grids are homogeneous and commensurate
homogeneous = .FALSE.
IF ( (nkf1 /= 0) .AND. (nkf2 /= 0) .AND. (nkf3 /= 0) .AND. &
(nqf1 /= 0) .AND. (nqf2 /= 0) .AND. (nqf3 /= 0) .AND. &
(MOD(nkf1,nqf1) == 0) .AND. (MOD(nkf2,nqf2) == 0) .AND. (MOD(nkf3,nqf3) == 0) ) THEN
homogeneous = .TRUE.
ELSE
homogeneous = .FALSE.
ENDIF
!
totq = 0
! Check if the file has been pre-computed
IF (mpime == ionode_id) THEN
INQUIRE(FILE='selecq.fmt',EXIST=exst)
ENDIF
CALL mp_bcast(exst, ionode_id, world_comm)
!
IF ( (nkf1 /= 0) .AND. (nkf2 /= 0) .AND. (nkf3 /= 0) .AND. (nqf1 /= 0) .AND. (nqf2 /= 0) .AND. (nqf3 /= 0) ) THEN
!
! Check if the file has been pre-computed
IF (mpime == ionode_id) THEN
INQUIRE(FILE='selecq.fmt',EXIST=exst)
IF (exst) THEN
IF (selecqread) THEN
WRITE(stdout,'(5x,a)')' '
WRITE(stdout,'(5x,a)')'Reading selecq.fmt file. '
CALL qwindow(exst, nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq, homogeneous)
ELSE
WRITE(stdout,'(5x,a)')' '
WRITE(stdout,'(5x,a)')'A selecq.fmt file was found but re-created because selecqread == .false. '
CALL qwindow(.FALSE., nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq, homogeneous)
ENDIF
CALL mp_bcast(exst, ionode_id, world_comm)
!
IF (exst) THEN
IF (selecqread) THEN
WRITE(stdout,'(5x,a)')' '
WRITE(stdout,'(5x,a)')'Reading selecq.fmt file. '
CALL qwindow(exst, nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq)
ELSE
WRITE(stdout,'(5x,a)')' '
WRITE(stdout,'(5x,a)')'A selecq.fmt file was found but re-created because selecqread == .false. '
CALL qwindow(.FALSE., nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq)
ENDIF
ELSE ! exst
IF (selecqread) THEN
CALL errore( 'ephwann_shuffle', 'Variable selecqread == .true. but file selecq.fmt not found.',1 )
ELSE
CALL qwindow(exst, nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq)
ENDIF
ELSE ! exst
IF (selecqread) THEN
CALL errore( 'ephwann_shuffle', 'Variable selecqread == .true. but file selecq.fmt not found.',1 )
ELSE
CALL qwindow(exst, nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq, homogeneous)
ENDIF
!
WRITE(stdout,'(5x,a,i8,a)')'We only need to compute ',totq, ' q-points'
WRITE(stdout,'(5x,a)')' '
ELSE
! If Random points or points read from files, then take all.
totq = nqf
ALLOCATE(selecq(totq))
DO iq = 1, totq
selecq(iq) = iq
ENDDO
ENDIF ! homogeneous grids
ENDIF
!
WRITE(stdout,'(5x,a,i8,a)')'We only need to compute ',totq, ' q-points'
WRITE(stdout,'(5x,a)')' '
!
! -----------------------------------------------------------------------
! Possible restart during step 1)
......
......@@ -100,6 +100,8 @@
!! Check wheter this is the first cycle after a restart.
LOGICAL :: first_time
!! Check wheter this is the first timeafter a restart.
LOGICAL :: homogeneous
!! Check if the k and q grids are homogenous and commensurate.
!
CHARACTER (len=256) :: filint
!! Name of the file to write/read
......@@ -809,45 +811,46 @@
! Determines which q-points falls within the fsthick windows
! Store the result in the selecq.fmt file
! If the file exists, automatically restart from the file
! This is only done in the case of homogeneous grids.
! -----------------------------------------------------------------------
!
! Check if the grids are homogeneous and commensurate
homogeneous = .FALSE.
IF ( (nkf1 /= 0) .AND. (nkf2 /= 0) .AND. (nkf3 /= 0) .AND. &
(nqf1 /= 0) .AND. (nqf2 /= 0) .AND. (nqf3 /= 0) .AND. &
(MOD(nkf1,nqf1) == 0) .AND. (MOD(nkf2,nqf2) == 0) .AND. (MOD(nkf3,nqf3) == 0) ) THEN
homogeneous = .TRUE.
ELSE
homogeneous = .FALSE.
ENDIF
!
totq = 0
!
IF ( (nkf1 /= 0) .AND. (nkf2 /= 0) .AND. (nkf3 /= 0) .AND. (nqf1 /= 0) .AND. (nqf2 /= 0) .AND. (nqf3 /= 0) ) THEN
!
! Check if the file has been pre-computed
IF (mpime == ionode_id) THEN
INQUIRE(FILE='selecq.fmt',EXIST=exst)
! Check if the file has been pre-computed
IF (mpime == ionode_id) THEN
INQUIRE(FILE='selecq.fmt',EXIST=exst)
ENDIF
CALL mp_bcast(exst, ionode_id, world_comm)
!
IF (exst) THEN
IF (selecqread) THEN
WRITE(stdout,'(5x,a)')' '
WRITE(stdout,'(5x,a)')'Reading selecq.fmt file. '
CALL qwindow(exst, nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq, homogeneous)
ELSE
WRITE(stdout,'(5x,a)')' '
WRITE(stdout,'(5x,a)')'A selecq.fmt file was found but re-created because selecqread == .false. '
CALL qwindow(.FALSE., nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq, homogeneous)
ENDIF
CALL mp_bcast(exst, ionode_id, world_comm)
!
IF (exst) THEN
IF (selecqread) THEN
WRITE(stdout,'(5x,a)')' '
WRITE(stdout,'(5x,a)')'Reading selecq.fmt file. '
CALL qwindow(exst, nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq)
ELSE
WRITE(stdout,'(5x,a)')' '
WRITE(stdout,'(5x,a)')'A selecq.fmt file was found but re-created because selecqread == .false. '
CALL qwindow(.FALSE., nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq)
ENDIF
ELSE ! exst
IF (selecqread) THEN
CALL errore( 'ephwann_shuffle', 'Variable selecqread == .true. but file selecq.fmt not found.',1 )
ELSE
CALL qwindow(exst, nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq)
ENDIF
ELSE ! exst
IF (selecqread) THEN
CALL errore( 'ephwann_shuffle', 'Variable selecqread == .true. but file selecq.fmt not found.',1 )
ELSE
CALL qwindow(exst, nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq, homogeneous)
ENDIF
!
WRITE(stdout,'(5x,a,i8,a)')'We only need to compute ',totq, ' q-points'
WRITE(stdout,'(5x,a)')' '
ELSE
totq = nqf
ALLOCATE(selecq(totq))
DO iq = 1, totq
selecq(iq) = iq
ENDDO
ENDIF ! homogeneous grids
ENDIF
!
WRITE(stdout,'(5x,a,i8,a)')'We only need to compute ',totq, ' q-points'
WRITE(stdout,'(5x,a)')' '
!
! -----------------------------------------------------------------------
! Possible restart during step 1)
......
......@@ -17,7 +17,8 @@
CONTAINS
!
!-----------------------------------------------------------------------
SUBROUTINE qwindow(exst, nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq)
SUBROUTINE qwindow( exst, nrr_k, dims, totq, selecq, irvec_r, ndegen_k, &
cufkk, cufkq, homogeneous )
!-----------------------------------------------------------------------
!!
!! This subroutine pre-computes the q-points that falls within the fstichk
......@@ -44,6 +45,8 @@
!
LOGICAL, INTENT(in) :: exst
!! If the file exist
LOGICAL, INTENT(in) :: homogeneous
!! Check if the grids are homogeneous and commensurate
INTEGER, INTENT(IN) :: nrr_k
!! Number of WS points for electrons
INTEGER, INTENT(IN) :: dims
......@@ -105,6 +108,8 @@
!! $r\cdot k$
REAL(kind=DP) :: etf_loc(nbndsub, nkf)
!! Eigen-energies all full k-grid.
REAL(kind=DP) :: etf_locq(nbndsub, nkf)
!! Eigen-energies all full k-grid.
REAL(kind=DP) :: etf_all(nbndsub, nkqtotf/2)
!! Eigen-energies all full k-grid.
REAL(kind=DP) :: xkf_tmp (3, nkqtotf)
......@@ -138,104 +143,153 @@
CALL mp_bcast(selecq, ionode_id, world_comm )
IF (nqtot /= nqtotf) THEN
CALL errore( 'qwindow', 'Cannot read from selecq.fmt, the q-point grid or &
fsthick window are different from read one. Remove the selecq.fmt file and restart. ',1 )
& fsthick window are different from read one. Remove the selecq.fmt file and restart.',1 )
ENDIF
!
ELSE
ALLOCATE(selecq(nqf))
selecq(:) = 0
etf_loc(:,:) = zero
etf_loc(:,:) = zero
etf_locq(:,:) = zero
etf_all(:,:) = zero
!
! First store eigen energies on full grid.
DO ik = 1, nkf
ikk = 2 * ik - 1
xkk = xkf(:, ikk)
CALL dgemv('t', 3, nrr_k, twopi, irvec_r, 3, xkk, 1, 0.0_DP, rdotk, 1 )
IF (use_ws) THEN
DO iw=1, dims
DO iw2=1, dims
DO ir = 1, nrr_k
IF (ndegen_k(ir,iw2,iw) > 0) THEN
cfac(ir,iw2,iw) = exp( ci*rdotk(ir) ) / ndegen_k(ir,iw2,iw)
ENDIF
IF (homogeneous) THEN
! First store eigen energies on full grid.
DO ik = 1, nkf
ikk = 2 * ik - 1
xkk = xkf(:, ikk)
CALL dgemv('t', 3, nrr_k, twopi, irvec_r, 3, xkk, 1, 0.0_DP, rdotk, 1 )
IF (use_ws) THEN
DO iw=1, dims
DO iw2=1, dims
DO ir = 1, nrr_k
IF (ndegen_k(ir,iw2,iw) > 0) THEN
cfac(ir,iw2,iw) = exp( ci*rdotk(ir) ) / ndegen_k(ir,iw2,iw)
ENDIF
ENDDO
ENDDO
ENDDO
ENDDO
ELSE
cfac(:,1,1) = exp( ci*rdotk(:) ) / ndegen_k(:,1,1)
ENDIF
CALL hamwan2bloch ( nbndsub, nrr_k, cufkk, etf_loc(:, ik), chw, cfac, dims)
ENDDO
CALL poolgather ( nbndsub, nkqtotf/2, nkf, etf_loc, etf_all )
!
! In case of k-point symmetry
IF (mp_mesh_k) THEN
BZtoIBZ(:) = 0
s_BZtoIBZ(:,:,:) = 0
ELSE
cfac(:,1,1) = exp( ci*rdotk(:) ) / ndegen_k(:,1,1)
ENDIF
CALL hamwan2bloch ( nbndsub, nrr_k, cufkk, etf_loc(:, ik), chw, cfac, dims)
ENDDO
CALL poolgather ( nbndsub, nkqtotf/2, nkf, etf_loc, etf_all )
!
IF ( mpime == ionode_id ) THEN
! In case of k-point symmetry
IF (mp_mesh_k) THEN
BZtoIBZ(:) = 0
s_BZtoIBZ(:,:,:) = 0
!
CALL set_sym_bl( )
!
! What we get from this call is BZtoIBZ
CALL kpoint_grid_epw ( nrot, time_reversal, .false., s, t_rev, bg, nkf1*nkf2*nkf3, &
nkf1,nkf2,nkf3, nkqtotf_tmp, xkf_tmp, wkf_tmp,BZtoIBZ,s_BZtoIBZ)
IF ( mpime == ionode_id ) THEN
!
CALL set_sym_bl( )
!
! What we get from this call is BZtoIBZ
CALL kpoint_grid_epw ( nrot, time_reversal, .false., s, t_rev, bg, nkf1*nkf2*nkf3, &
nkf1,nkf2,nkf3, nkqtotf_tmp, xkf_tmp, wkf_tmp,BZtoIBZ,s_BZtoIBZ)
!
IF (iterative_bte) THEN
BZtoIBZ_tmp(:) = 0
DO ikbz=1, nkf1*nkf2*nkf3
BZtoIBZ_tmp(ikbz) = map_rebal( BZtoIBZ( ikbz ) )
ENDDO
BZtoIBZ(:) = BZtoIBZ_tmp(:)
ENDIF
!
ENDIF ! mpime
CALL mp_bcast( BZtoIBZ, ionode_id, inter_pool_comm )
!
IF (iterative_bte) THEN
BZtoIBZ_tmp(:) = 0
DO ikbz=1, nkf1*nkf2*nkf3
BZtoIBZ_tmp(ikbz) = map_rebal( BZtoIBZ( ikbz ) )
ENDDO
BZtoIBZ(:) = BZtoIBZ_tmp(:)
ENDIF
ENDIF ! mp_mesh_k
!
DO iq=1, nqf
xxq = xqf (:, iq)
!
ENDIF ! mpime
CALL mp_bcast( BZtoIBZ, ionode_id, inter_pool_comm )
!
ENDIF ! mp_mesh_k
!
DO iq=1, nqf
xxq = xqf (:, iq)
!
found(:) = 0
DO ik = 1, nkf
ikk = 2 * ik - 1
xkk = xkf(:, ikk)
xkq = xkk + xxq
!
CALL kpmq_map( xkk, (/0d0,0d0,0d0/), 1, ind1 )
CALL kpmq_map( xkk, xxq, 1, ind2 )
found(:) = 0
DO ik = 1, nkf
ikk = 2 * ik - 1
xkk = xkf(:, ikk)
xkq = xkk + xxq
!
CALL kpmq_map( xkk, (/0d0,0d0,0d0/), 1, ind1 )
CALL kpmq_map( xkk, xxq, 1, ind2 )
!
! Use k-point symmetry
IF (mp_mesh_k) THEN
IF ( (( minval ( abs(etf_all(:, BZtoIBZ(ind1)) - ef) ) < fsthick ) .and. &
( minval ( abs(etf_all(:, BZtoIBZ(ind2)) - ef) ) < fsthick )) ) THEN
found(my_pool_id+1) = 1
EXIT ! exit the loop
ENDIF
ELSE
IF ( (( minval ( abs(etf_all(:, ind1) - ef) ) < fsthick ) .and. &
( minval ( abs(etf_all(:, ind2) - ef) ) < fsthick )) ) THEN
found(my_pool_id+1) = 1
EXIT ! exit the loop
ENDIF
ENDIF
!
ENDDO ! k-loop
! If found on any k-point from the pools
CALL mp_sum(found, world_comm)
!
! Use k-point symmetry
IF (mp_mesh_k) THEN
IF ( (( minval ( abs(etf_all(:, BZtoIBZ(ind1)) - ef) ) < fsthick ) .and. &
( minval ( abs(etf_all(:, BZtoIBZ(ind2)) - ef) ) < fsthick )) ) THEN
found(my_pool_id+1) = 1
EXIT ! exit the loop
IF (SUM(found) > 0) THEN
totq = totq + 1
selecq(totq) = iq
!
IF (MOD(totq,500) == 0) THEN
WRITE(stdout,'(5x,a,i8,i8)')'Number selected, total',totq,iq
ENDIF
ELSE
IF ( (( minval ( abs(etf_all(:, ind1) - ef) ) < fsthick ) .and. &
( minval ( abs(etf_all(:, ind2) - ef) ) < fsthick )) ) THEN
ENDIF
ENDDO ! iq
ELSE ! homogeneous
DO iq=1, nqf
xxq = xqf (:, iq)
found(:) = 0
DO ik = 1, nkf
ikk = 2 * ik - 1
xkk = xkf(:, ikk)
xkq = xkk + xxq
!
CALL dgemv('t', 3, nrr_k, twopi, irvec_r, 3, xkk, 1, 0.0_DP, rdotk, 1 )
CALL dgemv('t', 3, nrr_k, twopi, irvec_r, 3, xkq, 1, 0.0_DP, rdotk2, 1 )
IF (use_ws) THEN
DO iw=1, dims
DO iw2=1, dims
DO ir = 1, nrr_k
IF (ndegen_k(ir,iw2,iw) > 0) THEN
cfac(ir,iw2,iw) = exp( ci*rdotk(ir) ) / ndegen_k(ir,iw2,iw)
cfacq(ir,iw2,iw) = exp( ci*rdotk2(ir) ) / ndegen_k(ir,iw2,iw)
ENDIF
ENDDO
ENDDO
ENDDO
ELSE
cfac(:,1,1) = exp( ci*rdotk(:) ) / ndegen_k(:,1,1)
cfacq(:,1,1) = exp( ci*rdotk2(:) ) / ndegen_k(:,1,1)
ENDIF
CALL hamwan2bloch ( nbndsub, nrr_k, cufkk, etf_loc(:, ik), chw, cfac, dims)
CALL hamwan2bloch ( nbndsub, nrr_k, cufkq, etf_locq(:, ik), chw, cfacq, dims)
IF ( (( minval ( abs(etf_loc(:, ik) - ef) ) < fsthick ) .and. &
( minval ( abs(etf_locq(:, ik) - ef) ) < fsthick )) ) THEN
found(my_pool_id+1) = 1
EXIT ! exit the loop
ENDIF
ENDIF
!
ENDDO ! k-loop
! If found on any k-point from the pools
CALL mp_sum(found, world_comm)
!
IF (SUM(found) > 0) THEN
totq = totq + 1
selecq(totq) = iq
ENDDO ! ik
! If found on any k-point from the pools
CALL mp_sum(found, world_comm)
!
IF (MOD(totq,500) == 0) THEN
WRITE(stdout,'(5x,a,i8,i8)')'Number selected, total',totq,iq
IF (SUM(found) > 0) THEN
totq = totq + 1
selecq(totq) = iq
!
IF (MOD(totq,500) == 0) THEN
WRITE(stdout,'(5x,a,i8,i8)')'Number selected, total',totq,iq
ENDIF
ENDIF
ENDIF
!
ENDDO
ENDDO ! iq
ENDIF ! homogeneous
!
IF (mpime == ionode_id) THEN
OPEN(unit=iunselecq, file='selecq.fmt', action='write')
WRITE (iunselecq,*) totq ! Selected number of q-points
......
......@@ -60,7 +60,7 @@
phonselfen = .false.
a2f = .false.
fsthick = 1.2 ! eV
fsthick = 2.0 ! eV
eptemp = 1 ! K
degaussw = 0.05 ! eV
......
......@@ -60,7 +60,7 @@
phonselfen = .false.
a2f = .false.
fsthick = 1.2 ! eV
fsthick = 2.0 ! eV
eptemp = 1 ! K
degaussw = 0.05 ! eV
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment