Resonance Driving Terms

Functions for the calculations of Resonance Driving Terms, as well as getting lists of valid driving term indices for certain orders.

optics_functions.rdt.calculate_rdts(df: TfsDataFrame, rdts: Sequence[str], qx: float | None = None, qy: float | None = None, feeddown: int = 0, complex_columns: bool = True, loop_phases: bool = False, hamiltionian_terms: bool = False) TfsDataFrame[source]

Calculates the Resonance Driving Terms.

Eq. (A8) in [FranchiAnalyticFormulas2017] . One might notice that this code implementation has a factor \(2 \pi\) in the exponential term of the numerator that is not found in Eq. (A8) of the reference. This is due to the fact that in [FranchiAnalyticFormulas2017], phase advances are in radians whereas the expected values for this code are output by MAD-X, which makes them in units of \(2 \pi\).

Parameters:
  • df (TfsDataFrame) -- Twiss Dataframe.

  • rdts (Sequence) -- List of rdt-names to calculate.

  • qx (float) -- Tune in X-Plane (if not given, header df.Q1 is assumed present).

  • qy (float) -- Tune in Y-Plane (if not given, header df.Q2 is assumed present).

  • feeddown (int) -- Levels of feed-down to include.

  • complex_columns (bool) -- Output complex values in single column of type complex. If False, split complex columns into two real-valued columns.

  • loop_phases (bool) -- Loop over elements when calculating phase-advances. Might be slower for small number of elements, but allows for large (e.g. sliced) optics.

  • hamiltionian_terms (bool) -- Add the hamiltonian terms to the result dataframe.

Returns:

New TfsDataFrame with RDT columns.

optics_functions.rdt.generator(orders: Sequence[int], normal: bool = True, skew: bool = True, complex_conj: bool = True) dict[source]

Generates lists of RDT-4-tuples sorted into a dictionary by order.

Parameters:
  • orders (list) -- list of orders to be generated. Orders < 2 raise errors.

  • normal (bool) -- generate normal RDTs (default: True).

  • skew (bool) -- generate skew RDTs (default: True).

  • complex_conj (bool) -- Have both, RDT and it’s complex conjugate RDT in the list (default: True).

Returns:

Dictionary with keys of orders containing lists of 4-Tuples for the RDTs of that order.

optics_functions.rdt.get_ac_dipole_rdts(order_or_terms: int | str | Sequence[str], spectral_line: Tuple[int], plane: str, ac_tunes: Tuple[float, float], acd_name: str)[source]

Calculates the Hamiltonian Terms under Forced Motion.

Parameters:
  • order_or_terms (Union[int, str, Sequence[str]]) -- If an int is given all Resonance Driving Terms up to this order will be calculated. The strings are assumed to be the desired driving term names, e.g. “F1001”

  • spectral_line (Tuple[int]) -- Needed to determine what phase advance is needed before and after AC dipole location, depends on detal+ and delta-. Sample input: (2,-1)

  • plane (str) -- Either ‘H’ or ‘V’ to determine phase term of AC dipole before and after ACD location.

  • ac_tunes (Tuple[float, float]) -- i.e. (0.302, 0.33)

  • acd_name (str) -- The AC Dipole element name (?).

optics_functions.rdt.get_all_to_order(n: int) List[Tuple[int, int, int, int]][source]

Returns list of all valid RDT jklm-tuple of order 2 to n