Material refactor plus integration tests#17
Merged
shawest merged 8 commits intoshawest:masterfrom Feb 12, 2026
Merged
Conversation
This pull request moves functionality for creating materials and calculating stopping power into neucbot/material.py. As part of this refactoring, the stopping power calculations now use binary search (using bisect.bisect) rather than sequential search for faster computations on average (logarithmic time rather than linear time).
As some of the implementation details for neucBOT change under the hood (e.g. the use of binary search rather than sequential searching), there needs to be a comprehensive way beyond unit tests to ensure that no regressions are introduced. To do this, outputs files were generated for the following three commands on the current master branch: $ python3 ./neucbot.py -m Materials/Acrylic.dat -c Chains/Th232Chain.dat $ python3 ./neucbot.py -m Materials/Acrylic.dat -l AlphaLists/Rn220Alphas.dat $ python3 ./neucbot.py -m Materials/Acrylic.dat -l AlphaLists/Bi212Alphas.dat These output files will serve as integration tests. As more neucBOT refactoring and enhancements occur, they should not change the expected outputs of these commands. In a subsequent commit, these tests will be required to pass in all Github PRs before merging.
88869a4 to
8cc6c75
Compare
mpiercy827
commented
Feb 2, 2026
mpiercy827
commented
Feb 2, 2026
The stopping power calculation for a material at a given alpha energy level was incorrectly copied/modified when being moved from neucbot.py to neucbot/material.py, and this was caught by the integration tests added in an earlier commit. The unit tests have been modified accordingly and the integration tests are almost passing, they are off by ~1e-16.
The commit populates stopping power lists when a MaterialComposition is created so that they don't have to be recreated/recalculated for every alpha energy step (which is the current implementation).
mpiercy827
commented
Feb 4, 2026
This commit normalizes the abundance of an isotope between 0 and 1 in the element.abundance() function, and ensures that isotope fractions in a MaterialComposition object are also between 0 and 1. The only diffs present in the integration tests at this point are due to floating point precision limitations and can likely be ignored.
and reflect the current state of the code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request factors material-related code (including the calculation of stopping powers) into its own
neucbot/material.pyfile, and also adds integration tests to ensure that any change in functionality does not impact the expected output of neucBOT.More details can be found in the commit messages.