The dynamical algorithm#
The master pattern is computed as in EMsoft’s EMEBSDmaster
(mod_EBSDmaster.f90), per energy bin E and incident direction k.
Structure factors. For every
hklin the lookup box (out to twice thedminsphere), Weickenmeier-Kohl complex atomic amplitudes with phonon and core absorption (FSCATT, ported with EMsoft’s exact constants) are summed over the orbit with phasesexp(-2 pi i g.r)and scaled bypref = 0.04787801 / (4 pi V_cell), thenU = preg Vwithpreg = 0.664840340614319(CalcUcg).V_0,U'_0and the refraction-corrected relativistic wavelength come from theg = 0entry.Incident directions. The square Rosca-Lambert grid, both hemispheres, as unit vectors in the Cartesian crystal frame (
k = k_hat / lambda,k_n = 1 / lambda). Only the point group’s fundamental sector is computed and the result replicated by symmetry.Reflection list. All centering-allowed
hklwithd >= dminand|s_g| / (lambda |U_g|) <= c3. Forbidden reflections are kept within|s_g| <= sg_doubleas double-diffraction channels. Excitation errors come from the Ewald-sphere relations_g = -g.(2k + g) / (2 (k + g).n)with the foil normal along the beam.Bethe partition. For each candidate
g,m = min_h |s_g| / (lambda |U_{g-h}|)over all candidatesh. A reflection is strong whenm <= c1, weak whenc1 < m <= c2and dropped otherwise. Systematically absent reflections carry no structure factor and are never strong beams; promoting them was the one thing that held silicon below exact agreement with EMsoft.Dynamical matrix (nm-2,
GetDynMat):A_gh = U_{g-h} - (lambda/2) sum_w U_{g-w} U_{w-h} / s_woff the diagonal,A_gg = 2 s_g / lambda - (lambda/2) sum_w |U_{g-w}|^2 / s_w + i U'_0.Bloch solve and depth integration (
CalcLgh). EigendecomposeA, scale the eigenvaluesW -> W / (2 k_n), invert the eigenvector matrixCand takealpha = C^-1[:, 0]. ThenI_jk = conj(alpha_j) alpha_k sum_z lambda_E(z) exp(-q_jk z) dz / twithq_jk = 2 pi [(Im W_j + Im W_k) + i (Re W_j - Re W_k)](real part folded positive), andL_gh = conj(C) I C^T.lambda_E(z)is the Monte Carlo exit-depth fraction timesexp(+2 pi z / x_gp), which cancels the normal absorption already in the eigenvalues; the depth limit is the 99 % histogram depth.bloch_prismevaluates the same integral through the scattering matrix instead of an eigendecomposition.S_gh weighting. Per asymmetric-unit site,
S_gh = sum_atoms Z^2 exp(-B s^2) exp(+2 pi i (h - g).r), and the master-pattern intensity isI(k) = Re sum_gh L_gh S_gh / n_atoms.Accumulation. Intensities land at their Lambert pixel on the correct hemisphere, each computed pixel written to all its symmetry equivalents.
Energy loop. Steps 2-8 repeat per energy bin, since the wavelength, reflection lists and matrices change with
E; an energy-resolved master has shape(nE, 2, n, n). Trigonal and hexagonal systems would use the hexagonal Lambert grid with a final square resampling, which is not implemented.