Skip to content

:electron: 3013 add class methods for each current drive efficiency calc along with suitable tests#3621

Merged
timothy-nunn merged 41 commits intomainfrom
3013-add-class-methods-for-each-current-drive-efficiency-calc-along-with-suitable-tests
Apr 24, 2025
Merged

:electron: 3013 add class methods for each current drive efficiency calc along with suitable tests#3621
timothy-nunn merged 41 commits intomainfrom
3013-add-class-methods-for-each-current-drive-efficiency-calc-along-with-suitable-tests

Conversation

@chris-ashe
Copy link
Copy Markdown
Collaborator

@chris-ashe chris-ashe commented Apr 7, 2025

This PR focusses on refactoring current_drive.py so that it has separate classes for each of the current drive schemes and tidies up and expands the output.

Naming changes

New variables

eta_cd_hcd_secondary
p_hcd_injected_current_total_mw

Variable changes

pinjwpfix -> p+hcd_secondary_electric_mw
pinjwp -> p_hcd_electric_total_mw
plhybd -> p_hcd_lowhyb_injected_total_mw
pnbeam -> p_hcd_beam_injected_total_mw
echpow -> p_hcd_ecrh_electric_mw
fvsbrnni -> f_c_plasma_non_inductive
inductive_current_fraction -> f_c_plasma_inductive
aux_current_fraction -> f_c_plasma_auxiliary


Code structure

Previous

classes_CurrentDrive-main
out-main

New

classes_CurrentDrive

out


Code output

Previous

image

New

image


🐛 Bugs

# the fixed auxiliary current
                current_drive_variables.c_hcd_secondary_driven = (
                    eta_cd_hcd_secondary
                    * (
                        current_drive_variables.p_hcd_secondary_injected_mw
                        - current_drive_variables.p_hcd_secondary_extra_heat_mw
                    )
                    * 1.0e6
                )
pnbitotfix = current_drive_variables.p_hcd_secondary_injected_mw / (
                    1.0e0
                    - current_drive_variables.f_p_beam_orbit_loss
                    + current_drive_variables.f_p_beam_orbit_loss
                    * current_drive_variables.f_p_beam_shine_through
                )

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 Apr 7, 2025

Codecov Report

❌ Patch coverage is 36.66667% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.39%. Comparing base (302cff7) to head (255258c).
⚠️ Report is 414 commits behind head on main.

Files with missing lines Patch % Lines
process/stellarator.py 0.00% 9 Missing ⚠️
process/physics.py 50.00% 4 Missing ⚠️
process/io/sankey_funcs.py 0.00% 2 Missing ⚠️
process/pfcoil.py 0.00% 2 Missing ⚠️
process/main.py 50.00% 1 Missing ⚠️
process/output.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3621      +/-   ##
==========================================
+ Coverage   36.24%   36.39%   +0.15%     
==========================================
  Files          88       88              
  Lines       22090    22051      -39     
==========================================
+ Hits         8006     8025      +19     
+ Misses      14084    14026      -58     

☔ 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 self-assigned this Apr 7, 2025
@chris-ashe chris-ashe added Refactor HCD Relating to heating and current drive systems labels Apr 7, 2025
@chris-ashe chris-ashe force-pushed the 3013-add-class-methods-for-each-current-drive-efficiency-calc-along-with-suitable-tests branch from 03abbe9 to 0029c39 Compare April 11, 2025 10:04
@chris-ashe chris-ashe requested a review from Copilot April 11, 2025 13:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 53 out of 62 changed files in this pull request and generated no comments.

Files not reviewed (9)
  • examples/data/csv_output_large_tokamak_MFILE.DAT: Language not supported
  • examples/data/large_tokamak_1_MFILE.DAT: Language not supported
  • examples/data/large_tokamak_2_MFILE.DAT: Language not supported
  • examples/data/large_tokamak_3_MFILE.DAT: Language not supported
  • examples/data/large_tokamak_4_MFILE.DAT: Language not supported
  • examples/data/large_tokamak_IN.DAT: Language not supported
  • examples/data/large_tokamak_once_through_IN.DAT: Language not supported
  • examples/data/scan_MFILE.DAT: Language not supported
  • examples/data/scan_example_file_IN.DAT: Language not supported

