<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Well, yes. The relationship between direct and FFT methods is very straightforward. Since the direct summation over the grid points gives the exact value of the sampled function AT the grid points, the relationship is clearly (in the one dimensional case)<div>&nbsp; &nbsp; &nbsp; &nbsp;F\sub{FFT}(h) = Sum(-infinity, +infinity, F\sub{exact}(h+j*N)</div><div>where j is the summation index and N is the number of equally spaced sample points.</div><div><br></div><div>When I published this method I gave an error analysis that gives a more detailed discussion.</div><div><div style="margin: 0px; font-family: 'Times New Roman'; font-size: 14px; ">Acta Crystallographica Section A, Vol. 33, &nbsp;p. 486-492 (1977).</div><div style="margin: 0px; font-family: 'Times New Roman'; font-size: 14px; "><br></div><div style="margin: 0px; font-family: 'Times New Roman'; font-size: 14px; ">A very quick calculation involving grid size and an assumption of roughly Gaussian fall-off will quickly tell you whether or not the expected error is negligible. I recommend this check for any attempt to automatically decide between quick and accurate structure factor calculations.</div><div style="margin: 0px; font-family: 'Times New Roman'; font-size: 14px; "><br></div><div style="margin: 0px; font-family: 'Times New Roman'; font-size: 14px; ">Lynn Ten Eyck</div><div style="margin: 0px; font-family: 'Times New Roman'; font-size: 14px; "><br></div><div><div><div>On Dec 7, 2012, at 11:06 AM, Richard Gildea &lt;<a href="mailto:rgildea@gmail.com">rgildea@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">I meant to include in the previous email that I add the following lines to the loop over dmin in Graeme's script:<div><div><br></div><div>&nbsp; &nbsp; gridding = structure.crystal_symmetry().gridding(d_min=dmin)</div><div>&nbsp; &nbsp; print "gridding: ", gridding.n_real()</div>

</div><div><br></div><div>giving the output:</div><div><br></div><div><div>d_min: 5.0</div><div>gridding: &nbsp;(3, 3, 3)</div><div>d_min: 2.5</div><div>gridding: &nbsp;(8, 8, 8)</div><div>d_min: 1.7</div><div>gridding: &nbsp;(9, 9, 9)</div>

</div><div><br></div><div>With so few grid points it is entirely unsurprising that the FFT is such a poor approximation of the direct summation in this case!</div><div><br></div><div>Cheers,</div><div><br></div><div>Richard</div>

<div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 7 December 2012 10:49, Richard Gildea <span dir="ltr">&lt;<a href="mailto:rgildea@gmail.com" target="_blank">rgildea@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Graeme,<div><br></div><div>When you pass algorithm=None to xray.structure.structure_factors() it is supposed determine dynamically whether direct summation or FFT is best suited. However in this case (I guess because of the tiny unit cell?), the algorithm for choosing which method clearly fails as in this case direct summation would undoubtedly be better than FFT:</div>


<div><br></div><div>(from cctbx_project/cctbx/xray/structure_factors/from_scatterers.py)</div><div><br></div><div><div>&nbsp; &nbsp; &nbsp; &nbsp; # rough estimate</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if ( &nbsp;4*n_scatterers*self.space_group().order_p()*n_miller_indices</div>


<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt; self.crystal_gridding().n_grid_points()):</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; algorithm = "direct"</div></div><div><br></div><div>Maybe there should be some special handling for small unit cells here? I don't know if there is a reason why you would ever want to calculate structure factors via FFT for unit cells this tiny?</div>


