Plot of Twiss parameters

Loads libraries and setting environment


In [1]:
# imports to current namespace all useful functions and symbols implemented in pyaccel library
from sirius.interactive import *

# matplotlib plots are inlined in the browser.
%matplotlib inline


Names defined in sirius.interactive: Accelerator, Kicktable, add_error_excitation_kdip, add_error_excitation_main, add_error_misalignment_x, add_error_misalignment_y, add_error_multipoles, add_error_rotation_pitch, add_error_rotation_roll, add_error_rotation_yaw, add_knob, bo, bpm, build, calc_emittance_coupling, calc_lifetimes, calc_twiss, corrector, de, dl, draw_lattice, drift, element_pass, find_dict, find_indices, find_m44, find_m66, find_orbit4, find_orbit6, find_spos, flatten, get_attribute, get_beam_size, get_chromaticities, get_equilibrium_parameters, get_error_misalignment_x, get_error_misalignment_y, get_error_rotation_pitch, get_error_rotation_roll, get_error_rotation_yaw, get_frac_tunes, get_mcf, get_natural_bunch_length, get_natural_emittance, get_natural_energy_spread, get_radiation_integrals, get_revolution_frequency, get_revolution_period, get_rf_frequency, get_rf_voltage, get_traces, get_transverse_acceptance, get_twiss, hcorrector, length, line_pass, marker, np, plot_twiss, plt, px, py, PYACCEL_VERSION, quadrupole, rbend, read_flat_file, refine_lattice, rfcavity, ring_pass, rx, ry, set_4d_tracking, set_6d_tracking, set_attribute, set_error_misalignment_x, set_error_misalignment_y, set_error_rotation_pitch, set_error_rotation_roll, set_error_rotation_yaw, set_knob, sextupole, shift, si, tb, ts, vcorrector, write_flat_file, write_flat_file_to_string.

Creates SIRIUS storage ring model (last version) and turns cavity and radiation on for 6D trackings


In [2]:
# access data structure with info on the current lattice version and optics mode
latt_version = si.lattice_version
opti_mode = si.default_optics_mode
print('Loading Sirius lattice version ' + latt_version + ', optics mode ' + opti_mode)

# invokes function from the current Sirius version to create corresponding model
the_ring = si.create_accelerator()
set_6d_tracking(the_ring) # turns on all necessary flags for 6d tracking


Loading Sirius lattice version SI_V12, optics mode C01

Calculates Twiss parameters


In [3]:
# invokes pyaccel optics routine that calculates Twiss parameters 
twiss, *_ = calc_twiss(the_ring)

# selects useful parameters of interest for plotting
spos, betax, betay, etax = get_twiss(twiss, ('spos', 'betax','betay', 'etax'))

# prints all Twiss parameters at the entrance of the ring
print('Twiss at start of the Sirius lattice:'), print()
print(twiss[0])


Twiss at start of the Sirius lattice:

spos          : +0.000e+00
rx, ry        : -1.128e-08, +0.000e+00
px, py        : -3.871e-09, +0.000e+00
de, dl        : -7.120e-05, -1.704e-02
mux, muy      : +0.000e+00, +0.000e+00
betax, betay  : +1.776e+01, +5.002e+00
alphax, alphay: +2.726e-03, -8.706e-04
etax, etapx   : +8.368e-05, +6.562e-06
etay, etapy   : +0.000e+00, +0.000e+00

Plots Twiss parameters


In [4]:
# plots beta functions and etax
fig = plt.plot(spos, betax)
plt.plot(spos, betay)
plt.plot(spos, 100*etax)

# gets ring data used to select only a superperiod for the plots
circumference = the_ring.length
symmetry = si.lattice_symmetry
length_superperiod = circumference/symmetry

# beautifies plot
_ = plt.xlim((0,length_superperiod))
_ = plt.xlabel('spos [m]')
_ = plt.ylabel('$\\beta_x$ [m], betay [m], etax [cm]')
_ = plt.legend(('betax','betay', 'etax'))
_ = plt.grid('on')
_ = plt.title('Twiss Functions for SIRIUS '+latt_version+'.'+opti_mode)



In [ ]: