MATLAB 光学仿真设计实验报告.docx
《MATLAB 光学仿真设计实验报告.docx》由会员分享,可在线阅读,更多相关《MATLAB 光学仿真设计实验报告.docx(25页珍藏版)》请在冰豆网上搜索。
MATLAB光学仿真设计实验报告
MATLAB光学仿真设计实验报告
实验一
代码:
clear;
clc;
i=sqrt(-1);
lm=1064e-9;
L=888*lm;
a=18*lm;
k=2*pi/lm;
x1=linspace(-a,a,1000);
Un_n=zeros(1,1000);
Un_1=ones(1,1000);
form=1:
1000
x=x1(m);
y=exp((-i*k*(x-x1).^2)/(2*L)).*Un_1;
Un_n(m)=sqrt(i/(lm*L)*exp(-i*k*L))*sum(y);
end
aaa=abs(Un_n);
yabsmax=max(aaa);
Un_n=Un_n/yabsmax;
Un_2=aaa/yabsmax;
Yn_2=angle(Un_n);
formmm=1:
299
forn=1:
1000
x=x1(n);
y=exp((-i*k*(x-x1).^2)/(2*L)).*Un_n;
Un_n_1(n)=sqrt(i/(lm*L)*exp(-i*k*L))*sum(y);
end
Un_n=Un_n_1;
aaa1=abs(Un_n);
yabsmax=max(aaa1);
Un_n=Un_n/yabsmax;
end
Un_300=aaa1/yabsmax;
Yn_300=angle(Un_n);
forn=1:
1000
x=x1(n);
y=exp((-i*k*(x-x1).^2)/(2*L)).*Un_n;
Un_n_1(n)=sqrt(i/(lm*L)*exp(-i*k*L))*sum(y);
end
Un_n=Un_n_1;
bbb=abs(Un_n);
yabsmax=max(bbb);
Un_n=Un_n/yabsmax;
Un_301=bbb/yabsmax;
Yn_301=angle(Un_n);
figure
(1);plot(Un_2);
holdon;
plot(Un_300,'r');
holdon;
plot(Un_301,'g');
xlabel('X');ylabel('振幅');
gridon;
axison;
axis([0,1000,0,1])
figure
(2);
plot(Yn_2);
holdon;
plot(Yn_300,'r');
holdon;
plot(Yn_301,'g');
xlabel('X');ylabel('相位');
gridon;
axison;
axis([0,1000,-0.5,2.5])
所得图像:
更改数据为:
L=666*lm;a=22*lm;
实验二:
代码:
clearall
clc
tao_p=1.6e-12;
tao_e=2.2e-9;
N0=1.1e8;
n_g=4;
c=3e8;
v_g=c/n_g;
Tao=0.3;
a=2.5e-20;
Nth=2.14e8;
n0=1e12;
w=2e-6;
L=250e-6;
d=0.2e-6;
V=w*L*d;
Gr=Tao*v_g*a;
beta_sp=1e-4;
B=1e-16;
ee=1.6e-19;
gama=1/tao_p;
gama_e=1/tao_e;
I=2e-2;
h=2e-12;
Th=h*(2^15);
tt=[0:
h:
Th];
M=length(tt);
tt=zeros(1,M+1);
P_0=zeros(1,M+1);
N=zeros(1,M+1);
P_0
(1)=3e2;
N
(1)=n0*V;
forii=1:
M
PK1=((Gr*(N(ii)/V-n0)-gama)*P_0(ii)+beta_sp*B*N(ii).^2/V);
NK1=(I/(ee)-gama_e*N(ii)-Gr*(N(ii)/V-n0)*P_0(ii));
PK2=((Gr*((N(ii)+h*NK1/2)/V-n0)-gama)*(P_0(ii)+h*PK1/2)+beta_sp*B*(N(ii)+h*NK1/2).^2/V);
NK2=(I/(ee)-gama_e*(N(ii)+h*NK1/2)-Gr*((N(ii)+h*NK1/2)/V-n0)*(P_0(ii)+h*PK1/2));
PK3=((Gr*((N(ii)+h*NK2/2)/V-n0)-gama)*(P_0(ii)+h*PK2/2)+beta_sp*B*(N(ii)+h*NK2/2).^2/V);
NK3=(I/(ee)-gama_e*(N(ii)+h*NK2/2)-Gr*((N(ii)+h*NK2/2)/V-n0)*(P_0(ii)+h*PK2/2));
PK4=((Gr*((N(ii)+h*NK3)/V-n0)-gama)*(P_0(ii)+h*PK3)+beta_sp*B*(N(ii)+h*NK3).^2/V);
NK4=(I/(ee)-gama_e*(N(ii)+h*NK3)-Gr*((N(ii)+h*NK3)/V-n0)*(P_0(ii)+h*PK3));
tt(ii+1)=tt(ii)+h;
P_0(ii+1)=P_0(ii)+(PK1+2*PK2+2*PK3+PK4)*h/6;
N(ii+1)=N(ii)+(NK1+2*NK2+2*NK3+NK4)*h/6;
end
figure
(1);plot(tt,N,'r');
ylabel('载流子数密度');
xlabel('时间');
gridon
figure
(2);
plot(tt,P_0,'g');
gridon
ylabel('光子数密度');
xlabel('时间');
所得图像:
改变参数为:
L=456e-6;
实验三:
代码:
clearall
clc
tao_p=1.6e-12;
tao_e=2.2e-9;
N0=1.1e8;
n_g=4;
c=3e8;
v_g=c/n_g;
Tao=0.3;
a=2.5e-20;
Nth=2.14e8;
n0=1e12;
w=2e-6;
L=250e-6;
d=0.2e-6;
V=w*L*d;
Gr=Tao*v_g*a;
beta_sp=1e-4;
B=1e-16;
ee=1.6e-19;
gama=1/tao_p;
gama_e=1/tao_e;
I0=9e-2;
h=2e-12;
Th=h*(2^17);
tt=[0:
h:
Th];
M=length(tt);
tt=zeros(1,M+1);
P_0=zeros(1,M+1);
N=zeros(1,M+1);
P_0
(1)=3e2;
N
(1)=n0*V;
Am=0.9;
fm=0.01e9;
forii=1:
M
I=I0*(1+Am*sin(2*pi*fm*tt(ii));
PK1=((Gr*(N(ii)/V-n0)-gama)*P_0(ii)+beta_sp*B*N(ii).^2/V);
NK1=(I/(ee)-gama_e*N(ii)-Gr*(N(ii)/V-n0)*P_0(ii));
PK2=((Gr*((N(ii)+h*NK1/2)/V-n0)-gama)*(P_0(ii)+h*PK1/2)+beta_sp*B*(N(ii)+h*NK1/2).^2/V);
NK2=(I/(ee)-gama_e*(N(ii)+h*NK1/2)-Gr*((N(ii)+h*NK1/2)/V-n0)*(P_0(ii)+h*PK1/2));
PK3=((Gr*((N(ii)+h*NK2/2)/V-n0)-gama)*(P_0(ii)+h*PK2/2)+beta_sp*B*(N(ii)+h*NK2/2).^2/V);
NK3=(I/(ee)-gama_e*(N(ii)+h*NK2/2)-Gr*((N(ii)+h*NK2/2)/V-n0)*(P_0(ii)+h*PK2/2));
PK4=((Gr*((N(ii)+h*NK3)/V-n0)-gama)*(P_0(ii)+h*PK3)+beta_sp*B*(N(ii)+h*NK3).^2/V);
NK4=(I/(ee)-gama_e*(N(ii)+h*NK3)-Gr*((N(ii)+h*NK3)/V-n0)*(P_0(ii)+h*PK3));
tt(ii+1)=tt(ii)+h;
P_0(ii+1)=P_0(ii)+(PK1+2*PK2+2*PK3+PK4)*h/6;
N(ii+1)=N(ii)+(NK1+2*NK2+2*NK3+NK4)*h/6;
end
figure
(1);plot(tt,N,'r');
ylabel('载流子数密度');
xlabel('时间');
gridon
figure
(2);
plot(tt,P_0,'g');
gridon
ylabel('光子数密度');
xlabel('时间');
所得图像:
方波:
I=I0*[1+Am*square((2*pi*fm*tt(ii)),50)];
更改参数:
Am=5;fm=0.2*10^9;
实验四:
代码:
clearall
clc
tao_p=1.6e-12;
tao_e=2.2e-9;
N0=1.1e8;
n_g=4;
c=3e8;
v_g=c/n_g;
Tao=0.3;
a=2.5e-20;
Nth=2.14e8;
n0=1e12;
w=2e-6;
L=250e-6;
d=0.2e-6;
V=w*L*d;
Gr=Tao*v_g*a;
beta_sp=1e-4;
B=1e-16;
ee=1.6e-19;
gama=1/tao_p;
gama_e=1/tao_e;
I0=9e-2;
h=2e-12;
Th=h*(2^17);
tt=[0:
h:
Th];
M=length(tt);
tt=zeros(1,M+1);
P_0=zeros(1,M+1);
N=zeros(1,M+1);
P_0
(1)=3e2;
N
(1)=n0*V;
Am=0.9;
fm=0.01e9;
forii=1:
M
I=I0*(1+Am*sin(2*pi*fm*tt(ii));
PK1=((Gr*(N(ii)/V-n0)-gama)*P_0(ii)+beta_sp*B*N(ii).^2/V);
NK1=(I/(ee)-gama_e*N(ii)-Gr*(N(ii)/V-n0)*P_0(ii));
PK2=((Gr*((N(ii)+h*NK1/2)/V-n0)-gama)*(P_0(ii)+h*PK1/2)+beta_sp*B*(N(ii)+h*NK1/2).^2/V);
NK2=(I/(ee)-gama_e*(N(ii)+h*NK1/2)-Gr*((N(ii)+h*NK1/2)/V-n0)*(P_0(ii)+h*PK1/2));
PK3=((Gr*((N(ii)+h*NK2/2)/V-n0)-gama)*(P_0(ii)+h*PK2/2)+beta_sp*B*(N(ii)+h*NK2/2).^2/V);
NK3=(I/(ee)-gama_e*(N(ii)+h*NK2/2)-Gr*((N(ii)+h*NK2/2)/V-n0)*(P_0(ii)+h*PK2/2));
PK4=((Gr*((N(ii)+h*NK3)/V-n0)-gama)*(P_0(ii)+h*PK3)+beta_sp*B*(N(ii)+h*NK3).^2/V);
NK4=(I/(ee)-gama_e*(N(ii)+h*NK3)-Gr*((N(ii)+h*NK3)/V-n0)*(P_0(ii)+h*PK3));
tt(ii+1)=tt(ii)+h;
P_0(ii+1)=P_0(ii)+(PK1+2*PK2+2*PK3+PK4)*h/6;
N(ii+1)=N(ii)+(NK1+2*NK2+2*NK3+NK4)*h/6;
end
figure
(1);plot(tt,N,'r');
ylabel('载流子数密度');
xlabel('时间');
gridon
figure
(2);
plot(tt,P_0,'g');
gridon
ylabel('光子数密度');
xlabel('时间');
[WA1,wwl]=powerspectrum(abs(P_0(end-10000:
end)).^2,h);
Wall=10*log(WA1);
figure(3);
plot(wwl*1e-9,Wall);
%调用函数%
function[WA,ww]=powerspectrum(S,h)
Aaa=S;
St=1/h
RR1=(Aaa(1:
length(Aaa)-1));
N=length(RR1);
Wq=fft(RR1);
Wq
(1)=0;
WA=(abs(Wq(1:
N/2)));
ww=St*(0:
N/2-1)/N;
所得图像:
把代码中的I=I0*(1+Am*sin(2*pi*fm*tt(ii))换成I=I0*(1+Am*square(2*pi*fm*tt(ii),50)),即把正弦信号换成方波信号,改变其他参数,调整成输出方波,所得图像:
实验五:
代码:
clearall
clc
u=2;
a=2.2;
gama_s=1000*1e9;
k=125*1e9;
gama_p=192*1e9;
gama_a=0.02*1e9;
gama_N=0.67*1e9;
h=2e-12;
Th=h*(2^15);
tt=[0:
h:
Th];
M=length(tt);
tt=zeros(1,M+1);
E_x=zeros(1,M+1);
E_y=zeros(1,M+1);
N=zeros(1,M+1);
n=zeros(1,M+1);
E_x
(1)=0.03;
E_y
(1)=0.06;
N
(1)=1.003;
n
(1)=0.00003;
forii=1:
M
P=abs(E_x(ii)).^2+abs(E_y(ii)).^2;
E_x1=k*(1+i*a)*((N(ii)-1).*E_x(ii)+i*n(ii).*E_y(ii))-(gama_a+i*gama_p)*E_x(ii);
E_y1=k*(1+i*a)*((N(ii)-1).*E_y(ii)-i*n(ii).*E_x(ii))+(gama_a+i*gama_p)*E_y(ii);
N1=gama_N*(u-N(ii).*(1+P)-i*n(ii).*(E_y(ii).*conj(E_x(ii))-E_x(ii).*conj(E_y(ii))));
n1=-gama_s*n(ii)-gama_N*(n(ii)*P+i*N(ii).*(E_y(ii).*conj(E_x(ii))-E_x(ii).*conj(E_y(ii))));E_x2=k*(1+i*a)*((N(ii)+h*N1/2-1).*(E_x(ii)+h.*E_x1/2)+i*(n(ii)+h*n1/2).*(E_y(ii)+h*E_y1/2))-(gama_a+i*gama_p)*(E_x(ii)+h*E_x1/2);E_y2=k*(1+i*a)*((N(ii)+h*N1/2-1).*(E_y(ii)+h.*E_x1/2)-i*(n(ii)+h*n1/2).*(E_x(ii)+h*E_x1/2))+(gama_a+i*gama_p)*(E_y(ii)+h*E_y1/2);N2=gama_N*(u-(N(ii)+h*N1/2).*(1+P)-i*(n(ii)+h*n1/2).*((E_y(ii)+h.*E_y1/2).*conj((E_x(ii)+h*E_x1/2))-(E_x(ii)+h*E_x1/2).*conj((E_y(ii)+h.*E_y1/2))));n2=-gama_s*(n(ii)+h*n1/2)-gama_N*((n(ii)+h*n1/2).*P+i*(N(ii)+h*N1/2).*((E_y(ii)+h*E_y1/2).*conj((E_x(ii)+h*E_x1/2))-(E_x(ii)+h*E_x1/2).*conj((E_y(ii)+h*E_y1/2))));E_x3=k*(1+i*a)*((N(ii)+h*N2/2-1).*(E_x(ii)+h*E_x2/2)+i*(n(ii)+h*n2/2).*(E_y(ii)+h*E_y2/2))-(gama_a+i*gama_p).*(E_x(ii)+h*E_x2/2);E_y3=k*(1+i*a)*((N(ii)+h*N2/2-1).*(E_y(ii)+h*E_x2/2)-i*(n(ii)+h*n2/2).*(E_x(ii)+h*E_x2/2))+(gama_a+i*gama_p).*(E_y(ii)+h*E_y2/2);N3=gama_N*(u-(N(ii)+h*N2/2).*(1+P)-i*(n(ii)+h*n2/2).*((E_y(ii)+h*E_y2/2).*conj((E_x(ii)+h*E_x2/2))-(E_x(ii)+h*E_x2/2).*conj((E_y(ii)+h*E_y2/2))));n3=-gama_s*(n(ii)+h*n2/2)-gama_N*((n(ii)+h*n2/2).*P+i*(N(ii)+h*N2/2).*((E_y(ii)+h*E_y2/2).*conj((E_x(ii)+h*E_x2/2))-(E_x(ii)+h*E_x2/2).*conj((E_y(ii)+h*E_y2/2))));E_x4=k*(1+i*a)*((N(ii)+h*N3-1).*(E_x(ii)+h*E_x3)+i*(n(ii)+h*n3).*(E_y(ii)+h*E_y3))-(gama_a+i*gama_p)*(E_x(ii)+h*E_x3);E_y4=k*(1+i*a)*((N(ii)+h*N3-1).*(E_y(ii)+h*E_x3)-i*(n(ii)+h*n3).*(E_x(ii)+h*E_x3))+(gama_a+i*gama_p)*(E_y(ii)+h*E_y3);
N4=gama_N*(u-(N(ii)+h*N3).*(1+P)-i*(n(ii)+h*n3).*((E_y(ii)+h*E_y3).*conj((E_x(ii)+h*E_x3))-(E_x(ii)+h*E_x3).*conj((E_y(ii)+h*E_y3))));n4=-gama_s*(n(ii)+h*n3)-gama_N*((n(ii)+h*n3)*P+i*(N(ii)+h*N3).*((E_y(ii)+h*E_y3).*conj((E_x(ii)+h*E_x3))-(E_x(ii)+h*E_x3).*conj((E_y(ii)+h*E_y3))));
tt(ii+1)=tt(ii)+h;
E_x(ii+1)=E_x(ii)+(E_x1+2*E_x2+2*E_x3+E_x4)*h/6;
E_y(ii+1)=E_y(ii)+(E_y1+2*E_y2+2*E_y3+E_y4)*h/6;
N(ii+1)=N(ii)+(N1+2*N2+2*N3+N4)*h/6;
n(ii+1)=n(ii)+(n1+2*n2+2*n3+n4)*h/6;
figure(3);plot(tt,N,'black');
xlabel('时间');
ylabel('总载流子密度');
gridon
figure(4);plot(tt,n,'b');
xlabel('时间');
ylabel('反转载流子密度差值');
gridon
end
figure
(1);plot(tt,abs(Ex).^2,'r');
xlabel('时间');
ylabel('X线偏振模');
gridon
figure
(2);plot(tt,abs(Ey).^2,'g');
xlabel('时间');
ylabel('Y线偏振模');
gridon
所得图像:
加入正弦调制,将u=2;变成下面的u即可:
forii=1:
M
u=2*(0.8+0.2*sin(0.2*pi*1e9*tt(ii)));
p=abs(Ex(ii)).^2+abs(Ey(ii)).^2;
实验六:
代码:
clearall
clc
u=2;
a=2.2;
gama_s=1e12;;
k=125*1e9;
gama_p=192*1e9;
gama_a=0.02*1e9;
gama_N=0.67*1e9;
eta=10e9;
tao=3e-9;
w=1.22e15;
h=2e-12;
Th=h*(2^15);
tt=[0:
h:
Th];
tm=length([0:
h:
tao]);
M=length(tt);
tt=zeros(1,M+1);
E_x=zeros(1,M+1);
E_y=zeros(1,M+1);
N=zeros(1,M+1);
n=zeros(1,M+1);
E_x
(1)=0.03;
E_y
(1)=0.06;
N
(1)=1.003;
n
(1)=0.00003;
forii=1:
M
iftt(ii)P=abs(E_x(ii)).^2+abs(E_y(ii)).^2;
E_x1=k*(1+i*a)*((N(ii)-1).*E_x(ii)+i*n(ii).*E_y(ii))-(gama_a+i*gama_p)*E_x(ii);
E_y1=k*(1+i*a)*((N(ii)-1).*E_y(ii)-i*n(ii).*E_x(ii))+(gama_a+i*gama_p)*E_y(ii);
N1=gama_N*(u-N(ii).*(1+P)-i*n(ii).*(E_y(ii).*conj(E_x(ii))-E_x(ii).*conj(E_y(ii))));
n1=-gama_s*n(ii)-gama_N*(n(ii)*P+i*N(ii).*(E_y(ii).*conj(E_x(ii))-E_x(ii).*conj(E_y(ii))));E_x2=k*(1+i*a)*((N(ii)+h*N1/2-1).*(E_x(ii)+h.*E_x1/2)+i*(n(ii)+h*n1/2).*(E_y(ii)+h*E_y1/2))-(gama_a+i*gama_p)*(E_x(ii)+h*E_x1/2);E_y2=k*(1+i*a)*((N(ii)+h*N1/2-1).*(E_y(ii)+h.*E_x1/2)-i*(n(ii)+h*n1/2).*(E_x(ii)+h*E_x1/2))+(gama_a+i*gama_p)*(E_y(ii)+h*E_y1/2);N2=gama_N*(u-(N(ii)+h*N1/2).*(1+P)-i*(n(ii)+h*n1/2).*((E_y(ii)+h.*E_y1/2).*conj((E_x(ii)+h*E_x1/2))-(E_x(ii)+h*E_x1/2)