Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduction of order=0.5 mode in Single_crystal #1762

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

mads-bertelsen
Copy link
Contributor

The optimization in Single_crystal to reuse calculations for the previous ray when they are identical was supposed to speed up the calculation with a large factor, but in practice it was found to only reach a speed up of about 2 even with large split numbers. This was explored as a tangent in this issue: #1725

The reason is that the expensive hkl_search is performed both for the ray entering the crystal (which can be reused as the wave vector will be exactly the same as the previous ray when using split), and for when leaving the crystal, hence at most half of the work can be reused.

Here a new mode is introduced, order=0.5, where the attenuation from coherent scattering as the ray leaves the crystal is simply ignored, meaning the number of hkl_search calls can be reduced with a factor equal to the split number.

Here are results for lucine with different values for the order:
lucine_order_comparison_wide
lucine_order_comparison_narrow

As well as rubredoxin:
output_narrow_rubredoxin

The new mode, order=0.5 is stable when changing split value as expected:
order_half_split_stable

The execution time as a function of order and split is shown in the graf below:
execution_time_orders
This is for a target ncount after the crystal, so split 100 would be done with a factor 100 less rays than split 1. The fastest run with order=0.5 is barely more than a second, while the slowest runs with higher order is about 100 seconds.

The speedup between the different order settings can be seen below, the limit of 2 for order=1 is clearly seen.
speedup_orders

Here a speedup of almost a factor of 30 is seen. The increase in speed is suspected to grow for higher split numbers, but will saturate as the time spent elsewhere in the simulation starts to become the bottleneck.

@willend
Copy link
Contributor

willend commented Nov 18, 2024

@mads-bertelsen thanks for this, most welcome. I will have a look at adjusting / adding to tests including Single_crystal later.

@willend willend merged commit d2da55d into main Nov 18, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants