コード例 #1
0
    def __init__(self,
                 size=(50., 50., 10.),
                 reflectivity=0.5,
                 *args,
                 **kwargs):
        Component.__init__(self, *args, **kwargs)
        self.size = size
        w, h, l = self.size
        __a_surf = Plane(shape=Rectangular(size=(w, h)),
                         reflectivity=reflectivity)
        __p_surf = Plane(shape=Rectangular(size=(w, h)))

        __u_surf = Plane(shape=Rectangular(size=(w, l)))
        __l_surf = Plane(shape=Rectangular(size=(w, l)))

        __lf_surf = Plane(shape=Rectangular(size=(l, h)))
        __rg_surf = Plane(shape=Rectangular(size=(l, h)))

        self.surflist["S1"] = (__a_surf, (0, 0, 0), (0, 0, 0))
        self.surflist["S2"] = (__p_surf, (0, 0, l), (0, 0, 0))

        self.surflist["S3"] = (__u_surf, (0, h / 2, l / 2.), (pi / 2, 0, 0))
        self.surflist["S4"] = (__l_surf, (0, -h / 2, l / 2.), (pi / 2, 0, 0))

        self.surflist["S5"] = (__lf_surf, (-w / 2, 0, l / 2.), (0, pi / 2, 0))
        self.surflist["S6"] = (__rg_surf, (w / 2, 0, l / 2.), (0, pi / 2, 0))
コード例 #2
0
    def __init__(self,
                 radius=50.,
                 thickness=10,
                 curvature_s1=1. / 200,
                 curvature_s2=1. / 200,
                 *args,
                 **kwargs):
        Component.__init__(self, *args, **kwargs)
        self.radius = radius
        self.thickness = thickness
        self.curvature_s1 = curvature_s1
        self.curvature_s2 = curvature_s2

        if self.curvature_s1 != 0.:
            __a_surf = Spherical(shape=Circular(radius=self.radius),
                                 curvature=self.curvature_s1)
        else:
            __a_surf = Plane(shape=Circular(radius=self.radius))

        if self.curvature_s2 != 0:
            __p_surf = Spherical(shape=Circular(radius=self.radius),
                                 curvature=self.curvature_s2)
        else:
            __p_surf = Plane(shape=Circular(radius=self.radius))

        self.surflist["S1"] = (__a_surf, (0, 0, -self.thickness / 2), (0, 0,
                                                                       0))
        self.surflist["S2"] = (__p_surf, (0, 0, self.thickness / 2), (0, 0, 0))

        if self.curvature_s1 != 0:
            r_a = 1. / self.curvature_s1
            s_a = absolute(r_a) - sqrt(r_a * r_a - self.radius * self.radius)
            if (r_a) < 0: s_a = -s_a
        else:
            s_a = 0.

        if self.curvature_s2 != 0:
            r_p = 1. / self.curvature_s2
            s_p = absolute(r_p) - sqrt(r_p * r_p - self.radius * self.radius)
            if (r_p) > 0: s_p = -s_p
        else:
            s_p = 0.

        #Ojo, falta verificar si la lente es fisicamente posible es decir th1>0
        th1 = self.thickness - s_a - s_p

        zp = float(-self.thickness / 2 + s_a + th1 / 2.)
        __c_surf_1 = Cylindrical(shape=Rectangular(size=(2. * self.radius,
                                                         th1)),
                                 curvature=1. / self.radius)

        __c_surf_2 = Cylindrical(shape=Rectangular(size=(2 * self.radius,
                                                         th1)),
                                 curvature=1. / self.radius)

        self.surflist["B1"] = (__c_surf_1, (-self.radius, 0, zp), (pi / 2., 0,
                                                                   pi / 2))

        self.surflist["B2"] = (__c_surf_2, (self.radius, 0, zp), (-pi / 2., 0,
                                                                  pi / 2))
コード例 #3
0
    def __init__(self,
                 radius=50.,
                 thickness=10,
                 reflectivity=0.5,
                 *args,
                 **kwargs):
        Component.__init__(self, *args, **kwargs)
        __a_surf = Plane(shape=Circular(radius=radius),
                         reflectivity=reflectivity)
        __p_surf = Plane(shape=Circular(radius=radius))

        self.surflist["S1"] = (__a_surf, (0, 0, 0), (0, 0, 0))
        self.surflist["S2"] = (__p_surf, (0, 0, thickness), (0, 0, 0))

        __c_surf_1 = Cylindrical(shape=Rectangular(size=(2. * radius,
                                                         thickness)),
                                 curvature=1. / radius)
        __c_surf_2 = Cylindrical(shape=Rectangular(size=(2 * radius,
                                                         thickness)),
                                 curvature=1. / radius)

        self.surflist["B1"] = (__c_surf_1, (-radius, 0, thickness / 2.),
                               (pi / 2., 0, pi / 2))
        self.surflist["B2"] = (__c_surf_2, (radius, 0, thickness / 2.),
                               (-pi / 2., 0, pi / 2))
