From f70514f390004f22cdfd7b10dfa41c7fd28a0c72 Mon Sep 17 00:00:00 2001 From: ZacharyVarley <33402037+ZacharyVarley@users.noreply.github.com> Date: Sun, 8 Dec 2024 08:37:35 -0600 Subject: [PATCH] Update WK_scattering_factors.py Relevant WK computation in others.f90 in Prof. Marc De Graef's EMsoft reads: DO J=1,4 FPHON = FPHON + A1(J)*A1(J)*(DEWA * RI1(B1(J),B1(J),G) - RI2(B1(J),B1(J),G,UL)) DO I=1,J-1 FPHON = FPHON + 2.*A1(J)*A1(I)*(DEWA * RI1(B1(I),B1(J),G)-RI2(B1(I),B1(J),G,UL)) When J=1: The inner loop condition is DO I=1,0 (since J-1 = 0) In Fortran, when the upper bound is less than the lower bound, the loop is not executed at all So for J=1, only the first FPHON calculation happens, the inner loop is skipped. In the current py4DSTEM code, the inner loop is executed for ii = jj = 0 making the diagonal be computed a second time with a factor of 2.0 and take an overall prefactor of 3.0 instead of 1.0. If I am missing something and this has been verified against others.f90, then completely ignore this. --- py4DSTEM/process/diffraction/WK_scattering_factors.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/py4DSTEM/process/diffraction/WK_scattering_factors.py b/py4DSTEM/process/diffraction/WK_scattering_factors.py index eb964de96..23bb5c5d3 100644 --- a/py4DSTEM/process/diffraction/WK_scattering_factors.py +++ b/py4DSTEM/process/diffraction/WK_scattering_factors.py @@ -174,14 +174,9 @@ def compute_WK_factor( B1 = B / (4.0 * np.pi) ** 2 for jj in range(4): - Fphon += ( - A1[jj] - * A1[jj] - * (DWF * RI1(B1[jj], B1[jj], G) - RI2(B1[jj], B1[jj], G, UL)) - ) for ii in range(jj + 1): Fphon += ( - 2.0 + (2.0 if jj != ii else 1.0) * A1[jj] * A1[ii] * (DWF * RI1(B1[ii], B1[jj], G) - RI2(B1[ii], B1[jj], G, UL))