pyaccelerator.utils¶
Module Contents¶
Functions¶
|
Plot the evolution of twiss parameters through the lattice. |
|
Plot the evolution of phase space coordinates through the lattice. |
|
Plot the phase space coordinates distribution. |
|
Helper function to create 1D vertical arrays. |
|
Helper function to create twiss vectors. |
|
Helper function to create phase space coordinate vectors. |
|
Given 2 twiss parameters, compute the third. |
|
Iteratively compute the matrix multiplictions of the arrays in the |
|
Compute twiss clojure condition: |
|
Compute the twiss transfer matrix from a 2x2 phase space transfer |
|
Compute the periodic twiss solution for the provided transfer matrix. |
-
pyaccelerator.utils.plot_twiss(self) → Tuple[plt.Figure, plt.Axes][source]¶ Plot the evolution of twiss parameters through the lattice.
- Returns
The plotted
plt.Figureandplt.Axes.
-
pyaccelerator.utils.plot_phasespace(self, plane: str = 'both', style: str = 'auto', add_legend: bool = True) → Tuple[plt.Figure, plt.Axes][source]¶ Plot the evolution of phase space coordinates through the lattice.
- Parameters
plane – plane of interest, either ‘h’ or ‘v’.
style – either ‘s’, ‘phasespace’ or ‘auto’.
add_legend – if True will add the s coordinate as the legend when plotting in phasespace.
- Returns
The plotted
plt.Figureandplt.Axes.
-
pyaccelerator.utils.plot_phasespace_distribution(self, plane: str = 'both') → Tuple[plt.Figure, plt.Axes][source]¶ Plot the phase space coordinates distribution.
- Parameters
plane – plane of interest, either ‘h’ or ‘v’.
- Returns
The plotted
plt.Figureandplt.Axes.
-
pyaccelerator.utils.to_v_vec(vec: Sequence[float]) → np.ndarray[source]¶ Helper function to create 1D vertical arrays.
- Parameters
vec – Vector to convert to vertical array.
- Returns
Vertical 1D
np.ndarray.
-
pyaccelerator.utils.to_twiss(twiss: Sequence[Union[float, None]]) → np.ndarray[source]¶ Helper function to create twiss vectors.
- Parameters
twiss – List of length 3, a single twiss parameter can be None.
- Returns
Completed vertical 1D twiss parameter
np.ndarray.
-
pyaccelerator.utils.to_phase_coord(phase_coord: Sequence[float]) → np.ndarray[source]¶ Helper function to create phase space coordinate vectors.
- Parameters
phase_coord – List of length 3.
- Returns
Vertical 1D
np.ndarray.
-
pyaccelerator.utils.complete_twiss(beta: Optional[float] = None, alpha: Optional[float] = None, gamma: Optional[float] = None) → Tuple[float, float, float][source]¶ Given 2 twiss parameters, compute the third.
- Parameters
beta (optional) – Beta function in meters.
alpha (optional) – Twiss alpha in radians.
gamma (optional) – Twiss gamma in meter^-1.
- Returns
Tuple of completes twiss parameters, (beta, alpha, gamma).
-
pyaccelerator.utils.compute_one_turn(list_of_m: Sequence[np.array]) → np.array[source]¶ Iteratively compute the matrix multiplictions of the arrays in the provided sequence.
- Parameters
list_of_m – Sequence of transfer matrices.
- Returns
Result of the iterative matrix multiplication of the matrices.
-
pyaccelerator.utils.compute_twiss_clojure(twiss: Sequence[float]) → float[source]¶ Compute twiss clojure condition:
beta * gamma - alpha^2 = 1
- Parameters
twiss – List of twiss parameters, [beta[m], alpha[rad], gamma[m]]
- Returns
beta * gamma - alpha^2