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.

desc.magnetic_fields.SplineMagneticField(R, ...)

Magnetic field from precomputed values on a grid.

desc.magnetic_fields.DommaschkPotentialField([...])

Magnetic field due to a Dommaschk scalar magnetic potential in rpz coordinates.

desc.magnetic_fields.ScalarPotentialField(...)

Magnetic field due to a scalar magnetic potential in cylindrical coordinates.

desc.magnetic_fields.ToroidalMagneticField(B0, R0)

Magnetic field purely in the toroidal (phi) direction.

desc.magnetic_fields.VerticalMagneticField(B0)

Uniform magnetic field purely in the vertical (Z) direction.

desc.magnetic_fields.PoloidalMagneticField(B0, ...)

Pure poloidal magnetic field (ie in theta direction).

desc.magnetic_fields.ScaledMagneticField(...)

Magnetic field scaled by a scalar value.

desc.magnetic_fields.SumMagneticField(*fields)

Sum of two or more magnetic field sources.

There are also classes for representing a current potential on a winding surface:

desc.magnetic_fields.CurrentPotentialField(...)

Magnetic field due to a surface current potential on a toroidal surface.

desc.magnetic_fields.FourierCurrentPotentialField([...])

Magnetic field due to a surface current potential on a toroidal surface.

There is also a class for representing omnigenous magnetic fields:

desc.magnetic_fields.OmnigenousField([L_B, ...])

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.

desc.magnetic_fields.field_line_integrate(r0, ...)

Trace field lines by integration.

desc.magnetic_fields also contains a utility function for reading output files from the BNORM code:

desc.magnetic_fields.read_BNORM_file(fname, ...)

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):

desc.coils.FourierRZCoil([current, R_n, ...])

Coil parameterized by fourier series for R,Z in terms of toroidal angle phi.

desc.coils.FourierXYZCoil([current, X_n, ...])

Coil parameterized by fourier series for X,Y,Z in terms of arbitrary angle s.

desc.coils.FourierPlanarCoil([current, ...])

Coil that lines in a plane.

desc.coils.SplineXYZCoil(current, X, Y, Z[, ...])

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).

desc.coils.CoilSet(*coils[, NFP, sym, name])

Set of coils of different geometry but shared parameterization and resolution.

desc.coils.MixedCoilSet(*coils[, name])

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.