Particles¶
- class particles.Beam(*args, **kwargs)¶
- property alpha_x: Tensor¶
Alpha function in x direction in rad.
- property alpha_y: Tensor¶
Alpha function in y direction in rad.
- property beta_x: Tensor¶
Beta function in x direction in meters.
- property beta_y: Tensor¶
Beta function in y direction in meters.
- property emittance_x: Tensor¶
Emittance of the beam in x direction in m*rad.
- property emittance_y: Tensor¶
Emittance of the beam in y direction in m*rad.
- empty = "I'm an empty beam!"¶
- classmethod from_astra(path: str, **kwargs) Beam ¶
Load an Astra particle distribution as a Cheetah Beam.
- classmethod from_parameters(mu_x: Tensor | None = None, mu_xp: Tensor | None = None, mu_y: Tensor | None = None, mu_yp: Tensor | None = None, sigma_x: Tensor | None = None, sigma_xp: Tensor | None = None, sigma_y: Tensor | None = None, sigma_yp: Tensor | None = None, sigma_s: Tensor | None = None, sigma_p: Tensor | None = None, cor_x: Tensor | None = None, cor_y: Tensor | None = None, cor_s: Tensor | None = None, energy: Tensor | None = None, total_charge: Tensor | None = None) Beam ¶
Create beam that with given beam parameters.
- Parameters:
n – Number of particles to generate.
mu_x – Center of the particle distribution on x in meters.
mu_xp – Center of the particle distribution on x’=px/px’ (trace space) in rad.
mu_y – Center of the particle distribution on y in meters.
mu_yp – Center of the particle distribution on y’ in rad.
sigma_x – Sigma of the particle distribution in x direction in meters.
sigma_xp – Sigma of the particle distribution in x’ direction in rad.
sigma_y – Sigma of the particle distribution in y direction in meters.
sigma_yp – Sigma of the particle distribution in y’ direction in rad.
sigma_s – Sigma of the particle distribution in s direction in meters.
sigma_p – Sigma of the particle distribution in p direction in meters.
energy – Energy of the beam in eV.
total_charge – Total charge of the beam in C.
- classmethod from_twiss(beta_x: Tensor | None = None, alpha_x: Tensor | None = None, emittance_x: Tensor | None = None, beta_y: Tensor | None = None, alpha_y: Tensor | None = None, emittance_y: Tensor | None = None, energy: Tensor | None = None, total_charge: Tensor | None = None) Beam ¶
Create a beam from twiss parameters.
- Parameters:
beta_x – Beta function in x direction in meters.
alpha_x – Alpha function in x direction in rad.
emittance_x – Emittance in x direction in m*rad.
beta_y – Beta function in y direction in meters.
alpha_y – Alpha function in y direction in rad.
emittance_y – Emittance in y direction in m*rad.
energy – Energy of the beam in eV.
total_charge – Total charge of the beam in C.
- property mu_p: Tensor¶
- property mu_s: Tensor¶
- property mu_x: Tensor¶
- property mu_xp: Tensor¶
- property mu_y: Tensor¶
- property mu_yp: Tensor¶
- property normalized_emittance_x: Tensor¶
Normalized emittance of the beam in x direction in m*rad.
- property normalized_emittance_y: Tensor¶
Normalized emittance of the beam in y direction in m*rad.
- property parameters: dict¶
Return an iterator over module parameters.
This is typically passed to an optimizer.
- Args:
- recurse (bool): if True, then yields parameters of this module
and all submodules. Otherwise, yields only parameters that are direct members of this module.
- Yields:
Parameter: module parameter
Example:
>>> # xdoctest: +SKIP("undefined vars") >>> for param in model.parameters(): >>> print(type(param), param.size()) <class 'torch.Tensor'> (20L,) <class 'torch.Tensor'> (20L, 1L, 5L, 5L)
- property relativistic_beta: Tensor¶
- property relativistic_gamma: Tensor¶
- property sigma_p: Tensor¶
- property sigma_s: Tensor¶
- property sigma_x: Tensor¶
- property sigma_xp: Tensor¶
- property sigma_xxp: Tensor¶
- property sigma_y: Tensor¶
- property sigma_yp: Tensor¶
- property sigma_yyp: Tensor¶
- transformed_to(mu_x: Tensor | None = None, mu_xp: Tensor | None = None, mu_y: Tensor | None = None, mu_yp: Tensor | None = None, sigma_x: Tensor | None = None, sigma_xp: Tensor | None = None, sigma_y: Tensor | None = None, sigma_yp: Tensor | None = None, sigma_s: Tensor | None = None, sigma_p: Tensor | None = None, energy: Tensor | None = None, total_charge: Tensor | None = None) Beam ¶
Create version of this beam that is transformed to new beam parameters.
- Parameters:
mu_x – Center of the particle distribution on x in meters.
mu_xp – Center of the particle distribution on x’ in rad.
mu_y – Center of the particle distribution on y in meters.
mu_yp – Center of the particle distribution on y’ in rad.
sigma_x – Sigma of the particle distribution in x direction in meters.
sigma_xp – Sigma of the particle distribution in x’ direction in rad.
sigma_y – Sigma of the particle distribution in y direction in meters.
sigma_yp – Sigma of the particle distribution in y’ direction in rad.
sigma_s – Sigma of the particle distribution in s direction in meters.
sigma_p – Sigma of the particle distribution in p direction,
dimensionless. :param energy: Energy of the beam in eV. :param total_charge: Total charge of the beam in C.
- class particles.ParameterBeam(mu: Tensor, cov: Tensor, energy: Tensor, total_charge: Tensor | None = None, device=None, dtype=torch.float32)¶
Beam of charged particles, where each particle is simulated.
- Parameters:
mu – Mu vector of the beam.
cov – Covariance matrix of the beam.
energy – Energy of the beam in eV.
total_charge – Total charge of the beam in C.
device – Device to use for the beam. If “auto”, use CUDA if available. Note: Compuationally it would be faster to use CPU for ParameterBeam.
- broadcast(shape: Size) ParameterBeam ¶
Broadcast beam to new shape.
- classmethod from_astra(path: str, device=None, dtype=torch.float32) ParameterBeam ¶
Load an Astra particle distribution as a Cheetah Beam.
- classmethod from_ocelot(parray, device=None, dtype=torch.float32) ParameterBeam ¶
Load an Ocelot ParticleArray parray as a Cheetah Beam.
- classmethod from_parameters(mu_x: Tensor | None = None, mu_xp: Tensor | None = None, mu_y: Tensor | None = None, mu_yp: Tensor | None = None, sigma_x: Tensor | None = None, sigma_xp: Tensor | None = None, sigma_y: Tensor | None = None, sigma_yp: Tensor | None = None, sigma_s: Tensor | None = None, sigma_p: Tensor | None = None, cor_x: Tensor | None = None, cor_y: Tensor | None = None, cor_s: Tensor | None = None, energy: Tensor | None = None, total_charge: Tensor | None = None, device=None, dtype=torch.float32) ParameterBeam ¶
Create beam that with given beam parameters.
- Parameters:
n – Number of particles to generate.
mu_x – Center of the particle distribution on x in meters.
mu_xp – Center of the particle distribution on x’=px/px’ (trace space) in rad.
mu_y – Center of the particle distribution on y in meters.
mu_yp – Center of the particle distribution on y’ in rad.
sigma_x – Sigma of the particle distribution in x direction in meters.
sigma_xp – Sigma of the particle distribution in x’ direction in rad.
sigma_y – Sigma of the particle distribution in y direction in meters.
sigma_yp – Sigma of the particle distribution in y’ direction in rad.
sigma_s – Sigma of the particle distribution in s direction in meters.
sigma_p – Sigma of the particle distribution in p direction in meters.
energy – Energy of the beam in eV.
total_charge – Total charge of the beam in C.
- classmethod from_twiss(beta_x: Tensor | None = None, alpha_x: Tensor | None = None, emittance_x: Tensor | None = None, beta_y: Tensor | None = None, alpha_y: Tensor | None = None, emittance_y: Tensor | None = None, sigma_s: Tensor | None = None, sigma_p: Tensor | None = None, cor_s: Tensor | None = None, energy: Tensor | None = None, total_charge: Tensor | None = None, device=None, dtype=torch.float32) ParameterBeam ¶
Create a beam from twiss parameters.
- Parameters:
beta_x – Beta function in x direction in meters.
alpha_x – Alpha function in x direction in rad.
emittance_x – Emittance in x direction in m*rad.
beta_y – Beta function in y direction in meters.
alpha_y – Alpha function in y direction in rad.
emittance_y – Emittance in y direction in m*rad.
energy – Energy of the beam in eV.
total_charge – Total charge of the beam in C.
- property mu_p: Tensor¶
- property mu_s: Tensor¶
- property mu_x: Tensor¶
- property mu_xp: Tensor¶
- property mu_y: Tensor¶
- property mu_yp: Tensor¶
- property sigma_p: Tensor¶
- property sigma_s: Tensor¶
- property sigma_x: Tensor¶
- property sigma_xp: Tensor¶
- property sigma_xxp: Tensor¶
- property sigma_y: Tensor¶
- property sigma_yp: Tensor¶
- property sigma_yyp: Tensor¶
- transformed_to(mu_x: Tensor | None = None, mu_xp: Tensor | None = None, mu_y: Tensor | None = None, mu_yp: Tensor | None = None, sigma_x: Tensor | None = None, sigma_xp: Tensor | None = None, sigma_y: Tensor | None = None, sigma_yp: Tensor | None = None, sigma_s: Tensor | None = None, sigma_p: Tensor | None = None, energy: Tensor | None = None, total_charge: Tensor | None = None, device=None, dtype=torch.float32) ParameterBeam ¶
Create version of this beam that is transformed to new beam parameters.
- Parameters:
n – Number of particles to generate.
mu_x – Center of the particle distribution on x in meters.
mu_xp – Center of the particle distribution on x’ in rad.
mu_y – Center of the particle distribution on y in meters.
mu_yp – Center of the particle distribution on y’ in rad.
sigma_x – Sigma of the particle distribution in x direction in meters.
sigma_xp – Sigma of the particle distribution in x’ direction in rad.
sigma_y – Sigma of the particle distribution in y direction in meters.
sigma_yp – Sigma of the particle distribution in y’ direction in rad.
sigma_s – Sigma of the particle distribution in s direction in meters.
sigma_p – Sigma of the particle distribution in p, dimensionless.
energy – Energy of the beam in eV.
total_charge – Total charge of the beam in C.
- class particles.ParticleBeam(particles: Tensor, energy: Tensor, particle_charges: Tensor | None = None, device=None, dtype=torch.float32)¶
Beam of charged particles, where each particle is simulated.
- Parameters:
particles – List of 7-dimensional particle vectors.
energy – Energy of the beam in eV.
total_charge – Total charge of the beam in C.
device – Device to move the beam’s particle array to. If set to “auto” a CUDA GPU is selected if available. The CPU is used otherwise.
- broadcast(shape: Size) ParticleBeam ¶
Broadcast beam to new shape.
- classmethod from_astra(path: str, device=None, dtype=torch.float32) ParticleBeam ¶
Load an Astra particle distribution as a Cheetah Beam.
- classmethod from_ocelot(parray, device=None, dtype=torch.float32) ParticleBeam ¶
Convert an Ocelot ParticleArray parray to a Cheetah Beam.
- classmethod from_parameters(num_particles: Tensor | None = None, mu_x: Tensor | None = None, mu_y: Tensor | None = None, mu_xp: Tensor | None = None, mu_yp: Tensor | None = None, sigma_x: Tensor | None = None, sigma_y: Tensor | None = None, sigma_xp: Tensor | None = None, sigma_yp: Tensor | None = None, sigma_s: Tensor | None = None, sigma_p: Tensor | None = None, cor_x: Tensor | None = None, cor_y: Tensor | None = None, cor_s: Tensor | None = None, energy: Tensor | None = None, total_charge: Tensor | None = None, device=None, dtype=torch.float32) ParticleBeam ¶
Generate Cheetah Beam of random particles.
- Parameters:
num_particles – Number of particles to generate.
mu_x – Center of the particle distribution on x in meters.
mu_y – Center of the particle distribution on y in meters.
mu_xp – Center of the particle distribution on x’ in rad.
mu_yp – Center of the particle distribution on y’ in metraders.
sigma_x – Sigma of the particle distribution in x direction in meters.
sigma_y – Sigma of the particle distribution in y direction in meters.
sigma_xp – Sigma of the particle distribution in x’ direction in rad.
sigma_yp – Sigma of the particle distribution in y’ direction in rad.
sigma_s – Sigma of the particle distribution in s direction in meters.
sigma_p – Sigma of the particle distribution in p, dimensionless.
cor_x – Correlation between x and x’.
cor_y – Correlation between y and y’.
cor_s – Correlation between s and p.
energy – Energy of the beam in eV.
device – Device to move the beam’s particle array to. If set to “auto” a CUDA GPU is selected if available. The CPU is used otherwise.
- Total_charge:
Total charge of the beam in C.
- classmethod from_twiss(num_particles: Tensor | None = None, beta_x: Tensor | None = None, alpha_x: Tensor | None = None, emittance_x: Tensor | None = None, beta_y: Tensor | None = None, alpha_y: Tensor | None = None, emittance_y: Tensor | None = None, energy: Tensor | None = None, sigma_s: Tensor | None = None, sigma_p: Tensor | None = None, cor_s: Tensor | None = None, total_charge: Tensor | None = None, device=None, dtype=torch.float32) ParticleBeam ¶
Create a beam from twiss parameters.
- Parameters:
beta_x – Beta function in x direction in meters.
alpha_x – Alpha function in x direction in rad.
emittance_x – Emittance in x direction in m*rad.
beta_y – Beta function in y direction in meters.
alpha_y – Alpha function in y direction in rad.
emittance_y – Emittance in y direction in m*rad.
energy – Energy of the beam in eV.
total_charge – Total charge of the beam in C.
- classmethod make_linspaced(num_particles: Tensor | None = None, mu_x: Tensor | None = None, mu_y: Tensor | None = None, mu_xp: Tensor | None = None, mu_yp: Tensor | None = None, sigma_x: Tensor | None = None, sigma_y: Tensor | None = None, sigma_xp: Tensor | None = None, sigma_yp: Tensor | None = None, sigma_s: Tensor | None = None, sigma_p: Tensor | None = None, energy: Tensor | None = None, total_charge: Tensor | None = None, device=None, dtype=torch.float32) ParticleBeam ¶
Generate Cheetah Beam of n linspaced particles.
- Parameters:
n – Number of particles to generate.
mu_x – Center of the particle distribution on x in meters.
mu_y – Center of the particle distribution on y in meters.
mu_xp – Center of the particle distribution on x’ in rad.
mu_yp – Center of the particle distribution on y’ in rad.
sigma_x – Sigma of the particle distribution in x direction in meters.
sigma_y – Sigma of the particle distribution in y direction in meters.
sigma_xp – Sigma of the particle distribution in x’ direction in rad.
sigma_yp – Sigma of the particle distribution in y’ direction in rad.
sigma_s – Sigma of the particle distribution in s direction in meters.
sigma_p – Sigma of the particle distribution in p, dimensionless.
energy – Energy of the beam in eV.
device – Device to move the beam’s particle array to. If set to “auto” a CUDA GPU is selected if available. The CPU is used otherwise.
- property mu_p: Tensor | None¶
- property mu_s: Tensor | None¶
- property mu_x: Tensor | None¶
- property mu_xp: Tensor | None¶
- property mu_y: float | None¶
- property mu_yp: Tensor | None¶
- property num_particles: int¶
- property ps: Tensor | None¶
- property sigma_p: Tensor | None¶
- property sigma_s: Tensor | None¶
- property sigma_x: Tensor | None¶
- property sigma_xp: Tensor | None¶
- property sigma_xxp: Tensor¶
- property sigma_y: Tensor | None¶
- property sigma_yp: Tensor | None¶
- property sigma_yyp: Tensor¶
- property ss: Tensor | None¶
- property total_charge: Tensor¶
- transformed_to(mu_x: Tensor | None = None, mu_y: Tensor | None = None, mu_xp: Tensor | None = None, mu_yp: Tensor | None = None, sigma_x: Tensor | None = None, sigma_y: Tensor | None = None, sigma_xp: Tensor | None = None, sigma_yp: Tensor | None = None, sigma_s: Tensor | None = None, sigma_p: Tensor | None = None, energy: Tensor | None = None, total_charge: Tensor | None = None, device=None, dtype=torch.float32) ParticleBeam ¶
Create version of this beam that is transformed to new beam parameters.
- Parameters:
n – Number of particles to generate.
mu_x – Center of the particle distribution on x in meters.
mu_y – Center of the particle distribution on y in meters.
mu_xp – Center of the particle distribution on x’ in rad.
mu_yp – Center of the particle distribution on y’ in rad.
sigma_x – Sigma of the particle distribution in x direction in meters.
sigma_y – Sigma of the particle distribution in y direction in meters.
sigma_xp – Sigma of the particle distribution in x’ direction in rad.
sigma_yp – Sigma of the particle distribution in y’ direction in rad.
sigma_s – Sigma of the particle distribution in s direction in meters.
sigma_p – Sigma of the particle distribution in p, dimensionless.
energy – Energy of the beam in eV.
total_charge – Total charge of the beam in C.
device – Device to move the beam’s particle array to. If set to “auto” a CUDA GPU is selected if available. The CPU is used otherwise.
- classmethod uniform_3d_ellispoid(num_particles: Tensor | None = None, radius_x: Tensor | None = None, radius_y: Tensor | None = None, radius_s: Tensor | None = None, sigma_xp: Tensor | None = None, sigma_yp: Tensor | None = None, sigma_p: Tensor | None = None, energy: Tensor | None = None, total_charge: Tensor | None = None, device=None, dtype=torch.float32)¶
Generate a particle beam with spatially uniformly distributed particles inside an ellipsoid, i.e. a waterbag distribution.
- Note that:
The generated particles do not have correlation in the momentum directions, and by default a cold beam with no divergence is generated.
For batched generation, parameters that are not None must have the same shape.
- Parameters:
num_particles – Number of particles to generate.
radius_x – Radius of the ellipsoid in x direction in meters.
radius_y – Radius of the ellipsoid in y direction in meters.
radius_s – Radius of the ellipsoid in s (longitudinal) direction
in meters. :param sigma_xp: Sigma of the particle distribution in x’ direction in rad, default is 0. :param sigma_yp: Sigma of the particle distribution in y’ direction in rad, default is 0. :param sigma_p: Sigma of the particle distribution in p, dimensionless. :param energy: Energy of the beam in eV. :param total_charge: Total charge of the beam in C. :param device: Device to move the beam’s particle array to. :param dtype: Data type of the generated particles.
- Returns:
ParticleBeam with uniformly distributed particles inside an ellipsoid.
- property xps: Tensor | None¶
- property xs: Tensor | None¶
- property yps: Tensor | None¶
- property ys: Tensor | None¶