pyaccelerator.beam

Accelerator Beam

Module Contents

Classes

Beam

Represents one beam.

class pyaccelerator.beam.Beam(energy: float = 6500000.0, mass: float = physical_constants['proton mass energy equivalent in MeV'][0], n_particles: int = 1000, emittance: Union[Tuple[float, float], float] = 3.5e-06, sigma_energy: float = 0, sampling: str = 'bigaussian')[source]

Represents one beam.

Parameters
  • energy – Beam kinetic energy in MeV, defaults to 6500000.

  • mass – Particle mass in MeV, defaults to proton mass.

  • n_particles – Number of particles in the beam, defaults to 1000.

  • emittance – Normalized beam emittance in meters, to specify horizontal and vertical emittances use a tuple, defaults to 3.5e-6.

  • sigma_energy – Relative Kinetic energy spread.

  • sampling – Distribution sampling method, defaults to “bigaussian”.

Examples

Beam with even emittances:

>>> Beam(n_particles=100, emittance=2.5e-6)

Beam with uneven emittances:

>>> Beam(n_particles=100, emittance=(3.5e-6, 2.5e-6))

Compute the phase space ellipse:

>>> beam = Beam()
>>> ellipse = beam.ellipse([1, 2, 5])
>>> ellipse.x
...
>>> ellipse.x_prime
...
>>> ellipse.y
...
>>> ellipse.y_prime
...
>>> ellipse.dp
...
>>> ellipse.plot()
...

Match a distribution to twiss parameters:

>>> beam = Beam()
>>> distrib = beam.match([1, 2, 5])
>>> distrib.x
...
>>> distrib.x_prime
...
>>> distrib.y
...
>>> distrib.y_prime
...
>>> distrib.dp
...
>>> distrib.plot()
...
property gamma_relativistic(self)[source]
property beta_relativistic(self)[source]
property geo_emittance_h(self)[source]
property geo_emittance_v(self)[source]
property p(self)[source]
property sigma_p(self)[source]
ellipse(self, twiss_h: Sequence[float], twiss_v: Optional[Sequence[float]] = None, closure_tol: float = 1e-10, n_angles: int = 1000.0) → PhasespaceDistribution[source]

Compute the beam’s phase space ellipse given the twiss parameters.

Parameters
  • twiss_h – Horizontal twiss parameters, beta[m], alpha[rad], gamma[m^-1], one twiss parameter can be None.

  • twiss_v – Vertical twiss parameters, beta[m], alpha[rad], gamma[m^-1], one twiss parameter can be None, if None assumes the same twiss values as twiss_h.

  • closure_tol – Numerical tolerance on the twiss closure condition, defaults to 1e-10.

  • n_angles – Number of angles for which to compute the ellipse, defaults to 1e3.

Returns

Position, angle phase and dp/p space coordrinates of the ellipse.

Note, dp/p will be set to 0.

match(self, twiss_h: Sequence[float], twiss_v: Optional[Sequence[float]] = None, closure_tol: float = 1e-10) → PhasespaceDistribution[source]

Generate a matched beam phase space distribution to the provided twiss parameters.

Parameters
  • twiss_h – Horizontal twiss parameters, beta[m], alpha[rad], gamma[m^-1], to which to match the distribution.

  • twiss_v – Horizontal twiss parameters, beta[m], alpha[rad], gamma[m^-1], to which to match the distribution, if None will use the same values as twiss_h.

  • closure_tol – Numerical tolerance on the twiss closure condition, defaults to 1e-10.

Returns

Position, angle and dp/p phase space coordinates.