|
31 | 31 | logger = logging.getLogger(__name__) |
32 | 32 |
|
33 | 33 |
|
| 34 | +def calculate_cylindrical_safety_factor( |
| 35 | + rmajor: float, |
| 36 | + rminor: float, |
| 37 | + plasma_current: float, |
| 38 | + b_plasma_toroidal_on_axis: float, |
| 39 | + kappa95: float, |
| 40 | + triang95: float, |
| 41 | +) -> float: |
| 42 | + """Calculate the cylindrical safety factor from the IPDG89 guidelines. |
| 43 | +
|
| 44 | + Parameters |
| 45 | + ---------- |
| 46 | + rmajor : float |
| 47 | + Major radius of the tokamak in meters. |
| 48 | + rminor : float |
| 49 | + Minor radius of the tokamak in meters. |
| 50 | + plasma_current : float |
| 51 | + Plasma current in amperes. |
| 52 | + b_plasma_toroidal_on_axis : float |
| 53 | + Toroidal magnetic field on axis in tesla. |
| 54 | + kappa95 : float |
| 55 | + Elongation at 95% of the plasma boundary. |
| 56 | + triang95 : float |
| 57 | + Triangularity at 95% of the plasma boundary. |
| 58 | + Returns |
| 59 | + ------- |
| 60 | + float |
| 61 | + Cylindrical safety factor (dimensionless). |
| 62 | + Notes |
| 63 | + ----- |
| 64 | + The cylindrical safety factor is calculated following the IPDG89 guidelines. |
| 65 | + The formula accounts for plasma elongation and triangularity effects on the |
| 66 | + safety factor through the kappa95 and triang95 parameters. |
| 67 | +
|
| 68 | + """ |
| 69 | + |
| 70 | + # Calculate cyclindrical safety factor from IPDG89 |
| 71 | + return ( |
| 72 | + ((2 * np.pi) / constants.RMU0) |
| 73 | + * rminor**2 |
| 74 | + / (rmajor * plasma_current / b_plasma_toroidal_on_axis) |
| 75 | + * 0.5 |
| 76 | + * (1.0 + kappa95**2 * (1.0 + 2.0 * triang95**2 - 1.2 * triang95**3)) |
| 77 | + ) |
| 78 | + |
| 79 | + |
34 | 80 | @nb.jit(nopython=True, cache=True) |
35 | 81 | def rether( |
36 | 82 | alphan, |
@@ -590,6 +636,15 @@ def physics(self): |
590 | 636 | physics_variables.triang95, |
591 | 637 | ) |
592 | 638 |
|
| 639 | + physics_variables.qstar = calculate_cylindrical_safety_factor( |
| 640 | + rmajor=physics_variables.rmajor, |
| 641 | + rminor=physics_variables.rminor, |
| 642 | + plasma_current=physics_variables.plasma_current, |
| 643 | + b_plasma_toroidal_on_axis=physics_variables.b_plasma_toroidal_on_axis, |
| 644 | + kappa95=physics_variables.kappa95, |
| 645 | + triang95=physics_variables.triang95, |
| 646 | + ) |
| 647 | + |
593 | 648 | # ----------------------------------------------------- |
594 | 649 | # Plasma Current Profile |
595 | 650 | # ----------------------------------------------------- |
|
0 commit comments