ocelot.cpbd.csr

@ authors Martin Dohlus DESY, 2015, Sergey Tomin XFEL, 2016

Module Contents

Classes

Smoothing

SubBinning

K0_fin_anf

CSR

coherent synchrotron radiation

Functions

nextpow2(p)

Mimic matlab function nextpow2

csr_convolution(a, b)

sample_0(i, a, b)

sample_1(i, a, b, c)

ocelot.cpbd.csr.logger
ocelot.cpbd.csr.nb_flag = True
ocelot.cpbd.csr.ne_flag = True
ocelot.cpbd.csr.nextpow2(p)

Mimic matlab function nextpow2

Parameters

p

Returns

ocelot.cpbd.csr.csr_convolution(a, b)
ocelot.cpbd.csr.sample_0(i, a, b)
ocelot.cpbd.csr.sample_1(i, a, b, c)
class ocelot.cpbd.csr.Smoothing
q_per_step_ip2_py(self, N_BIN, Q_BIN, BIN0, BIN1, NSIG, RMS, step, Nz, z1)
Q2EQUI(self, q, BS_params, SBINB, NBIN)

input BIN = bin boundaries BIN(N_BIN, 2), in time or space Q_BIN = charges per bin Q_BIN(N_BIN) BS_params = binning and smoothing parameters binning………………….. X_QBIN = length or charge binning 0… 1 = length…charge N_BIN = number of bins M_BIN = multiple binning(with shifted bins) smoothing………………… IP_method = 0 / 1 / 2 for rectangular / triangular / gauss SP = ? parameter for gauss sigma_min = minimal sigma, if IP_method == 2 step_unit = if positive –> step=integer * step_unit output z1, z2, Nz = equidistant mesh(Nz meshlines) charge_per_step = charge per step, charge_per_step(1:Nz) bins might overlapp!

class ocelot.cpbd.csr.SubBinning(x_qbin, n_bin, m_bin)
p_per_subbins_py(self, s, SBINB, K_BIN)
subbin_bound(self, q, s, x_qbin, n_bin, m_bin)
input

q = array/scalar with charges of macro particles (sorted) s = longitudinal vector (time or space) (sorted) B_params = binning parameters

[X_QBIN,N_BIN,M_BIN] X_QBIN = length or charge binning

0 … 1 = length … charge

N_BIN = number of bins M_BIN = multiple binning (with shifted bins)

output

SBINB = array with subbin boundaries NBIN = particles per subbin

particles are sorted! all particles are valid

class ocelot.cpbd.csr.K0_fin_anf
K0_1_jit(self, indx, j, R, n, traj4, traj5, traj6, w, gamma)
K0_0_jit(self, i, traj0, traj1, traj2, traj3, gamma, s, n, R, w, wmin)
K0_fin_anf_opt(self, i, traj, wmin, gamma)
K0_fin_anf_np(self, i, traj, wmin, gamma)
K0_fin_anf_numexpr(self, i, traj, wmin, gamma)
estimate_start_index(self, i, traj, w_min, beta, i_min=1000, n_test=10)

This method estimates the index of the first trajectory point from which CSR effects should be computed.

This method can significantly reduce the computing time of CSR effects by pre-discaring regions of the reference trajectory which do not influence the CSR calculation (i.e. the points where w <= wmin). This is performed by testing the w <= wmin condition for a subset of n_test equally-spaced points along the reference trajectory. The index of the last tested trajectory point in which w <= wmin is returned.

iint

Iteration index

trajndarray

Reference trajectory along which CSR forces are calculated

w_minfloat

Leftmost edge of the longitudinal bunch binning.

betafloat

Relativistic factor.

i_minint

Minimum iteration index. When i<i_min, no estimation of the starting index is performed (0 is returned).

n_testint

Number of points along the trajectory in which to test whether they should be taken into account for the CSR calculation.

The estimated start index, which is always <= than the real one.

class ocelot.cpbd.csr.CSR

Bases: ocelot.cpbd.physics_proc.PhysProc

coherent synchrotron radiation Attributes:

self.step = 1 [in Navigator.unit_step] - step of the CSR kick applying for beam (ParticleArray) self.sigma_min = 1.e-4 - minimal sigma if gauss filtering applied self.traj_step = 0.0002 [m] - trajectory step or, other words, integration step for calculation of the CSR-wake self.apply_step = 0.0005 [m] - step of the calculation CSR kick, to calculate average CSR kick

K0_inf_anf(self, i, traj, wmin)
Parameters
  • i – index of the trajectories points for the convolution kernel is calculated;

  • traj – trajectory. traj[0,:] - longitudinal coordinate, traj[1,:], traj[2,:], traj[3,:] - rectangular coordinates, traj[4,:], traj[5,:], traj[6,:] - tangential unit vectors

  • wmin – the first coordinate of the mash

Returns

K0_fin_inf(self, i, traj, w_range, gamma)

Radiative interaction is coming from the infinite straight line that is assumed before the specified CSR region and it is calculated analytically

Parameters
  • i

  • traj

  • w_range

  • gamma

Returns

K0_inf_inf(self, i, traj, w_range)

Radiative interaction is coming from the infinite straight line that is assumed before the specified CSR region and it is calculated analytically

Parameters
  • i

  • traj

  • w_range

Returns

CSR_K1(self, i, traj, NdW, gamma=None)
Parameters
  • i – index of the trajectories points for the convolution kernel is calculated;

  • traj – trajectory. traj[0,:] - longitudinal coordinate, traj[1,:], traj[2,:], traj[3,:] - rectangular coordinates, traj[4,:], traj[5,:], traj[6,:] - tangential unit vectors

  • NdW – list [N, dW], NdW[0] is number of mesh points, NdW[1] = dW > 0 is increment. Mesh = Mesh = (-N:0) * dW

  • gamma

Returns

prepare(self, lat)

calculation of trajectory in rectangular coordinates calculation of the z_csr_start :param lat: Magnetic Lattice :return: self.csr_traj: trajectory. traj[0,:] - longitudinal coordinate,

traj[1,:], traj[2,:], traj[3,:] - rectangular coordinates, traj[4,:], traj[5,:], traj[6,:] - tangential unit vectors

apply(self, p_array, delta_s)

the method is called on every step.

Parameters
  • p_array

  • dz

Returns

finalize(self, *args, **kwargs)

the method is called at the end of tracking

Returns

plot_wake(self, p_array, lam_K1, itr_ra, s1, st)

Method to plot CSR wakes on each step and save pictures in the working folder. Might be time-consuming.

Parameters
  • p_array

  • lam_K1

  • itr_ra

  • s1

  • st

Returns