fusion-energy / openmc-plasma-source

Creates a plasma source as an openmc.source object from input parameters that describe the plasma
MIT License
25 stars 11 forks source link

Improved energy distribution using NeSST #89

Open shimwell opened 6 months ago

shimwell commented 6 months ago

This PR is an attempt to make use of NeSST to define the neutron spectra. Closes #88

I have a bit more work to do before it is ready, for example I'm going to see if I can combined the Muir spectra for DD and DT neutrons with the openmc.stats.Discrete distribution for the TT neutrons.

going to try combining with this

shimwell commented 4 months ago

This PR has turned into a bit of a big refactoring, sorry for the large diff

On the plus side it does now solve #80 and #37 and touches on addressing Liams comments in #47

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 97.19626% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 95.74%. Comparing base (64e4aa1) to head (bbdb65c). Report is 6 commits behind head on main.

:exclamation: Current head bbdb65c differs from pull request most recent head e860a74. Consider uploading reports for the commit e860a74 to get more accurate results

Files Patch % Lines
src/openmc_plasma_source/fuel_types.py 95.12% 4 Missing :warning:
src/openmc_plasma_source/__init__.py 83.33% 1 Missing :warning:
src/openmc_plasma_source/tokamak_source.py 98.75% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #89 +/- ## ========================================== - Coverage 95.96% 95.74% -0.23% ========================================== Files 7 5 -2 Lines 347 235 -112 ========================================== - Hits 333 225 -108 + Misses 14 10 -4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

shimwell commented 4 months ago

tests are passing locally and on CI the examples are running locally and on CI

only missing code coverage now

shimwell commented 4 months ago

This PR is currently reducing the package by a reasonable amount of lines of code while also adding functionality.

I've redone the checking of values so that it is more concise as mentioned by @RemDelaporteMathurin

I'm keen to see if this issue can be fixed before we bring in nesst as a dependency

shimwell commented 4 months ago

I just noticed another part of the code that will need changing to support DD and DT reactions. It looks like this part is only considering DT reactions

https://github.com/fusion-energy/openmc-plasma-source/blob/64e4aa13f1e81efb8d0e16d7b76acb40bacce468/src/openmc_plasma_source/tokamak_source.py#L416

So we might need to add DD reactions

Also I guess the ion_density for DD pairs is also half that of DT pairs

@RemDelaporteMathurin do you remember why this is ion_density**2 here in the code?