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.
Convert a single array of concatenated parameters into a dictionary.
Attributes
Number of toroidal field periods.
currents or scaling factors for each field group.
total number of optimizable parameters.
dictionary of integers of sizes of each optimizable parameter.
string names of parameters that have been declared optimizable.
dictionary of arrays of optimizable parameters.
arrays of indices for each parameter in concatenated array.