[Pw_forum] fft 3D

Fang Liu cufe.fliu at gmail.com
Thu May 16 22:18:33 CEST 2013


Dear Andrei,

Welcome to join this discussion.
I attached my zipped result.

Best,
Fang


2013/5/17 Andrei Malashevich <andrei.malashevich at yale.edu>

> Dear Paolo,
>
> I apologize if my question is not really relevant to the discussion but
> some time ago I also encountered a question about FFT grids that I wanted
> to clarify.
>
>  When I was studying the PP/stm.f90 routine, I decided to do the following
> test.
> In this routine I set the density rho%of_r by hand to be just some linear
> function of the z coordinate, rho(z), see, e.g. attached file
> before_fft.eps.
> In this file the x-axis corresponds to the 3rd dimension of the FFT grid,
> and y-axis shows rho(z).
>
> The routine stm.f90 at the end has symmetrization part, that involves
> fwfft and invfft:
>
>   IF ( .not. gamma_only) THEN
>      !
>      CALL sym_rho_init (gamma_only)
>      !
>      psic(:) = cmplx ( rho%of_r(:,1), 0.0_dp, kind=dp)
>      CALL fwfft ('Dense', psic, dfftp)
>      rho%of_g(:,1) = psic(nl(:))
>      CALL sym_rho (1, rho%of_g)
>      psic(:) = (0.0_dp, 0.0_dp)
>      psic(nl(:)) = rho%of_g(:,1)
>      CALL invfft ('Dense', psic, dfftp)
>      rho%of_r(:,1) = dble(psic(:))
>   ENDIF
>
> If I comment this symmetrization part entirely, I obtain the result shown
> in the file before_fft.eps, which is what I wanted.
> Now if I uncomment everyhting related to fwfft and invfft and comment only
> calls to sym_rho_init and sym_rho, I get the result shown in figure
> after_fft.eps.
>
> So it looks that by doing FFT and inverse FFT did not return the original
> function.
> I understand that my function rho(z) is not realistic and has a huge
> discontinuity but I thought that it should not really matter for this FFT
> test.
> At least when I took a similar function in 1D, and did FFT and inverse FFT
> in my python script I got my original function back.
>
> Did I do something wrong with this test, or is it indeed the expected
> behavior of the code for some reason?
> Do you know why this happens?
> I would appreciate if you could comment on this.
>
> Thank you,
> Andrei Malashevich
>
> Postdoctoral Associate
> Department of Applied Physics
> Yale University
>
>
>
>
>
> On Thu, May 16, 2013 at 1:18 PM, Fang Liu <cufe.fliu at gmail.com> wrote:
>
>> Dear Paolo,
>>
>> Thank you very much for your quick reply.
>>
>>
>>> > In real space, the wavefunction is a real vector.
>>>
>>> only for k=0 or if there is inversion symmetry
>>>
>>
>> Yes. I'm only considering the case k=0 at this moment.
>>
>>>
>>> > I want to write some code using 3D fft (forward and backward)
>>> > in Quantum Espresso for general complex vector (stored in 3D
>>> > array)
>>>
>>> I am not sure I understand what you want to do: the 3D FFT in
>>> QE is quite general.
>>>
>>> _______________________________________________
>>>
>>> I tried the following test codes in QE.
>> That is, I use a 25*25*25 3D FFT mesh. The original 3d array g3d =
>> (1.0_DP, -1.0_DP).
>> First I do invfft and then fwfft. Finally I don't get the original 3d
>> array, but a 3d array g3dnew
>>  in which g3dnew(1),g3dnew(2),...,g3dnew(3025)= (1.0_DP, -1.0_DP)
>> while g3dnew(3026),....,g3dnew(15625)=0.0.
>>
>> But if I do fwfft first and then invfft, I can finally get the original
>> 3d array.
>>
>> I don't know the reason. I tried to attach my results, but it seems too
>> large to be sent
>> quickly. So I cancelled it.
>>
>> Thank you very much.
>>
>> ===========
>>      open(UNIT=73, FILE='g3d.log',STATUS='replace', FORM='formatted',
>> ACTION='write')
>>
>>     g3d = (1.0_DP, -1.0_DP)
>>     write(73,*), 'g3d: original'
>>     do i=1, dffts%nnr
>>        write(73,101), i, g3d(i)
>>     enddo
>>
>>
>>     CALL invfft ('Wave', g3d, dffts) !transform potential to real space
>>
>>     write(73,*), 'g3d: after invfft'
>>     do i=1, dffts%nnr
>>        write(73,101), i, g3d(i)
>>     enddo
>>
>>     CALL fwfft ('Wave', g3d, dffts) !transform potential to reciprocal
>> space
>>
>>     write(73,*), 'g3d: after fwfft'
>>     do i=1, dffts%nnr
>>        write(73,101), i, g3d(i)
>>     enddo
>>
>>     close(73)
>> ==============
>>
>> Best,
>> Fang
>>
>>
>> 2013/5/16 Paolo Giannozzi <paolo.giannozzi at uniud.it>
>>
>>> On Wed, 2013-05-15 at 16:45 -0700, Fang Liu wrote:
>>>
>>> > In real space, the wavefunction is a real vector.
>>>
>>> only for k=0 or if there is inversion symmetry
>>>
>>> > I want to write some code using 3D fft (forward and backward)
>>> > in Quantum Espresso for general complex vector (stored in 3D
>>> > array)
>>>
>>> I am not sure I understand what you want to do: the 3D FFT in
>>> QE is quite general.
>>>
>>> P.
>>> --
>>>  Paolo Giannozzi, Dept. Chemistry&Physics&Environment,
>>>  Univ. Udine, via delle Scienze 208, 33100 Udine, Italy
>>>  Phone +39-0432-558216, fax +39-0432-558222
>>>
>>> _______________________________________________
>>> Pw_forum mailing list
>>> Pw_forum at pwscf.org
>>> http://pwscf.org/mailman/listinfo/pw_forum
>>>
>>
>>
>> _______________________________________________
>> Pw_forum mailing list
>> Pw_forum at pwscf.org
>> http://pwscf.org/mailman/listinfo/pw_forum
>>
>
>
> _______________________________________________
> Pw_forum mailing list
> Pw_forum at pwscf.org
> http://pwscf.org/mailman/listinfo/pw_forum
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quantum-espresso.org/pipermail/users/attachments/20130517/7f604c28/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: g3d-invfft-fwfft.zip
Type: application/zip
Size: 130824 bytes
Desc: not available
URL: <http://lists.quantum-espresso.org/pipermail/users/attachments/20130517/7f604c28/attachment.zip>


More information about the users mailing list