Skip to content

utils

Module to hold plotting functions, used in plot_proc.py, which are common to multiple reactor components

dh_vertices(r0, a, triang, kap)

Returns the radial and vertical coordinates which, when plotted, plots half a thin D-section, centred on z = 0

Parameters:

Name Type Description Default
r0 float

major radius of centre

required
a float

horizontal radius

required
triang float

plasma triangularity

required
kap float

plasma elongation

required

Returns:

Type Description
tuple[ndarray, ndarray]

tuple containing radial and vertical coordinates which, when plotted, plots a half thin D-section with a gap

Source code in process/models/geometry/utils.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def dh_vertices(
    r0: float, a: float, triang: float, kap: float
) -> tuple[np.ndarray, np.ndarray]:
    """Returns the radial and vertical coordinates which, when plotted, plots half a thin D-section, centred on z = 0

    Parameters
    ----------
    r0:
        major radius of centre
    a:
        horizontal radius
    triang:
        plasma triangularity
    kap:
        plasma elongation

    Returns
    -------
    :
        tuple containing radial and vertical coordinates which, when plotted, plots a half thin D-section with a gap
    """
    angs = np.linspace(0, np.pi, 50, endpoint=True)
    rs = r0 + a * np.cos(angs + triang * np.sin(1.0 * angs))
    zs = kap * a * np.sin(angs)
    return rs, zs

dhgap_vertices(inpt, outpt, inthk, outthk, toppt, topthk, triang)

Returns the radial and vertical coordinates which, when plotted, plots a half thick D-section with a gap

Parameters:

Name Type Description Default
inpt float

inner point

required
outpt float

outer point

required
inthk float

inner thickness

required
outthk float

outer thickness

required
toppt float

top point

required
topthk float

top thickness

required
triang float

plasma triangularity

required

Returns:

Type Description
tuple[ndarray, ndarray, ndarray, ndarray, ndarray, ndarray, ndarray, ndarray]

tuple containing radial and vertical coordinates which, when plotted, plots a half thick D-section with a gap

Source code in process/models/geometry/utils.py
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
def dhgap_vertices(
    inpt: float,
    outpt: float,
    inthk: float,
    outthk: float,
    toppt: float,
    topthk: float,
    triang: float,
) -> tuple[
    np.ndarray,
    np.ndarray,
    np.ndarray,
    np.ndarray,
    np.ndarray,
    np.ndarray,
    np.ndarray,
    np.ndarray,
]:
    """Returns the radial and vertical coordinates which, when plotted, plots a half thick D-section with a gap

    Parameters
    ----------
    inpt:
        inner point
    outpt:
        outer point
    inthk:
        inner thickness
    outthk:
        outer thickness
    toppt:
        top point
    topthk:
        top thickness
    triang:
        plasma triangularity

    Returns
    -------
    :
        tuple containing radial and vertical coordinates which, when plotted, plots a half thick D-section with a gap
    """
    arc = np.pi / 4.0
    r01 = (inpt + outpt) / 2.0
    r02 = (inpt + inthk + outpt - outthk) / 2.0
    a1 = r01 - inpt
    a2 = r02 - inpt - inthk
    kap1 = toppt / a1
    kap2 = (toppt - topthk) / a2
    angs = np.linspace(0.0, (np.pi / 2.0) - arc / 2.0, 50, endpoint=True)
    rs1 = r01 + a1 * np.cos(angs + triang * np.sin(angs))
    zs1 = kap1 * a1 * np.sin(angs)
    rs2 = r02 + a2 * np.cos(angs + triang * np.sin(angs))
    zs2 = kap2 * a2 * np.sin(angs)
    angs = np.linspace(np.pi, np.pi + ((np.pi / 2.0) - arc), 50, endpoint=True)
    rs3 = r01 + a1 * np.cos(angs + triang * np.sin(angs))
    zs3 = kap1 * a1 * np.sin(angs)
    rs4 = r02 + a2 * np.cos(angs + triang * np.sin(angs))
    zs4 = kap2 * a2 * np.sin(angs)

    return rs1, rs2, rs3, rs4, zs1, zs2, zs3, zs4

ellips_fill_vertices(a1=0, a2=0, b1=0, b2=0, x0=0, y0=0, ang1=0, ang2=np.pi / 2)

Returns the vertices of a shape which, when filled, fills the space between two concentric ellipse sectors

Parameters:

Name Type Description Default
a1 float

horizontal radius to be filled, defaults to 0

0
a2 float

horizontal radius to be filled, defaults to 0

0
b1 float

vertical radius to be filled, defaults to 0

0
b2 float

vertical radius to be filled, defaults to 0

0
x0 float

x coordinate of centre of ellipses, defaults to 0

0
y0 float

y coordinate of centre of ellipses, defaults to 0

0
ang1 float

polar angle at start, defaults to 0

0
ang2 float

polar angle at end, defaults to np.pi/2

pi / 2

Returns:

Type Description
list[tuple[float, float]]

list containing (R,Z) coordinates which, when plotted, fill space between ellipses

Source code in process/models/geometry/utils.py
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
def ellips_fill_vertices(
    a1: float = 0,
    a2: float = 0,
    b1: float = 0,
    b2: float = 0,
    x0: float = 0,
    y0: float = 0,
    ang1: float = 0,
    ang2: float = np.pi / 2,
) -> list[tuple[float, float]]:
    """Returns the vertices of a shape which, when filled, fills the space between two concentric ellipse sectors

    Parameters
    ----------
    a1:
        horizontal radius to be filled, defaults to 0
    a2:
        horizontal radius to be filled, defaults to 0
    b1:
        vertical radius to be filled, defaults to 0
    b2:
        vertical radius to be filled, defaults to 0
    x0:
        x coordinate of centre of ellipses, defaults to 0
    y0:
        y coordinate of centre of ellipses, defaults to 0
    ang1:
        polar angle at start, defaults to 0
    ang2:
        polar angle at end, defaults to np.pi/2

    Returns
    -------
    :
        list containing (R,Z) coordinates which, when plotted, fill space between ellipses
    """
    angs = np.linspace(ang1, ang2, endpoint=True)
    r1 = ((np.cos(angs) / a1) ** 2 + (np.sin(angs) / b1) ** 2) ** (-0.5)
    xs1 = r1 * np.cos(angs) + x0
    ys1 = r1 * np.sin(angs) + y0
    angs = np.linspace(ang2, ang1, endpoint=True)
    r2 = ((np.cos(angs) / a2) ** 2 + (np.sin(angs) / b2) ** 2) ** (-0.5)
    xs2 = r2 * np.cos(angs) + x0
    ys2 = r2 * np.sin(angs) + y0
    verts = list(zip(xs1, ys1, strict=False))
    verts.extend(list(zip(xs2, ys2, strict=False)))
    endpoint = verts[-1:]
    verts.extend(endpoint)

    return verts