piol.element module¶
Inheritance diagram¶

API reference¶
- class piol.element.Element(name='', description='')[source]¶
Bases:
object
Baseclass for beamline elements that interact with particles.
- Parameters
name (str) – Name given to the element.
description (str) – Description of the element, currently not used.
- name¶
Name given to the element
- Type
str
- description¶
Description of the element, currently not used.
- Type
str
- parameters¶
Collected parameters for the element, contents depend on the subclass.
- Type
dict
- parameterModified¶
Flag to indicate that a parameter has added or modified. Derived class should clear this after a successfull rebuild.
- Type
boolean
- isLeaf¶
Boolean attribute, indicating if the element is at the end of a branch of elements.
- Type
boolean
- info¶
Dictionary containing information about the element in a non-parametric form. Not written by the library itself.
- Type
dict
- calculateField(s0, R=5)[source]¶
Returns a tuple with interpolators for element electric and magnetic field profiles.
The field with the fringe fields (Enge) are evaluated from R*D before the entrance field boundary at s0 to R*D after the exit field boundary along the reference trajectory. Here D is half the element height and R by default is 5.
- field(kind)[source]¶
Return the field strength within the element.
- Parameters
kind ({'magnetic' , 'electric'}) – String to select field type.
- Returns
Field strength within the element.
- Return type
float
- getTransferMatrix()[source]¶
Returns the transfer matrix for the element or None if matrix is unitary.
Derived classes should raise an error if matrix is not available
- height()[source]¶
Calculate the height of the element.
- Returns
float
- Return type
Height of the element.
- length()[source]¶
Calculate the length of the element.
- Returns
float
- Return type
Length of the element.
- opticalAxisExit()[source]¶
Returns the exiting optical axis.
Returns the coordinate transformation from the entrance plane to the exit plane. The returned value is a tuple (r,x,y), where r (vector) is a translation from entrance optical axis origin to exit optical axis origin; x and y are unit vectors defining the exit plane coordinate system. The z-axis is the cross product of x and y, and points towards positive optical axis.
- plot(ax, view, s)[source]¶
Plot the element
Plots a representation of the element using the plotter interface in a cross section view. Defaults to plotting nothing.
- Parameters
ax (Axis) – Axis instance to plot on
view (str) – String describing which viewpoint to draw on. Must be known to the Plotter.
s (float) – Starting distance along the optical axis for element start.
- processTrajectory(driver, plesToSave, ds, dr, dx, dy)[source]¶
Process the particles and profile plane information before saving those.
This is called by driver. This method is implemented only in elements which are wrapping other elements and are for example rotating the elements it is containing. By default this method just returns all the arguments in the same order.
- rebuild()[source]¶
Rebuilds element if any of its parameters have been modified.
Defaults to doing nothing.
- class piol.element.ElementStack(name='ElementStack', description='')[source]¶
Bases:
piol.element.Element
A stack of elements (for building beam lines).
- Parameters
name (str) – Name given to the stack of elements.
description (str) – Description of the stack of elements.
- build()¶
Builds element.
- calculateField(s0, R=5)¶
Returns a tuple with interpolators for element electric and magnetic field profiles.
The field with the fringe fields (Enge) are evaluated from R*D before the entrance field boundary at s0 to R*D after the exit field boundary along the reference trajectory. Here D is half the element height and R by default is 5.
- field(kind)¶
Return the field strength within the element.
- Parameters
kind ({'magnetic' , 'electric'}) – String to select field type.
- Returns
Field strength within the element.
- Return type
float
- getTransferMatrix()[source]¶
Calculate the total transfer matrix of the system.
Todo
The way matrix order is handled by the getTransferMatrix mechanism should be revised.
- Returns
Transfermatrix numerically describing the entire system.
- Return type
- height()¶
Calculate the height of the element.
- Returns
float
- Return type
Height of the element.
- length()[source]¶
Calculate the length of the element.
- Returns
float
- Return type
Length of the element.
- opticalAxisExit()¶
Returns the exiting optical axis.
Returns the coordinate transformation from the entrance plane to the exit plane. The returned value is a tuple (r,x,y), where r (vector) is a translation from entrance optical axis origin to exit optical axis origin; x and y are unit vectors defining the exit plane coordinate system. The z-axis is the cross product of x and y, and points towards positive optical axis.
- plot(plotter, view, s)[source]¶
Plot the elements in the stack
Plots a representation of the elements using the plotter interface in a cross section view. Defaults to plotting nothing.
- Parameters
plotter (Plotter) – Plotter instance to plot on
view (str) – String describing which viewpoint to draw on. Must be known to the Plotter.
s (float) – Starting distance along the optical axis for element start.
- processTrajectory(driver, plesToSave, ds, dr, dx, dy)¶
Process the particles and profile plane information before saving those.
This is called by driver. This method is implemented only in elements which are wrapping other elements and are for example rotating the elements it is containing. By default this method just returns all the arguments in the same order.
- rebuild()[source]¶
Rebuilds element if any of its parameters have been modified.
Defaults to doing nothing.
- resetSAdvance(maxSAdvance)[source]¶
DEPRACATED. USE resetSAdvance(). Resets maxSAdvance property of all contained elements to new value.
- setParameter(parameter, newvalue)¶
Modifies given parameter.
- setParameters(parameters)¶
Convenience function for setting multiple parameters with a dictionary.