Skip to content

3385 Update the plasma composition docs to include all new models#3386

Merged
timothy-nunn merged 48 commits intomainfrom
3385-update-the-plasma-composition-docs-to-include-all-new-models
Jan 29, 2025
Merged

3385 Update the plasma composition docs to include all new models#3386
timothy-nunn merged 48 commits intomainfrom
3385-update-the-plasma-composition-docs-to-include-all-new-models

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

@chris-ashe chris-ashe commented Nov 8, 2024

Description

This PR was originally meant to cover the radiation section of the code as well but will be put into a separate issue to prevent conflicts.

  • zeffai now added to output.

Namespace changes

Functions

  • radpwr() -> calculate_radiation_powers()

Variables

Plasma Composition

  • afuel -> m_fuel_amu: This has now been added to output
  • abeam -> m_beam_amu: This has now been added to output
  • dnalp -> nd_alphas
  • dnprot -> nd_protons
  • protium -> f_nd_protium_electrons
  • dnbeam -> nd_beam_ions
  • dnitot -> nd_ions_total
  • dnz -> nd_impurities
  • aion -> m_ions_total_amu
  • ralpne -> f_nd_alpha_electron
  • rnbeam -> f_nd_beam_electron
  • deni -> nd_fuel_ions

⚡ Radiation

  • pradpv -> pden_plasma_rad_mw
  • pradmw -> p_plasma_rad_mw
  • peakfactrad -> f_fw_rad_max
  • pouterzoneradmw -> p_plasma_outer_rad_mw
  • pinnerzoneradmw -> p_plasma_inner_rad_mw
  • photon_wall -> pflux_fw_rad_mw
  • peakradwallload -> pflux_fw_rad_max_mw
  • psyncpv -> pden_plasma_sync_mw
  • ssync -> f_sync_reflect

✨ New additions

The new constants have been added to constants.f90 for the different fuel species atomic masses from NIST. These updated mass values caused the plasma composition and first wall heating unit tests to fail.

  • m_deuteron_amu: 2.0 -> 2.013553212544
  • m_helion_amu: 3.0 -> 3.014932246932
  • m_triton_amu: 3.0 -> 3.01550071597
  • m_alpha_amu: 4.0 -> 4.001506179129
  • m_proton_amu:1.0 -> 1.0072764665789

The ATOMIC_MASS_DEUTERIUM and ATOMIC_MASS_TRITIUM local variables in physics_functions.py has been replaced with the values above.

The same has been done for the impurity species taking in impurity_radiation.py:

  • m_protium_amu: 1.01 -> 1.00782503223
  • m_helium_amu: 4.003 -> 4.002602
  • m_beryllium_amu: 9.01 -> 9.0121831
  • m_carbon_amu: 12.01 -> 12.0096
  • m_nitrogen_amu: 14.01 -> 14.00643
  • m_oxygen_amu: 15.999 -> 15.99903
  • m_neon_amu: 20.18 -> 20.1797
  • m_silicon_amu: 28.09 -> 28.084
  • m_argon_amu: 39.95 -> 39.948
  • m_iron_amu: 55.85 -> 55.845
  • m_nickel_amu: 58.70 -> 58.6934
  • m_krypton_amu: 83.80 -> 83.798
  • m_xenon_amu: 131.30 -> 131.293
  • m_tungsten_amu: 183.85 -> 183.84

🐛 Bugs

  • In psync_albajar_fidone() the temperature profile parameter tbeta was not used as intended by the model authors but was just fixed to a value of 2.0.
  • In psync_albajar_fidone() the plasma elongation kappa is not given to the function as intded, instead it was calculated internally as follows:
kap = physics_variables.plasma_volume / (
        2.0e0 * np.pi**2 * physics_variables.rmajor * physics_variables.rminor**2
    )
  • In the calculation of the density weighted mass of all ions in plasma_composition() the proton density was not multiplied by its true mass value and was just set to 1.0.
  • Calculation the mass-weighted effective charge (zeffai) did not use the true masses of the particles in atomic mass units. Impleneting the true masses causes a change in unit tests as such:
Obtained: 0.43056686748101997
Expected: 0.4325898512799211 ± 4.3e-07

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.

@chris-ashe chris-ashe linked an issue Nov 8, 2024 that may be closed by this pull request
@chris-ashe chris-ashe changed the title 3385 update the plasma composition docs to include all new models 🚧 3385 update the plasma composition docs to include all new models Nov 8, 2024
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 8, 2024

Codecov Report

❌ Patch coverage is 34.10853% with 85 lines in your changes missing coverage. Please review.
✅ Project coverage is 30.60%. Comparing base (41afdb6) to head (924826d).
⚠️ Report is 531 commits behind head on main.

Files with missing lines Patch % Lines
process/physics.py 46.29% 29 Missing ⚠️
process/stellarator.py 0.00% 18 Missing ⚠️
process/io/sankey_funcs.py 0.00% 10 Missing ⚠️
process/current_drive.py 11.11% 8 Missing ⚠️
process/physics_functions.py 57.89% 8 Missing ⚠️
process/io/plot_proc.py 0.00% 5 Missing ⚠️
process/power.py 0.00% 2 Missing ⚠️
process/dcll.py 66.66% 1 Missing ⚠️
process/divertor.py 0.00% 1 Missing ⚠️
process/init.py 66.66% 1 Missing ⚠️
... and 2 more
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3386   +/-   ##
=======================================
  Coverage   30.60%   30.60%           
=======================================
  Files          80       80           
  Lines       19269    19254   -15     
=======================================
- Hits         5897     5893    -4     
+ Misses      13372    13361   -11     

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

@chris-ashe chris-ashe force-pushed the 3385-update-the-plasma-composition-docs-to-include-all-new-models branch from 229400e to 80e5a83 Compare January 7, 2025 15:18
@chris-ashe chris-ashe added Documentation Improvements or additions to documentation Impurities Plasma impurities labels Jan 7, 2025
@chris-ashe chris-ashe force-pushed the 3385-update-the-plasma-composition-docs-to-include-all-new-models branch 2 times, most recently from d0adab7 to b24d113 Compare January 8, 2025 11:21
@chris-ashe chris-ashe changed the title 🚧 3385 update the plasma composition docs to include all new models 🚧 3385 Update the plasma composition and radiation docs to include all new models Jan 8, 2025
@chris-ashe chris-ashe force-pushed the 3385-update-the-plasma-composition-docs-to-include-all-new-models branch from c98dec3 to e4c93b2 Compare January 24, 2025 14:45
@chris-ashe chris-ashe changed the title 🚧 3385 Update the plasma composition and radiation docs to include all new models 🚧 3385 Update the plasma composition docs to include all new models Jan 24, 2025
@chris-ashe chris-ashe marked this pull request as ready for review January 24, 2025 14:55
@chris-ashe chris-ashe changed the title 🚧 3385 Update the plasma composition docs to include all new models 3385 Update the plasma composition docs to include all new models Jan 24, 2025
@chris-ashe chris-ashe self-assigned this Jan 24, 2025
Copy link
Copy Markdown
Collaborator

@j-a-foster j-a-foster left a comment

Choose a reason for hiding this comment

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

Just a couple of minor things, otherwise docs all look good.

Comment thread documentation/proc-pages/physics-models/plasma_composition.md
Comment thread documentation/proc-pages/physics-models/plasma_composition.md Outdated
@chris-ashe chris-ashe force-pushed the 3385-update-the-plasma-composition-docs-to-include-all-new-models branch from c5c962b to 016270b Compare January 27, 2025 16:03
Copy link
Copy Markdown
Collaborator

@j-a-foster j-a-foster left a comment

Choose a reason for hiding this comment

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

Additions to constants.f90 are all correct.

Copy link
Copy Markdown
Collaborator

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

Happy with changes. Just want to check a section with lots of comments has all of them referenced.

Comment on lines 620 to +628
de2o = 1.0e-20 * physics_variables.ne0
pao = 6.04e3 * (physics_variables.rminor * de2o) / physics_variables.bt
gfun = 0.93e0 * (
1.0e0
+ 0.85e0 * np.exp(-0.82e0 * physics_variables.rmajor / physics_variables.rminor)
)
kfun = (physics_variables.alphan + 3.87e0 * physics_variables.alphat + 1.46e0) ** (
-0.79e0
)
kfun = kfun * (1.98e0 + physics_variables.alphat) ** 1.36e0 * tbet**2.14e0
kfun = kfun * (tbet**1.53e0 + 1.87e0 * physics_variables.alphat - 0.16e0) ** (
-1.33e0
gfun = 0.93e0 * (1.0e0 + 0.85e0 * np.exp(-0.82e0 * physics_variables.aspect))
kfun = (
(physics_variables.alphan + 3.87 * physics_variables.alphat + 1.46) ** -0.79
* (1.98 + physics_variables.alphat) ** 1.36
* physics_variables.tbeta**2.14
* (physics_variables.tbeta**1.53 + 1.87 * physics_variables.alphat - 0.16)
** -1.33
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.

Do all of these constants and factors come from the referenced papers?

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.

And 0.62 (rpow)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I will be coming back to this when I look at the radiation properly in another PR, was doing it originally with the composition review

@chris-ashe chris-ashe force-pushed the 3385-update-the-plasma-composition-docs-to-include-all-new-models branch from 8492e38 to 9a0d9e7 Compare January 28, 2025 13:24
…eplace with physics_variables.kappa for clarity
…cs_functions.py and use new values from constants.f90
@chris-ashe chris-ashe force-pushed the 3385-update-the-plasma-composition-docs-to-include-all-new-models branch from 9a0d9e7 to fecf4a8 Compare January 29, 2025 08:37
Copy link
Copy Markdown
Collaborator

@j-a-foster j-a-foster left a comment

Choose a reason for hiding this comment

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

Happy for this to be merged.

@timothy-nunn timothy-nunn merged commit 56c5667 into main Jan 29, 2025
@timothy-nunn timothy-nunn deleted the 3385-update-the-plasma-composition-docs-to-include-all-new-models branch January 29, 2025 10:29
ajpearcey pushed a commit that referenced this pull request Feb 26, 2025
)

* Rename and reorganize plasma documentation: separate radiation content into its own file and update references

* 🔄 Rename impurity species count variable from nimp to n_impurities for consistency across documentation and code

* 🔄 Rename afuel variable to m_fuel_amu for consistency across the codebase

* 🔄 Update fuel species mass calculations to use constants for improved accuracy

* 🔄 Rename abeam variable to m_beam_amu for consistency across documentation and code

* ✅ Update unit tests failing due to using proper fuel species atomic masses

* 🔄 Rename dnalp variable to nd_alphas for consistency across the codebase

* 🔄 Rename dnprot variable to nd_protons for consistency across the codebase

* 🔄 Rename protium variable to f_nd_protium_electrons for consistency across the codebase

* 🔄 Rename dnbeam variable to nd_beam_ions for consistency across the codebase

* 🔄 Rename dnitot variable to nd_ions_total for consistency across the codebase

* 🔄 Rename dnz variable to nd_impurities for consistency across the codebase

* 🔄 Rename aion variable to m_ions_total_amu for consistency across the codebase

* 🔄 Add atomic mass constants for various elements to improve code clarity and maintainability

* 📝 Update documentation to reflect changes in plasma composition and impurities section

* 🔄 Rename pradmw variable to p_plasma_rad_mw for consistency across the codebase

* 🔄 Rename photon_wall variable to p_fw_rad_mw for consistency across the codebase

* 🔄 Rename peakradwallload variable to p_fw_rad_max_mw for consistency across the codebase

* 🔄 Rename pinnerzoneradmw variable to p_plasma_inner_rad_mw for consistency across the codebase

* 🔄 Rename pouterzoneradmw variable to p_plasma_outer_rad_mw for consistency across the codebase

* 🔄 Rename peakfactrad variable to f_fw_rad_max for consistency across the codebase

* ♻️ Rename p_fw_rad_mw and p_fw_rad_max_mw to pflux_fw_rad_mw and pflux_fw_rad_max_mw for consistency across the codebase

* 🔄 Rename radpwr() to calculate_radiation_power() and add type hints and docstring

* 🔄 Rename psyncpv to pden_plasma_sync_mw for consistency across the codebase

* 🐛 fix old nimp variable name for new init.py

* 🔄 Rename pradpv to pden_plasma_rad_mw for consistency across the codebase

* 🎨 Update plasma radiation documentation and improve psync_albajar_fidone function docstring for clarity

* 🐛 Add the tbeta parameter to the synchrotron power calculations as intended. Value was fixed to 2.0

* 🐛 Remove unused kap variable from psync_albajar_fidone function and replace with physics_variables.kappa for clarity

* 🔄 Rename ssync to f_sync_reflect for clarity and consistency across the codebase

* 🚚 Move coulomb logarithm definitions to the appropriate section in the Physics class for better organization

* ➕ Add new m_proton_amu variable and multiply it by the proton mass in the density weighted calculation

* 🐛 Refactor zeffai calculation to use mass-weighted plasma effective charge with constants for improved accuracy

* 🎨 Update plasma_composition() doc section

* 🎨 Enhance plasma radiation documentation with detailed loss functions and references

* 🔄 Rename 'ralpne' to 'f_nd_alpha_electron' for clarity and consistency across data files and code

* 🔄 Rename 'rnbeam' to 'f_nd_beam_electron' for clarity and consistency in calculations and documentation

* 🔄 Rename 'deni' to 'nd_fuel_ions' for clarity and consistency across code and documentation

* 🎨 Update ion density labels for clarity and consistency in output

* 🔥 Remove the ATOMIC_MASS_DEUTERIUM and ATOMIC_MASS_TRITIUM from physics_functions.py and use new values from constants.f90

* 📝 Add output for average mass of fuel and beam ions in physics calculations

* 🚚 Move density limit output to correct section

* 🎨 Update output labels for electron and ion densities for clarity and consistency

* 🎨 Add new variable mappings for peak factor, impurities, and beam electrons in obsolete_vars.py

* 🎨 Clean up obsolete_vars.py and add separators in physics.py for better readability

* 🎨 Enhance plasma composition documentation with impurity species indices and iteration variables

* Requested review changes

* 🎨 Refactor total calculation in Power class for improved readability
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 Impurities Plasma impurities Variable rename

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update the plasma composition docs to include all new models

5 participants