Modification to PAW fine mesh generation

Documentation, Web site and code modifications

Moderators: baguetl, routerov

Locked
Steven Miller
Posts: 5
Joined: Fri Jul 30, 2010 10:39 pm

Modification to PAW fine mesh generation

Post by Steven Miller » Wed Aug 04, 2010 10:09 pm

In the ground state forum, I discussed a seg fault error that results from a fine mesh that has a dimension that is coarser than the coarse mesh. This creates a problem in the indgrid.F90 subroutine, because you end up with an incomplete coatofin vector, which causes transgrid to corrupt memory and segfault when transferring rhog from the coarse to fine grid. I created a patch that changes getng.F90 such that the invars2m.F90 can pass the coarse mesh as an input parameter, and getng will use that as an initial guess for calculating the fine mesh. This helps ensure that the fine grid will be at a minimum as fine as the coarse grid in every dimension.

My only concern is whether this method might cause some meshes to end up finer than needed, even if the mesh was perfectly okay anyway. Based on how it searches for the optimal mesh in getng, I don't believe this will be an issue. It should only make a difference if the fine mesh were problematic, in which case this is necessary. Does anyone know if this will be an issue? The section where it changes getng.F90 is show below:

Code: Select all

@@ -206,8 +207,14 @@
 !Save input values of ngfft
  ngsav(1:3) = ngfft(1:3)
 
-!Give an initial guess at ngfft and iterate
- ngfft(1:3)=2
+!As an initial guess for ngfft, use the provided coarse mesh grid
+ if (PRESENT(ngfftc)) then
+   ngfft(1:3)=ngfftc(1:3)
+   call wrtout(std_out,' Using supplied coarse mesh as initial guess.','COLL')
+ else
+   ngfft(1:3)=2
+ end if
+


"getng" is modified to accept an optional argument, ngfftc, the coarse mesh grid dimensions. If not supplied, it uses (2,2,2) as the initial guess, but if it is supplied, it uses ngfftc as the initial guess.

The patch also modifies indgrid.F90 to check to make sure there are no zeros in coatofin. Even with the modified getng algorithm, it may be possible for the user to specify an ngfftdg in the input file which will cause the crash to occur. The patch fixes it to detect the problem and break with an error message.

mverstra
Posts: 655
Joined: Wed Aug 19, 2009 12:01 pm

Re: Modification to PAW fine mesh generation

Post by mverstra » Sat Sep 04, 2010 8:31 am

Hello Steven,

this is a very complete bug report, thanks. It seems strange you could even set things up such that the fine grid is coarser... Could we have the full patch file so we can insert it in abinit 6.2.3 and the upcoming 6.4? And also a small input file which crashes with present code, so we can set up a test?

Cheers

Matthieu
Matthieu Verstraete
University of Liege, Belgium

Locked