-
Notifications
You must be signed in to change notification settings - Fork 126
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
Abins: improve handling of isotopic cross-sections #38448
Conversation
This isotope currently gives a NaN cross-section. We should ensure that unsupported isotopes give a noisy error instead.
Currently Abins identifies if the mass is a standard isotopic mixture by comparing against In the case of zinc, the standard mass has been revised by a difference of more than 0.01, so CASTEP writes mass values that are not detected by Abins as being the standard. A more robust workflow could look at which is nearest between the standard mass and another known isotope. I have found a quirk in the
Mass values that are too high raise an error, but masses that are too low do not! |
- remove "substitution" logic branch - instead delegate isotope detection and workspace naming to a new class - in this commit a new Atom is still (unnecessarily) spawned to get cross-section
We can now pass on the AtomInfo object rather than its consitituent data.
In cases such as F, one isotope is so dominant that essentially we would always use the properties of the standard mixture. Oddly, in this case Mantid will not find neutron data if the atomic mass was provided. i.e. Atom('F').neutron() works, but Atom('F', 19).neutron() returns a dict full of NaN, despite them having exactly the same mass.
Abins input files usually give the element symbol and mass. These masses often do not match exactly to those in Mantid's data. - In the case that the nearest isotope has no data, but the "mixture" is _quite_ near the target mass (0.01 amu, for now), log a warning and use the mixture. This helps handle nasty cases like 127I where Mantid has _slightly_ different masses for the pure isotope and mixture, but essentially it is a 100% mixture and there is no neutron-scattering data for the isolated isotope. - If the nearest isotope has no data and the standard mixture is too far away, raise an error.
For an example of a really nasty case that requires some logic to get through:
To resolve this, we
|
The error is now raised by the data class when we try to access a property that uses Atom. As such it is not really a get_cross_section test any more and can be moved out.
The docs failure might be connected to
but I'm not sure what to do about that. The pre-commit hooks will not let me append another newline to the release note! |
Thanks @robertapplin for figuring out the docs formatting 🎉 |
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.
The changes are sensible and adding the atominfo dataclass handles better edge cases and also simplifies the code in some parts. Additionally, test cases are added.
I have very small comments but otherwise looks fine to me.
Co-authored-by: Adri Diaz <[email protected]>
This gets rid of a hard-coded epsilon. Strictly these two comparisons are not quite doing the same thing, but this precision should be good for both.
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.
Thanks for addressing my comments.
This is a squashed version of mantidproject#38448 Create failing test: Abins get_cross_section for Zn65 This isotope currently gives a NaN cross-section. We should ensure that unsupported isotopes give a noisy error instead. Implement ValueError for NaN cross-section data Fix missing return value, test good cases Begin refactoring Abins isotope handling - remove "substitution" logic branch - instead delegate isotope detection and workspace naming to a new class - in this commit a new Atom is still (unnecessarily) spawned to get cross-section Continue refactor: streamline _create_workspace We can now pass on the AtomInfo object rather than its consitituent data. Continue refactor: move AtomInfo into _fill_s_workspace methods Simplify get_cross_section from an established AtomInfo Handle neutron data for atoms where one isotope = mixture In cases such as F, one isotope is so dominant that essentially we would always use the properties of the standard mixture. Oddly, in this case Mantid will not find neutron data if the atomic mass was provided. i.e. Atom('F').neutron() works, but Atom('F', 19).neutron() returns a dict full of NaN, despite them having exactly the same mass. Update Abins2D to use AtomInfo class Handle some more Abins isotope challenging cases Abins input files usually give the element symbol and mass. These masses often do not match exactly to those in Mantid's data. - In the case that the nearest isotope has no data, but the "mixture" is _quite_ near the target mass (0.01 amu, for now), log a warning and use the mixture. This helps handle nasty cases like 127I where Mantid has _slightly_ different masses for the pure isotope and mixture, but essentially it is a 100% mixture and there is no neutron-scattering data for the isolated isotope. - If the nearest isotope has no data and the standard mixture is too far away, raise an error. Direct unit test for AtomInfo Test refactor: move error check closer to source The error is now raised by the data class when we try to access a property that uses Atom. As such it is not really a get_cross_section test any more and can be moved out. Add release note Tweak release note format Update scripts/abins/abinsalgorithm.py Co-authored-by: Adri Diaz <[email protected]> Move AtomInfo to separate file Tighten epsilon for "same" mass values, re-use in atominfo This gets rid of a hard-coded epsilon. Strictly these two comparisons are not quite doing the same thing, but this precision should be good for both.
Description of work
Summary of work
Purpose of work
Primary issue:
Unstable isotopes such as Zn65 currently give a NaN cross-section. We should ensure that unsupported isotopes give a noisy error instead.
Secondary issue:
We are seeing Zn65 because data with mass 65.39 is being inappropriately rounded to this exotic isotope, rather than identified as being the standard isotopic mixture. Such cases should be detected more robustly.
Fixes #37735
Report to: Jeff Armstrong
Further detail of work
To test:
The changes are covered by unit tests and system tests
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.