coilpy.dipole#
- class coilpy.dipole.Dipole(**kwargs)[source]#
Bases:
object
magnetic dipole class
- bfield(pos)[source]#
- Calculate the magnetic field at an arbitrary position.
No symmetry info considered for now.
- Parameters:
pos (array_like) – [x,y,z] Cartesian coordinates in space.
- Returns:
The total magnetic field produced by all dipoles
- Return type:
numpy.array
- classmethod from_regcoil(regcoilname, winding, ilambda=-1, symmetry='full', num_pol=128, num_tor=128, m0=None, half_shift=True)[source]#
Initialize from REGCOIL current potential
- Parameters:
regcoilname (str) – REGCOIL netcdf output file.
winding (str, optional) – NESCOIL input format winding surface.
ilambda (int, optional) – Lambda index in REGCOIL output. Defaults to -1.
symmetry (str, optional) – Stellarator symmetry option. Defaults to ‘full’.
num_pol (int, optional) – Number of poloidal dipoles. Defaults to 128.
num_tor (int, optional) – Number of toroidal dipoles. Defaults to 128.
m0 ([type], optional) – Magnetization limit per thickness. Defaults to None.
half_shift (bool, optional) – Logical flag to determine if half-grid shifted. Defaults to True.
- Returns:
None
- mimic(template, **kwargs)[source]#
Mimic rho, mp, mt following the “template” dipole set
- Parameters:
template (Dipole class) – The template Dipole class to be mirrored.
- Returns:
None
- Return type:
None
- classmethod open(filename, verbose=False, **kwargs)[source]#
Read FAMUS dipoles
- Parameters:
filename (str) – path to open the file.
verbose (bool, optional) – Whether to print additional info. Defaults to False.
- Returns:
Dipole class
- Return type:
- classmethod read_dipole_old(filename, zeta=0.0, zeta1=6.283185307179586, **kwargs)[source]#
read diploes from FOCUS format (old)
- Parameters:
filename (str) – path to open the file.
zeta (float, optional) – Starting toroidal angle for clipping. Defaults to 0.0.
zeta1 (float, optional) – [Ending toroidal angle for clipping]. Defaults to np.pi*2.
- Returns:
Dipole class
- Return type:
- round_angle()[source]#
round off the moment orientation to the closest preferred axis
- Returns:
return a new dipole class with rounded orientations
- Return type:
Dipole class
- save(filename, unique=False, tol=0)[source]#
write diploes from FOCUS format
- Parameters:
filename (str) – FOCUS file name.
unique (bool, optional) – Writing dipole every self.nfp term. Defaults to False.
tol (float, optional) – tolerance to skip zeros. Defaults to 0.
- toVTK(vtkname, dim=1, close=False, ntnz=False, toroidal=False, **kwargs)[source]#
write dipole data into a VTK file
- Parameters:
vtkname (str) – VTK filename, will be appended with .vts or .vtu.
dim (tuple, optional) – Dimension information if saved as structured grids. Defaults to (1).
close (bool, optional) – Logical flag to manually close the gaps. Defaults to False.
ntnz (bool, optional) – Logical flag of theta-zeta order. Defaults to False.
toroidal (bool, optional) – Logical flag of filling in the toroidal gap. Defaults to False.
- Returns:
None