def test_default_wake_length(self): test_object= InducedVoltageFreq( None, self.profile, [self.impedance_source]) np.testing.assert_allclose( test_object.wake_length, self.profile.bin_size * self.profile.n_slices)
def test_frequency_resolution_frequency_resolution(self): test_object= InducedVoltageFreq( None, self.profile, [self.impedance_source], frequency_resolution=3e6) np.testing.assert_allclose( test_object.frequency_resolution, test_object.freq[1] - test_object.freq[0])
slice_beam, 34.6669349520904 / 10e9 * general_params.f_rev, RF_sct_par, deriv_mode='diff') # 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,
impedance_scenario.importImpedanceSPS( VVSA_shielded=shield_vvsa, VVSB_shielded=shield_vvsb, # kickerMario=new_MKE, noMKP=False, # BPH_shield=BPH_shield ) # Convert to formats known to BLonD impedance_model = impedance2blond(impedance_scenario.table_impedance) # Induced voltage calculated by the 'frequency' method SPS_freq = InducedVoltageFreq(beam, profile, impedance_model.impedanceListToPlot, frequency_step) # # The main 200MHz impedance is effectively 0.0 # impedance_scenario = scenario(MODEL=impedance_model_str, # FB_attenuation=-1000) # induced_voltage = TotalInducedVoltage(beam, profile, [SPS_freq]) mpiprint('SPS impedance model set!') R2 = 27.1e3 # series impedance [kOhm/m^2] vg = 0.0946 * c # group velocity [m/s] fr = 200.222e6 # resonant frequency [Hz] if cavities == 'present':
RF_sct_par = RFStation(general_params, harmonic_numbers, voltage_program, phi_offset, n_rf_systems) 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 = \
# LOAD IMPEDANCE TABLES-------------------------------------------------------- R_S = 5e3 frequency_R = 10e6 Q = 10 resonator = Resonators(R_S, frequency_R, Q) # INDUCED VOLTAGE FROM IMPEDANCE----------------------------------------------- imp_list = [resonator] ind_volt_freq = InducedVoltageFreq(beam, slice_beam, 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])
LHCNoiseFB=noiseFB) mpiprint(" PL gain is %.4e 1/s for initial turn T0 = %.4e s" % (PL.gain, 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',
'../output_files/EX_05_output_data_res', Profile=slice_beam_res, buffer_time=1) # 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, \
# Building up BLonD objects ResonatorsList10MHz = imp10MHzToBLonD.wakeList ImpedanceTableList10MHz = imp10MHzToBLonD.impedanceList ResonatorsListRest = impRestToBLonD.wakeList ImpedanceTableListRest = impRestToBLonD.impedanceList frequency_step = 1 / (ring.t_rev[0] * n_turns_memory) # [Hz] front_wake_length = filter_front_wake * ring.t_rev[0] * n_turns_memory PS_intensity_freq_Rest = InducedVoltageFreq( beam, profile, ResonatorsList10MHz + ImpedanceTableList10MHz + ResonatorsListRest + ImpedanceTableListRest, frequency_step, RFParams=rf_params, multi_turn_wake=True, front_wake_length=front_wake_length) PS_inductive = InductiveImpedance(beam, profile, space_charge_z_over_n, rf_params, deriv_mode='gradient') PS_intensity_plot = InducedVoltageFreq( beam, profile, ResonatorsList10MHz + ImpedanceTableList10MHz + ResonatorsListRest +
ind_volt_time = InducedVoltageTime(beam, profile, [resonator]) tot_ind_volt = TotalInducedVoltage(beam, profile, [ind_volt_time]) profile.track() exec_time = np.zeros(n_test) for k in range(n_test): t0 = time.perf_counter() tot_ind_volt.induced_voltage_sum() t1 = time.perf_counter() exec_time[k] = t1 - t0 print( f'Full convolution: mean {np.mean(exec_time):1.3e} s, std {np.std(exec_time):1.3e} s' ) # Induced voltage in frequency domain. Zero padding to avoid front wake ind_volt_freq = InducedVoltageFreq(beam, profile, [resonator], frequency_resolution=0.5 / profile.bin_size / n_slices) tot_ind_volt_freq = TotalInducedVoltage(beam, profile, [ind_volt_freq]) profile.track() exec_time_f = np.zeros(n_test) for k in range(n_test): t0 = time.perf_counter() tot_ind_volt_freq.induced_voltage_sum() t1 = time.perf_counter() exec_time_f[k] = t1 - t0 print( f'Frequency domain: mean {np.mean(exec_time_f):1.3e} s, std {np.std(exec_time_f):1.3e} s' ) print( f'Speed-up vs full convolution {np.mean(exec_time)/np.mean(exec_time_c):1.2f}'
def test_frequency_resolution_n_fft(self): test_object= InducedVoltageFreq( None, self.profile, [self.impedance_source], frequency_resolution=3e6) np.testing.assert_equal(test_object.n_fft, 1080)
def test_default_n_rfft(self): test_object= InducedVoltageFreq( None, self.profile, [self.impedance_source]) np.testing.assert_equal(test_object.n_fft, 16)
def test_default_frequency_resolution(self): test_object= InducedVoltageFreq( None, self.profile, [self.impedance_source]) np.testing.assert_allclose(test_object.frequency_resolution, 1/(self.profile.bin_size * self.profile.n_slices))