Exemple #1
0
    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))
Exemple #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))
Exemple #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))
 def _add_brim(self, defn, z_position):
     """Adds an outer brim surface defined by surface definition defn.
     Only applies is the specified outer diameter of this lens is larger
     than the maximum diameter of the defined surface.
     Brim will be located at postion z_position.
     """
     if self.outer_diameter > defn.diameter:
         brim = Aperture(
             shape=Circular(radius=0.5 * self.outer_diameter),
             ap_shape=Circular(radius=0.5 * defn.diameter),
         )
         self.surflist.append((brim, (0, 0, z_position), (0, 0, pi / 2)))
     elif self.outer_diameter < defn.diameter:
         raise InvalidGeometryException(
             "Lens outer diameter can not be smaller than the diameter of an aspheric surface."
         )
Exemple #5
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)
    def pyoptools_repr(self, obj):
        InD = obj.InD.Value
        OutD = obj.OutD.Value

        return comp_lib.Stop(Circular(OutD / 2.0), Circular(InD / 2.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)