You are on page 1of 11

Matlab code

FBG using plane wave expansion:


clear

warning off

epsa=13;

epsb=1;

a=1.0;

R=0.2*a;

a1=a;

b1=2*pi/a;

%n=input('please input n: ');

n=24;

NumberofPW=49;

count=1;

G=(-n:n).*b1;

r=(-n:n);

N=98;

m=20;

%%%this is very important to expand the epsilon function like this

%%%even expansion, so that the imag part is zero

eps1=[epsb*ones((N-m)/2,1);epsa*ones(m,1);epsb*ones((N-m)/2,1)];

eps20=(fftshift(fft(eps1)./N));

%%Now we get the FFT matrix for the dielectric function.

%%We need to get the E(G-G') matrix

%%this matrix include the frequency all we need

for x=1:NumberofPW,

for y=x:NumberofPW,

b=r(x)-r(y)+(2*n+1)+1;

eps2(x,y)=eps20(b);
eps2(y,x)=eps2(x,y);

end

end

k0=-pi/a:2*pi/a/30:pi/a;

eps2=inv(eps2);

counter=1;

for ii=1:length(k0),

k=k0(ii);

M=abs((k+G')*(k+G)).*(eps2);

E=sort(abs(eig(M)));

freq(:,counter)=sqrt(abs(E(1:10))).*a./2./pi;

display(sprintf('calculation of k=%f is finished',k));

counter=counter+1;

end

tmpx=1:length(k0);

plot(tmpx,freq,'linewidth',2)

title('Band structure of a 1D square photonic band structure')

xlabel('wave vector')

ylabel('wa/2\pic')

grid on

axis([1 31 0 1])
FINAL PLANE WAVE METHOD

% Clean up workspace

clear all

%close all

% PhC parameters

d1 = 400e-9;

d2 = 600e-9;

d = d1 + d2;

n1 = 1.5;

n2 = 1;

% Input light parameters

kz = linspace(0,2*pi/d,100);

c = 3e8;

% Decomposition constants

N = 24; % This chooses the number of bands

% NB: choosing this number too small will lead to


% an innacurate band diagram due to truncation of

% the Fourier series.

% Create matrix and solve eigenvalue equation

w2 = zeros(2*N+1,length(kz)); % Set up storage array

for kk = 1:length(kz)

% Make matrix using for loop

M =zeros(2*N+1,2*N+1);

for nn = (-N):N

for pp = (-N):N

Fn = (d1/d) * (1/n1^2-1/n2^2) * sin((pp-nn)*d1/d)/((pp-nn)*d1/d);

if ((pp-nn)==0)

Fn=0;

end

M(nn+N+1,pp+N+1) = (2*pi/d*nn + kz(kk))^2 * Fn ;

end

end

w2(:,kk) = sort(eig(M)); % Find and sort the eigenvalues

end

% Plot band diagram

clf

%subplot(2,2,i);

plot(kz*d,real(sqrt(w2)*d),'linewidth',2)

hold on

axis tight

set(gca,'FontSize',14)

xlabel('k_zd','FontSize',14)

ylabel('\omega d/c','FontSize',14)

ylim([0,2*pi])
Band gap for w= 2.966, w=3.525

K=0

Transfer: w=2.31 , w=2.946

FBG using transfer matrix:


% Clean up workspace

close all

clear all

% EM constants

c = 1; % In this example we will use normalized units

% Due to the scale invariance of Maxwell’s equations,

% so long as we are consistent, the units we use don’t matter.

% PhC constants

d1 = 4/10;

d2 = 6/10;
d = d1 + d2;

n1 =1.5;

n2 = 1;

% Light constants

w = linspace(-2*pi,2*pi, 500);

D1 = w.*n1 * d1;

D2 = w.*n2 * d2;

% Right hand side of the characteristic equation is independent of k_z

RHS = cos(D1).*cos(D2) - 0.5*(n1^2+n2^2)/(n1*n2) * sin(D1) .* sin(D2);

% Define the wave number space

kz = linspace(-2*pi,2*pi,500);

% Calculate the bands, one point of kz at a time

for ll = 1:length(kz)

LHS = cos(kz(ll)*d);

end

plot(real(acos(RHS)),w*d/c,'linewidth',2);

axis tight ,

xlabel('k_zd')

ylabel('\omega d/c')

xlim([0 6])
Transmittance

% Input conditions

eps1 = 11.9;

eps2 = 5.8;

b1 = 1028; % Thickness

b2 = 1472;

b12 = 1250;

nm = 10^(-9);

c = 3*10^8;

N = 20; % Bilayer number

P = 2; % Period

l = 10000:21000; % wavelength
w = 2*pi*c./(l*nm);

lam0 = 14160; %nm

w0 = 2*pi*c/(lam0*nm);

% Refractive index array

n1 = sqrt(eps1);

n2 = sqrt(eps2);

n= [n1, n2];

nArray = [1, repmat(n,1,N), 1]; % without defect, where 1 is in air

% Thickness array

b = zeros(1,N*P);

for i = 1:2:N*P

b(i) = b1;

end

for i = 2:2:N*P

b(i) = b2;

end

% Wave vector in vacuum

k=2*pi./l;

% Fresnel coefficients

r=zeros(1, N*P+1);

t=zeros(1, N*P+1);

for i=1:1:N*P+1

r(i)=(nArray(i)-nArray(i+1))/(nArray(i)+nArray(i+1));
t(i)=2*nArray(i)/(nArray(i)+nArray(i+1));

end

% Transfer and transmit matricies in layer j

M=zeros(2,2,N*P+1);

F=zeros(2,2,length(l),N*P);

for i=1:1:N*P+1

M(1,1,i)=1/t(i);

M(1,2,i)=r(i)/t(i);

M(2,1,i)=r(i)/t(i);

M(2,2,i)=1/t(i);

end

for i=1:1:N*P

for j=1:length(l)

F(1,1,j,i)=exp(1i*nArray(i+1)*k(j)*b(i));

F(1,2,j,i)=0;

F(2,1,j,i)=0;

F(2,2,j,i)=exp(-1i*nArray(i+1)*k(j)*b(i));

end

end

% Full matrix

T=zeros(2,2,length(l));

for j=1:length(l)

T(:,:,j)=M(:,:,1);

for i=1:1:N*P

T(:,:,j)=T(:,:,j)*F(:,:,j,i)*M(:,:,i+1);
end

end

M=zeros(length(l));

for j=1:length(l)

M(j)=abs( (T(1,1,j).*T(2,2,j)-T(1,2,j).*T(2,1,j))./T(2,2,j) ).^2;

end

figure(1)

plot(w/w0,M(:,1),'k','linewidth',1.5);

axis([0.7 1.3 0 1]);

grid on;

yticks([0,0.25,0.5,0.75,1]);

set(gca,'FontSize',16,'FontName', 'Times New Roman');

hold on;

You might also like