def setUp(self): circumference = 110.4 # [m] energy = 2.5e9 # [eV] alpha = 0.0082 self.R_bend = 5.559 # bending radius [m] # C_gamma = e**2 / (3*epsilon_0 * (m_e*c**2)**4) # [m J^3] # C_gamma *= e**3 # [m eV^3] harmonic_number = 184 voltage = 800e3 # eV phi_offsets = 0 self.seed = 1234 self.intensity = 2.299e9 self.n_macroparticles = int(1e2) self.sigma_dt = 10e-12 # RMS, [s] self.ring = Ring(circumference, alpha, energy, Positron(), synchronous_data_type='total energy', n_turns=1) self.rf_station = RFStation(self.ring, harmonic_number, voltage, phi_offsets, n_rf=1) self.beam = Beam(self.ring, self.n_macroparticles, self.intensity) bigaussian(self.ring, self.rf_station, self.beam, self.sigma_dt, seed=self.seed)
def run_simple(self): self.ring = Ring(self.C, self.alpha_0, self.Ek, Proton(), self.N_t, synchronous_data_type='kinetic energy', alpha_1=None, alpha_2=None) self.beam = Beam(self.ring, self.N_p, self.N_b) self.rf = RFStation(self.ring, 1, 0, np.pi) original_distribution_dt = np.zeros(self.beam.n_macroparticles) original_distribution_dE = np.linspace( -0.1*self.beam.energy, 0.1*self.beam.energy, self.beam.n_macroparticles) self.beam.dt[:] = np.array(original_distribution_dt) self.beam.dE[:] = np.array(original_distribution_dE) self.long_tracker = RingAndRFTracker( self.rf, self.beam, solver='simple') for i in range(self.ring.n_turns): self.long_tracker.track() original_distribution_dt += self.ring.n_turns * linear_drift( original_distribution_dE, self.ring.eta_0[0, 0], self.ring.beta[0, 0], self.ring.energy[0, 0], self.ring.t_rev[0]) return self.beam.dt, original_distribution_dt, original_distribution_dE
def test_U0(self): # LEP, values from S. Lee 2nd ed., table 4.2 circumference = 26658.9 # [m] energy = 55e9 # [eV] R_bend = 3096.2 # bending radius [m] alpha = 1e-3 # dummy value ring = Ring(circumference, alpha, energy, Positron(), synchronous_data_type='total energy', n_turns=1) rf_station_dummy = RFStation(ring, 42, 1e6, 0, n_rf=1) iSR = SynchrotronRadiation(ring, rf_station_dummy, None, R_bend, shift_beam=False, quantum_excitation=False) self.assertEqual(int(iSR.U0 / 1e6), 261, msg="Wrong U0")
def setUp(self): # Bunch parameters # ----------------- N_turn = 200 N_b = 1e9 # Intensity N_p = int(2e6) # Macro-particles # Machine parameters # -------------------- C = 6911.5038 # Machine circumference [m] p = 450e9 # Synchronous momentum [eV/c] gamma_t = 17.95142852 # Transition gamma alpha = 1./gamma_t**2 # First order mom. comp. factor # Define general parameters # -------------------------- self.general_params = Ring(C, alpha, p, Proton(), N_turn) # Define beam # ------------ self.beam = Beam(self.general_params, N_p, N_b) # Define RF section # ----------------- self.rf_params = RFStation(self.general_params, [4620], [7e6], [0.])
def setUp(self): initial_time = 0 final_time = 1E-3 # Machine and RF parameters radius = 25 gamma_transition = 4.4 # [1] C = 2 * np.pi * radius # [m] momentum_compaction = 1 / gamma_transition**2 # [1] particle_type = 'proton' self.ring = Ring(C, momentum_compaction, \ ([0, 1E-3], [3.13E8, 3.13E8]), Proton()) self.rf_params = RFStation(self.ring, [1], [1E3], [np.pi], 1) self.beam = Beam(self.ring, 1, 0) self.profile = Profile(self.beam) self.long_tracker = RingAndRFTracker(self.rf_params, self.beam) self.full_ring = FullRingAndRF([self.long_tracker]) self.n_turns = self.ring.n_turns self.map_ = [self.full_ring.track, self.profile.track] self.trackIt = TrackIteration(self.map_)
def setUp(self): self.general_params = Ring(np.ones(self.n_sections) * self.C/self.n_sections, np.tile(self.momentum_compaction, (1, self.n_sections)).T, np.tile(self.sync_momentum, (self.n_sections, self.n_turns+1)), self.particle_type, self.n_turns, n_sections=self.n_sections) self.RF_sct_par = [] self.RF_sct_par_cpp = [] for i in np.arange(self.n_sections)+1: self.RF_sct_par.append(RFStation(self.general_params, [self.harmonic_numbers], [ self.voltage_program/self.n_sections], [self.phi_offset], self.n_rf_systems, section_index=i)) self.RF_sct_par_cpp.append(RFStation(self.general_params, [self.harmonic_numbers], [ self.voltage_program/self.n_sections], [self.phi_offset], self.n_rf_systems, section_index=i)) # DEFINE BEAM------------------------------------------------------------------ self.beam = Beam(self.general_params, self.n_macroparticles, self.n_particles) self.beam_cpp = Beam(self.general_params, self.n_macroparticles, self.n_particles) # DEFINE SLICES---------------------------------------------------------------- number_slices = 500 cut_options = CutOptions( cut_left=0., cut_right=self.bucket_length, n_slices=number_slices) self.slice_beam = Profile(self.beam, CutOptions=cut_options) self.slice_beam_cpp = Profile(self.beam_cpp, CutOptions=cut_options) # DEFINE TRACKER--------------------------------------------------------------- self.longitudinal_tracker = [] self.longitudinal_tracker_cpp = [] for i in range(self.n_sections): self.longitudinal_tracker.append(RingAndRFTracker( self.RF_sct_par[i], self.beam, Profile=self.slice_beam)) self.longitudinal_tracker_cpp.append(RingAndRFTracker( self.RF_sct_par_cpp[i], self.beam_cpp, Profile=self.slice_beam_cpp)) full_tracker = FullRingAndRF(self.longitudinal_tracker) full_tracker_cpp = FullRingAndRF(self.longitudinal_tracker_cpp) # BEAM GENERATION-------------------------------------------------------------- matched_from_distribution_function(self.beam, full_tracker, emittance=self.emittance, distribution_type=self.distribution_type, distribution_variable=self.distribution_variable, seed=1000) matched_from_distribution_function(self.beam_cpp, full_tracker_cpp, emittance=self.emittance, distribution_type=self.distribution_type, distribution_variable=self.distribution_variable, seed=1000) self.slice_beam.track() self.slice_beam_cpp.track()
def setUp(self): # Ring and RF definitions ring = Ring(2 * np.pi * 1100.009, 1 / 18**2, 25.92e9, Particle=Proton()) rf = RFStation(ring, [4620], [4.5e6], [0.], n_rf=1) self.T_s = 5 * rf.t_rf[0, 0]
def test_kinetic_energy_positive(self): # Kinetic energy must be greater or equal 0 for all turns general_parameters = Ring(self.C, self.alpha_0, self.momentum, self.particle, self.n_turns, n_sections=self.num_sections) self.assertTrue( (general_parameters.kin_energy >= 0.0).all(), msg='In TestGeneralParameters kinetic energy is ' + 'negative!')
def test_cycle_time_turn1(self): # Cycle_time[0] must be equal to t_rev[0] general_parameters = Ring(self.C, self.alpha_0, self.momentum, self.particle, self.n_turns, n_sections=self.num_sections) self.assertEqual(general_parameters.cycle_time[0], general_parameters.t_rev[0], msg='In TestGeneralParameters cycle_time at first ' + 'turn not equal to revolution time at first turn!')
def test_alpha_shape_exception(self): # Test if 'momentum compaction' RuntimeError gets thrown for wrong # shape of alpha alpha = [[3.21e-4, 2.e-5, 5.e-7]] # only one array! with self.assertRaisesRegex( RuntimeError, "ERROR in Ring: the input data " + "does not match the number of sections", msg='No RuntimeError for wrong shape of alpha!'): Ring(self.C, alpha, self.momentum, self.particle, self.n_turns, n_sections=self.num_sections)
def test_exact_order1and2_vs_expectation(self): self.ring = Ring(self.C, self.alpha_0, self.Ek, Proton(), self.N_t, synchronous_data_type='kinetic energy', alpha_1=self.alpha_1, alpha_2=self.alpha_2) self.beam = Beam(self.ring, self.N_p, self.N_b) self.rf = RFStation(self.ring, 1, 0, np.pi) original_distribution_dt = np.zeros(self.beam.n_macroparticles) original_distribution_dE = np.linspace(-0.1 * self.beam.energy, 0.1 * self.beam.energy, self.beam.n_macroparticles) self.beam.dt[:] = np.array(original_distribution_dt) self.beam.dE[:] = np.array(original_distribution_dE) self.long_tracker = RingAndRFTracker(self.rf, self.beam, solver='exact') # Forcing usage of legacy self.long_tracker.solver = 'exact' self.long_tracker.solver = self.long_tracker.solver.encode( encoding='utf_8') for i in range(self.ring.n_turns): self.long_tracker.track() original_distribution_dt += self.ring.n_turns * expected_drift( original_distribution_dE, self.ring.alpha_0[0, 0], self.ring.alpha_1[0, 0], self.ring.alpha_2[0, 0], self.ring.energy[0, 0], self.ring.t_rev[0], self.ring.ring_circumference, self.ring.Particle.mass) np.testing.assert_allclose(self.beam.dt, original_distribution_dt, rtol=relative_tolerance, atol=absolute_tolerance)
def test_momentum_shape_exception(self): # Test if RuntimeError gets thrown for wrong shape of momentum cycle_time = np.linspace(0, 1, self.n_turns) momentum = [[450e9], [450e9]] # only one momentum! with self.assertRaisesRegex( RuntimeError, "ERROR in Ring: synchronous data " + "does not match the time data", msg='No RuntimeError for wrong shape of momentum!'): Ring(self.C, self.alpha_0, ((cycle_time, momentum[0]), (cycle_time, momentum[1])), self.particle, self.n_turns, n_sections=self.num_sections)
def setUp(self): initial_time = 0 final_time = 25E-3 periodicity_tracking = True # Machine and RF parameters radius = 25 gamma_transition = 4.4 # [1] C = 2 * np.pi * radius # [m] momentum_compaction = 1 / gamma_transition**2 # [1] particle_type = 'proton' self.ring = Ring(C, momentum_compaction, \ ([0, 25E-3], [3.13E8, 3.5E8]), Proton()) self.rf_params = RFStation(self.ring, [1, 2], [0, 0], \ [np.pi, np.pi*0.95], 2)
def test_ring_length_exception(self): # Test if 'ring length size' RuntimeError gets thrown for wrong number # of rf sections num_sections = 1 # only one rf-section! with self.assertRaisesRegex( RuntimeError, 'ERROR in Ring: Number of sections and ring ' + 'length size do not match!', msg='No RuntimeError for wrong n_sections!'): Ring(self.C, self.alpha_0, self.momentum, self.particle, self.n_turns, n_sections=num_sections, alpha_1=self.alpha_1, alpha_2=self.alpha_2)
def test_synchronous_data_exception(self): # What to do when user wants momentum programme for multiple sections? # One array of cycle_time? One array per section? # Currently, __init__ checks only if the number of cycle_time arrays is # the same as the number of momentum_arrays, but not if the array # have the correct length. cycle_time = np.linspace(0, 1, self.n_turns) # wrong length with self.assertRaisesRegex( RuntimeError, "ERROR in Ring: synchronous data does " + "not match the time data", msg='No RuntimeError for wrong synchronous_data!'): Ring(self.C, self.alpha_0, ((cycle_time, self.momentum), (cycle_time, self.momentum)), self.particle, self.n_turns, n_sections=self.num_sections)
def setUp(self): self.ring = Ring(self.C, self.alpha, np.linspace(self.p_i, self.p_f, self.N_t + 1), Proton(), self.N_t) self.beam = Beam(self.ring, self.N_p, self.N_b) self.rf = RFStation(self.ring, [self.h], self.V * np.linspace(1, 1.1, self.N_t + 1), [self.dphi]) bigaussian(self.ring, self.rf, self.beam, self.tau_0 / 4, reinsertion=True, seed=1) self.profile = Profile( self.beam, CutOptions(n_slices=100, cut_left=0, cut_right=self.rf.t_rf[0, 0]), FitOptions(fit_option='gaussian')) self.long_tracker = RingAndRFTracker(self.rf, self.beam, Profile=self.profile)
def test_momentum_length_exception(self): # Test if RuntimeError gets thrown for wrong length of momentum # Only n_turns elements per section! momentum = [ np.linspace(450e9, 450e9, self.n_turns), np.linspace(450e9, 450e9, self.n_turns) ] with self.assertRaisesRegex( RuntimeError, "ERROR in Ring: The input data " + "does not match the proper length " + "\(n_turns\+1\)", msg='No RuntimeError for wrong length of momentum array!'): Ring(self.C, self.alpha_0, momentum, self.particle, self.n_turns, n_sections=self.num_sections)
def setUp(self): C = 2 * np.pi * 1100.009 # Ring circumference [m] gamma_t = 18.0 # Gamma at transition alpha = 1 / gamma_t**2 # Momentum compaction factor p_s = 25.92e9 # Synchronous momentum at injection [eV] N_m = 1e5 # Number of macro-particles for tracking N_b = 1.0e11 # Bunch intensity [ppb] # Set up machine parameters self.ring = Ring(C, alpha, p_s, Proton(), n_turns=1) # RF-frequency at which to compute beam current self.omega = 2 * np.pi * 200.222e6 # Create Gaussian beam self.beam = Beam(self.ring, N_m, N_b) self.profile = Profile(self.beam, CutOptions=CutOptions(cut_left=-1.e-9, n_slices=100, cut_right=6.e-9))
def setUp(self): # Bunch parameters (dummy) N_b = 1e9 # Intensity N_p = 50000 # Macro-particles # Machine and RF parameters C = 26658.883 # Machine circumference [m] p_s = 450e9 # Synchronous momentum [eV/c] h = 35640 # Harmonic number V = 4e6 # RF voltage [V] dphi = 0 # Phase modulation/offset gamma_t = 53.8 # Transition gamma alpha = 1 / gamma_t**2 # First order mom. comp. factor # Initialise necessary classes ring = Ring(C, alpha, p_s, Particle=Proton(), n_turns=1) self.rf = RFStation(ring, [h], [V], [dphi]) beam = Beam(ring, N_p, N_b) self.profile = Profile(beam) # Test in open loop, on tune self.RFFB = LHCRFFeedback(open_drive=True) self.f_c = self.rf.omega_rf[0, 0] / (2 * np.pi)
def setUp(self): n_turns = 200 intensity_pb = 1.2e6 # protons per bunch n_macroparticles = int(1e6) # macropartilces per bunch sigma = 0.05e-9 # sigma for gaussian bunch [s] self.time_offset = 0.1e-9 # time by which to offset the bunch # Ring parameters SPS C = 6911.5038 # Machine circumference [m] sync_momentum = 25.92e9 # SPS momentum at injection [eV/c] gamma_transition = 17.95142852 # Q20 Transition gamma momentum_compaction = 1./gamma_transition**2 # Momentum compaction array self.ring = Ring(C, momentum_compaction, sync_momentum, Proton(), n_turns=n_turns) # RF parameters SPS harmonic = 4620 # Harmonic numbers voltage = 4.5e6 # [V] phi_offsets = 0 self.rf_station = RFStation(self.ring, harmonic, voltage, phi_offsets) t_rf = self.rf_station.t_rf[0, 0] # Beam setup self.beam = Beam(self.ring, n_macroparticles, intensity_pb) bigaussian(self.ring, self.rf_station, self.beam, sigma, seed=1234, reinsertion=True) # displace beam to see effect of phase error and phase loop self.beam.dt += self.time_offset # Profile setup self.profile = Profile(self.beam, CutOptions=CutOptions(cut_left=0, cut_right=t_rf, n_slices=1024))
def run_expected_drift(self): self.ring = Ring(self.C, self.alpha_0, self.Ek, Proton(), self.N_t, synchronous_data_type='kinetic energy', alpha_1=self.alpha_1, alpha_2=self.alpha_2) self.beam = Beam(self.ring, self.N_p, self.N_b) self.rf = RFStation(self.ring, 1, 0, np.pi) original_distribution_dt = np.zeros(self.beam.n_macroparticles) original_distribution_dE = np.linspace( -0.1*self.beam.energy, 0.1*self.beam.energy, self.beam.n_macroparticles) original_distribution_dt += self.ring.n_turns * expected_drift( original_distribution_dE, self.ring.alpha_0[0, 0], self.ring.alpha_1[0, 0], self.ring.alpha_2[0, 0], self.ring.energy[0, 0], self.ring.t_rev[0], self.ring.ring_circumference, self.ring.Particle.mass) return original_distribution_dt, original_distribution_dE
def run_exact_order1and2(self): self.ring = Ring(self.C, self.alpha_0, self.Ek, Proton(), self.N_t, synchronous_data_type='kinetic energy', alpha_1=self.alpha_1, alpha_2=self.alpha_2) self.beam = Beam(self.ring, self.N_p, self.N_b) self.rf = RFStation(self.ring, 1, 0, np.pi) original_distribution_dt = np.zeros(self.beam.n_macroparticles) original_distribution_dE = np.linspace( -0.1*self.beam.energy, 0.1*self.beam.energy, self.beam.n_macroparticles) self.beam.dt[:] = np.array(original_distribution_dt) self.beam.dE[:] = np.array(original_distribution_dE) self.long_tracker = RingAndRFTracker( self.rf, self.beam, solver='exact') # Forcing usage of legacy self.long_tracker.solver = 'exact' self.long_tracker.solver = self.long_tracker.solver.encode( encoding='utf_8') for i in range(self.ring.n_turns): self.long_tracker.track() original_distribution_dt += self.ring.n_turns * exact_drift( original_distribution_dE, self.ring.alpha_0[0, 0], self.ring.alpha_1[0, 0], self.ring.alpha_2[0, 0], self.ring.beta[0, 0], self.ring.energy[0, 0], self.ring.t_rev[0]) return self.beam.dt, original_distribution_dt, original_distribution_dE
alpha = 1./gamma_t/gamma_t # First order mom. comp. factor # Tracking details N_t = 2000 # Number of turns to track dt_plt = 200 # Time steps between plots # Simulation setup ------------------------------------------------------------ print("Setting up the simulation...") print("") # Define general parameters containing data for both RF stations general_params = Ring([0.3*C, 0.7*C], [[alpha], [alpha]], [p_s*np.ones(N_t+1), p_s*np.ones(N_t+1)], Proton(), N_t, n_sections = 2) # Define RF station parameters and corresponding tracker beam = Beam(general_params, N_p, N_b) rf_params_1 = RFStation(general_params, [h], [V1], [dphi], section_index=1) long_tracker_1 = RingAndRFTracker(rf_params_1, beam) rf_params_2 = RFStation(general_params, [h], [V2], [dphi], section_index=2) long_tracker_2 = RingAndRFTracker(rf_params_2, beam) # Define full voltage over one turn and a corresponding "overall" set of #parameters, which is used for the separatrix (in plotting and losses)
# Derived parameters E_0 = m_e * c**2 / e # [eV] tot_beam_energy = np.sqrt(sync_momentum**2 + E_0**2) # [eV] momentum_compaction = 1 / gamma_transition**2 # [1] # Cavities parameters n_rf_systems = 1 harmonic_numbers = [133650] voltage_program = [10e9] phi_offset = [np.pi] bucket_length = C / c / harmonic_numbers[0] # DEFINE RING------------------------------------------------------------------ general_params = Ring(C, momentum_compaction, sync_momentum, Electron(), n_turns) RF_sct_par = RFStation(general_params, harmonic_numbers, voltage_program, phi_offset, n_rf_systems) # DEFINE BEAM------------------------------------------------------------------ beam = Beam(general_params, n_macroparticles, n_particles) # DEFINE TRACKER--------------------------------------------------------------- longitudinal_tracker = RingAndRFTracker(RF_sct_par, beam) full_tracker = FullRingAndRF([longitudinal_tracker]) # DEFINE SLICES----------------------------------------------------------------
# Tracking details N_t = 1 # Number of turns to track # ----------------------------------------------------------------------------- PLOT_NO_BEAM = True # Plot settings plt.rc('axes', labelsize=12, labelweight='normal') plt.rc('lines', linewidth=1.5, markersize=6) plt.rc('font', family='sans-serif') plt.rc('legend', fontsize=12) # Logger for messages on console & in file Logger(debug=True) ring = Ring(C, alpha, p_s, Particle=Proton(), n_turns=1) rf = RFStation(ring, [h], [3.1e6], [dphi]) # SPS-equivalent for 0.57 eVs, 1.65 ns bunch = Beam(ring, N_m, N_p) bigaussian(ring, rf, bunch, sigma_dt=1.65e-9 / 4) #tau_0) # Real RF voltage rf = RFStation(ring, [h], [V], [dphi]) beam = Beam(ring, N_m * NB, N_p * NB) buckets = rf.t_rf[0, 0] * 10 for i in range(12): beam.dt[i * N_m:(i + 1) * N_m] = bunch.dt[0:N_m] + i * buckets beam.dE[i * N_m:(i + 1) * N_m] = bunch.dE[0:N_m] for i in range(12, 60): beam.dt[i * N_m:(i + 1) *
def setUp(self): C = 2*np.pi*1100.009 # Ring circumference [m] gamma_t = 18.0 # Gamma at transition alpha = 1/gamma_t**2 # Momentum compaction factor p_s = 25.92e9 # Synchronous momentum at injection [eV] h = 4620 # 200 MHz system harmonic phi = 0. # 200 MHz RF phase # With this setting, amplitude in the two four-section, five-section # cavities must converge, respectively, to # 2.0 MV = 4.5 MV * 4/18 * 2 # 2.5 MV = 4.5 MV * 5/18 * 2 V = 4.5e6 # 200 MHz RF voltage N_t = 1 # Number of turns to track self.ring = Ring(C, alpha, p_s, Particle=Proton(), n_turns=N_t) self.rf = RFStation(self.ring, h, V, phi) N_m = 1e6 # Number of macro-particles for tracking N_b = 72*1.0e11 # Bunch intensity [ppb] # Gaussian beam profile self.beam = Beam(self.ring, N_m, N_b) sigma = 1.0e-9 bigaussian(self.ring, self.rf, self.beam, sigma, seed=1234, reinsertion=False) n_shift = 1550 # how many rf-buckets to shift beam self.beam.dt += n_shift * self.rf.t_rf[0, 0] self.profile = Profile( self.beam, CutOptions=CutOptions( cut_left=(n_shift-1.5)*self.rf.t_rf[0, 0], cut_right=(n_shift+2.5)*self.rf.t_rf[0, 0], n_slices=4*64)) self.profile.track() # Cavities l_cav = 43*0.374 v_g = 0.0946 tau = l_cav/(v_g*c)*(1 + v_g) f_cav = 200.222e6 n_cav = 2 # factor 2 because of two four/five-sections cavities short_cavity = TravelingWaveCavity(l_cav**2 * n_cav * 27.1e3 / 8, f_cav, 2*np.pi*tau) shortInducedVoltage = InducedVoltageTime(self.beam, self.profile, [short_cavity]) l_cav = 54*0.374 tau = l_cav/(v_g*c)*(1 + v_g) long_cavity = TravelingWaveCavity(l_cav**2 * n_cav * 27.1e3 / 8, f_cav, 2*np.pi*tau) longInducedVoltage = InducedVoltageTime(self.beam, self.profile, [long_cavity]) self.induced_voltage = TotalInducedVoltage( self.beam, self.profile, [shortInducedVoltage, longInducedVoltage]) self.induced_voltage.induced_voltage_sum() self.cavity_tracker = RingAndRFTracker( self.rf, self.beam, Profile=self.profile, interpolation=True, TotalInducedVoltage=self.induced_voltage) self.OTFB = SPSCavityFeedback( self.rf, self.beam, self.profile, G_llrf=5, G_tx=0.5, a_comb=15/16, turns=50, Commissioning=CavityFeedbackCommissioning()) self.OTFB_tracker = RingAndRFTracker(self.rf, self.beam, Profile=self.profile, TotalInducedVoltage=None, CavityFeedback=self.OTFB, interpolation=True)
h = 35640 # Harmonic number V = 6e6 # RF voltage [V] dphi = 0 # Phase modulation/offset gamma_t = 55.759505 # Transition gamma alpha = 1. / gamma_t / gamma_t # First order mom. comp. factor # Tracking details N_t = 2000 # Number of turns to track dt_plt = int(sys.argv[2]) # Time steps between plots # Simulation setup ------------------------------------------------------------ print("Setting up the simulation...") print("") # Define general parameters ring = Ring(C, alpha, np.linspace(p_i, p_f, N_t + 1), Proton(), N_t) # Define beam and distribution beam = Beam(ring, N_p, N_b) # Define RF station parameters and corresponding tracker rf = RFStation(ring, [h], [V], [dphi]) long_tracker = RingAndRFTracker(rf, beam) bigaussian(ring, rf, beam, tau_0 / 4, reinsertion=True, seed=1) # Need slices for the Gaussian fit # profile = Profile(beam, CutOptions(n_slices=N_p//1000), # FitOptions(fit_option='gaussian')) # Define what to save in file
gamma_t = 15.59 # Transition gamma alpha = 1. / gamma_t / gamma_t # First order mom. comp. factor # Tracking details N_t = 45500 # Number of turns to track dt_plt = 5000 # Time steps between plots # Simulation setup ------------------------------------------------------------- print("Setting up the simulation...") print("") # Define general parameters general_params = Ring(C, alpha, np.linspace(p_i, p_f, N_t + 1), Particle(m_p, Z), n_turns=N_t) # Define beam and distribution beam = Beam(general_params, N_p, N_b) print("Particle mass is %.3e eV" % general_params.Particle.mass) print("Particle charge is %d e" % general_params.Particle.charge) linspace_test = np.linspace(p_i, p_f, N_t + 1) momentum_test = general_params.momentum beta_test = general_params.beta gamma_test = general_params.gamma energy_test = general_params.energy mass_test = general_params.Particle.mass # [eV] charge_test = general_params.Particle.charge # e*Z
except: pass # Beam parameters n_macroparticles = 100000 n_particles = 0 # Machine and RF parameters radius = 25 # [m] gamma_transition = 4.076750841 alpha = 1 / gamma_transition**2 C = 2 * np.pi * radius # [m] n_turns = 2000 general_params = Ring(C, alpha, 310891054.809, Proton(), n_turns) # Cavities parameters n_rf_systems = 1 harmonic_numbers_1 = 1 voltage_1 = 8000 # [V] phi_offset_1 = np.pi # [rad] rf_params = RFStation(general_params, [harmonic_numbers_1], [voltage_1], [phi_offset_1], n_rf_systems) my_beam = Beam(general_params, n_macroparticles, n_particles) cut_options = CutOptions(cut_left=0, cut_right=2.0 * 0.9e-6, n_slices=200) slices_ring = Profile(my_beam, cut_options) #Phase loop
# Ring parameters SPS circumference = 6911.5038 # Machine circumference [m] sync_momentum = 25.92e9 # SPS momentum at injection [eV/c] if optics == 'Q20': gamma_transition = 17.95142852 # Q20 Transition gamma elif optics == 'Q22': gamma_transition = 20.071 # Q22 Transition gamma else: raise RuntimeError('No gamma_transition specified') momentum_compaction = 1. / gamma_transition**2 # Momentum compaction array ring = Ring(circumference, momentum_compaction, sync_momentum, Proton(), n_turns=n_turns) tRev = ring.t_rev[0] # RF parameters SPS n_rf_systems = 1 # Number of rf systems if n_rf_systems == 2: V2_ratio = 1.00e-01 # voltage 800 MHz [V] harmonic_numbers = [4620, 18480] # Harmonic numbers voltage = [V1, V1 * V2_ratio] phi_offsets = [0, np.pi] elif n_rf_systems == 1: harmonic_numbers = 4620 # Harmonic numbers voltage = V1