コード例 #4
0
    def __init__(self,
                 size=(50.0, 50.0, 10.0),
                 reflectivity=0.0,
                 lpmm=600,
                 angle=0,
                 M=[1],
                 *args,
                 **kwargs):
        Component.__init__(self, *args, **kwargs)
        self.size = size
        w, h, l = self.size
        lpmmx = lpmm * cos(angle)
        lpmmy = lpmm * sin(angle)
        phf = poly2d([0, 2 * pi * lpmmx, 2 * pi * lpmmy])
        __a_surf = RPPMask(shape=Rectangular(size=(w, h)),
                           phm=phf,
                           reflectivity=reflectivity,
                           M=M)
        __p_surf = Plane(shape=Rectangular(size=(w, h)))

        __u_surf = Plane(shape=Rectangular(size=(w, l)))
        __l_surf = Plane(shape=Rectangular(size=(w, l)))

        __lf_surf = Plane(shape=Rectangular(size=(l, h)))
        __rg_surf = Plane(shape=Rectangular(size=(l, h)))

        self.surflist["S1"] = (__a_surf, (0, 0, 0), (0, 0, 0))
        self.surflist["S2"] = (__p_surf, (0, 0, l), (0, 0, 0))

        self.surflist["S3"] = (__u_surf, (0, h / 2, l / 2.0), (pi / 2, 0, 0))
        self.surflist["S4"] = (__l_surf, (0, -h / 2, l / 2.0), (pi / 2, 0, 0))

        self.surflist["S5"] = (__lf_surf, (-w / 2, 0, l / 2.0), (0, pi / 2, 0))
        self.surflist["S6"] = (__rg_surf, (w / 2, 0, l / 2.0), (0, pi / 2, 0))
コード例 #5
0
ファイル: diffraction.py プロジェクト: ramezquitao/pyoptools
    def __init__(self, size=(50., 50., 10.), reflectivity=0., lpmm=600, angle=0, M=[1], *args, **kwargs):
        Component.__init__(self, *args, **kwargs)
        self.size = size
        w, h, l = self.size
        lpmmx = lpmm * cos(angle)
        lpmmy = lpmm * sin(angle)
        phf = poly2d([0, 2 * pi * lpmmx, 2 * pi * lpmmy])
        __a_surf = RPPMask(shape=Rectangular(size=(w, h)), phm=phf,
                           reflectivity=reflectivity, M=M)
        __p_surf = Plane(shape=Rectangular(size=(w, h)))

        __u_surf = Plane(shape=Rectangular(size=(w, l)))
        __l_surf = Plane(shape=Rectangular(size=(w, l)))

        __lf_surf = Plane(shape=Rectangular(size=(l, h)))
        __rg_surf = Plane(shape=Rectangular(size=(l, h)))

        self.surflist["S1"] = (__a_surf, (0, 0, 0), (0, 0, 0))
        self.surflist["S2"] = (__p_surf, (0, 0, l), (0, 0, 0))

        self.surflist["S3"] = (__u_surf, (0, h / 2, l / 2.), (pi / 2, 0, 0))
        self.surflist["S4"] = (__l_surf, (0, -h / 2, l / 2.), (pi / 2, 0, 0))

        self.surflist["S5"] = (__lf_surf, (-w / 2, 0, l / 2.), (0, pi / 2, 0))
        self.surflist["S6"] = (__rg_surf, (w / 2, 0, l / 2.), (0, pi / 2, 0))
コード例 #6
0
ファイル: ideallens.py プロジェクト: cihologramas/pyoptools
def IdealTLens(
    shape=Rectangular(size=(50, 50)), ap_shape=Rectangular(size=(40, 40)), f=100, d=20
):
    """Function to define an ideal thick lens."""
    S1 = IdealPPlanes(shape=shape, f=f, d=d)
    S2 = Aperture(shape=Rectangular(size=(50, 50)), ap_shape=ap_shape)
    S3 = Aperture(shape=Rectangular(size=(50, 50)), ap_shape=ap_shape)
    A1 = Component(
        surflist=[
            (S2, (0, 0, 0), (0, 0, 0)),
        ]
    )
    A2 = Component(
        surflist=[
            (S3, (0, 0, 0), (0, 0, 0)),
        ]
    )
    L1 = Component(
        surflist=[
            (S1, (0, 0, 0), (0, 0, 0)),
        ]
    )
    Si = System(
        complist=[
            (L1, (0, 0, 0), (0, 0, 0)),
            (A1, (0, 0, -1.001 * d / 2), (0, 0, 0)),
            (A2, (0, 0, 1.001 * d / 2), (0, 0, 0)),
        ],
        n=1,
    )

    return Si
コード例 #7
0
    def __init__(self,
                 size=(20, 20),
                 thickness=10,
                 curvature_s1=1. / 200,
                 curvature_s2=1. / 200,
                 *args,
                 **kwargs):
        Component.__init__(self, *args, **kwargs)
        self.size = size
        w, h = self.size
        self.thickness = thickness
        self.curvature_s1 = curvature_s1
        self.curvature_s2 = curvature_s2

        if self.curvature_s1 != 0.:
            __a_surf = Cylindrical(shape=Rectangular(size=(w, h)),
                                   curvature=self.curvature_s1)
        else:
            __a_surf = Plane(shape=Rectangular(size=(w, h)))

        if self.curvature_s2 != 0:
            __p_surf = Cylindrical(shape=Rectangular(size=(w, h)),
                                   curvature=self.curvature_s2)
        else:
            __p_surf = Plane(shape=Rectangular(size=(w, h)))

        self.surflist["S1"] = (__a_surf, (0, 0, -self.thickness / 2), (0, 0,
                                                                       0))
        self.surflist["S2"] = (__p_surf, (0, 0, self.thickness / 2), (0, 0, 0))
