Sie sind auf Seite 1von 22

D6hy(upml+1:ih_tot-upml,je_tot-upml+1:je_tot).

*bs(upml+1:ih_tot-upml,je_totupml+1:je_tot));
%***********************************************************************
% Get obseverations, compute phasor quantities(Ei)
%***********************************************************************
for i=1:size(I,2)
ez_obs(n,i)=ez(I(i),J(i));
ftr(i)=ftr(i)+ez_obs(n,i)*cos(omega*n*dt);
fti(i)=fti(i)+ez_obs(n,i)*sin(omega*n*dt);
end
E_i=E_i+ez(i_cen,j_cen)*(cos(omega*n*dt)-1j*sin(omega*n*dt));
for i=1:length(Id)
ez_boundary(n,i)=ez(Id(i),Jd(i));
hx_boundary(n,i)=hx(Id(i),Jd(i));
hy_boundary(n,i)=hy(Id(i),Jd(i));
end
end
Ez_b=(ftr-1j*fti);

3. scatter_UPML.m
%***********************************************************************
% 2D scatter problem, with scatter. the scatter is put in the center of
% the grid. and it's diameter is 4mm.
%***********************************************************************
%
%
Program author: Fuqiang Gao
%
Department of Electrical and Computer Engineering
%
University of Wisconsin-Madison
%
1415 Engineering Drive
%
Madison, WI 53706-1691
%
fgao4@wisc.edu
%
%***********************************************************************
function [ez_boundarys ez_obs]=scatter_UPML(nmax)
%***********************************************************************
% Fundamental constants
%***********************************************************************
cc=2.99792458e8;
%speed of light in free space
muz=4.0*pi*1.0e-7;
%permeability of free space
epsz=1.0/(cc*cc*muz);
%permittivity of free space
% nmax=1000;
%***********************************************************************

% Source Parameters
%***********************************************************************
epsrb=44.0;
sigrb=0;
epsrs=50.0;
sigrs=0;
%Parameter for lossy case
% epsrb=44.0;
% sigrb=4.162;
% epsrs=50.0;
% sigrs=4.91;
freq=5e9;
%frequency
omega=2*pi*freq;
%***********************************************************************
% Grid parameters
%***********************************************************************
beta=omega*sqrt(muz*epsz*epsrb)*sqrt(1/2*(sqrt(1+(sigrb/omega/epsz/epsrb)^2)+1));
lamda=2*pi/beta;
delta=2.5e-4;
%space increment in 2-D lattice
dt=delta*sqrt(epsrb)/(2.0*cc); %time increment
ie=round((0.25)/delta);
je=round((0.25)/delta);
ih=ie-1;
jh=je-1;
upml=10;
ie_tot=ie+2*upml;
je_tot=je+2*upml;
ih_tot=ie_tot-1;
jh_tot=je_tot-1;
i_cen=round(ie_tot/2);
%center location
j_cen=round(je_tot/2);
i_src=i_cen-round(0.075/delta);
%source location
j_src=j_cen;
x=linspace(delta,ih_tot*delta,ih_tot);
y=linspace(delta,jh_tot*delta,jh_tot);
fmax=1e10;
tau=3e-10;%1/(pi*(fmax-freq));
ndecay=tau/dt;
n0=3*ndecay;
%***********************************************************************
% Material parameters
%***********************************************************************
MEDIAez=ones(ie_tot,je_tot);
MEDIAhx=ones(ie_tot,jh_tot);
MEDIAhy=ones(ih_tot,je_tot);

ez(ie_tot,je_tot)=0.0;
dz=ez;
hx(ie_tot,jh_tot)=0.0;
bx=hx;
hy(ih_tot,je_tot)=0.0;
by=hy;
C1ez=ones(size(ez));
C2ez=ones(size(ez));
C3ez=ones(size(ez));
C4ez=ones(size(ez));
C5ez=ones(size(ez));
C6ez=ones(size(ez));
D1hx=ones(size(hx));
D2hx=ones(size(hx));
D3hx=ones(size(hx));
D4hx=ones(size(hx));
D5hx=ones(size(hx));
D6hx=ones(size(hx));
D1hy=ones(size(hy));
D2hy=ones(size(hy));
D3hy=ones(size(hy));
D4hy=ones(size(hy));
D5hy=ones(size(hy));
D6hy=ones(size(hy));
C1=(2*epsrb*epsz*1-sigrb*dt)/(2*epsrb*epsz*1+sigrb*dt);
C2=2*epsrb*epsz*dt/(2*epsrb*epsz*1+sigrb*dt);
C3=(2*epsrb*epsz*1-sigrb*dt)/(2*epsrb*epsz*1+sigrb*dt);
C4=1.0/(2*epsrb*epsz*1+sigrb*dt)/(epsrb*epsz);
C5=2.0*epsrb*epsz;
C6=2.0*epsrb*epsz;
D1x=(2*epsrb*epsz*1-sigrb*dt)/(2*epsrb*epsz*1+sigrb*dt);
D2x=2*epsrb*epsz*dt/(2*epsrb*epsz*1+sigrb*dt);
D3x=1.0;
D4x=1.0/(2*epsrb*epsz)/muz;
D5x=2.0*epsrb*epsz+sigrb*dt;
D6x=2.0*epsrb*epsz-sigrb*dt;
D1y=1.0;
D2y=dt;
D3y=(2*epsrb*epsz*1-sigrb*dt)/(2*epsrb*epsz*1+sigrb*dt);
D4y=1.0/(2*epsrb*epsz+sigrb*dt)/muz;
D5y=2.0*epsrb*epsz+sigrb*dt;

D6y=2.0*epsrb*epsz-sigrb*dt;
%Assign main domain parameters to whole region, then modify the PML region
C1ez=C1*C1ez;
C2ez=C2*C2ez;
C3ez=C3*C3ez;
C4ez=C4*C4ez;
C5ez=C5*C5ez;
C6ez=C6*C6ez;
D1hx=D1x*D1hx;
D2hx=D2x*D2hx;
D3hx=D3x*D3hx;
D4hx=D4x*D4hx;
D5hx=D5x*D5hx;
D6hx=D6x*D6hx;
D1hy=D1y*D1hy;
D2hy=D2y*D2hy;
D3hy=D3y*D3hy;
D4hy=D4y*D4hy;
D5hy=D5y*D5hy;
D6hy=D6y*D6hy;
%assing media pointers to scatter
for i=1:ie_tot
for j=1:je_tot
if ((i-i_cen)^2+(j-j_cen)^2)<=(0.002/delta)^2 %scatter
MEDIAez(i,j)=2;
MEDIAhx(i,j)=2;
MEDIAhy(i,j)=2;
end
end
end
%Get index of observation points
I=ones(1,2);
J=ones(1,2);
index=1;
for i=1:ie_tot
for j=1:je_tot
if (((i-i_cen)^2+(j-j_cen)^2)>=(0.04/delta)^2 && ((i-i_cen)^2+(j-j_cen)^2)<(0.04/delta+1)^2)
I(index)=i;
J(index)=j;
index=index+1;
end;
end
end

