desc.coils.FourierXYZCoil

class desc.coils.FourierXYZCoil(current=1, X_n=[0, 10, 2], Y_n=[0, 0, 0], Z_n=[-2, 0, 0], modes=None, name='')Source

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

Parameters:
  • current (float) – current through coil, in Amperes

  • X_n (array-like) – fourier coefficients for X, Y, Z

  • Y_n (array-like) – fourier coefficients for X, Y, Z

  • Z_n (array-like) – fourier coefficients for X, Y, Z

  • modes (array-like) – mode numbers associated with X_n etc.

  • name (str) – name for this coil

Examples

from desc.coils import FourierXYZCoil
from desc.grid import LinearGrid
import numpy as np

I = 10
mu0 = 4 * np.pi * 1e-7
R_coil = 10
# circular coil given by X(s) = 10*cos(s), Y(s) = 10*sin(s)
coil = FourierXYZCoil(
    current=I,
    X_n=[0, R_coil, 0],
    Y_n=[0, 0, R_coil],
    Z_n=[0, 0, 0],
    modes=[0, 1, -1],
)
z0 = 10
field_evaluated = coil.compute_magnetic_field(
    np.array([[0, 0, 0], [0, 0, z0]]), basis="rpz"
)
np.testing.assert_allclose(
    field_evaluated[0, :], np.array([0, 0, mu0 * I / 2 / R_coil]), atol=1e-8
)
np.testing.assert_allclose(
    field_evaluated[1, :],
    np.array([0, 0, mu0 * I / 2 * R_coil**2 / (R_coil**2 + z0**2) ** (3 / 2)]),
    atol=1e-8,
)

Methods

change_resolution([N])

Change the maximum angular resolution.

compute(names[, grid, params, transforms, ...])

Compute the quantity given by name on grid.

compute_Bnormal(surface[, eval_grid, ...])

Compute Bnormal from self on the given surface.

compute_magnetic_field(coords[, params, ...])

Compute magnetic field at a set of points.

copy([deepcopy])

Return a (deep)copy of this object.

equiv(other)

Compare equivalence between DESC objects.

flip([normal])

Flip the curve about the plane with specified normal.

from_values(current, coords[, N, s, basis, name])

Fit coordinates to FourierXYZCoil representation.

get_coeffs(n)

Get Fourier coefficients for given mode number(s).

load(load_from[, file_format])

Initialize from file.

pack_params(p)

Convert a dictionary of parameters into a single array.

rotate([axis, angle])

Rotate the curve by a fixed angle about axis in X, Y, Z coordinates.

save(file_name[, file_format, file_mode])

Save the object.

save_BNORM_file(surface, fname[, basis_M, ...])

Create BNORM-style .txt file containing Bnormal Fourier coefficients.

save_mgrid(path, Rmin, Rmax, Zmin, Zmax[, ...])

Save the magnetic field to an mgrid NetCDF file in "raw" format.

set_coeffs(n[, X, Y, Z])

Set specific Fourier coefficients.

to_FourierXYZ([N, grid, s, name])

Convert coil to FourierXYZCoil representation.

to_SplineXYZ([knots, grid, method, name])

Convert coil to SplineXYZCoil.

translate([displacement])

Translate the curve by a rigid displacement in X, Y, Z.

unpack_params(x)

Convert a single array of concatenated parameters into a dictionary.

Attributes

N

Maximum mode number.

X_basis

Spectral basis for X Fourier series.

X_n

Spectral coefficients for X.

Y_basis

Spectral basis for Y Fourier series.

Y_n

Spectral coefficients for Y.

Z_basis

Spectral basis for Z Fourier series.

Z_n

Spectral coefficients for Z.

current

Current passing through the coil, in Amperes.

dim_x

total number of optimizable parameters.

dimensions

dictionary of integers of sizes of each optimizable parameter.

name

Name of the curve.

optimizable_params

string names of parameters that have been declared optimizable.

params_dict

dictionary of arrays of optimizable parameters.

rotmat

Rotation matrix of curve in X, Y, Z.

shift

Displacement of curve in X, Y, Z.

x_idx

arrays of indices for each parameter in concatenated array.