Closed Jean1995 closed 1 year ago
Very good work!
the interpolation is only up to x=20, above, the functions are again evaluated analytically:
can you give a rough estimate on how often x>20
?
regarding the validation, the transition at x=20
seems to be smooth. But why are there larger deviations for f1m at around 11 or for f2m at around 19?
regarding the tests, one could compare histograms between Moliere and MoliereInterpol, similar to the cross-sections
- can you give a rough estimate on how often
x>20
?
I analyzed this for a few different use cases:
Propagation of a 1 PeV myon in ice, 500 MeV ecut:
Propagation of a 1 PeV myon in ice, 0.05 vcut:
Propagation of a 1 PeV myon in standardrock, 500 MeV ecut:
Propagation of a 1 PeV myon in standardrock, 0.05 vcut:
Simulation of a 10 TeV electron-induced shower, with a cut of 0.5 MeV
So I believe it is universally at a ratio of around 0.5%
- regarding the validation, the transition at
x=20
seems to be smooth. But why are there larger deviations for f1m at around 11 or for f2m at around 19?
For f1M
, the numerical evaluation method changes at x=12
:
The same happens for f2M
at 18.0625:
Here, the evaluation of f2M seems to be quite instable in general before we reach 18.0625.
- regarding the tests, one could compare histograms between Moliere and MoliereInterpol, similar to the cross-sections
Good point. I already thought about this, however, the results of individual calculations are not as similar as I would have thought. But I will have a closer look at this an add appropriate tests.
When profiling the performance of multiple scattering calculations, we already knew that
Moliere
takes much longer to calculate thanHighland
orHighlandIntegral
. For applications such as CORSIKA 8, where an accurate description of large-scattering angles is mandatory, this starts to becomes a performance issue.When profiling the execution of
Moliere
, I figured out that most of the time is spent in the functionsf1M
,f2M
,F1M
F2M
, where an expression is evaluated using Horner's method. Looking at the manual of EGS, I found out that they use interpolation tables to store the values of these functions instead of evaluating them for every execution.Therefore, I implemented a similar approach for PROPOSAL, using the
cubicinterpolation
classes.First of all, these are validations that the interpolation works smoothly:
Validation of f1M
![image](https://user-images.githubusercontent.com/15159319/232249506-99b91034-afb6-4d4d-b395-f0421dd07bc7.png) ![image](https://user-images.githubusercontent.com/15159319/232249511-b4c8205d-b26c-4fac-a396-7886d7304a09.png)Validation of f2M
![image](https://user-images.githubusercontent.com/15159319/232249534-ab3a324b-ab4c-49bf-bf98-fda816fe7073.png) ![image](https://user-images.githubusercontent.com/15159319/232249538-d5e01d66-84fa-4c45-810b-232ccf7070ac.png)Validation of F1M
![image](https://user-images.githubusercontent.com/15159319/232249549-03918258-2f8b-4dcf-b452-92a6d2c2d249.png) ![image](https://user-images.githubusercontent.com/15159319/232249552-3f24e0d6-57bf-4f77-bc08-fb18d08c506d.png)Validation of F2M
![image](https://user-images.githubusercontent.com/15159319/232249560-3c057ea5-c659-44b1-85df-69f50cdf0193.png) ![image](https://user-images.githubusercontent.com/15159319/232249581-14936069-249d-4d71-be8a-3c25a84a4801.png)The results of the scattering angles stays true to the results without the interpolation. This plots shows the scattering angles for electrons in air, with a fixed initial energy of 1 GeV and a fixed final energy of 0.9 GeV.
The runtime improvement can be seen in the following plot, which shows the computing time per scattering angle.
While the actual runtime improvement always depends on the specific usecase, it is at least of a factor of two.
This PR also include some smaller improvements, namely:
multiple_scattering::ScatteringOffset
Moliere::CalculateRandomAngle
doesn't seem to converge (normally, only about 5 iterations are necessary)