piol.driver module¶
Inheritance diagram¶

API reference¶
- class piol.driver.Driver(s0=0, r0=array([0, 0, 0]), x0=array([1, 0, 0]), y0=array([0, 1, 0]))[source]¶
Bases:
object
Holder object for driving particles through the beamline.
Driver holds the information about the particles being driven through the elements.
- Parameters
s0 (float) – Initial s-coordinate at the start of the beam line.
r0 (numpy.ndarray (size 3)) – Start of beam line in cartesian laboratory coordinates.
x0 (numpy.ndarray (size 3)) – Unit vector defining the direction of positive x axis at the start of the beam line.
y0 (numpy.ndarray (size 3)) – Unit vector defining the direction of positive y axis at the start of the beam line.
- plane0¶
Information about the profile plane at the start of the beam line., This is used to set the profile plane if user calls self.clear().
- Type
- plane¶
Current profile plane. Set to plane0 if self.clear() is called.
- Type
- traj¶
List of dictionaries, holding particle information at the different profile planes along the s-axis until the current point.
- Type
list
- trajPlanes¶
List of profile planes corresponding to each list item in the ‘traj’.
- Type
- particles¶
Dictionary holding the current particle information in numpy arrays, keys are the particle properties.
- Type
dict
- getParticleIds(N=None)[source]¶
Return new particle identification numbers.
If N == None a single new id is returned. Otherwise N new ids are returned in a numpy array.
- Parameters
N (
None
orint
) – Array length of new ids to be returned.- Returns
Returns the next id if
None
is passed, an array of next ids if a length is passed.- Return type
int
ornp.array
- onElementEnter(element)[source]¶
Process entering an element.
If element calling this has element.isLeaf==True then current set of particles is appended to self.traj and current information of the profile plane is appended to self.profilePlanes.
- registerTransfer(newparticles, ds, dr=array([0., 0., 0.]), dx=array([0., 0., 0.]), dy=array([0., 0., 0.]), save=True)[source]¶
Advances particles to a new profile plane.
Manages callbacks and effects of element wrappers to particle coordinates and saves the data and the new profile plane created according to the given parameters.
- Parameters
newparticles (dict) – Dictionary of particle information in numpy arrays. Should not be used after calling this function.
ds (float) – Path length along the s-axis from the previous plane.
dr (numpy.ndarray (size 3)) – Vector from the origin of the previous plane to the origin of this plane stated in the coordinate system of the last profile plane
dx (numpy.ndarray (size 3)) – Change of unit vector x from the previous plane to this plane stated in the coordinate system of the last profile plane
dy (numpy.ndarray (size 3)) – Change of unit vector x from the previous plane to this plane stated in the coordinate system of the last profile plane
save (bool) – Boolean stating if the new plane and the particle data are to be saved.
- setTransferCallbacks(callbacks)[source]¶
Set a list of callback functions to be called whenever registerTranfer() is called.
The callback functions take the driver and particle set as argument and should return the modified particle set. Provides a mechanism for modelling additional effects within the beamline, such as space charge repulsion, scattering by residual gas, etc.
- class piol.driver.ProfilePlane(s=0.0, r=array([0., 0., 0.]), ux=array([1., 0., 0.]), uy=array([0., 1., 0.]))[source]¶
Bases:
object
Profile plane along the beam line.
Todo
Check the automatic cut of trajectories hitting the default walls of elements.
- s¶
Position of the profile plane along the optical axis in meters.
- Type
float
- r¶
Position of the origin of the profile plane in laboratory coordinates.
- Type
numpyp.ndarray
(size 3)
- ux¶
Unit vector defining the direction of positive x axis.
- Type
numpy.ndarray
(size 3)
- uy¶
Unit vector defining the direction of positive y axis.
- Type
numpy.ndarray
(size 3)