# MATLAB代做-python代做-FPGA代做-光子晶体光纤中模场的分布是准二维的

### 时间：2019-5-26 1:06:45 点击：

核心提示：MATLAB代做-python代做-FPGA代做-光子晶体光纤中模场的分布是准二维的 ...
```clc;
clear;
warning off;

mu0=4*pi*10^(-7);  %��մŵ���
epsilon0=8.85*10^(-12);    %��ս�糣��
n_slab=1.45;
n_air=1;
n_slab2=n_slab^2;
n_air2=n_air^1;
n_average=(n_slab2+n_air2)/2;
epsilon_slab=n_slab2*epsilon0;
epsilon_air=n_air2*epsilon0;
epsilon_average=(n_slab2+n_air2)*epsilon0/2;
%z_slab2=mu0/epsilon_slab;
z_air2=mu0/epsilon0;

pitch=1.8e-6;         % �ն����ĵļ��
ddx=0.7e-6/13;               %�ռ䲽��
kz=15/pitch;    %  �������򴫲�����
dt=0.95/(3e8*sqrt((2/ddx^2)+(kz/2)^2)); %����ʱ�䲽��

a=ceil(pitch/ddx);    % �ն����ĵļ���������
%pitchs=1.5e-6;          %�ڲ�ȱ�ݿ�����
%as=ceil(pitchs/ddx);
%ds=1.4e-6;
d1=pitch*0.3;
d2=pitch*0.3;
d3=pitch*0.3;
d4=pitch*0.3;
%rs=ceil(ds/2/ddx);
r1=ceil(d1/2/ddx);   % x/y/z �൱��x/(y*z)
r2=ceil(d2/2/ddx);
r3=ceil(d3/2/ddx);
r4=ceil(d4/2/ddx);

layer=4;       %���ڰ�������ײ���
npml=8;              % PML����

I=(layer+1)*2*a+2*npml; % ��������
J=I;
ic=I/2;jc=J/2;        % I,J������ż����ic,jc,kc�ŷ����±�Ҫ��

spread=round(0.8e-6/6e8/dt);            % ��Դ���� ��ʱ���һ��
t0=round(4*spread+0.5)-1;                %��������  ��ʱ���һ��
r0=100;

%---------���������Ų���

para=zeros(I,J,6);  %��һ����糣�� �ڶ����ŵ�ϵ�� �������ĸ��絼��(x,y) ���塢����������(x,y)
xn_max=1/(30*n_slab*pi*ddx);  % xn�൱�ڵ絼��  ��糣��ȡ�����ֵ
for i=1:I;
for j=1:J;
para(i,j,2)=mu0;
para(i,j,1)=epsilon_slab; %��ȫ���óɹ�Ľ�糣��
end
end

%����PML�߽�
for i=1:npml;
xnum=npml-i+1;
xxn=xnum/npml;
xn=xn_max*(xxn^4); % ����絼�� ָ��Ϊ4
xm=z_air2*xn;  % ���嵼����
for j=1:J;
para(i,j,3)=xn;
para(i,j,5)=xm;
para(I-i+1,j,3)=xn;
para(I-i+1,j,5)=xm;
para(j,i,4)=xn;
para(j,i,6)=xm;
para(j,I-i+1,4)=xn;
para(j,I-i+1,6)=xm;
end
end

%���ù��Ӿ���������ڲ���

%��һ�У�wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
for j=jc;
for i=jc;   %for i=jc:a:jc+a;
for i1=-r1:r1;
for j1=-r1:r1;
if sqrt(i1^2+j1^2)<r1;
para(round(i+i1),round(j+j1),1)=epsilon_air;
end
end
end
for i1=-r1-1:r1+1;
for j1=-r1-1:r1+1;
if para(i+i1,j+j1,1)==epsilon_air & (para(i+i1-1,j+j1,1)==epsilon_slab | para(i+i1+1,j+j1,1)==epsilon_slab | para(i+i1,j+j1-1,1)==epsilon_slab | para(i+i1,j+j1+1,1)==epsilon_slab);
para(i+i1,j+j1,1)=epsilon_average;
end
end
end  %���y��ݽ���
end
end

for j=jc;%r2=3;
for i=jc+2*a;
for i1=-r2:r2;
for j1=-r2:r2;
if(sqrt(i1^2+j1^2)<r1);
para(round(i+i1),round(j+j1),1)=n_air2*epsilon0;
end
end
end
for i1=-r2:r2;
for j1=-r2:r2;
if para(i+i1,j+j1,1)==epsilon_air & (para(i+i1-1,j+j1,1)==epsilon_slab | para(i+i1+1,j+j1,1)==epsilon_slab | para(i+i1,j+j1-1,1)==epsilon_slab | para(i+i1,j+j1+1,1)==epsilon_slab);
para(round(i+i1),round(j+j1),1)=epsilon_average;
end
end
end  %���y��ݽ���
end
end

for j=jc;%r3=4;
for i=jc+3*a;
for i1=-r3:r3;
for j1=-r3:r3;
if(sqrt(i1^2+j1^2)<r2);
para(round(i+i1),round(j+j1),1)=n_air2*epsilon0;
end
end
end
for i1=-r3:r3;
for j1=-r3:r3;
if para(i+i1,j+j1,1)==epsilon_air & (para(i+i1-1,j+j1,1)==epsilon_slab | para(i+i1+1,j+j1,1)==epsilon_slab | para(i+i1,j+j1-1,1)==epsilon_slab | para(i+i1,j+j1+1,1)==epsilon_slab);
para(round(i+i1),round(j+j1),1)=epsilon_average;
end
end
end %���y��ݽ���
end
end

for j=jc;%r4=5
for i=jc+4*a;
for i1=-r4:r4;
for j1=-r4:r4;
if(sqrt(i1^2+j1^2)<r2);
para(round(i+i1),round(j+j1),1)=n_air2*epsilon0;
end
end
end
for i1=-r4:r4;
for j1=-r4:r4;
if para(i+i1,j+j1,1)==epsilon_air & (para(i+i1-1,j+j1,1)==epsilon_slab | para(i+i1+1,j+j1,1)==epsilon_slab | para(i+i1,j+j1-1,1)==epsilon_slab | para(i+i1,j+j1+1,1)==epsilon_slab);
para(round(i+i1),round(j+j1),1)=epsilon_average;
end
end
end %���y��ݽ���
end
end

%�ڶ��У�wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
w1=sqrt(3)/2*a;w2=a/2;
for j=jc+w1;%r1=2;
for i=jc+w2;
for i1=-r1:r1;
for j1=-r1:r1;
if(sqrt(i1^2+j1^2)<r1);
para(round(i+i1),round(j+j1),1)=n_air2*epsilon0;
end
end
end
for i1=-r1-1:r1+1;
for j1=-r1-1:r1+1;
if para(round(i+i1),round(j+j1),1)==epsilon_air & (para(round(i+i1-1),round(j+j1),1)==epsilon_slab | para(round(i+i1+1),round(j+j1),1)==epsilon_slab | para(round(i+i1),round(j+j1-1),1)==epsilon_slab | para(round(i+i1),round(j+j1+1),1)==epsilon_slab);
para(round(i+i1),round(j+j1),1)=epsilon_average;
end
end
end %���y��ݽ���
end
end

for j=jc+w1;%r2=3;
for i=jc+w2+a;
for i1=-r2:r2;
for j1=-r2:r2;
if(sqrt(i1^2+j1^2)<r1);
para(round(i+i1),round(j+j1),1)=n_air2*epsilon0;
end
end
end
for i1=-r2:r2;
for j1=-r2:r2;
if  para(round(i+i1),round(j+j1),1)==epsilon_air & (para(round(i+i1-1),round(j+j1),1)==epsilon_slab | para(round(i+i1+1),round(j+j1),1)==epsilon_slab | para(round(i+i1),round(j+j1-1),1)==epsilon_slab | para(round(i+i1),round(j+j1+1),1)==epsilon_slab);
para(round(i+i1),round(j+j1),1)=epsilon_average;
end
end
end %���y��ݽ���
end
end

for j=jc+w1;%r3=4;
for i=jc+w2+2*a;
for i1=-r3:r3;
for j1=-r3:r3;
if(sqrt(i1^2+j1^2)<r2);
para(round(i+i1),round(j+j1),1)=n_air2*epsilon0;
end
end
end
for i1=-r3:r3;
for j1=-r3:r3;
if  para(round(i+i1),round(j+j1),1)==epsilon_air & (para(round(i+i1-1),round(j+j1),1)==epsilon_slab | para(round(i+i1+1),round(j+j1),1)==epsilon_slab | para(round(i+i1),round(j+j1-1),1)==epsilon_slab | para(round(i+i1),round(j+j1+1),1)==epsilon_slab);
para(round(i+i1),round(j+j1),1)=epsilon_average;
end
end
end %���y��ݽ���
end
end

for j=jc+w1;%r4=5;
for i=jc+w2+3*a;
for i1=-r4:r4;
for j1=-r4:r4;
if(sqrt(i1^2+j1^2)<r2);
para(round(i+i1),round(j+j1),1)=n_air2*epsilon0;
end
end
end
for i1=-r4:r4;
for j1=-r4:r4;
if  para(round(i+i1),round(j+j1),1)==epsilon_air & (para(round(i+i1-1),round(j+j1),1)==epsilon_slab | para(round(i+i1+1),round(j+j1),1)==epsilon_slab | para(round(i+i1),round(j+j1-1),1)==epsilon_slab | para(round(i+i1),round(j+j1+1),1)==epsilon_slab);
para(round(i+i1),round(j+j1),1)=epsilon_average;
end
end
end %���y��ݽ���
end
end

%�����У�wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
ww1=sqrt(3)/2*a*2;
for j=jc+ww1;%r2=3;
for i=jc:a:jc+a;
for i1=-r2:r2;
for j1=-r2:r2;
if(sqrt(i1^2+j1^2)<r1);
para(round(i+i1),round(j+j1),1)=n_air2*epsilon0;
end
end
end
for i1=-r2:r2;
for j1=-r2:r2;
if  para(round(i+i1),round(j+j1),1)==epsilon_air & (para(round(i+i1-1),round(j+j1),1)==epsilon_slab | para(round(i+i1+1),round(j+j1),1)==epsilon_slab | para(round(i+i1),round(j+j1-1),1)==epsilon_slab | para(round(i+i1),round(j+j1+1),1)==epsilon_slab);
para(round(i+i1),round(j+j1),1)=epsilon_average;
end
end
end %���y��ݽ���
end
end

for j=jc+ww1;%r3=4;
for i=jc+2*a;
for i1=-r3:r3;
for j1=-r3:r3;
if(sqrt(i1^2+j1^2)<r2);
para(round(i+i1),round(j+j1),1)=n_air2*epsilon0;
end
end
end
for i1=-r3:r3;
for j1=-r3:r3;
if  para(round(i+i1),round(j+j1),1)==epsilon_air & (para(round(i+i1-1),round(j+j1),1)==epsilon_slab | para(round(i+i1+1),round(j+j1),1)==epsilon_slab | para(round(i+i1),round(j+j1-1),1)==epsilon_slab | para(round(i+i1),round(j+j1+1),1)==epsilon_slab);
para(round(i+i1),round(j+j1),1)=epsilon_average;
end
end
end %���y��ݽ���
end
end

for j=jc+ww1;%r4=5;
for i=jc+3*a;
for i1=-r4:r4;
for j1=-r4:r4;
if(sqrt(i1^2+j1^2)<r2);
para(round(i+i1),round(j+j1),1)=n_air2*epsilon0;
end
end
end
for i1=-r4:r4;
for j1=-r4:r4;
if  para(round(i+i1),round(j+j1),1)==epsilon_air & (para(round(i+i1-1),round(j+j1),1)==epsilon_slab | para(round(i+i1+1),round(j+j1),1)==epsilon_slab | para(round(i+i1),round(j+j1-1),1)==epsilon_slab | para(round(i+i1),round(j+j1+1),1)==epsilon_slab);
para(round(i+i1),round(j+j1),1)=epsilon_average;
end
end
end %���y��ݽ���
end
end

%�����У�wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
www1=sqrt(3)/2*a*3;
for j=jc+www1;%r3=4;
for i=jc+w2:a:jc+w2+a;
for i1=-r3:r3;
for j1=-r3:r3;
if(sqrt(i1^2+j1^2)<r2);
para(round(i+i1),round(j+j1),1)=n_air2*epsilon0;
end
end
end
for i1=-r3:r3;
for j1=-r3:r3;
if  para(round(i+i1),round(j+j1),1)==epsilon_air & (para(round(i+i1-1),round(j+j1),1)==epsilon_slab | para(round(i+i1+1),round(j+j1),1)==epsilon_slab | para(round(i+i1),round(j+j1-1),1)==epsilon_slab | para(round(i+i1),round(j+j1+1),1)==epsilon_slab);
para(round(i+i1),round(j+j1),1)=epsilon_average;
end
end
end %���y��ݽ���
end
end

for j=jc+www1;%r4=5;
for i=jc+w2+2*a;
for i1=-r4:r4;
for j1=-r4:r4;
if(sqrt(i1^2+j1^2)<r2);
para(round(i+i1),round(j+j1),1)=n_air2*epsilon0;
end
end
end
for i1=-r4:r4;
for j1=-r4:r4;
if  para(round(i+i1),round(j+j1),1)==epsilon_air & (para(round(i+i1-1),round(j+j1),1)==epsilon_slab | para(round(i+i1+1),round(j+j1),1)==epsilon_slab | para(round(i+i1),round(j+j1-1),1)==epsilon_slab | para(round(i+i1),round(j+j1+1),1)==epsilon_slab);
para(round(i+i1),round(j+j1),1)=epsilon_average;
end
end
end %���y��ݽ���
end
end

%�����У�wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwww1=sqrt(3)/2*a*4;
for j=jc+wwww1;%r4=5;
for i=jc:a:jc+2*a;
for i1=-r4:r4;
for j1=-r4:r4;
if(sqrt(i1^2+j1^2)<r2);
para(round(i+i1),round(j+j1),1)=n_air2*epsilon0;
end
end
end
for i1=-r4:r4;
for j1=-r4:r4;
if  para(round(i+i1),round(j+j1),1)==epsilon_air & (para(round(i+i1-1),round(j+j1),1)==epsilon_slab | para(round(i+i1+1),round(j+j1),1)==epsilon_slab | para(round(i+i1),round(j+j1-1),1)==epsilon_slab | para(round(i+i1),round(j+j1+1),1)==epsilon_slab);
para(round(i+i1),round(j+j1),1)=epsilon_average;
end
end
end %���y��ݽ���
end
end

%�����϶����1/4�ṹ���Ƶ�ȫ��ƽ��
for i=1:ic;
for j=1:jc;
para(ic-i+1,jc-j+1,1)=para(ic+i-1,jc+j-1,1); % 3����
para(ic-i+1,jc+j-1,1)=para(ic+i-1,jc+j-1,1); % 2����
para(ic+i-1,jc-j+1,1)=para(ic+i-1,jc+j-1,1); % 4����
end
end

%---------�����Ų����������

debug=1;

hz=zeros(I,J); hx=hz; hy=hz;
ex=hz; ey=hz; ez=hz;
dx=hz; dy=hz; dz=hz; bx=hz; by=hz; bz=hz;
dx_d=hz; dy_d=hz; dz_d=hz; bx_d=hz; by_d=hz; bz_d=hz;

%ѡȡ����ʱ���εĵ�

ey20k=zeros(I,J);
ex20k=zeros(I,J);

% ׼����ѭ��wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
nsteps=100;%ceil(sqrt(2)*I*15);

for t=1:nsteps;
%wwwwwwwwwwwwwwwwwwwwwwwwwwww�����������ʱ��wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
if t==1
t_start=cputime;
disp(strcat('1 / ',int2str(nsteps),'  Calculating ,And trying to calculate the run time...'))
else
disp(strcat(int2str(t),' /  ',int2str(nsteps),'  Calculating...May be ','  ',num2str((nsteps-t+1)*t_elapsed),'  seconds left'))

end
%wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww�������wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

%�����ʼ����
pulse=exp(-0.5*((t-t0)/spread)^2);

for i=1:I-1;   %  ����ռ����Hֵ
for j=1:J-1;
tempy_add=1/dt+para(i,j,6)/mu0/2;
tempx_add=1/dt+para(i,j,5)/mu0/2;
tempy_sub=para(i,j,6)/mu0/2-1/dt;
tempx_sub=para(i,j,5)/mu0/2-1/dt;
bx_d(i,j)=bx(i,j);
bx(i,j)=bx(i,j)-dt*((ez(i,j+1)-ez(i,j))/ddx-kz*ey(i,j));
hx(i,j)=-tempy_sub/tempy_add*hx(i,j)+1/mu0/tempy_add*(tempx_add*bx(i,j)+tempx_sub*bx_d(i,j))+exp(-((i-ic-a)^2+(j-jc)^2)/r0^2)*pulse+exp(-((i-ic+a)^2+(j-jc)^2)/r0^2)*pulse;%��Hx(ic,jc)�Ӽ���Դ
by_d(i,j)=by(i,j);
by(i,j)=by(i,j)+dt*((ez(i+1,j)-ez(i,j))/ddx-kz*ex(i,j));
hy(i,j)=-tempx_sub/tempx_add*hy(i,j)+1/mu0/tempx_add*(tempy_add*by(i,j)+tempy_sub*by_d(i,j));%+(i==ic)*(j==jc)*pulse;%��Hy(ic,jc)�Ӽ���Դ
bz_d(i,j)=bz(i,j);
bz(i,j)=-tempy_sub/tempy_add*bz(i,j)+1/tempy_add*((ex(i,j+1)-ex(i,j))-(ey(i+1,j)-ey(i,j)))/ddx;
hz(i,j)=-tempx_sub/tempx_add*hz(i,j)+1/mu0/tempx_add/dt*(bz(i,j)-bz_d(i,j));
end
end

for i=2:I;  %  ����ռ����Eֵ
for j=2:J;
tempy_add=1/dt+para(i,j,4)/epsilon0/2;
tempx_add=1/dt+para(i,j,3)/epsilon0/2;
tempy_sub=para(i,j,4)/epsilon0/2-1/dt;
tempx_sub=para(i,j,3)/epsilon0/2-1/dt;
dx_d(i,j)=dx(i,j);
dx(i,j)=dx(i,j)+dt*((hz(i,j)-hz(i,j-1))/ddx+kz*hy(i,j));
ex(i,j)=-tempy_sub/tempy_add*ex(i,j)+1/para(i,j,1)/tempy_add*(tempx_add*dx(i,j)+tempx_sub*dx_d(i,j));
dy_d(i,j)=dy(i,j);
dy(i,j)=dy(i,j)-dt*((hz(i,j)-hz(i-1,j))/ddx+kz*hx(i,j));
ey(i,j)=-tempx_sub/tempx_add*ey(i,j)+1/para(i,j,1)/tempx_add*(tempy_add*dy(i,j)+tempy_sub*dy_d(i,j));
dz_d(i,j)=dz(i,j);
dz(i,j)=-tempy_sub/tempy_add*dz(i,j)+1/tempy_add*((hy(i,j)-hy(i-1,j))-(hx(i,j)-hx(i,j-1)))/ddx;
ez(i,j)=-tempx_sub/tempx_add*ez(i,j)+1/para(i,j,1)/tempx_add/dt*(dz(i,j)-dz_d(i,j));
end
end

%����ʱ����

ey20k=ey(1:I,1:J);
ex20k=ex(1:I,1:J);

%����ʣ�μ�ʱ��wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
if t==1
t_elapsed=cputime-t_start;
end
%wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
end % ��ѭ��������
x=-178:177;y=x;
[X,Y]=meshgrid(x,y);
Z=ey20k.^2+ex20k.^2;
surf(X,Y,Z)```
` `
` `
```联系：highspeedlogic
QQ ：1224848052

```

• ##### 您是如何找到本站的？
• 百度搜索
• Google搜索
• 查阅资料过程中
• 论坛发现
• 百度贴吧发现
• 朋友介绍
• 没有相关文章
###### 发表我的评论
• 大名：
• 内容：
• matlab代做|matlab专业代做|matlab淘宝代做|python人工智能代做(www.hslogic.com) © 2020 版权所有 All Rights Reserved.
• Email:highspeed_logic@163.com 站长QQ: 1224848052

专业代做/代写/承接、MATLAB、SIMULINK、FPGA项目、博士/硕士/本科毕业设计、课题设计、论文，毕业论文，Coursework、Eassy、Assignment