at.latticetools.matching#

Matching of lattice parameters.

The matching acts on a VariableList to statisfy the constraints expressed in an ObservableList.

Examples of use of such classes are available in:

Examples of matching are given in Matching.

Functions

match(variables, constraints, *[, method, ...])

Observable matching.

ring_match(ring, variables, constraints, *)

Match constraints by varying variables.

match(variables, constraints, *, method=None, verbose=2, max_nfev=1000, optim_kw=None, **eval_kw)[source]#

Observable matching.

Minimisation is performed by the least_squares() function.

Parameters:
  • variables (VariableList) – Variable parameters

  • constraints (ObservableList) – Constraints to fulfill

  • method (str | None) – Minimisation algorithm (see least_squares()). If None, use ‘lm’ for unbounded problems, ‘trf’ otherwise,

  • verbose (int) – Level of verbosity,

  • max_nfev (int) – Maximum number of function evaluation,

  • optim_kw (dict | None) – Dictionary of optimiser keyword arguments sent to least_squares(),

Keyword Arguments:

**eval_kw – Evaluation keywords provided to the ObservableList.evaluate() method. For instance “ring” (for lattice-dependent observables), “dp”, “dct”, “orbit”, “twiss_in”, “r_in”… Default values are taken from the ObservableList.

Returns:

Matching result – solution for the variable values.

Raises:

RuntimeError – If optimisation fails

ring_match(ring, variables, constraints, *, copy=False, method=None, verbose=2, max_nfev=1000, **kwargs)[source]#

Match constraints by varying variables.

Minimisation is performed by the least_squares() function.

Parameters:
  • ring (Lattice) – Lattice description

  • variables (VariableList) – Variable parameters

  • constraints (ObservableList) – Constraints to fulfill

  • copy (bool) – If True, return a modified copy of ring, otherwise perform the match in-line

  • method (str | None) – Minimisation algorithm (see least_squares()). If None, use ‘lm’ for unbounded problems, ‘trf’ otherwise,

  • verbose (int) – Level of verbosity,

  • max_nfev (int) – Maximum number of function evaluation,

Keyword Arguments:
  • dp (float | None) – Momentum deviation. Default taken from the ObservableList,

  • dct (float | None) – Path lengthening. Default taken from the ObservableList,

  • df (float | None) – Deviation from the nominal RF frequency. Default taken from the ObservableList,

  • orbit (Orbit | None) – Initial orbit. Avoids looking for the closed orbit if it is already known. Used for MatrixObservable and LocalOpticsObservable. Default taken from the ObservableList,

  • twiss_in – Initial conditions for transfer line optics See get_optics(). Used for LocalOpticsObservable. Default taken from the ObservableList,

  • r_in (Orbit | None) – Initial trajectory, used for TrajectoryObservable. Default taken from the ObservableList,

  • **kwargs – The other keyword arguments sent to, least_squares().

Returns:

Modified Lattice if copy=True, None otherwise

Raises:

Examples

See Matching