piol.transfermatrix module

Inheritance diagram

Inheritance diagram of piol.transfermatrix

API reference

class piol.transfermatrix.TransferMatrix[source]

Bases: object

Class representing any order transfer matrix (Taylor polynomial).

TransferMatrix is a class which implements a mathematic tool to apply taylor polynomials to multiple coordinates. It is a mathematical tool and doesn’t necessary transfer particles forward on the optical axis.

outCoords

String of output coordinates

Type

str

inCoords

String of input coordinates

Type

str

addCoefficient(outputcoord, value, inputcoords)[source]

Adds a coefficient to the matrix.

Adds coefficient to the matrix and updates the string of output coordinates (member outCoords) and string of input coordinates (member inCoords).

Parameters
  • outputcoord (str) – Single character

  • value (float) – Value of the coefficient

  • inputcoords (str) – String of single character base coordinates

Notes

After adding a last coefficient one should call sortMergeCoefficient() to improve the performance.

apply(coords)[source]

Modifies the coordinates according to the stored taylor polynomials.

Parameters

coords (dictionary of numpy arrays) – Dictionary where each key is a string of length 1 and is the name of the coordinate and value is a numpy array of values of this coordinate for the ensamble.

Notes

All numpy arrays (values of the dictionary ‘coords’) must have same length.

getCoefficient(outputcoord, inputcoords)[source]

Returns a value of a coefficient.

Finds the coefficient and returns its value. If coefficient is not found then Exception is raised. Inputcoords is sorted (see sortMergeCoefficients()) so passing “xax” there will match base “axx”.

Parameters
  • outputcoord (str) – Single character

  • inputcoords (str) – String of single character base coordinates

multiply(other, order=None)[source]

Multiplies two transfer matrices.

Multiplies the current transfer matrix B with a given matrix A as C=B*A. NOTE: the TransferMatrix C multiplies coordinates from left. Consequence: in the optical axis B comes later than A!

The resulting transfer matrix C=B*A can be always formed. The transformation of C applied to a set of coordinates will be equal to use of subsequent transformations A and B apart from rounding errors. This means that B can contain an input coordinate which is not any of A’s output coordinate.

Parameters
  • other (TransferMatrix) – Transfer matrix to be multiplied with self. (A)

  • order (int, optional) – Maximum order for coefficients to return. If not given, then maximum resulting oreder is the sum of orders of self and other.

Returns

Multiplied TransferMatrix up to order `order`

Return type

TransferMatrix.

sortMergeCoefficients()[source]

Sorts and merges coefficients.

Sorts coefficients according to output coord and input coords. After the call coefficients are for example (A|A), (A|B), (A|AX), (A|XX), (B|B), (B|Y), (X|A), (X|X), (X|AXX).

Finally merges same coefficients by summing them up.