:mod:`ocelot.cpbd.csr` ====================== .. py:module:: ocelot.cpbd.csr .. autoapi-nested-parse:: @ authors Martin Dohlus DESY, 2015, Sergey Tomin XFEL, 2016 Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: ocelot.cpbd.csr.Smoothing ocelot.cpbd.csr.SubBinning ocelot.cpbd.csr.K0_fin_anf ocelot.cpbd.csr.CSR Functions ~~~~~~~~~ .. autoapisummary:: ocelot.cpbd.csr.nextpow2 ocelot.cpbd.csr.csr_convolution ocelot.cpbd.csr.sample_0 ocelot.cpbd.csr.sample_1 .. data:: logger .. data:: nb_flag :annotation: = True .. data:: ne_flag :annotation: = True .. function:: nextpow2(p) Mimic matlab function nextpow2 :param p: :return: .. function:: csr_convolution(a, b) .. function:: sample_0(i, a, b) .. function:: sample_1(i, a, b, c) .. py:class:: Smoothing .. method:: q_per_step_ip2_py(self, N_BIN, Q_BIN, BIN0, BIN1, NSIG, RMS, step, Nz, z1) .. method:: 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! .. py:class:: SubBinning(x_qbin, n_bin, m_bin) .. method:: p_per_subbins_py(self, s, SBINB, K_BIN) .. method:: 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 .. py:class:: K0_fin_anf .. method:: K0_1_jit(self, indx, j, R, n, traj4, traj5, traj6, w, gamma) .. method:: K0_0_jit(self, i, traj0, traj1, traj2, traj3, gamma, s, n, R, w, wmin) .. method:: K0_fin_anf_opt(self, i, traj, wmin, gamma) .. method:: K0_fin_anf_np(self, i, traj, wmin, gamma) .. method:: K0_fin_anf_numexpr(self, i, traj, wmin, gamma) .. method:: 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. Parameters ---------- i : int Iteration index traj : ndarray Reference trajectory along which CSR forces are calculated w_min : float Leftmost edge of the longitudinal bunch binning. beta : float Relativistic factor. i_min : int Minimum iteration index. When i 0 is increment. Mesh = Mesh = (-N:0) * dW :param gamma: :return: .. method:: 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 .. method:: apply(self, p_array, delta_s) the method is called on every step. :param p_array: :param dz: :return: .. method:: finalize(self, *args, **kwargs) the method is called at the end of tracking :return: .. method:: 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. :param p_array: :param lam_K1: :param itr_ra: :param s1: :param st: :return: