Optimize source using chopper cascade acceptance diagram#136
Optimize source using chopper cascade acceptance diagram#136
Conversation
|
@YooSunYoung I got it down to only a few iterations, but it seems we cannot mask out tighly around the polygons after all. This leads to weird results (see the spikes and striping) Neutrons sampled from the source: If I either don't mask at all (and iterate more), or mask just rectangles using the polygon bounding boxes, I don't get the effect, but I have to do 28 iterations to sample 3M neutrons (this takes ~6s just to build the source).
I guess the thing that we really save on is RAM, so it's still worth it. But I don't think we save much in compute time... |
|
I believe that the artifacts above can be explained by the Gaussian noise that is added to the neutron birth time and wavelength during the sampling. But when we have a mask where sets the probability to 0, suddenly things no longer balance out. We have some contributions that should be coming from outside the polygons to even things out that no longer exist because their probability has been set to 0. While the cells that are not masked contribute their tails to the surroundings. Instead, we want to use uniform noise between -0.5 and 0.5 cell size. |
|
After updates in #139 and some further performance improvements in the masking, building an optimized source is now fast, uses a tight mask, and no longer has weird artifacts/striping. Without optimization (1M neutrons, Odin choppers): 942625 neutrons blocked, 57375 visible With optimization (1M neutrons, Odin choppers): 0 blocked, 1M visible |






Alternative to #131 , needs #139
Instead of using readings from a run, we compute analytically the chopper acceptance diagram and mask out the regions in the probability distribution that are rejected by the choppers.
We just make a new source from the masking, thus requiring no changes to the rest of the codebase.
To optimize the source, we pass the list of choppers in the beamline as
optimize_for:Original with 1M neutrons (72907 visible at the detector, 927093 blocked)

Optimized source with 1M neutrons (1M visible, 0 neutrons are blocked)

TODO: still need to write some tests.