<div><br></div><div>Cheers,</div><div><br></div><div>Richard</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On 7 December 2012 09:21, Nicholas Sauter <span dir="ltr">&lt;<a href="mailto:nksauter@lbl.gov" target="_blank">nksauter@lbl.gov</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Graeme,<br>
<br>
Just as a general ballpark figure, for protein work the difference<br>
between approximate FFT structure factors and the exact direct sum<br>
figures is on the order of 1%.<br>
<br>
Nick<br>
<div><br>
On Fri, Dec 7, 2012 at 8:29 AM, &nbsp;&lt;<a href="mailto:Graeme.Winter@diamond.ac.uk" target="_blank">Graeme.Winter@diamond.ac.uk</a>&gt; wrote:<br>
&gt; Bing! Bet Nat's hit this in one.<br>
&gt;<br>
&gt; There may be a resolution dependence for 'F' but F001 (say) should not change, and should not go from 0 to non-0 no matter what. Direct summation much better here...<br>
&gt;<br>
&gt; Presumably for a protein structure the effects of gridding will also be much less significant.<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Graeme<br>
&gt; ________________________________________<br>
&gt; From: <a href="mailto:cctbxbb-bounces@phenix-online.org" target="_blank">cctbxbb-bounces@phenix-online.org</a> [<a href="mailto:cctbxbb-bounces@phenix-online.org" target="_blank">cctbxbb-bounces@phenix-online.org</a>] on behalf of Nathaniel Echols [<a href="mailto:nechols@lbl.gov" target="_blank">nechols@lbl.gov</a>]<br>



&gt; Sent: 07 December 2012 15:46<br>
&gt; To: cctbx mailing list<br>
&gt; Subject: Re: [cctbxbb] Structure factor calculation weirdness<br>
&gt;<br>
&gt; On Fri, Dec 7, 2012 at 7:36 AM, &nbsp;&lt;<a href="mailto:Graeme.Winter@diamond.ac.uk" target="_blank">Graeme.Winter@diamond.ac.uk</a>&gt; wrote:<br>
&gt;&gt; Some confusion here at diamond � it seems that the amplitude of F(hkl)<br>
&gt;&gt; depends on dmin<br>
&gt;<br>
&gt; Yes, because it's using the FFT method, which means it first does map<br>
&gt; sampling on a grid whose dimensions will partly depend on the<br>
&gt; resolution. &nbsp;I'm not sure if there is resolution dependence for the<br>
&gt; scattering factors (I thought so, but I don't really know details),<br>
&gt; but I tried using direct summation and the resolution effect<br>
&gt; disappears.<br>
&gt;<br>
&gt; &nbsp; f_calc = structure.structure_factors(<br>
&gt; &nbsp; &nbsp; algorithm="direct",<br>
&gt; &nbsp; &nbsp; d_min = dmin).f_calc()<br>
&gt;<br>
&gt; For your toy example the speed difference isn't noticeable - for a<br>
&gt; protein structure it will be considerable.<br>
&gt;<br>
&gt; -Nat<br>
&gt; _______________________________________________<br>
&gt; cctbxbb mailing list<br>
&gt; <a href="mailto:cctbxbb@phenix-online.org" target="_blank">cctbxbb@phenix-online.org</a><br>
&gt; <a href="http://phenix-online.org/mailman/listinfo/cctbxbb" target="_blank">http://phenix-online.org/mailman/listinfo/cctbxbb</a><br>
&gt;<br>
&gt; --<br>
&gt; This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.<br>



&gt; Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.<br>
&gt; Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.<br>



&gt; Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom<br>



&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; cctbxbb mailing list<br>
&gt; <a href="mailto:cctbxbb@phenix-online.org" target="_blank">cctbxbb@phenix-online.org</a><br>
&gt; <a href="http://phenix-online.org/mailman/listinfo/cctbxbb" target="_blank">http://phenix-online.org/mailman/listinfo/cctbxbb</a><br>
<br>
<br>
<br>
</div><span><font color="#888888">--<br>
Nicholas K. Sauter, Ph. D.<br>
Computer Staff Scientist, Physical Biosciences Division<br>
Lawrence Berkeley National Laboratory<br>
1 Cyclotron Rd., Bldg. 64R0121<br>
Berkeley, CA 94720-8118<br>
<a href="tel:%28510%29%20486-5713" value="+15104865713" target="_blank">(510) 486-5713</a><br>
</font></span><div>_______________________________________________<br>
cctbxbb mailing list<br>
<a href="mailto:cctbxbb@phenix-online.org" target="_blank">cctbxbb@phenix-online.org</a><br>
<a href="http://phenix-online.org/mailman/listinfo/cctbxbb" target="_blank">http://phenix-online.org/mailman/listinfo/cctbxbb</a><br>
</div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
_______________________________________________<br>cctbxbb mailing list<br><a href="mailto:cctbxbb@phenix-online.org">cctbxbb@phenix-online.org</a><br>http://phenix-online.org/mailman/listinfo/cctbxbb<br></blockquote></div><br></div></div></body></html>