Contour¶
device_inductance.contour ¶
Specialized contour-tracing algo for finding the last closed flux contour defining the edge of a tokamak plasma.
Among other uses, this contour is needed in order to estimate the plasma's self-inductance.
trace_contour ¶
trace_contour(
grids: tuple[NDArray, NDArray],
psi_total: NDArray,
start: tuple[float, float],
maxis: tuple[float, float],
limiter_circumference: float,
mask_limiter: NDArray,
ds: float = 0.01,
tol: float = 0.0001,
) -> tuple[NDArray, NDArray] | None
Specialized contour-tracing algo for finding the last closed flux contour defining the edge of a tokamak plasma. Among other uses, this contour is needed in order to estimate the plasma's self-inductance.
Attempts to trace a closed contour starting at start and returns None
if the contour crosses the limiter or does not make a full loop, or if
the resulting contour ends up being excessively long (longer than the limiter).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grids
|
tuple[NDArray, NDArray]
|
[m] 1D coordinate grids for computational domain |
required |
psi_total
|
NDArray
|
[T-m^2] 2D grid of total poloidal flux |
required |
start
|
tuple[float, float]
|
[m] Initial guess coordinates |
required |
maxis
|
tuple[float, float]
|
[m] Magnetic axis coords from O-point search |
required |
limiter_circumference
|
float
|
[m] Limiter length in R-Z plane, to bound expected contour length |
required |
mask_limiter
|
NDArray
|
Float mask of limiter interior (1.0 inside, 0.0 outside) |
required |
ds
|
float
|
[m] Step size. Defaults to 1e-2. |
0.01
|
tol
|
float
|
[T-m^2] Contour flux level tolerance. Defaults to 1e-4. |
0.0001
|
Returns:
| Type | Description |
|---|---|
tuple[NDArray, NDArray] | None
|
Optional[(rpath, zpath)] contour path coordinates if a closed loop was found |
Source code in src/device_inductance/contour.py
17 18 19 20 21 22 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 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 148 149 150 151 152 153 | |