コード例 #8
0
ファイル: prism.py プロジェクト: uamhforever/pyoptools
    def __init__(self, s, l, *args, **kwargs):
        #s alto o profundidad del prisma
        #l Longitud del lado mas largo del prisma

        #La referencia del prisma de dove esta en el centro del prisma

        Component.__init__(self, *args, **kwargs)

        d = 1.4142135623730951 * s

        #Diagonales del prisma

        s1 = Plane(shape=Rectangular(size=(d, s)))
        s2 = Plane(shape=Rectangular(size=(d, s)))

        #Lado largo del prisma
        s3 = Plane(shape=Rectangular(size=(l, s)))
        #lado corto del prisma
        s4 = Plane(shape=Rectangular(size=(l - 2 * s, s)))

        sp1 = (l - s) / 2.
        self.surflist["S1"] = (s1, (-sp1, 0, 0), (0, -pi / 4, 0))
        self.surflist["S2"] = (s2, (sp1, 0, 0), (0, pi / 4, 0))
        self.surflist["S3"] = (s3, (0, 0, -s / 2.), (0, 0, 0))
        self.surflist["S4"] = (s4, (0, 0, s / 2.), (0, 0, 0))
コード例 #9
0
ファイル: prism.py プロジェクト: adamLange/pyoptools
    def __init__(self, width=50, height=10., reflectivity=0, *args, **kwargs):
        
        Component.__init__(self,*args, **kwargs)

        self.width=width
        self.height=height
        self.reflectivity=reflectivity
        
        
        __a_face= Plane (shape=Rectangular(size=(self.width,self.height)))
        __b_face= Plane (shape=Rectangular(size=(self.width,self.height)))

        h=sqrt(2.)*self.width

        __h_face= Plane (shape=Rectangular(size=(h,self.height)),reflectivity=self.reflectivity)
        
        w2=self.width/2.
        __e1=Plane (shape=Triangular(((-w2,w2),(-w2,-w2),(w2,-w2))))
        __e2=Plane (shape=Triangular(((-w2,w2),(-w2,-w2),(w2,-w2))))

        
        
        self.surflist["S1"]=(__a_face,(0,0,-self.width/2),(0,0,0))
        self.surflist["S2"]=(__b_face,(self.width/2,0,0),(0,pi/2,0))
        self.surflist["S3"]=(__h_face,(0,0,0),(0,-pi/4,0))
        self.surflist["S4"]=(__e1,(0,self.height/2,0),(pi/2,-pi/2,0) )
        self.surflist["S5"]=(__e2,(0,-self.height/2,0),(pi/2,-pi/2,0) )
コード例 #10
0
ファイル: prism.py プロジェクト: uamhforever/pyoptools
    def __init__(self, width=50, height=10., reflectivity=0, *args, **kwargs):

        Component.__init__(self, *args, **kwargs)

        self.width = width
        self.height = height
        self.reflectivity = reflectivity

        __a_face = Plane(shape=Rectangular(size=(self.width, self.height)))
        __b_face = Plane(shape=Rectangular(size=(self.width, self.height)))

        h = sqrt(2.) * self.width

        __h_face = Plane(shape=Rectangular(size=(h, self.height)),
                         reflectivity=self.reflectivity)

        w2 = self.width / 2.
        __e1 = Plane(shape=Triangular(((-w2, w2), (-w2, -w2), (w2, -w2))))
        __e2 = Plane(shape=Triangular(((-w2, w2), (-w2, -w2), (w2, -w2))))

        self.surflist["S1"] = (__a_face, (0, 0, -self.width / 2), (0, 0, 0))
        self.surflist["S2"] = (__b_face, (self.width / 2, 0, 0), (0, pi / 2,
                                                                  0))
        self.surflist["S3"] = (__h_face, (0, 0, 0), (0, -pi / 4, 0))
        self.surflist["S4"] = (__e1, (0, self.height / 2, 0), (pi / 2, -pi / 2,
                                                               0))
        self.surflist["S5"] = (__e2, (0, -self.height / 2, 0), (pi / 2,
                                                                -pi / 2, 0))
コード例 #11
0
ファイル: powell_lens.py プロジェクト: wcamilo96/pyoptools
    def __init__(self,
                 radius=4.445,
                 thickness=7.62,
                 K=-4.302,
                 R=3.00,
                 *args,
                 **kwargs):
        Component.__init__(self, *args, **kwargs)
        self.radius = radius
        self.thickness = thickness
        self.K = K
        self.R = R

        __a_surf = Aspherical(shape=Circular(radius=self.radius),
                              Ax=0,
                              Ay=self.R,
                              Kx=-1,
                              Ky=self.K,
                              poly=poly2d((0, 0)))

        self.surflist["S1"] = (__a_surf, (0, 0, 0), (0, 0, 0))

        __p_surf = Plane(shape=Circular(radius=(self.radius)))

        self.surflist["B1"] = (__p_surf, (0, 0, self.thickness), (0, 0, 0))
