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,12 +842,19 @@
! 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.
! -----------------------------------------------------------------------
totq = 0
!
IF ( (nkf1 /= 0) .AND. (nkf2 /= 0) .AND. (nkf3 /= 0) .AND. (nqf1 /= 0) .AND. (nqf2 /= 0) .AND. (nqf3 /= 0) ) THEN
! 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)
......@@ -856,30 +865,22 @@
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)
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)
CALL qwindow(.FALSE., nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq, homogeneous)
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)
CALL qwindow(exst, nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq, homogeneous)
ENDIF
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
!
! -----------------------------------------------------------------------
! 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,11 +811,19 @@
! 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.
! -----------------------------------------------------------------------
totq = 0
!
IF ( (nkf1 /= 0) .AND. (nkf2 /= 0) .AND. (nkf3 /= 0) .AND. (nqf1 /= 0) .AND. (nqf2 /= 0) .AND. (nqf3 /= 0) ) THEN
! 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
......@@ -825,29 +835,22 @@
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)
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)
CALL qwindow(.FALSE., nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq, homogeneous)
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)
CALL qwindow(exst, nrr_k, dims, totq, selecq, irvec_r, ndegen_k, cufkk, cufkq, homogeneous)
ENDIF
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
!
! -----------------------------------------------------------------------
! 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,15 +143,17 @@
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_locq(:,:) = zero
etf_all(:,:) = zero
!
IF (homogeneous) THEN
! First store eigen energies on full grid.
DO ik = 1, nkf
ikk = 2 * ik - 1
......@@ -234,8 +241,55 @@
WRITE(stdout,'(5x,a,i8,i8)')'Number selected, total',totq,iq
ENDIF
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
ENDDO ! ik
! 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
!
IF (MOD(totq,500) == 0) THEN
WRITE(stdout,'(5x,a,i8,i8)')'Number selected, total',totq,iq
ENDIF
ENDIF
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