def __init__(self,
              name="Undefined",
              plane_mirror=MirrorPlane(L=0.4,
                                       AngleGrazing=numpy.deg2rad(2.5)),
              position_directives=PositioningDirectives()):
     super(WisePlaneMirror,
           self).__init__(name=name,
                          boundary_shape=Plane(),
                          wise_optical_element=OpticalElement(
                              Element=plane_mirror,
                              PositioningDirectives=position_directives,
                              Name=name,
                              IsSource=False))
예제 #2
0
    def __init__(self,
                 name                                 = "Undefined",
                 optical_element_displacement         = None,
                 orientation_of_reflection_plane      = Orientation.UP,
                 invert_tangent_component             = False,
                 d_spacing                            = 0.0,
                 psi_0r                               = 0.0,
                 psi_0i                               = 0.0,
                 psi_hr                               = 0.0,
                 psi_hi                               = 0.0,
                 psi_hbr                              = 0.0,
                 psi_hbi                              = 0.0,
                 asymmetry_angle                      = 0.0,
                 thickness                            = 0.0,
                 diffraction_geometry                 = DiffractionGeometry.BRAGG,
                 incident_angle                       = 0.0
                ):
        SRWOpticalElement.__init__(self, optical_element_displacement=optical_element_displacement)

        Crystal.__init__(self,
                         name,
                         surface_shape=Plane(),
                         boundary_shape=Rectangle(x_left=0.0,
                                                  x_right=0.0,
                                                  y_bottom=0.0,
                                                  y_top=0.0),
                         material="Unknown",
                         diffraction_geometry=diffraction_geometry,
                         asymmetry_angle = asymmetry_angle,
                         thickness = thickness
                        )

        self.orientation_of_reflection_plane                  = orientation_of_reflection_plane
        self.invert_tangent_component                         = invert_tangent_component

        self.d_spacing                            = d_spacing
        self.psi_0r                               = psi_0r
        self.psi_0i                               = psi_0i
        self.psi_hr                               = psi_hr
        self.psi_hi                               = psi_hi
        self.psi_hbr                              = psi_hbr
        self.psi_hbi                              = psi_hbi
        self.asymmetry_angle                      = asymmetry_angle
        self.thickness                            = thickness
        self.diffraction_geometry                 = diffraction_geometry
        self.grazing_angle                        = incident_angle

        if diffraction_geometry == DiffractionGeometry.LAUE: raise NotImplementedError("Laue Geometry is not yet supported")
예제 #3
0
 def get_shape(self):
     return Plane()


if __name__ == "__main__":



    src1 = ElectronBeam.initialize_as_pencil_beam(energy_in_GeV=6.0,current=0.2)
    src2 = Undulator()
    screen1 = Screen("screen1")
    lens1 = IdealLens(name="lens1",focal_y=6.0,focal_x=None,)
    filter1 = Filter("filter1","H2O",3.0e-6)
    slit1 = Slit(name="slit1",boundary_shape=Rectangle(-0.5e-3,0.5e-3,-2e-3,2e-3))
    stopper1 = BeamStopper(name="stopper1",boundary_shape=Rectangle(-0.5e-3,0.5e-3,-2e-3,2e-3))
    mirror1 = Mirror(name="mirror1",boundary_shape=Rectangle(-0.5e-3,0.5e-3,-2e-3,2e-3))
    crystal1 = Crystal(name="crystal1",surface_shape=Plane())
    grating1 = Grating(name="grating1",surface_shape=Conic())

    mylist = [src1,src2,screen1,lens1,filter1,slit1, stopper1, mirror1, grating1, crystal1]

    #
    # test individual 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))
예제 #5
0
        bending_magnet_magnetic_structure=BendingMagnet(radius=0.0,
                                                        magnetic_field=1.2,
                                                        length=0.0),
        bending_magnet_parameters=Shadow3BendingMagnetParameters(NPOINT=50000))

    slit = Shadow3Slit(name="first slit",
                       boundary_shape=Rectangle(x_left=-0.001,
                                                x_right=0.001,
                                                y_bottom=-0.005,
                                                y_top=0.005),
                       slit_parameters=Shadow3SlitParameters())

    slit_coordinates = ElementCoordinates(p=10.0, q=2.0)

    mirror = Shadow3Mirror(name="mirror 1",
                           surface_shape=Plane(),
                           boundary_shape=Rectangle(x_left=-0.05,
                                                    x_right=0.05,
                                                    y_bottom=-0.5,
                                                    y_top=0.5),
                           mirror_parameters=Shadow3PlaneMirrorParameters())

    mirror_coordinates = ElementCoordinates(p=2.0,
                                            q=5.0,
                                            angle_radial=88.0,
                                            angle_azimuthal=0.0)

    elements = RaytracingElements()
    elements.add_beamline_element(
        BeamlineElement(optical_element=slit, coordinates=slit_coordinates))
    elements.add_beamline_element(