Skip to content

plasma

Calculate plasma elongation and radial and vertical coordinates for the geometry of the plasma

PlasmaGeometry dataclass

Holds radial and vertical coordinates for the geometry of a plasma

Source code in process/models/geometry/plasma.py
11
12
13
14
15
16
17
18
19
20
@dataclass
class PlasmaGeometry:
    """Holds radial and vertical coordinates for the geometry of a plasma"""

    rs: np.ndarray
    """radial plasma coordinates"""
    zs: np.ndarray
    """vertical plasma coordinates"""
    kappa: float
    """plasma separatrix elongation"""

rs instance-attribute

radial plasma coordinates

zs instance-attribute

vertical plasma coordinates

kappa instance-attribute

plasma separatrix elongation

plasma_geometry(rmajor, rminor, triang, kappa, i_single_null, i_plasma_shape, square)

Calculates radial and vertical distances and plasma elongation for the geometry of the plasma.

This function computes the radial and vertical coordinates of the plasma boundary, as well as the plasma elongation, based on the given major radius, minor radius, triangularity, and elongation at 95% of the plasma surface. It also considers whether the plasma configuration is single null or double null.

Parameters:

Name Type Description Default
rmajor float

Plasma major radius.

required
rminor float

Plasma minor radius.

required
triang float

Plasma triangularity at separatrix.

required
kappa float

Plasma elongation at separatrix.

required
i_single_null int

Switch for single null (1) or double null (0) plasma configuration.

required
i_plasma_shape int

Switch for plasma shape (0 for double arc, 1 for Sauter).

required
square float

Square term for Sauter plasma shape.

required

Returns:

Type Description
PlasmaGeometry

A dataclass containing the plasma elongation and the radial and vertical coordinates of the plasma.

Source code in process/models/geometry/plasma.py
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
def plasma_geometry(
    rmajor: float,
    rminor: float,
    triang: float,
    kappa: float,
    i_single_null: int,
    i_plasma_shape: int,
    square: float,
) -> PlasmaGeometry:
    """Calculates radial and vertical distances and plasma elongation for the geometry of the plasma.

    This function computes the radial and vertical coordinates of the plasma boundary, as well as the plasma elongation,
    based on the given major radius, minor radius, triangularity, and elongation at 95% of the plasma surface. It also
    considers whether the plasma configuration is single null or double null.

    Parameters
    ----------
    rmajor:
        Plasma major radius.
    rminor:
        Plasma minor radius.
    triang:
        Plasma triangularity at separatrix.
    kappa:
        Plasma elongation at separatrix.
    i_single_null:
        Switch for single null (1) or double null (0) plasma configuration.
    i_plasma_shape:
        Switch for plasma shape (0 for double arc, 1 for Sauter).
    square:
        Square term for Sauter plasma shape.

    Returns
    -------
    PlasmaGeometry
        A dataclass containing the plasma elongation and the radial and vertical coordinates of the plasma.
    """

    # Original PROCESS double arc plasma shape
    if i_plasma_shape == 0:
        x1 = (2.0 * rmajor * (1.0 + triang) - rminor * (triang**2 + kappa**2 - 1.0)) / (
            2.0 * (1.0 + triang)
        )
        x2 = (2.0 * rmajor * (triang - 1.0) - rminor * (triang**2 + kappa**2 - 1.0)) / (
            2.0 * (triang - 1.0)
        )
        r1 = 0.5 * math.sqrt(
            (rminor**2 * ((triang + 1.0) ** 2 + kappa**2) ** 2) / ((triang + 1.0) ** 2)
        )
        r2 = 0.5 * math.sqrt(
            (rminor**2 * ((triang - 1.0) ** 2 + kappa**2) ** 2) / ((triang - 1.0) ** 2)
        )
        theta1 = np.arcsin((kappa * rminor) / r1)
        theta2 = np.arcsin((kappa * rminor) / r2)
        inang = 1.0 / r1
        outang = 1.5 / r2
        if i_single_null == 0:
            angs1 = np.linspace(
                -(inang + theta1) + np.pi, (inang + theta1) + np.pi, 500, endpoint=True
            )
            angs2 = np.linspace(
                -(outang + theta2), (outang + theta2), 500, endpoint=True
            )
        else:
            angs1 = np.linspace(
                -theta1 + np.pi, (inang + theta1) + np.pi, 500, endpoint=True
            )
            angs2 = np.linspace(-(outang + theta2), theta2, 500, endpoint=True)

        xs1 = -(r1 * np.cos(angs1) - x1)
        ys1 = r1 * np.sin(angs1)
        xs2 = -(r2 * np.cos(angs2) - x2)
        ys2 = r2 * np.sin(angs2)

        rs = [xs1, xs2]
        zs = [ys1, ys2]

        return PlasmaGeometry(rs=rs, zs=zs, kappa=kappa)

    # Sauter plasma shape
    if i_plasma_shape == 1:
        x = np.linspace(-np.pi, np.pi, 256)

        # Sauter
        return PlasmaGeometry(
            rs=rmajor + rminor * np.cos(x + triang * np.sin(x) - square * np.sin(2 * x)),
            zs=kappa * rminor * np.sin(x + square * np.sin(2 * x)),
            kappa=kappa,
        )

    # Explicit return statement at the end of the function
    return None