It's a bit scrapy so far, but here's the progress in method development for calculating beta parameters as a tensor product sum in python, as a series of three notebooks:
- Geometric method development pt. 1 (basic element development)
- Geometric method development pt. 2 (with fully implemented and verified tensor methods)
- Geometric method development pt. 3 (full aligned frame calculations and testing)
This is a good question... at least two reasons:
- Tensor methods provide a clean separation of the various elements of the theory into physically meaningful parts, hence aid understanding and intuition.
- Numerically, with the Xarray package (see also the full Xarray docs), one can implement tensor products and sums pretty directly, making a more transparent comparison with the formalism and code (this - at least for me - has certainly not been the case in the past, with large vector or multiple-nested-loop type constructions required), and code that is easier to verify, maintain and modify.
Additionally, I think this should also generally be fast (as compared to nested-loop type codes), although this may be at the cost of higher memory requirements. In the current implementation, the tensor routines are approximately two orders of magnitude faster than (single code) nested-loop style code... although the latter was not particularly well optimised, and it's likely true that highly-optimised, low-level, parallelised code will always be fastest. This is, however, also more challenging to write (that said, now all the formalisms are verified, more low-level development will probably happen for fitting problems in any case, especially for GPU-based routines!).
Here's a quick demo result, showing BLM parameters for impulsively aligned N2 . Computation took <1 second. (See here for more details.)
Matrix element definitions
In the process of doing this, I've finally verified my definitions, calibration and use of ePolyScat raw matrix elements.^ This ensures that the use of the matrix elements is consistent between the python codes and the beta parameters output directly from ePS for the LF results, and also that the new AF code reduces to the LF case for an isotropic distributions. Phew.
^ This is mainly a self-consistency issue, and, in previous work, hasn't mattered if using only matrix elements from a single source with the corresponding formalism... but is rather important when comparing matrix elements from different formalisms, or comparing theory to experimental results. Plus general piece-of-mind and thoroughness of course!