%Get index of source locations


Id=ones(1,2);
Jd=ones(1,2);
index=1;
for i=1:ie_tot
for j=1:je_tot
if
(((i-i_cen)^2+(j-j_cen)^2)>(0.002/delta+0.4)^2
j_cen)^2)<(0.002/delta+1.4)^2)
Id(index)=i;
Jd(index)=j;
index=index+1;
end;
end
end
source=[i_src-i_cen 0];
phi=ones(1,size(Id,2));
for i=1:size(Id,2)
a=[Id(i)-i_cen Jd(i)-j_cen];
l=sqrt(source(1)^2+source(2)^2)*sqrt(a(1)^2+a(2)^2);
cfi=dot(a,source)/l;
phi(i)=acos(cfi);
if a(2)<0
phi(i)=2*pi-phi(i);
end
end
for i=1:length(phi)-1
for j=i+1:length(phi)
if phi(j)<phi(i)
temp=phi(i);
phi(i)=phi(j);
phi(j)=temp;
temp=Id(i);
Id(i)=Id(j);
Id(j)=temp;
temp=Jd(i);
Jd(i)=Jd(j);
Jd(j)=temp;
end
end
end
eps=[epsrb epsrs 1/2*(epsrb+epsrs)];
sig=[sigrb sigrs 1/2*(sigrs+sigrb)];
mu=[1.0 1.0 1.0];
sigstar=[0.0 0.0 0.0];

&&

((i-i_cen)^2+(j-

%***********************************************************************
% Main Grid Coefficients
%***********************************************************************
ca=(1.0-(dt*sig)./(2.0*epsz*eps))./(1.0+(dt*sig)./(2.0*epsz*eps));
cb=(dt./epsz./eps./delta)./(1.0+(dt*sig)./(2.0*epsz*eps));
da=(1.0-(sigstar*dt)./(2.0*muz*mu))./(1.0+(dt*sigstar)./(2.0*muz*mu));
db=(dt./muz./mu./delta)./(1.0+(dt*sigstar)./(2.0*muz*mu));
%***********************************************************************
% UPML Coefficients
%***********************************************************************
%Update coefficients in PML region
R0=exp(-16);
%reflection error
m=4;
%order of polynomial grading
d=upml*delta;
%thickness of pml slabs;
eta=sqrt(muz/epsrb/epsz);
%x-direction
sigxmax=-(m+1)*log(R0/100)/2/d/eta;
kxmax=1.0;
sigfactor=sigxmax/(m+1)/(d^m)/delta;
kfactor=(kxmax-1)/(m+1)/(d^m)/delta;
for i=1:upml
%coefficients on the boundary
x2=(upml-i+1.5)*delta;
x1=(upml-i+0.5)*delta;
sigx=(x2^(m+1)-x1^(m+1))*sigfactor;
kx=1+(x2^(m+1)-x1^(m+1))*kfactor;
C1=(2*epsrb*epsz*kx-sigx*dt)/(2*epsrb*epsz*kx+sigx*dt);
C2=(2*epsrb*epsz*dt)/(2*epsrb*epsz*kx+sigx*dt);
D5=(2*epsrb*epsz*kx+sigx*dt);
D6=(2*epsrb*epsz*kx-sigx*dt);
C1ez(i,:)=C1;
C1ez(ie_tot-i+1,:)=C1;
C2ez(i,:)=C2;
C2ez(ie_tot-i+1,:)=C2;
D5hx(i,:)=D5;
D5hx(ie_tot-i+1,:)=D5;
D6hx(i,:)=D6;
D6hx(ie_tot-i+1,:)=D6;
%coefficients in the center
x2=(upml-i+1)*delta;
x1=(upml-i)*delta;
sigx=(x2^(m+1)-x1^(m+1))*sigfactor;
kx=1+(x2^(m+1)-x1^(m+1))*kfactor;

D3=(2*epsrb*epsz*kx-sigx*dt)/(2*epsrb*epsz*kx+sigx*dt);
D4=1.0/(2*epsrb*epsz*kx+sigx*dt)/muz;
D3hy(i,:)=D3;
D3hy(ih_tot-i+1,:)=D3;
D4hy(i,:)=D4;
D4hy(ih_tot-i+1,:)=D4;
end
% Model PEC walls
C1ez(1,:)=-1.0;
C1ez(ie_tot,:)=-1.0;
C2ez(1,:)=0.0;
C2ez(ie_tot,:)=0.0;
%y-direction
sigymax=-(m+1)*log(R0/100)/2/d/eta;
kymax=1.0;
sigfactor=sigymax/(m+1)/(d^m)/delta;
kfactor=(kymax-1)/(m+1)/(d^m)/delta;
for j=1:upml
%coefficients on the boundary
y2=(upml-j+1.5)*delta;
y1=(upml-j+0.5)*delta;
sigy=(y2^(m+1)-y1^(m+1))*sigfactor;
ky=1+(y2^(m+1)-y1^(m+1))*kfactor;
C3=(2*epsrb*epsz*ky-sigy*dt)/(2*epsrb*epsz*ky+sigy*dt);
C4=1.0/(2*epsrb*epsz*ky+sigy*dt)/epsrb/epsz;
D5=(2*epsrb*epsz*ky+sigy*dt);
D6=(2*epsrb*epsz*ky-sigy*dt);
C3ez(:,j)=C3;
C3ez(:,je_tot-j+1)=C3;
C4ez(:,j)=C4;
C4ez(:,je_tot-j+1)=C4;
D5hy(:,j)=D5;
D5hy(:,je_tot-j+1)=D5;
D6hy(:,j)=D6;
D6hy(:,je_tot-j+1)=D6;
%coefficients in the center
y2=(upml-j+1)*delta;
y1=(upml-j)*delta;
sigy=(y2^(m+1)-y1^(m+1))*sigfactor;
ky=1+(y2^(m+1)-y1^(m+1))*kfactor;
D1=(2*epsrb*epsz*ky-sigy*dt)/(2*epsrb*epsz*ky+sigy*dt);
D2=2*epsrb*epsz*dt/(2*epsrb*epsz*ky+sigy*dt);
D1hx(:,j)=D1;
D1hx(:,jh_tot-j+1)=D1;
D2hx(:,j)=D2;

D2hx(:,jh_tot-j+1)=D2;
end

%***********************************************************************
% BEGIN TIME-STEPPING LOOP
%***********************************************************************
ez_obs(nmax,size(I,2))=0.0;
ez_boundarys=zeros(nmax,length(Id));
%store ez field on boundary at every time step
hx_boundarys=zeros(nmax,length(Id));
%store ez field on boundary at every time step
hy_boundarys=zeros(nmax,length(Id));
%store ez field on boundary at every time step
Je=0.0;
for n=1:nmax
%***********************************************************************
% Update electric fields
%***********************************************************************
es=ez;
ez(upml+1:ie_tot-upml,upml+1:je_tot-upml)=ca(MEDIAez(upml+1:ie_tot-upml,upml+1:je_totupml)).*ez(upml+1:ie_tot-upml,upml+1:je_tot-upml)+...
cb(MEDIAez(upml+1:ie_tot-upml,upml+1:je_tot-upml)).*...
(hy(upml+1:ie_tot-upml,upml+1:je_tot-upml)-hy(upml:ih_tot-upml,upml+1:je_totupml)+...
hx(upml+1:ie_tot-upml,upml:jh_tot-upml)-hx(upml+1:ie_tot-upml,upml+1:je_totupml));
ds=dz;
dz(2:upml,2:je_tot-1)=C1ez(2:upml,2:je_tot-1).*dz(2:upml,2:je_tot-1)+...
C2ez(2:upml,2:je_tot-1)./delta.*((hy(2:upml,2:je_tot-1)-hy(1:upml-1,2:je_tot-1))-...
(hx(2:upml,2:je_tot-1)-hx(2:upml,1:je_tot-2)));
ez(2:upml,2:je_tot-1)=C3ez(2:upml,2:je_tot-1).*es(2:upml,2:je_tot-1)+...
C4ez(2:upml,2:je_tot-1).*(C5ez(2:upml,2:je_tot-1).*dz(2:upml,2:je_tot-1)C6ez(2:upml,2:je_tot-1).*ds(2:upml,2:je_tot-1));
dz(upml+1:ie_tot-1,2:upml)=C1ez(upml+1:ie_tot-1,2:upml).*ds(upml+1:ie_tot-1,2:upml)+...
C2ez(upml+1:ie_tot-1,2:upml)./delta.*((hy(upml+1:ie_tot-1,2:upml)-hy(upml:ie_tot2,2:upml))-...
(hx(upml+1:ie_tot-1,2:upml)-hx(upml+1:ie_tot-1,1:upml-1)));
ez(upml+1:ie_tot-1,2:upml)=C3ez(upml+1:ie_tot-1,2:upml).*es(upml+1:ie_tot-1,2:upml)+...
C4ez(upml+1:ie_tot-1,2:upml).*(C5ez(upml+1:ie_tot-1,2:upml).*dz(upml+1:ie_tot1,2:upml)-...
C6ez(upml+1:ie_tot-1,2:upml).*ds(upml+1:ie_tot-1,2:upml));
dz(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1)=C1ez(upml+1:ie_tot-1,je_tot-upml+1:je_tot1).*ds(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1)+...
C2ez(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1)./delta.*...

((hy(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1)-hy(upml:ie_tot-2,je_tot-upml+1:je_tot1))-...
(hx(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1)-hx(upml+1:ie_tot-1,je_tot-upml:je_tot-2)));
ez(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1)=C3ez(upml+1:ie_tot-1,je_tot-upml+1:je_tot1).*es(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1)+...
C4ez(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1).*...
(C5ez(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1).*dz(upml+1:ie_tot-1,je_totupml+1:je_tot-1)-...
C6ez(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1).*ds(upml+1:ie_tot-1,je_totupml+1:je_tot-1));
dz(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml)=C1ez(ie_tot-upml+1:ie_tot-1,upml+1:je_totupml).*ds(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml)+...
C2ez(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml)./delta.*...
((hy(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml)-hy(ie_tot-upml:ie_tot2,upml+1:je_tot-upml))-...
(hx(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml)-hx(ie_tot-upml+1:ie_tot-1,upml:je_totupml-1)));
ez(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml)=C3ez(ie_tot-upml+1:ie_tot-1,upml+1:je_totupml).*es(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml)+...
C4ez(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml).*...
(C5ez(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml).*dz(ie_tot-upml+1:ie_tot1,upml+1:je_tot-upml)-...
C6ez(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml).*ds(ie_tot-upml+1:ie_tot1,upml+1:je_tot-upml));

ez(i_src,j_src)=ez(i_src,j_src)-cb(MEDIAez(i_src,j_src))*delta*exp(-((nn0)/ndecay)^2)*sin(omega*(n-n0)*dt);
%***********************************************************************
% Update magnetic fields
%***********************************************************************
hs=hx;
hx(upml+1:ie_tot-upml,upml+1:jh_tot-upml)=da(MEDIAhx(upml+1:ie_tot-upml,upml+1:jh_totupml)).*hx(upml+1:ie_tot-upml,upml+1:jh_tot-upml)+...
db(MEDIAhx(upml+1:ie_tot-upml,upml+1:jh_tot-upml)).*(ez(upml+1:ie_totupml,upml+1:jh_tot-upml)-ez(upml+1:ie_tot-upml,upml+2:je_tot-upml));
bs=bx;
bx(1:upml,:)=D1hx(1:upml,:).*bx(1:upml,:)-D2hx(1:upml,:).*(ez(1:upml,2:je_tot)ez(1:upml,1:jh_tot))./delta;
hx(1:upml,:)=D3hx(1:upml,:).*hx(1:upml,:)+D4hx(1:upml,:).*(D5hx(1:upml,:).*bx(1:upml,:)D6hx(1:upml,:).*bs(1:upml,:));
bx(upml+1:ie_tot,1:upml)=D1hx(upml+1:ie_tot,1:upml).*bs(upml+1:ie_tot,1:upml)-...
D2hx(upml+1:ie_tot,1:upml).*(ez(upml+1:ie_tot,2:upml+1)-ez(upml+1:ie_tot,1:upml))./delta;

hx(upml+1:ie_tot,1:upml)=D3hx(upml+1:ie_tot,1:upml).*hs(upml+1:ie_tot,1:upml)+D4hx(upml+
1:ie_tot,1:upml).*...
(D5hx(upml+1:ie_tot,1:upml).*bx(upml+1:ie_tot,1:upml)D6hx(upml+1:ie_tot,1:upml).*bs(upml+1:ie_tot,1:upml));
bx(ie_tot-upml+1:ie_tot,upml+1:jh_tot)=D1hx(ie_tot-upml+1:ie_tot,upml+1:jh_tot).*bs(ie_totupml+1:ie_tot,upml+1:jh_tot)-...
D2hx(ie_tot-upml+1:ie_tot,upml+1:jh_tot).*(ez(ie_tot-upml+1:ie_tot,upml+2:jh_tot+1)ez(ie_tot-upml+1:ie_tot,upml+1:jh_tot))./delta;
hx(ie_tot-upml+1:ie_tot,upml+1:jh_tot)=D3hx(ie_tot-upml+1:ie_tot,upml+1:jh_tot).*...
hs(ie_tot-upml+1:ie_tot,upml+1:jh_tot)+D4hx(ie_tot-upml+1:ie_tot,upml+1:jh_tot).*...
(D5hx(ie_tot-upml+1:ie_tot,upml+1:jh_tot).*bx(ie_tot-upml+1:ie_tot,upml+1:jh_tot)-...
D6hx(ie_tot-upml+1:ie_tot,upml+1:jh_tot).*bs(ie_tot-upml+1:ie_tot,upml+1:jh_tot));
bx(upml+1:ie_tot-upml,jh_tot-upml+1:jh_tot)=D1hx(upml+1:ie_tot-upml,jh_totupml+1:jh_tot).*bs(upml+1:ie_tot-upml,jh_tot-upml+1:jh_tot)-...
D2hx(upml+1:ie_tot-upml,jh_tot-upml+1:jh_tot).*...
(ez(upml+1:ie_tot-upml,jh_tot-upml+2:jh_tot+1)-ez(upml+1:ie_tot-upml,jh_totupml+1:jh_tot))./delta;
hx(upml+1:ie_tot-upml,jh_tot-upml+1:jh_tot)=D3hx(upml+1:ie_tot-upml,jh_totupml+1:jh_tot).*...
hs(upml+1:ie_tot-upml,jh_tot-upml+1:jh_tot)+D4hx(upml+1:ie_tot-upml,jh_totupml+1:jh_tot).*...
(D5hx(upml+1:ie_tot-upml,jh_tot-upml+1:jh_tot).*bx(upml+1:ie_tot-upml,jh_totupml+1:jh_tot)-...
D6hx(upml+1:ie_tot-upml,jh_tot-upml+1:jh_tot).*bs(upml+1:ie_tot-upml,jh_totupml+1:jh_tot));

hs=hy;
hy(upml+1:ih_tot-upml,upml+1:je_tot-upml)=da(MEDIAhy(upml+1:ih_tot-upml,upml+1:je_totupml)).*...
hy(upml+1:ih_tot-upml,upml+1:je_tot-upml)+db(MEDIAhy(upml+1:ih_totupml,upml+1:je_tot-upml)).*...
(ez(upml+2:ie_tot-upml,upml+1:je_tot-upml)-ez(upml+1:ih_tot-upml,upml+1:je_tot-upml));
bs=by;
by(1:upml,:)=D1hy(1:upml,:).*by(1:upml,:)-D2hy(1:upml,:).*(-(ez(2:upml+1,1:je_tot)ez(1:upml,1:je_tot)))./delta;
hy(1:upml,:)=D3hy(1:upml,:).*hy(1:upml,:)+D4hy(1:upml,:).*(D5hy(1:upml,:).*by(1:upml,:)D6hy(1:upml,:).*bs(1:upml,:));
by(upml+1:ih_tot,1:upml)=D1hy(upml+1:ih_tot,1:upml).*bs(upml+1:ih_tot,1:upml)-...
D2hy(upml+1:ih_tot,1:upml).*(-(ez(upml+2:ih_tot+1,1:upml)ez(upml+1:ih_tot,1:upml)))./delta;
hy(upml+1:ih_tot,1:upml)=D3hy(upml+1:ih_tot,1:upml).*hs(upml+1:ih_tot,1:upml)+D4hy(upml+
1:ih_tot,1:upml).*...

(D5hy(upml+1:ih_tot,1:upml).*by(upml+1:ih_tot,1:upml)D6hy(upml+1:ih_tot,1:upml).*bs(upml+1:ih_tot,1:upml));
by(ih_tot-upml+1:ih_tot,upml+1:je_tot)=D1hy(ih_tot-upml+1:ih_tot,upml+1:je_tot).*bs(ih_totupml+1:ih_tot,upml+1:je_tot)-...
D2hy(ih_tot-upml+1:ih_tot,upml+1:je_tot).*(-(ez(ih_tot-upml+2:ih_tot+1,upml+1:je_tot)ez(ih_tot-upml+1:ih_tot,upml+1:je_tot)))./delta;
hy(ih_tot-upml+1:ih_tot,upml+1:je_tot)=D3hy(ih_tot-upml+1:ih_tot,upml+1:je_tot).*hs(ih_totupml+1:ih_tot,upml+1:je_tot)+...
D4hy(ih_tot-upml+1:ih_tot,upml+1:je_tot).*(D5hy(ih_totupml+1:ih_tot,upml+1:je_tot).*by(ih_tot-upml+1:ih_tot,upml+1:je_tot)-...
D6hy(ih_tot-upml+1:ih_tot,upml+1:je_tot).*bs(ih_tot-upml+1:ih_tot,upml+1:je_tot));
by(upml+1:ih_tot-upml,je_tot-upml+1:je_tot)=D1hy(upml+1:ih_tot-upml,je_totupml+1:je_tot).*bs(upml+1:ih_tot-upml,je_tot-upml+1:je_tot)-...
D2hy(upml+1:ih_tot-upml,je_tot-upml+1:je_tot).*...
(-(ez(upml+2:ih_tot-upml+1,je_tot-upml+1:je_tot)-ez(upml+1:ih_tot-upml,je_totupml+1:je_tot)))./delta;
hy(upml+1:ih_tot-upml,je_tot-upml+1:je_tot)=D3hy(upml+1:ih_tot-upml,je_totupml+1:je_tot).*hs(upml+1:ih_tot-upml,je_tot-upml+1:je_tot)+...
D4hy(upml+1:ih_tot-upml,je_tot-upml+1:je_tot).*...
(D5hy(upml+1:ih_tot-upml,je_tot-upml+1:je_tot).*by(upml+1:ih_tot-upml,je_totupml+1:je_tot)-...
D6hy(upml+1:ih_tot-upml,je_tot-upml+1:je_tot).*bs(upml+1:ih_tot-upml,je_totupml+1:je_tot));
for i=1:size(I,2)
ez_obs(n,i)=ez(I(i),J(i));
end
for i=1:length(Id)
ez_boundarys(n,i)=ez(Id(i),Jd(i));
hx_boundarys(n,i)=hx(Id(i),Jd(i));
hy_boundarys(n,i)=hy(Id(i),Jd(i));
end
end

4. sbc.m
function [fi Ed ez_obs Jz rc]=sbc(nmax,eoz)
%***********************************************************************
% Fundamental constants
%***********************************************************************
cc=2.99792458e8;

%speed of light in free space

muz=4.0*pi*1.0e-7;
%permeability of free space
epsz=1.0/(cc*cc*muz);
%permittivity of free space
% nmax=1000;
%***********************************************************************
% Source Parameters
%***********************************************************************
epsrb=44.0;
sigrb=0;
epsrs=50.0;
sigrs=0;
%Parameter for lossy case
% epsrb=44.0;
% sigrb=4.162;
% epsrs=50.0;
% sigrs=4.91;
freq=5e9;
%frequency
omega=2*pi*freq;
%***********************************************************************
% Grid parameters
%***********************************************************************
beta=omega*sqrt(muz*epsz*epsrb)*sqrt(1/2*(sqrt(1+(sigrb/omega/epsz/epsrb)^2)+1));
lamda=2*pi/beta;
delta=2.5e-4;%2.5e-4;%lamda/8.9/10;
%space increment in 2-D lattice
dt=delta*sqrt(epsrb)/(2.0*cc); %time increment
ie=round((0.25)/delta);
je=round((0.25)/delta);
ih=ie-1;
jh=je-1;
upml=10;
ie_tot=ie+2*upml;
je_tot=je+2*upml;
ih_tot=ie_tot-1;
jh_tot=je_tot-1;
i_cen=round(ie_tot/2);
%center location
j_cen=round(je_tot/2);
i_src=i_cen-round(0.075/delta);
%source location
j_src=j_cen;
x=linspace(delta,ih_tot*delta,ih_tot);
y=linspace(delta,jh_tot*delta,jh_tot);
fmax=1e10;
tau=3e-10;%1/(pi*(fmax-freq));
ndecay=tau/dt;
n0=3*ndecay;
%***********************************************************************
% Material parameters
%***********************************************************************
MEDIAez=ones(ie_tot,je_tot);
MEDIAhx=ones(ie_tot,jh_tot);

MEDIAhy=ones(ih_tot,je_tot);
ez(ie_tot,je_tot)=0.0;
dz=ez;
hx(ie_tot,jh_tot)=0.0;
bx=hx;
hy(ih_tot,je_tot)=0.0;
by=hy;
C1ez=ones(size(ez));
C2ez=ones(size(ez));
C3ez=ones(size(ez));
C4ez=ones(size(ez));
C5ez=ones(size(ez));
C6ez=ones(size(ez));
D1hx=ones(size(hx));
D2hx=ones(size(hx));
D3hx=ones(size(hx));
D4hx=ones(size(hx));
D5hx=ones(size(hx));
D6hx=ones(size(hx));
D1hy=ones(size(hy));
D2hy=ones(size(hy));
D3hy=ones(size(hy));
D4hy=ones(size(hy));
D5hy=ones(size(hy));
D6hy=ones(size(hy));
C1=(2*epsrb*epsz*1-sigrb*dt)/(2*epsrb*epsz*1+sigrb*dt);
C2=2*epsrb*epsz*dt/(2*epsrb*epsz*1+sigrb*dt);
C3=(2*epsrb*epsz*1-sigrb*dt)/(2*epsrb*epsz*1+sigrb*dt);
C4=1.0/(2*epsrb*epsz*1+sigrb*dt)/(epsrb*epsz);
C5=2.0*epsrb*epsz;
C6=2.0*epsrb*epsz;
D1x=(2*epsrb*epsz*1-sigrb*dt)/(2*epsrb*epsz*1+sigrb*dt);
D2x=2*epsrb*epsz*dt/(2*epsrb*epsz*1+sigrb*dt);
D3x=1.0;
D4x=1.0/(2*epsrb*epsz)/muz;
D5x=2.0*epsrb*epsz+sigrb*dt;
D6x=2.0*epsrb*epsz-sigrb*dt;
D1y=1.0;
D2y=dt;
D3y=(2*epsrb*epsz*1-sigrb*dt)/(2*epsrb*epsz*1+sigrb*dt);
D4y=1.0/(2*epsrb*epsz+sigrb*dt)/muz;
D5y=2.0*epsrb*epsz+sigrb*dt;
D6y=2.0*epsrb*epsz-sigrb*dt;

%Assign main domain parameters to whole region, then modify the PML region
C1ez=C1*C1ez;
C2ez=C2*C2ez;
C3ez=C3*C3ez;
C4ez=C4*C4ez;
C5ez=C5*C5ez;
C6ez=C6*C6ez;
D1hx=D1x*D1hx;
D2hx=D2x*D2hx;
D3hx=D3x*D3hx;
D4hx=D4x*D4hx;
D5hx=D5x*D5hx;
D6hx=D6x*D6hx;
D1hy=D1y*D1hy;
D2hy=D2y*D2hy;
D3hy=D3y*D3hy;
D4hy=D4y*D4hy;
D5hy=D5y*D5hy;
D6hy=D6y*D6hy;
%assing media pointers to scatter
for i=1:ie_tot
for j=1:je_tot
if ((i-i_cen)^2+(j-j_cen)^2)<=(0.002/delta)^2 %scatter
MEDIAez(i,j)=2;
MEDIAhx(i,j)=2;
MEDIAhy(i,j)=2;
%
elseif ((i-i_cen)^2+(j-j_cen)^2)<=(0.002/delta)^2 && ((i-i_cen)^2+(jj_cen)^2)>(0.002/delta-1)^2 %scatter
%
MEDIAez(i,j)=3;
%
MEDIAhx(i,j)=3;
%
MEDIAhy(i,j)=3;
end
end
end
%Get index of observation points
I=ones(1,2);
J=ones(1,2);
index=1;
for i=1:ie_tot
for j=1:je_tot
if
(((i-i_cen)^2+(j-j_cen)^2)>=(0.04/delta)^2
j_cen)^2)<(0.04/delta+1)^2)
I(index)=i;
J(index)=j;
index=index+1;
end;

