desc.objectives.QuadraticFlux

class desc.objectives.QuadraticFlux(eq, field, target=None, bounds=None, weight=1, normalize=True, normalize_target=True, source_grid=None, eval_grid=None, field_grid=None, vacuum=False, name='Quadratic flux')Source

Target B*n = 0 on LCFS.

Uses virtual casing to find plasma component of B and penalizes (B_coil + B_plasma)*n. The equilibrium is kept fixed while the field is unfixed.

Parameters:
  • eq (Equilibrium) – Equilibrium upon whose surface the normal field error will be minimized. The equilibrium is kept fixed during the optimization with this objective.

  • field (MagneticField) – External field produced by coils or other source, which will be optimized to minimize the normal field error on the provided equilibrium’s surface.

  • target (float, ndarray, optional) – Target value(s) of the objective. Only used if bounds is None. len(target) must be equal to Objective.dim_f. Default target is zero.

  • bounds (tuple, optional) – Lower and upper bounds on the objective. Overrides target. len(bounds[0]) and len(bounds[1]) must be equal to Objective.dim_f

  • weight (float, ndarray, optional) – Weighting to apply to the Objective, relative to other Objectives. len(weight) must be equal to Objective.dim_f

  • normalize (bool) – Whether to compute the error in physical units or non-dimensionalize.

  • normalize_target (bool) – Whether target and bounds should be normalized before comparing to computed values. If normalize is True and the target is in physical units, this should also be set to True.

  • source_grid (Grid, optional) – Collocation grid containing the nodes for plasma source terms. Default grid is detailed in the docs for compute_B_plasma

  • eval_grid (Grid, optional) – Collocation grid containing the nodes on the plasma surface at which the magnetic field is being calculated and where to evaluate Bn errors. Default grid is: LinearGrid(rho=np.array([1.0]), M=eq.M_grid, N=eq.N_grid, NFP=int(eq.NFP), sym=False)

  • field_grid (Grid, optional) – Grid used to discretize field (e.g. grid for the magnetic field source from coils). Default grid is determined by the specific MagneticField object, see the docs of that object’s compute_magnetic_field method for more detail.

  • vacuum (bool) – If true, B_plasma (the contribution to the normal field on the boundary from the plasma currents) is set to zero.

  • name (str) – Name of the objective function.

Methods

build([use_jit, verbose])

Build constant arrays.

compute(field_params[, constants])

Compute boundary force error.

compute_scalar(*args, **kwargs)

Compute the scalar form of the objective.

compute_scaled(*args, **kwargs)

Compute and apply weighting and normalization.

compute_scaled_error(*args, **kwargs)

Compute and apply the target/bounds, weighting, and normalization.

compute_unscaled(*args, **kwargs)

Compute the raw value of the objective.

copy([deepcopy])

Return a (deep)copy of this object.

equiv(other)

Compare equivalence between DESC objects.

grad(*args, **kwargs)

Compute gradient vector of self.compute_scalar wrt x.

hess(*args, **kwargs)

Compute Hessian matrix of self.compute_scalar wrt x.

jac_scaled(*args, **kwargs)

Compute Jacobian matrix of self.compute_scaled wrt x.

jac_scaled_error(*args, **kwargs)

Compute Jacobian matrix of self.compute_scaled_error wrt x.

jac_unscaled(*args, **kwargs)

Compute Jacobian matrix of self.compute_unscaled wrt x.

jit()

Apply JIT to compute methods, or re-apply after updating self.

jvp_scaled(v, x[, constants])

Compute Jacobian-vector product of self.compute_scaled.

jvp_scaled_error(v, x[, constants])

Compute Jacobian-vector product of self.compute_scaled_error.

jvp_unscaled(v, x[, constants])

Compute Jacobian-vector product of self.compute_unscaled.

load(load_from[, file_format])

Initialize from file.

print_value(*args, **kwargs)

Print the value of the objective.

save(file_name[, file_format, file_mode])

Save the object.

xs(*things)

Return a tuple of args required by this objective from optimizable things.

Attributes

bounds

Lower and upper bounds of the objective.

built

Whether the transforms have been precomputed (or not).

constants

Constant parameters such as transforms and profiles.

dim_f

Number of objective equations.

fixed

Whether the objective fixes individual parameters (or linear combo).

linear

Whether the objective is a linear function (or nonlinear).

name

Name of objective (str).

normalization

normalizing scale factor.

scalar

Whether default "compute" method is a scalar or vector.

target

Target value(s) of the objective.

things

Optimizable things that this objective is tied to.

weight

Weighting to apply to the Objective, relative to other Objectives.