コード例 #12
0
ファイル: prism.py プロジェクト: ramezquitao/pyoptools
    def __init__(self, s,l, *args, **kwargs):
        #s alto o profundidad del prisma
        #l Longitud del lado mas largo del prisma

        #La referencia del prisma de dove esta en el centro del prisma

        Component.__init__(self,*args, **kwargs)

        d=1.4142135623730951*s

        #Diagonales del prisma

        s1= Plane(shape=Rectangular(size=(d,s)))
        s2= Plane(shape=Rectangular(size=(d,s)))

        #Lado largo del prisma
        s3= Plane(shape=Rectangular(size=(l,s)))
        #lado corto del prisma
        s4= Plane(shape=Rectangular(size=(l-2*s,s)))


        sp1=(l-s)/2.
        self.surflist["S1"]=(s1, (-sp1, 0, 0), (0, -pi/4, 0))
        self.surflist["S2"]=(s2, ( sp1, 0, 0), (0,  pi/4, 0))
        self.surflist["S3"]=(s3, (0, 0, -s/2.), (0, 0, 0))
        self.surflist["S4"]=(s4, (0, 0,  s/2.), (0, 0, 0))
コード例 #13
0
ファイル: library.py プロジェクト: hstarmans/opticaldesign
 def __init__(self, sides=3, height=3, inner_radius=10, **traits):
     if sides < 3:
         raise Exception("Polygon should have at least 3 sides.")
     side_length = 2 * inner_radius * np.tan(np.pi / sides)
     Component.__init__(self, **traits)
     # create a side base shape
     side = Plane(shape=Rectangular(size=(side_length, height)))
     for i in range(sides):
         angle = 2 * np.pi / sides * i
         center = inner_radius * np.array([np.cos(angle), np.sin(angle)])
         self.surflist[f"S{i}"] = (side, (center[0], center[1], 0),
                                   (np.pi / 2, 0, angle + np.pi / 2))
     # create a top/bottom base shape
     triangle = Plane(shape=Triangular(((0, 0), (-inner_radius,
                                                 -side_length / 2),
                                        (-inner_radius, side_length / 2))))
     for i in ['bottom', 'height']:
         surface = len(self.surflist)
         if i == 'bottom':
             offset = -height / 2
         else:
             offset = height / 2
         for i in range(sides):
             angle = 2 * np.pi / sides * i
             if sides % 2:
                 offset = 2 * np.pi / (sides * 2)
             else:
                 offset = 0
             self.surflist[f"S{i+surface}"] = (triangle, (0, 0, offset),
                                               (0, 0, angle + offset))
コード例 #14
0
 def __init__(self, size=(10, 10), transparent=True, *args, **kwargs):
     Component.__init__(self, *args, **kwargs)
     self.__d_surf = Plane(
         shape=Rectangular(size=size)
     )  #ArrayDetector (size=self.size, transparent=self.transparent)
     self.size = size
     self.surflist["S1"] = (self.__d_surf, (0, 0, 0), (0, 0, 0))
     self.material = 1.
コード例 #15
0
ファイル: spherical_lens.py プロジェクト: adamLange/pyoptools
    def __init__(self,radius= 50., thickness=10, curvature_s1=1./200,curvature_s2=1./200,*args,**kwargs):
        Component.__init__(self,*args,**kwargs)
        self.radius=radius
        self.thickness=thickness
        self.curvature_s1=curvature_s1
        self.curvature_s2=curvature_s2
        
        if self.curvature_s1!=0.:
            __a_surf= Spherical (shape=Circular(radius= self.radius),
                                      curvature=self.curvature_s1)
        else:
            __a_surf= Plane(shape=Circular(radius= self.radius))
     
        if self.curvature_s2!=0:
            __p_surf= Spherical (shape=Circular(radius= self.radius),
                                      curvature=self.curvature_s2)
        else:
            __p_surf= Plane(shape=Circular(radius= self.radius))
        
        self.surflist["S1"]=(__a_surf,(0,0,-self.thickness/2),(0,0,0))
        self.surflist["S2"]=(__p_surf,(0,0,self.thickness/2 ),(0,0,0))

        if self.curvature_s1!=0:
            r_a=1./self.curvature_s1
            s_a=  absolute(r_a)-sqrt(r_a*r_a-self.radius*self.radius)
            if(r_a)<0: s_a=-s_a
        else:
            s_a=0.
            
        
        if self.curvature_s2!=0:
            r_p=1./self.curvature_s2
            s_p=  absolute(r_p)-sqrt(r_p*r_p-self.radius*self.radius)
            if(r_p)>0: s_p=-s_p
        else:
            s_p=0.

        
        


        #Ojo, falta verificar si la lente es fisicamente posible es decir th1>0
        th1=self.thickness-s_a-s_p


        zp=float(-self.thickness/2+s_a+th1/2.)
        __c_surf_1=Cylindrical(shape=Rectangular(size=(2.*self.radius,th1)),
                               curvature=1./self.radius)

        __c_surf_2=Cylindrical(shape=Rectangular(size=(2*self.radius,th1)),
                               curvature=1./self.radius)

        self.surflist["B1"]=(__c_surf_1,(-self.radius,0,zp),
                              (pi/2.,0,pi/2))

        self.surflist["B2"]=(__c_surf_2,(self.radius,0,zp),
                              (-pi/2.,0,pi/2))
