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. |
|
Wrap an arbitrary function for calculating magnetic field in lab 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. |
desc.magnetic_fields also has a function which can solve a regularized least-squares problem
in order to find the optimal surface current distribution which minimizes the normal field on a
given plasma boundary, desc.magnetic_fields.solve_regularized_surface_current, which can
be used in a similar way as the REGCOIL code:
Runs REGCOIL-like algorithm to find the current potential for the 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, using diffrax package. |
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 an arbitrary angle s. |
|
Coil that lies in a plane. |
|
Coil that lies 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.
There are also utility functions for getting an initial guess for coil optimization using modular, helical, or saddle coils:
|
Initialize a CoilSet of modular coils for stage 2 optimization. |
|
Initialize a CoilSet of helical coils for stage 2 optimization. |
|
Initialize a CoilSet of saddle coils for stage 2 optimization. |