differentiable_ucg_lut#

de_ebsd.crystal.differentiable_ucg_lut(crystal, energy_kev, dmin, *, positions=None, occupancies=None, debye_waller=None, absorption=True, device=None, dtype=torch.complex128)[source]#

Assemble the U_g lookup table in torch, differentiable in the crystal.

U_g = pre * sum_site occ_site * f_site(g) * sum_r exp(-2 pi i g.r). All three parameter groups are differentiable when passed as requires_grad tensors:

  • positions – the structure-factor phase sum_r exp(-2 pi i g.r);

  • occupancies – the linear per-site weight;

  • debye_waller (B in nm^2, one per site) – feeds the torch WK amplitude (de_ebsd.crystal.scattering_torch.wk_scattering_factor_torch()), so U_g differentiates w.r.t. the thermal factor.

When debye_waller is None the amplitudes are evaluated in numpy and held constant (positions/occupancy gradients only). Feed the result to a torch backend (bloch_prism) as its u_lut for end-to-end d(intensity)/d(crystal parameter). Lattice gradients (through g) remain a further step.