コード例 #16
0
ファイル: ideallens.py プロジェクト: wcamilo96/pyoptools
def IdealTLens(shape=Rectangular(size=(50,50)), ap_shape=Rectangular(size=(40,40)), f=100,d=20):
    """Funcion envoltorio que representa una lente ideal gruesa
    """
    S1=IdealPPlanes(shape=shape, f=f,d=d)
    S2=Aperture(shape=Rectangular(size=(50,50)),ap_shape=ap_shape)
    S3=Aperture(shape=Rectangular(size=(50,50)),ap_shape=ap_shape)
    A1=Component(surflist=[(S2,(0,0,0),(0,0,0)),])
    A2=Component(surflist=[(S3,(0,0,0),(0,0,0)),])
    L1=Component(surflist=[(S1,(0,0,0),(0,0,0)),])
    Si=System(complist=[(L1,(0,0,0),(0,0,0)),
                        (A1,(0,0,-1.001*d/2),(0,0,0)),
                        (A2,(0,0, 1.001*d/2),(0,0,0)),],n=1)

    return Si
コード例 #17
0
ファイル: powell_lens.py プロジェクト: ramezquitao/pyoptools
    def __init__(self, radius=4.445, thickness=7.62, K=-4.302, R=3.00, *args, **kwargs):
        Component.__init__(self, *args, **kwargs)
        self.radius = radius
        self.thickness = thickness
        self.K = K
        self.R = R

        __a_surf = Aspherical(shape=Circular(radius=self.radius), Ax=0, Ay=self.R, Kx=-1, Ky=self.K,
                              poly=poly2d((0, 0)))

        self.surflist["S1"] = (__a_surf, (0, 0, 0), (0, 0, 0))

        __p_surf = Plane(shape=Circular(radius=(self.radius)))

        self.surflist["B1"] = (__p_surf, (0, 0, self.thickness), (0, 0, 0))
コード例 #18
0
def evaluate_geometry():

    lightsources = []
    components = []
    apertures = []
    for obj_key in bpy.data.objects.keys():
        obj = bpy.data.objects[obj_key]
        if not 'source' in obj.data.name:
            if 'n' in obj.keys():
                # for this to be true, n must be define as custom property in Blender "Object Properties" <- NOT Mesh Properties
                mw = obj.matrix_world

                mesh = obj.data
                mesh.calc_loop_triangles()
                loop_triangles = mesh.loop_triangles

                S_list = []
                for tri in loop_triangles:
                    tri_center = np.array(mw @ tri.center.to_3d())
                    # get global vertice coordinate-vectors from mesh by their index
                    tri_vertices = [
                        mw @ mesh.vertices[index].co for index in tri.vertices
                    ]
                    # convert to arrays
                    vertices = [
                        np.array(vertice.to_3d()) for vertice in tri_vertices
                    ]

                    S = surfaces.Plane(reflectivity=0,
                                       shape=shapes.Triangular(
                                           (vertices[0], vertices[1],
                                            vertices[2])))
                    S_list.append(S)
                C = Component(surflist=S_list, material=np.float(obj['n']))
                components.append(C)
            else:
                print(
                    obj.name,
                    'not included in ray-trace; no refractive index defined.')
        else:
            mw = obj.matrix_world
            mesh = obj.data
            mesh.calc_loop_triangles()
            loop_triangles = mesh.loop_triangles

            for tri in loop_triangles:
                tri_vertices = [
                    mw @ mesh.vertices[index].co for index in tri.vertices
                ]
                # convert to arrays
                vertices = [
                    np.array(vertice.to_3d()) for vertice in tri_vertices
                ]
                apertures.append(vertices)
    try:
        Sys = System(complist=components, n=bpy.data.worlds['World']['n'])
    except KeyError:
        Sys = System(complist=components, n=1.0)
    print('Geometries evaluated.')
    return Sys, apertures
コード例 #19
0
ファイル: mirror.py プロジェクト: ramezquitao/pyoptools
    def __init__(self, radius=50., thickness=10, reflectivity=0.5, *args, **kwargs):
        Component.__init__(self, *args, **kwargs)
        __a_surf = Plane(shape=Circular(radius=radius), reflectivity=reflectivity)
        __p_surf = Plane(shape=Circular(radius=radius))

        self.surflist["S1"] = (__a_surf, (0, 0, 0), (0, 0, 0))
        self.surflist["S2"] = (__p_surf, (0, 0, thickness), (0, 0, 0))

        __c_surf_1 = Cylindrical(shape=Rectangular(size=(2. * radius, thickness)),
                                 curvature=1. / radius)
        __c_surf_2 = Cylindrical(shape=Rectangular(size=(2 * radius, thickness)),
                                 curvature=1. / radius)

        self.surflist["B1"] = (__c_surf_1, (-radius, 0, thickness / 2.),
                               (pi / 2., 0, pi / 2))
        self.surflist["B2"] = (__c_surf_2, (radius, 0, thickness / 2.),
                               (-pi / 2., 0, pi / 2))
