Ejemplo n.º 1
0
# direct space charge
dir_space_charge = InductiveImpedance(
    my_beam, slice_beam,
    -376.730313462 / (general_params.beta[0] * general_params.gamma[0]**2),
    RF_sct_par)

# INDUCED VOLTAGE FROM IMPEDANCE------------------------------------------------

imp_list = [Ekicker_table, F_C_table]

ind_volt_freq = InducedVoltageFreq(my_beam,
                                   slice_beam,
                                   imp_list,
                                   frequency_resolution=2e5)

total_induced_voltage = TotalInducedVoltage(
    my_beam, slice_beam, [ind_volt_freq, steps, dir_space_charge])

# PLOTS

format_options = {
    'dirname': this_directory + '../output_files/EX_02_fig',
    'linestyle': '.'
}
plots = Plot(general_params,
             RF_sct_par,
             my_beam,
             1,
             n_turns,
             0,
             5.72984173562e-7,
             -my_beam.sigma_dE * 4.2,
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
    L_long = 43 * 0.374  # interaction length [m]
    R_shunt_long = L_long**2 * R2 / 8  # shunt impedance [Ohm]
    damping_time_long = 2 * np.pi * L_long / vg * (1 + 0.0946)
    n_cav_long = 2  # factor 2 because of two cavities are used for tracking

    L_short = 32 * 0.374  # interaction length [m]
    R_shunt_short = L_short**2 * R2 / 8  # shunt impedance [Ohm]
    damping_time_short = 2 * np.pi * L_short / vg * (1 + 0.0946)
    n_cav_short = 4  # factor 4 because of four cavities are used for tracking

longCavity = TravelingWaveCavity(n_cav_long * R_shunt_long, fr,
                                 damping_time_long)
longCavityFreq = InducedVoltageFreq(beam, profile, [longCavity],
                                    frequency_step)
longCavityIntensity = TotalInducedVoltage(beam, profile, [longCavityFreq])

shortCavity = TravelingWaveCavity(n_cav_short * R_shunt_short, fr,
                                  damping_time_short)
shortCavityFreq = InducedVoltageFreq(beam, profile, [shortCavity],
                                     frequency_step)
shortCavityIntensity = TotalInducedVoltage(beam, profile, [shortCavityFreq])

# FB parameters
if FB_strength == 'present':
    FBstrengthLong = 1.05
    FBstrengthShort = 0.73
elif FB_strength == 'future':
    # -26dB
    FBstrengthLong = 1.8
    FBstrengthShort = FBstrengthLong
frequency_R = 2*RF_sct_par.omega_rf[0,0] / 2.0 / np.pi
Q = 10000

print('Im Z/n = '+str(R_S / (RF_sct_par.t_rev[0] * frequency_R * Q)))

resonator = Resonators(R_S, frequency_R, Q)


# INDUCED VOLTAGE FROM IMPEDANCE ----------------------------------------------

imp_list = [resonator]

ind_volt_freq = InducedVoltageFreq(beam, slice_beam, imp_list,
                                   frequency_resolution=5e4)

total_ind_volt = TotalInducedVoltage(beam, slice_beam, [ind_volt_freq])

# BEAM GENERATION -------------------------------------------------------------

n_bunches = 3
bunch_spacing_buckets = 10
intensity_list = [1e11, 1e11, 1e11]
minimum_n_macroparticles = [5e5, 5e5, 5e5]
distribution_options_list = {'bunch_length': 1e-9,
                             'type': 'parabolic_amplitude',
                             'density_variable': 'Hamiltonian'}

matched_from_distribution_density_multibunch(beam, general_params,
                             full_tracker, distribution_options_list,
                             n_bunches, bunch_spacing_buckets,
                             intensity_list=intensity_list,
Ejemplo n.º 5
0
                                   imp_list,
                                   RFParams=RF_sct_par,
                                   frequency_resolution=1e3,
                                   multi_turn_wake=True,
                                   mtw_mode='time')

ind_volt_time = InducedVoltageTime(beam,
                                   slice_beam,
                                   imp_list,
                                   RFParams=RF_sct_par,
                                   wake_length=n_turns * bucket_length,
                                   multi_turn_wake=True)

ind_volt_freq_periodic = InducedVoltageFreq(beam, slice_beam, imp_list)

total_ind_volt_freq = TotalInducedVoltage(beam, slice_beam, [ind_volt_freq])

total_ind_volt_time = TotalInducedVoltage(beam, slice_beam, [ind_volt_time])

total_ind_volt_freq_periodic = TotalInducedVoltage(beam, slice_beam,
                                                   [ind_volt_freq_periodic])

# ACCELERATION MAP-------------------------------------------------------------

map_ = [total_ind_volt_freq] + [total_ind_volt_time]

total_ind_volt_freq_periodic.track()

# FIRST COMPARISON: CONSTANT REVOLUTION FREQUENCY -----------------------------
for i in range(n_turns):
longitudinal_tracker = RingAndRFTracker(RF_sct_par,beam)
full_tracker = FullRingAndRF([longitudinal_tracker])

# INDUCED VOLTAGE FROM IMPEDANCE-----------------------------------------------
R_S = 95e3
frequency_R = 10e9
Q = 1.0

frequency_resolution_input = 1e7

Zres = Resonators(R_S, frequency_R, Q)
ind_volt = InducedVoltageFreq(beam, slice_beam, [Zres],
                              frequency_resolution=frequency_resolution_input)
                     
total_induced_voltage = TotalInducedVoltage(beam, slice_beam, [ind_volt])

beam_generation_output = matched_from_distribution_function(beam, full_tracker,
                                   distribution_type=distribution_type,
                                   emittance=emittance,
                                   distribution_variable=distribution_variable,
                                   main_harmonic_option='lowest_freq',
                                   TotalInducedVoltage=total_induced_voltage,
                                   n_iterations=20, seed=1256)

[sync_freq_distribution_left, sync_freq_distribution_right], \
    [emittance_array_left, emittance_array_right], \
    [delta_time_left, delta_time_right], \
    particleDistributionFreq, synchronous_time = \
                         synchrotron_frequency_distribution(beam, full_tracker,
                                 TotalInducedVoltage=beam_generation_output[1])
Ejemplo n.º 7
0
                                                                  ring.t_rev[0]))
mpiprint("   SL gain is %.4e turns" % PL.gain2)
mpiprint("   Omega_s0 = %.4e s at flat bottom, %.4e s at flat top"
         % (rf.omega_s0[0], rf.omega_s0[n_turns]))
mpiprint("   SL a_i = %.4f a_f = %.4f" % (PL.lhc_a[0], PL.lhc_a[n_turns]))
mpiprint("   SL t_i = %.4f t_f = %.4f" % (PL.lhc_t[0], PL.lhc_t[n_turns]))

# Injecting noise in the cavity, PL on

# Define machine impedance from http://impedance.web.cern.ch/impedance/
ZTot = np.loadtxt(os.path.join(inputDir, 'Zlong_Allthemachine_450GeV_B1_LHC_inj_450GeV_B1.dat'),
                  skiprows=1)
ZTable = InputTable(ZTot[:, 0], ZTot[:, 1], ZTot[:, 2])
indVoltage = InducedVoltageFreq(
    beam, profile, [ZTable], frequency_resolution=freq_res)
totVoltage = TotalInducedVoltage(beam, profile, [indVoltage])

# TODO add the noiseFB
tracker = RingAndRFTracker(rf, beam, BeamFeedback=PL, Profile=profile,
                           interpolation=True, TotalInducedVoltage=totVoltage,
                           solver='simple')
# interpolation=True, TotalInducedVoltage=None)
mpiprint("PL, SL, and tracker set...")
# Fill beam distribution
fullring = FullRingAndRF([tracker])
# Juan's fit to LHC profiles: binomial w/ exponent 1.5
# matched_from_distribution_function(beam, fullring,
#    main_harmonic_option = 'lowest_freq',
#    distribution_exponent = 1.5, distribution_type='binomial',
#    bunch_length = 1.1e-9, bunch_length_fit = 'fwhm',
#    distribution_variable = 'Action')
Ejemplo n.º 8
0
R_S = 5e4
frequency_R = 10e6
Q = 1e2

resonator = Resonators(R_S, frequency_R, Q)

# INDUCED VOLTAGE FROM IMPEDANCE-----------------------------------------------

imp_list = [resonator]

ind_volt_freq = InducedVoltageFreq(beam, slice_beam, imp_list,
                    frequency_resolution=1e4)

ind_volt_time = InducedVoltageTime(beam, slice_beam, imp_list)

total_ind_volt_freq = TotalInducedVoltage(beam, slice_beam, [ind_volt_freq])

total_ind_volt_time = TotalInducedVoltage(beam, slice_beam, [ind_volt_time])

total_ind_volt_ZoN = TotalInducedVoltage(beam, slice_beam, [ZoN])

# PLOTS 

# ACCELERATION MAP-------------------------------------------------------------

map_ = [slice_beam] + [total_ind_volt_freq] + [total_ind_volt_time] + \
       [total_ind_volt_ZoN] + [ring_RF_section]

# TRACKING + PLOTS-------------------------------------------------------------
beam.split()
for i in range(n_turns):
Ejemplo n.º 9
0
# LOAD IMPEDANCE TABLE--------------------------------------------------------

table = np.loadtxt(this_directory + '../input_files/EX_05_new_HQ_table.dat',
                   comments='!')

R_shunt = table[:, 2] * 10**6
f_res = table[:, 0] * 10**9
Q_factor = table[:, 1]
resonator = Resonators(R_shunt, f_res, Q_factor)

ind_volt_time = InducedVoltageTime(my_beam, slice_beam, [resonator])
ind_volt_freq = InducedVoltageFreq(my_beam_freq, slice_beam_freq, [resonator],
                                   1e5)
ind_volt_res = InducedVoltageResonator(my_beam_res, slice_beam_res, resonator)

tot_vol = TotalInducedVoltage(my_beam, slice_beam, [ind_volt_time])
tot_vol_freq = TotalInducedVoltage(my_beam_freq, slice_beam_freq,
                                   [ind_volt_freq])
tot_vol_res = TotalInducedVoltage(my_beam_res, slice_beam_res, [ind_volt_res])

# Analytic result-----------------------------------------------------------
VindGauss = np.zeros(len(slice_beam.bin_centers))
for r in range(len(Q_factor)):
    # Notice that the time-argument of inducedVoltageGauss is shifted by
    # mean(my_slices.bin_centers), because the analytical equation assumes the
    # Gauss to be centered at t=0, but the line density is centered at
    # mean(my_slices.bin_centers)
    tmp = analytical_gaussian_resonator(tau_0/4, \
                    Q_factor[r],R_shunt[r],2*np.pi*f_res[r], \
                    slice_beam.bin_centers - np.mean(slice_beam.bin_centers), \
                    my_beam.intensity)
Ejemplo n.º 10
0
                                  deriv_mode='gradient')

PS_intensity_plot = InducedVoltageFreq(
    beam,
    profile,
    ResonatorsList10MHz + ImpedanceTableList10MHz + ResonatorsListRest +
    ImpedanceTableListRest,
    frequency_step,
    RFParams=rf_params,
    multi_turn_wake=True,
    front_wake_length=front_wake_length)

# PS_longitudinal_intensity = TotalInducedVoltage(
#     beam, profile, [PS_intensity_freq_10MHz, PS_intensity_freq_Rest, PS_inductive])

PS_longitudinal_intensity = TotalInducedVoltage(
    beam, profile, [PS_intensity_freq_Rest, PS_inductive])

# RF tracker
tracker = RingAndRFTracker(rf_params,
                           beam,
                           interpolation=True,
                           Profile=profile,
                           TotalInducedVoltage=PS_longitudinal_intensity)
full_tracker = FullRingAndRF([tracker])

# Beam generation
distribution_options = {
    'type': 'parabolic_amplitude',
    'density_variable': 'Hamiltonian',
    'bunch_length': bunch_length
}
Ejemplo n.º 11
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")
Ejemplo n.º 12
0
    plt.figure()
    convtime = np.linspace(-1e-9, -1e-9+len(V_ind_beam.real)*
                           profile.bin_size, len(V_ind_beam.real))
    plt.plot(convtime, V_ind_beam.real, 'b--')
    plt.plot(convtime[:140], V_ind_beam.real[:140], 'b', label='Re(Vind), OTFB')
    plt.plot(convtime, V_ind_beam.imag, 'r--')
    plt.plot(convtime[:140], V_ind_beam.imag[:140], 'r', label='Im(Vind), OTFB')
    plt.plot(convtime[:140], V_ind_beam.real[:140]*np.cos(OTFB_4.omega_c*convtime[:140]) \
             + V_ind_beam.imag[:140]*np.sin(OTFB_4.omega_c*convtime[:140]), 
             color='purple', label='Total, OTFB')

    # Comparison with impedances: FREQUENCY DOMAIN
    TWC200_4 = TravelingWaveCavity(0.876e6, 200.222e6, 3.899e-6)
    TWC200_5 = TravelingWaveCavity(1.38e6, 200.222e6, 4.897e-6)
    indVoltageTWC = InducedVoltageTime(beam, profile, [TWC200_4, TWC200_4, TWC200_5, TWC200_5])
    indVoltage = TotalInducedVoltage(beam, profile, [indVoltageTWC])
    indVoltage.induced_voltage_sum()
    plt.plot(indVoltage.time_array, indVoltage.induced_voltage, color='limegreen', label='Time domain w FFT')
    
    # Comparison with impedances: TIME DOMAIN
    TWC200_4.wake_calc(profile.bin_centers - profile.bin_centers[0])
    TWC200_5.wake_calc(profile.bin_centers - profile.bin_centers[0])
    wake1 = 2*(TWC200_4.wake + TWC200_5.wake)
    Vind = -profile.Beam.ratio*profile.Beam.Particle.charge*e*\
        np.convolve(wake1, profile.n_macroparticles, mode='full')[:140]
    plt.plot(convtime[:140], Vind, color='teal', label='Time domain w conv')
    
    # Wake from impulse response
    OTFB_4.TWC.impulse_response_gen(omega_c, profile.bin_centers)
    OTFB_5.TWC.impulse_response_gen(omega_c, profile.bin_centers)
    OTFB_4.TWC.compute_wakes(profile.bin_centers)
Ejemplo n.º 13
0
R_shunt = 1e6
f_res = 915e6
Q_factor = 5000
resonator = Resonators(R_shunt, f_res, Q_factor)

# Set up of induced voltage

# Dictionary for compressed wake calculation
compression_dict = {}
compression_dict['n_window'] = int(2 * n_slices_per_bucket)
compression_dict['n_spacing'] = int(bunch_spacing * n_slices_per_bucket)

# Induced voltage with compressed convolution
ind_volt_time_compressed = InducedVoltageTime(
    beam, profile, [resonator], compression_dict=compression_dict)
tot_ind_volt_compressed = TotalInducedVoltage(beam, profile,
                                              [ind_volt_time_compressed])
profile.track()

# Performance test
n_test = 50
exec_time_c = np.zeros(n_test)
for k in range(n_test):
    t0 = time.perf_counter()
    tot_ind_volt_compressed.induced_voltage_sum()
    t1 = time.perf_counter()
    exec_time_c[k] = t1 - t0
print(
    f'Compressed convolution: mean {np.mean(exec_time_c):1.3e} s, std {np.std(exec_time_c):1.3e} s'
)

# Induced voltage with full convolution