&&

((i-i_cen)^2+(j-

end
end
%Get index of source locations
Id=ones(1,2);
Jd=ones(1,2);
index=1;
for i=1:ie_tot
for j=1:je_tot
if
(((i-i_cen)^2+(j-j_cen)^2)>(0.002/delta+0.4)^2
j_cen)^2)<(0.002/delta+1.4)^2)
Id(index)=i;
Jd(index)=j;
index=index+1;
end
end
end

&&

source=[i_src-i_cen 0];
phi=ones(1,size(Id,2));
for i=1:size(Id,2)
a=[Id(i)-i_cen Jd(i)-j_cen];
l=sqrt(source(1)^2+source(2)^2)*sqrt(a(1)^2+a(2)^2);
cfi=dot(a,source)/l;
phi(i)=acos(cfi);
if a(2)<0
phi(i)=2*pi-phi(i);
end
end
for i=1:length(phi)-1
for j=i+1:length(phi)
if phi(j)<phi(i)
temp=phi(i);
phi(i)=phi(j);
phi(j)=temp;
temp=Id(i);
Id(i)=Id(j);
Id(j)=temp;
temp=Jd(i);
Jd(i)=Jd(j);
Jd(j)=temp;
end
end
end

%***********************************************************************
% compute observation points angle
%***********************************************************************

