Skip to content

More accurately simulate the neutron flux profile - #3653

Open
OceanNuclear wants to merge 143 commits into
mainfrom
neutronics
Open

More accurately simulate the neutron flux profile#3653
OceanNuclear wants to merge 143 commits into
mainfrom
neutronics

Conversation

@OceanNuclear

@OceanNuclear OceanNuclear commented May 2, 2025

Copy link
Copy Markdown
Contributor

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

codecov-commenter commented May 2, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.64929% with 349 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.23%. Comparing base (771e4d2) to head (7a08d64).
⚠️ Report is 286 commits behind head on main.

Files with missing lines Patch % Lines
process/models/neutronics/base.py 53.99% 219 Missing ⚠️
process/models/neutronics/data.py 64.28% 130 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3653      +/-   ##
==========================================
+ Coverage   47.81%   50.23%   +2.41%     
==========================================
  Files         143      154      +11     
  Lines       29993    30750     +757     
==========================================
+ Hits        14342    15447    +1105     
+ Misses      15651    15303     -348     

☔ View full report in Codecov by Harness.
📢 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

OceanNuclear commented Nov 24, 2025

Copy link
Copy Markdown
Contributor Author

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

@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

@je-cook je-cook left a comment

Copy link
Copy Markdown
Collaborator

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

je-cook commented Apr 1, 2026

Copy link
Copy Markdown
Collaborator

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

OceanNuclear commented Apr 1, 2026

Copy link
Copy Markdown
Contributor Author

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.

@OceanNuclear

Copy link
Copy Markdown
Contributor Author

Listing all of the methods available under the NeutronProfile class (for my own use/sanity):

Continuous range of values per layer:

Quantity methods (manually select layer) methods (automatically select layer) units
Neutron flux (groupwise_)neutron_flux_in_layer (groupwise_)neutron_flux_at $m^{-2} s^{-1}$
Neutron current (groupwise_)neutron_current_in_layer (groupwise_)neutron_current_at $m^{-2} s^{-1}$
Heating (groupwise_)neutron_heating_in_layer (groupwise_)neutron_heating_at $W m^{-3} $
Tritium production (groupwise_)tritium_production_in_layer (groupwise_)tritium_production_at mole $m^{-3}$

One value per layer:

Quantity method(s) unit
Neutron flux (groupwise_)integrated_flux_in_layer $m^{-2} s^{-1}$
Neutron current (groupwise_)neutron_current_through_interface/(groupwise_)neutron_current_escaped $m^{-2} s^{-1}$
Heating (groupwise_)integrated_heating_in_layer $W m^{-2}$
Tritium production (groupwise_)integrated_tritium_production_in_layer mole $m^{-2} s^{-1}$
linear heating density groupwise_linear_heating_density_in_layer $J m^{-1}$

This gives a total of 27 available methods.

Comment on lines +174 to +179
class AutoPopulatingDict:
"""
Class that behaves like a dictionary, but if the required key does not
exist in the dictionary, it will call the populating_method to populate
that specific key.
"""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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