关于OSLO光线型评价函数源码分析

来源:互联网 发布:2017java项目开发视频 编辑:程序博客网 时间:2024/05/22 05:18

 如同我学习编程一样,什么都想知道个究竟,最近算是深入学习OSLO光学设计软件,选择你,是因为你很透明,你能让我知道你干了什么,也能可以让我想让你干什么你就干什么,你是光软的VC++,连自带的CCL编程语言都是那么让我亲切,真想从内心里说,爱死你了,我很幸福的将赌注押在你身上了,也算不枉费我花那么多时间去构建那些繁琐的光学设计理论。。。现在用到你自带的很牛逼的光学型评价函数了,你很干净利落,产生该一系列操作数前,只给了个如此丑陋的对话框,虽然看了你的程序参考书,但是你这给的一些了参数还是让人摸不着头脑,再仔细看下HELP,哦,原来你说要追求细节,自己去看optim_erfs.ccl 这里的源码吧,太爽了,完全符合鄙人口味,现分析你牛逼的如下源码:

#ifndef _OSLO_LIGHT_//一看这知道你肚子里那点花花肠子了

cmd geniierf(double design_frequency, double f1_fymax, double f2_fymin,
             double f2_fymax, double f2_fx, double f3_fymin, double f3_fymax, double f3_fx,
             double f2_distol, double f3_distol)
