?? on the synthesis of fiber bragg gratings by layer peeling.m
字號(hào):
%%%%%參照文獻(xiàn)《on the synthesis of fiber bragg grating by layer
%%%%%peeling》中第一個(gè)例子編寫的程序,用自己編寫的傅立葉程序變換
%%%%已試驗(yàn)成功,謹(jǐn)慎修改
clear all
clc
Neff=1.446;
L=10; %%%光柵長(zhǎng)10cm
N=500;
delta=L/N; %%%分成500層
Lm=linspace(0,10,N);
M=1000;
step=4/(M-1);
wvl=[1548:step:1552]*1e-7; %%%4nm的波長(zhǎng)范圍分成1000個(gè)點(diǎn)
wvlD=1550*1e-7;
deviate=2*pi*Neff*(1./wvl-1/wvlD); %%%失諧量
t=linspace(-20,20,M);
dw=157/(M-1);
dt=40/(M-1);
alpha=zeros(1,N); %%%用于存欲求的Rho
q=zeros(1,N); %%%用于存欲求的耦合系數(shù)
r=zeros(N,M); %%%用于存500個(gè)反射譜
r(1,:)=sqrt(0.9)*exp(-(deviate/19.2).^20); %%%理想反射譜
%figure,plot(deviate,r(1,:))
%h=r*exp(i*deviate'*t)/(2*pi)*dw; %%%傅立葉變換到時(shí)域
h1=r(1,:)*exp(i*deviate'*(t-10))/(2*pi)*dw; %%%平移
win=sin(2*pi*t/40); %%%漢寧窗
h2=h1.*win;
h3=h2(M/2:M-1); %%%提取【0 10】的部分
h4=h3(N/4:3*N/4-1);
t3=linspace(0,20,M/2);
t4=linspace(5,15,N/2);
%figure,plot(t4,real(h4))
r(1,:)=h4*exp(i*t4'*deviate)*dt; %%%反變換到頻域,求得物理可實(shí)現(xiàn)譜
%figure,plot(deviate,abs(r(1,:)))
%%%%%%求q
ph=exp(-i*2*(deviate)*delta);
for n=1:N
rs=sum(r'); %%%求和
alpha(1,n)=rs(1,n)/M; %%%文獻(xiàn)中的(9)式
qabs=-atanh(abs(alpha(1,n)))/delta;
qphase=-phase(alpha(1,n));
q(1,n)=qabs*exp(i*qphase);
r(n+1,:)=ph.*((r(n,:)-alpha(1,n))./(1-conj(alpha(1,n))*r(n,:)));
end
figure,plot(Lm,real(q)) %%%%
%%%%%用傳輸矩陣法,求反射譜,參照文獻(xiàn)《on the synthesis of fiber bragg grating by layer
%%%%%peeling》
for j=1:M
Matrix_g=[1,0;0,1];
for k=1:N
kac=q(1,k);
delta1=deviate(1,j);
alpha=sqrt(abs(kac)^2-delta1^2);
alphaL=alpha.*delta;
T11=cosh(alphaL)+i*(delta1/alpha)*sinh(alphaL);
T12=(kac/alpha)*sinh(alphaL);
T21=(conj(kac)/alpha)*sinh(alphaL);
T22=cosh(alphaL)-i*(delta1/alpha)*sinh(alphaL);
Matrix_g=Matrix_g*[T11,T12;T21,T22];
end
TT11=Matrix_g(1);TT12=Matrix_g(3);TT21=Matrix_g(2);TT22=Matrix_g(4);
reflect=-TT21/TT11;
Reflectivity(j)=(abs(reflect)).^2;
Q(j)=phase(reflect);
end
figure,plot(wvl,10*log10(Reflectivity)) %%%%畫反射譜,縱軸單位為 db時(shí),用這個(gè)方法比peeling中的好
%%%%%%%%求時(shí)延
P(1)=Q(1);P(2)=Q(2);P(3)=Q(3); %%%求導(dǎo)就是求斜率
for l=4:M;
if(abs(Q(l-1)-Q(l))<=4.5) %%%為什么是4.5???
P(l)=((wvl(1))^2/(2*pi*3e8))*((Q(l-1)-Q(l))/(step*1e-9)); %%%%公式見(jiàn)《fiber grating spectra》(32)
else
P(l)=((wvl(1))^2/(2*pi*3e8))*((Q(l-3)-Q(l-2))/(step*1e-9));
end
temp_lamda(l-3)=wvl(l);
temp_Delay(l-3)=-P(l);
end
Delay=10^12*temp_Delay;
figure,plot(temp_lamda,Delay)
%%%%%%用自己編寫的程序,實(shí)現(xiàn)《on the synthesis of fiber bragg grating by layer
%%%%%%peeling》中第二個(gè)例子
%%%%已經(jīng)試驗(yàn)成功,謹(jǐn)慎修改
clear all
clc
Neff=1.446;
L=12; %%%光柵長(zhǎng)10cm
N=600;
delta=L/N; %%%分成500層
Lm=linspace(0,12,N);
M=1200;
step=4/(M-1);
wvl=[1548:step:1552]*1e-7; %%%4nm的波長(zhǎng)范圍分成1000個(gè)點(diǎn)
wvlD=1550*1e-7;
deviate=2*pi*Neff*(1./wvl-1/wvlD); %%%失諧量
t=linspace(-24,24,M);
dw=157/(M-1);
dt=48/(M-1);
alpha=zeros(1,N); %%%用于存欲求的Rho
q=zeros(1,N); %%%用于存欲求的耦合系數(shù)
r=zeros(N,M); %%%用于存500個(gè)反射譜
r(1,:)=sqrt(0.9)*exp(-(deviate/12.3).^2).*exp(-i*0.13*deviate.^2);%%%理想反射譜,s=10.^12ps
figure,plot(wvl,abs(r(1,:)))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%未平移
%h=r(1,:)*exp(i*deviate'*(t))/(2*pi)*dw; %%%傅立葉變換到時(shí)域
%figure,plot(t,real(h))
%win_1=exp(-4*log(2)*(t).^2/(12)); %%%高斯窗
%win_1=0.5*(1+cos(2*pi*(t)/24)); %%%升余弦窗
%figure,plot(t,win_1)
%h_1=h.*win_1;
%figure,plot(t,real(h_1))
%r(1,:)=h_1*exp(i*(t)'*deviate)*dt;
%figure,plot(deviate,abs(r(1,:)))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%平移
h1=r(1,:)*exp(i*deviate'*(t-12))/(2*pi)*dw;
%figure,plot(t,real(h1))
win=exp(-4*log(2)*(t-12).^2/(8)); %%%漢寧窗
%win=0.5*(1+cos(2*pi*(t-12)/12)); %%%%升余弦窗
h2=h1.*win;
h3=h2(M/2:M-1); %%%提取【0 10】的部分
h4=h3(N/4:3*N/4-1);
t3=linspace(0,24,M/2);
%figure,plot(t3,real(h3))
%t4=linspace(6,18,N/2);
%figure,plot(t4,real(h4))
r(1,:)=h4*exp(i*t4'*deviate)*dt; %%%反變換到頻域,求得物理可實(shí)現(xiàn)譜
figure,plot(wvl,abs(r(1,:)))
%%%%%求q
ph=exp(-i*2*(deviate)*delta);
for n=1:N
rs=sum(r'); %%%求和
alpha(1,n)=rs(1,n)/M; %%%文獻(xiàn)中的(9)式
qabs=-atanh(abs(alpha(1,n)))/delta;
qphase=-phase(alpha(1,n));
q(1,n)=qabs*exp(i*qphase);
r(n+1,:)=ph.*((r(n,:)-alpha(1,n))./(1-conj(alpha(1,n))*r(n,:)));
end
figure,plot(Lm,abs(q)) %%%%
%win_q=exp(-4*log(2)*(Lm-6).^2/(8));
%figure,plot(Lm,win_q)
%q1=q.*win_q;
%figure,plot(Lm,abs(q1))
%%%%%%%求反射譜
for j=1:M
Matrix_g=[1,0;0,1];
for k=1:N
kac=q(1,k);
delta1=deviate(1,j);
alpha=sqrt(abs(kac)^2-delta1^2);
alphaL=alpha.*delta;
T11=cosh(alphaL)+i*(delta1/alpha)*sinh(alphaL);
T12=(kac/alpha)*sinh(alphaL);
T21=(conj(kac)/alpha)*sinh(alphaL);
T22=cosh(alphaL)-i*(delta1/alpha)*sinh(alphaL);
Matrix_g=Matrix_g*[T11,T12;T21,T22];
end
TT11=Matrix_g(1);TT12=Matrix_g(3);TT21=Matrix_g(2);TT22=Matrix_g(4);
reflect=-TT21/TT11;
Reflectivity(j)=(abs(reflect)).^2;
Q(j)=phase(reflect);
end
figure,plot(deviate,10*log10(Reflectivity)) %%%%畫反射譜,縱軸單位為 db時(shí),用這個(gè)方法比peeling中的好%%
%%%%%%%%%%%%%%%求時(shí)延
P(1)=Q(1);P(2)=Q(2);P(3)=Q(3); %%%求導(dǎo)就是求斜率
for l=4:M;
if(abs(Q(l-1)-Q(l))<=4) %%%為什么是4.5???
P(l)=((wvl(1))^2/(2*pi*3e8))*((Q(l-1)-Q(l))/(step*1e-9)); %%%%公式見(jiàn)《fiber grating spectra》(32)
else
P(l)=((wvl(1))^2/(2*pi*3e8))*((Q(l-3)-Q(l-2))/(step*1e-9));
end
temp_lamda(l-3)=wvl(l);
temp_Delay(l-3)=-P(l);
end
Delay=10^8*temp_Delay;
figure,plot(temp_lamda,Delay)
axis([1.5495e-4 1.5505e-4 0 1000])
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -