Magnetic Fields and Coils
There are a number of ways for representing arbitrary magnetic fields in the lab
(\(R, \phi, Z\)) frame. Their common characteristic is a compute_magnetic_field
method allowing evaluation of \(\mathbf{B}\) at points in space.
Magnetic Fields
The desc.magnetic_fields
module contains classes representing a number of standard
field configurations, as well as classes for combining and scaling these fields.
For interfacing with MAKEGRID type files, the SplineMagneticField
class has a
from_mgrid
option allowing you to load an mgrid file and interpolate where needed.
All MagneticField objects also have a save_mgrid method to save field data so that
it can be read by VMEC and STELLOPT. They also have a compute_Bnormal method which accepts
a surface and computes the normal field strength on that surface.
Magnetic field from precomputed values on a grid. |
|
Magnetic field due to a Dommaschk scalar magnetic potential in rpz coordinates. |
|
Magnetic field due to a scalar magnetic potential in cylindrical coordinates. |
|
Magnetic field purely in the toroidal (phi) direction. |
|
Uniform magnetic field purely in the vertical (Z) direction. |
|
Pure poloidal magnetic field (ie in theta direction). |
|
Magnetic field scaled by a scalar value. |
|
Sum of two or more magnetic field sources. |
There are also classes for representing a current potential on a winding surface:
Magnetic field due to a surface current potential on a toroidal surface. |
|
Magnetic field due to a surface current potential on a toroidal surface. |
There is also a class for representing omnigenous magnetic fields:
|
A magnetic field with perfect omnigenity (but is not necessarily analytic). |
For analyzing the structure of magnetic fields, it is often useful to find the trajectories
of magnetic field lines, which can be done via desc.magnetic_fields.field_line_integrate
.
Trace field lines by integration. |
desc.magnetic_fields
also contains a utility function for reading output files from
the BNORM code:
|
Read BNORM-style .txt file containing Bnormal Fourier coefficients. |
Coils
Coil
objects in desc.coils
are themselves subclasses of MagneticField
, allowing
them to be used anywhere that expects a magnetic field type. There are a number of parameterizations
based on the Curve
classes defined in desc.geometry
(which, since they are based on Curve
classes, can also use the same Curve
conversion methods to convert between coil representations):
|
Coil parameterized by fourier series for R,Z in terms of toroidal angle phi. |
|
Coil parameterized by fourier series for X,Y,Z in terms of arbitrary angle s. |
|
Coil that lines in a plane. |
|
Coil parameterized by spline points in X,Y,Z. |
There are also objects for holding a collection of coils with efficient methods for
evaluating the combined field. A CoilSet
must consist of members with the same
parameterization, while a MixedCoilSet
can contain arbitrary types (including
another CoilSet
).
|
Set of coils of different geometry but shared parameterization and resolution. |
|
Set of coils or coilsets of different geometry. |
DESC CoilSet
or MixedCoilSet
objects can also be created from MAKEGRID-formatted coil text files via
the from_makegrid_coilfile method. They can also be saved in a MAKEGRID-formatted text file with
the save_in_makegrid_format method.