コード例 #20
0
ファイル: prism.py プロジェクト: uamhforever/pyoptools
    def __init__(self, s, *args, **kwargs):

        Component.__init__(self, *args, **kwargs)

        s1 = Plane(shape=Rectangular(size=(s, s)))
        s2 = Plane(shape=Rectangular(size=(s, s)))
        d = s / cos(radians(22.5))
        s3 = Plane(shape=Rectangular(size=(d, s)), reflectivity=1)
        s4 = Plane(shape=Rectangular(size=(d, s)), reflectivity=1)
        d1 = d * sin(radians(22.5) / 2.)
        s5 = Plane(shape=Rectangular(size=(2 * sqrt(2) * d1, s)))

        self.surflist["S1"] = (s1, (0, 0, -s / 2.), (0, 0, 0))
        self.surflist["S2"] = (s2, (s / 2., 0, 0), (0, pi / 2, 0))
        self.surflist["S3"] = (s3, (0, 0, s / 2. + d1), (0, pi / 8, 0))
        self.surflist["S4"] = (s4, (-s / 2. - d1, 0, 0), (0, 3 * pi / 8, 0))
        self.surflist["S5"] = (s5, (-s / 2. - d1, 0, s / 2. + d1), (0, -pi / 4,
                                                                    0))
コード例 #21
0
def IdealLens(shape=Rectangular(size=(50,50)), f=100):
    """Function to create a component that behaves as an ideal lens

    :param shape: Shape of the lens
    :type shape: :class:`~pyoptools.raytrace.shape.shape.Shape`
    """
    S1=IdealSurface(shape=shape, f=f)
    L1=Component(surflist=[(S1,(0,0,0),(0,0,0))])
    return L1
コード例 #22
0
ファイル: cube.py プロジェクト: ramezquitao/pyoptools
 def __init__(self, size=(10,10,10), **traits):
     Component.__init__(self,**traits)
     self.size=size
     w, h, l=self.size
     __a_surf = Plane(shape=Rectangular(size=(w, h)))
     __p_surf = Plane(shape=Rectangular(size=(w, h)))
     
     __u_surf = Plane(shape=Rectangular(size=(w, l)))
     __l_surf = Plane(shape=Rectangular(size=(w, l)))
     
     __lf_surf = Plane(shape=Rectangular(size=(l, h)))
     __rg_surf = Plane(shape=Rectangular(size=(l, h)))
     
     self.surflist["S1"]=(__a_surf,(0,0,-l/2),(0,0,0))
     self.surflist["S2"]=(__p_surf,(0,0,l/2),(0,0,0))
     
     self.surflist["S3"]=(__u_surf,(0,h/2,0),(pi/2,0,0))
     self.surflist["S4"]=(__l_surf,(0,-h/2,0),(pi/2,0,0))
     
     self.surflist["S5"]=(__lf_surf,(-w/2,0,0),(0,pi/2,0))
     self.surflist["S6"]=(__rg_surf,(w/2,0,0),(0,pi/2,0))
コード例 #23
0
ファイル: mirror.py プロジェクト: ramezquitao/pyoptools
    def __init__(self, size=(50., 50., 10.), reflectivity=0.5, *args, **kwargs):
        Component.__init__(self, *args, **kwargs)
        self.size = size
        w, h, l = self.size
        __a_surf = Plane(shape=Rectangular(size=(w, h)), reflectivity=reflectivity)
        __p_surf = Plane(shape=Rectangular(size=(w, h)))

        __u_surf = Plane(shape=Rectangular(size=(w, l)))
        __l_surf = Plane(shape=Rectangular(size=(w, l)))

        __lf_surf = Plane(shape=Rectangular(size=(l, h)))
        __rg_surf = Plane(shape=Rectangular(size=(l, h)))

        self.surflist["S1"] = (__a_surf, (0, 0, 0), (0, 0, 0))
        self.surflist["S2"] = (__p_surf, (0, 0, l), (0, 0, 0))

        self.surflist["S3"] = (__u_surf, (0, h / 2, l / 2.), (pi / 2, 0, 0))
        self.surflist["S4"] = (__l_surf, (0, -h / 2, l / 2.), (pi / 2, 0, 0))

        self.surflist["S5"] = (__lf_surf, (-w / 2, 0, l / 2.), (0, pi / 2, 0))
        self.surflist["S6"] = (__rg_surf, (w / 2, 0, l / 2.), (0, pi / 2, 0))
コード例 #24
0
    def __init__(self, size=(10, 10, 10), **traits):
        Component.__init__(self, **traits)
        self.size = size
        w, h, l = self.size
        __a_surf = Plane(shape=Rectangular(size=(w, h)))
        __p_surf = Plane(shape=Rectangular(size=(w, h)))

        __u_surf = Plane(shape=Rectangular(size=(w, l)))
        __l_surf = Plane(shape=Rectangular(size=(w, l)))

        __lf_surf = Plane(shape=Rectangular(size=(l, h)))
        __rg_surf = Plane(shape=Rectangular(size=(l, h)))

        self.surflist["S1"] = (__a_surf, (0, 0, -l / 2), (0, 0, 0))
        self.surflist["S2"] = (__p_surf, (0, 0, l / 2), (0, 0, 0))

        self.surflist["S3"] = (__u_surf, (0, h / 2, 0), (pi / 2, 0, 0))
        self.surflist["S4"] = (__l_surf, (0, -h / 2, 0), (pi / 2, 0, 0))

        self.surflist["S5"] = (__lf_surf, (-w / 2, 0, 0), (0, pi / 2, 0))
        self.surflist["S6"] = (__rg_surf, (w / 2, 0, 0), (0, pi / 2, 0))
