desc.magnetic_fields.CurrentPotentialField
- class desc.magnetic_fields.CurrentPotentialField(potential, potential_dtheta, potential_dzeta, params=None, R_lmn=None, Z_lmn=None, modes_R=None, modes_Z=None, NFP=1, sym='auto', M=None, N=None, name='', check_orientation=True)Source
Magnetic field due to a surface current potential on a toroidal surface.
Surface current K is assumed given by K = n x ∇ Φ where:
n is the winding surface unit normal.
Phi is the current potential function, which is a function of theta and zeta.
This function then uses biot-savart to find the B field from this current density K on the surface.
- Parameters:
potential (callable) – function to compute the current potential. Should have a signature of the form potential(theta,zeta,**params) -> ndarray. theta,zeta are poloidal and toroidal angles on the surface
potential_dtheta (callable) – function to compute the theta derivative of the current potential
potential_dzeta (callable) – function to compute the zeta derivative of the current potential
params (dict, optional) – default parameters to pass to potential function (and its derivatives)
R_lmn (array-like, shape(k,)) – Fourier coefficients for winding surface R and Z in cylindrical coordinates
Z_lmn (array-like, shape(k,)) – Fourier coefficients for winding surface R and Z in cylindrical coordinates
modes_R (array-like, shape(k,2)) – poloidal and toroidal mode numbers [m,n] for R_lmn.
modes_Z (array-like, shape(k,2)) – mode numbers associated with Z_lmn, defaults to modes_R
NFP (int) – number of field periods
sym (bool) – whether to enforce stellarator symmetry for the surface geometry. Default is “auto” which enforces if modes are symmetric. If True, non-symmetric modes will be truncated.
M (int or None) – Maximum poloidal and toroidal mode numbers. Defaults to maximum from modes_R and modes_Z.
N (int or None) – Maximum poloidal and toroidal mode numbers. Defaults to maximum from modes_R and modes_Z.
name (str) – name for this field
check_orientation (bool) – ensure that this surface has a right handed orientation. Do not set to False unless you are sure the parameterization you have given is right handed (ie, e_theta x e_zeta points outward from the surface).
Methods
change_resolution
(*args, **kwargs)Change the maximum poloidal and toroidal 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.
constant_offset_surface
(offset[, grid, M, ...])Create a FourierRZSurface with constant offset from the base surface (self).
copy
([deepcopy])Return a (deep)copy of this object.
equiv
(other)Compare equivalence between DESC objects.
from_input_file
(path)Create a surface from Fourier coefficients in a DESC or VMEC input file.
from_qp_model
([major_radius, aspect_ratio, ...])Create a surface from a near-axis model for quasi-poloidal symmetry.
from_surface
(surface, potential, ...[, params])Create CurrentPotentialField using geometry provided by given surface.
from_values
(coords, theta[, zeta, M, N, ...])Create a surface from given R,Z coordinates in real space.
get_coeffs
(m[, 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.
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
(m[, n, R, Z])Set specific Fourier coefficients.
Convert a single array of concatenated parameters into a dictionary.
Attributes
Maximum radial mode number.
Maximum poloidal mode number.
Maximum toroidal mode number.
Number of (toroidal) field periods.
Spectral basis for R.
Spectral coefficients for R.
Spectral basis for Z.
Spectral coefficients for Z.
total number of optimizable parameters.
dictionary of integers of sizes of each optimizable parameter.
Name of the surface.
string names of parameters that have been declared optimizable.
Dict of parameters to pass to potential function and its derivatives.
dictionary of arrays of optimizable parameters.
Potential function, signature (theta,zeta,**params) -> potential value.
Phi poloidal deriv.
Phi toroidal deriv.
Flux surface label.
Whether or not the surface is stellarator symmetric.
arrays of indices for each parameter in concatenated array.