基于MFC的双缝夫琅禾费衍射现象的模拟
(2 天津大学精密仪器与光电子工程学院,省份 天津 城市天津 邮编 300072)
(1 单位 省份 城市 邮编)
摘要 在分析了解双缝夫琅禾费衍射的物理学及光学模型的基础上,采用 Visual C++6.0
中的 MFC,对于双缝夫琅禾费衍射进行计算机的仿真模拟,分别研究了 d,d/a,λ变化时
不同的现象及原理。
关键词 双缝夫琅禾费衍射;MFC;双缝间距 d;缝宽 a;波长λ
Based on MFC of double slit his post for simulation of
diffraction phenomenon
Author1 孟佳圆 Author2 尚双双 Author3 孙畅 Author4 崔新宁
(1 Department, University,city,province postal-code, China)
(2Tianjin university precision instrument and optoelectronic engineering college ,Tianjin
University,Tianjin,Tianjin 300072)
Abstract
we use the MFC of Visual C++6.0 to simulate the double slit Fraunhofer
diffraction. At the same time we talk abut the different phenomena and principle when d,a and λ
changed.
Keywords
slit;wavelength
the double slit Fraunhofer diffraction ;the distance of double slit ;the width of
1.应用 MFC 进行仿真模拟的基本思路及程序设计概况
1.1 用于编程的双缝衍射基本原理
图 1 双缝衍射装置
Fig.1. Double-slit diffraction equipment
双缝衍射的实验装置如图 1 所示:一光栅有 N 条缝,透光的缝宽度为 a,不
透光的挡板宽度为 b,入射光波为。
双缝间距为 d=a+b,d 称为光栅常数。如图 1 所示,在方向,相邻两条缝
之间的光程差为=dsin,相位差为
2
,假设每一个单缝引
2
sin
d
起的光波振幅为 'A ,根据多个等幅同频振动的合振幅公式:
A
A
sin
2/
n
2/
sin
,
所 有 缝 在 方 向 产 生 的 振 幅 为
'
A
'
A
sin
sin
2/
N
2/
'
A
sin
sin
Nv
v
, 其 中
v
sind
。汇聚点的光强为
sin(
Nv
sin
v
是单缝引起的光强。根据单缝衍射的公式
I
I
'
0
2
)
'
2'
A
。当 N=1,可知: '
0I
u
2
)
,可得光栅衍射的光强
0
,其中
I
sin(
u
I
0
。
I
sina
公式
I
I
0
u
2
)
sin(
u
sin(
sin
Nv
v
2)
,其中 u=
(1)当 N=1 时,光强公式变为单缝衍射的公式
I
I
0
u
2
)
sin(
u
,因此
u
2)
sin(
u
称为单缝衍射因子。
(2)当 N=2 时,根据光栅衍射公式可得:
I
I
0
1.2.在 MFC 已有框架基础上,自己定义及填写的程序概况
u
sin(
u
2
4)
cos
2
v
[2]。
由于 MFC 本身就有一定设计好的程序,在进行仿真时只需在程序给出的框
架 中 填 入 进 行 夫 琅 禾 费 衍 射 特 有 的 参 数 及 定 义 即 可 。 下 面 我 们 将 给 出 在
aaaDlg.cpp 中我们自己填写的程序代码。(均包含了程序中已经给出的说明)
(1)OnInitDialog()中有几行做数据初始化,具体的初始化程序为
BOOL CAaaDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
// Set small icon
// Set big icon
m_d = 0.0015;
m_lambda = 632.8;
m_multi = 3;
type = 3;
anim = false;
UpdateData(FALSE);
// TODO: Add extra initialization here
return TRUE;
// return TRUE unless you set the focus to a control
}
(2)OnDrawItem() 图形绘制函数。具体程序代码如下:
{
// TODO: Add your message handler code here and/or call default
if(nIDCtl == IDC_STATIC1){
CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CDC memdc;
memdc.CreateCompatibleDC(pDC);
CRect rc;
::GetClientRect(::GetDlgItem(this->GetSafeHwnd(),
IDC_STATIC1),
&rc);
CBitmap MemBitmap;
MemBitmap.CreateCompatibleBitmap(pDC,rc.Width(),rc.Height());
memdc.SelectObject(&MemBitmap);
memdc.FillSolidRect(rc, RGB(255, 255, 255));
memdc.FillSolidRect(rc, RGB(255, 255, 255));
memdc.MoveTo(20, 20);
memdc.LineTo(20, 300);
memdc.LineTo(500, 300);
memdc.MoveTo(20, 300);
draw.init(20, 20, 280, 4, m_d, m_multi, m_lambda);
Draw::Para para = draw.getNext();
while(para.x < 500)
{
memdc.LineTo(para.x, para.y);
memdc.FillSolidRect(para.x, 320, 1, 40, RGB(0.1 * sqrt(para.I *
100 / 4) * 255, 0, 0));
para = draw.getNext();
}
CString s;
s.Format(" 参 数 :\nd = %f mm\nd = %fa\n λ = %f nm", para.d,
para.multi,
para.lambda);
::SetWindowText(::GetDlgItem(this->GetSafeHwnd(),
IDC_STATIC2),
s);
if(type == 0){
m_d += 0.0001;
if(m_d > 0.01)
m_d = 0.0005;
}
else if(type == 1){
m_lambda += 10;
if(m_lambda > 2700)
m_lambda = 500;
}else if(type == 2){
m_multi += 0.1;
if(m_multi > 20)
m_multi = 1;
}
pDC->BitBlt(0,0,rc.Width(),rc.Height(),&memdc,0,0,SRCCOPY);
MemBitmap.DeleteObject();
memdc.DeleteDC();
return;
}
CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct);
}
(3)OnButton1() 绘制按钮事件,具体代码如下所示:
{
// TODO: Add your control notification handler code here
UpdateData();
KillTimer(0);
type = 3;
anim = false;
::InvalidateRect(::GetDlgItem(this->GetSafeHwnd(), IDC_STATIC1), NULL,
FALSE);
}
(4)OnAnim()
(5)OnButton3()
(6)OnLambdaAnim()
d 变化动画演示按钮事件
d/a 倍数变化演示按钮事件
λ(lambda)变化演示事件
四五六三部分为我们仿真模拟研究的主要部分,我们将在后面的部分进行更
为具体的分析(在后面一并给出代码),此处不赘述。
(7)OnTimer()
{
定时器事件
// TODO: Add your message handler code here and/or call default
if(nIDEvent == 0){
::InvalidateRect(::GetDlgItem(this->GetSafeHwnd(),
IDC_STATIC1),
NULL,
FALSE);
}
CDialog::OnTimer(nIDEvent);
}
1.3 对于 draw.h 和 draw.cpp 文件执行流程的注释及说明
draw 类用来计算,并将计算结果返回。(其中有个定义是我们在网上找
的照着它里面的公式打的。)
OnDrawItem()是主要的绘图函数,根据 draw 类返回的结果画线和光谱。
动画演示是通过定时器实现的,定时器函数中通过 invalid 控件使其重绘,
进而调用了 OnDrawItem()。
“绘制”按钮就是只取消(invalid)一次。
2.从工程光学角度分析夫琅禾费双缝衍射及程序设计
2.1 对于双缝夫琅禾费原理的进一步探究
研究双缝夫琅禾费的强度分布公式可用夫琅和费衍射公式对双缝平面积分
求取,还可以用另一种形式进行求取。观察孔径平移的衍射强度分布的结果:a)、
b)情况衍射图样的位置不变,当同一照明光照射到双缝时,屏上衍射分布是两单
缝衍射复振幅分布叠加。如图 2 所示。
Figure2
(a)center of slit on the optical axis
(b)the slit moved in the aperture
于是,双缝衍射是单缝衍射和双缝干涉的结果。
如图 3 系统写出
图 3
于是可得双缝夫琅禾费衍射光强分布式:
下面分析强度分布曲线: