input_parameters Package

rf_parameters Module

Module gathering and processing all RF parameters used in the simulation.

Authors

Alexandre Lasheen, Danilo Quartullo, Helga Timko

class blond.input_parameters.rf_parameters.RFStation(Ring, harmonic, voltage, phi_rf_d, n_rf=1, section_index=1, omega_rf=None, phi_noise=None, phi_modulation=None, RFStationOptions=<blond.input_parameters.rf_parameters_options.RFStationOptions object>)

Bases: object

Class containing all the RF parameters for all the RF systems in one ring segment or RF station.

How to use RF programs:

  • For 1 RF system and constant values of V, h, or phi, input a single value

  • For 1 RF system and varying values of V, h, or phi, input an array of n_turns+1 values

  • For several RF systems and constant values of V, h, or phi, input lists of single values

  • For several RF systems and varying values of V, h, or phi, input lists of arrays of n_turns+1 values

  • For pre-processing, pass a list of times-voltages, times-harmonics, and/or times-phases for each RF system as a tuple ((time_1, voltage_1), (time_2, voltage_2), …)

Optional: RF frequency other than the design frequency. In this case, need to use a beam phase loop for correct RF phase!

Optional: empty RFStation (e.g. for machines with synchrotron radiation); input voltage as 0.

The index \(n\) denotes time steps, \(l\) the index of the RF systems in the section.

N.B. for negative eta the RF phase has to be shifted by Pi w.r.t the time reference.

Parameters
  • Ring (class) – A Ring type class

  • harmonic (float (opt: float array/matrix, tuple of float array/matrix)) – Harmonic number of the RF system, \(h_{l,n}\) [1]. For input options, see above

  • voltage (float (opt: float array/matrix, tuple of float array/matrix)) – RF cavity voltage as seen by the beam, \(V_{l,n}\) [V]. For input options, see above

  • phi_rf_d (float (opt: float array/matrix, tuple of float array/matrix)) – Programmed/designed RF cavity phase, \(\phi_{d,l,n}\) [rad]. For input options, see above

  • n_rf (int) – Optional, Number of harmonic rf systems in the section \(l\). Becomes mandatory for several rf systems.

  • section_index (int) – Optional, In case of several sections in the Ring object, this specifies after which section the rf station is located (to get the right momentum program etc.). Value should be in the range 1..Ring.n_sections

  • omega_rf (float (opt: float array/matrix)) – Optional, Sets the rf angular frequency program that does not follow the harmonic condition. For input options, see above.

  • phi_noise (float (opt: float array/matrix)) – Optional, programmed RF cavity phase noise, \(\phi_{N,l,n}\) [rad]. Added to all RF systems in the station. For input options, see above

  • phi_modulation (class (opt: iterable of classes)) – A PhaseModulation type class (or iterable of classes)

  • RFStationOptions (class) – Optionnal, A RFStationOptions-based class defining smoothing, interpolation, etc. options for harmonic, voltage, and/or phi_rf_d programme to be interpolated to a turn-by-turn programme

counter

Counter of the current simulation time step; defined as a list in order to be passed by reference

Type

int

section_index

Unique index \(k\) of the RF station the present class is defined for. Input in the range 1..n_sections (see input_parameters.ring.Ring). Inside the code, indices 0..n_sections-1 are used.

Type

int

Particle

Inherited from input_parameters.ring.Ring.Particle

Type

class

n_turns

Inherited from input_parameters.ring.Ring.n_turns

Type

int

ring_circumference

Inherited from input_parameters.ring.Ring.ring_circumference

Type

float

section_length

Length \(L_k\) of the RF section; inherited from input_parameters.ring.Ring.ring_length

Type

float

length_ratio

Fractional RF section length \(L_k/C\)

Type

float

t_rev

Inherited from input_parameters.ring.Ring.t_rev

Type

float array [n_turns+1]

momentum

Momentum program of the present RF section; inherited from input_parameters.ring.Ring.momentum

Type

float array [n_turns+1]

beta

Relativistic beta of the present RF section; inherited from input_parameters.ring.Ring.beta

Type

float array [n_turns+1]

gamma

Relativistic gamma of the present RF section; inherited from input_parameters.ring.Ring.gamma

Type

float array [n_turns+1]

energy

Total energy of the present RF section; inherited from input_parameters.ring.Ring.energy

Type

float array [n_turns+1]

delta_E

Time derivative of total energy of the present section; inherited from input_parameters.ring.Ring.delta_E

Type

float array [n_turns+1]

alpha_order

Inherited from input_parameters.ring.Ring.alpha_order

Type

int

charge

Inherited from beam.Particle.charge

Type

int

alpha_0

Zeroth order momentum compaction factor of the present section; inherited from input_parameters.ring.Ring.alpha_0

Type

float array [n_turns+1]

alpha_1

First order momentum compaction factor of the present section; inherited from input_parameters.ring.Ring.alpha_1

Type

float array [n_turns+1]

alpha_2

Second order momentum compaction factor of the present section; inherited from input_parameters.ring.Ring.alpha_2

Type

float array [n_turns+1]

eta_0

Zeroth order slippage factor of the present section; inherited from input_parameters.ring.Ring.eta_0

Type

float array [n_turns+1]

eta_1

First order slippage factor of the present section; inherited from input_parameters.ring.Ring.eta_1

Type

float array [n_turns+1]

eta_2

Second order slippage factor of the present section; inherited from input_parameters.ring.Ring.eta_2

Type

float array [n_turns+1]

sign_eta_0

Sign of the eta_0 array

Type

float array

harmonic

Harmonic number for each rf system, \(h_{l,n}\) [1]

Type

float matrix [n_rf, n_turns+1]

voltage

Actual rf voltage of each harmonic system, \(V_{rf,l,n}\) [V]

Type

float matrix [n_rf, n_turns+1]

empty

Flag to specify if the RFStation is empty

Type

bool

phi_rf_d

Designed rf cavity phase of each harmonic system, \(\phi_{d,l,n}\) [rad]

Type

float matrix [n_rf, n_turns+1]

phi_rf

Actual RF cavity phase of each harmonic system used for tracking, \(\phi_{rf,l,n}\) [rad]. Initially the same as the designed phase.

Type

float matrix [n_rf, n_turns+1]

omega_rf_d

Design RF angular frequency of the RF systems in the station \(\omega_{d,l,n} = \frac{h_{l,n} \beta_{l,n} c}{R_{s,n}}\) [Hz]

Type

float matrix [n_rf, n_turns+1]

omega_rf

Actual RF angular frequency of the RF systems in the station \(\omega_{rf,l,n} = \frac{h_{l,n} \beta_{l,n} c}{R_{s,n}}\) [Hz]. Initially the same as the designed angular frequency.

Type

float matrix [n_rf, n_turns+1]

phi_noise

Programmed cavity phase noise for each RF harmonic.

Type

None or float matrix [n_rf, n_turns+1]

phi_modulation

Programmed cavity phase modulation for each RF harmonic.

Type

None or float matrix [n_rf, n_turns+1]

dphi_rf

Accumulated RF phase error of each harmonic system \(\Delta \phi_{rf,l,n}\) [rad]

Type

float matrix [n_rf]

t_rf

RF period \(\frac{2 \pi}{\omega_{rf,l,n}}\) [s]

Type

float matrix [n_rf, n_turns+1]

phi_s

Synchronous phase for this section, calculated in input_parameters.rf_parameters.calculate_phi_s()

Type

float array [n_turns+1]

Q_s

Synchrotron tune for this section, calculated in input_parameters.rf_parameters.calculate_Q_s()

Type

float array [n_turns+1]

omega_s0

Central synchronous angular frequency corresponding to Q_s (single harmonic, no intensity effects) \(\omega_{s,0} = Q_s \omega_{\text{rev}}\) [1/s], where \(\omega_{\text{rev}}\) is defined in input_parameters.ring.Ring)

Type

float array [n_turns+1]

RFStationOptions

The RFStationOptions is kept as an attribute of the RFStationg object for further usage.

Type

RFStationOptions()

Examples

>>> # To declare a double-harmonic RF system for protons:
>>>
>>> n_turns = 10
>>> C = 26659
>>> alpha = 3.21e-4
>>> momentum = 450e9
>>> ring = Ring(n_turns, C, alpha, momentum)
>>> rf_station = RFStation(ring, [35640, 71280], [6e6, 6e5], [0, 0], 2)
eta_tracking(beam, counter, dE)

Function to calculate the slippage factor as a function of the energy offset \(\Delta E\) of the particle. The slippage factor of the \(i\) th order is \(\eta(\delta) = \sum_{i}(\eta_i \, \delta^i) = \sum_{i} \left(\eta_i \, \left[ \frac{\Delta E} {\beta_s^2 E_s} \right]^i \right)\)

blond.input_parameters.rf_parameters.calculate_Q_s(RFStation, Particle=<blond.beam.beam.Proton object>)

Function calculating the turn-by-turn synchrotron tune for single-harmonic RF, without intensity effects.

Parameters
  • RFStation (class) – An RFStation type class.

  • Particle (class) – A Particle type class; default is Proton().

Returns

Synchrotron tune.

Return type

float

blond.input_parameters.rf_parameters.calculate_phi_s(RFStation, Particle=<blond.beam.beam.Proton object>, accelerating_systems='as_single')

Function calculating the turn-by-turn synchronous phase according to the parameters in the RFStation object. The phase is expressed in the lowest RF harmonic and with respect to the RF bucket (see the equations of motion defined for BLonD). The returned value is given in the range [0, 2*Pi]. Below transition, the RF wave is shifted by Pi w.r.t. the time reference.

The accelerating_systems option can be set to

  • ‘as_single’ (default): the synchronous phase is calculated analytically taking into account the phase program (RFStation.phi_offset).

  • ‘all’: the synchronous phase is calculated numerically by finding the minimum of the potential well; no intensity effects included. In case of several minima, the deepest is taken. WARNING: in case of RF harmonics with comparable voltages, this may lead to inconsistent values of phi_s.

  • ‘first’: not yet implemented. Its purpose should be to adjust the RFStation.phi_offset of the higher harmonics so that only the main harmonic is accelerating.

Parameters
  • RFStation (class) – An RFStation type class.

  • Particle (class) – A Particle type class; default is Proton().

  • accelerating_systems (str) – Choice of accelerating systems; or options, see list above.

Returns

Synchronous phase.

Return type

float

ring Module

Module gathering all general input parameters used for the simulation.
Authors

Alexandre Lasheen, Danilo Quartullo, Helga Timko

class blond.input_parameters.ring.Ring(ring_length, alpha_0, synchronous_data, Particle, n_turns=1, synchronous_data_type='momentum', bending_radius=None, n_sections=1, alpha_1=None, alpha_2=None, RingOptions=<blond.input_parameters.ring_options.RingOptions object>)

Bases: object

Class containing the general properties of the synchrotron that are independent of the RF system or the beam.

The index \(n\) denotes time steps, \(k\) ring segments/sections and \(i\) momentum compaction orders.

Parameters
  • ring_length (float (opt: float array [n_sections])) – Length [m] of the n_sections ring segments of the synchrotron. An RF station, a synchrotron radiation kick, and/or an impedance kick can be included at the end of each ring section.

  • alpha_0 (float (opt: float array/matrix [n_sections, n_turns+1])) – Momentum compaction factor of zeroth order \(\alpha_{0,k,i}\) [1]; can be input as single float or as a program of (n_turns + 1) turns (should be of the same size as synchronous_data). In case of higher order momentum compaction, check the documentation for the inputs: alpha_order, alpha_1, alpha_2

  • synchronous_data (float (opt: float array/matrix [n_sections, n_turns+1])) – Design synchronous particle momentum (default) [eV], kinetic or total energy [eV] or bending field [T] on the design orbit. Input for each RF section \(p_{s,k,n}\). Can be input as a single constant float, or as a program of (n_turns + 1) turns. In case of several sections without acceleration, input: [[momentum_section_1], [momentum_section_2], etc.]. In case of several sections with acceleration, input: [momentum_program_section_1, momentum_program_section_2, etc.]. Can be input also as a tuple of time and momentum, see also ‘cycle_time’ and ‘PreprocessRamp’

  • Particle (class) – A Particle-based class defining the primary, synchronous particle (mass and charge) that is reference for the momentum/energy in the ring.

  • n_turns (int) – Optional: Number of turns \(n\) [1] to be simulated. If a synchronous_data program is passed as a tuple (see below), the number of turns will be overwritten depending on the length in time of the program

  • synchronous_data_type (str) – Optional: Choice of ‘synchronous_data’ type; can be ‘momentum’ (default), ‘total energy’, ‘kinetic energy’ or ‘bending field’ (requires bending_radius to be defined)

  • bending_radius (float) – Optional: Radius [m] of the bending magnets, required if ‘bending field’ is set for the synchronous_data_type

  • n_sections (int) – Optional: number of ring sections/segments; default is 1

  • alpha_1 (float (opt: float array/matrix [n_sections, n_turns+1])) – Momentum compaction factor of first order \(\alpha_{1,k,i}\) [1]; can be input as single float or as a program of (n_turns + 1) turns (should be of the same size as synchronous_data and alpha_0).

  • alpha_2 (float (opt: float array/matrix [n_sections, n_turns+1])) – Optional : Momentum compaction factor of second order \(\alpha_{2,k,i}\) [1]; can be input as single float or as a program of (n_turns + 1) turns (should be of the same size as synchronous_data and alpha_0).

  • RingOptions (class) – Optional : A RingOptions-based class with default options to check the input and initialize the momentum program for the simulation. This object defines the interpolation scheme, plotting options, etc. The options for this object can be adjusted and passed to the Ring object.

ring_circumference

Circumference of the synchrotron. Sum of ring segment lengths, \(C = \sum_k L_k\) [m]

Type

float

ring_radius

Radius of the synchrotron, \(R = C/(2 \pi)\) [m]

Type

float

bending_radius

Bending radius in dipole magnets, \(\rho\) [m]

Type

float

alpha_order

Highest order of momentum compaction (as defined by the input). Can be 0,1,2.

Type

int

alpha_0

Zeroth order momentum compaction factor \(\alpha_{0,k,n}\)

Type

float matrix [n_sections, n_turns+1]

alpha_1

First order momentum compaction factor \(\alpha_{1,k,n}\)

Type

float matrix [n_sections, n_turns+1]

alpha_2

Second order momentum compaction factor \(\alpha_{2,k,n}\)

Type

float matrix [n_sections, n_turns+1]

eta_0

Zeroth order slippage factor \(\eta_{0,k,n} = \alpha_{0,k,n} - \frac{1}{\gamma_{s,k,n}^2}\) [1]

Type

float matrix [n_sections, n_turns+1]

eta_1

First order slippage factor \(\eta_{1,k,n} = \frac{3\beta_{s,k,n}^2}{2\gamma_{s,k,n}^2} + \alpha_{1,k,n} - \alpha_{0,k,n}\eta_{0,k,n}\) [1]

Type

float matrix [n_sections, n_turns+1]

eta_2

Second order slippage factor \(\eta_{2,k,n} = -\frac{\beta_{s,k,n}^2\left(5\beta_{s,k,n}^2-1\right)} {2\gamma_{s,k,n}^2} + \alpha_{2,k,n} - 2\alpha_{0,k,n}\alpha_{1,k,n} + \frac{\alpha_{1,k,n}}{\gamma_{s,k,n}^2} + \alpha_{0,k}^2\eta_{0,k,n} - \frac{3\beta_{s,k,n}^2\alpha_{0,k,n}}{2\gamma_{s,k,n}^2}\) [1]

Type

float matrix [n_sections, n_turns+1]

momentum

Synchronous relativistic momentum on the design orbit \(p_{s,k,n}\)

Type

float matrix [n_sections, n_turns+1]

beta

Synchronous relativistic beta program for each segment of the ring \(\beta_{s,k}^n = \frac{1}{\sqrt{1 + \left(\frac{m}{p_{s,k,n}}\right)^2} }\) [1]

Type

float matrix [n_sections, n_turns+1]

gamma

Synchronous relativistic gamma program for each segment of the ring \(\gamma_{s,k,n} = \sqrt{ 1 + \left(\frac{p_{s,k,n}}{m}\right)^2 }\) [1]

Type

float matrix [n_sections, n_turns+1]

energy

Synchronous total energy program for each segment of the ring \(E_{s,k,n} = \sqrt{ p_{s,k,n}^2 + m^2 }\) [eV]

Type

float matrix [n_sections, n_turns+1]

kin_energy

Synchronous kinetic energy program for each segment of the ring \(E_{s,kin} = \sqrt{ p_{s,k,n}^2 + m^2 } - m\) [eV]

Type

float matrix [n_sections, n_turns+1]

delta_E

Derivative of synchronous total energy w.r.t. time, for all sections, \(: \quad E_{s,k,n+1}- E_{s,k,n}\) [eV]

Type

float matrix [n_sections, n_turns+1]

t_rev

Revolution period turn by turn. \(T_{0,n} = \frac{C}{\beta_{s,n} c}\) [s]

Type

float array [n_turns+1]

f_rev

Revolution frequency \(f_{0,n} = \frac{1}{T_{0,n}}\) [Hz]

Type

float array [n_turns+1]

omega_rev

Revolution angular frequency \(\omega_{0,n} = 2\pi f_{0,n}\) [1/s]

Type

float array [n_turns+1]

cycle_time

Cumulative cycle time, turn by turn, \(t_n = \sum_n T_{0,n}\) [s]. Possibility to extract cycle parameters at these moments using ‘parameters_at_time’.

Type

float array [n_turns+1]

RingOptions

The RingOptions is kept as an attribute of the Ring object for further usage.

Type

RingOptions()

Examples

>>> # To declare a single-section synchrotron at constant energy:
>>> # Particle type Proton
>>> from beam.beam import Proton
>>> from input_parameters.ring import Ring
>>>
>>> n_turns = 10
>>> C = 26659
>>> alpha_0 = 3.21e-4
>>> momentum = 450e9
>>> ring = Ring(C, alpha_0, momentum, Proton(), n_turns)
>>>
>>>
>>> # To declare a two section synchrotron at constant energy and
>>> # higher-order momentum compaction factors; particle Electron:
>>> from beam.beam import Electron
>>> from input_parameters.ring import Ring
>>>
>>> n_turns = 10
>>> C = [13000, 13659]
>>> alpha_0 = [[3.21e-4], [2.89e-4]]  # or [3.21e-4, 2.89e-4]
>>> alpha_1 = [[2.e-5], [1.e-5]]  # or [2.e-5, 1.e-5]
>>> alpha_2 = [[5.e-7], [5.e-7]]  # or [5.e-7, 5.e-7]
>>> momentum = 450e9
>>> ring = Ring(C, alpha_0, momentum, Electron(), n_turns,
>>>             alpha_1=alpha_1, alpha_2=alpha_2)
eta_generation()

Function to generate the slippage factors (zeroth, first, and second orders, see 1) from the momentum compaction and the relativistic beta and gamma program through the cycle.

References

1

“Accelerator Physics,” S. Y. Lee, World Scientific, Third Edition, 2012.

parameters_at_time(cycle_moments)

Function to return various cycle parameters at a specific moment in time. The cycle time is defined to start at zero in turn zero.

Parameters

cycle_moments (float array) – Moments of time at which cycle parameters are to be calculated [s].

Returns

parameters – Contains ‘momentum’, ‘beta’, ‘gamma’, ‘energy’, ‘kin_energy’, ‘f_rev’, ‘t_rev’. ‘omega_rev’, ‘eta_0’, and ‘delta_E’ interpolated to the moments contained in the ‘cycle_moments’ array

Return type

dictionary

ring_options Module

Function(s) for pre-processing input data

Authors

Helga Timko, Alexandre Lasheen, Danilo Quartullo, Simon Albright

