示例#1
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_)
示例#2
0
    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
示例#3
0
    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):

        # 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]
示例#5
0
    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 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)
示例#7
0
 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)
示例#8
0
    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)
示例#9
0
    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))
示例#10
0
    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))
示例#11
0
    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
示例#12
0
    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
示例#13
0
# Derived parameters
E_0 = m_p * c**2 / e  # [eV]
tot_beam_energy = E_0 + kin_beam_energy  # [eV]
sync_momentum = np.sqrt(tot_beam_energy**2 - E_0**2)  # [eV / c]
momentum_compaction = 1 / gamma_transition**2  # [1]

# Cavities parameters
n_rf_systems = 1
harmonic_numbers = 1
voltage_program = 8e3  #[V]
phi_offset = np.pi

# DEFINE RING------------------------------------------------------------------

general_params = Ring(C, momentum_compaction, sync_momentum, Proton(), n_turns)

RF_sct_par = RFStation(general_params, [harmonic_numbers], [voltage_program],
                       [phi_offset], n_rf_systems)

my_beam = Beam(general_params, n_macroparticles, n_particles)

ring_RF_section = RingAndRFTracker(RF_sct_par, my_beam)

# DEFINE BEAM------------------------------------------------------------------
bigaussian(general_params, RF_sct_par, my_beam, sigma_dt, seed=1)

# DEFINE SLICES----------------------------------------------------------------
slice_beam = Profile(
    my_beam,
    CutOptions(cut_left=-5.72984173562e-7,
示例#14
0
 def setUp(self):
     self.proton = Proton()
gamma = tot_beam_energy / E_0
beta = np.sqrt(1.0-1.0/gamma**2.0)

momentum_compaction = 1 / gamma_transition**2

# Cavities parameters
n_rf_systems = 1
harmonic_numbers = 35640.0
voltage_program = 16e6
phi_offset = 0


# DEFINE RING------------------------------------------------------------------

general_params = Ring(C, momentum_compaction,
                                   sync_momentum, Proton(), n_turns)

RF_sct_par = RFStation(general_params, [harmonic_numbers], [voltage_program],
                       [phi_offset], n_rf_systems)

beam = Beam(general_params, n_macroparticles, n_particles)
ring_RF_section = RingAndRFTracker(RF_sct_par, beam)

full_tracker = FullRingAndRF([ring_RF_section])

fs = RF_sct_par.omega_s0[0]/2/np.pi    

bucket_length = 2.0 * np.pi / RF_sct_par.omega_rf[0,0]

# DEFINE SLICES ---------------------------------------------------------------
示例#16
0
# 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) *
示例#17
0
    def setUp(self):
        """
        Slicing of the same Gaussian profile using four distinct settings to
        test different features.
        """

        np.random.seed(1984)

        intensity_pb = 1.0e11
        sigma = 0.2e-9  # Gauss sigma, [s]

        n_macroparticles_pb = int(1e4)
        n_bunches = 2

        # --- Ring and RF ----------------------------------------------
        intensity = n_bunches * intensity_pb  # total intensity SPS
        n_turns = 1
        # Ring parameters SPS
        circumference = 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

        ring = Ring(circumference,
                    momentum_compaction,
                    sync_momentum,
                    Proton(),
                    n_turns=n_turns)

        # RF parameters SPS
        harmonic_number = 4620  # harmonic number
        voltage = 3.5e6  # [V]
        phi_offsets = 0

        self.rf_station = RFStation(ring,
                                    harmonic_number,
                                    voltage,
                                    phi_offsets,
                                    n_rf=1)
        t_rf = self.rf_station.t_rf[0, 0]

        bunch_spacing = 5  # RF buckets

        n_macroparticles = n_bunches * n_macroparticles_pb
        self.beam = Beam(ring, n_macroparticles, intensity)

        for bunch in range(n_bunches):

            bunchBeam = Beam(ring, n_macroparticles_pb, intensity_pb)
            bigaussian(ring,
                       self.rf_station,
                       bunchBeam,
                       sigma,
                       reinsertion=True,
                       seed=1984 + bunch)

            self.beam.dt[bunch*n_macroparticles_pb : (bunch+1)*n_macroparticles_pb] \
                = bunchBeam.dt + bunch*bunch_spacing * t_rf
            self.beam.dE[bunch * n_macroparticles_pb:(bunch + 1) *
                         n_macroparticles_pb] = bunchBeam.dE

        self.filling_pattern = np.zeros(bunch_spacing * (n_bunches - 1) + 1)
        self.filling_pattern[::bunch_spacing] = 1

        # uniform profile

        profile_margin = 0 * t_rf

        t_batch_begin = 0 * t_rf
        t_batch_end = (bunch_spacing * (n_bunches - 1) + 1) * t_rf

        self.n_slices_rf = 32  # number of slices per RF-bucket

        cut_left = t_batch_begin - profile_margin
        cut_right = t_batch_end + profile_margin

        # number of rf-buckets of the self.beam
        # + rf-buckets before the self.beam + rf-buckets after the self.beam
        n_slices = self.n_slices_rf * (
            bunch_spacing * (n_bunches - 1) + 1 +
            int(np.round((t_batch_begin - cut_left) / t_rf)) +
            int(np.round((cut_right - t_batch_end) / t_rf)))

        self.uniform_profile = Profile(self.beam,
                                       CutOptions=CutOptions(
                                           cut_left=cut_left,
                                           n_slices=n_slices,
                                           cut_right=cut_right))
        self.uniform_profile.track()
示例#18
0
tau_0 = 1.0e-9  # Initial bunch length, 4 sigma [s]

# Machine and RF parameters
C = 26658.883  # Machine circumference [m]
p = 450e9  # Synchronous momentum [eV/c]
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

# Simulation setup ------------------------------------------------------------
ring = Ring(C, alpha, p, Proton(), N_t)
rf = RFStation(ring, [h], [V], [dphi])
beam = Beam(ring, N_p, N_b)
bigaussian(ring, rf, beam, tau_0 / 4, reinsertion=True, seed=1)
profile = Profile(beam,
                  CutOptions=CutOptions(n_slices=100,
                                        cut_left=0,
                                        cut_right=2.5e-9))
profile.track()

# Calculate oscillation amplitude from coordinates
dtmax, bin_centres, histogram = oscillation_amplitude_from_coordinates(
    ring, rf, beam.dt, beam.dE, Np_histogram=100)

# Normalise profiles
profile.n_macroparticles /= np.sum(profile.n_macroparticles)
示例#19
0
# 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
    phi_offsets = 0
示例#20
0
    def test_vind(self):

        # randomly chose omega_c from allowed range
        np.random.seed(1980)
        factor = np.random.uniform(0.9, 1.1)

        # round results to this digits
        digit_round = 8

        # SPS parameters
        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
        V = 4.5e6  # 200 MHz RF voltage
        phi = 0.  # 200 MHz RF phase

        # Beam and tracking parameters
        N_m = 1e5  # Number of macro-particles for tracking
        N_b = 1.0e11  # Bunch intensity [ppb]
        N_t = 1  # Number of turns to track

        ring = Ring(C, alpha, p_s, Proton(), n_turns=N_t)
        rf = RFStation(ring, h, V, phi)
        beam = Beam(ring, N_m, N_b)
        bigaussian(ring, rf, beam, 3.2e-9 / 4, seed=1234, reinsertion=True)

        n_shift = 5  # how many rf-buckets to shift beam
        beam.dt += n_shift * rf.t_rf[0, 0]
        profile = Profile(beam,
                          CutOptions=CutOptions(
                              cut_left=(n_shift - 1.5) * rf.t_rf[0, 0],
                              cut_right=(n_shift + 1.5) * rf.t_rf[0, 0],
                              n_slices=140))
        profile.track()

        l_cav = 16.082
        v_g = 0.0946
        tau = l_cav / (v_g * c) * (1 + v_g)
        TWC_impedance_source = TravelingWaveCavity(l_cav**2 * 27.1e3 / 8,
                                                   200.222e6, 2 * np.pi * tau)

        # Beam loading by convolution of beam and wake from cavity
        inducedVoltageTWC = InducedVoltageTime(beam, profile,
                                               [TWC_impedance_source])
        induced_voltage = TotalInducedVoltage(beam, profile,
                                              [inducedVoltageTWC])
        induced_voltage.induced_voltage_sum()
        V_ind_impSource = np.around(induced_voltage.induced_voltage,
                                    digit_round)

        # Beam loading via feed-back system
        OTFB_4 = SPSOneTurnFeedback(rf, beam, profile, 4, n_cavities=1)
        OTFB_4.counter = 0  # First turn

        OTFB_4.omega_c = factor * OTFB_4.TWC.omega_r
        # Compute impulse response
        OTFB_4.TWC.impulse_response_beam(OTFB_4.omega_c, profile.bin_centers)

        # Compute induced voltage in (I,Q) coordinates
        OTFB_4.beam_induced_voltage(lpf=False)
        # convert back to time
        V_ind_OTFB \
            = OTFB_4.V_fine_ind_beam.real \
                * np.cos(OTFB_4.omega_c*profile.bin_centers) \
            + OTFB_4.V_fine_ind_beam.imag \
                * np.sin(OTFB_4.omega_c*profile.bin_centers)
        V_ind_OTFB = np.around(V_ind_OTFB, digit_round)

        self.assertListEqual(
            V_ind_impSource.tolist(),
            V_ind_OTFB.tolist(),
            msg="In TravelingWaveCavity test_vind: induced voltages differ")
示例#21
0
    os.mkdir(this_directory + '../output_files/EX_08_fig')
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 = 500
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*np.pi, n_slices=200, 
                         RFSectionParameters=rf_params, cuts_unit = 'rad')
slices_ring = Profile(my_beam, cut_options)
示例#22
0
worker.greet()
if worker.isMaster:
    worker.print_version()

worker.initLog(bool(args['log']), args['logdir'])
worker.initTrace(bool(args['trace']), args['tracefile'])
worker.taskparallelism = withtp

mpiprint(args)

# Simulation setup ------------------------------------------------------------
mpiprint("Setting up the simulation...")

# Define general parameters
ring = Ring(C, alpha, np.linspace(p_i, p_f, n_turns + 1), Proton(), n_turns)

# Define beam and distribution
beam = Beam(ring, n_particles, N_b)

# Define RF station parameters and corresponding tracker
rf = RFStation(ring, [h], [V], [dphi])

bigaussian(ring, rf, beam, tau_0 / 4, reinsertion=True, seed=seed)

# Need slices for the Gaussian fit
# TODO add the gaussian fit
profile = Profile(beam, CutOptions(n_slices=n_slices))
# FitOptions(fit_option='gaussian'))

long_tracker = RingAndRFTracker(rf, beam)
    def test_rf_parameters_calculate_phi_s(self):

        self.assertEqual(calculate_phi_s(self.rf_params, Particle=Proton())[0], numpy.pi,
                         msg="Wrong phi_s for Proton")
        self.assertEqual(calculate_phi_s(self.rf_params, Particle=Electron())[0], 0.0,
                         msg="Wrong phi_s for Electron")
示例#24
0
    # unpack=True)
    ps = np.ascontiguousarray(ps)
    ps = np.concatenate((ps, np.ones(436627)*6.5e12))
else:
    ps = 450.e9*np.ones(n_turns+1)
mpiprint("Flat top momentum %.4e eV" % ps[-1])
if REAL_RAMP:
    V = np.concatenate((np.linspace(6.e6, 12.e6, 13563374),
                        np.ones(436627)*12.e6))
else:
    V = 6.e6*np.ones(n_turns+1)
mpiprint("Flat top voltage %.4e V" % V[-1])
mpiprint("Momentum and voltage loaded...")

# Define general parameters
ring = Ring(C, alpha, ps[0:n_turns+1], Proton(), n_turns=n_turns)
mpiprint("General parameters set...")

# Define RF parameters (noise to be added for CC case)
rf = RFStation(ring, [h], [V[0:n_turns+1]], [0.])
mpiprint("RF parameters set...")

# Generate RF phase noise
LHCnoise = FlatSpectrum(ring, rf, fmin_s0=0.8571, fmax_s0=1.001,
                        initial_amplitude=1.e-5,
                        predistortion='weightfunction')
LHCnoise.dphi = np.load(
    os.path.join(inputDir, 'LHCNoise_fmin0.8571_fmax1.001_ampl1e-5_weightfct_6.5TeV.npz'))['arr_0']
LHCnoise.dphi = np.ascontiguousarray(LHCnoise.dphi[0:n_turns+1])
mpiprint("RF phase noise loaded...")
示例#25
0
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
# 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)
Vtot = total_voltage([rf_params_1, rf_params_2])
示例#27
0
    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)
示例#28
0
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
示例#29
0
h = 35640  # Harmonic number
V = 6e6  # RF voltage [eV]
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 = 200  # Number of turns to track
dt_plt = 20  # Time steps between plots

# Simulation setup -------------------------------------------------------------
print("Setting up the simulation...")
print("")

# Define general parameters
general_params = Ring(C, alpha, p_s, Proton(), N_t)

# Define RF station parameters and corresponding tracker
rf_params = RFStation(general_params, [h], [V], [0])

# Pre-processing: RF phase noise -----------------------------------------------
RFnoise = FlatSpectrum(general_params,
                       rf_params,
                       delta_f=1.12455000e-02,
                       fmin_s0=0,
                       fmax_s0=1.1,
                       seed1=1234,
                       seed2=7564,
                       initial_amplitude=1.11100000e-07,
                       folder_plots=this_directory +
                       '../output_files/EX_03_fig')
示例#30
0
momentumTime = loaded_program['momentumTime'] / 1e3  # s
momentum = loaded_program['momentum'] * 1e9  # eV/c

rfPerHamonicTime = loaded_program['rfPerHamonicTime'] / 1e3  # s
rfPerHamonicDict = loaded_program['rfPerHamonicDict']
rfProgH21 = rfPerHamonicDict.item()['21'] * 1e3
rfProgH21[rfPerHamonicTime >= 2.710] = rfProgH21[rfPerHamonicTime >= 2.710][0]

c_time_injection = 0.170
c_time_extraction = 2.850

c_time_start = 2.055  # s
c_time_end = c_time_extraction

# General parameters PS
particle_type = Proton()
circumference = 2 * np.pi * 100  # Machine circumference [m]
gamma_transition = 6.1  # Transition gamma
momentum_compaction = 1. / gamma_transition**2  # Momentum compaction array

# RF parameters PS
n_rf_systems = 1  # Number of rf systems second section
harmonic_number = 21  # Harmonic number section
phi_offset = 0  # Phase offset

voltage_ratio = 0.15
harmonic_ratio = 4

# Beam parameters
n_bunches = 21
n_particles = 1e6