Normal
Normalization matrix utils
- twiss.normal.cs_normal(pars: torch.Tensor) torch.Tensor [source]
Generate Courant-Snyder normalization matrix
- Parameters:
pars (Tensor) – Courant-Snyder twiss parameters ax, bx, ay, by
- Returns:
normalization matrix N, M = N R N^-1
- Return type:
Tensor
Note
[ax, bx, ay, by] are CS twiss parameters
Examples
>>> import torch >>> from twiss.matrix import is_symplectic >>> pars = torch.tensor([0, 1, 0, 1], dtype=torch.float64) >>> is_symplectic(cs_normal(pars)) True
- twiss.normal.lb_normal(pars: torch.Tensor) torch.Tensor [source]
Generate Lebedev-Bogacz normalization matrix
- Parameters:
pars (Tensor) – Lebedev-Bogacz twiss parameters a1x, b1x, a2x, b2x, a1y, b1y, a2y, b2y, u, v1, v2
- Returns:
normalization matrix N, M = N R N^-1
- Return type:
Tensor
Note
[a1x, b1x, a2x, b2x, a1y, b1y, a2y, b2y, u, v1, v2] are LB twiss parameters [a1x, b1x, a2y, b2y] are ‘in-plane’ twiss parameters
Examples
>>> import torch >>> from twiss.matrix import is_symplectic >>> pars = torch.tensor([0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0], dtype=torch.float64) >>> is_symplectic(lb_normal(pars)) True
- twiss.normal.normal_to_wolski(n: torch.Tensor) torch.Tensor [source]
Compute Wolski twiss matrices for a given normalization matrix
- Parameters:
n (torch.Tensor, even-dimension, symplectic) – normalization matrix
- Return type:
Tensor
Examples
>>> from math import pi >>> import torch >>> from twiss.matrix import rotation >>> m = rotation(2*pi*torch.tensor(0.88, dtype=torch.float64)) >>> t, n, w = twiss(m) >>> torch.allclose(normal_to_wolski(n), w) True
- twiss.normal.parametric(pars: torch.Tensor) torch.Tensor [source]
Generate ‘parametric’ 4x4 normalization matrix for given free elements
- Parameters:
pars (Tensor) – free matrix elements n11, n33, n21, n43, n13, n31, n14, n41
- Returns:
normalization matrix N M = N R N^-1
- Return type:
Tensor
Note
Elements denoted with x are computed for given free elements using symplectic condition For n11 > 0 & n33 > 0, all matrix elements are not singular in uncoupled limit
n11 0 n13 n14 n21 x x x n31 x n33 0 n41 x n43 x
Examples
>>> import torch >>> from twiss.matrix import is_symplectic >>> pars = torch.tensor([1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) >>> is_symplectic(parametric(pars)) True
- twiss.normal.wolski_to_normal(w: torch.Tensor, *, epsilon: float = 1e-12) torch.Tensor [source]
Compute normalization matrix for given Wolski twiss matrices
- Parameters:
w (Tensor) – Wolski twiss matrices
epsilon (float, optional, default=1.0E-12) – tolerance epsilon
- Return type:
Tensor
Note
Normalization matrix is computed using fake one-turn matrix with fixed tunes
Examples
>>> from math import pi >>> import torch >>> from twiss.matrix import rotation >>> m = rotation(2*pi*torch.tensor(0.88, dtype=torch.float64)) >>> t, n, w = twiss(m) >>> torch.allclose(wolski_to_normal(w), n) True