Skip to content
Snippets Groups Projects
Commit 21a87cc6 authored by Alexis GAMELIN's avatar Alexis GAMELIN
Browse files

Add mbtrack2 files for SLS and SOLEIL Upgrade

Add mbtrack2 files for:
SLS 1st experiment - 100 mA in uniform filling.
SOLEIL Upgrade single bunch case at 20 mA.
parent 4e8527fa
No related branches found
No related tags found
No related merge requests found
import numpy as np
from machine_data import sls
from mbtrack2.tracking import Beam, CavityResonator, LongitudinalMap, SynchrotronRadiation
from mbtrack2.tracking.monitors import BeamMonitor, CavityMonitor, BunchSpectrumMonitor, BeamSpectrumMonitor
Vc = 2.2e6
ring = sls()
m = 1
Rs = 12480000
Q = 40000
QL = 13333
detune = -100e3
MC = CavityResonator(ring, m, Rs, Q, QL,detune)
MC.Vc = Vc
MC.theta = np.arccos(ring.U0/MC.Vc)
MC.set_optimal_detune(0.1)
MC.set_generator(0.1)
m = 3
Rs = 1.41e10
Q = 1.6e8
QL = 1.6e8
detune = 55e3
HHC = CavityResonator(ring, m, Rs, Q, QL,detune)
HHC.Vg = 0
HHC.theta_g = 0
long = LongitudinalMap(ring)
rad = SynchrotronRadiation(ring)
turns = int(4e4)
detune = np.array([1000e3, 100e3, 55e3, 50e3, 40e3, 35e3, 30e3, 25e3, 20e3])
tot_turns = int(len(detune)*turns)
name = "SLS_100mA"
MCmon = CavityMonitor("MC", ring, file_name=name, save_every=10,
buffer_size=100, total_size=tot_turns/10, mpi_mode=True)
HCmon = CavityMonitor("HHC", ring, file_name=None, save_every=10,
buffer_size=100, total_size=tot_turns/10, mpi_mode=True)
bbmon = BeamMonitor(h=ring.h, file_name=None, save_every=10, buffer_size=100,
total_size=tot_turns/10, mpi_mode=True)
beamspec = BeamSpectrumMonitor(ring, save_every=25e3, buffer_size=1, total_size=9, dim="tau",
n_fft=None, file_name=None, mpi_mode=True)
bunchspec = BunchSpectrumMonitor(ring, bunch_number=0, mp_number=1e4, sample_size=1e3, save_every=25e3,
buffer_size=1, total_size=9, dim="tau", n_fft=None,
file_name=None, mpi_mode=True)
for det in detune:
bb = Beam(ring)
filling = np.ones(ring.h)*100e-3/ring.h
bb.init_beam(filling, mp_per_bunch=1e4, track_alive=False, mpi=True)
HHC.detune = det
MC.init_phasor(bb)
HHC.init_phasor(bb)
for i in range(int(turns+1)):
if ((bb.mpi.rank == 0) is True) and (i % 1000 == 0):
print("detune = " + str(det*1e-3))
print(i)
long.track(bb)
rad.track(bb)
bb.mpi.share_distributions(bb)
MC.track(bb)
HHC.track(bb)
bbmon.track(bb)
MCmon.track(bb, MC)
HCmon.track(bb, HHC)
if (i >= 15e3):
beamspec.track(bb)
bunchspec.track(bb)
bbmon.close()
# -*- coding: utf-8 -*-
"""
SLS parameters script.
Only longitudinal paramters are correct.
@author: Alexis Gamelin
@date: 08/12/2021
"""
import numpy as np
from pathlib import Path
from mbtrack2.tracking import Synchrotron, Optics, Electron, Beam
def sls():
h = 480
L = 288.0073
E0 = 2.4e9
particle = Electron()
ac = 6.0406e-4
U0 = 538.784e3
tau = np.array([0, 0, 4.28364e-3])
tune = np.array([0, 0, 0])
emit = np.array([1e-9, 1e-9*0.01])
sigma_0 = 12.6e-12
sigma_delta = 8.74e-4
chro = [0,0]
# mean values
beta = np.array([1, 1])
alpha = np.array([0, 0])
dispersion = np.array([0, 0, 0, 0])
optics = Optics(local_beta=beta, local_alpha=alpha,
local_dispersion=dispersion)
ring = Synchrotron(h, optics, particle, L=L, E0=E0, ac=ac, U0=U0, tau=tau,
emit=emit, tune=tune, sigma_delta=sigma_delta,
sigma_0=sigma_0, chro=chro)
return ring
\ No newline at end of file
# -*- coding: utf-8 -*-
"""
Created on Tue May 4 17:10:31 2021
@author: gamelina
"""
import numpy as np
from mbtrack2.vlasov import BeamLoadingVlasov
from mbtrack2.tracking.rf import CavityResonator
from mbtrack2.collective_effects import gaussian_bunch
from machine_data import sls
from scipy.constants import c
import matplotlib as mpl
import matplotlib.pyplot as plt
from scipy.signal import peak_widths, find_peaks
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = [12, 5]
plt.rcParams['figure.dpi'] = 200
## No IDs and full coupling
## 3 HHC & 1.7 MV
Vc = 2.2e6
ring = sls()
m = 1
Rs = 12480000
Q = 40000
QL = 13333
detune = -100e3
MC = CavityResonator(ring, m, Rs, Q, QL,detune)
MC.Vc = Vc
MC.theta = np.arccos(ring.U0/MC.Vc)
MC.set_optimal_detune(0.1)
MC.set_generator(0.1)
m = 3
Rs = 1.41e10
Q = 1.6e8
QL = 1.6e8
detune = 55e3
HHC = CavityResonator(ring, m, Rs, Q, QL,detune)
HHC.Vg = 0
HHC.theta_g = 0
HHC.detune = 55e3
V = BeamLoadingVlasov(ring,[MC,HHC], 0.1,auto_set_MC_theta=False)
sol = V.beam_equilibrium(plot=True)
HHC.detune = 25e3
V = BeamLoadingVlasov(ring,[MC,HHC], 0.1,auto_set_MC_theta=False)
sol = V.beam_equilibrium(plot=True)
ax = plt.gca()
ax.legend([r"$f_r - f_3 =$ 55 kHz", r"$f_r - f_3 =$ 25 kHz"])
ax.set_ylabel("arb. unit")
plt.tight_layout()
#plt.savefig("HC3_cas0_83_85kHz.jpg",dpi=200)
\ No newline at end of file
# -*- coding: utf-8 -*-
"""
SOLEIL synchrotron parameters script.
@author: Alexis Gamelin
@date: 14/01/2020
"""
import numpy as np
from pathlib import Path
from mbtrack2.tracking import Synchrotron, Optics, Electron, Beam
def v0313_v2(IDs="noID", coupling="full", V_RF=None, ADTS=False):
# Using RF table from 16/02/2021 (L. Nadolski)
h = 416
L = 354.7373
E0 = 2.75e9
particle = Electron()
ac = 9.12e-5
chro = [1.6,1.6]
tune = np.array([0.2,0.2])
sigma_0 = 8e-12
if IDs == "noID" and coupling == "full":
tau = np.array([9.2e-3, 9.3e-3, 11.7e-3])
emit = np.array([52e-12, 52e-12])
sigma_delta = 9e-4
U0 = 515e3
if IDs == "ID1" and coupling == "full":
tau = np.array([7.1e-3, 7.1e-3, 6.2e-3])
emit = np.array([39e-12, 39e-12])
sigma_delta = 8.9e-4
U0 = 760e3
if IDs == "ID2" and coupling == "full":
tau = np.array([6.35e-3, 6.35e-3, 5.1e-3])
emit = np.array([35e-12, 35e-12])
sigma_delta = 8.8e-4
U0 = 874e3
if IDs == "noID" and coupling == "no":
tau = np.array([7.1e-3, 13.2e-3, 11.7e-3])
emit = np.array([81e-12, 1e-12])
sigma_delta = 9e-4
U0 = 515e3
if IDs == "ID1" and coupling == "no":
tau = np.array([5.6e-3, 8.8e-3, 6.2e-3])
emit = np.array([64e-12, 1e-12])
sigma_delta = 8.9e-4
U0 = 760e3
if IDs == "ID2" and coupling == "no":
tau = np.array([5.1e-3, 7.6e-3, 5.1e-3])
emit = np.array([58e-12, 1e-12])
sigma_delta = 8.8e-4
U0 = 874e3
# mean values
beta = np.array([3.178, 4.197])
alpha = np.array([0, 0])
dispersion = np.array([0, 0, 0, 0])
optics = Optics(local_beta=beta, local_alpha=alpha,
local_dispersion=dispersion)
if ADTS is True:
# Name format : coef_yx means coef of vertical ADTS as a function of horizontal offset.
coef_xx = np.array([2.10012957e+07, -1.95066506e+02, -1.87260829e+03,
4.17160112e-02, 0])
coef_yx = np.array([1.30396188e+07, 1.55792082e+04, 5.80031793e+02,
-2.52678776e-01, 0])
coef_xy = np.array([9.88551670e+03, -2.80640442e-03, 0])
coef_yy = np.array([1.84297492e+04, 7.24309395e-08, 0])
adts = [coef_xx, coef_yx, coef_xy, coef_yy]
else:
adts = None
ring = Synchrotron(h, optics, particle, L=L, E0=E0, ac=ac, U0=U0, tau=tau,
emit=emit, tune=tune, sigma_delta=sigma_delta,
sigma_0=sigma_0, chro=chro, adts=adts)
if V_RF is not None:
tuneS = ring.synchrotron_tune(V_RF)
ring.sigma_0 = (ring.sigma_delta * np.abs(ring.eta)
/ (tuneS * 2 * np.pi * ring. f0))
return ring
import numpy as np
from machine_data import v0313_v2
from mbtrack2.tracking import Beam, CavityResonator, LongitudinalMap, SynchrotronRadiation
from mbtrack2.tracking.monitors import BunchMonitor, CavityMonitor, BunchSpectrumMonitor
Vc = 1.7e6
ring = v0313_v2(IDs="noID", V_RF=Vc)
Itot = 0.02
m = 1
Rs = 19.6e6
Q = 34e3
QL = 6e3
detune = -100e3
MC = CavityResonator(ring, m, Rs, Q, QL,detune)
MC.Vc = Vc
MC.theta = np.arccos(ring.U0/MC.Vc)
MC.set_optimal_detune(Itot)
MC.set_generator(Itot)
m = 3
Rs = 90e8
Q = 1e8
QL = 1e8
detune = 120e3
HHC = CavityResonator(ring, m, Rs, Q, QL,detune)
HHC.Vg = 0
HHC.theta_g = 0
long = LongitudinalMap(ring)
rad = SynchrotronRadiation(ring)
turns = int(7.5e4)
detune = np.array([4e3, 3.7e3, 3.5e3, 3.4e3, 3.3e3, 3.2e3, 3.1e3])
tot_turns = int(len(detune)*turns)
name = "v0313_HC3_SB_scanDetune"
MCmon = CavityMonitor("MC", ring, file_name=name, save_every=10,
buffer_size=100, total_size=tot_turns/10, mpi_mode=False)
HCmon = CavityMonitor("HHC", ring, file_name=None, save_every=10,
buffer_size=100, total_size=tot_turns/10, mpi_mode=False)
bunchmon = BunchMonitor(bunch_number=0, file_name=None, save_every=10,
buffer_size=100, total_size=tot_turns/10, mpi_mode=False)
bunchspec = BunchSpectrumMonitor(ring, bunch_number=0, mp_number=1e4, sample_size=1e3, save_every=30e3,
buffer_size=1, total_size=14, dim="tau", n_fft=None,
file_name=None, mpi_mode=False)
for det in detune:
bb = Beam(ring)
filling = np.zeros(ring.h)
filling[0] = Itot
bb.init_beam(filling, mp_per_bunch=1e4, track_alive=False, mpi=False)
HHC.detune = det
MC.init_phasor(bb)
HHC.init_phasor(bb)
for i in range(int(turns+1)):
if (i % 100 == 0):
print("detune = " + str(det*1e-3))
print(i)
long.track(bb)
rad.track(bb)
MC.track(bb)
HHC.track(bb)
bunchmon.track(bb)
MCmon.track(bb, MC)
HCmon.track(bb, HHC)
if (i >= 15e3):
bunchspec.track(bb)
bunchmon.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment