desc.magnetic_fields.solve_regularized_surface_current
- class desc.magnetic_fields.solve_regularized_surface_current(field, eq, lambda_regularization=1e-30, current_helicity=(1, 0), vacuum=False, regularization_type='regcoil', source_grid=None, eval_grid=None, vc_source_grid=None, external_field=None, external_field_grid=None, verbose=1, chunk_size=None, B_plasma_chunk_size=None)Source
Runs REGCOIL-like algorithm to find the current potential for the surface.
NOTE: The function is not jit/AD compatible
Follows algorithm of [1] to find the current potential Phi on the surface, given a surface current:
K = n x ∇ Φ Φ(θ,ζ) = Φₛᵥ(θ,ζ) + Gζ/2π + Iθ/2π
The algorithm minimizes the quadratic flux on the plasma surface due to the surface current (B_Phi_SV for field from the single valued part Φₛᵥ, and B_GI for that from the secular terms I and G), plasma current, and external fields:
Bn = ∫ ∫ (B . n)^2 dA B = B_plasma + B_external + B_Phi_SV + B_GI
G is fixed by the equilibrium magnetic field strength, and I is determined by the desired coil topology (given by
current_helicity), with zero helicity corresponding to modular coils, and non-zero helicity corresponding to helical coils. The algorithm then finds the single-valued part of Φ by minimizing the quadratic flux on the plasma surface along with a regularization term on the surface current magnitude:min_Φₛᵥ ∫ ∫ (B . n)^2 dA + λ ∫ ∫ ||K||^2 dA
where λ is the regularization parameter, smaller lambda_regularization corresponds to less regularization (consequently, lower Bn error but more complex and large surface currents) and larger lambda_regularization corresponds to more regularization (consequently, higher Bn error but simpler and smaller surface currents).
If the
simpleregularization is used, the problem instead becomes:min_Φₛᵥ (B . n)^2 + λ ||Φ_mn||^2
- Parameters:
field (FourierCurrentPotentialField) –
FourierCurrentPotentialFieldto run REGCOIL algorithm with.eq (Equilibrium) – Equilibrium to minimize the quadratic flux (plus regularization) on.
lambda_regularization (float or ndarray, optional) – regularization parameter, >= 0, regularizes minimization of Bn on plasma surface with minimization of current density mag K on winding surface i.e. larger lambda_regularization, simpler coilset and smaller currents, but worse Bn. If a float, only runs REGCOIL for that single value and returns a list with the single FourierCurrentPotentialField and the associated data. If an array is passed, will run REGCOIL for each lambda_regularization in that array and return a list of FourierCurrentPotentialFields, and the associated data.
current_helicity (tuple of size 2, optional) – Tuple of
(M_coil, N_coil)used to determine coil topology, where`` M_coil`` is the number of poloidal transits a coil makes before closing back on itself andN_coilis the number of toroidal transits a coil makes before returning back to itself. ifN_coilis zero andM_coilnonzero, it corresponds to modular coil topology. If bothN_coil,``M_coil`` are nonzero, it corresponds to helical coils. IfN_coil,``M_coil`` are both zero, it corresponds to windowpane coils. The net toroidal current (whenM_coilis nonzero) is set asI = N_coil(G-G_ext)/M_coilAs an example, if helical coils which make one poloidal transit per field period and close on themselves after one full toroidal transit are desired, that corresponds tocurrent_helicity = (1*NFP, 1)vacuum (bool, optional) – if True, will not include the contribution to the normal field from the plasma currents.
regularization_type ({"simple","regcoil"}) – whether to use a simple regularization based off of just the single-valued part of Phi, or to use the full REGCOIL regularization penalizing | K | ^ 2. Defaults to
"regcoil"source_grid (Grid, optional) – Source grid upon which to evaluate the surface current when calculating the normal field on the plasma surface. Defaults to LinearGrid(M=max(3 * current_potential_field.M_Phi, 30), N=max(3 * current_potential_field.N_Phi, 30), NFP=eq.NFP)
eval_grid (Grid, optional) – Grid upon which to evaluate the normal field on the plasma surface, and at which the normal field is minimized. Defaults to LinearGrid(M=eq.M_grid, N=eq.N_grid, NFP=eq.NFP)
vc_source_grid (LinearGrid) – LinearGrid to use for the singular integral for the virtual casing principle to calculate the component of the normal field from the plasma currents. Must have endpoint=False and sym=False and be linearly spaced in theta and zeta, with nodes only at rho=1.0
external_field (_MagneticField,) – DESC _MagneticField object giving the magnetic field provided by any coils/fields external to the winding surface. e.g. can provide a TF coilset to calculate the surface current which is needed to minimize Bn given this external coilset providing the bulk of the required net toroidal magnetic flux, by default None
external_field_grid (Grid, optional) – Source grid with which to evaluate the external field when calculating its contribution to the normal field on the plasma surface (if it is a type that requires a source, like a CoilSet or a CurrentPotentialField). By default None, which will use the default grid for the given external field type.
verbose (int, optional) – level of verbosity, if 0 will print nothing. 1 will display Bn max,min,average and chi^2 values for each lambda_regularization. 2 will display Jacobian timing info
chunk_size (int or None) – Size to split Biot-Savart computation into chunks of evaluation points. If no chunking should be done or the chunk size is the full input then supply
None.B_plasma_chunk_size (int or None) – Size to split singular integral computation for B_plasma into chunks. If no chunking should be done or the chunk size is the full input then supply
None. Default ischunk_size.
- Returns:
fields (list of FourierCurrentPotentialField) – A FourierCurrentPotentialField with the Phi_mn set to the optimized current potential. This is a list of length lambda_regularization.size with the optimized fields for each parameter value lambda_regularization.
data (dict) –
Dictionary with the following keys,:
lambda_regularization : regularization parameter the algorithm was ran with, a array of passed-in `lambda_regularization` corresponding to the list of `Phi_mn`. Phi_mn : the single-valued current potential coefficients which minimize the Bn at the given eval_grid on the plasma, subject to regularization on the surface current magnitude governed by lambda_regularization. A list of arrays of length `self.Phi_basis.num_modes` if passed-in `lambda_regularization`, with list length `lambda_regularization.size`, corresponding to the list of regularization parameters `lambda_regularization`. I : float, net toroidal current (in Amperes) on the winding surface. Governed by the `current_helicity` parameters, and is zero for modular coils (when `p=current_helicity[0]=0`). G : float, net poloidal current (in Amperes) on the winding surface. Determined by the equilibrium toroidal magnetic field, as well as the given external field. chi^2_B : quadratic flux squared, integrated over the plasma surface. list of float of length `lambda_regularization.size`, corresponding to the array of `lambda_regularization` values. chi^2_K : Current density magnitude squared, integrated over winding surface. a list of float of length `lambda_regularization.size`, corresponding to the array of `lambda_regularization`. ||K|| : Current density magnitude on winding surface, evaluated at the given `source_grid`. A list of arrays, with list length `lambda_regularization.size`, corresponding to the array of `lambda_regularization`. eval_grid: Grid object that Bn was evaluated at. source_grid: Grid object that Phi and K were evaluated at.
References