bfieldtools.coil_optimize.optimize_lsq

bfieldtools.coil_optimize.optimize_lsq(mesh_conductor, bfield_specification, reg=1000.0, objective='minimum_inductive_energy')

Optimization of coil stream function according to a specified objective using least-squares.

Parameters
mesh_conductor: MeshConductor object

Contains Trimesh mesh as well as physical properties, e.g. inductance

bfield_specification: list

List in which element is a dictionary containing a coil specification.

objective: string or dict

if string, either ‘minimum_inductive_energy’ or ‘minimum_ohmic_power’ if tuple, should contain: (a, b), where a and b are floats describing the inductive and resitive weighting factors. The resistance matrix is scaled according to the largest singular value of the inductance matrix for consistent behavior across meshes.

reg: float

Regularization/tradeoff parameter (lambda). A larger lambda leads to more emphasis on the specification, at the cost of the quadratic objective. The lambda value is relative to the maximum singular value w of the eigenvalue equation

\[\mathbf{C}^T \mathbf{C} \mathbf{v}[:,i] = \mathbf{w}[i] \mathbf{Q} \mathbf{v}[:,i]\]

where C is the constraint matrix and Q is the quadratic objective matrix.

Returns
S: StreamFunction

Optimization solution

Notes

Each specification is a dict, which contains
  • coupling: Coupling matrix (N_r, N_verts, 3)

  • target: (N_r, 3)

NOTE The following spec parameters are ignored:
  • abs_error: float or (N_r, 3)

  • rel_error: float or (N_r, 3)