def plot_Ez_on_axis(n_pe, beam_tot_z, beam_num_ptcl): """ Plot the longitudinal electric field in a plasma bubble. Valid in "strong bubble regime", where rb_max*k_pe >> 1. Args: n_pe: number density of the electron plasma beam_tot_z: total length of the drive beam beam_num_ptcl: number of e- in the drive beam Returns: ax: matplotlib 'Axis' object for Ez inside bubble """ # calculate the maximum bubble radius rb_max = lbn_wake.calc_rb_max(n_pe, beam_tot_z, beam_num_ptcl) # calculate the bubble half width xi_b = lbn_wake.calc_bubble_halfwidth(rb_max) # calculate the approximate (constant?) decelerating field # along the drive beam E_decel = lbn_wake.calc_E_decel_along_beam(n_pe, beam_tot_z, beam_num_ptcl) # Specify the plot range, xi_min <= xi <= xi_max # xi=ct-z is the distance from the front of the bubble (positive) xi_min = 0. xi_max = 1.99 * xi_b num_points = 100 xi_array = np.linspace(xi_min, xi_max, num=num_points) ez_array = np.zeros(num_points) for iloop in range(0, num_points): xi = xi_array[iloop] if xi < 0. or xi > 2. * xi_b: ez_array[iloop] = 0. elif xi < beam_tot_z: ez_array[iloop] = E_decel else: rb = lbn_wake.calc_local_bubble_radius(xi, rb_max) ez_array[iloop] = lbn_wake.calc_Ez_on_axis_no_beam( n_pe, rb, rb_max) # normalize units to GV/m and microns ez_array *= 1.e-9 xi_array *= 1.e6 # generate the plot ax = plt.subplot(111) ax.plot(xi_array, ez_array) ax.set_xlabel('xi = ct - z [microns]') ax.set_ylabel('(axial) Ez [GV/m]') ax.set_title('PWFA axial Ez in "strong" regime') return ax
def plot_bubble_radius(n_pe, beam_tot_z, beam_num_ptcl): """ Plot the plasma bubble radius. Valid in "strong bubble regime", where rb_max*k_pe >> 1. Args: n_pe: number density of the electron plasma beam_tot_z: total length of the drive beam beam_num_ptcl: number of e- in the drive beam Returns: ax: matplotlib 'Axis' object for bubble radius plot """ # calculate the maximum bubble radius rb_max = lbn_wake.calc_rb_max(n_pe, beam_tot_z, beam_num_ptcl) # calculate the bubble half width xi_b = lbn_wake.calc_bubble_halfwidth(rb_max) # Specify the plot range, xi_min <= xi <= xi_max # xi=ct-z is the distance from the front of the bubble (positive) xi_min = 0. xi_max = 2. * xi_b num_points = 200 xi_array = np.linspace(xi_min, xi_max, num=num_points) rb_array = np.zeros(num_points) for iloop in range(0, num_points): rb_array[iloop] = lbn_wake.calc_local_bubble_radius( xi_array[iloop], rb_max) # normalize units to microns rb_array *= 1.e6 xi_array *= 1.e6 # generate the plot ax = plt.subplot(111) ax.plot(xi_array, rb_array) ax.set_xlabel('xi = ct - z [microns]') ax.set_ylabel('rb [microns]') ax.set_title('PWFA bubble radius in "strong" regime') return ax
print(" We assume this is a location behind the drive beam:") # rb_max is calculated above drb_dxi_nb = lbn_wake.calc_drb_dxi_no_beam(rb, rb_max) print(" drb_dxi (no beam) = ", rs_sigfig(drb_dxi_nb,3), " [rad]") print() print("*******") print("Calculate local axial longitudinal electric field...") print(" We assume this is a location behind the drive beam:") Ez_nb = lbn_wake.calc_Ez_on_axis_no_beam(n_pe, rb, rb_max) print(" Ez (no beam) = ", rs_sigfig(Ez_nb*1.e-9,3), " [GV/m] (+ or -)") print() print("*******") print("Calculate the halfwidth of the plasma bubble:") xi_b = lbn_wake.calc_bubble_halfwidth(rb_max) print(" xi_b = ", rs_sigfig(xi_b*1.e6,3), " [microns]") print() print("*******") print("Calculate local bubble radius at arbitrary location...") print(" Selected location is 'xi=ct-z' (positive):") xi = 0.3*xi_b print(" xi = ", rs_sigfig(xi*1.e6,3), " [microns]") rb = lbn_wake.calc_local_bubble_radius(xi, rb_max) print(" rb = ", rs_sigfig(rb*1.e6,3), " [microns]") print() print("*******") print("Calculate bubble radius at location of maximum...") print(" Selected location is 'xi=xi_b' (positive):")
def test_lbn_10(): rb_max = lbn_wake.calc_rb_max(n_pe, beam_tot_z, beam_num_ptcl) xi_b = lbn_wake.calc_bubble_halfwidth(rb_max) rb = lbn_wake.calc_local_bubble_radius(xi_b, rb_max) assert rs_sigfig(rb * 1.e6, 3) == rs_sigfig(97.2, 3)
def test_lbn_09(): rb_max = lbn_wake.calc_rb_max(n_pe, beam_tot_z, beam_num_ptcl) xi_b = lbn_wake.calc_bubble_halfwidth(rb_max) xi = 0.3 * xi_b rb = lbn_wake.calc_local_bubble_radius(xi, rb_max) assert rs_sigfig(rb * 1.e6, 3) == rs_sigfig(77.7, 3)
def test_lbn_08(): rb_max = lbn_wake.calc_rb_max(n_pe, beam_tot_z, beam_num_ptcl) xi_b = lbn_wake.calc_bubble_halfwidth(rb_max) assert rs_sigfig(xi_b * 1.e6, 3) == rs_sigfig(82.3, 3)