Ejemplo n.º 1
0
    def __init__(self,
                 name="Undefined",
                 electron_beam=SRWElectronBeam(),
                 magnetic_structure=SRWMagneticStructure()):
        LightSource.__init__(self, name, electron_beam, magnetic_structure)

        self.__source_wavefront_parameters = None
Ejemplo n.º 2
0
    def __init__(
            self,
            name="Undefined",
            filename="",  # comsyl result filename
            # electron_beam       = None,
            # magnetic_structure  = None,
            # undulator_coherent_mode_decomposition_1d = None,
            # dimension           = 2,
        mode_index=None,  # for wavefront retrieving
            normalize_with_eigenvalue=1,  # for wavefront retrieving (integer)
    ):

        electron_beam = EmptyLightSource(name=name)
        magnetic_structure = None  # Undulator(K_vertical=undulator_coherent_mode_decomposition_1d.K,
        # period_length=undulator_coherent_mode_decomposition_1d.undulator_period,
        # number_of_periods=undulator_coherent_mode_decomposition_1d.undulator_nperiods)

        LightSource.__init__(self,
                             name=name,
                             electron_beam=electron_beam,
                             magnetic_structure=magnetic_structure)

        self.filename = filename
        self.af_oasys = None
        self._dimension = 2
        self.dimension = 2
        self.mode_index = mode_index
        self.normalize_with_eigenvalue = normalize_with_eigenvalue
        self._set_support_text([
            # ("name"      ,           "to define ", "" ),
            ("dimension", "dimension ", ""),
            ("filename", "filename ", ""),
        ])
Ejemplo n.º 3
0
    def __init__(self,
                 name="Undefined",
                 electron_beam=ElectronBeam(),
                 magnetic_structure=MagneticStructure(),
                 additional_parameters=None):
        LightSource.__init__(self, name, electron_beam, magnetic_structure)

        self._shadow3_source = self._build_shadow3_source(additional_parameters)
Ejemplo n.º 4
0
 def set_light_source(self, light_source=LightSource()):
     if not (isinstance(light_source, LightSource)
             or isinstance(light_source, EmptyLightSource)):
         raise Exception("Input class must be of type: " +
                         LightSource.__name__ + " or " +
                         EmptyLightSource.__name__)
     else:
         self._light_source = light_source
Ejemplo n.º 5
0
    def __init__(self,
                 light_source=LightSource(),
                 beamline_elements_list=None):
        self._light_source = light_source
        if beamline_elements_list is None:
            self._beamline_elements_list = []
        else:
            self._beamline_elements_list = beamline_elements_list

        # support text containg name of variable, help text and unit. Will be stored in self._support_dictionary
        self._set_support_text([
            ("light_source", "Light Source", ""),
            ("beamline_elements_list", "Beamline Elements", ""),
        ])
    #

    for i,element in enumerate(mylist):
        element.to_json("tmp_%d.json"%i)

    for i,element in enumerate(mylist):
        print("loading element %d"%i)
        tmp = load_from_json_file("tmp_%d.json"%i)
        print("returned class: ",type(tmp))



    #
    # test Ligtsource
    #
    lightsource1 = LightSource("test_source",src1,src2)
    lightsource1.to_json("tmp_100.json")

    tmp = load_from_json_file("tmp_100.json")
    print("returned class: ",type(tmp))
    print("\n-----------Info on: \n",tmp.info(),"----------------\n\n")

    print( tmp.get_electron_beam().info() )
    print( tmp.get_magnetic_structure().info() )

    #
    # test full beamline
    #

    SCREEN1     = BeamlineElement(screen1,      coordinates=ElementCoordinates(p=11.0))
    LENS1       = BeamlineElement(lens1,        coordinates=ElementCoordinates(p=12.0))
Ejemplo n.º 7
0
from syned.beamline.optical_elements.mirrors.mirror import Mirror
from syned.beamline.optical_elements.gratings.grating import Grating

from syned.beamline.beamline import BeamlineElement, Beamline
from syned.beamline.element_coordinates import ElementCoordinates

if __name__ == "__main__":


    print("==================== LightSource: ==================")


    src1 = ElectronBeam.initialize_as_pencil_beam(energy_in_GeV=6.0,current=0.2)
    src2 = Undulator()
    src = LightSource("test",src1,src2)

    for key in src1.keys():
        print(key,src1.to_dictionary()[key])

    for key in src2.keys():
        print(key,src2.to_dictionary()[key])


    print(src1.keys())
    print(src2.keys())

    print(src1.info())
    print(src2.info())

Ejemplo n.º 8
0
                                       moment_xpxp=(3.8e-07/0.0078)**2,
                                       moment_yy=(0.0036*1e-2)**2,
                                       moment_ypyp=(3.8e-09/0.0036)**2,
                                       )

    syned_bending_magnet = BendingMagnet(radius=25.1772,magnetic_field=0.8,length=25.1772*0.001)

    emin = 5000.0                # Photon energy scan from energy (in eV)
    emax = 100000.0              # Photon energy scan to energy (in eV)
    ng_e = 51                    # Photon energy scan number of points
    ng_j = 20                    # Number of points in electron trajectory (per period) for internal calculation only
    flag_emittance = 1           # when sampling rays: Use emittance (0=No, 1=Yes)



    bm_input = InputSourceBM(
                 emin=emin,               # Photon energy scan from energy (in eV)
                 emax=emax,               # Photon energy scan to energy (in eV)
                 ng_e=ng_e,                    # Photon energy scan number of points
                 ng_j=ng_j,                    # Number of points in electron trajectory (per period) for internal calculation only
                 flag_emittance=flag_emittance,           # when sampling rays: Use emittance (0=No, 1=Yes)
                )

    ls = LightSource(syned_electron_beam,syned_bending_magnet)
    ls1 = LightSourceBM(syned_electron_beam,syned_bending_magnet,bm_input)
    # print(bm_input.info())
    print(ls1.info())

    ls1.to_json("tmp.json")