<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.yambo-code.eu/wiki/index.php?action=history&amp;feed=atom&amp;title=The_Fast_Fourier_Transformation</id>
	<title>The Fast Fourier Transformation - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.yambo-code.eu/wiki/index.php?action=history&amp;feed=atom&amp;title=The_Fast_Fourier_Transformation"/>
	<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=The_Fast_Fourier_Transformation&amp;action=history"/>
	<updated>2026-05-18T15:39:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=The_Fast_Fourier_Transformation&amp;diff=2576&amp;oldid=prev</id>
		<title>Marini at 13:35, 25 October 2019</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=The_Fast_Fourier_Transformation&amp;diff=2576&amp;oldid=prev"/>
		<updated>2019-10-25T13:35:07Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:35, 25 October 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l11&quot;&gt;Line 11:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 11:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Implementation ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Implementation ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Calls to FFT routines can be found in yambo in several places, for instance during the computation of optical oscillators (see [[&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Xd|Xd&lt;/del&gt;]] ) or the exchange self-energy (see [[&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;../docs/doc_XX.php|XX&lt;/del&gt;]] ), or in loading the wavefunctions (see &amp;#039;&amp;#039;src/2wf_and_fft/wfload.F&amp;#039;&amp;#039;). In the first two cases the quantity of interest (matrix element) has the form&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Calls to FFT routines can be found in yambo in several places, for instance during the computation of optical oscillators (see [[&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Dynamical Response&lt;/ins&gt;]] ) or the exchange self-energy (see [[&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Hartree-Fock&lt;/ins&gt;]] ), or in loading the wavefunctions (see &amp;#039;&amp;#039;src/2wf_and_fft/wfload.F&amp;#039;&amp;#039;). In the first two cases the quantity of interest (matrix element) has the form&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[File:PIC_doc_FFT-19.png]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[File:PIC_doc_FFT-19.png]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Marini</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=The_Fast_Fourier_Transformation&amp;diff=2573&amp;oldid=prev</id>
		<title>Marini: Created page with &quot; = Fast Fourier Transformation (FFT) =  The Fast Fourier transform (FFT) is an efficient algorithm for computing the discrete Fourier transform and its inverse. In the mathema...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=The_Fast_Fourier_Transformation&amp;diff=2573&amp;oldid=prev"/>
		<updated>2019-10-25T13:27:46Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; = Fast Fourier Transformation (FFT) =  The Fast Fourier transform (FFT) is an efficient algorithm for computing the discrete Fourier transform and its inverse. In the mathema...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
= Fast Fourier Transformation (FFT) =&lt;br /&gt;
&lt;br /&gt;
The Fast Fourier transform (FFT) is an efficient algorithm for computing the discrete Fourier transform and its inverse. In the mathematics and engineering fields, the FFT is frequently used to transform between the frequency and time domains. In plane-wave codes such as yambo, the 3-dimensional complex-complex FFT algorithm is very heavily used to transform functions (typically wavefunctions or densities) from real space (&amp;#039;&amp;#039;&amp;#039;r,R&amp;#039;&amp;#039;&amp;#039;) into their counterparts in reciprocal space (&amp;#039;&amp;#039;&amp;#039;k,q,G&amp;#039;&amp;#039;&amp;#039;), and back again via the inverse transform. Since wavefunctions and densities are sampled on &amp;#039;&amp;#039;finite grids&amp;#039;&amp;#039; based on the reciprocal lattice vectors (&amp;#039;&amp;#039;&amp;#039;G&amp;#039;&amp;#039;&amp;#039;), e.g.&lt;br /&gt;
&lt;br /&gt;
[[File:PIC_doc_FFT-7.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:PIC_doc_FFT-12.png]]&lt;br /&gt;
&lt;br /&gt;
a &amp;#039;&amp;#039;discrete&amp;#039;&amp;#039; Fourier transform is necessary to transform them to finite grids in the unit cell. Likewise, integrals are transformed into weighted sums.&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
Calls to FFT routines can be found in yambo in several places, for instance during the computation of optical oscillators (see [[Xd|Xd]] ) or the exchange self-energy (see [[../docs/doc_XX.php|XX]] ), or in loading the wavefunctions (see &amp;#039;&amp;#039;src/2wf_and_fft/wfload.F&amp;#039;&amp;#039;). In the first two cases the quantity of interest (matrix element) has the form&lt;br /&gt;
[[File:PIC_doc_FFT-19.png]]&lt;br /&gt;
&lt;br /&gt;
This quantity could be computed by expanding the wavefunctions in &amp;#039;&amp;#039;&amp;#039;G&amp;#039;&amp;#039;&amp;#039; space using (1), and carrying out various sums and integrals- including a double sum over G! However, the matrix element can also be computed using a Fourier transform:&lt;br /&gt;
[[File:PIC_doc_FFT-24.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:PIC_doc_FFT-28.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:PIC_doc_FFT-32.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:PIC_doc_FFT-36.png]]&lt;br /&gt;
&lt;br /&gt;
However, this is just the Fourier transform of&lt;br /&gt;
[[File:PIC_doc_FFT-41.png]]&lt;br /&gt;
&lt;br /&gt;
In practice, the real space integral could be discretized over N&amp;lt;sub&amp;gt;R&amp;lt;/sub&amp;gt; points, and converted into a sum; the Fourier transforms are hence discrete. Therefore, we note that the matrix element (3) can be calculated by:&lt;br /&gt;
# Converting both wavefunctions to the same real space grid, by means of FTs (see (2));&lt;br /&gt;
# Computing the simple product of the wavefunctions in real space, to obtain the product appearing inside (4);&lt;br /&gt;
# Carrying out the (inverse) FT (i.e., compute (4)), to obtain (6).&lt;br /&gt;
&lt;br /&gt;
Why bother doing all this? Because it turns out that the FT can be carried out very efficiently, and is much faster than doing the products of the wavefunctions in reciprocal space!&lt;br /&gt;
== Efficiency ==&lt;br /&gt;
&lt;br /&gt;
We can illustrate the efficiency of the FFT by considering a more simple example: calculation of the density in real space:&lt;br /&gt;
[[File:PIC_doc_FFT-55.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:PIC_doc_FFT-59.png]]&lt;br /&gt;
&lt;br /&gt;
Number of computations in reciprocal space method:&lt;br /&gt;
[[File:PIC_doc_FFT-63.png]]&lt;br /&gt;
&lt;br /&gt;
However, if we transform the wavefunctions to real space first using the Fast Fourier Transform routine (i.e., NOT just by regularly calculating the sum over G, as in the usual discrete Fourier transform):&lt;br /&gt;
[[File:PIC_doc_FFT-67.png]]&lt;br /&gt;
&lt;br /&gt;
where the expression on the left is evaluated using a call to the FFT routine, we can then obtain&lt;br /&gt;
[[File:PIC_doc_FFT-72.png]]&lt;br /&gt;
&lt;br /&gt;
Number of computations in real space/FFT method:&lt;br /&gt;
[[File:PIC_doc_FFT-76.png]]&lt;br /&gt;
&lt;br /&gt;
If you really want to find out why an FFT is faster than a regular FT, you can find further information in the references. Most people just treat FFT routines as black boxes, and this includes the good people of yambo. To summarise: the number of computations required for an N-point discrete Fourier Transform is 2N&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; if a straightforward algorithm is used. An FFT algorithm reduces this to 2 N ln(N). Since calls to the FFT routine constitute a large part of the total runtime, it is important to have highly efficient FFT libraries (and if possible, tuned to the hardware). Presently, yambo has the possibility of using the routines of Stefan Goedecker (hardwired internally: &amp;#039;&amp;#039;src/2wf_and_fft/sgfft.F&amp;#039;&amp;#039;) or the FFTW routines (external libraries, set FFTW_LIBS when configuring). Other efficient vendor specific libraries are included in the IBM ESSL, the AMD ACML and the Intel MKL libraries, although these are not coded into yambo as yet.&lt;br /&gt;
== Numerical factors: grids and cutoffs ==&lt;br /&gt;
&lt;br /&gt;
This brings us to one of the most important tuning parameters in yambo: [[Variables#FFTGvecs|FFTGvecs]] . This determines the number of &amp;#039;&amp;#039;&amp;#039;G&amp;#039;&amp;#039;&amp;#039;-vectors used in the FFT routine. It is &amp;#039;&amp;#039;&amp;#039;strongly&amp;#039;&amp;#039;&amp;#039; advised that you test the convergence of your spectrum with this parameter! Usually you will find you can reduce the calculation time by a considerable amount by reducing this factor from the default (the number of &amp;#039;&amp;#039;&amp;#039;G&amp;#039;&amp;#039;&amp;#039;&amp;#039;s in the DFT wavefunctions), without affecting the accuracy much. Note that this applies also to the calculation of the optical oscillators (&amp;#039;&amp;#039;q-&amp;gt;0; G,G&amp;#039;=0&amp;#039;&amp;#039;), where the FFT routine is not actually used.&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* S. Goedecker, &amp;#039;&amp;#039;Rotating a three-dimensional array in optimal positions for vector processing: Case study for a three-dimensional Fast Fourier Transform&amp;#039;&amp;#039;, Comp. Phys. Commun. &amp;#039;&amp;#039;&amp;#039;76&amp;#039;&amp;#039;&amp;#039;, 294 (1993)&lt;br /&gt;
* FFTW: The fastest Fourier Transform in the West, [http://www.fftw.org/ http://www.fftw.org]&lt;br /&gt;
* FFT theory at [http://en.wikipedia.org/wiki/Fast_Fourier_transform Wikipedia]&lt;br /&gt;
* FFT theory at [http://mathworld.wolfram.com/FastFourierTransform.html Mathworld]&lt;/div&gt;</summary>
		<author><name>Marini</name></author>
	</entry>
</feed>