Xpart API

The particle class

class xpart.Particles(**kwargs)

Particle objects have the following fields:

  • s [m]: Reference accumulated pathlength

  • x [m]: Horizontal position

  • px[1]: Px / (m/m0 * p0c) = beta_x gamma /(beta0 gamma0)

  • y [m]: Vertical position

  • py [1]: Py / (m/m0 * p0c)

  • delta[1]: Pc / (m/m0 * p0c) - 1

  • ptau [1]: Energy / (m/m0 * p0c) - 1

  • psigma [1]: ptau/beta0

  • rvv [1]: beta/beta0

  • rpp [1]: 1/(1+delta) = (m/m0 * p0c) / Pc

  • zeta [m]: beta (s/beta0 - ct )

  • tau [m]:

  • sigma [m]: s - beta0 ct = rvv * zeta

  • mass0 [eV]:

  • q0 [e]: Reference charge

  • p0c [eV]: Reference momentum

  • energy0 [eV]: Reference energy

  • gamma0 [1]: Reference relativistic gamma

  • beta0 [1]: Reference relativistix beta

  • chi [1]: q/ q0 * m0/m = qratio / mratio

  • mass_ratio [1]: mass/mass0

  • charge_ratio [1]: q / q0

  • particle_id [int]: Identifier of the particle

  • at_turn [int]: Number of tracked turns

  • state [int]: It is 0 if the particle is lost, 1 otherwise

  • weight [int]: Particle weight in number of particles

    (for collective sims.)

  • at_element [int]: Identifier of the last element through which

    the particle has been

  • parent_particle_id [int]: Identifier of the parent particle

    (secondary production processes)

to_dict()
hide_lost_particles()
unhide_lost_particles()
property lost_particles_are_hidden
reorganize()
add_particles(part, keep_lost=False)
get_active_particle_id_range()
property delta
property psigma
property rvv
property rpp
property ptau
property energy0
property energy
add_to_energy(delta_energy)
set_reference(p0c=7000000000000.0, mass0=938272088.1604904, q0=1)
set_particle(index, set_scalar_vars=False, check_scalar_vars=True, **kwargs)
update_delta(new_delta_value)
compare(particle, rel_tol=1e-06, abs_tol=1e-15)

The build_particles function

xpart.build_particles(_context=None, _buffer=None, _offset=None, particle_class=<class 'xpart.particles.particles.Particles'>, particle_ref=None, x=None, px=None, y=None, py=None, zeta=None, delta=None, x_norm=None, px_norm=None, y_norm=None, py_norm=None, R_matrix=None, scale_with_transverse_norm_emitt=None, weight=None)

Function to create particle objects from arrays containing physical or normalized coordinates.

Parameters
  • particle_ref (-) – Reference particle to which the provided arrays with coordinates are added

  • x (-) – Values to be added to particle_ref.x

  • px (-) – Values to be added to particle_ref.px

  • y (-) – Values to be added to particle_ref.y

  • py (-) – Values to be added to particle_ref.py

  • zeta (-) – Values to be added to particle_ref.zeta

  • delta (-) – Values to be added to particle_ref.delta

  • x_norm (-) – transverse normalized coordinate x (in sigmas) used in combination with the one turn matrix R_matrix and with the transverse emittances provided in the argument scale_with_transverse_norm_emitt to generate x, px, y, py (x, px, y, py cannot be provided if x_norm, px_norm, y_norm, py_norm are provided).

  • px_norm (-) – transverse normalized coordinate px (in sigmas) used in combination with the one turn matrix R_matrix and with the transverse emittances provided in the argument scale_with_transverse_norm_emitt to generate x, px, y, py (x, px, y, py cannot be provided if x_norm, px_norm, y_norm, py_norm are provided).

  • y_norm (-) – transverse normalized coordinate y (in sigmas) used in combination with the one turn matrix R_matrix and with the transverse emittances provided in the argument scale_with_transverse_norm_emitt to generate x, px, y, py (x, px, y, py cannot be provided if x_norm, px_norm, y_norm, py_norm are provided).

  • py_norm (-) – transverse normalized coordinate py (in sigmas) used in combination with the one turn matrix R_matrix and with the transverse emittances provided in the argument scale_with_transverse_norm_emitt to generate x, px, y, py (x, px, y, py cannot be provided if x_norm, px_norm, y_norm, py_norm are provided).

  • R_matrix (-) – 6x6 matrix defining the linearized one-turn map to be used for the transformation of the normalized coordinates into physical space.

  • scale_with_transverse_norm_emitt (-) – Tuple of two elements defining the transverse normalized emittances used to rescale the provided transverse normalized coordinates (x, px, y, py).

  • weight (-) – weights to be assigned to the particles.

  • _context (-) – xobjects context in which the particle object is allocated.