Skip to content

⏲️ Update confinement time docs#3493

Merged
timothy-nunn merged 106 commits intomainfrom
update_confinement_time_docs
Feb 7, 2025
Merged

⏲️ Update confinement time docs#3493
timothy-nunn merged 106 commits intomainfrom
update_confinement_time_docs

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

@chris-ashe chris-ashe commented Jan 22, 2025

Description

A new file called confinement_time.py has been created to store all of the confinement time scalings as seperate functions instead of being privately stored in the pcond() function.

⚠️ The manual inputting of the confinement time has now been moved to i_confinement_time == 0

Namespace changes

Functions

  • pcond() -> calculate_confinement_time()
  • igmarcal -> output_confinement_comparison(): Plotting the confinement time scaling comparison table is now a callable function that shows all scalings.
  • fhfac() -> find_other_h_factors(): The function fhz() has now been placed inside as an internal function as it is only called by find_other_h_factors().

Variables

kappaa_IPB -> kappa_ipb
taup -> t_alpha_confinement
tauei -> t_ion_energy_confinement
tauee -> t_electron_energy_confinement
t_alpha_confinement/taueff -> f_alpha_energy_confinement
taueff -> t_energy_confinement
taulimit -> f_alpha_energy_confinement_min
dntau -> ntau

  • 🔥 iinvqd: Removed as source cannot be found
  • 🔥 kappaa: Removed as variable is no longer used due to not checking legacy docs
  • ipnlaws -> n_confinement_scalings
  • tauscl -> labels_confinement_scalings
  • total_energy_conf_tim -> t_energy_confinement_beta : This variable describes the confinement time calculated intrinsically from the total thermal energy and the chosen loss power.
  • ptripv -> `pden_ion_transport_loss_mw
  • ptrepv -> pden_electron_transport_loss_mw
  • ftaulimit -> falpha_energy_confinement
  • ptrimw -> p_ion_transport_loss_mw
  • ptremw -> p_electron_transport_loss_mw
  • powerht -> p_plasma_loss_mw
  • isc -> i_confinement_scaling

✨ New additions

  • f_alpha_energy_confinement: Created as a new variable instead of being calculated as a fraction in outplas(). Is now calculated and set in the phyaux() function

  • nTtau: New variable to properly represent the Lawson triple product as a calculated variable in phyaux() function.

New expanded scaling output that now shows all scalings:

image


🧪 Tests

  • A new test_confinement_time.py file has been created in tests/unit to test all of the scaling for the case where all the scaling inputs are equal to one. This should catch if any of the scaling exponents or variable definitions are changed

🐛 Bugs

  • kappaa_IPB was being called as kappaa_ipb
  • The Murari scaling was using the old IPB98 definition of $\kappa$ instead of the updated definition from the paper corrections. This caused some changes to the regression tests as follows:
expected_ptrepv=0.081359821043062386, -> expected_ptrepv=0.08399287091443618,
expected_ptripv=0.072209244483967094,  -> expected_ptripv=0.07454615402313478,
expected_tauee=3.2718670722507683, ->  expected_tauee=3.169298972363837,
expected_tauei=3.2718670722507683,  -> expected_tauei=3.169298972363837,
expected_taueff=3.2718670722507692,  -> expected_taueff=3.169298972363837,
  • Same bug as above for the Petty scaling
expected_ptrepv=0.081513009259203975, -> expected_ptrepv=0.0831039731066564,
expected_ptripv=0.072345203550858064, -> expected_ptripv=0.07375723096135396,
expected_tauee=3.2657182196344126, -> expected_tauee=3.203198469625145,
expected_tauei=3.2657182196344126, -> expected_tauei=3.203198469625145,
expected_taueff=3.2657182196344126, -> expected_taueff=3.203198469625145,
  • Same bug as above for the Petty08 component of the Menard NSTX-Petty08 hybrid
expected_ptrepv=0.070108167457759038, -> expected_ptrepv=0.07147653259174333
expected_ptripv=0.062223069561580698, -> expected_ptripv=0.06343753403847416
expected_tauee=3.7969687288631331, -> expected_tauee=3.7242785823911264
expected_tauei=3.7969687288631331, -> expected_tauei=3.7242785823911264
expected_taueff=3.7969687288631335, ->  expected_taueff=3.7242785823911264
  • Coefficiecnt value for the ITER93-H scaling form ELM-free had the wrong coefficient of 0.053 when the literature says 0.036

  • Calculating the ion and electron ransport losses has raw constants floats instead of using constants.f90. This caused the calculate_confinement_time() tests to fail. Though only by a difference at the 5th decimal place

Old

ptripv = 2.403e-22 * nd_ions_total * tin / t_ion_confinement
ptrepv = 2.403e-22 * dene * ten / t_electron_confinement

New

ptripv = (
            (3 / 2)
            * (constants.electron_charge / 1e3)
            * nd_ions_total
            * tin
            / t_ion_confinement
        )
        ptrepv = (
            (3 / 2)
            * (constants.electron_charge / 1e3)
            * dene
            * ten
            / t_electron_confinement
        )

  • A loose calculation for the confinement time can be found at the top of calculate_confinement_time() beofre applying any of the scalings and is of the form:
eps2 = eps / 2.0e0
        str5 = 2.0e0 / (1.0e0 + (kappa**2))
        ck2 = (0.66e0 + (1.88e0 * (np.sqrt(eps2))) - (1.54e0 * eps2)) * (
            1.0e0 + (1.5e0 * (eps2**2))
        )
        chii = (
            (6.5e-22)
            * ck2
            * zeff
            * (aspect**1.5e0)
            * dene
            * (q**2)
            * str5
            / ((np.sqrt(tin)) * (bt**2))
        )
        str2 = 2.0e0 * (kappa**2) / (1.0e0 + (kappa**2))
        t_ion_energy_confinement = 0.375e0 * rminor**2 / chii * str2

However at the bottom of the file it is simpky re-written as equal to the electron confinement time such as:

  # Ion energy confinement time
        # N.B. Overwrites earlier calculation above
        t_ion_energy_confinement = t_electron_energy_confinement

This has been in the code from the old GitLab version and the Git blame can always see this there. It has therefore been removed.

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 Jan 22, 2025

Codecov Report

❌ Patch coverage is 66.11842% with 103 lines in your changes missing coverage. Please review.
✅ Project coverage is 31.20%. Comparing base (c8f147c) to head (9788212).
⚠️ Report is 491 commits behind head on main.

Files with missing lines Patch % Lines
process/physics.py 48.08% 95 Missing ⚠️
process/power.py 0.00% 3 Missing ⚠️
process/stellarator.py 0.00% 3 Missing ⚠️
process/confinement_time.py 99.11% 1 Missing ⚠️
process/init.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3493      +/-   ##
==========================================
+ Coverage   30.84%   31.20%   +0.36%     
==========================================
  Files          80       81       +1     
  Lines       19327    19440     +113     
==========================================
+ Hits         5961     6066     +105     
- Misses      13366    13374       +8     

☔ 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 update_confinement_time_docs branch 3 times, most recently from 72b5075 to 4fc3e48 Compare January 23, 2025 14:45
@chris-ashe chris-ashe self-assigned this Jan 23, 2025
@chris-ashe chris-ashe added the Physics Relating to the physics models label Jan 23, 2025
@chris-ashe chris-ashe force-pushed the update_confinement_time_docs branch 5 times, most recently from bb322ae to 590113b Compare January 29, 2025 11:23
@j-a-foster j-a-foster linked an issue Jan 31, 2025 that may be closed by this pull request
Copy link
Copy Markdown
Collaborator Author

@chris-ashe chris-ashe left a comment

Choose a reason for hiding this comment

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

@j-a-foster Dont forget to add the doc page

@chris-ashe chris-ashe force-pushed the update_confinement_time_docs branch 2 times, most recently from 06c80a4 to e97a78d Compare February 3, 2025 14:51
@chris-ashe chris-ashe changed the title 🚧 Update confinement time docs ⏲️ Update confinement time docs Feb 4, 2025
@chris-ashe chris-ashe marked this pull request as ready for review February 4, 2025 16:07
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.

Some minor comments, otherwise happy with the docs.

| 48 | NSTX gyro-Bohm (Buxton) (H-mode; spherical tokamak) | P. Buxton et al. 2019 Plasma Phys. Control. Fusion 61 035006 |
| 49 | Use input `tauee_in` | |
| 50 | ITPA20 (H-mode) | G. Verdoolaege et al 2021 Nucl. Fusion 61 076006 |
Normally most confinement scalings will be of the form:
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.

Caveat that not all scalings listed contain all of these parameters e.g. epsilon


$$
\tau_{\text{E}} = 0.0367 I^{1.006} R^{1.731} \kappa_{\text{IPB}}^{1.45} P^{-0.735} \\
\times \frac{\overline{n}_{19}^{0.49}}{1+e^\left({-9.403\left(\frac{\overline{n}_{19}^{0.49}}{B_{\text{T}}}\right)^{-1.365}}\right)}
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.

The exponent in the 1+e in the denominator could be substituted for e.g. X and then underneath, define X = -9.403(n/Bt)^-1.365, just to tidy up the formula a bit. Not absolutely needed, will leave up to you to decide.

Comment thread documentation/proc-pages/physics-models/plasma_confinement.md Outdated
Comment thread documentation/proc-pages/physics-models/plasma_confinement.md Outdated
Comment thread documentation/proc-pages/physics-models/plasma_confinement.md Outdated
Comment thread documentation/proc-pages/physics-models/plasma_confinement.md Outdated
Comment thread documentation/proc-pages/physics-models/plasma_confinement.md Outdated
Comment thread documentation/proc-pages/physics-models/plasma_confinement.md Outdated
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 code changes, thanks for writing tests for each one. Please fix the conflicts.

Comment thread source/fortran/input.f90
case ('ftaulimit')
call parse_real_variable('ftaulimit', ftaulimit, 0.001D0, 1.0D0, &
'f-value for lower limit on taup/taueff the ratio of alpha particle to energy confinement times')
case ('falpha_energy_confinement')
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.

The old variables do not appear to have been added to obsolete variables

Comment thread process/physics.py Outdated
Comment thread process/confinement_time.py Outdated
j-a-foster and others added 20 commits February 7, 2025 11:54
@chris-ashe chris-ashe force-pushed the update_confinement_time_docs branch from c8f6e73 to 97ae8fb Compare February 7, 2025 11:55
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 with the docs - okay to be merged.

@timothy-nunn timothy-nunn merged commit 95128e9 into main Feb 7, 2025
@timothy-nunn timothy-nunn deleted the update_confinement_time_docs branch February 7, 2025 15:07
ajpearcey pushed a commit that referenced this pull request Feb 26, 2025
* ❇️ Create new confinement time file and add neo_alcator scaling

* ✨Add Merezhkin-Mukhovatov confinement time calculation and update Neo-Alcator scaling

* 🔄 Rename 'isc' to 'i_confinement_time' for clarity in confinement time scaling law

* ♻️ Make user input confinement time be option zero for i_confinement_time

* ✨ Add Mirnov confinement time calculation and integrate into physics module

* ✨ Add Shimomura confinement time calculation and integrate into physics module

* ✨ Add Kaye-Goldston confinement time calculation and update documentation for available scalings

* ✨ Add ITER 89-P L-mode confinement time calculation and update documentation

* ♻️ Update number of energy confinement time scaling laws to 50 and remove unused label

* 📝 Add L-H power threshold scalings documentation and integrate into MkDocs navigation

* ✨ Add ITER 89-O L-mode confinement time calculation and update documentation

* ✨ Add Rebut-Lallia L-mode confinement time calculation and update documentation

* ✨ Add Goldston L-mode confinement time calculation and update documentation

* ✨ Add T-10 L-mode confinement time calculation and update documentation

* ✨ Add JAERI / Odajima-Shimomura L-mode confinement time calculation and update documentation

* ✨ Add ITER H90-P H-mode confinement time calculation and update documentation

* ✨ Add Kaye "big" L-mode confinement time calculation and update documentation

* 🔄 Rename variable 'iradloss' to 'i_rad_loss' for consistency in power balance calculations and update related documentation

* ✨ Add minimum of ITER 89-P and ITER 89-O confinement time calculation and update documentation

* ✨ Add Riedel L-mode scaling confinement time calculation and update documentation

* ✨ Add Christiansen L-mode scaling confinement time calculation and update documentation

* ✨ Add Lackner-Gottardi L-mode scaling confinement time calculation and update documentation

* ✨ Add Neo-Kaye L-mode scaling confinement time calculation and update documentation

* ✨ Add Riedel H-mode scaling confinement time calculation and update documentation

* ✨ Add amended ITER H90-P confinement time calculation and update documentation

* ✨ Add Sudo et al. stellarators/heliotron scaling confinement time calculation and update documentation

* ✨ Add Gyro-reduced Bohm scaling confinement time calculation and update documentation

* ✨ Add Lackner-Gottardi stellarator scaling confinement time calculation and update documentation

* ✨ Add ELM-free ITER H-mode scaling confinement time calculation and update documentation

* ✨ Add ELMy ITER H97-P(y) scaling confinement time calculation and update documentation

* ✨ Add ITER-96P (ITER-97L) L-mode scaling confinement time calculation and update documentation

* ✨ Add IPB98(y) ELMy H-mode scaling confinement time calculation and update documentation

* 🔄 Rename kappaa_IPB to kappa_ipb for consistency in variable naming

* 📝 Add more information about the kappa_ipb change

* ✨ Add IPB98(y,1) ELMy H-mode scaling confinement time calculation and update documentation

* ✨ Add IPB98(y,2) ELMy H-mode scaling confinement time calculation and update documentation

* ✨ Add IPB98(y,3) ELMy H-mode scaling confinement time calculation and update documentation

* ✨ Add IPB98(y,4) ELMy H-mode scaling confinement time calculation and update documentation

* ✨ Add ISS95 stellarator scaling confinement time calculation and update documentation

* ✨ Add ISS04 stellarator scaling confinement time calculation and update documentation

* ✨ Add DS03 beta-independent H-mode scaling confinement time calculation and update documentation

* ✨ Add Murari "Non-power law" H-mode scaling confinement time calculation and update documentation

* ✨ Add Petty H-mode scaling confinement time calculation and update documentation

* ✨ Add Hubbard I-mode nominal scaling confinement time calculation and update documentation

* ✨ Add Hubbard I-mode lower scaling confinement time calculation and update documentation

* ✨ Add Hubbard I-mode upper scaling confinement time calculation and update documentation

* ✨ Add Menard NSTX H-mode scaling confinement time calculation and update documentation

* ✨ Add Menard NSTX-Petty08 hybrid confinement time calculation and update Petty scaling references in documentation

* ✨ Add Buxton NSTX gyro-Bohm confinement time calculation and update documentation

* ✨ Add ITPA20 H-mode scaling confinement time calculation and update documentation

* 🔄 Refactor pcond to calculate_confinement_time

* ✨ Add ITER-93 ELM-free H-mode scaling confinement time calculation and update documentation

* ✅ Fix integration test indexing fail

* 🔥 Remove igmarcal function and put functionality into outplas

* 🔄 Rename taup to t_alpha_confinement for clarity and update related documentation

* 🔄 Rename tauei to t_ion_confinement for clarity and update related references

* 🔄 Rename tauee to t_electron_confinement for clarity and update related references

* 🔄 Rename t_alpha_confinement_taueff to f_alpha_energy_confinement for clarity and update related references, create it as a new variable

* 🔄 Rename taueff to t_energy_confinement for clarity and update related references

* 🔄 Rename taulimit to f_alpha_energy_confinement_min for clarity and update related references

* ❇️ Add nTtau variable for Lawson triple product and update related references

* 🔄 Rename dntau to ntau for clarity and update related references

* 📝 Enhance plasma confinement documentation with overview, key constraints, and detailed scaling laws

* ⚠️ Add warning about TITAN Reversed-Field Pinch scaling being removed

* ❇️ Add Lang high density H-mode scaling and related confinement time calculation

* 👕 Apply new ruff linting rules

* ❇️ Implement Valovic modified ELMy-H mode scaling for confinement time calculation and update documentation

* ❇️ Add Kaye modified L-mode scaling for confinement time calculation and update documentation

* ❇️ Add ITERH-PB98P(y) H-mode scaling for confinement time calculation and update documentation

* Refactor confinement time calculations to use m_fuel_amu instead of afuel for improved accuracy

* 🎨 Add all references to mkdocs page

* Update documentation and code to use 'vol_plasma' instead of 'plasma_volume' for consistency in confinement calculations

* 🔥 Remove unused inverse quadrature switch from L-mode scaling and related documentation

* Add constants to ion/electron confinement time calc instead of loose floats

* 🔥 Remove references to 'kappaa' from physics calculations and related tests for clarity and consistency

* Refactor variable names for consistency: update 'kappaa' to 'kappa' in physics calculations and tests

* Refactor physics variable names for clarity: update 'a_plasma_poloidal' to 'None' and 'aion' to 'm_ions_total_amu'

* 🐛 Fix too many variables called to Neo Kaye scaling

* Refactor ion confinement variable names for clarity: update 't_ion_confinement' to 't_ion_energy_confinement' across multiple files

* Refactor electron confinement variable names for clarity: update 't_electron_confinement' to 't_electron_energy_confinement' across multiple files

* ➖ rearranged hfact multiplication calc

* ➕ Added ITPA20-IL confinement scaling for papercut

* ➕ Added comment for ITPA20-IL scaling

* 📝 Updated docs for new scaling

* 📝 updated tauscl and ipnlaws

* ➕ Added unit tests for various confinement time calculations

* ➖ Removed inverse quadrature switch from multiple MFILE and IN files

* Refactor confinement time calculations and update output formatting in physics module

* 🔄 Rename ipnlaws to n_confinement_scalings for clarity and consistency across the codebase

* 🔄 Update references from tauscl to labels_confinement_scalings for consistency in confinement time scaling law

* 🔥 Remove overwritten ion confinement calculation

* 🔄 Rename total_energy_conf_time to t_energy_confinement_beta for consistency across the codebase

* 🔄 Rename ptripv to pden_ion_transport_loss_mw for clarity and consistency across the codebase

* 🔄 Rename ptrepv to pden_electron_transport_loss_mw for clarity and consistency across the codebase

* 🔄 Rename ptremw to p_electron_transport_loss_mw for clarity and consistency across the codebase

* 🔄 Rename ptrimw to p_ion_transport_loss_mw for clarity and consistency across the codebase

* 🔄 Update plasma confinement documentation for clarity and consistency in energy loss power calculations

* 🔄 Rename ftaulimit to falpha_energy_confinement for clarity and consistency across input files and documentation

* 🔄 Adjust formatting in energy confinement output for improved readability and consistency

* 🔄 Clarify comments in physics.py regarding ion and electron energy confinement calculations

* Rename powerht to p_plasma_loss_mw for clarity and consistency across the codebase and documentation

* 🔄 Refactor H-factor calculation methods for clarity and consistency in physics module

* 🔄 Fix typos in plasma confinement documentation and Fortran physics variables for clarity and accuracy

* 📝 Doc review updates

* 📝 Requested review changes, add variables to obsolete dictionary

* 📝 Add subscripts to plasma current and loss power

---------

Co-authored-by: Jack <jack.foster@ukaea.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Variables Physics Relating to the physics models Variable rename

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update the plasma confinement time section of the docs to include all new models Add ITPA20-IL and IPTA20 H factor scaling

5 participants