From: John Stone (johns_at_ks.uiuc.edu)
Date: Tue Jul 29 2008 - 13:22:57 CDT

Hi,
  Jim mentioned that the VMD pmepot plugin he wrote also contains
code to determine a good FFT size. Here's a verbatim snippet from the
pmepot plugin. You could either adapt this for your own use or simply
call it from your own code. If you choose to call it from your own code,
you'd need to do something like:
package require pmepot
set newval [::PMEPot::good_fft_dim $myvalue]

proc ::PMEPot::good_fft_dim { r {max 0} } {
  variable default_grid_max_dim
  if { $max == 0 } { set max $default_grid_max_dim }
  if { $max < 8 } { error "max dimension of $max is too small" }
  set nl [list 8 10 12 16 20 24 30 32 36 40 48 50 56 60 64 72 80 \
                84 88 96 100 108 112 120 128]
  set goodn 8
  foreach mi {1 2 3 4 5 6 8 10} {
    foreach ni $nl {
      set n [expr $mi * $ni]
      if {$n > $max} { return $goodn }
      if {$n > $goodn} { set goodn $n }
      if {$goodn >= $r} { return $goodn }
    }
  }
  return $goodn
}

You may also find the PMEPot code for calculating grid dimensions
from the cell basis vectors useful:

proc ::PMEPot::make_grid_from_cell { cell resolution {max 0} } {
  foreach { o a b c } $cell { break }
  set a [expr 1.0 * [veclength $a] / $resolution]
  set b [expr 1.0 * [veclength $b] / $resolution]
  set c [expr 1.0 * [veclength $c] / $resolution]
  set na [good_fft_dim $a $max]
  set nb [good_fft_dim $b $max]
  set nc [good_fft_dim $c $max]
  return [list $na $nb $nc]
}

On Tue, Jul 29, 2008 at 08:21:17AM +0200, Balazs Jojart wrote:
> Hi Roman,
> look the folllowing link:
> http://www.ks.uiuc.edu/Research/namd/mailing_list/namd-l/0051.html
> hope this helps.
> balazs
>
> Roman Petrenko wrote:
> >sorry for being so stupid,
> >it just struck me that cellBasisVectors are simply rounded to higher
> >integer coordinate differences (max-min).
> >
> >Ok, how to explain number 32???
> >
> >
> >
> >On Mon, Jul 28, 2008 at 8:46 PM, Roman Petrenko <rpetrenko_at_gmail.com>
> >wrote:
> >
> >>Dear all,
> >>after looking at the namd tutorial and the user guide and still do not
> >>understand how to come up with the numbers for periodic boundary
> >>conditions!
> >>---------------------
> >>
> >>># Periodic Boundary Conditions
> >>>cellBasisVector1 42. 0. 0.
> >>>cellBasisVector2 0. 44. 0.
> >>>cellBasisVector3 0. 0 47.
> >>>cellOrigin 31. 29. 17.5
> >>>wrapAll on
> >>># PME (for full-system periodic electrostatics)
> >>>PME yes
> >>>PMEGridSizeX 32
> >>>PMEGridSizeY 32
> >>>PMEGridSizeZ 32
> >>>
> >>-----------------------
> >>The only line i understand here is cellOrigin, which i compute as
> >>set cen [measure center [atomselect top "all"] weight mass]
> >>cellOrigin [lindex $cen 0] [lindex $cen 1] [lindex $cen 2]
> >>
> >>BUT, how to find all other magic numbers 42,44,47, and 32 for specific
> >>protein?
> >>
> >>Please, help
> >>
> >>--
> >>Roman Petrenko.
> >>Physics Department
> >>University of Cincinnati
> >>
> >>
> >
> >
> >
> >

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
Email: johns_at_ks.uiuc.edu                 Phone: 217-244-3349
  WWW: http://www.ks.uiuc.edu/~johns/      Fax: 217-244-6078