desc.magnetic_fields.MagneticFieldFromUser
- class desc.magnetic_fields.MagneticFieldFromUser(fun, params=None)Source
Wrap an arbitrary function for calculating magnetic field in lab coordinates.
- Parameters:
fun (callable) –
Function to compute magnetic field at arbitrary points. Should have a signature of the form
fun(coords, params) -> Bwherecoordsis a (n,3) array of positions in R, phi, Z coordinates where the field is to be evaluated.paramsis an array of optional parameters, eg for optimizing the field.Bis the returned value of the magnetic field as a (n,3) array in R, phi, Z coordinates.
params (ndarray, optional) – Default values for parameters. Defaults to an empty array.
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.
compute_magnetic_vector_potential(coords[, ...])Compute magnetic vector potential at a set of points.
copy([deepcopy])Return a (deep)copy of this object.
equiv(other)Compare equivalence between DESC objects.
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
total number of optimizable parameters.
dictionary of integers of sizes of each optimizable parameter.
string names of parameters that have been declared optimizable.
Parameters of the field allowed to vary during optimization.
dictionary of arrays of optimizable parameters.
arrays of indices for each parameter in concatenated array.