示例#1
0
    def generate_6D_Gaussian_bunch_matched(
            self, n_macroparticles, intensity, epsn_x, epsn_y,
            sigma_z=None, epsn_z=None, margin=0):
        '''Generate a 6D Gaussian distribution of particles which is
        transversely as well as longitudinally matched.
        The distribution is found iteratively to exactly yield the
        given bunch length while at the same time being stationary in
        the non-linear bucket. Thus, the bunch length should amount
        to the one specificed and should not change significantly
        during the synchrotron motion.

        Requires self.longitudinal_focusing == 'non-linear'
        for the bucket.
        '''
        assert self.longitudinal_focusing == 'non-linear'
        epsx_geo = epsn_x/self.betagamma
        epsy_geo = epsn_y/self.betagamma

        bunch = gen.ParticleGenerator(macroparticlenumber=n_macroparticles,
                intensity=intensity, charge=self.charge, mass=self.mass,
                circumference=self.circumference, gamma=self.gamma,
                distribution_x=gen.gaussian2D(epsx_geo),
                alpha_x=self.alpha_x[0], beta_x=self.beta_x[0], D_x=self.D_x[0],
                distribution_y=gen.gaussian2D(epsy_geo),
                alpha_y=self.alpha_y[0], beta_y=self.beta_y[0], D_y=self.D_y[0],
                distribution_z=gen.RF_bucket_distribution(
                    rfbucket=self.longitudinal_map.get_bucket(gamma=self.gamma),
                    sigma_z=sigma_z, epsn_z=epsn_z, margin=margin,
                    printer=self._printer)
                ).generate()

        return bunch
示例#2
0
 def test_rf_bucket_distribution(self):
     '''Tests the functionality of the rf-bucket matchor'''
     #SPS Q20 flattop
     nparticles = 100
     h1 = 4620
     h2 = 4 * 4620
     V1 = 10e6
     V2 = 1e6
     dphi1 = 0
     dphi2 = 0
     alpha = 0.00308
     p_increment = 0
     long_map = RFSystems(self.circumference, [h1, h2], [V1, V2],
                          [dphi1, dphi2], [alpha],
                          self.gamma,
                          p_increment,
                          charge=self.charge,
                          mass=self.mass)
     bucket = long_map.get_bucket(gamma=self.gamma)
     bunch = gf.ParticleGenerator(nparticles,
                                  1e11,
                                  constants.e,
                                  constants.m_p,
                                  self.circumference,
                                  self.gamma,
                                  distribution_z=gf.RF_bucket_distribution(
                                      bucket,
                                      epsn_z=0.002,
                                      printer=SilentPrinter())).generate()
示例#3
0
    def generate_6D_Gaussian_bunch_matched(
        self, n_macroparticles, intensity, epsn_x, epsn_y, sigma_z=None, epsn_z=None
    ):
        """Generate a 6D Gaussian distribution of particles which is
        transversely as well as longitudinally matched.
        The distribution is found iteratively to exactly yield the
        given bunch length while at the same time being stationary in
        the non-linear bucket. Thus, the bunch length should amount
        to the one specificed and should not change significantly
        during the synchrotron motion.

        Requires self.longitudinal_mode == 'non-linear'
        for the bucket.
        """
        if self.longitudinal_mode == 'linear':
            assert(sigma_z is not None)
            bunch = self.generate_6D_Gaussian_bunch(n_macroparticles, intensity,
                    epsn_x, epsn_y, sigma_z)
        elif self.longitudinal_mode == "non-linear":
            epsx_geo = epsn_x / self.betagamma
            epsy_geo = epsn_y / self.betagamma

            injection_optics = self.transverse_map.get_injection_optics()

            bunch = generators.ParticleGenerator(
                macroparticlenumber=n_macroparticles,
                intensity=intensity,
                charge=self.charge,
                mass=self.mass,
                circumference=self.circumference,
                gamma=self.gamma,
                distribution_x=generators.gaussian2D(epsx_geo),
                alpha_x=injection_optics["alpha_x"],
                beta_x=injection_optics["beta_x"],
                D_x=injection_optics["D_x"],
                distribution_y=generators.gaussian2D(epsy_geo),
                alpha_y=injection_optics["alpha_y"],
                beta_y=injection_optics["beta_y"],
                D_y=injection_optics["D_y"],
                distribution_z=generators.RF_bucket_distribution(
                    self.longitudinal_map.get_bucket(gamma=self.gamma),
                    sigma_z=sigma_z,
                    epsn_z=epsn_z,
                ),
            ).generate()
        else:
            raise ValueError('Unknown longitudinal mode!')

        return bunch
示例#4
0
    def generate_6D_Gaussian_bunch_matched_parabolic(self,
                                                     n_macroparticles,
                                                     intensity,
                                                     epsn_x,
                                                     epsn_y,
                                                     sigma_z=None,
                                                     epsn_z=None,
                                                     margin=0):
        '''
        Modified version to use parabolic longitudinal profile
        instead of the gaussian one

        Added 06.04.2018
        '''
        assert self.longitudinal_focusing == 'non-linear'
        epsx_geo = epsn_x / self.betagamma
        epsy_geo = epsn_y / self.betagamma

        bunch = gen.ParticleGenerator(
            macroparticlenumber=n_macroparticles,
            intensity=intensity,
            charge=self.charge,
            mass=self.mass,
            circumference=self.circumference,
            gamma=self.gamma,
            distribution_x=gen.gaussian2D(epsx_geo),
            alpha_x=self.alpha_x[0],
            beta_x=self.beta_x[0],
            D_x=self.D_x[0],
            distribution_y=gen.gaussian2D(epsy_geo),
            alpha_y=self.alpha_y[0],
            beta_y=self.beta_y[0],
            D_y=self.D_y[0],
            distribution_z=gen.RF_bucket_distribution(
                rfbucket=self.longitudinal_map.get_bucket(gamma=self.gamma),
                distribution_type=ParabolicDistribution,
                sigma_z=sigma_z,
                epsn_z=epsn_z,
                margin=margin,
                printer=self._printer)).generate()

        return bunch