Skip to content

Commit 632de11

Browse files
committed
Add cylindrical safety factor calculation to Physics model
1 parent 76a67a5 commit 632de11

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

process/models/physics/physics.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,52 @@
3131
logger = logging.getLogger(__name__)
3232

3333

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+
3480
@nb.jit(nopython=True, cache=True)
3581
def rether(
3682
alphan,
@@ -590,6 +636,15 @@ def physics(self):
590636
physics_variables.triang95,
591637
)
592638

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+
593648
# -----------------------------------------------------
594649
# Plasma Current Profile
595650
# -----------------------------------------------------

0 commit comments

Comments
 (0)