Fix of order system in Single_crystal #1764
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It was realized that the order system in Single_crystal in general performed unnecessary calculations, mainly calculating the coherent cross section, and then not using it when the ray leaves the crystal. This was fixed, and this made recent introduction of a order=0.5 mode and double bookkeeping of the heavy Tau_list unnecessary, so these were removed.
This update retains the speedup of order=0.5 for order=1 and reduces the memory footprint significantly for large systems.
The above graph was done with a relatively small ncount / problem size, the ceiling for speed up is increased with these parameters, speed ups of factor 100 are still observed with sufficiently large problems.
There is a significant difference between order=0 (all multiple scattering) and order=1, there are still improvements that could be made without sacrificing performance, for example allowing incoherent scattering to higher orders even when the coherent part is disabled.
Some changes were made in the propagation for Powder and PG mode that can lead to the ray leaving the sample during normal propagation. This is reversed to a more secure version. To show this works as intended, there is a test instrument that compares PowderN and Single_crystal with the powder mode. This fails as they are not exactly alike, meaning there is more debugging to do.