Example #1
0
import numpy as np
import scipy.io
import pickle
from pymodels import si
from apsuite.commissioning_scripts.calc_orbcorr_mat import OrbRespmat

mod = si.create_accelerator()
famdata = si.get_family_data(mod)
respmat = OrbRespmat(mod, 'SI', dim='6d')

# Change corretors indices to fast correctors:
respmat.ch_idx = np.array(famdata['FCH']['index']).ravel()
respmat.cv_idx = np.array(famdata['FCV']['index']).ravel()
mat = respmat.get_respm()


# the unit of the matrix elements are um/urad
# It is organized as folows:
# M = | Mxx Mxy |
#     | Myx Myy |
# where
# Mxx --> FCH BPMx
# Mxy --> FCV BPMx
# Myx --> FCH BPMy
# Myy --> FCV BPMy
# which means the dimension of M is (320, 160)
mat = mat[:,:-1]  # remove RF line from matrix

with open('Rmat.pickle', 'wb') as filehandle:
	pickle.dump(mat, filehandle)
Example #2
0
    for n in range(len(traj_turns)):
        rx = m2um * traj_turns[n][0, :]
        plt.plot(twiss.spos, rx, '-.', label=f'Turn {n}')
    label = r'Envelope $\propto \sqrt{\beta(s)}$'
    plt.plot(twiss.spos, +m2um * envelop, color='k', label=label)
    plt.plot(twiss.spos, -m2um * envelop, color='k')
    plt.xlim([0, model.length / 10])
    plt.xlabel('pos [m]')
    plt.ylabel('rx [um]')
    title = 'Horizontal position from Tracking\n' + \
        f'(Envelope function defined by initial' + \
        f' condition x = {m2um*rx0:.0f} um,' + \
        f' J = {action*m2nm:.2f} nm.rad)'
    plt.title(title)
    plt.legend()
    plt.show()


# create SI model
model = si.create_accelerator()

# refine elements in the model
model = pyaccel.lattice.refine_lattice(model, 0.05)

# turn longitudinal dynamics off
model.cavity_on = False
model.radiation_on = False

if __name__ == '__main__':
    plot_envelope(model)
Example #3
0
# %%
import numpy as np

import pyaccel
from pymodels import si
import mathphys

# This code works with mathphys at v1.1.0 and pyaccel at 90d6e7c

# %%
ring = si.create_accelerator()
ring[651].voltage = 1.5e6
eqpar = pyaccel.optics.EquilibriumParameters(ring)
current = 100  # mA
en_accep = np.array([-1, 1]) * eqpar.rf_acceptance  # * 0.04
energy = eqpar.accelerator.energy / 1e9
n = mathphys.beam_optics.calc_number_of_electrons(energy, current / 864,
                                                  ring.length)
coupling = 0.01
avg_pressure = 1e-9

accepx, accepy, *_ = pyaccel.optics.get_transverse_acceptance(
    ring, eqpar.twiss, energy_offset=0.0)
accep_x = min(accepx)
accep_y = min(accepy)
accep_t = [accep_x, accep_y]

lifetime = pyaccel.lifetime.Lifetime(ring)
lifetime.coupling = coupling

# %%