-
Notifications
You must be signed in to change notification settings - Fork 128
Update PaalmanPingsAbsorptionCorrection #39210
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
Conversation
4940cc9
to
e0250aa
Compare
I was using the following script (which I think is pretty much the same as the one put above in the PR) for testing, ws = CreateWorkspace(DataX=[1.7981, 1.7983], DataY=[0.0]*4, NSpec=4, UnitX="Wavelength", YUnitLabel="Counts")
EditInstrumentGeometry(ws,
PrimaryFlightPath=5.0,
SpectrumIDs=[1, 2, 3, 4],
L2=[2.0, 2.0, 2.0, 2.0],
Polar=[10.0, 90.0, 170.0, 90.0],
Azimuthal=[0.0, 0.0, 0.0, 45.0],
DetectorIDs=[1, 2, 3, 4],
InstrumentName="Instrument")
SetSample(ws,
Geometry={"Shape": "Cylinder", "Height": 5.68, "Radius": 0.295},
Material={"ChemicalFormula": "La-(B11)5.94-(B10)0.06", "SampleNumberDensity": 0.1},
ContainerGeometry={"Shape": 'HollowCylinder', 'Height': 5.68, 'InnerRadius': 0.295, 'OuterRadius': 0.315},
ContainerMaterial={"ChemicalFormula": "V", "SampleNumberDensity": 0.0721})
SetBeam(ws, Geometry={'Shape': 'Slit', 'Width': 100.0, 'Height': 200.0})
abs = PaalmanPingsAbsorptionCorrection(ws)
for a in ["ass", "assc", "acc", "acsc"]:
print("{:4} {:.4f}(θ=10) {:.4f}(θ=90) {:.4f}(θ=170) {:.4f}(θ=90,φ=45)".format(a, *(mtd["abs_"+a].readY(i)[0] for i in range(4)))) Here, you can see that I was using a huge beam size. The thing is, when the beam size is larger than the sample size in every dimension, the calculation result should be the same as for the case where we don't have the beam size defined at all. However, the result created above is not the same as with the script in which I commented out the I am suspecting this may be something to do with the integration volume setting for sample and container. Maybe we were missing the intersecting volume setting for the container? |
@Kvieta1990 I made an update that should fix the issue you are seeing with the beam illuminating the whole sample not giving the same result. |
Thank you! I will grab the change and do the test. |
I check the latest push and now having a super big beam size does create consistent outputs compared to the no beam defined case. Thank you! I have another thing. When setting the beam size to be, SetBeam(ws, Geometry={'Shape': 'Slit', 'Width': 1.0, 'Height': 2.0}) I got the output like this,
Compared to the no beam defined situation (i.e., assuming the whole sample exposed to the beam), the difference seems to be a bit too large to me. I don't have a good expectation based on a solid physics ground, since the evaluation of the coefficients involves a normalization over the integration volume and as we reduce the integration volume size, the value on the top gets smaller but the normalization factor at the bottom also gets smaller (see the Eqn. (8) here). But the observed difference being so big makes me wonder whether we do the normalization correctly here. If I look at the codes here, I found the division is done over the sample volume (from the variable used there We can discuss about this further. Unfortunately I have a full morning event tomorrow so I cannot go to the status meeting. But I will be free in the afternoon. So if you want to discuss, I can try to tune in later tomorrow. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finished with the "non test code" part of the code review. There are only a few minor things that I found. I'll go over the test code, and actually build it and run the tests early tomorrow.
Framework/Algorithms/inc/MantidAlgorithms/PaalmanPingsAbsorptionCorrection.h
Show resolved
Hide resolved
Framework/Algorithms/inc/MantidAlgorithms/PaalmanPingsAbsorptionCorrection.h
Show resolved
Hide resolved
@searscr I am wondering your thoughts about my very last comment about the volume normalization? Please feel free to let me know if you want to discuss. Thank you! |
@Kvieta1990 Here we are setting the "sample volume" to the calculated volume from the |
I am not sure actually. When I see For example, we can do a little test to print out the |
@Kvieta1990 You were right, I had the sample and the integration volume backwards in the function to calculate the Raster volume so it was using the full sample size. I have updated the algorithm and now running the same test you ran before with SetBeam(ws, Geometry={'Shape': 'Slit', 'Width': 1.0, 'Height': 2.0}) The result is
compared to the full sample
Does that look more correct? |
That looks more reasonable! Thank you so much @searscr! I will check later today to see whether I have more comments and I will let you know. |
45333f4
to
7a65c5e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I built the code and ran through all of the tests as described (, including the details in the discussion with the CIS about what's supposed to happen when the beam profile is larger than the sample). I am happy with the quality of the changes, and as far as I can tell, everything is working as expected.
@searscr Sorry for the delayed response. I did check the PR, running the tests we did before and it seems to be all fine. Thank you so much! |
👋 Hi, @searscr, Conflicts have been detected against the base branch. Please rebase your branch against the base branch. |
8ed8dab
to
d2e1fdb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-approved after rebase.
* Update BeamProfileFactory * Make requested changes * Swapped integration volume and sample object when doing Rasterize::calculate() * Update PaalmanPings * cppCheck and release notes * fix whole sample illuminated by beam * fix cppcheck * address review comments * fix cppcheck * correct Raster::Calculate call * fix cppcheck * add comment for V3D comparison * remove unused variable --------- Co-authored-by: Daniel Caballero <dlcaballero16@gmail.com>
* Update BeamProfileFactory * Make requested changes * Swapped integration volume and sample object when doing Rasterize::calculate() * Update PaalmanPings * cppCheck and release notes * fix whole sample illuminated by beam * fix cppcheck * address review comments * fix cppcheck * correct Raster::Calculate call * fix cppcheck * add comment for V3D comparison * remove unused variable --------- Co-authored-by: Daniel Caballero <dlcaballero16@gmail.com>
* Update BeamProfileFactory (#39135) * Update BeamProfileFactory * Make requested changes * Add Gauge Volume to Monte Carlo Absorption (#39158) * optional gauge volume passed to interaction vol * added initial test that nothing has broken and gv is used * ensure point generated in gauge vol * adjust sptr behaviour and scoped variables * updated mc-strategy tests * now check gv point in sample + added tests * fixed cylinder orientation in test * added release note * amended so gauge volume overrides active region * made scattering sample only when gv and updated docs * changed information to conditional warning * fix cpp check? * fix incorrect virtual method construction * fix new cppcheck fail * create factory init * fix docs warning * revert number of samples to 1 as changes powder references * added comments explaining 'create' change * add bullet point to release note * add nodiscard and compact setActiveRegion * move nodiscard before virtual * warn to check gauge vol if attempts fail * AnyShapeAbsorption uses beam description to determine volume (#39208) * Update BeamProfileFactory * Make requested changes * Added use of IBeamProfile in AnyShapeAbsorption as an option to determine gauge volume. Updated getIntersectionWithSample in IBeamProfile to not need beam direction. Added unit test for AnyShapeAbsorption * Swapped integration volume and sample object when doing Rasterize::calculate() * Fixed IBeamProfileTest * Added release notes * Fixed release notes * Updated function comment * Addressed PR comments * Undid change making raster object const ref * Address PR comments * Undid small change --------- Co-authored-by: Carson Sears <searscr@ornl.gov> * Update Absorption Concept Page (#39232) * Update Absorption Concept Page * update doc * Update PaalmanPingsAbsorptionCorrection (#39210) * Update BeamProfileFactory * Make requested changes * Swapped integration volume and sample object when doing Rasterize::calculate() * Update PaalmanPings * cppCheck and release notes * fix whole sample illuminated by beam * fix cppcheck * address review comments * fix cppcheck * correct Raster::Calculate call * fix cppcheck * add comment for V3D comparison * remove unused variable --------- Co-authored-by: Daniel Caballero <dlcaballero16@gmail.com> --------- Co-authored-by: andy-bridger <71634246+andy-bridger@users.noreply.github.com> Co-authored-by: Daniel Caballero <132241327+dlcaballero16@users.noreply.github.com> Co-authored-by: Daniel Caballero <dlcaballero16@gmail.com>
Description of work
Do not merge before #39208
Updates
PaalmanPingsAbsorptionCorrection
to determine theGaugeVolume
from the beam parameters provided fromSetBeam
. The following priority will be used to determine the integration volume for L1 distances:DefineGaugeVolume
or setting aGaugeVolume
property for the workspace with a valid XML string defining shape.SetBeam
to find the intersection with the beam properties and the sample/container shapeSummary of work
#39135 Created the functionality to get the intersection volume of the beam and the sample shape. This updates
PaalmanPingsAbsorptionCorrection
to use the new functionality to provide another method of determining theGaugeVolume
.Relates to EWM 10071
Story Summary:
modify the function and add in tests to demonstrate that it works. The tests are defined in the epic/parent story.
The gauge volume will be determined by the first one of the following that exists:
Further detail of work
To test:
Reviewer
Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.
Code Review
Functional Tests
Does everything look good? Mark the review as Approve. A member of
@mantidproject/gatekeepers
will take care of it.Gatekeeper
If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.