desc.objectives.Omnigenity

class desc.objectives.Omnigenity(eq, field, target=None, bounds=None, weight=1, normalize=True, normalize_target=True, loss_function=None, deriv_mode='fwd', eq_grid=None, field_grid=None, M_booz=None, N_booz=None, eta_weight=1, eq_fixed=False, field_fixed=False, name='omnigenity')Source

Omnigenity error.

Errors are relative to a target field that is perfectly omnigenous, and are computed on a collocation grid in (ρ,η,α) coordinates.

This objective assumes that the collocation point (θ=0,ζ=0) lies on the contour of maximum field strength ||B||=B_max.

Parameters:
  • eq (Equilibrium) – Equilibrium to be optimized to satisfy the Objective.

  • field (OmnigenousField) – Omnigenous magnetic field to be optimized to satisfy the Objective.

  • 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

  • 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.

  • loss_function ({None, 'mean', 'min', 'max'}, optional) – Loss function to apply to the objective values once computed. This loss function is called on the raw compute value, before any shifting, scaling, or normalization.

  • deriv_mode ({"auto", "fwd", "rev"}) – Specify how to compute jacobian matrix, either forward mode or reverse mode AD. “auto” selects forward or reverse mode based on the size of the input and output of the objective. Has no effect on self.grad or self.hess which always use reverse mode and forward over reverse mode respectively.

  • eq_grid (Grid, optional) – Collocation grid containing the nodes to evaluate at for equilibrium data. Defaults to a linearly space grid on the rho=1 surface. Must be a single flux surface without stellarator symmetry.

  • field_grid (Grid, optional) – Collocation grid containing the nodes to evaluate at for omnigenous field data. The grid nodes are given in the usual (ρ,θ,ζ) coordinates (with θ ∈ [0, 2π), ζ ∈ [0, 2π/NFP)), but θ is mapped to η and ζ is mapped to α. Defaults to a linearly space grid on the rho=1 surface. Must be a single flux surface without stellarator symmetry.

  • M_booz (int, optional) – Poloidal resolution of Boozer transformation. Default = 2 * eq.M.

  • N_booz (int, optional) – Toroidal resolution of Boozer transformation. Default = 2 * eq.N.

  • eta_weight (float, optional) – Magnitude of relative weight as a function of η: w(η) = (eta_weight + 1) / 2 + (eta_weight - 1) / 2 * cos(η) Default value of 1 weights all nodes equally.

  • eq_fixed (bool, optional) – Whether the Equilibrium eq is fixed or not. If True, the equilibrium is fixed and its values are precomputed, which saves on computation time during optimization and self.things = [field] only. If False, the equilibrium is allowed to change during the optimization and its associated data are re-computed at every iteration (Default).

  • field_fixed (bool, optional) – Whether the OmnigenousField field is fixed or not. If True, the field is fixed and its values are precomputed, which saves on computation time during optimization and self.things = [eq] only. If False, the field is allowed to change during the optimization and its associated data are re-computed at every iteration (Default).

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

Methods

build([use_jit, verbose])

Build constant arrays.

compute([params_1, params_2, constants])

Compute omnigenity errors.

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.