Exemple #1
0
    def generate_gaussian6dBunch(self,n_macroparticles, alpha_x, alpha_y, beta_x,
                                  beta_y, dispx, dispy,
                                  gamma = 3730.27):
        Q_s = 0.0020443
        C = 26658.883
        alpha_0 = [0.0003225]
        linear_map = LinearMap(alpha_0, C, Q_s)

        intensity = 1.05e11
        sigma_z = 0.0059958
        gamma_t = 1. / np.sqrt(alpha_0)
        p0 = np.sqrt(gamma**2 - 1) * m_p * c
        beta_z = (linear_map.eta(dp=0, gamma=gamma) * linear_map.circumference /
              (2 * np.pi * linear_map.Qs))
        epsn_x = 3.75e-6 # [m rad]
        epsn_y = 3.75e-6 # [m rad]
        epsn_z = 4 * np.pi * sigma_z**2 * p0 / (beta_z * e)
        bunch = generate_Gaussian6DTwiss(
            macroparticlenumber=n_macroparticles, intensity=intensity, charge=e,
            gamma=gamma, mass=m_p, circumference=C,
            alpha_x=0., beta_x=1., epsn_x=epsn_x,
            alpha_y=0., beta_y=1., epsn_y=epsn_y,
            beta_z=beta_z, epsn_z=epsn_z)
        # Scale to correct beta and alpha
        bunch.x *= np.sqrt(beta_x)
        bunch.xp = -alpha_x/np.sqrt(beta_x) * bunch.x + 1./np.sqrt(beta_x) * bunch.xp
        bunch.y = np.sqrt(beta_y)*bunch.y
        bunch.yp = -alpha_y/np.sqrt(beta_y) * bunch.y + 1./np.sqrt(beta_y) * bunch.yp
        bunch.x += dispx * bunch.dp
        bunch.y += dispy * bunch.dp
        return bunch
Exemple #2
0
    def create_bunch_with_params(self,alpha_x, beta_x, disp_x, gamma):
        np.random.seed(0)
        beta_y = beta_x
        alpha_y = alpha_x
        disp_y = disp_x
        alpha0= [0.00308]
        C = 6911.
        Qs = 0.017
        epsn_x = 3.75e-6
        epsn_y = 3.75e-6
        linear_map = LinearMap(alpha0, Qs, C)
       # then transform...
        intensity = 1.05e11
        sigma_z = 0.23
        gamma_t = 1. / np.sqrt(linear_map.alpha_array[0])
        p0 = np.sqrt(gamma**2 - 1) * m_p * c

        beta_z = np.abs((linear_map.eta(dp=0, gamma=gamma) * linear_map.circumference /
                  (2 * np.pi * linear_map.Qs)))

        epsn_z = 4 * np.pi * sigma_z**2 * p0 / (beta_z * e)
        #print ('epsn_z: ' + str(epsn_z))
        bunch = generate_Gaussian6DTwiss(
            macroparticlenumber=10000, intensity=intensity, charge=e,
            gamma=gamma, mass=m_p, circumference=linear_map.circumference,
            alpha_x=0., beta_x=1., epsn_x=epsn_x,
            alpha_y=0., beta_y=1., epsn_y=epsn_y,
            beta_z=beta_z, epsn_z=epsn_z)
        # Scale to correct beta and alpha
        xx = bunch.x.copy()
        yy = bunch.y.copy()
        bunch.x *= np.sqrt(beta_x)
        bunch.xp = -alpha_x/np.sqrt(beta_x) * xx + 1./np.sqrt(beta_x) * bunch.xp
        bunch.y *= np.sqrt(beta_y)
        bunch.yp = -alpha_y/np.sqrt(beta_y) * yy + 1./np.sqrt(beta_y) * bunch.yp
        bunch.x += disp_x * bunch.dp
        bunch.y += disp_y * bunch.dp
        return bunch