class blond.input_parameters.ring_options.RingOptions(interpolation='linear', smoothing=0, flat_bottom=0, flat_top=0, t_start=None, t_end=None, plot=False, figdir='fig', figname='preprocess_ramp', sampling=1)

Bases: object

Class to preprocess the synchronous data for Ring, interpolating it to every turn.

Parameters
  • interpolation (str) – Interpolation options for the data points. Available options are ‘linear’ (default), ‘cubic’, and ‘derivative’

  • smoothing (float) – Smoothing value for ‘cubic’ interpolation

  • flat_bottom (int) – Number of turns to be added on flat bottom; default is 0. Constant extrapolation is used for the synchronous data

  • flat_top (int) – Number of turns to be added on flat top; default is 0. Constant extrapolation is used for the synchronous data

  • t_start (int) – Starting index from which the time array input should be taken into account; default is 0

  • t_end (int) – Last index up to which the time array input should be taken into account; default is -1

  • plot (bool) – Option to plot interpolated arrays; default is False

  • figdir (str) – Directory to save optional plot; default is ‘fig’

  • figname (str) – Figure name to save optional plot; default is ‘preprocess_ramp’

  • sampling (int) – Decimation value for plotting; default is 1

preprocess(mass, circumference, time, momentum)

Function to pre-process acceleration ramp data, interpolating it to every turn. Currently it works only if the number of RF sections is equal to one, to be extended for multiple RF sections.

Parameters
  • mass (float) – Particle mass [eV]

  • circumference (float) – Ring circumference [m]

  • time (float array) – Time points [s] corresponding to momentum data

  • momentum (float array) – Particle momentum [eV/c]

Returns

  • float array – Cumulative time [s]

  • float array – Interpolated momentum [eV/c]

reshape_data(input_data, n_turns, n_sections, interp_time='t_rev', input_to_momentum=False, synchronous_data_type='momentum', mass=None, charge=None, circumference=None, bending_radius=None)

Checks whether the user input is consistent with the expectation for the Ring object. The possibilites are detailed in the documentation of the Ring object.

Parameters
  • input_data (Ring.synchronous_data, Ring.alpha_0,1,2) – Main input data to reshape

  • n_turns (Ring.n_turns) – Number of turns the simulation should be. Note that if the input_data is passed as a tuple it is expected that the input_data is a program. Hence, the number of turns may not correspond to the input one and will be overwritten

  • n_sections (Ring.n_sections) – The number of sections of the ring. The simulation is stopped if the input_data shape does not correspond to the expected number of sections.

  • interp_time (str or float or float array [n_turns+1]) – Optional : defines the time on which the program will be interpolated. If ‘t_rev’ is passed and if the input_data is momentum (see input_to_momentum option) the momentum program is interpolated on the revolution period (see preprocess() function). If a float or a float array is passed, the program is interpolated on that input ; default is ‘t_rev’

  • input_to_momentum (bool) – Optional : flags if the input_data is the momentum program, the options defined below become necessary for conversion

  • synchronous_data_type (str) – Optional : to be passed to the convert_data function if input_to_momentum ; default is ‘momentum’

  • mass (Ring.Particle.mass) – Optional : the mass of the particles in [eV/c**2] ; default is None

  • charge (Ring.Particle.charge) – Optional : the charge of the particles in units of [e] ; default is None

  • circumference (Ring.circumference) – Optional : the circumference of the ring ; default is None

  • bending_radius (Ring.bending_radis) – Optional : the bending radius of magnets ; default is None

Returns

Returns the data with the adequate shape for the Ring object

Return type

output_data

blond.input_parameters.ring_options.convert_data(synchronous_data, mass, charge, synchronous_data_type='momentum', bending_radius=None)

Function to convert synchronous data (i.e. energy program of the synchrotron) into momentum.

Parameters
  • synchronous_data (float array) – The synchronous data to be converted to momentum

  • mass (float or Particle.mass) – The mass of the particles in [eV/c**2]

  • charge (int or Particle.charge) – The charge of the particles in units of [e]

  • synchronous_data_type (str) – Type of input for the synchronous data ; can be ‘momentum’, ‘total energy’, ‘kinetic energy’ or ‘bending field’ (last case requires bending_radius to be defined)

  • bending_radius (float) – Bending radius in [m] in case synchronous_data_type is ‘bending field’

Returns

momentum – The input synchronous_data converted into momentum [eV/c]

Return type

float array

blond.input_parameters.ring_options.load_data(filename, ignore=0, delimiter=None)

Helper function to load column-by-column data from a txt file to numpy arrays.

Parameters
  • filename (str) – Name of the file containing the data.

  • ignore (int) – Number of lines to ignore from the head of the file.

  • delimiter (str) – Delimiting character between columns.

Returns

Input data, column by column.

Return type

list of arrays

rf_parameters_options Module

Function(s) for pre-processing input data

Authors

Helga Timko, Alexandre Lasheen, Danilo Quartullo, Simon Albright

class blond.input_parameters.rf_parameters_options.RFStationOptions(interpolation='linear', smoothing=0, plot=False, figdir='fig', figname=['data'], sampling=1)

Bases: object

Class to preprocess the RF data (voltage, phase, harmonic) for RFStation, interpolating it to every turn.

Parameters
  • interpolation (str) – Interpolation options for the data points. Available options are ‘linear’ (default) and ‘cubic’

  • smoothing (float) – Smoothing value for ‘cubic’ interpolation

  • plot (bool) – Option to plot interpolated arrays; default is False

  • figdir (str) – Directory to save optional plot; default is ‘fig’

  • figname (list of str) – Figure name to save optional plot; default is ‘data’, different arrays will have figures with different indices

  • sampling (int) – Decimation value for plotting; default is 1

reshape_data(input_data, n_turns, n_rf, interp_time, t_start=0)

Checks whether the user input is consistent with the expectation for the RFStation object. The possibilites are detailed in the documentation of the RFStation object.

Parameters
  • input_data (Ring.synchronous_data, Ring.alpha_0,1,2) – Main input data to reshape

  • n_turns (RFStation.n_turns) – Number of turns the simulation should be. Note that if the input_data is passed as a tuple it is expected that the input_data is a program. This parameter is only relevant if the rf program is passed as an array/list with the rigth size (see interp_time otherwise)

  • n_rf (RFStation.n_rf) – The number of rf harmonics in the station. The simulation is stopped if the input_data shape does not correspond to the expected number of rf harmonics.

  • interp_time (Ring.cycle_time) – Ensure that the rf program is interpolated on the same time basis as the Ring.momentum program

  • t_start (Ring.RingOptions.t_start or float) – Uses the same t_start as the one used to interpolate the momentum program in Ring. This value can nevertheless be changed to a custom value if necessary.

Returns

Returns the data with the adequate shape for the RStation object

Return type

output_data

blond.input_parameters.rf_parameters_options.combine_rf_functions(function_list, merge_type='linear', resolution=0.001, Ring=None, main_h=True)

Function to combine different RF programs. Each program is passed in a tuple with complete function (single valued or numpy array) and 2-list [start_time, stop_time].

Parameters
  • function_list (list of tuples) – each tuple has form (function, [start_time, stop_time]) function can be a numpy.ndarray of format [time, value] or single valued if function is single valued it will be assumed constant from start_time to stop_time if function is numpy.ndarray it will be truncated to start_time, stop_time

  • merge_type (str) –

    string signifying type of merge available, options are:

    linear : function will be linearly interpolated from function_1[stop_time] to function_2[start_time] isoadiabatic : designed for voltage functions and intended to maintain adiabaticity during change of voltage, best suited to flat momentum sections linear_tune : for use with voltages, provides a linear change in the tune from function_1[stop_time] to function_2[start_time]

  • resolution (float) – the time in seconds between points of the interpolation

  • Ring (class) – A Ring type class, only used with linear_tune merge_type

  • main_h (boolean) – if main_h is True dE is considered in linear_tune merge_type, otherwise dE is set to 0

Returns

Return type

2 dimensional numpy.ndarray containing [time, value] of merged functions