1
2! Copyright (C) 2019 T. Mueller, J. K. Dewhurst, S. Sharma and E. K. U. Gross.
3! This file is distributed under the terms of the GNU General Public License.
4! See the file COPYING for license details.
5
6subroutine potefieldu
7use modmain
8use modulr
9implicit none
10! local variables
11integer ir
12real(8) v0,v(3)
13! allocatable arrays
14real(8), allocatable :: rfft(:)
15if (sum(abs(efielduc(:))).lt.epslat) return
16allocate(rfft(nqpt))
17! constant added to potential so that it is zero at the ultracell center
18v(:)=0.5d0*(avecu(:,1)+avecu(:,2)+avecu(:,3))
19v0=dot_product(efielduc(:),v(:))
20! calculate the potential in real-space
21do ir=1,nqpt
22  rfft(ir)=v0-dot_product(efielduc(:),vrcu(:,ir))
23end do
24! Fourier transform to Q-space
25call rzfftifc(3,ngridq,-1,rfft,vclq)
26deallocate(rfft)
27end subroutine
28
29