Skip to content

More accurately simulate the neutron flux profile#3653

Open
OceanNuclear wants to merge 127 commits intomainfrom
neutronics
Open

More accurately simulate the neutron flux profile#3653
OceanNuclear wants to merge 127 commits intomainfrom
neutronics

Conversation

@OceanNuclear
Copy link
Copy Markdown
Contributor

@OceanNuclear OceanNuclear commented May 2, 2025

Description

Calculates the neutron flux profile in the first wall and blanket, using an extremely simplified diffusion-based model of an infinite slab sandwich.

Reason for choosing this model

It's better than not having a neutronics model.
It's also very simplified, so it can be calculated on the fly, without installing any deterministic neutron transport codes as dependency.

Checklist

I confirm that I have completed the following checks:

  • My changes follow the PROCESS style guide
  • I have justified any large differences in the regression tests caused by this pull request in the comments.
  • I have added new tests where appropriate for the changes I have made.
  • If I have had to change any existing unit or integration tests, I have justified this change in the pull request comments.
  • If I have made documentation changes, I have checked they render correctly.
  • I have added documentation for my change, if appropriate.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 2, 2025

Codecov Report

❌ Patch coverage is 58.38509% with 335 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.24%. Comparing base (771e4d2) to head (7a2b943).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
process/models/neutronics/base.py 63.32% 172 Missing ⚠️
process/models/neutronics/data.py 51.48% 163 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3653      +/-   ##
==========================================
+ Coverage   47.81%   48.24%   +0.42%     
==========================================
  Files         143      145       +2     
  Lines       29993    30930     +937     
==========================================
+ Hits        14342    14921     +579     
- Misses      15651    16009     +358     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@OceanNuclear OceanNuclear requested a review from chris-ashe May 2, 2025 21:04
@chris-ashe chris-ashe added Physics Relating to the physics models Neutronics Power Cycle and removed Physics Relating to the physics models labels May 6, 2025
@OceanNuclear OceanNuclear force-pushed the neutronics branch 2 times, most recently from a7c3d81 to 56884d7 Compare June 4, 2025 15:47
@OceanNuclear OceanNuclear changed the title First commit - made a mockup of NeutronFluxProfile calculator. More accurately simulate the neutron flux profile, to get a more accurate estimate of the neutronics quantities. Jun 4, 2025
@OceanNuclear OceanNuclear changed the title More accurately simulate the neutron flux profile, to get a more accurate estimate of the neutronics quantities. More accurately simulate the neutron flux profile Jun 4, 2025
@OceanNuclear OceanNuclear force-pushed the neutronics branch 3 times, most recently from 5ada3ea to 3336c23 Compare October 30, 2025 15:13
@OceanNuclear
Copy link
Copy Markdown
Contributor Author

OceanNuclear commented Nov 24, 2025

The current state of this branch is:

  • 1-group 2-layer model is written
  • 1-group 2-layer model is fully tested (regression & unit tests)
  • Multi-group model & >2-layer model is written
  • Multi-group model & >2-layer model is tested
  • incorporated real data
  • Wrote function that accepts collapsed cross-section data (The downloading and collapsing of nuclear data has to be done by the user using a class that inherits from ENDFRecord.)
  • Plotting is already available, example 1-group 2-layer model:
current flux heating
  • Plotting is tested

…r message, leaving the instructions on how to perform iteration calculations in the comments.
… created without knowing the nuclear data first, *and then* knowing what isotopes' nculear data needs to be get, populate_from_nuclear_data_library() can then help backfill these values, long after the instantiation of these materials.
…_set when raising the RuntimeError for missing isotopes in the nuclear data library.
@OceanNuclear OceanNuclear marked this pull request as ready for review March 27, 2026 13:41
@OceanNuclear OceanNuclear requested a review from a team as a code owner March 27, 2026 13:41
@OceanNuclear
Copy link
Copy Markdown
Contributor Author

@chris-ashe In the new folder structure, would you prefer the neutronics.py and neutronics_data.py to live in model/ or core/?

@je-cook je-cook self-assigned this Apr 1, 2026
Copy link
Copy Markdown
Collaborator

@je-cook je-cook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure descriptors is the right way to go. Most descriptor stuff I've written I have eventually rewritten without descriptors because I found a better way.

On the atomic data is there any reason we cant use something like periodictable which we use in elsewhere.

@OceanNuclear
Copy link
Copy Markdown
Contributor Author

Happy to hear out examples of where descriptors were removed and see if I can implement anything similar. So far I'm unaware of any other ways of writing the code that wouldn't make it even more spaghetti: the @summarize_values decorator is doing a lot of heavy lifting and cutting the amount of code that I have to write down by half.

@je-cook
Copy link
Copy Markdown
Collaborator

je-cook commented Apr 1, 2026

Great, need to have a think but will let you know

@OceanNuclear
Copy link
Copy Markdown
Contributor Author

periodictable sounds good, thanks for the suggestion, I'll likely replace the atomic_data.json with it, and possibly cutting down the size of the PR as a result.

I haven't figured out yet the right way of getting the abundance values in periodictable (in the same format as written at the top of the atomic_data.json), but I'm sure I'll find it eventually.

@OceanNuclear
Copy link
Copy Markdown
Contributor Author

OceanNuclear commented Apr 1, 2026

I'll add a bit of context for your consideration while thinking about refactoring away the descriptors:

Regarding the @summarize_values decorators, I think they can be improved upon as well, for the following reasons:

  1. I observed redundancy. The NeutronFluxProfile class has the following list of ..._in_layer() methods:
  • groupwise_neutron_flux_in_layer
  • groupwise_neutron_current_in_layer
  • groupwise_neutron_heating_in_layer
  • groupwise_tritium_production_in_layer
    and it also has the following list of ..._in_layer() methods, which simply chooses the correct layer according to the x value:
  • groupwise_neutron_flux_at
  • groupwise_neutron_current_at
  • groupwise_neutron_heating_at
  • groupwise_tritium_production_at
    This suggest that there's definitely duplicated code that can be abstracted away.
  1. I'm unhappy with the signature of the _in_layer methods:
  • Current signature: (self, n: int, num_layer: int, x: float | npt.NDArray)
  • Preferred signature: (self, num_layer: int, n: int, x: float | npt.NDArray), which aligns with the indexing order of the coefficients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants