Example #1
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)
long_tracker_tot = RingAndRFTracker(rf_params_tot, beam_dummy)

print("General and RF parameters set...")


# Define beam and distribution

bigaussian(general_params, rf_params_tot, beam, tau_0/4, 
                              reinsertion = 'on', seed=1)

print("Beam set and distribution generated...")


# Need slices for the Gaussian fit; slice for the first plot
slice_beam = Profile(beam, CutOptions(n_slices=100),
                 FitOptions(fit_option='gaussian'))       
# Define what to save in file
bunchmonitor = BunchMonitor(general_params, rf_params_tot, beam,
                            this_directory + '../output_files/EX_04_output_data',
                            Profile=slice_beam, buffer_time=1)

# PLOTS
format_options = {'dirname': this_directory + '../output_files/EX_04_fig', 'linestyle': '.'}
plots = Plot(general_params, rf_params_tot, beam, dt_plt, dt_plt, 0, 
             0.0001763*h, -450e6, 450e6, xunit='rad',
             separatrix_plot=True, Profile=slice_beam,
             h5file=this_directory + '../output_files/EX_04_output_data',
             histograms_plot=True, format_options=format_options)

# For testing purposes
test_string = ''
bigaussian(general_params, RF_sct_par, my_beam, tau_0 / 4, seed=1)
bigaussian(general_params_freq,
           RF_sct_par_freq,
           my_beam_freq,
           tau_0 / 4,
           seed=1)
bigaussian(general_params_res, RF_sct_par_res, my_beam_res, tau_0 / 4, seed=1)

number_slices = 2**8
cut_options = CutOptions(cut_left=0,
                         cut_right=2 * np.pi,
                         n_slices=number_slices,
                         RFSectionParameters=RF_sct_par,
                         cuts_unit='rad')
slice_beam = Profile(my_beam, cut_options, FitOptions(fit_option='gaussian'))
cut_options_freq = CutOptions(cut_left=0,
                              cut_right=2 * np.pi,
                              n_slices=number_slices,
                              RFSectionParameters=RF_sct_par_freq,
                              cuts_unit='rad')
slice_beam_freq = Profile(my_beam_freq, cut_options_freq,
                          FitOptions(fit_option='gaussian'))
cut_options_res = CutOptions(cut_left=0,
                             cut_right=2 * np.pi,
                             n_slices=number_slices,
                             RFSectionParameters=ring_RF_section_res,
                             cuts_unit='rad')
slice_beam_res = Profile(my_beam_res, cut_options_res,
                         FitOptions(fit_option='gaussian'))