desc.perturbations.optimal_perturb
- desc.perturbations.optimal_perturb(eq, objective_f, objective_g, dR=False, dZ=False, dL=False, dp=False, di=False, dPsi=False, dRb=False, dZb=False, subspace=None, order=2, tr_ratio=[0.1, 0.25], cutoff=None, verbose=1, copy=True)Source
Perturb an Equilibrium with respect to input parameters to optimize an objective.
- Parameters:
eq (Equilibrium) – Equilibrium to perturb.
objective_f (ObjectiveFunction) – Objective function to satisfy.
objective_g (ObjectiveFunction) – Objective function to optimize.
dR (ndarray or bool, optional) – Array of indices of modes to include in the perturbations of R, Z, lambda, pressure, rotational transform, total magnetic flux, R_boundary, and Z_boundary. Setting to True (False) includes (excludes) all modes.
dZ (ndarray or bool, optional) – Array of indices of modes to include in the perturbations of R, Z, lambda, pressure, rotational transform, total magnetic flux, R_boundary, and Z_boundary. Setting to True (False) includes (excludes) all modes.
dL (ndarray or bool, optional) – Array of indices of modes to include in the perturbations of R, Z, lambda, pressure, rotational transform, total magnetic flux, R_boundary, and Z_boundary. Setting to True (False) includes (excludes) all modes.
dp (ndarray or bool, optional) – Array of indices of modes to include in the perturbations of R, Z, lambda, pressure, rotational transform, total magnetic flux, R_boundary, and Z_boundary. Setting to True (False) includes (excludes) all modes.
di (ndarray or bool, optional) – Array of indices of modes to include in the perturbations of R, Z, lambda, pressure, rotational transform, total magnetic flux, R_boundary, and Z_boundary. Setting to True (False) includes (excludes) all modes.
dPsi (ndarray or bool, optional) – Array of indices of modes to include in the perturbations of R, Z, lambda, pressure, rotational transform, total magnetic flux, R_boundary, and Z_boundary. Setting to True (False) includes (excludes) all modes.
dRb (ndarray or bool, optional) – Array of indices of modes to include in the perturbations of R, Z, lambda, pressure, rotational transform, total magnetic flux, R_boundary, and Z_boundary. Setting to True (False) includes (excludes) all modes.
dZb (ndarray or bool, optional) – Array of indices of modes to include in the perturbations of R, Z, lambda, pressure, rotational transform, total magnetic flux, R_boundary, and Z_boundary. Setting to True (False) includes (excludes) all modes.
subspace (ndarray, optional) – Transform matrix to give a subspace from the full parameter space. Can be used to enforce custom optimization constraints.
order ({0,1,2,3}) – Order of perturbation (0=none, 1=linear, 2=quadratic, etc.)
tr_ratio (float or array of float) – Radius of the trust region, as a fraction of ||x||. Enforces ||dx1|| <= tr_ratio*||x|| and ||dx2|| <= tr_ratio*||dx1||. If a scalar, uses the same ratio for all steps. If an array, uses the first element for the first step and so on. Note that ||X|| uses a scaled norm, weighted by the jacobian.
cutoff (float) – Relative cutoff for small singular values in pseudo-inverse. Default is np.finfo(A.dtype).eps*max(A.shape) where A is the Jacobian matrix.
verbose (int) – Level of output.
copy (bool) – Whether to perturb the input equilibrium (False) or make a copy (True, Default).
- Returns:
eq_new (Equilibrium) – optimized equilibrium