29 & nft(3), & !< FFT grid
30 & nr, & !< Number of r in whole grid, product(nft(1:3))
31 & npw !< Number of PW inside sphere
32 integer,
allocatable :: &
33 & map(:), & !< (npw) npw(sphere) -> nr(grid) mapper
34 & mill(:,:) !< (3,npw) Miller index
47 real(8),
intent(in) :: g2cut
48 type(
fft),
intent(out) :: xfft
50 integer :: ii, i1, i2, i3, nmax3(3), nmax
51 real(8) :: norm, gv0(3), g2
52 integer,
allocatable :: mill0(:,:)
55 norm = sqrt(dot_product(
avec(1:3,ii),
avec(1:3,ii)))
56 nmax3(ii) = ceiling(sqrt(g2cut)*norm/(2.0d0*
pi))
59 nmax = product(nmax3(1:3)*2+1)
60 allocate(mill0(3,nmax))
63 do i3 = -nmax3(3), nmax3(3)
64 do i2 = -nmax3(2), nmax3(2)
65 do i1 = -nmax3(1), nmax3(1)
66 gv0(1:3) = matmul(
bvec(1:3,1:3), dble((/i1,i2,i3/)))
67 g2 = dot_product(gv0,gv0)
69 xfft%npw = xfft%npw + 1
70 mill0(1:3,xfft%npw) = (/i1,i2,i3/)
76 write(*,*)
" Numver of PW inside sphere : ", xfft%npw
81 xfft%nft(ii) = maxval(mill0(ii,1:xfft%npw))*2 + 1
85 write(*,*)
" FFT grid : ", xfft%nft(1:3)
86 xfft%nr = product(xfft%nft(1:3))
87 write(*,*)
" Numver of PW in grid : ", xfft%nr
88 allocate(xfft%mill(3,xfft%nr), xfft%map(xfft%npw))
93 do i3 = 0, xfft%nft(3) - 1
94 do i2 = 0, xfft%nft(2) - 1
95 do i1 = 0, xfft%nft(1) - 1
97 xfft%mill(1:3,ii) = modulo((/i1, i2, i3/) + xfft%nft(1:3)/2, xfft%nft(1:3)) &
106 mill0(1:3,ii) = modulo(mill0(1:3,ii), xfft%nft(1:3))
107 xfft%map(ii) = 1 + mill0(1,ii) + xfft%nft(1)*(mill0(2,ii) + xfft%nft(2)*mill0(3,ii))
116 integer,
intent(inout) :: nfft
118 integer :: base(4) = (/2,3,5,7/), ibase, iexp, &
119 & start, last, nexp, nfft1, nfft2
124 do nfft1 = start, last
130 nexp = ceiling(log(dble(nfft2))/log(dble(base(ibase))))
133 if(mod(nfft2, base(ibase)) == 0)
then
134 nfft2 = nfft2 / base(ibase)