-
Notifications
You must be signed in to change notification settings - Fork 17
❇️ ♻️ Create Beta class #4053
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
❇️ ♻️ Create Beta class #4053
Conversation
20e44af to
ce7c700
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4053 +/- ##
==========================================
+ Coverage 46.47% 46.49% +0.02%
==========================================
Files 123 124 +1
Lines 28902 28955 +53
==========================================
+ Hits 13432 13464 +32
- Misses 15470 15491 +21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
00a9ee6 to
ec47444
Compare
bdebe55 to
c75741c
Compare
…roved clarity and maintainability
… redundant function from physics_functions.py
…ndant function from physics.py
…d remove redundant function
…or improved maintainability
…d and improve error handling
…esson, Original Scaling, Menard, Tholerus, and Stambaugh relations
…variable formatting
…roved organization and maintainability
c75741c to
6e872d5
Compare
timothy-nunn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think some more calculations can be moved into the new class
process/physics.py
Outdated
| # Normalised beta from Troyon beta limit | ||
| physics_variables.beta_norm_total = self.beta.calculate_normalised_beta( | ||
| beta=physics_variables.beta_total_vol_avg, | ||
| rminor=physics_variables.rminor, | ||
| c_plasma=physics_variables.plasma_current, | ||
| b_field=physics_variables.b_plasma_toroidal_on_axis, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can go into the Beta.run section
process/physics.py
Outdated
| physics_variables.beta_norm_max_wesson = ( | ||
| self.beta.calculate_beta_norm_max_wesson( | ||
| ind_plasma_internal_norm=physics_variables.ind_plasma_internal_norm | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this calculation
process/physics.py
Outdated
| # Original scaling law | ||
| physics_variables.beta_norm_max_original_scaling = ( | ||
| self.calculate_beta_norm_max_original(eps=physics_variables.eps) | ||
| self.beta.calculate_beta_norm_max_original(eps=physics_variables.eps) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this one
process/physics.py
Outdated
| physics_variables.beta_norm_max_menard = self.calculate_beta_norm_max_menard( | ||
| eps=physics_variables.eps | ||
| physics_variables.beta_norm_max_menard = ( | ||
| self.beta.calculate_beta_norm_max_menard(eps=physics_variables.eps) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this one
process/physics.py
Outdated
| physics_variables.beta_norm_max_thloreus = ( | ||
| self.beta.calculate_beta_norm_max_thloreus( | ||
| c_beta=physics_variables.c_beta, | ||
| pres_plasma_on_axis=physics_variables.pres_plasma_thermal_on_axis, | ||
| pres_plasma_vol_avg=physics_variables.pres_plasma_thermal_vol_avg, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this one
process/physics.py
Outdated
| physics_variables.beta_norm_max_stambaugh = ( | ||
| self.calculate_beta_norm_max_stambaugh( | ||
| self.beta.calculate_beta_norm_max_stambaugh( | ||
| f_c_plasma_bootstrap=current_drive_variables.f_c_plasma_bootstrap, | ||
| kappa=physics_variables.kappa, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this one
process/physics.py
Outdated
| try: | ||
| model = BetaNormMaxModel(int(physics_variables.i_beta_norm_max)) | ||
| physics_variables.beta_norm_max = self.beta.get_beta_norm_max_value(model) | ||
| except ValueError: | ||
| raise ProcessValueError( | ||
| "Illegal value of i_beta_norm_max", | ||
| i_beta_norm_max=physics_variables.i_beta_norm_max, | ||
| ) | ||
| ) from None | ||
|
|
||
| # calculate_beta_limit() returns the beta_vol_avg_max for beta | ||
| physics_variables.beta_vol_avg_max = calculate_beta_limit( | ||
| physics_variables.b_plasma_toroidal_on_axis, | ||
| physics_variables.beta_norm_max, | ||
| physics_variables.plasma_current, | ||
| physics_variables.rminor, | ||
| physics_variables.beta_vol_avg_max = self.beta.calculate_beta_limit_from_norm( | ||
| b_plasma_toroidal_on_axis=physics_variables.b_plasma_toroidal_on_axis, | ||
| beta_norm_max=physics_variables.beta_norm_max, | ||
| plasma_current=physics_variables.plasma_current, | ||
| rminor=physics_variables.rminor, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this bit?
3005857 to
6e872d5
Compare
…ved organization and maintainability
This pull request introduces a new
PlasmaBetaclass to centralize and standardize plasma beta calculations across the codebase. The changes refactor existing code to use this class, update dependencies, and add new unit tests for its methods. The most important changes are grouped below:Core Refactoring and Architecture:
Added a new
PlasmaBetaclass toprocess.physicsand refactored the codebase to use this class for all plasma beta-related calculations, replacing previous standalone functions.Updated the initialization of major classes (
main.py,stellarator.py) to instantiate and passPlasmaBetaobjects where needed, ensuring consistent access to beta calculations throughout the application.Code Cleanup and Removal:
Removed the now-obsolete
fast_alpha_betafunction fromprocess/physics_functions.py, migrating its logic to the newPlasmaBetaclass.Updated all usages of beta calculation functions to use the new class methods, including replacing calls in the
Stellaratormodel.Testing and Validation:
test_physics.pyandtest_stellarator.pyto use the newPlasmaBetaclass and its methods, ensuring all previous tests remain valid and comprehensive.PlasmaBetamethods, such ascalculate_normalised_betaandcalculate_plasma_energy_from_beta, to improve coverage and reliability.Dependency and Import Updates:
PlasmaBetaclass.These changes improve maintainability by centralizing plasma beta logic, reduce code duplication, and enhance test coverage.## Description
Checklist
I confirm that I have completed the following checks: