Page 1 of 1

confused by code in hartre1.F90 (solved)  [SOLVED]

Posted: Wed May 04, 2011 9:55 pm
by ldamewood
I'm trying to write a small routine to calculate some energy term and I was using hartre1.F90 (in 6.6.2) as a template. This part is giving me trouble:

Code: Select all

 do ii=1,3
   id(ii)=ngfft(ii)/2+2
   do ing=1,ngfft(ii)
     ig=ing-(ing/id(ii))*ngfft(ii)-1
     gq(ii,ing)=ig+qphon(ii)
   end do
 end do


For my calculation, ngfft(:)=36 and for simplicity, qphon(:)=0. The result is

Code: Select all

gq(1,:)=gq(2,:)=gq(3,:)=
   -1.8000
   -2.6000
   -3.4000
   -4.2000
   -5.0000
   -5.8000
   -6.6000
   -7.4000
   -8.2000
   -9.0000
   -9.8000
  -10.6000
  -11.4000
  -12.2000
  -13.0000
  -13.8000
  -14.6000
  -15.4000
  -16.2000
  -17.0000
  -17.8000
  -18.6000
  -19.4000
  -20.2000
  -21.0000
  -21.8000
  -22.6000
  -23.4000
  -24.2000
  -25.0000
  -25.8000
  -26.6000
  -27.4000
  -28.2000
  -29.0000
  -29.8000


Shouldn't the G vectors be whole numbers; or am I missing something?

Thanks!

Re: confused by code in hartre1.F90

Posted: Thu May 05, 2011 8:34 am
by mverstra
yes, but

1) the gq are G+q, so they will certainly not be integers
2) if ngfft is odd it looks like you will get half integer values for id anyway

matthieu

Re: confused by code in hartre1.F90

Posted: Thu May 05, 2011 6:16 pm
by ldamewood
nevermind, I got it. integer math. :-P