-
Notifications
You must be signed in to change notification settings - Fork 18
Create diamagnetic current class #4156
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
Changes from all commits
2812e75
ccda10a
7b58d45
a28edaa
8d1fc53
f4a768a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,18 @@ | ||
| import logging | ||
| from enum import IntEnum | ||
| from types import DynamicClassAttribute | ||
|
|
||
| import matplotlib.pyplot as plt | ||
| import numba as nb | ||
| import numpy as np | ||
|
|
||
| import process.core.io.mfile as mf | ||
| from process.core import constants | ||
| from process.core import process_output as po | ||
| from process.core.exceptions import ProcessValueError | ||
| from process.core.model import Model | ||
| from process.data_structure import ( | ||
| current_drive_variables, | ||
| physics_variables, | ||
| ) | ||
|
|
||
|
|
@@ -29,9 +33,13 @@ class PlasmaCurrentModel(IntEnum): | |
| def __new__(cls, value, full_name): | ||
| obj = int.__new__(cls, value) | ||
| obj._value_ = value | ||
| obj.full_name = full_name | ||
| obj._full_name_ = full_name | ||
| return obj | ||
|
|
||
| @DynamicClassAttribute | ||
| def full_name(self): | ||
| return self._full_name_ | ||
|
|
||
|
|
||
| class PlasmaCurrent: | ||
| """Class to hold plasma current calculations for plasma processing.""" | ||
|
|
@@ -925,3 +933,116 @@ def calculate_current_coefficient_fiesta( | |
| Volume 154, 2020, 111530, ISSN 0920-3796, https://doi.org/10.1016/j.fusengdes.2020.111530. | ||
| """ | ||
| return 0.538 * (1.0 + 2.440 * eps**2.736) * kappa**2.154 * triang**0.060 | ||
|
|
||
|
|
||
| class PlasmaDiamagneticCurrentModel(IntEnum): | ||
| """Enum for plasma diamagnetic current method types""" | ||
|
|
||
| NONE = (0, "None") | ||
| HENDER_ST_FIT = (1, "Hender ST fit") | ||
| SCENE_FIT = (2, "SCENE fit") | ||
|
|
||
| def __new__(cls, value, full_name): | ||
| obj = int.__new__(cls, value) | ||
| obj._value_ = value | ||
| obj._full_name_ = full_name | ||
| return obj | ||
|
|
||
| @DynamicClassAttribute | ||
| def full_name(self): | ||
| return self._full_name_ | ||
|
|
||
|
|
||
| class PlasmaDiamagneticCurrent(Model): | ||
| """Class to hold plasma diamagnetic current calculations for plasma processing.""" | ||
|
|
||
| def __init__(self): | ||
| self.outfile = constants.NOUT | ||
| self.mfile = constants.MFILE | ||
|
|
||
| def run(self): | ||
| # Hender scaling for diamagnetic current at tight physics_variables.aspect ratio | ||
| current_drive_variables.f_c_plasma_diamagnetic_hender = ( | ||
| self.diamagnetic_fraction_hender(physics_variables.beta_total_vol_avg) | ||
| ) | ||
|
|
||
| # SCENE scaling for diamagnetic current | ||
| current_drive_variables.f_c_plasma_diamagnetic_scene = ( | ||
| self.diamagnetic_fraction_scene( | ||
| physics_variables.beta_total_vol_avg, | ||
| physics_variables.q95, | ||
| physics_variables.q0, | ||
| ) | ||
| ) | ||
|
|
||
| if ( | ||
| physics_variables.i_diamagnetic_current | ||
| == PlasmaDiamagneticCurrentModel.HENDER_ST_FIT | ||
| ): | ||
| current_drive_variables.f_c_plasma_diamagnetic = ( | ||
| current_drive_variables.f_c_plasma_diamagnetic_hender | ||
| ) | ||
| elif ( | ||
| physics_variables.i_diamagnetic_current | ||
| == PlasmaDiamagneticCurrentModel.SCENE_FIT | ||
| ): | ||
| current_drive_variables.f_c_plasma_diamagnetic = ( | ||
| current_drive_variables.f_c_plasma_diamagnetic_scene | ||
| ) | ||
|
|
||
|
Comment on lines
+978
to
+992
|
||
| def output(self): | ||
| po.oblnkl(self.outfile) | ||
| po.ovarrf( | ||
| self.outfile, | ||
| "Diamagnetic fraction (Hender)", | ||
| "(f_c_plasma_diamagnetic_hender)", | ||
| current_drive_variables.f_c_plasma_diamagnetic_hender, | ||
| "OP ", | ||
| ) | ||
| po.ovarrf( | ||
| self.outfile, | ||
| "Diamagnetic fraction (SCENE)", | ||
| "(f_c_plasma_diamagnetic_scene)", | ||
| current_drive_variables.f_c_plasma_diamagnetic_scene, | ||
| "OP ", | ||
| ) | ||
| po.oblnkl(self.outfile) | ||
|
|
||
| @staticmethod | ||
| @nb.njit(cache=True) | ||
| def diamagnetic_fraction_hender(beta: float) -> float: | ||
| """Calculate the diamagnetic fraction based on the Hender fit. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| beta : | ||
| the plasma beta value | ||
|
|
||
| Returns | ||
| ------- | ||
| float | ||
| the diamagnetic fraction | ||
|
|
||
| """ | ||
| return beta / 2.8 | ||
|
|
||
| @staticmethod | ||
| @nb.njit(cache=True) | ||
| def diamagnetic_fraction_scene(beta: float, q95: float, q0: float) -> float: | ||
| """Calculate the diamagnetic fraction based on the SCENE fit by Tim Hender. | ||
|
Comment on lines
+1011
to
+1032
|
||
|
|
||
| Parameters | ||
| ---------- | ||
| beta : | ||
| the plasma beta value | ||
| q95 : | ||
| the normalized safety factor at 95% of the plasma radius | ||
| q0 : | ||
| the normalized safety factor at the magnetic axis | ||
|
|
||
| Returns | ||
| ------- | ||
| float | ||
| the diamagnetic fraction | ||
| """ | ||
| return beta * (0.1 * q95 / q0 + 0.44) * 0.414 | ||
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.
There are extra trailing spaces before the newline in the plasma current line (
... MA \n). This can produce odd spacing/wrapping in the rendered matplotlib text and is inconsistent with the other lines. Remove the trailing spaces unless they are required for a specific alignment behavior.