@chris-ashe chris-ashe changed the title 🚧 3013 add class methods for each current drive efficiency calc along with suitable tests 3013 add class methods for each current drive efficiency calc along with suitable tests Apr 11, 2025
@chris-ashe chris-ashe marked this pull request as ready for review April 11, 2025 16:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 58 out of 67 changed files in this pull request and generated 2 comments.

Files not reviewed (9)
  • examples/data/csv_output_large_tokamak_MFILE.DAT: Language not supported
  • examples/data/large_tokamak_1_MFILE.DAT: Language not supported
  • examples/data/large_tokamak_2_MFILE.DAT: Language not supported
  • examples/data/large_tokamak_3_MFILE.DAT: Language not supported
  • examples/data/large_tokamak_4_MFILE.DAT: Language not supported
  • examples/data/large_tokamak_IN.DAT: Language not supported
  • examples/data/large_tokamak_once_through_IN.DAT: Language not supported
  • examples/data/scan_MFILE.DAT: Language not supported
  • examples/data/scan_example_file_IN.DAT: Language not supported

Comment thread documentation/proc-pages/eng-models/heating_and_current_drive/RF/ic_overview.md Outdated
@chris-ashe chris-ashe changed the title 3013 add class methods for each current drive efficiency calc along with suitable tests :electron: 3013 add class methods for each current drive efficiency calc along with suitable tests Apr 11, 2025
@chris-ashe chris-ashe force-pushed the 3013-add-class-methods-for-each-current-drive-efficiency-calc-along-with-suitable-tests branch from 2e7713b to 9585e4a Compare April 11, 2025 16:26
Comment thread documentation/proc-pages/eng-models/heating_and_current_drive/RF/ic_overview.md Outdated
Comment thread process/main.py Outdated
@chris-ashe chris-ashe force-pushed the 3013-add-class-methods-for-each-current-drive-efficiency-calc-along-with-suitable-tests branch from 48d92a3 to 349df47 Compare April 23, 2025 14:17
…frequency and update references in CurrentDrive class
…ron cyclotron heating efficiency and update related documentation
…nstein Wave current drive efficiency and refactor CurrentDrive class to utilize this new method
…clotron current drive efficiency and refactor CurrentDrive class to utilize this new method
…calculations using a dictionary of models and remove redundant code
… introduce new variables for driven current fractions
…ons_mw and update injected power handling for ion cyclotron cases
…ated calculations in current drive and heat transport modules
…s for primary heating power in heat transport module
…e cases and improve wall plug power efficiency
…ty and update related calculations and documentation
@chris-ashe chris-ashe force-pushed the 3013-add-class-methods-for-each-current-drive-efficiency-calc-along-with-suitable-tests branch from 349df47 to 351576f Compare April 23, 2025 14:25
Comment thread documentation/proc-pages/eng-models/heating_and_current_drive/RF/ic_overview.md Outdated
@chris-ashe chris-ashe force-pushed the 3013-add-class-methods-for-each-current-drive-efficiency-calc-along-with-suitable-tests branch from 351576f to 255258c Compare April 23, 2025 14:32
@timothy-nunn timothy-nunn merged commit 2840326 into main Apr 24, 2025
14 of 18 checks passed
@timothy-nunn timothy-nunn deleted the 3013-add-class-methods-for-each-current-drive-efficiency-calc-along-with-suitable-tests branch April 24, 2025 08:45
grmtrkngtn pushed a commit that referenced this pull request May 16, 2025
…uitable tests (#3621)

* ♻️ Refactor CurrentDrive initialization to include new classes for each current drive type

* ❇️ Add lower_hybrid_fenstermacher function to calculate lower hybrid frequency and update references in CurrentDrive class

* ✨ Add ion_cyclotron_ipdg89 function for calculating ion cyclotron heating efficiency and update documentation

* ✨ Add electron_cyclotron_fenstermacher function for calculating electron cyclotron heating efficiency and update related documentation

* ✨ Add lower_hybrid_ehst function for calculating Lower Hybrid current drive efficiency and update documentation

* ✨ Add electron_berstein_freethy function for calculating Electron Bernstein Wave current drive efficiency and refactor CurrentDrive class to utilize this new method

* ✨ Add electron_cyclotron_freethy function for calculating Electron Cyclotron current drive efficiency and refactor CurrentDrive class to utilize this new method

* ✨ Refactor CurrentDrive class to streamline current drive efficiency calculations using a dictionary of models and remove redundant code

* 🔄 Make eta_cd_hcd_secondary a proper current_drive variable

* ➕ Add calculation for the normalised secondary efficiency

* ✨ Create new current driven variables for the hcd systems

* ✨ Add calculations for secondary heating current drive efficiency and introduce new variables for driven current fractions

* 🔄 Rename pinjwpfix to p_hcd_secondary_electric_mw for clarity and consistency in current drive calculations

* 🔄 Rename variable plhybd to p_hcd_lowhyb_injected_total_mw for clarity and consistency in current drive calculations

* 🔄 Rename variable pnbeam to p_hcd_beam_injected_total_mw for clarity and consistency in current drive calculations

* ✨ Introduce p_hcd_primary_injected_mw variable and update calculations for primary heating power in current drive module

* ✨ Add variables for ion cyclotron and electron Bernstein wave injection power in current drive module

* ✨ Add injector wall plug efficiency variables for ion cyclotron and electron Bernstein wave in current drive module

* ♻️ Refactor current drive calculations to introduce p_hcd_secondary_ions_mw and update injected power handling for ion cyclotron cases

* 🔄 Rename pinjwp to p_hcd_electric_total_mw for clarity and update related calculations in current drive and heat transport modules

* ✨ Introduce p_hcd_primary_electric_mw variable and update calculations for primary heating power in heat transport module

* ♻️ Update current drive calculations to handle electron Bernstein wave cases and improve wall plug power efficiency

* ♻️ Refactor primary heating power calculations in current drive module for improved clarity and maintainability

* ✨ Add p_beam_plasma_coupled_mw variable to track neutral beam power coupled to plasma after losses

* 🔄 Rename echwpow to p_hcd_ecrh_electric_mw for clarity and update related data files

* ♻️ Update current drive calculations to include electron Bernstein wave power and improve wall plug efficiency

* ♻️ Rename pwplh to p_hcd_lowhyb_electric_mw for clarity and update related calculations and tests

* ✨ Add p_ebw_injected_mw variable to track electron Bernstein wave power and update related tests

* 📝 Enhance current drive reporting by adding extra power metrics and improving efficiency calculations

* 🔄 Rename fvsbrnni to f_c_plasma_non_inductive for clarity and update related data files and calculations

* 🔄 Rename inductive_current_fraction to f_c_plasma_inductive for clarity and update related calculations and documentation

* 🔄 Rename aux_current_fraction to f_c_plasma_auxiliary for clarity and update related calculations and data files

* 📝 Fix nbi in output

* Post rebase updates

* 🔄 Move legend function from CurrentDrive to ElectronCyclotron for better organization and clarity

* 🔄 Add initial data files and documentation for heating and current drive systems

* 🔄 Add p_hcd_injected_current_total_mw as a variable

* 🔄 Refactor current drive method calls for clarity and consistency

* 🔄 Refactor current drive method calls for clarity and consistency

* Re make current drive unit tests to new style, create case for lower hybrid

* 🔄 Refactor CurrentDrive initialization to instantiate cyclotron and beam classes directly
grmtrkngtn pushed a commit that referenced this pull request May 16, 2025
…uitable tests (#3621)

* ♻️ Refactor CurrentDrive initialization to include new classes for each current drive type

* ❇️ Add lower_hybrid_fenstermacher function to calculate lower hybrid frequency and update references in CurrentDrive class

* ✨ Add ion_cyclotron_ipdg89 function for calculating ion cyclotron heating efficiency and update documentation

* ✨ Add electron_cyclotron_fenstermacher function for calculating electron cyclotron heating efficiency and update related documentation

* ✨ Add lower_hybrid_ehst function for calculating Lower Hybrid current drive efficiency and update documentation

* ✨ Add electron_berstein_freethy function for calculating Electron Bernstein Wave current drive efficiency and refactor CurrentDrive class to utilize this new method

* ✨ Add electron_cyclotron_freethy function for calculating Electron Cyclotron current drive efficiency and refactor CurrentDrive class to utilize this new method

* ✨ Refactor CurrentDrive class to streamline current drive efficiency calculations using a dictionary of models and remove redundant code

* 🔄 Make eta_cd_hcd_secondary a proper current_drive variable

* ➕ Add calculation for the normalised secondary efficiency

* ✨ Create new current driven variables for the hcd systems

* ✨ Add calculations for secondary heating current drive efficiency and introduce new variables for driven current fractions

* 🔄 Rename pinjwpfix to p_hcd_secondary_electric_mw for clarity and consistency in current drive calculations

* 🔄 Rename variable plhybd to p_hcd_lowhyb_injected_total_mw for clarity and consistency in current drive calculations

* 🔄 Rename variable pnbeam to p_hcd_beam_injected_total_mw for clarity and consistency in current drive calculations

* ✨ Introduce p_hcd_primary_injected_mw variable and update calculations for primary heating power in current drive module

* ✨ Add variables for ion cyclotron and electron Bernstein wave injection power in current drive module

* ✨ Add injector wall plug efficiency variables for ion cyclotron and electron Bernstein wave in current drive module

* ♻️ Refactor current drive calculations to introduce p_hcd_secondary_ions_mw and update injected power handling for ion cyclotron cases

* 🔄 Rename pinjwp to p_hcd_electric_total_mw for clarity and update related calculations in current drive and heat transport modules

* ✨ Introduce p_hcd_primary_electric_mw variable and update calculations for primary heating power in heat transport module

* ♻️ Update current drive calculations to handle electron Bernstein wave cases and improve wall plug power efficiency

* ♻️ Refactor primary heating power calculations in current drive module for improved clarity and maintainability

* ✨ Add p_beam_plasma_coupled_mw variable to track neutral beam power coupled to plasma after losses

* 🔄 Rename echwpow to p_hcd_ecrh_electric_mw for clarity and update related data files

* ♻️ Update current drive calculations to include electron Bernstein wave power and improve wall plug efficiency

* ♻️ Rename pwplh to p_hcd_lowhyb_electric_mw for clarity and update related calculations and tests

* ✨ Add p_ebw_injected_mw variable to track electron Bernstein wave power and update related tests

* 📝 Enhance current drive reporting by adding extra power metrics and improving efficiency calculations

* 🔄 Rename fvsbrnni to f_c_plasma_non_inductive for clarity and update related data files and calculations

* 🔄 Rename inductive_current_fraction to f_c_plasma_inductive for clarity and update related calculations and documentation

* 🔄 Rename aux_current_fraction to f_c_plasma_auxiliary for clarity and update related calculations and data files

* 📝 Fix nbi in output

* Post rebase updates

* 🔄 Move legend function from CurrentDrive to ElectronCyclotron for better organization and clarity

* 🔄 Add initial data files and documentation for heating and current drive systems

* 🔄 Add p_hcd_injected_current_total_mw as a variable

* 🔄 Refactor current drive method calls for clarity and consistency

* 🔄 Refactor current drive method calls for clarity and consistency

* Re make current drive unit tests to new style, create case for lower hybrid

* 🔄 Refactor CurrentDrive initialization to instantiate cyclotron and beam classes directly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

HCD Relating to heating and current drive systems Refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add class methods for each current drive efficiency calc along with suitable tests

4 participants