7.6 Example — Doublet Lens Tilt Nulls
PDF section 7.6. Source script: KrakenOS/Examples/Examp_Doublet_Lens_Tilt-Nulls.py.
Demonstrates null surfaces — "NULL"-glass interfaces inserted around a
tilted element to undo the coordinate transformation so the downstream
surfaces remain on the original optical axis. The first null surface
applies the opposite tilt (Order = 1); the second restores the
thickness.
Figure 13. 2D and 3D view of a doublet with one tilted face, isolated from the rest of the system by null surfaces.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Examp Doublet Lens Tilt Nulls"""
import numpy as np
from importlib import metadata
""" Looking for if KrakenOS is installed, if not, it assumes that
an folder downloaded from github is run"""
required = {'KrakenOS'}
installed = {dist.metadata["Name"] for dist in metadata.distributions() if dist.metadata.get("Name")}
missing = {pkg for pkg in required if pkg not in installed}
if missing:
print("Not installed")
import sys
sys.path.append("../..")
import KrakenOS as Kos
import pickle
# _________________________________________#
P_Obj = Kos.surf()
P_Obj.Rc = 0.0
P_Obj.Thickness = 1
P_Obj.Glass = "AIR"
P_Obj.Diameter = 30.0
# _________________________________________#
L1a = Kos.surf()
L1a.Rc = 5.513435044607768E+001
L1a.Thickness = 6.0
L1a.Glass = "BK7"
L1a.Diameter = 30.0
L1a.TiltX = 4
# _________________________________________#
Null1_L1a = Kos.surf()
Null1_L1a.Thickness = -L1a.Thickness
Null1_L1a.Glass = "NULL"
Null1_L1a.Diameter = L1a.Diameter
Null1_L1a.TiltX = -L1a.TiltX
Null1_L1a.Order = 1
# _________________________________________#
Null2_L1a = Kos.surf()
Null2_L1a.Thickness = L1a.Thickness
Null2_L1a.Glass = "NULL"
Null2_L1a.Diameter = L1a.Diameter
# _________________________________________#
L1b = Kos.surf()
L1b.Rc = -4.408716526030626E+001
L1b.Thickness = 3.0
L1b.Glass = "F2"
L1b.Diameter = 30
# _________________________________________#
L1c = Kos.surf()
L1c.Rc = -2.246906271406796E+002
L1c.Thickness = 9.737871661422000E+001
L1c.Glass = "AIR"
L1c.Diameter = 30
# _________________________________________#
P_Ima = Kos.surf()
P_Ima.Rc = 0.0
P_Ima.Thickness = 0.0
P_Ima.Glass = "AIR"
P_Ima.Diameter = 10.0
P_Ima.Name = "Image plane"
# _________________________________________#
A = [P_Obj, L1a, Null1_L1a, Null2_L1a, L1b, L1c, P_Ima]
configuracion_1 = Kos.Setup()
# _________________________________________#
Doblete = Kos.system(A, configuracion_1, build = 0)
# with open('mi_objeto.pkl', 'wb') as archivo_salida:
# # Usa pickle.dump para serializar y guardar el objeto en el archivo.
# pickle.dump(Doblete, archivo_salida)
# with open('mi_objeto.pkl', 'rb') as archivo_entrada:
# Doblete = pickle.load(archivo_entrada)
Doblete.build()
Rayos = Kos.raykeeper(Doblete)
# _________________________________________#
tam = 5
rad = 10.0
tsis = 6
for i in range(-tam, tam + 1):
for j in range(-tam, tam + 1):
x_0 = (i / tam) * rad
y_0 = (j / tam) * rad
r = np.sqrt((x_0 * x_0) + (y_0 * y_0))
if r < rad:
tet = 0.0
pSource_0 = [x_0, y_0, 0.0]
dCos = [0.0, np.sin(np.deg2rad(tet)), np.cos(np.deg2rad(tet))]
W = 0.4
Doblete.Trace(pSource_0, dCos, W)
Rayos.push()
W = 0.5
Doblete.Trace(pSource_0, dCos, W)
Rayos.push()
W = 0.6
Doblete.Trace(pSource_0, dCos, W)
Rayos.push()
# _________________________________________#
Kos.display3d(Doblete, Rayos, 2)