Skip to content

Commit

Permalink
Properly implement normalised emittance
Browse files Browse the repository at this point in the history
  • Loading branch information
jank324 committed Sep 3, 2023
1 parent 1d709e6 commit ba893a6
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions cheetah/particles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import torch
from scipy.constants import physical_constants
from torch.distributions import MultivariateNormal


Expand Down Expand Up @@ -183,7 +184,16 @@ def emittance_x(self) -> torch.Tensor:

@property
def normalized_emittance_x(self) -> torch.Tensor:
return self.emittance_x / self.energy # TODO: Is this correct?
relativistic_gamma = (
self.energy
/ physical_constants["electron mass energy equivalent in MeV"][0]
)
relativistic_beta = (
torch.sqrt(1 - 1 / (relativistic_gamma**2))
if torch.abs(relativistic_gamma) > 0
else 1.0
)
return self.emittance_x * relativistic_beta * relativistic_gamma

@property
def beta_x(self) -> torch.Tensor:
Expand All @@ -201,7 +211,16 @@ def emittance_y(self) -> torch.Tensor:

@property
def normalized_emittance_y(self) -> torch.Tensor:
return self.emittance_y / self.energy # TODO: Is this correct?
relativistic_gamma = (
self.energy
/ physical_constants["electron mass energy equivalent in MeV"][0]
)
relativistic_beta = (
torch.sqrt(1 - 1 / (relativistic_gamma**2))
if torch.abs(relativistic_gamma) > 0
else 1.0
)
return self.emittance_y * relativistic_beta * relativistic_gamma

@property
def beta_y(self) -> torch.Tensor:
Expand Down

0 comments on commit ba893a6

Please sign in to comment.