<div dir="ltr"><div><div><div><div>Dear Andrei,<br><br></div>Welcome to join this discussion.<br></div>I attached my zipped result.<br><br></div>Best,<br></div>Fang<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">
2013/5/17 Andrei Malashevich <span dir="ltr"><<a href="mailto:andrei.malashevich@yale.edu" target="_blank">andrei.malashevich@yale.edu</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Dear Paolo, <div><br></div><div>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.</div><div><br>
</div><div>
When I was studying the PP/stm.f90 routine, I decided to do the following test.</div><div>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.</div>
<div>In this file the x-axis corresponds to the 3rd dimension of the FFT grid, and y-axis shows rho(z).</div><div><br></div><div>The routine stm.f90 at the end has symmetrization part, that involves fwfft and invfft:</div>
<div><br></div><div><div> IF ( .not. gamma_only) THEN</div><div> !</div><div> CALL sym_rho_init (gamma_only)</div><div> !</div><div> psic(:) = cmplx ( rho%of_r(:,1), 0.0_dp, kind=dp)</div><div>
CALL fwfft ('Dense', psic, dfftp)</div><div> rho%of_g(:,1) = psic(nl(:))</div><div> CALL sym_rho (1, rho%of_g)</div><div> psic(:) = (0.0_dp, 0.0_dp)</div><div> psic(nl(:)) = rho%of_g(:,1)</div>
<div> CALL invfft ('Dense', psic, dfftp)</div><div> rho%of_r(:,1) = dble(psic(:))</div><div> ENDIF</div><div><br></div><div>If I comment this symmetrization part entirely, I obtain the result shown in the file before_fft.eps, which is what I wanted.</div>
<div>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.</div><div><br></div><div>So it looks that by doing FFT and inverse FFT did not return the original function. </div>
<div>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. </div>
<div>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.</div><div><br></div><div>Did I do something wrong with this test, or is it indeed the expected behavior of the code for some reason?</div>
<div>Do you know why this happens? </div><div>I would appreciate if you could comment on this.</div>
<div><br></div><div>Thank you,</div><div>Andrei Malashevich</div><div><br></div><div>Postdoctoral Associate</div><div>Department of Applied Physics<br></div><div><div>Yale University</div>
</div></div><div><br></div><div><br></div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 16, 2013 at 1:18 PM, Fang Liu <span dir="ltr"><<a href="mailto:cufe.fliu@gmail.com" target="_blank">cufe.fliu@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Dear Paolo,<br><br></div>Thank you very much for your quick reply.<div><br><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<br>
> In real space, the wavefunction is a real vector.<br>
<br>
</div>only for k=0 or if there is inversion symmetry<br></blockquote><div><br></div></div></div><div>Yes. I'm only considering the case k=0 at this moment. <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div>
<div><br>
> I want to write some code using 3D fft (forward and backward)<br>
> in Quantum Espresso for general complex vector (stored in 3D<br>
> array)<br>
<br>
</div>I am not sure I understand what you want to do: the 3D FFT in<br>
QE is quite general.</div></div><span><font color="#888888"><br>
_______________________________________________<br>
<br></font></span></blockquote><div>I tried the following test codes in QE.<br></div><div>That is, I use a 25*25*25 3D FFT mesh. The original 3d array g3d = (1.0_DP, -1.0_DP).<br></div><div>First I do invfft and then fwfft. Finally I don't get the original 3d array, but a 3d array g3dnew<br>
in which g3dnew(1),g3dnew(2),...,g3dnew(3025)= (1.0_DP, -1.0_DP) <br>while g3dnew(3026),....,g3dnew(15625)=0.0.<br><br></div><div>But if I do fwfft first and then invfft, I can finally get the original 3d array.<br><br>
</div><div>I don't know the reason. I tried to attach my results, but it seems too large to be sent<br></div><div>quickly. So I cancelled it.<br></div><div>
<br></div><div>Thank you very much.<br><br></div><div>===========<br> open(UNIT=73, FILE='g3d.log',STATUS='replace', FORM='formatted', ACTION='write')<br><br> g3d = (1.0_DP, -1.0_DP)<br>
write(73,*), 'g3d: original'<br> do i=1, dffts%nnr<br> write(73,101), i, g3d(i)<br> enddo<br> <br> <br> CALL invfft ('Wave', g3d, dffts) !transform potential to real space<br> <br> write(73,*), 'g3d: after invfft'<br>
do i=1, dffts%nnr<br> write(73,101), i, g3d(i)<br> enddo<br> <br> CALL fwfft ('Wave', g3d, dffts) !transform potential to reciprocal space<br> <br> write(73,*), 'g3d: after fwfft'<br>
do i=1, dffts%nnr<br> write(73,101), i, g3d(i)<br> enddo<br><br> close(73)<br>==============<br><br></div><div>Best,<br></div>Fang</div><div><div><div class="gmail_extra"><br><br>
<div class="gmail_quote">2013/5/16 Paolo Giannozzi <span dir="ltr"><<a href="mailto:paolo.giannozzi@uniud.it" target="_blank">paolo.giannozzi@uniud.it</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On Wed, 2013-05-15 at 16:45 -0700, Fang Liu wrote:<br>
<br>
> In real space, the wavefunction is a real vector.<br>
<br>
</div>only for k=0 or if there is inversion symmetry<br>
<div><br>
> I want to write some code using 3D fft (forward and backward)<br>
> in Quantum Espresso for general complex vector (stored in 3D<br>
> array)<br>
<br>
</div>I am not sure I understand what you want to do: the 3D FFT in<br>
QE is quite general.<br>
<span><font color="#888888"><br>
P.<br>
--<br>
Paolo Giannozzi, Dept. Chemistry&Physics&Environment,<br>
Univ. Udine, via delle Scienze 208, 33100 Udine, Italy<br>
Phone <a href="tel:%2B39-0432-558216" value="+390432558216" target="_blank">+39-0432-558216</a>, fax <a href="tel:%2B39-0432-558222" value="+390432558222" target="_blank">+39-0432-558222</a><br>
<br>
_______________________________________________<br>
Pw_forum mailing list<br>
<a href="mailto:Pw_forum@pwscf.org" target="_blank">Pw_forum@pwscf.org</a><br>
<a href="http://pwscf.org/mailman/listinfo/pw_forum" target="_blank">http://pwscf.org/mailman/listinfo/pw_forum</a><br>
</font></span></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Pw_forum mailing list<br>
<a href="mailto:Pw_forum@pwscf.org" target="_blank">Pw_forum@pwscf.org</a><br>
<a href="http://pwscf.org/mailman/listinfo/pw_forum" target="_blank">http://pwscf.org/mailman/listinfo/pw_forum</a><br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Pw_forum mailing list<br>
<a href="mailto:Pw_forum@pwscf.org">Pw_forum@pwscf.org</a><br>
<a href="http://pwscf.org/mailman/listinfo/pw_forum" target="_blank">http://pwscf.org/mailman/listinfo/pw_forum</a><br></blockquote></div><br></div>