matlab仿真及其在光学课程中的应用答案,结构光三维成像matlab
一内容介绍为了了解电磁波在光子晶体中的传输特性,用矩阵实验室与时域有限差分法把电磁波在真空与光子晶体中的传播实时可视化,并给出了场的空间静态分布。数值模拟的结果表明,禁带中的波被光子晶体控制,其能量分布在介质柱中,并观察到了电磁波局域化现象。
2部分代码清除所有丢失所有CLC % @所有CLC % @所有CLC % @所有CLC % @所有CLC % @所有CLC % @所有CLC % @所有CLC % @所有CLC % @所有CLC % @所有CLC % @所有CLC
%%%%%%%%%%%%%%%%%%%%%常量%%%常量%%%常量%%常量%%常量%%常量
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
c=2.99792458e8
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%绘图参数
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
band=1;
field=1;
=0;
AAbs=1;%%绘图绝对值(五)
RReal=0;%%绘图实数(五)
ii mag=0;%%绘图图像(五)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%参数%%%%%参数%%%参数%%%参数%%参数%%参数%%参数%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
十六进制=1;
comb=0;
TM=0;
TE=1;
Nx=32x网格上的点数%必须是2的幂(32,64,128,256,512,)
Ny=32y网格上的点数%必须是2的幂(32,64,128,256,512,)
NGx=10%谐波数%必须是x的2倍-1
NGy=11%谐波数%必须是y的2倍-1
Nkx=10分散在k空间上的点数%
Nky=Nkx分散在k空间上的点数%
n个模式=5;询问的解决方案数量百分比
NP=3;为字段绘制的周期数百分比
n1=1;%%光学折射率材料一
N2=sqrt(12);%%光学折射率材料2
定额单位=1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % % % % % % % % % % % % % % % % % % % % % % % % % % %的索引几何
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
如果NormUnits==1
l=1;
elseif NormUnits==0
l=1e-6;
目标
LX=L;
ly=L * sqrt(3)/2;
a1=Lx *[1 0];
a2=Lx *[1/2 sqrt(3)/2];
count=1;
对于jj=0:Nx-1,
对于j=0:Ny-1,
AAA(count,)=jj * a1/(Nx-1)j * a2/(Ny-1);
计数=计数1;
目标
目标
xhex=shape(AAA(:1),Ny,Nx);
yhex=shape(AAA(:2),Ny,Nx);
dx=Xhex(1,2)-Xhex(1,1);
dy=Yhex(2,1)-Yhex(1,1);
if(hex==1)(comb==1) (hex==0)(comb==0)
显示("错误:选择六边形点阵或蜂巢点阵")
破裂
目标
如果十六进制==1
a=0.3% 0.495;
idx1=( (Xhex-Lx*3/4).^2 (Yhex-Ly/2).^2)(a*l)^2;
idx2=( (Xhex-Lx*3/4 Lx/2).^2 (Yhex-Ly/2 Ly).^2)(a*l)^2;
idx3=( (Xhex-Lx*3/4-Lx/2).^2 (Yhex-Ly/2-Ly).^2)(a*l)^2;
idx4=( (Xhex-Lx*3/4-Lx).^2 (Yhex-Ly/2).^2)(a*l)^2;
idx5=( (Xhex-Lx*3/4 Lx).^2 (Yhex-Ly/2).^2)(a*l)^2;
idx=idx 1 id x2 idx 3 id x4 idx 5;
EPS=idx*n2^2(1-idx)*n1^2;
目标
如果梳状==1
a=0.24
idx1a=( (Xhex-Lx*3/4).^2 (Yhex-Ly/5).^2)(a*l)^2;
idx1b=( (Xhex-Lx*3/4 Lx/2).^2 (Yhex-Ly/5-Lx/sqrt(3) Ly).^2)(a*l)^2;
idx2a=( (Xhex-Lx*3/4).^2 (Yhex-Ly/5-Lx/sqrt(3))。^2)(a*l)^2;
idx2b=( (Xhex-Lx*3/4-Lx/2).^2(yhex-ly/5ly)。^2)(a*l)^2;
idx=idx1a idx1b idx2a idx2b
EPS=idx*n2^2(1-idx)*n1^2;
目标
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%倒易点阵向量%%%%%倒易点阵向量
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NGx=2 *楼层(NGx/2);%%四舍五入到较低的偶数
NGy=2 *楼层(NGy/2);%%四舍五入到较低的偶数
B1=2 * pi/Lx *[1-sqrt(3)/3];
B2=2 * pi/Lx *[0 2 * sqrt(3)/3];
count=1;
GGG=[];
对于jj=-NGx:NGx
for j=-NGy:NGy
GGG(计数,)=jj * b1 j * b2
计数=计数1;
目标
目标
GX十六进制=shape(GGG(:1),2*NGy 1,2 * NGy 1,2
gyhex=shape(GGG(:2),2*NGy 1,2 * NGy 1,2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%六角傅里叶变换%%%%六角傅里叶变换%%%六角傅里叶变换
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
伽马=1。/EPS;
f=;
对于jj=1:长度(Gxhex(1,))
对于j=1:长度(Gyhex(:1))
whex=exp( -1i*( Gxhex(1,jj)*(Xhex-Xhex(1))*(Nx-1)/Nx(Gyhex(j,jj))*(Yhex-Yhex(1))*(Ny-1)/Ny);
Ghex(j,jj)=sum(sum(f . * whex));
目标
目标
gammak=Ghex * dx * dy/Lx/Ly;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%% % % % % % % % % % %的建筑的reciproque点阵向量% % % %再% % % %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
count=1;
GGG=[];
对于jj=-NGx/2:NGx/2,
对于j=-NGy/2:NGy/2,
GGG(计数,)=jj * b1 j * b2
计数=计数1;
目标
目标
GX hex=shape(GGG(:1),NGy 1,NGx 1);
gyhex=shape(GGG(:2),NGy 1,NGx 1);
NGx=长度(Gxhex(1,));
NGy=length(Gyhex(:1));
NG=NGx * NGy
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % % % % % % % k空间向量的构建
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
kx=linspace( 0,pi/L,Nkx)* 2/3;
ky=linspace( 0,pi/Ly,Nky);
k=[
ky*0 ky
kx ky(end) kx*0
sort(kx, descend) sort(ky, descend )
];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%再也没有什么可以改变的了!%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (TE==1 TM==1) (TE==0 TM==0)
显示(错误:选择 TM 或TE’)
破裂
目标
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
不依赖于k的哈密尔顿函数的第一部分
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
HHH=零(NGy,NGx,NGy,NGx);
对于ix=1:NGx
对于jx=1:NGx
对于iy=1:NGy
对于jy=1:NGy
HHH(iy,ix,jy,JX)=1伽马克(iy-jy NGy,IX-JX NGx);
目标
目标
目标
目标
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
对于i=1:长度(k(:1))
[psi,f0]=PhC2D_hex_PWE_f(Xhex,Yhex,Gxhex,Gyhex,k(i,),HHH,nmodes,TE,TM);
e(:I)=psi;
如果NormUnits==1
FF(:I)=F0 * Lx/(2 * pi);
elseif NormUnits==0
FF(:I)=F0 * c/(2 * pi)* 1e-12;%转换为太赫兹波
(:i)=2*pi ./F0 * 1e 6;%转换成波长(微米)
目标
目标
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%的数字
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
如果AAbs==1
EE=ABS(E);
目标
如果RReal==1
EE=实数(E)和:
目标
如果IImag==1
EE=imag(E);
目标
如果NormUnits==0
Xhex=Xhex * 1e6
Yhex=Yhex * 1e6
Lx=Lx * 1e6
Ly=Ly * 1e6
k=k * 1e-6;
目标
如果字段==1
如果TM==1 TE==0
图(位置,[100 50 1000 1000],名称,‘Ez’);
elseif TE==1 TM==0
图(位置,[100 50 1000 1000],名称,‘Exy’);
目标
彩色地图(喷射)
对于ii=0:nmodes-1
对于i=1:Np
对于j=1:Np
子情节(nmodes,3,3,1 3 * ii)
继续
pcolor( Xhex (i-1 (j-1)/2)*Lx,Yhex (j-1)*Ly,EE(:ii 1,1))
contour( Xhex (i-1 (j-1)/2)*Lx,Yhex (j-1)*Ly,abs(eps),1,’线宽,2,线条颜色, w )
目标
目标
遮光平板
%颜色条
如果RReal==1 IImag==1
卡克斯([-1 1])
elseif AAbs==1
卡克斯([0 1])
目标
如果NormUnits==1
title(strcat(\Gamma: w=,num2str(FF(1 ii,1), %.2f ))
xlabel(x (norm .单位))
ylabel(y (norm .单位))
elseif NormUnits==0
标题(strcat(\Gamma: \lambda=,num2str(lambda(1 ii,1), %.2f ), um ))
xlabel(x (um))
ylabel(y (um))
目标
xlim([0 1.5*Np*Lx])
ylim([0 Np*Ly])
目标
对于ii=0:nmodes-1
对于i=1:Np
对于j=1:Np
子情节(nmodes,3,3,2 3 * ii)
继续
pcolor( Xhex (i-1 (j-1)/2)*Lx,Yhex (j-1)*Ly,EE(:ii 1,1*Nkx))
contour( Xhex (i-1 (j-1)/2)*Lx,Yhex (j-1)*Ly,abs(eps),1,’线宽,2,线条颜色, w )
目标
目标
遮光平板
%颜色条
如果RReal==1 IImag==1
卡克斯([-1 1])
elseif AAbs==1
卡克斯([0 1])
目标
如果NormUnits==1
标题(strcat(M: w=,num2str(FF(1 ii,length(k)/3), %.2f ))
xlabel(x (norm .单位))
ylabel(y (norm .单位))
elseif NormUnits==0
标题(strcat(M: \lambda=,num2str(lambda(1 ii,length(k)/3), %.2f ), um ))
xlabel(x (um))
ylabel(y (um))
目标
xlim([0 1.5*Np*Lx])
ylim([0 Np*Ly])
目标
对于ii=0:nmodes-1
对于i=1:Np
对于j=1:Np
子情节(nmodes,3,3,3 * ii)
继续
pcolor( Xhex (i-1 (j-1)/2)*Lx,Yhex (j-1)*Ly,EE(:ii 1,2*Nkx))
contour( Xhex (i-1 (j-1)/2)*Lx,Yhex (j-1)*Ly,abs(eps),1,’线宽,2,线条颜色, w )
目标
目标
遮光平板
%颜色条
如果RReal==1 IImag==1
卡克斯([-1 1])
elseif AAbs==1
卡克斯([0 1])
目标
如果NormUnits==1
title(strcat(K: w=,num2str(FF(1 ii,长度(k)*2/3), %.2f ))
xlabel(x (norm .单位))
ylabel(y (norm .单位))
elseif NormUnits==0
标题(strcat(K: \lambda=,num2str(lambda(1 ii,长度(k)*2/3), %.2f ), um ))
xlabel(x (um))
ylabel(y (um))
目标
xlim([0 1.5*Np*Lx])
ylim([0 Np*Ly])
目标
目标
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
如果==1
图(位置,[1100 50 500 400])
支线剧情(111)
继续
对于i=1:Np
对于j=1:Np
pcolor( Xhex (i-1 (j-1)/2)*Lx,Yhex (j-1)*Ly,real(eps))
目标
目标
遮光平板
彩色地图(喷射)
c=彩条
标题(c,“”)
如果NormUnits==1
xlabel(x (norm .单位))
ylabel(y (norm .单位))
elseif NormUnits==0
xlabel(x (um))
ylabel(y (um))
目标
%轴相等
目标
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
如果频段==1
图(位置,[50 570 900 450])
子情节(1,2,1)
坚持住;%网格打开;
plot(0:长度(k)-1,实数(FF(1:nmodes,), o-)
yscale=get(gca, ylim );
xlim([0长度(k)-1])
绘图([1/3 *长度1/3 *长度(k)],yscale, k )
绘图([2/3 *长度2/3 *长度(k)],yscale, k )
绘图([3/3 *长度(k)3/3 *长度(k)],yscale, k )
文本(0/3 *长度(k),-0.05*yscale(2), \Gamma )
文本(1/3 *长度(k),-0.05 * y刻度(2),“米”)
文本(2/3 *长度(K),-0.05 * y刻度(2),“K”)
文本(3/3 *长度(k),-0.05 * y刻度(2), \)
%xlabel(k )
set(gca, xticklabel ,[])
如果NormUnits==1
ylabel(w (2\pi/Ltot))
elseif NormUnits==0
ylabel(f (THz))
目标
title(strcat(R/a=,num2str(a),;n1=,num2str(n1, %.2f ),;n2=,num2str(n2, %.2f ))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
次要情节(1,2,2)
坚持住;网格打开;
LW=2;
对于I=1:n模式
plot3( k(:1)*Lx/pi,k(:2)*Ly/pi,real(FF(i,, o-)
目标
set(gca, xticklabel ,[])
set(gca, yticklabel ,[])
xlabel(kx (pi/Lx))
ylabel(ky (pi/Ly))
如果NormUnits==1
zlabel(w (2\pi/Ltot))
elseif NormUnits==0
zlabel(f (THz))
目标
视图(-30,15)
plot3( [-1 1]*2/3,[1 1],[0 0], r ,线宽,长)
plot3( [-1 1]*2/3,-[1 1],[0 0], r ,线宽,长)
绘图3( [1 2]*2/3,[1 0],[0 0], r ,线宽,长)
绘图3( [1 2]*2/3,-[1 0],[0 0], r ,线宽,长)
plot3( -[2 1]*2/3,-[0 1],[0 0], r ,线宽,长)
plot3( -[2 1]*2/3,[0 1],[0 0], r ,线宽,长)
plot3( [-1 1]*2/3,[1 1],[1 1]*max(实数(FF(nmodes),), r ,线宽,LW)
plot3( [-1 1]*2/3,-[1 1],[1 1]*max(实数(FF(nmodes),), r ,线宽,LW)
图3([1 ^ 2]* 2/3,[1 ^ 0],[1 ^ 1]* max(实数(FF(n模式),), r ,线宽,LW)
plot 3([1 ^ 2]* 2/3,-[1 ^ 0],[1 ^ 1]* max(实数(FF(nmodes,), r ,线宽,LW)
plot3( -[2 1]*2/3,-[0 1],[1 1]*max(实数(FF(nmodes),), r ,线宽,LW)
plot3( -[2 1]*2/3,[0 1],[1 1]*max(实数(FF(nmodes),), r ,线宽,LW)
plot3( [1 1]*2/3,[1 1],[0 1]*max(实数(FF(nmodes),), r ,线宽,LW)
plot3( [1 1]*2/3,-[1 1],[0 1]*max(实数(FF(nmodes,), r ,线宽,LW)
plot3( -[1 1]*2/3,[1 1],[0 1]*max(实数(FF(nmodes),), r ,线宽,LW)
plot3( -[1 1]*2/3,-[1 1],[0 1]*max(实数(FF(nmodes),), r ,线宽,LW)
plot3( 2*[1 1]*2/3,0*[1 1],[0 1]*max(实数(FF(nmodes,), r ,线宽,LW)
plot3( -2*[1 1]*2/3,0*[1 1],[0 1]*max(实数(FF(nmodes,), r ,线宽,LW)
目标
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % % % % % % % % % % % % % % END % % % END % % END % % END % % END % % END % % END % % END % % END % % END % % END % % END % % END % % END %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3运行结果
四参考文献[1]王磊。任意形状二维介质光子晶体特性研究d .电子科技大学, 2008.
[2]荣垂才,闫珂柱,谢应茂。二维光子晶体中场的分布[J]的缩写.激光技术, 2008.
郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。