8000 :3260 update the fusion reactions section of the plasma docs to full account for all models and details by chris-ashe · Pull Request #3345 · ukaea/PROCESS · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

:3260 update the fusion reactions section of the plasma docs to full account for all models and details #3345

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

Conversation

chris-ashe
Copy link
Collaborator
@chris-ashe chris-ashe commented Oct 9, 2024

This pull request includes multiple changes across various documentation files and source code to improve the clarity and accuracy of the fusion reaction models and related constants. The most important changes include renaming variables for consistency, adding detailed documentation for fusion reaction methods, and updating references to reflect these changes.

Documentation Enhancements:

Navigation and Organization:

  • mkdocs.yml: Updated the navigation structure to include a more detailed breakdown of fusion reactions, separating the overview and Bosch-Hale methods.

Bugs 🐛

  • The value for the mass of deuterium (ATOMIC_MASS_DEUTERIUM) and tritium (ATOMIC_MASS_TRITIUM) in atomic mass units was in correctly given and then multiplied by the mass of the proton instead of the atomic mass unit value in physics_functions.py.

  • One of the term values in beam_energy_to_ions() used an approximate value which is now calculated directly

  • The _hot_beam_fusion_reaction_rate_integrand() was using proton mass instead of atomic mass unit

  • The normalised density for the fusion rate integral in fusion_rate_integral() was normalising to the volume averaged electron density instead of the ion density.

New features

  • The fusion energies and reaction product energy branching ratios have been enhanced with more precise variables and are
    calculated implicitly.
  • New updated output for more detail:

Old

image

New

image

Code cleanup and test updates ♻️ :

  • Many functions and classes now have expanded docstrings and type hints. Along with renaming internal variables to be explicitly descriptive.
  • OUT.DAT and variable name widths have been widened to allow for more variable name space and labels
  • set_fusion_powers() has now had the fast alpha beta component calculation removed and placed into a new function of fast_alpha_beta()
  • New deuterium_branching() function

Namespace changes

