%%
clear,clc
close all
a=[0.202 0.206 0.210 0.214 0.219 0.224 0.226 0.228 0.231 0.257 0.274 0.283 ...
0.293 0.313 0.325 0.340 0.361 0.441 0.467 0.480 0.508 0.589 0.643 ];%um
b1=[0.321 0.253 0.193 0.124 0.074 0.017 -0.008 -0.027 -0.052 -0.186 -0.235 ...
-0.279 -0.311 -0.348 -0.352 -0.393 -0.418 -0.475 -0.485 -0.499 -0.514 -0.530 -0.549];%10^-5/C
b2=[0.267 0.193 0.143 0.083 0.027 -0.048 -0.075 -0.093 -0.112 -0.265 -0.323 ...
-0.385 -0.415 -0.450 -0.469 -0.591 -0.521 -0.593 -0.601 -0.610 -0.616 -0.642 -0.653];%10^-5/C
% plot(a ,[b1 ;b2;b2-b1])
p=polyfit(a,b2-b1,4);%15
% plot(a,[b2-b1;polyval(p,a)] )
%% 目标函数:
close all
lamda_1 = 202 :643;%nm
lamda_2 = 0.202: 0.643;
sigma1=pi/2 ;%rad
% sigma2=239*pi/180 ;%rad 90~270 0.5~1.5pi
% theta=72.2*pi/180 ;%rad
Sig2 = (90:0.5:270)/180*pi;%rad
Tall = -10:0.5:80;
data = zeros( numel(Tall),numel(Sig2) );
lamda0=400;%nm
f_e_o_400=polyval( p,0.4 );
f_e_o_lam=polyval( p,lamda_2);
for i = 1:numel(Tall) ;%t+273;
for j = 1:numel(Sig2)
T = Tall(i);
sigma2 = Sig2(j);
theta = 0.5*acos(-sqrt(2)/2*abs(sin(sigma2/2)));% rad
delta_n = 0.00887+0.01827*exp(-lamda0/0.12096) + (T-23)*(f_e_o_400)*10^-5;% 400 nm -> T
delta_n_1 =0.00887+0.01827*exp(-lamda_1/0.12096)+ (T-23)*(f_e_o_lam)*10^-5;
P1=sigma1*lamda0*delta_n_1./(lamda_1*delta_n);
P2=sigma2*lamda0*delta_n_1./(2*lamda_1*delta_n);
sigma_1=2*acos(cos(P1).*cos(P2)-sin(P1).*sin(P2)*cos(2*theta) )/pi*180;
%% 判断 条件
tem = sigma_1>=90*0.98 & sigma_1<=90;
dd = diff(tem);
tem1 = find(dd==1);tem2 = find(dd(2:end)==-1) ;
if tem(end)==1
tem2 = [tem2 numel(dd)];
end
data(i,j) = max([tem2- tem1,0]);
%%
% if data(i,j)==28
% plot(lamda_1,sigma_1)
% hold on
% plot(lamda_1([1,end]),[0.98 0.98]*90)%,'--')
% title(['temperature :' num2str(T)])
% xlabel('波长/nm')
% ylabel('延迟量/角度')
% pause(0.1)
% end
end
end
%%
fprintf('最长的消色差范围:%d \n',max(max(data)))
[xx,yy]=meshgrid(Sig2,Tall);
mesh(xx,yy,data),xlabel('sigma2 /rad'),ylabel('T /C摄氏度'),zlabel('消色差范围/nm')
title(['sigma2搜索步长:' num2str(diff(Sig2(1:2))) 'T 温度 搜索步长:' num2str(diff(Tall(1:2))) ])
%%
%% 改变 sigma2 T 温度 搜索步长
close all
Sig2 = 3:0.01:3.3;%rad
Tall = -10:0.1:80;
data = zeros( numel(Tall),numel(Sig2) );
for i = 1:numel(Tall) ;%t+273;
for j = 1:numel(Sig2)
T = Tall(i);
sigma2 = Sig2(j);
theta = 0.5*acos(-sqrt(2)/2*abs(sin(sigma2/2)));% rad
delta_n = 0.00887+0.01827*exp(-lamda0/0.12096) + (T-23)*(f_e_o_400)*10^-5;% 400 nm -> T
delta_n_1 =0.00887+0.01827*exp(-lamda_1/0.12096)+ (T-23)*(f_e_o_lam)*10^-5;
P1=sigma1*lamda0*delta_n_1./(lamda_1*delta_n);
P2=sigma2*lamda0*delta_n_1./(2*lamda_1*delta_n);
sigma_1=2*acos(cos(P1).*cos(P2)-sin(P1).*sin(P2)*cos(2*theta) )/pi*180;
%% 判断 条件
tem = sigma_1>=90*0.98 & sigma_1<=90;
dd = diff(tem);
tem1 = find(dd==1);tem2 = find(dd(2:end)==-1) ;
if tem(end)==1
tem2 = [tem2 numel(dd)];
end
data(i,j) = max([tem2- tem1,0]);
%%
% if data(i,j)==28
% plot(lamda_1,sigma_1)
% hold on
% plot(lamda_1([1,end]),[0.98 0.98]*90)%,'--')
% title(['temperature :' num2str(T)])
% xlabel('波长/nm')
% ylabel('延迟量/角度')
% pause(0.1)
% end
end
end
%%
fprintf('最长的消色差范围:%d \n',max(max(data)))
[xx,yy]=meshgrid(Sig2,Tall);
mesh(xx,yy,data),xlabel('sigma2 /rad'),ylabel('T /C摄氏度'),zlabel('消色差范围/nm')
title(['精细搜索: sigma2搜索步长:' num2str(diff(Sig2(1:2))) 'T 温度 搜索步长:' num2str(diff(Tall(1:2))) ])