desc.magnetic_fields.SplineMagneticField

class desc.magnetic_fields.SplineMagneticField(R, phi, Z, BR, Bphi, BZ, currents=1.0, NFP=1, method='cubic', extrap=False)Source

Magnetic field from precomputed values on a grid.

Parameters:
  • R (array-like, size(NR)) – R coordinates where field is specified

  • phi (array-like, size(Nphi)) – phi coordinates where field is specified

  • Z (array-like, size(NZ)) – Z coordinates where field is specified

  • BR (array-like, shape(NR,Nphi,NZ,Ngroups)) – radial magnetic field on grid

  • Bphi (array-like, shape(NR,Nphi,NZ,Ngroups)) – toroidal magnetic field on grid

  • BZ (array-like, shape(NR,Nphi,NZ,Ngroups)) – vertical magnetic field on grid

  • currents (array-like, shape(Ngroups)) – Currents or scaling factors for each field group.

  • NFP (int, optional) – Number of toroidal field periods.

  • method (str) – interpolation method.

  • extrap (bool, optional) – whether to extrapolate beyond the domain of known field values or return nan.

Methods

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.

from_field(field, R, phi, Z[, params, ...])

Create a splined magnetic field from another field for faster evaluation.

from_mgrid(mgrid_file[, extcur, method, extrap])

Create a SplineMagneticField from an "mgrid" file from MAKEGRID.

load(load_from[, file_format])

Initialize from file.

pack_params(p)

Convert a dictionary of parameters into a single array.

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.

unpack_params(x)

Convert a single array of concatenated parameters into a dictionary.

Attributes

NFP

Number of toroidal field periods.

currents

currents or scaling factors for each field group.

dim_x

total number of optimizable parameters.

dimensions

dictionary of integers of sizes of each optimizable parameter.

optimizable_params

string names of parameters that have been declared optimizable.

params_dict

dictionary of arrays of optimizable parameters.

x_idx

arrays of indices for each parameter in concatenated array.