// hlp:  <P class="Edition">OSLO Premium/OSLO Standard</P>
// hlp:  <P>Generates a <a href="../optim/generation/genii.htm">Genii error function</a>.</P>
// kwd:  genii, error function, OCM, optimisation, error function builder
// cat:  optimization
{
 double uprime, dy, tmp;
 int    ssrow;
 char   tmpstr[32];

 set_preference(output_text, off);
 ssrow = sbrow();
 ssbuf_reset(ssrow, 50);

//上面是初始化相关变量及输出文本格式,且不管
 /* get current paraxial axial ray slope */
 paraxial_trace();
 uprime = -ssb(1, 2);//获取第一近轴角

 /* basic transverse tolerance Dy */
 dy = 1.0/(6.0*design_frequency);//原来此频率参数是为了得到横向公差的(估计是作评价函数的权重所用)
  
 /* delete old operands to enable new ray set */
 operands(new);
 end;
 //下面开始构建新的光线集(供追迹所用)
 /* construct new ray set */
 rayset(new);
 /* field points <fby fbx fbz fyrf fxrf fymin fymax fxmin fxmax wgt> *///视场点的设置函数,(fyrf fxrf )是视场点的参考光线孔径比例坐标,下面的视场点的权重都为1
 f(1, 0.0, 0.0, 0.0, 0.0, 0.0, -f1_fymax, f1_fymax, -f1_fymax, f1_fymax, 1.0);//轴上点的孔径X、Y方向的渐晕完全有f1_fymax表征,且是对称的!
 f(2, 0.7, 0.0, 0.0, 0.0, 0.0, f2_fymin, f2_fymax, -f2_fx, f2_fx, 1.0);//0.7视场的渐晕是(f2_fymin, f2_fymax, -f2_fx, f2_fx)
 f(3, 1.0, 0.0, 0.0, 0.0, 0.0, f3_fymin, f3_fymax, -f3_fx, f3_fx, 1.0);//全视场的渐晕是(f3_fymin, f3_fymax, -f3_fx, f3_fx)
 /* rays <type fy fx> */ //下面是孔径上取点方式了,都是中心的与边缘的,与对话框里的参数无关
 r(1, ref,  0.0, 0.0);
 r(2, ord,  1.0, 0.0);
 r(3, ord, -1.0, 0.0);
 r(4, ord,  0.0, 1.0);
 end(); 
//至此,对话框里的参数只剩 f2_distol, f3_distol了,下面要开始产生操作数了
 /* new operand set */
 operands(new);
 //下面的o(...)应是构建操作数的函数
/* GENII "tolerances" */ 
 sprintf(tmpstr, "%.11e", dy); 
 o(1, ins, tmpstr, min, 0.0, "_Dy tol");
 sprintf(tmpstr, "%.11e", 2.1*dy); 
 o(2, ins, tmpstr, min, 0.0, "_2.1 Dy");
 sprintf(tmpstr, "%.11e", 2.8*dy); 
 o(3, ins, tmpstr, min, 0.0, "_2.8 Dy");
 sprintf(tmpstr, "%.11e", 3.0*dy); 
 o(4, ins, tmpstr, min, 0.0, "_3 Dy");
 sprintf(tmpstr, "%.11e", 4.0*dy); 
 o(5, ins, tmpstr, min, 0.0, "_4 Dy");
 if (opdw)
  tmp = 1000.0*uni/wv[1];
 else
  tmp = 1.0;
 sprintf(tmpstr, "%.11e", tmp*uprime*dy/3.0); 
 o(6, ins, tmpstr, min, 0.0, "_up Dy/3");
 sprintf(tmpstr, "%.11e", tmp*3.2*uprime*dy); 
 o(7, ins, tmpstr, min, 0.0, "_3.2 up Dy");

//轴上点的
/* on-axis targets */
 if (uprime < 0.0)
  sprintf(tmpstr, "%.11e+PU", uprime);
 else
  sprintf(tmpstr, "PU+%.11e", uprime);
 o(8, ins, tmpstr, min, 0.0, "_uprime");             /* paraxial axial ray slope in image space */

//近轴光线的slope,用以保持焦距
 o(9, ins, "O8/0.0001", min, 1.0, "Fnb diff");       /* 0.0001 is experimental magic number */

//轴上细光束的场曲,就是像面的离焦
 o(10, ins, "DYY(1,1)/O4", min, 1.0, "Focus diff");  /* focus shift penalty */

//轴上边缘光线的横向光线差,即轴上边缘球差
 o(11, ins, "DY(1,2)/O1", min, 1.0, "Axial DY");     /* transverse aberration */

//轴上边缘光线OPD
 o(12, ins, "OPD(1,2)/O6", min, 1.0, "Axial OPD");   /* OPD on-axis */

轴上边缘光线DMD
 o(13, ins, "DMD(1,2)/O6", min, 1.0, "Axial DMD");   /* axial color (DMD) */

//0.7视场的
/* 0.7 field targets */
 sprintf(tmpstr, "%.11e", f2_distol);//将f2_distol拷贝的字符数组里,意欲何为?

//通过查看O命令,其第三个参数,即tmpstr,是用作操作数定义用的,实际上结果也是如此,且o(14)权重为0,只是作为中间运算量(其值貌似就是f2_distol),字面意思理解是畸变(Ds)的
//公差(tol),是用来做畸变的权重的,该是如此!

 o(14, ins, tmpstr, min, 0.0, "_0.7 Dstol");
 o(15, ins, "100*DIST(2,1)", min, 0.0, "_0.7 Dist");

//畸变
 o(16, ins, "O15/O14", min, 1.0, "0.7 Dist");        /* Distortion */

//子午细光束场曲
 o(17, ins, "DYY(2,1)/O2", min, 1.0, "0.7 YFS");     /* tangential field curvature */

//弧矢细光束场曲
 o(18, ins, "DXX(2,1)/O2", min, 1.0, "0.7 XFS");     /* sagittal field curvature */

//三级彗差
 o(19, ins, "S2T(2,1)/O7", min, 1.0, "0.7 Coma");    /* primary aperture coma */

//上边缘光线横向光线差
 o(20, ins, "DY(2,2)/O3", min, 1.0, "0.7 DY U");     /* transverse aberration in upper aperture */

//上边缘光线OPD
 o(21, ins, "OPD(2,2)/O6", min, 1.0, "0.7 OPD U");   /* OPD in upper aperture */

//上边缘光线DMD
 o(22, ins, "DMD(2,2)/O6", min, 1.0, "0.7 DMD U");   /* DMD for lateral color in upper aperture */

//下边缘光线横向光线差
 o(23, ins, "DY(2,3)/O3", min, 1.0, "0.7 DY L");     /* transverse aberration in lower aperture */

//下边缘光线OPD
 o(24, ins, "OPD(2,3)/O6", min, 1.0, "0.7 OPD L");   /* OPD in lower aperture */

//下边缘光线DMD
 o(25, ins, "DMD(2,3)/O6", min, 1.0, "0.7 DMD L");   /* DMD for lateral color in lower aperture */

//边缘弧矢光线的DX
 o(26, ins, "DX(2,4)/O3", min, 1.0, "0.7 Sag DX");   /* transverse aberration x-component for sagittal ray */

//边缘弧矢光线的DY
 o(27, ins, "DY(2,4)/O1", min, 1.0, "0.7 Sag DY");   /* transverse aberration y-component for sagittal ray */

//边缘弧矢光线的OPD
 o(28, ins, "OPD(2,4)/O6", min, 1.0, ".7 Sag OPD");  /* OPD for sagittal ray */

//全视场的,与0.7类似
/* 1.0 field targets */
 sprintf(tmpstr, "%.11e", f3_distol);                  
 o(29, ins, tmpstr, min, 0.0, "_1.0 Dstol");
 o(30, ins, "100*DIST(3,1)", min, 0.0, "_1.0 Dist");
 o(31, ins, "O30/O29", min, 1.0, "1.0 Dist");        /* Distortion */
 o(32, ins, "DYY(3,1)/O4", min, 1.0, "1.0 YFS");     /* tangential field curvature */
 o(33, ins, "DXX(3,1)/O1", min, 1.0, "1.0 XFS");     /* sagittal field curvature */
 o(34, ins, "S2T(3,1)/O7", min, 1.0, "1.0 Coma");    /* primary aperture coma */
 o(35, ins, "DY(3,2)/O5", min, 1.0, "1.0 DY U");     /* transverse aberration in upper aperture */
 o(36, ins, "OPD(3,2)/O6", min, 1.0, "1.0 OPD U");   /* OPD in upper aperture */
 o(37, ins, "DMD(3,2)/O6", min, 1.0, "1.0 DMD U");   /* DMD for lateral color in upper aperture */
 o(38, ins, "DY(3,3)/O5", min, 1.0, "1.0 DY L");     /* transverse aberration in lower aperture */
 o(39, ins, "OPD(3,3)/O6", min, 1.0, "1.0 OPD L");   /* OPD in lower aperture */
 o(40, ins, "DMD(3,3)/O6", min, 1.0, "1.0 DMD L");   /* DMD for lateral color in lower aperture */
 o(41, ins, "DX(3,4)/O5", min, 1.0, "1.0 Sag DX");   /* transverse aberration x-component for sagittal ray */
 o(42, ins, "DY(3,4)/O1", min, 1.0, "1.0 Sag DY");   /* transverse aberration y-component for sagittal ray */
 o(43, ins, "OPD(3,4)/O6", min, 1.0, "1 Sag OPD");   /* OPD for sagittal ray */
 end();
 
 ssbuf_reset(-ssrow, 0);
 set_preference(output_text, on);
}
好了,其参数意义大抵如此,默认值就是如上面对话框中给出的,即轴上点不设渐晕,0.7视场y、x方向分别有0.9、0.8的渐晕,全视场y、x方向分别有0.8、0.7的渐晕!要想利用不同于此的比例孔径相关像差项,只要改这几个参数就够了!至于畸变公差,这是有国际标准的,用它默认的好。

 

原创粉丝点击