piol.raytrace module

Inheritance diagram

Inheritance diagram of piol.raytrace

API reference

class piol.raytrace.RayTrace(refple, E, B, planes, steplen, xsize=0.1, ysize=0.1, iterator='RK45', maxsteps=1000)[source]

Bases: piol.element.Element

Non-relativistic ray-tracing of particles through electromagnetic fields.

Set up ray-tracing object with fields E and B. The planes variable defines a list of planes: the starting plane, possible intermediate planes and the exit plane. Each of the planes is defined by a tuple (c,u,v,col) with three numpy arrays: center point c0 and unit vectors u0 and v0; and a None or a Collimator object if the plane is to collimate particles. The u and v vectors are normalized internally.

Length of element is defined based on reference particle trajectory or zero if reference particle not defined.

Intermediate planes not in use currently.

Step length steplen is used for defining initial step size of integration in case of RK45. In case of fixed step size integrator it is used to calculate the time step size using initial particle velocity. The xsize and ysize define the size of box representing the elements in plots.

calc(q, m, xs0)[source]

Calculate particle with defined starting plane coordinates (x1,x2,x3,v1,v2,v3).

Returns the particle coordinates (x1,x2,x3,v1,v2,v3) at the end or None if the particle does not reach the end plane.

The calculation point time and coordinates can be found in internal attributes time and traj after calculation in the coordinate system of the field.

dxdt(t, x)[source]

Function providing right hand side for ray-tracer ODE solver.

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(plotter, 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.

printDebug(indent='')[source]

Print debugging information for element.

transfer(driver)[source]

Transfers the particles saved in the driver through the element.

Parameters

driver (Driver) – Driver of the system