文章目錄
- 設置光學參數
- 添加光學器件
設置光學參數
官方文檔:設計手機鏡頭
rayoptics中提供了OpticalModel類,可用于創建光學模型對象。OpticalModel類中的【optical_spec】成員,是一個OpticalSpecs對象,可用于指定光圈、視野、光譜和焦點位置等信息。
from rayoptics.environment import *opm = OpticalModel()
osp = opm.optical_specosp.title = 'Cell Phone Lens'
osp.dimensions = 'mm'
osp.pupil = PupilSpec(osp, key=['image', 'f/#'], value=3.5)
osp.fov = FieldSpec(osp, key=['image', 'height'], value=3.5, is_relative=True, flds=[0., .7071, 1])
osp.wvls = WvlSpec([('F', 0.5), ('d', 1.0), ('C', 0.5)], ref_wl=1)
上述代碼中,
- 【PupilSpec】即孔徑,其值為3.5,key表示孔徑類型,[‘image’, ‘f/#’]表示以像面F數為主
- 【FieldSpec】即視場,其值為3.5,key表示視場類型,[‘image’, ‘height’]表示像面高度。
- 【WvlSpec】即波長,其輸入為波長列表,其中F(氫藍線)、d(氦黃線)、c(氫紅線)的權重分別為0.5,1,0.5。
添加光學器件
opm中提供的seq_model成員,是一個SequentialModel對象,可用于定義接口和間隙,光通過這些接口和間隙傳播形成圖像,示意如下,其中【Ifc】為接口,【G】表示間隙。
IfcObj Ifc1 Ifc2 Ifc3 ... Ifci-1 IfcImg\ / \ / \ / \ /GObj G1 G2 Gi-1
下面通過成員函數【add_surface】為模型添加光學表面,以設計如下鏡頭
【add_surface】其輸入參數為列表,列表中元素含義為
- curvature,即曲率,若如果 radius_mode 為 True, 則為曲率半徑。
- thickness,即厚度,該表面到下一個表面的距離,單位 mm。
- v-number,一般為折射率。
- semi-diameter,半徑。
代碼如下
sm = opm.seq_model
opm.radius_mode = Truesm.gaps[0].thi=1e10sm.add_surface([0., 0.])
sm.set_stop()sm.add_surface([1.962, 1.19, 1.471, 76.6])
sm.ifcs[sm.cur_surface].profile = RadialPolynomial(r=1.962, ec=2.153,coefs=[0., 0., -1.895e-2, 2.426e-2, -5.123e-2, 8.371e-4, 7.850e-3, 4.091e-3, -7.732e-3, -4.265e-3])sm.add_surface([33.398, .93])
sm.ifcs[sm.cur_surface].profile = RadialPolynomial(r=33.398, ec=40.18,coefs=[0., 0., -4.966e-3, -1.434e-2, -6.139e-3, -9.284e-5, 6.438e-3, -5.72e-3, -2.385e-2, 1.108e-2])sm.add_surface([-2.182, .75, 1.603, 27.5])
sm.ifcs[sm.cur_surface].profile = RadialPolynomial(r=-2.182, ec=2.105,coefs=[0., 0., -4.388e-2, -2.555e-2, 5.16e-2, -4.307e-2, -2.831e-2, 3.162e-2, 4.630e-2, -4.877e-2])sm.add_surface([-6.367, 0.1])
sm.ifcs[sm.cur_surface].profile = RadialPolynomial(r=-6.367, ec=3.382,coefs=[0., 0., -1.131e-1, -7.863e-2, 1.094e-1, 6.228e-3, -2.216e-2, -5.89e-3, 4.123e-3, 1.041e-3])sm.add_surface([5.694, .89, 1.510, 56.2])
sm.ifcs[sm.cur_surface].profile = RadialPolynomial(r=5.694, ec=-221.1,coefs=[0., 0., -7.876e-2, 7.02e-2, 1.575e-3, -9.958e-3, -7.322e-3, 6.914e-4, 2.54e-3, -7.65e-4])sm.add_surface([9.192, .16])
sm.ifcs[sm.cur_surface].profile = RadialPolynomial(r=9.192, ec=0.9331,coefs=[0., 0., 9.694e-3, -2.516e-3, -3.606e-3, -2.497e-4, -6.84e-4, -1.414e-4, 2.932e-4, -7.284e-5])sm.add_surface([1.674, .85, 1.510, 56.2])
sm.ifcs[sm.cur_surface].profile = RadialPolynomial(r=1.674, ec=-7.617,coefs=[0., 0., 7.429e-2, -6.933e-2, -5.811e-3, 2.396e-3, 2.100e-3, -3.119e-4, -5.552e-5, 7.969e-6])sm.add_surface([1.509, .70])
sm.ifcs[sm.cur_surface].profile = RadialPolynomial(r=1.509, ec=-2.707,coefs=[0., 0., 1.767e-3, -4.652e-2, 1.625e-2, -3.522e-3, -7.106e-4, 3.825e-4, 6.271e-5, -2.631e-5])sm.add_surface([0., .40, 1.516, 64.1])
sm.add_surface([0., .64])opm.update_model()
sm.do_apertures = False
sm.list_model()
對模型進行羅列的結果為
r t medium mode zdr sdObj: 0.000000 1.00000e+10 air dummy 1 1.7455e+08Stop: 0.000000 0.00000 air 1 0.793582: 1.962000 1.19000 471.766 1 0.796453: 33.398000 0.930000 air 1 0.672434: -2.182000 0.750000 603.275 1 0.511955: -6.367000 0.100000 air 1 0.510076: 5.694000 0.890000 510.562 1 0.493557: 9.192000 0.160000 air 1 0.419758: 1.674000 0.850000 510.562 1 0.400099: 1.509000 0.700000 air 1 0.2846010: 0.000000 0.400000 516.641 1 0.2035711: 0.000000 0.640000 air 1 0.17198Img: 0.000000 0.00000 dummy 1 0.10146
繪圖代碼如下
import matplotlib.pyplot as plt
layout_plt0 = plt.figure(FigureClass=InteractiveLayout, opt_model=opm,do_draw_rays=True, do_paraxial_layout=False, is_dark=False).plot()
plt.show()