コード例 #25
0
    def __init__(self, size=(20, 20), thickness=10, curvature_s1=1. / 200, curvature_s2=1. / 200, *args, **kwargs):
        Component.__init__(self, *args, **kwargs)
        self.size = size
        w, h = self.size
        self.thickness = thickness
        self.curvature_s1 = curvature_s1
        self.curvature_s2 = curvature_s2

        if self.curvature_s1 != 0.:
            __a_surf = Cylindrical(shape=Rectangular(size=(w, h)),
                                   curvature=self.curvature_s1)
        else:
            __a_surf = Plane(shape=Rectangular(size=(w, h)))

        if self.curvature_s2 != 0:
            __p_surf = Cylindrical(shape=Rectangular(size=(w, h)),
                                   curvature=self.curvature_s2)
        else:
            __p_surf = Plane(shape=Rectangular(size=(w, h)))

        self.surflist["S1"] = (__a_surf, (0, 0, -self.thickness / 2), (0, 0, 0))
        self.surflist["S2"] = (__p_surf, (0, 0, self.thickness / 2), (0, 0, 0))
コード例 #26
0
ファイル: prism.py プロジェクト: ramezquitao/pyoptools
    def __init__(self, s, *args, **kwargs):
        """
        :param s: alto y base de las entradas del pentaprisma
        :param args:
        :param kwargs:
        :return:
        """

        Component.__init__(self,*args, **kwargs)

        s1 = Plane(shape=Rectangular(size=(s,s)))
        s2 = Plane(shape=Rectangular(size=(s,s)))
        d=s/cos(radians(22.5))
        s3 = Plane(shape=Rectangular(size=(d,s)),reflectivity=1)
        s4 = Plane(shape=Rectangular(size=(d,s)),reflectivity=1)
        d1=d*sin(radians(22.5)/2.)
        s5 = Plane(shape=Rectangular(size=(2*sqrt(2)*d1,s)))


        self.surflist["S1"] = (s1,(0,0,-s/2.),(0,0,0))
        self.surflist["S2"] = (s2,(s/2.,0,0),(0,pi/2,0))
        self.surflist["S3"] = (s3,(0,0,s/2.+d1),(0,pi/8,0))
        self.surflist["S4"] = (s4,(-s/2.-d1,0,0),(0,3*pi/8,0))
        self.surflist["S5"] = (s5,(-s/2.-d1,0,s/2.+d1),(0,-pi/4,0))
コード例 #27
0
ファイル: stop.py プロジェクト: uamhforever/pyoptools
 def __init__(self, shape=None, ap_shape=None, **traits):
     Component.__init__(self, **traits)
     #self.shape=shape
     #self.ap_shape=ap_shape
     face = Aperture(shape=shape, ap_shape=ap_shape)
     self.surflist["S1"] = (face, (0, 0, 0), (0, 0, 0))
コード例 #28
0
ファイル: ideallens.py プロジェクト: wcamilo96/pyoptools
def IdealLens(shape=Rectangular(size=(50,50)), f=100):
    """Funcion envoltorio que representa una lente ideal
    """
    S1=IdealSurface(shape=shape, f=f)
    L1=Component(surflist=[(S1,(0,0,0),(0,0,0))])
    return L1
コード例 #29
0
ファイル: stop.py プロジェクト: adamLange/pyoptools
 def __init__(self,shape=None,ap_shape=None,**traits):
     Component.__init__(self,**traits)
     #self.shape=shape
     #self.ap_shape=ap_shape
     face= Aperture (shape=shape,  ap_shape=ap_shape)
     self.surflist["S1"]=(face,(0,0,0),(0,0,0))
コード例 #30
0
ファイル: ccd.py プロジェクト: adamLange/pyoptools
 def __init__(self, size=(10,10), transparent=True,*args,**kwargs):
     Component.__init__(self, *args, **kwargs)
     self.__d_surf= Plane(shape=Rectangular(size=size))#ArrayDetector (size=self.size, transparent=self.transparent)
     self.size=size
     self.surflist["S1"]=(self.__d_surf,(0,0,0),(0,0,0))
     self.material=1.
