piol.trajectories module

Inheritance diagram

Inheritance diagram of piol.trajectories

API reference

class piol.trajectories.Emittance(x, a)[source]

Bases: object

Emittance class for calculating particle distribution properties

Calculates statistical (rms) model of the beam defined in 2D phase space by particle coordinates x and a. Produces an elliptical model of the beam distribution.

Parameters
  • x (numpy.ndarray) – An array with the x-coordinates of the particles.

  • a (numpy.ndarray) – An array with the a-coordinates of the particles.

xave

Average x-coordinate

Type

float

aave

Average a-coordinate

Type

float

xx

Average of (x-xave)^2

Type

float

aa

Average of (a-aave)^2

Type

float

xa

Average of (x-xave)*(a-aave)

Type

float

epsilon

The rms-emittance value, calculated as sqrt(xx*aa-xa^2)

Type

float

alpha

The Twiss parameter alpha, calculated as -xa/epsilon

Type

float

beta

The Twiss parameter beta, calculated as xx/epsilon

Type

float

gamma

The Twiss parameter gamma, calculated as aa/epsilon

Type

float

angle

The angle of rotation of the major axis of the ellipse

Type

float

rmajor

The radius of the major axis of the ellipse

Type

float

rminor

The radius of the minor axis of the ellipse

Type

float

rms_ellipse(N, F=1)[source]

Returns N point representation of rms ellipse in (x,a) coordinates.

Ellipse radius is multiplied by F for plotting 1-rms, 4-rms(F=2), …

Returns

ellipse – An (N,2) array with (x,a) coordinates pf the ellipse. First and last row are the same for convenience in plotting the ellipse.

Return type

numpy.ndarray

piol.trajectories.createSortedTrajectories(coordsets)[source]

Create a dictionary of arrays of particle coordinates sorted with respect to ‘id’ and ‘s’.

A simplified example of the output of this function is:

{'id': array([0., 0., 0., 0., 0.,
              1., 1., 1., 1., 1.,
              2., 2., 2., 2., 2.]),
 'x': array([0., 0.02, 0.02, 0.15., 0.15.,
             0., -0.01, -0.01., -0.03, -0.03,
             0., 0.03, 0.03, 0.2, 0.2]),
 'a': array([0.1., 0.1, 0.08, 0.08., 0.10.,
             -0.05., -0.05, -0.04., -0.04, -0.05,
             0.15., 0.15, 0.10, 0.10, 0.11]),
 's': array([0., 0.1, 0.1, 1.1, 1.1,
             0., 0.1, 0.1, 1.1, 1.1,
             0., 0.1, 0.1, 1.1, 1.1]),
 ...}
Parameters

coordsets (list) – a list of particle coordinate data at all profile planes.

Returns

sorted – A dictionary of numpy arrays with coordinate data for every particle at every profile plane.

Return type

dict

piol.trajectories.printColumns(coords, **kwargs)[source]

Print particle coordinates in columns.

Parameters
  • coords (dict) – particle coordinate data at a profile plane

  • **file (file object) – if defined, print to instead of sys.stdout

  • **columns (list) – if defined, only columns listed are printed