-
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
base: main
Are you sure you want to change the base?
❇️ ♻️ Create Beta class #4053
Conversation
7a93ce1 to
20e44af
Compare
20e44af to
ce7c700
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4053 +/- ##
==========================================
+ Coverage 46.49% 46.70% +0.20%
==========================================
Files 123 123
Lines 28777 29124 +347
==========================================
+ Hits 13381 13603 +222
- Misses 15396 15521 +125 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
3057b2c to
0d66af1
Compare
… redundant function from physics_functions.py
0d66af1 to
108a973
Compare
…ndant function from physics.py
00a9ee6 to
ec47444
Compare
…d remove redundant function
…or improved maintainability
| @property | ||
| def beta_norm_max_model_map(self): | ||
| """Mapping of beta norm max model indices to their calculated values.""" | ||
| return { | ||
| 0: physics_variables.beta_norm_max, | ||
| 1: physics_variables.beta_norm_max_wesson, | ||
| 2: physics_variables.beta_norm_max_original_scaling, | ||
| 3: physics_variables.beta_norm_max_menard, | ||
| 4: physics_variables.beta_norm_max_thloreus, | ||
| 5: physics_variables.beta_norm_max_stambaugh, | ||
| } |
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.
Can you turn this into an Enum
| @staticmethod | ||
| def calculate_beta_limit_from_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.
What is the speed impact of no longer JIT compiling this method?
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.
Can you move the calculations that are not depended on into the new Beta class and add run and output methods to this class.
That way in the caller we can do models.beta.run() (or models.beta.output()) which will run the Beta model (and output if appropriate). Some of the variables will need a bit of untangling (e.g. beta_poloidal_vol_avg which is used later on in physics to calculate f_c_plasma_bootstrap_sakai) but this can be done in a later PR.
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: