<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="appendonsend"></div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Hello </div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
there is a factor of 2 because the G vectors range from - N_max/ 2 to N_max/2, where N_max in the number of divisions of the FFT grid in a given direction. You may wannto to look at the routines called by fft_type_init to arrange the grid; but the simplified
expression for the max number of divisions in the FFT grid for a given edge of the lattice box is just: </div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
N_max = int(G_max * A_i / PI) </div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
PI being 3.14.... , A_i the length of the lattice vector for the particular edge and G_max the longest reciprocal vector prescribed by the cutoff, in QE, </div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
other few thing to keep in mind are that </div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<ul data-editing-info="{"applyListStyleFromLevel":false,"unorderedStyleType":1}" style="list-style-type: disc;">
<li style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<div>to be sure that the required cutoff is applied in all the Brillouin zone , G_max is set as: </div>
</li></ul>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
G_max = sqrt(ECUTRHO) + 1/2 * MAX (PI/A_i)</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<ul data-editing-info="{"applyListStyleFromLevel":false,"unorderedStyleType":1}" style="list-style-type: disc;">
<li style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<div>the value reported by pw.x should be the one for the wave functions with ECUTRHO set to 4 * ECUTWFC </div>
</li><li style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<div>the final values of the divisions are further mangled to avoid too large prime factors that can spoil the FFTW performance. </div>
</li></ul>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Hope it helps </div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Pietro </div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr style="display: inline-block; width: 98%;">
<div dir="ltr" id="divRplyFwdMsg"><span style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);"><b>From:</b> users <users-bounces@lists.quantum-espresso.org> on behalf of Dyer, Brock <brdyer@ursinus.edu><br>
<b>Sent:</b> Sunday, March 2, 2025 06:04<br>
<b>To:</b> Quantum ESPRESSO users Forum <users@lists.quantum-espresso.org><br>
<b>Subject:</b> Re: [QE-users] Details of Automatic FFT Grid Size Calculation</span>
<div> </div>
</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
I've been tracing down all the variables that are required to generate a good FFT grid, and I seem to be off by a factor of 2 in the end. I can't quite figure out what the issue is, but my guess may be that while I am storing 'ecutwfc' in Rydbergs there is
a conversion to Hartrees somewhere in the code that I haven't seen yet. </div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
My current process looks like this (with some values from a run I had recently so I can compare):</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
ecutwfc = 100 Ry</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Ecutrho = 400 Ry</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; line-height: 24px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
# Unit cell dimensions, given in Bohrs</div>
<div style="direction: ltr; line-height: 24px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
v1 = [44.09733757, 0.0, 0.0]</div>
<div style="direction: ltr; line-height: 24px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
v2 = [0.0, 44.09733757, 0.0]</div>
<div style="direction: ltr; line-height: 24px; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
v3 = [0.0, 0.0, 44.09733757]</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="" id="x_appendonsend"></div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
alat = sqrt(v1[0]**2 + v1[1]**2 + v1[2]**2)</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
tpiba = (2.0 * pi) / alat</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
gcutm = ecutrho / (tpiba**2)</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
at = [v1/alat, v2/alat, v3/alat]</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
nr1 = int(sqrt(gcutm) * sqrt(at[0][0]**2 + at[0][1]**2 + at[0][2]**2)) + 1</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
nr2 = int(sqrt(gcutm) * sqrt(at[1][0]**2 + at[1][1]**2 + at[1][2]**2)) + 1</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
nr3 = int(sqrt(gcutm) * sqrt(at[2][0]**2 + at[2][1]**2 + at[2][2]**2)) + 1</div>
<div style="direction: ltr; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
These last lines are where I've noticed the problem. From looking at the output of my run with the given cell sizes, I expect an FFT grid of 288x288x288, however if I were to run this code (and the code that checks if it's a good size) I'd get an FFT grid that
is only half that. I'd love some advice on this if it is at all possible. I also can send some more formatted code if it would help (I decided to cut down the python code so it looked a bit more like the original f90 code).</div>
<div style="direction: ltr; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr style="direction: ltr; display: inline-block; width: 98%;">
<div style="direction: ltr; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b>From:</b> users on behalf of Stefano de Gironcoli<br>
<b>Sent:</b> Thursday, February 27, 2025 2:50 PM<br>
<b>To:</b> users@lists.quantum-espresso.org<br>
<b>Subject:</b> Re: [QE-users] Details of Automatic FFT Grid Size Calculation</div>
<div style="direction: ltr; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<p style="direction: ltr; margin-top: 0px; margin-bottom: 0px;">it's in SUBROUTINE realspace_grid_init in FFTXlib/src/file fft_types.f90</p>
<p style="direction: ltr; margin-top: 0px; margin-bottom: 0px;"> !<br>
! ... calculate the size of the real-space dense grid for FFT<br>
! ... first, an estimate of nr1,nr2,nr3, based on the max values<br>
! ... of n_i indices in: G = i*b_1 + j*b_2 + k*b_3<br>
! ... We use G*a_i = n_i => n_i .le. |Gmax||a_i|<br>
!<br>
dfft%nr1 = int ( sqrt (gcutm) * sqrt (at(1, 1)**2 + at(2, 1)**2 + at(3, 1)**2) ) + 1<br>
dfft%nr2 = int ( sqrt (gcutm) * sqrt (at(1, 2)**2 + at(2, 2)**2 + at(3, 2)**2) ) + 1<br>
dfft%nr3 = int ( sqrt (gcutm) * sqrt (at(1, 3)**2 + at(2, 3)**2 + at(3, 3)**2) ) + 1<br>
<br>
</p>
<p style="direction: ltr; margin-top: 0px; margin-bottom: 0px;">stefano</p>
<p style="direction: ltr; margin-top: 0px; margin-bottom: 0px;"><br>
</p>
<p style="direction: ltr; margin-top: 0px; margin-bottom: 0px;"><br>
</p>
<div style="direction: ltr;">On 27/02/25 20:11, Dyer, Brock wrote:</div>
<blockquote>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Hello all, I have been working quite a bit lately on automating my QE workflow, and as part of that workflow I check the automatically calculated FFT grid sizes for the level of theory that I have been using in order to improve my parallelization. </div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
I have tried tracing down and reading the code that calculates the FFT grid sizes, however I cannot find/understand the actual code to calculate the grid sizes. My current understanding is that the initial parameters to calculate the grid size are 'ecutwfc'
and/or 'ecutrho', and the unit cell size, and then there seems to be some more math, and perhaps at the end the final dimensions get calculated in 'fft_ggen.f90'. </div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
What I am looking for ideally is a mathematical formula that includes all of the input parameters and operations required to calculate the FFT grid sizes so that I can implement it into my workflow and hopefully not have to run double calculations to properly
parallelize.</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Thanks in advance for the help!</div>
<div style="direction: ltr; font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="" id="x_x_Signature">
<p style="margin-top: 0px; margin-bottom: 0px;">Brock Dyer, Ursinus College Class of 2025</p>
<p style="margin-top: 0px; margin-bottom: 0px;"><br>
</p>
</div>
<div style="direction: ltr;"><br>
</div>
<fieldset style="" class="x_x_moz-mime-attachment-header"></fieldset>
<pre><div style="direction: ltr;">_______________________________________________________________________________
The Quantum ESPRESSO Foundation stands in solidarity with all civilians worldwide who are victims of terrorism, military aggression, and indiscriminate warfare.
--------------------------------------------------------------------------------
Quantum ESPRESSO is supported by MaX (<a href="https://linkprotect.cudasvc.com/url?a=http%3a%2f%2fwww.max-centre.eu&c=E,1,o6mRyDmIfQXWXGr_JikolRfWqjEMwbk8xt5Q6J2l_N7Fky0gnXgD_aQU9TdYIxh51SmHmmgN9S5AJxHAS6vpqDSxTijqfOUXWuQTbchy3TZnaqcHjGvJ&typo=1" id="OWAb0b45488-56a6-6b16-96e9-6f6b15e8f0f9" class="x_x_moz-txt-link-abbreviated x_OWAAutoLink" data-auth="NotApplicable">www.max-centre.eu</a>)
users mailing list <a href="mailto:users@lists.quantum-espresso.org" id="OWA3f356465-e8c8-b76e-ce2b-2165a66f1558" class="x_x_moz-txt-link-abbreviated x_OWAAutoLink">users@lists.quantum-espresso.org</a>
<a href="https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flists.quantum-espresso.org%2fmailman%2flistinfo%2fusers&c=E,1,MVtAKpGoN3VwtTvpYzhgehNBw3lc6Ccvz18zJQYi8KwO2z3w1lLip_vRNXU25kTl-Lr0eMQKhqjTUVWShMvELzUclPM0hjrp4RgEFfOWL7-pZnGUAGdhpqG_ZBdI&typo=1" id="OWAd6cf0b25-6c5a-f634-4cad-3afa026a4adf" class="x_x_moz-txt-link-freetext x_OWAAutoLink" data-auth="NotApplicable">https://lists.quantum-espresso.org/mailman/listinfo/users</a></div></pre>
</blockquote>
</body>
</html>