Constants

  • Several constants in constants.f90 have been made more verbose. Sadly they have not been able to be put into all uppercase form to be more Pythonic (PEP8).This is due to a parsing problem with f2py. The values have also been made more precise by taking values from NIST (https://physics.nist.gov/cuu/Constants/index.html). Comments are now also above the constants with link references to their values.
    Some changes below are:

    • Name: emass -> electron_mass; Value: 9.10938370D-31 -> 9.1093837139D-31. This new value has been applied to explicitly written floats in cfnbi() and eccdef(). This has been updated in the docs also
    • Name: pmass -> proton_mass; Value: 1.6726231D-27 -> 1.67262192595D-27.
    • Name: echarge -> electron_charge; Value 1.60217733D-19 -> 1.602176634D-19.

New additions:

  • deuteron_mass, triton_mass, neutro 8000 n_mass, alpha_mass, helion_mass. speed_light

  • electron_volt: This new value has been applied to explicitly written floats in eccdef(), acc2272(). This has been updated in the docs also. This has been added to be more syntactically correct when working with energy units instead of just calling

  • kiloelectron_volt: This has been added as a lot of conversions would previously multiply by 1000.0 across the code. This should increase readability.

  • atomic_mass_unit: Lots of functions are calling different fundamental mass values that are close but not technically correct, this is added to correct these errors.

  • electron_charge

  • d_t_energy, d_helium_energy, dd_helium_energy, dd_triton_energy. These are the reaction energy constants and are calculated implicitly from the mass differences of products and reactants

  • dt_alpha_energy. This is created to compliment the removal of ealphadt from the variables list

  • dt_neutron_energy_fraction, dd_neutron_energy_fraction, dd_proton_energy_fraction, dhelium_proton_energy_fraction. These are the calculated fractions my mass difference of the shared reaction energy between the fusion products.

  • alpha_power_plasma: This is a new output file variable to differentiate between the alpha power from the plasma and that from beams.

  • neutron_power_plasma: This is a new output file variable to differentiate between the neutron power from the plasma and that from beams.

  • neutron_power_beams: This is a new output file variable to differentiate between the neutron power from the plasma and that from beams.

  • fusion_rate_density_plasma

  • fusion_rate_density_total

  • alpha_rate_density_total

  • alpha_rate_desnty_plasma

  • dt_power_total

  • dt_power_plasma

  • f_dd_branching_trit

Functions

Re-named to be more descriptive about what the function does

  • bosch_hale() -> bosch_hale_reactivity()
  • fint() -> fusion_rate_integral()
  • dt() -> dt_reaction()
  • dhe3() -> dhe3_reaction()
  • dd1() -> dd_helion_reaction()
  • dd2() -> dd_triton_reaction()
  • palphabm() -> alpha_power_plasma()
  • xbrak() -> _fast_ion_pressure_integral()
  • sgvhot() -> beam_reaction_rate()
  • _sigbmfus() -> _beam_fusion_cross_section()
  • palph2() -> set_fusion_powers()
  • beamfus() -> beam_fusion()

Variables

A handful of variables are not quite descriptive/explicit enough in their naming and tend to lead to misinterpretation if it presents a per unit volume or a total value. Thus the following internal variables have been changed:

  • palppv -> alpha_power_density

  • pchargepv ->charged_power_density

  • pneutpv -> neutron_power_density

  • fusionrate -> fusion_rate_density

  • alpharate -> alpha_rate_density

  • protonrate -> proton_rate_density

  • pddpv -> dd_power_density

  • pdtpv -> dt_power_density

  • pdhepv -> dhe3_power_density

  • sigvdt -> sigmav_dt_average

  • pdt -> dt_power

  • pdhe3 -> dhe3_power

  • pdd -> dd_power

  • palpnb -> alpha_power_beams

  • palpmw -> alpha_power_total

  • pneutmw -> neutron_power_total

  • pchargemw -> non_alpha_charged_power. This was a misleading name as it doesn't account for alphas so was re-named

  • pfuscmw -> charged_particle_power: This is a new output file variable which is now added to physics_variables.f90 It was output by palph2() but was never written to output. It now is.

  • palpipv -> alpha_power_ion_density`. This variable has now also been added to the output

  • palpepv -> alpha_power_electron_density`. This variable has now also been added to the output

  • cnbeam -> beam_current

  • enbeam -> beam_energy

  • ftritbm -> f_tritium_beam

  • betanb -> beta_beam

  • dnbeam2 -> beam_density_out - To better clarify that this is the beam density produced by code output and is not from the input. Also to remove a variable name with a number at the end.

  • falpe -> f_alpha_electron

  • falpi -> f_alpha_ion

  • fdeut -> f_deuterium

  • f_trit -> f_tritium

  • fhe3 -> f_helium3

  • vol -> plasma_volume. This was changed due to conflicting understanding depending on the context of the module and to make it easier to search and find.

  • powfmw -> fusion_power

  • falpha -> f_alpha_plasma. Docs section created showing origin of default value.

Removals

  • ealphadt. Removed as it was a constants value, though down as an input variable. Replaced by dt_alpha_energy constant.

Checklist

I confirm that I have completed the following checks:

  • 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.

@chris-ashe chris-ashe added Documentation Improvements or additions to documentation Physics Relating to the physics models labels Oct 9, 2024
@chris-ashe chris-ashe self-assigned this Oct 9, 2024
@codecov-commenter
Copy link
codecov-commenter commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 40.41916% with 199 lines in your changes missing coverage. Please review.

Project coverage is 27.30%. Comparing base (b98d5ed) to head (01fa171).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
process/physics_functions.py 55.55% 84 Missing ⚠️
process/physics.py 22.95% 47 Missing ⚠️
process/stellarator.py 3.57% 27 Missing ⚠️
process/io/sankey_funcs.py 0.00% 17 Missing ⚠️
process/current_drive.py 23.07% 10 Missing ⚠️
process/io/plot_proc.py 0.00% 4 Missing ⚠️
process/plasma_geometry.py 0.00% 3 Missing ⚠️
process/hcpb.py 33.33% 2 Missing ⚠️
process/dcll.py 50.00% 1 Missing ⚠️
process/evaluators.py 0.00% 1 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3345      +/-   ##
==========================================
+ Coverage   27.20%   27.30%   +0.10%     
==========================================
  Files          76       77       +1     
  Lines       17779    17955     +176     
==========================================
+ Hits         4837     4903      +66     
- Misses      12942    13052     +110     

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

The commit updates the electron mass constant in multiple files to use the more accurate value provided by the NIST. This ensures that calculations involving the electron mass are more precise. Explicitly written float values has now also been set to this variable
@chris-ashe chris-ashe changed the title 3260 update the fusion reactions section of the plasma docs to full account for all models and details 🚧 3260 update the fusion reactions section of the plasma docs to full account for all models and details Oct 9, 2024
The commit updates the proton mass constant in multiple files to use the more accurate value provided by the NIST. This ensures that calculations involving the electron mass are more precise. Variable name has been changed from pmass to PROTON_MASS
…nd helion mass. Fix broken links for the electron and proton mass
…the-plasma-docs-to-full-account-for-all-models-and-details
… variable for electron_volt

The commit updates the electron mass constant in multiple files to use the more accurate value provided by the NIST. This ensures that calculations involving the electron mass are more precise. Variable name has been changed from emass to electron_mass
This commit adds new constants for the energy fractions carried by neutrons and protons in various fusion reactions. These constants are used to calculate the energy released in fusion reactions involving deuterium, tritium, helium-3, and protons. The energy fractions are calculated assuming a non-relativistic center of mass frame.

The following constants have been added:
- dt_neutron_energy_fraction: Energy fraction carried by neutron in deuterium-tritium reaction
- dd_neutron_energy_fraction: Energy fraction carried by neutron in deuterium-deuterium (helium-3 producing) reaction
- dd_proton_energy_fraction: Energy fraction carried by proton in deuterium-deuterium (triton producing) reaction
- dhelium_proton_energy_fraction: Energy fraction carried by proton in deuterium-helion (helium-3) reaction

These constants will be used in further calculations related to fusion reactions.
- Renamed `alpharate` variable to `alpha_rate_density` for clarity and consistency.
@chris-ashe chris-ashe force-pushed the 3260-update-the-fusion-reactions-section-of-the-plasma-docs-to-full-account-for-all-models-and-details branch from a30b5d1 to 61f1056 Compare October 31, 2024 09:53
@chris-ashe chris-ashe marked this pull request as ready for review November 4, 2024 10:18
@chris-ashe chris-ashe removed the request for review from j-a-foster November 4, 2024 10:18
@chris-ashe chris-ashe changed the title 🚧 3260 update the fusion reactions section of the plasma docs to full account for all models and details :3260 update the fusion reactions section of the plasma docs to full account for all models and details Nov 4, 2024
@chris-ashe chris-ashe force-pushed the 3260-update-the-fusion-reactions-section-of-the-plasma-docs-to-full-account-for-all-models-and-details branch from d6774d1 to a7b7587 Compare November 5, 2024 14:44
@chris-ashe chris-ashe force-pushed the 3260-update-the-fusion-reactions-section-of-the-plasma-docs-to-full-account-for-all-models-and-details branch from 3234d63 to 15c42a1 Compare November 6, 2024 09:55
@timothy-nunn
Copy link
Contributor

Can I request a review from @ajpearcey or @stuartmuldrew to confirm they are happy with variable name changes

@timothy-nunn
Copy link
Contributor

@je-cook FYI variable name changes that might cause problems in bluemira before you switch to our new release

Copy link
Contributor
@timothy-nunn timothy-nunn left a comment

Choose a reason for hiding this comment

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

Code looks fine. Alex or Jonny need to review the branching for physical validity.
Changes in the regression tests appear minor but, again, Alex or Jonny need agree.
Variable name changes need to be approved by Alex

Only one point about moving atomic masses of tritium and deuterium into the constants file?

Comment on lines +12 to +16
# https://physics.nist.gov/cgi-bin/cuu/Value?mdu|search_for=deuteron
ATOMIC_MASS_DEUTERIUM = 2.013553212544

# https://physics.nist.gov/cgi-bin/cuu/Value?mtu|search_for=triton
ATOMIC_MASS_TRITIUM = 3.01550071597
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth moving to constants.f90?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can leave out for now, will get swept out when another bit of the code needs to use the values

Copy link
Collaborator
@kj5248 kj5248 left a comment

Choose a reason for hiding this comment

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

Doc changes all look good to me now

Copy link
Collaborator
@ajpearcey ajpearcey left a comment

Choose a reason for hiding this comment

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

There are no issues with the variable name changes and branching ratio.

We could maybe have a discussion to write down a style guide for variable name to add to the docs.

Also ref: @je-cook these name changes may cause issues with Bluemira/process interactions.

@je-cook
Copy link
Collaborator
je-cook commented Nov 7, 2024

see Fusion-Power-Plant-Framework/bluemira#3636 for changes because of this

@timothy-nunn timothy-nunn merged commit 42780a9 into main Nov 7, 2024
14 of 18 checks passed
@timothy-nunn timothy-nunn deleted the 3260-update-the-fusion-reactions-section-of-the-plasma-docs-to-full-account-for-all-models-and-details branch November 7, 2024 16:11
chris-ashe added a commit that referenced this pull request Nov 8, 2024
…account for all models and details (#3345)

* refactor: Update Fusion Reactions navigation structure

* Fix some variable names for clairty

* Convert physics functions to Python

* Add new duterium_branching() function from Bosch-Hale to calculate the difference in D-D reactions

* Update electron mass constant to use the more accurate value

The commit updates the electron mass constant in multiple files to use the more accurate value provided by the NIST. This ensures that calculations involving the electron mass are more precise. Explicitly written float values has now also been set to this variable

* Update proton mass constant to use the more accurate value

The commit updates the proton mass constant in multiple files to use the more accurate value provided by the NIST. This ensures that calculations involving the electron mass are more precise. Variable name has been changed from pmass to PROTON_MASS

* Add new constants for the deuteron, triton, neutron, alpha particle and helion mass. Fix broken links for the electron and proton mass

* Revert variable names back to lowercase due to parsing issue with f2py

* Update electron mass constant to use the more accurate value. Add new variable for electron_volt
The commit updates the electron mass constant in multiple files to use the more accurate value provided by the NIST. This ensures that calculations involving the electron mass are more precise. Variable name has been changed from emass to electron_mass

* Add new constants for the speed of light, D-T reaction energy, D-3He reaction energy and both D-D reactions

* Refactor bosch_hale function to use more descriptive name and update function signature

* Add new constants for fusion reaction energy fractions

This commit adds new constants for the energy fractions carried by neutrons and protons in various fusion reactions. These constants are used to calculate the energy released in fusion reactions involving deuterium, tritium, helium-3, and protons. The energy fractions are calculated assuming a non-relativistic center of mass frame.

The following constants have been added:
- dt_neutron_energy_fraction: Energy fraction carried by neutron in deuterium-tritium reaction
- dd_neutron_energy_fraction: Energy fraction carried by neutron in deuterium-deuterium (helium-3 producing) reaction
- dd_proton_energy_fraction: Energy fraction carried by proton in deuterium-deuterium (triton producing) reaction
- dhelium_proton_energy_fraction: Energy fraction carried by proton in deuterium-helion (helium-3) reaction

These constants will be used in further calculations related to fusion reactions.

* Refactor fint() into fusion_rate_integral() to be more descriptive and make function more explicit

* Refactor variable name palppv to alpha_power_density for clarity and consistency

* Refactor variable name palppv to alpha_power_density for clarity and consistency

* Refactor variable name pneutpv to neutron_power_density for clarity and consistency

* Refactor variable names for fusion reactions in physics calculations

* Refactor variable names fusionrate to fusion_rate_density

* Refactor variable names for alpha particle production rate

- Renamed `alpharate` variable to `alpha_rate_density` for clarity and consistency.

* Refactor variable names for proton rate density in physics calculations

* Refactor variable name pdd to dd_power_density for clarity and consistency

* Refactor variable name pdtpv to dt_power_density for clarity and consistency

* Refactor variable names for helium-3 power density in physics calculations

* Refactor variable name sigvdt to sigmav_dt_average for clarity and consistency

* Refactor sum_fusion_rates() to be more explicit and pythonic

* Refactor set_physics_variables() to update global and module variables with fusion power densities and reaction rates

* Refactor the fusion reaction function. Docstring and type hints added with internal variables renamed for clarity

* Refactor the fusion reaction function. Docstring and type hints added with internal variables renamed for clarity

* Implement the new reaction energies and product  particle fractions from constants.f90

* Rename pdt to dt_power to be more explicit

* Rename pdhe3 to dhe3_power to be more descriptive

* Rename pdd to dd_power for more clarity

* Rename "vol" to "plasma_volume" in multiple files to improve code readability and maintain consistency with other variable names.

* Add type hints and expand docstring to palph2()

* Add new variable alpha_power_plasma that represents the alpha power produced just by reactions in the plasma. Has been added to output to show the breakdown of the total alpha power from the plasma and NBI contribution.

* Rename palpnb to alpha_power_beams for more clarity and consistency

* Rename "palpmw" to "alpha_power_total" for clarity and consistency

* Add new variable neutron_power_plasma that represents the neutron power produced just by reactions in the plasma. Has been added to output to show the breakdown of the total alpha power from the plasma and NBI contribution.

* Rename pneutmw to neutron_power_total for more clarity and consistency

* Add new variable to output called neutron_power_beams to show the breakdown of total fusion power

* Rename pchargemw to non_alpha_charged_power for clarity

* Add charged_particle_power as a new physics variable and add it to the output

* Rename powfmw to fusion_power for clarity

* Rename palpipv to alpha_power_ion_density for clarity

* Rename palpepv to alpha_power_electron_density for clarity

* Add alpha_power_electron_density and alpha_power_electron_density to output

* Add main bulk of FusionReaction class documentation descriptions

* Update BoschHale docs section

* Update variable name for charged particle power in stellarator.py and physics_variables.f90

* Remove ealphadt variable for the alpha particle energy in D-T reactions. New constant dt_alpha_energy is now called from the constants file in functions

* Update the variable name falpha to f_alpha_plasma for clarity and consistency

* Add new atomic mass unit and kilo electron volt constant. Rename palphabm() to alpha_power_beam(). Replace use of the proton mass instead of the amu unit

* Update atomic mass units for deuterium and tritium and change multiplied constant form proton mass to amu mass

* Add NBI beam fusion sections to new beam_reactions.md file. Rename xbrak() to beam_energy_to_ions(). Update beam energy to ions docs

* Update beam_reactions.md with NBI beam fusion sections and function name changes

* Rename sgvhot() to beam_reaction_rate()

* Rename _sigbmfus() to _beam_fusion_cross_section() and add to docs

* Refactor the _hot_beam_fusion_reaction_rate_integrand() function to improve readability and clarity. Update the function to use more descriptive variable names and add comments for better understanding.

* Refactor output.f90 format strings for improved spacing and readability

* Refactor palph2() to set_fusion_powers() and update naming of variables and test names

* Rename beamfus() to beam_fusion() and re-arrange beam fusion docs page

* Rename cnbeam to beam_current

* Rename enbeam to beam_energy

* Rename ftritbm to f_tritium_beam

* Rename beam_energy_to_ions() to _fast_ion_pressure_integral(). Add about derivations for beamcalc()

* Updated references to `dnbeam2` to `beam_density_out` in relevant files

* Rename betanb to beta_beam for consistency

* Beam reactions doc page structure refactor

* Rename falpe to f_alpha_electron and falpi to f_alpha_ion

* Refactor variable names for fuel ion fractions

* Remove the fast alpha beta contribution from set_fusion_powers() and put it into fast_alpha_beta(). neutron and alpha power densities are now split into separate plasma only and total variables.

* Add image showing the deuterium branching ratio and add discussion about plasma fuelling and add warning about reactions not covered

* Refactor bosch hale reactivity and replace electron with ion density

* Update the dt_power, alpha_rate_density, fusion_rate_density to now has distinct total and plasma only variants

* Add variables to obsolete variables dictionary and fix unit tests

* Add constraint equations to docs and tidy

* Revoke new outfile spacing and append fusion_power to pass integration tests

* pre-commit file fix

* Update Bosch-Hale documentation for clarity and consistency

* Revert deni to dene to prevent profile normalisation errors

* Add f_dd_branching_trit attribute and update fusion reaction calculations

---------

Co-authored-by: Timothy Nunn <timothy.nunn@ukaea.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements or additions to documentation Physics Relating to the physics models
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update the fusion reactions section of the plasma docs to full account for all models and details
6 participants
0