def __init__(self,
                 name="Undefined",
                 electron_beam=SRWElectronBeam(),
                 magnetic_structure=SRWMagneticStructure()):
        LightSource.__init__(self, name, electron_beam, magnetic_structure)

        self.__source_wavefront_parameters = None
    def __init__(self,
                 name="Undefined",
                 electron_beam=SRWElectronBeam(),
                 bending_magnet_magnetic_structure=SRWIRBendingMagnet()):

        super().__init__(name,
                         electron_beam=electron_beam,
                         magnetic_structure=bending_magnet_magnetic_structure)
    def __init__(self,
                 name="Undefined",
                 electron_beam=SRWElectronBeam(),
                 undulator_magnetic_structure=SRWUndulator()):

        super().__init__(name,
                         electron_beam=electron_beam,
                         magnetic_structure=undulator_magnetic_structure)
Beispiel #4
0
    def get_electron_beam(self):
        received_electron_beam = self.received_light_source.get_electron_beam()

        electron_beam = SRWElectronBeam(
            energy_in_GeV=received_electron_beam._energy_in_GeV,
            energy_spread=received_electron_beam._energy_spread,
            current=received_electron_beam._current)

        electron_beam._moment_x = 0.0
        electron_beam._moment_y = 0.0
        electron_beam._moment_z = self.get_default_initial_z()
        electron_beam._moment_xp = 0.0
        electron_beam._moment_yp = 0.0
        electron_beam._moment_xx = received_electron_beam._moment_xx
        electron_beam._moment_xxp = received_electron_beam._moment_xxp
        electron_beam._moment_xpxp = received_electron_beam._moment_xpxp
        electron_beam._moment_yy = received_electron_beam._moment_yy
        electron_beam._moment_yyp = received_electron_beam._moment_yyp
        electron_beam._moment_ypyp = received_electron_beam._moment_ypyp

        return electron_beam
Beispiel #5
0
    def get_electron_beam(self):
        if self.type_of_initialization == 2:
            electron_beam = SRWElectronBeam(energy_in_GeV=numpy.random.normal(self.electron_energy_in_GeV,
                                                                              self.electron_energy_spread*self.electron_energy_in_GeV),
                                            energy_spread=self.electron_energy_spread,
                                            current=self.ring_current)
        else:
            electron_beam = SRWElectronBeam(energy_in_GeV=self.electron_energy_in_GeV,
                                            energy_spread=self.electron_energy_spread,
                                            current=self.ring_current)

        if self.type_of_properties == 0:
            electron_beam._moment_xx = self.moment_xx
            electron_beam._moment_xxp = self.moment_xxp
            electron_beam._moment_xpxp = self.moment_xpxp
            electron_beam._moment_yy = self.moment_yy
            electron_beam._moment_yyp = self.moment_yyp
            electron_beam._moment_ypyp = self.moment_ypyp

            x, xp, y, yp = electron_beam.get_sigmas_all()

            self.electron_beam_size_h = x
            self.electron_beam_size_v = y
            self.electron_beam_divergence_h = xp
            self.electron_beam_divergence_v = yp
        elif self.type_of_properties == 1:
            electron_beam.set_sigmas_all(sigma_x=self.electron_beam_size_h,
                                         sigma_y=self.electron_beam_size_v,
                                         sigma_xp=self.electron_beam_divergence_h,
                                         sigma_yp=self.electron_beam_divergence_v)

            self.moment_xx = electron_beam._moment_xx
            self.moment_xpxp = electron_beam._moment_xpxp
            self.moment_yy = electron_beam._moment_yy
            self.moment_ypyp = electron_beam._moment_ypyp

        elif self.type_of_properties == 2:
            electron_beam.set_moments_from_twiss(horizontal_emittance = self.horizontal_emittance,
                                                 horizontal_beta      = self.horizontal_beta,
                                                 horizontal_alpha     = self.horizontal_alpha,
                                                 horizontal_eta       = self.horizontal_eta,
                                                 horizontal_etap      = self.horizontal_etap,
                                                 vertical_emittance   = self.vertical_emittance,
                                                 vertical_beta        = self.vertical_beta,
                                                 vertical_alpha       = self.vertical_alpha,
                                                 vertical_eta         = self.vertical_eta,
                                                 vertical_etap        = self.vertical_etap)

            self.moment_xx = electron_beam._moment_xx
            self.moment_xpxp = electron_beam._moment_xpxp
            self.moment_yy = electron_beam._moment_yy
            self.moment_ypyp = electron_beam._moment_ypyp

            x, xp, y, yp = electron_beam.get_sigmas_all()

            self.electron_beam_size_h = round(x, 9)
            self.electron_beam_size_v = round(y, 9)
            self.electron_beam_divergence_h = round(xp, 10)
            self.electron_beam_divergence_v = round(yp, 10)

        if self.type_of_initialization == 0: # zero
            self.moment_x = 0.0
            self.moment_y = 0.0
            self.moment_z = self.get_default_initial_z()
            self.moment_xp = 0.0
            self.moment_yp = 0.0
        elif self.type_of_initialization == 2: # sampled
            self.moment_x = numpy.random.normal(0.0, self.electron_beam_size_h)
            self.moment_y = numpy.random.normal(0.0, self.electron_beam_size_v)
            self.moment_z = self.get_default_initial_z()
            self.moment_xp = numpy.random.normal(0.0, self.electron_beam_divergence_h)
            self.moment_yp = numpy.random.normal(0.0, self.electron_beam_divergence_v)

        electron_beam._moment_x = self.moment_x
        electron_beam._moment_y = self.moment_y
        electron_beam._moment_z = self.moment_z
        electron_beam._moment_xp = self.moment_xp
        electron_beam._moment_yp = self.moment_yp

        print("\n", "Electron Trajectory Initialization:")
        print("X0: ", electron_beam._moment_x)
        print("Y0: ", electron_beam._moment_y)
        print("Z0: ", electron_beam._moment_z)
        print("XP0: ", electron_beam._moment_xp)
        print("YP0: ", electron_beam._moment_yp)
        print("E0: ", electron_beam._energy_in_GeV, "\n")

        return electron_beam