apace.twiss

Module Contents

Classes

Twiss

Calculate the Twiss parameter for a given lattice.

Attributes

CONST_C

CONST_Q

CONST_ME

CONST_E

CONST_MEV

TWO_PI

apace.twiss.CONST_C = 299792458
apace.twiss.CONST_Q = 3.832e-13
apace.twiss.CONST_ME = 9.1093837015e-31
apace.twiss.CONST_E = 1.602176634e-19
apace.twiss.CONST_MEV = 1.602176634e-13
apace.twiss.TWO_PI
class apace.twiss.Twiss(lattice, start_idx=0, **kwargs)

Inherits: apace.matrixmethod.MatrixMethod

Calculate the Twiss parameter for a given lattice.

Parameters
  • lattice (Lattice) – Lattice to calculate the Twiss parameter for.

  • start_idx (int, optional) – Index from which the accumulated array is calculated. This index is also used to calculated the initial twiss parameter using the periodicity condition.

  • energy (float, optional) – Energy of the beam in mev

Attributes

start_idx_changed

Gets emitted when the start index changes

one_turn_matrix_changed

Gets emitted when the one turn matrix changes.

twiss_array_changed

Gets emitted when the twiss functions change.

psi_changed

Gets emitted when the betatron phase changes.

tune_fractional_changed

Gets emitted when the fractional tune changes.

start_idx

Index from which the accumulated array is calculated. This index is also used to calculated the initial twiss parameter using the periodicity condition.

Return type

int

accumulated_array

Contains accumulated transfer matrices.

Return type

numpy.ndarray

one_turn_matrix

The transfer matrix for a full turn.

Return type

numpy.ndarray

term_x

Corresponds to \(2 - m_{11}^2 - 2 m_{12} m_{21} - m_{22}^2\), where \(m\) is the one turn matrix. Can be used to calculate the initial beta_x value \(\beta_{x0} = |2 m_{12}| / \sqrt{term_x}\). If term_x > 0, this means that there exists a periodic solution within the horizontal plane.

Return type

float

term_y

Corresponds to \(2 - m_{33}^2 - 2 m_{34} m_{43} - m_{44}^2\), where \(m\) is the one turn matrix. Can be used to calculate the initial beta_y value \(\beta_{y0} = |2 m_{12}| / \sqrt{term_y}\). If term_y > 0, this means that there exists a periodic solution within the vertical plane.

Return type

float

stable_x

Periodicity condition term_x > 0 for a stable solution in the horizontal plane.

Return type

bool

stable_y

Periodicity condition term_y > 0 for a stable solution in the vertical plane.

Return type

bool

stable

Periodicity condition term_x > 0 and term_y > 0 for a stable solution in both planes.

Return type

bool

initial_twiss

Array containing the initial twiss parameter.

Return type

numpy.ndarray

twiss_array

Contains the twiss parameter.

Return type

numpy.ndarray

beta_x

Horizontal beta function.

Return type

numpy.ndarray

beta_y

Vertical beta function.

Return type

numpy.ndarray

alpha_x

Horizontal alpha function.

Return type

numpy.ndarray

alpha_y

Vertical alpha function.

Return type

numpy.ndarray

gamma_x

Horizontal gamma function.

Return type

numpy.ndarray

gamma_y

Vertical gamma function.

Return type

numpy.ndarray

eta_x

Horizontal dispersion function.

Return type

numpy.ndarray

eta_x_dds

Derivative of the horizontal dispersion with respect to s.

Return type

numpy.ndarray

psi_x

Horizontal betatron phase.

Return type

numpy.ndarray

psi_y

Vertical betatron phase.

Return type

numpy.ndarray

tune_x

Horizontal tune. Corresponds to psi_x[-1] / 2 pi. Strongly depends on the selected step size.

Return type

float

tune_y

Vertical tune. Corresponds to psi_y[-1] / 2 pi. Strongly depends on the selected step size.

Return type

float

tune_x_fractional

Fractional part of the horizontal tune (Calculated from one-turn matrix).

Return type

float

tune_y_fractional

Fractional part of the vertical tune (Calculated from one-turn matrix).

Return type

float

chromaticity_x

Natural Horizontal Chromaticity. Depends on n_kicks

Return type

float

chromaticity_y

Natural Vertical Chromaticity. Depends on n_kicks

Return type

float

curly_h

The curly H function.

Return type

float

i1

The first synchrotron radiation integral.

Return type

float

i2

The second synchrotron radiation integral.

Return type

float

i3

The third synchrotron radiation integral.

Return type

float

i4

The fourth synchrotron radiation integral.

Return type

float

i5

The fifth synchrotron radiation integral.

Return type

float

alpha_c

Momentum Compaction Factor. Depends on n_kicks

Return type

float

gamma
Return type

float

emittance_x
Return type

float

energy
Return type

float

velocity
Return type

float

n_steps

Total number of steps.

Return type

int

element_indices

Contains the indices of each element within the transfer_matrices.

Return type

Dict[apace.classes.Element, List[int]]

step_size

Contains the step_size for each point. Has length of n_kicks

Return type

numpy.ndarray

s

Contains the orbit position s for each point. Has length of n_kicks + 1.

Return type

numpy.ndarray

matrices

Array of transfer matrices with shape (6, 6, n_kicks)

Return type

numpy.ndarray

k0

Array of deflections angles with shape (n_kicks).

Return type

numpy.ndarray

k1

Array of geometric quadruole strenghts with shape (n_kicks).

Return type

numpy.ndarray

start_index

Start index of the one-turn matrix and the accumulated transfer matrices.

Return type

int

start_position

Same as start_index, but position in meter instead of index.

Return type

float

matrices_acc

The accumulated transfer matrices starting from start_index.

Return type

numpy.ndarray

Methods

update_one_turn_matrix()

Manually update the one turn matrix and the accumulated array.

_on_one_turn_matrix_changed()
update_twiss_array()

Manually update the twiss_array.

_on_twiss_array_changed()
update_betatron_phase()

Manually update the betatron phase psi and the tune.

_on_psi_changed()
update_fractional_tune()

Manually update the fractional tune.

_on_tune_fractional_changed()
update_chromaticity()

Manually update the natural chromaticity.

_on_chromaticity_changed()
_on_curly_h_changed()
_on_i1_changed()
_on_i2_changed()
_on_i3_changed()
_on_i4_changed()
_on_i5_changed()
_on_alpha_c_changed()
_on_emittance_changed()
_on_element_changed(element, attribute)
update_n_steps()

Manually update the total number of kicks.

_on_n_steps_changed()
update_element_indices()

Manually update the indices of each element.

_on_element_indices_changed()
update_step_size()

Manually update the step_size array.

_on_step_size_changed()
update_s()

Manually update the orbit position array s.

_on_s_changed()
update_matrices()

Manually update the transfer_matrices.

update_matrices_acc()
_on_matrices_accumulated_changed()