freegsnke.shaped_coil module
Define a class of coil which contains a uniform current density over a shaped region.
Copyright 2019 Ben Dudson, University of York. Email: benjamin.dudson@york.ac.uk
This file is part of FreeGSNKE.
FreeGSNKE is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
FreeGSNKE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with FreeGSNKE. If not, see <http://www.gnu.org/licenses/>.
- class freegsnke.shaped_coil.ShapedCoil(shape: list[tuple[float, float]], current: float = 0.0, turns: int = 1, control: bool = True, npoints: int = 6)[source]
Bases:
CoilRepresents a coil with a uniform current density over a polygonal region.
The total toroidal current carried by the coil block is
current * turns.- property R: float
Major radius of the coil centre in m.
- Returns:
Mean radial position of the outline vertices.
- Return type:
float
- property Z: float
Height of the coil centre in m.
- Returns:
Mean vertical position of the outline vertices.
- Return type:
float
- __init__(shape: list[tuple[float, float]], current: float = 0.0, turns: int = 1, control: bool = True, npoints: int = 6) None[source]
Set the coil outline, current, turns and quadrature order.
- Parameters:
shape (list of (float, float)) – Outline of the coil shape as a list of points
[(r1, z1), (r2, z2), ...]in m. Must have more than two points.current (float, optional) – The current in the circuit in A. The total current is
current * turns.turns (int, optional) – Number of turns in the coil block.
control (bool, optional) – Enable or disable control system.
npoints (int, optional) – Number of quadrature points per triangle. Valid choices: 1, 3, 6.
- property area: float
Fixed polygon cross-sectional area.
- Returns:
Area in m^2.
- Return type:
float
- controlBr(R: float | ndarray, Z: float | ndarray) float | ndarray[source]
Calculate radial magnetic field Br at (R, Z) due to a unit current.
Sums the weighted contributions of the quadrature points.
- Parameters:
R (float or np.ndarray) – Radial coordinate(s) in m.
Z (float or np.ndarray) – Vertical coordinate(s) in m.
- Returns:
The quantity at (R, Z) per unit coil current.
- Return type:
float or np.ndarray
- controlBz(R: float | ndarray, Z: float | ndarray) float | ndarray[source]
Calculate vertical magnetic field Bz at (R, Z) due to a unit current.
Sums the weighted contributions of the quadrature points.
- Parameters:
R (float or np.ndarray) – Radial coordinate(s) in m.
Z (float or np.ndarray) – Vertical coordinate(s) in m.
- Returns:
The quantity at (R, Z) per unit coil current.
- Return type:
float or np.ndarray
- controlPsi(R: float | ndarray, Z: float | ndarray) float | ndarray[source]
Calculate poloidal flux at (R, Z) due to a unit current.
Sums the weighted contributions of the quadrature points.
- Parameters:
R (float or np.ndarray) – Radial coordinate(s) in m.
Z (float or np.ndarray) – Vertical coordinate(s) in m.
- Returns:
The quantity at (R, Z) per unit coil current.
- Return type:
float or np.ndarray
- copy() ShapedCoil[source]
Copy the polygon and quadrature points while preserving coil settings.
- Returns:
The copied coil.
- Return type:
- dtype = dtype([('RZlen', '<i8'), ('R', '<f8', (10,)), ('Z', '<f8', (10,)), ('current', '<f8'), ('turns', '<i8'), ('control', '?'), ('npoints', '<i8')])
- classmethod from_numpy_array(value: ndarray) ShapedCoil[source]
Restore the coil polygon and settings from a structured record.
- Parameters:
value (np.ndarray) – Structured array with dtype
ShapedCoil.dtype.- Returns:
The restored coil.
- Return type:
- Raises:
ValueError – If
value.dtypedoes not matchShapedCoil.dtype.
- plot(axis: object | None = None, show: bool = False) object[source]
Plot the coil shape, using axis if given.
- Parameters:
axis (matplotlib.axes.Axes, optional) – Axis to plot on. A new figure is created if None.
show (bool, optional) – Unused.
- Returns:
The axis plotted on.
- Return type:
matplotlib.axes.Axes