コード例 #31
0
def get_optical_path_ep(opsys, opaxis, raylist, stop=None, r=None):
    """Returns the optical path traveled by a ray up to the exit pupil
    
    The optical path is measured from the ray origin until it crosses the 
    exit pupil of the system.
    If a stop (aperture) is not given, the measurement is made up to the primary
    principal plane.
    
    
    Arguments:

    
    opsys
        Optical system under analisis
        
    opaxis
        Ray indicating the optical axis the origin of the optical axis, must be
        the position of the object used in the image formation. This is needed
        to be able to calculate the radius of the reference sphere.
    
    raylist
        List of rays that will be used to sample the optical path
    
    stop
        Aperture stop of the system. It must belong to opsys. In not given it
        will be assumed that the exit pupil is at the primary principal plane.
    r
        If None, measure up to the exit pupil plane. If given, use a reference 
        sphere with a vertex coinciding with the optical vertex.

    Return Value (hcl,opl,pc)
    
    hcl 
        List containing the coordinates of the hits in the pupil coordinate 
        system.
    
    opl
        list containing the optical paths measured
    
    pc
        intersection point between the optical axis, and the pupil plane.
        
    hcl[i] corresponds to opl[i]
    
    Note: This method only works if the optical axis coincides with the Z axis. 
    This must be corrected.
    """
    if stop != None:
        enp, exp = pupil_location(opsys, stop, opaxis)
    else:
        exp = find_ppp(opsys, opaxis)

    #Reset the system
    opsys.clear_ray_list()
    opsys.reset()

    # Propagate the rays
    #print "***", raylist
    opsys.ray_add(raylist)
    opsys.propagate()
    #pf=PlotFrame(opsys=opsys)
    rl = []
    l = []

    # Get the optical path up to the final element in the system
    for i in raylist:
        a = i.get_final_rays()
        if a[0].intensity != 0:
            # Reverse the rays to calculate the optical path from the final element
            #to the exit pupil

            nray = a[0].reverse()
            rl.append(nray)
            #TODO: This should not be done using the label
            nray.label = str(a[0].optical_path_parent())

    # Create a dummy system to calculate the wavefront at the exit pupil
    if r == None:
        #TODO: This ccd should be infinitely big. Have to see how this can be done
        ccd = CCD(size=(1000, 1000))
    else:
        ccds = Spherical(shape=Circular(radius=0.9 * r), curvature=1. / r)
        ccd = Component(surflist=[
            (ccds, (0, 0, 0), (0, 0, 0)),
        ])
    #print rl

    dummy = System(complist=[
        (ccd, exp, (0, 0, 0)),
    ], n=1.)

    #Calculate the optical path from the final element to the exit pupil plane
    dummy.ray_add(rl)
    dummy.propagate()
    #PlotFrame(opsys=dummy)
    hcl = []
    opl = []
    for ip, r in ccd.hit_list:
        #print ip
        x, y, z = ip
        #TODO: This should not be done using the label
        d = float(r.label) - r.optical_path()
        hcl.append((x, y, z))
        opl.append(d)
    return (hcl, opl, exp)
コード例 #32
0
    def __init__(
            self,
            outer_diameter=8.0,
            thickness=3.0,
            material=1.5,
            origin="center",
            s1={
                "diameter": 6.0,
                "roc": 3.0,
                "k": -1.5,
                "polycoefficents": (0, 0, 0, 0, 3e-3, 0, -10e-6),
                "max_thickness": None,
            },
            s2=None,
            *args,
            **kwargs):
        Component.__init__(self, *args, **kwargs)

        self.material = material
        self.thickness = thickness
        self.outer_diameter = outer_diameter

        # Fill defaults and put surface definitions into namespaces
        if not "max_thickness" in s1:
            s1["max_thickness"] = None
        if s2 is not None and not "max_thickness" in s2:
            s2["max_thickness"] = None

        s1_defn = SimpleNamespace(**s1)
        if s2 is not None:
            s2_defn = SimpleNamespace(**s2)
        else:
            s2_defn = None
        self.s1_defn, self.s2_defn = (s1_defn, s2_defn)

        # Auto select outer diameter if None
        if self.outer_diameter is None:
            candidates = [s1_defn.diameter]
            if s2 is not None:
                candidates.append(s2_defn.diameter)
            self.outer_diameter = max(candidates)

        # Start side thickness calculation, surfaces will be subtracted from this
        side_thickness = thickness

        # First surface
        s1_surf = Aspherical(
            shape=Circular(radius=0.5 * s1_defn.diameter),
            Ax=1.0 / s1_defn.roc,
            Ay=1.0 / s1_defn.roc,
            Kx=s1_defn.k,
            Ky=s1_defn.k,
            poly=poly1Drot(s1_defn.polycoefficents),
        )
        if s1_defn.max_thickness is None:
            s1_defn.max_thickness = s1_surf.topo(s1_defn.diameter / 2.0, 0)
        side_thickness -= s1_defn.max_thickness
        self.surflist.append((s1_surf, (0, 0, 0), (0, 0, pi / 2)))

        # Second surface
        if s2_defn is None:
            s2_surf = Plane(shape=Circular(radius=0.5 * self.outer_diameter))
        else:
            s2_surf = Aspherical(
                shape=Circular(radius=0.5 * s2_defn.diameter),
                Ax=1.0 / s2_defn.roc,
                Ay=1.0 / s2_defn.roc,
                Kx=s2_defn.k,
                Ky=s2_defn.k,
                poly=poly1Drot(s2_defn.polycoefficents),
            )
            if s2_defn.max_thickness is None:
                s2_defn.max_thickness = s2_surf.topo(s2_defn.diameter / 2.0, 0)
            side_thickness -= s2_defn.max_thickness
        self.surflist.append((s2_surf, (0, 0, thickness), (0, pi, pi / 2)))

        # Outer edge
        if side_thickness > 0:
            outer_edge = Cylinder(radius=self.outer_diameter / 2,
                                  length=side_thickness)
            self.surflist.append((
                outer_edge,
                (0, 0, s1_defn.max_thickness + 0.5 * side_thickness),
                (0, 0, pi / 2),
            ))
        elif side_thickness < 0:
            raise InvalidGeometryException(
                "Lens is not thick enough to support surfaces.")

        # Brim
        self._add_brim(s1_defn, s1_defn.max_thickness)
        if s2_defn is not None:
            self._add_brim(s2_defn, thickness - s2_defn.max_thickness)

        # Apply offset
        self._translate_origin(origin)