((i-i_cen)^2+(j-

source=[i_src-i_cen 0];
fi=ones(1,size(I,2));
for i=1:size(I,2)
a=[I(i)-i_cen J(i)-j_cen];
l=sqrt(source(1)^2+source(2)^2)*sqrt(a(1)^2+a(2)^2);
cfi=dot(a,source)/l;
fi(i)=acos(cfi);
if a(2)<0
fi(i)=2*pi-fi(i);
end
end
for i=1:size(fi,2)-1
for j=i+1:size(fi,2)
if fi(j)<fi(i)
temp=fi(i);
fi(i)=fi(j);
fi(j)=temp;
temp=I(i);
I(i)=I(j);
I(j)=temp;
temp=J(i);
J(i)=J(j);
J(j)=temp;
end
end
end
%delete some observation points, avoid 'noisy' data
i=1;
while (i<length(fi))
if abs(fi(i)-fi(i+1))<0.02
fi(i+1)=[];
I(i+1)=[];
J(i+1)=[];
else i=i+1;
end
end
eps=[epsrb epsrs 1/2*(epsrb+epsrs)];
sig=[sigrb sigrs 1/2*(sigrb+sigrs)];
mu=[1.0 1.0 1.0];
sigstar=[0.0 0.0 0.0];
disp=0.45e-3;
rc=-(sqrt(epsrs)-sqrt(epsrb))/(sqrt(epsrs)+sqrt(epsrb));
%***********************************************************************
% Compute Sources
%***********************************************************************

Jz=zeros(nmax-1,length(Id));
for i=2:nmax
Jz(i-1,:)=-(disp.*(epsrs*epsz-epsrb*epsz).*(eoz(i,:)-eoz(i-1,:))./dt+disp*(sigrssigrb)*(eoz(i,:)+eoz(i-1,:))/2);
end
Jz=Jz./delta;
%***********************************************************************
% Main Grid Coefficients
%***********************************************************************
ca=(1.0-(dt*sig)./(2.0*epsz*eps))./(1.0+(dt*sig)./(2.0*epsz*eps));
cb=(dt./epsz./eps./delta)./(1.0+(dt*sig)./(2.0*epsz*eps));
da=(1.0-(sigstar*dt)./(2.0*muz*mu))./(1.0+(dt*sigstar)./(2.0*muz*mu));
db=(dt./muz./mu./delta)./(1.0+(dt*sigstar)./(2.0*muz*mu));
%***********************************************************************
% UPML Coefficients
%***********************************************************************
%Update coefficients in PML region
R0=exp(-16);
%reflection error
m=4;
%order of polynomial grading
d=upml*delta;
%thickness of pml slabs;
eta=sqrt(muz/epsrb/epsz);
%x-direction
sigxmax=-(m+1)*log(R0/100)/2/d/eta;
kxmax=1.0;
sigfactor=sigxmax/(m+1)/(d^m)/delta;
kfactor=(kxmax-1)/(m+1)/(d^m)/delta;
for i=1:upml
%coefficients on the boundary
x2=(upml-i+1.5)*delta;
x1=(upml-i+0.5)*delta;
sigx=(x2^(m+1)-x1^(m+1))*sigfactor;
kx=1+(x2^(m+1)-x1^(m+1))*kfactor;
C1=(2*epsrb*epsz*kx-sigx*dt)/(2*epsrb*epsz*kx+sigx*dt);
C2=(2*epsrb*epsz*dt)/(2*epsrb*epsz*kx+sigx*dt);
D5=(2*epsrb*epsz*kx+sigx*dt);
D6=(2*epsrb*epsz*kx-sigx*dt);
C1ez(i,:)=C1;
C1ez(ie_tot-i+1,:)=C1;
C2ez(i,:)=C2;
C2ez(ie_tot-i+1,:)=C2;
D5hx(i,:)=D5;
D5hx(ie_tot-i+1,:)=D5;
D6hx(i,:)=D6;
D6hx(ie_tot-i+1,:)=D6;

%coefficients in the center


x2=(upml-i+1)*delta;
x1=(upml-i)*delta;
sigx=(x2^(m+1)-x1^(m+1))*sigfactor;
kx=1+(x2^(m+1)-x1^(m+1))*kfactor;
D3=(2*epsrb*epsz*kx-sigx*dt)/(2*epsrb*epsz*kx+sigx*dt);
D4=1.0/(2*epsrb*epsz*kx+sigx*dt)/muz;
D3hy(i,:)=D3;
D3hy(ih_tot-i+1,:)=D3;
D4hy(i,:)=D4;
D4hy(ih_tot-i+1,:)=D4;
end
% Model PEC walls
C1ez(1,:)=-1.0;
C1ez(ie_tot,:)=-1.0;
C2ez(1,:)=0.0;
C2ez(ie_tot,:)=0.0;
%y-direction
sigymax=-(m+1)*log(R0/100)/2/d/eta;
kymax=1.0;
sigfactor=sigymax/(m+1)/(d^m)/delta;
kfactor=(kymax-1)/(m+1)/(d^m)/delta;
for j=1:upml
%coefficients on the boundary
y2=(upml-j+1.5)*delta;
y1=(upml-j+0.5)*delta;
sigy=(y2^(m+1)-y1^(m+1))*sigfactor;
ky=1+(y2^(m+1)-y1^(m+1))*kfactor;
C3=(2*epsrb*epsz*ky-sigy*dt)/(2*epsrb*epsz*ky+sigy*dt);
C4=1.0/(2*epsrb*epsz*ky+sigy*dt)/epsrb/epsz;
D5=(2*epsrb*epsz*ky+sigy*dt);
D6=(2*epsrb*epsz*ky-sigy*dt);
C3ez(:,j)=C3;
C3ez(:,je_tot-j+1)=C3;
C4ez(:,j)=C4;
C4ez(:,je_tot-j+1)=C4;
D5hy(:,j)=D5;
D5hy(:,je_tot-j+1)=D5;
D6hy(:,j)=D6;
D6hy(:,je_tot-j+1)=D6;
%coefficients in the center
y2=(upml-j+1)*delta;
y1=(upml-j)*delta;
sigy=(y2^(m+1)-y1^(m+1))*sigfactor;
ky=1+(y2^(m+1)-y1^(m+1))*kfactor;
D1=(2*epsrb*epsz*ky-sigy*dt)/(2*epsrb*epsz*ky+sigy*dt);

D2=2*epsrb*epsz*dt/(2*epsrb*epsz*ky+sigy*dt);
D1hx(:,j)=D1;
D1hx(:,jh_tot-j+1)=D1;
D2hx(:,j)=D2;
D2hx(:,jh_tot-j+1)=D2;
end
% Model PEC walls
C3ez(:,1)=-1.0;
C3ez(:,je_tot)=-1.0;
C4ez(:,1)=0.0;
C4ez(:,je_tot)=0.0;

%***********************************************************************
% BEGIN TIME-STEPPING LOOP
%***********************************************************************
ez_obs(nmax,size(I,2))=0.0;
ftr(1,size(I,2))=0.0;
fti(1,size(I,2))=0.0;
for n=1:nmax-1
%***********************************************************************
% Update electric fields
%***********************************************************************
es=ez;
ez(upml+1:ie_tot-upml,upml+1:je_tot-upml)=ca(MEDIAez(upml+1:ie_totupml,upml+1:je_tot-upml)).*ez(upml+1:ie_tot-upml,upml+1:je_tot-upml)+...
cb(MEDIAez(upml+1:ie_tot-upml,upml+1:je_tot-upml)).*...
(hy(upml+1:ie_tot-upml,upml+1:je_tot-upml)-hy(upml:ih_tot-upml,upml+1:je_totupml)+...
hx(upml+1:ie_tot-upml,upml:jh_tot-upml)-hx(upml+1:ie_tot-upml,upml+1:je_totupml));
ds=dz;
dz(2:upml,2:je_tot-1)=C1ez(2:upml,2:je_tot-1).*dz(2:upml,2:je_tot-1)+...
C2ez(2:upml,2:je_tot-1)./delta.*((hy(2:upml,2:je_tot-1)-hy(1:upml-1,2:je_tot-1))-...
(hx(2:upml,2:je_tot-1)-hx(2:upml,1:je_tot-2)));
ez(2:upml,2:je_tot-1)=C3ez(2:upml,2:je_tot-1).*es(2:upml,2:je_tot-1)+...
C4ez(2:upml,2:je_tot-1).*(C5ez(2:upml,2:je_tot-1).*dz(2:upml,2:je_tot-1)C6ez(2:upml,2:je_tot-1).*ds(2:upml,2:je_tot-1));
dz(upml+1:ie_tot-1,2:upml)=C1ez(upml+1:ie_tot-1,2:upml).*ds(upml+1:ie_tot-1,2:upml)+...
C2ez(upml+1:ie_tot-1,2:upml)./delta.*((hy(upml+1:ie_tot-1,2:upml)-hy(upml:ie_tot2,2:upml))-...
(hx(upml+1:ie_tot-1,2:upml)-hx(upml+1:ie_tot-1,1:upml-1)));
ez(upml+1:ie_tot-1,2:upml)=C3ez(upml+1:ie_tot-1,2:upml).*es(upml+1:ie_tot-1,2:upml)+...
C4ez(upml+1:ie_tot-1,2:upml).*(C5ez(upml+1:ie_tot1,2:upml).*dz(upml+1:ie_tot-1,2:upml)-...

C6ez(upml+1:ie_tot-1,2:upml).*ds(upml+1:ie_tot-1,2:upml));
dz(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1)=C1ez(upml+1:ie_tot-1,je_tot-upml+1:je_tot1).*ds(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1)+...
C2ez(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1)./delta.*...
((hy(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1)-hy(upml:ie_tot-2,je_tot-upml+1:je_tot1))-...
(hx(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1)-hx(upml+1:ie_tot-1,je_tot-upml:je_tot2)));
ez(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1)=C3ez(upml+1:ie_tot-1,je_tot-upml+1:je_tot1).*es(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1)+...
C4ez(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1).*...
(C5ez(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1).*dz(upml+1:ie_tot-1,je_totupml+1:je_tot-1)-...
C6ez(upml+1:ie_tot-1,je_tot-upml+1:je_tot-1).*ds(upml+1:ie_tot-1,je_totupml+1:je_tot-1));
dz(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml)=C1ez(ie_tot-upml+1:ie_tot-1,upml+1:je_totupml).*ds(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml)+...
C2ez(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml)./delta.*...
((hy(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml)-hy(ie_tot-upml:ie_tot2,upml+1:je_tot-upml))-...
(hx(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml)-hx(ie_tot-upml+1:ie_tot1,upml:je_tot-upml-1)));
ez(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml)=C3ez(ie_tot-upml+1:ie_tot-1,upml+1:je_totupml).*es(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml)+...
C4ez(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml).*...
(C5ez(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml).*dz(ie_tot-upml+1:ie_tot1,upml+1:je_tot-upml)-...
C6ez(ie_tot-upml+1:ie_tot-1,upml+1:je_tot-upml).*ds(ie_tot-upml+1:ie_tot1,upml+1:je_tot-upml));
for i=1:length(Id)
ez(Id(i),Jd(i))=ez(Id(i),Jd(i))-cb(MEDIAez(Id(i),Jd(i)))*delta*Jz(n,i);
end
%***********************************************************************
% Update magnetic fields
%***********************************************************************
hs=hx;
hx(upml+1:ie_tot-upml,upml+1:jh_tot-upml)=da(MEDIAhx(upml+1:ie_totupml,upml+1:jh_tot-upml)).*hx(upml+1:ie_tot-upml,upml+1:jh_tot-upml)+...
db(MEDIAhx(upml+1:ie_tot-upml,upml+1:jh_tot-upml)).*(ez(upml+1:ie_totupml,upml+1:jh_tot-upml)-ez(upml+1:ie_tot-upml,upml+2:je_tot-upml));
bs=bx;
bx(1:upml,:)=D1hx(1:upml,:).*bx(1:upml,:)-D2hx(1:upml,:).*(ez(1:upml,2:je_tot)ez(1:upml,1:jh_tot))./delta;
hx(1:upml,:)=D3hx(1:upml,:).*hx(1:upml,:)+D4hx(1:upml,:).*(D5hx(1:upml,:).*bx(1:upml,:)D6hx(1:upml,:).*bs(1:upml,:));

bx(upml+1:ie_tot,1:upml)=D1hx(upml+1:ie_tot,1:upml).*bs(upml+1:ie_tot,1:upml)-...
D2hx(upml+1:ie_tot,1:upml).*(ez(upml+1:ie_tot,2:upml+1)ez(upml+1:ie_tot,1:upml))./delta;
hx(upml+1:ie_tot,1:upml)=D3hx(upml+1:ie_tot,1:upml).*hs(upml+1:ie_tot,1:upml)+D4hx(u
pml+1:ie_tot,1:upml).*...
(D5hx(upml+1:ie_tot,1:upml).*bx(upml+1:ie_tot,1:upml)D6hx(upml+1:ie_tot,1:upml).*bs(upml+1:ie_tot,1:upml));
bx(ie_tot-upml+1:ie_tot,upml+1:jh_tot)=D1hx(ie_totupml+1:ie_tot,upml+1:jh_tot).*bs(ie_tot-upml+1:ie_tot,upml+1:jh_tot)-...
D2hx(ie_tot-upml+1:ie_tot,upml+1:jh_tot).*(ez(ie_tot-upml+1:ie_tot,upml+2:jh_tot+1)ez(ie_tot-upml+1:ie_tot,upml+1:jh_tot))./delta;
hx(ie_tot-upml+1:ie_tot,upml+1:jh_tot)=D3hx(ie_tot-upml+1:ie_tot,upml+1:jh_tot).*...
hs(ie_tot-upml+1:ie_tot,upml+1:jh_tot)+D4hx(ie_tot-upml+1:ie_tot,upml+1:jh_tot).*...
(D5hx(ie_tot-upml+1:ie_tot,upml+1:jh_tot).*bx(ie_tot-upml+1:ie_tot,upml+1:jh_tot)-...
D6hx(ie_tot-upml+1:ie_tot,upml+1:jh_tot).*bs(ie_tot-upml+1:ie_tot,upml+1:jh_tot));
bx(upml+1:ie_tot-upml,jh_tot-upml+1:jh_tot)=D1hx(upml+1:ie_tot-upml,jh_totupml+1:jh_tot).*bs(upml+1:ie_tot-upml,jh_tot-upml+1:jh_tot)-...
D2hx(upml+1:ie_tot-upml,jh_tot-upml+1:jh_tot).*...
(ez(upml+1:ie_tot-upml,jh_tot-upml+2:jh_tot+1)-ez(upml+1:ie_tot-upml,jh_totupml+1:jh_tot))./delta;
hx(upml+1:ie_tot-upml,jh_tot-upml+1:jh_tot)=D3hx(upml+1:ie_tot-upml,jh_totupml+1:jh_tot).*...
hs(upml+1:ie_tot-upml,jh_tot-upml+1:jh_tot)+D4hx(upml+1:ie_tot-upml,jh_totupml+1:jh_tot).*...
(D5hx(upml+1:ie_tot-upml,jh_tot-upml+1:jh_tot).*bx(upml+1:ie_tot-upml,jh_totupml+1:jh_tot)-...
D6hx(upml+1:ie_tot-upml,jh_tot-upml+1:jh_tot).*bs(upml+1:ie_tot-upml,jh_totupml+1:jh_tot));

hs=hy;
hy(upml+1:ih_tot-upml,upml+1:je_tot-upml)=da(MEDIAhy(upml+1:ih_totupml,upml+1:je_tot-upml)).*...
hy(upml+1:ih_tot-upml,upml+1:je_tot-upml)+db(MEDIAhy(upml+1:ih_totupml,upml+1:je_tot-upml)).*...
(ez(upml+2:ie_tot-upml,upml+1:je_tot-upml)-ez(upml+1:ih_tot-upml,upml+1:je_totupml));
bs=by;
by(1:upml,:)=D1hy(1:upml,:).*by(1:upml,:)-D2hy(1:upml,:).*(-(ez(2:upml+1,1:je_tot)ez(1:upml,1:je_tot)))./delta;
hy(1:upml,:)=D3hy(1:upml,:).*hy(1:upml,:)+D4hy(1:upml,:).*(D5hy(1:upml,:).*by(1:upml,:)D6hy(1:upml,:).*bs(1:upml,:));
by(upml+1:ih_tot,1:upml)=D1hy(upml+1:ih_tot,1:upml).*bs(upml+1:ih_tot,1:upml)-...
D2hy(upml+1:ih_tot,1:upml).*(-(ez(upml+2:ih_tot+1,1:upml)ez(upml+1:ih_tot,1:upml)))./delta;

hy(upml+1:ih_tot,1:upml)=D3hy(upml+1:ih_tot,1:upml).*hs(upml+1:ih_tot,1:upml)+D4hy(u
pml+1:ih_tot,1:upml).*...
(D5hy(upml+1:ih_tot,1:upml).*by(upml+1:ih_tot,1:upml)D6hy(upml+1:ih_tot,1:upml).*bs(upml+1:ih_tot,1:upml));
by(ih_tot-upml+1:ih_tot,upml+1:je_tot)=D1hy(ih_totupml+1:ih_tot,upml+1:je_tot).*bs(ih_tot-upml+1:ih_tot,upml+1:je_tot)-...
D2hy(ih_tot-upml+1:ih_tot,upml+1:je_tot).*(-(ez(ih_tot-upml+2:ih_tot+1,upml+1:je_tot)ez(ih_tot-upml+1:ih_tot,upml+1:je_tot)))./delta;
hy(ih_tot-upml+1:ih_tot,upml+1:je_tot)=D3hy(ih_totupml+1:ih_tot,upml+1:je_tot).*hs(ih_tot-upml+1:ih_tot,upml+1:je_tot)+...
D4hy(ih_tot-upml+1:ih_tot,upml+1:je_tot).*(D5hy(ih_totupml+1:ih_tot,upml+1:je_tot).*by(ih_tot-upml+1:ih_tot,upml+1:je_tot)-...
D6hy(ih_tot-upml+1:ih_tot,upml+1:je_tot).*bs(ih_tot-upml+1:ih_tot,upml+1:je_tot));
by(upml+1:ih_tot-upml,je_tot-upml+1:je_tot)=D1hy(upml+1:ih_tot-upml,je_totupml+1:je_tot).*bs(upml+1:ih_tot-upml,je_tot-upml+1:je_tot)-...
D2hy(upml+1:ih_tot-upml,je_tot-upml+1:je_tot).*...
(-(ez(upml+2:ih_tot-upml+1,je_tot-upml+1:je_tot)-ez(upml+1:ih_tot-upml,je_totupml+1:je_tot)))./delta;
hy(upml+1:ih_tot-upml,je_tot-upml+1:je_tot)=D3hy(upml+1:ih_tot-upml,je_totupml+1:je_tot).*hs(upml+1:ih_tot-upml,je_tot-upml+1:je_tot)+...
D4hy(upml+1:ih_tot-upml,je_tot-upml+1:je_tot).*...
(D5hy(upml+1:ih_tot-upml,je_tot-upml+1:je_tot).*by(upml+1:ih_tot-upml,je_totupml+1:je_tot)-...
D6hy(upml+1:ih_tot-upml,je_tot-upml+1:je_tot).*bs(upml+1:ih_tot-upml,je_totupml+1:je_tot));
%***********************************************************************
% Get obseverations, compute phasor quantities
%***********************************************************************
for i=1:size(I,2)
ez_obs(n,i)=ez(I(i),J(i));
ftr(i)=ftr(i)+ez_obs(n,i)*cos(omega*n*dt);
fti(i)=fti(i)+ez_obs(n,i)*sin(omega*n*dt);
end
end
Ed=(ftr-1j*fti);

Das könnte Ihnen auch gefallen