ZIP with MATLAB scripts and note:
example 6.8
example 6.8 notes:
This example is about calculating the frequency deviation caused by the introduction of a structure in a resonant cavity. The available example recurs to cylinder volume formula to calculate the sized space by the perturbing structure, but with MATLAB, exact values of fields within the intersection of volumes can be reached, therefore extending the frequency deviation calculation to any arbitrary shape.
It would be accurate to calculate frequency deviations with the exact expression: (310pg):
same as
But when fields E H and band parameters not known, but for
-
small surface of cavity perturbing structure
-
all frequencies close enough to f0, for any f: |f-f0|<<1
then the 3rd expression may be used:
the numerator integral of the initial expression can be constrained to the volume where the material is introduced in the cavity, therefore
Wm We: stored magnetic and electric energy
General expressions of electric and magnetic energy:
Although this example shows the perturbation of a cavity with a fairly regular structure, it would be useful to have a way to calculate electric and magnetic fields within the structure so that there’s no need to recur to volume formulae of simple structures as it’s the case for this example.
Knowing E and H in each point of the resonant cavity would allow calculating frequency deviations for any arbitrary perturbing structure.
c0=299792458
f0=5e9
er=3;e0=8.854e-12;
mur=1;mu0=4*pi*10^-7
A=1
etha0=120*pi;lambda0=c0/f0;k0=2*pi/lambda0
a=.02;b=.01;d=.02
t=.0025
dx=a/200;
x=[0:a/200:a];y=[0:b/200:b];z=[0:d/200:d];
% empty cavity
% space points
[X Y Z]=meshgrid(x,y,z);
P=[X(:) Y(:) Z(:)]; % cavity points line-up
% E H field values
Ey=A*sin(pi*X/a).*sin(pi*Z/d);
Hx=-1j*A/(etha0)*sin(pi*X/a).*cos(pi*Z/d);
Hz=1j*pi*A/(k0*etha0*a)*cos(pi*X/a).*sin(pi*Z/d);
Ex=zeros(size(Ey));Ez=zeros(size(Ey));
Hy=zeros(size(Hx));
Hy=zeros(size(Hx));
% We [J] : stored electric field energy in cavity space free of perturbation
E20=Ex.*conj(Ex)+Ey.*conj(Ey)+Ez.*conj(Ez);
We=e0*er/4*sum(E20(:))
% Wm [J] : stored magnetic field energy in cavity space free of perturbation
H20=Hx.*conj(Hx)+Hy.*conj(Hy)+Hz.*conj(Hz);
Wm=mu0*mur/4*sum(H20(:))
% the cavity
vert = [0 0 0;1 0 0;1 1 0;0 1 0;0 0 1;1 0 1;1 1 1;0 1 1];
vert(:,1)=a*vert(:,1); % defining cavity vertices
vert(:,2)=b*vert(:,2);
vert(:,3)=d*vert(:,3);
fac = [1 2 6 5;2 3 7 6;3 4 8 7;4 1 5 8;1 2 3 4;5 6 7 8];
hf1=figure(1); % defining cavity faces
hp1=patch('Vertices',vert,'Faces',fac)
view(3)
axis vis3d
hp1.FaceVertexCData=hsv(6)
hp1.FaceColor='none'
xlabel(hf1.CurrentAxes,'x: [0 a]');
ylabel(hf1.CurrentAxes,'y: [0 b]');
zlabel(hf1.CurrentAxes,'z: [0 d]');
hf1.CurrentAxes.DataAspectRatio=[1 1 1]
the screw:
Ncyl=24
[x1, y1, z1]=cylinder(a/8*ones(1,numel(z)),Ncyl);
x1=x1(:); % cylinder r=a/20 and 24 points or faces.
y1=y1(:);
z1=d*z1(:);
x2=x1+a/2;y2= y1+b/2;
Pcyl=[x2 y2 z1]; % centering screw inside cavity
Pcyl=unique(Pcyl,'rows');
Pcyl=sortrows(Pcyl,3);
shp_cyl=alphaShape(Pcyl,1.5); % arrange Pcyl points in layers
hold all;plot(shp_cyl)
% find what cavity points inside screw volume
nL=numel(x)*numel(y)
% checking both cavity and screw shape have same amount layers
isequal(size(Pcyl,1)/Ncyl,size(P,1)/nL)
% now checking each layer for what cavity points fall inside screw volume
nlayer=size(Pcyl,1)/Ncyl
isequal(nlayer,numel(z))
% same as checking amount layers = numel(z)
Comment: 1st I considered that to collect cavity points found within screw volume a regular variable like P2=[x1 y1 z1] with x1 y1 z1 column vectors would be a problem to collect the cavity points found within screw volume because the amount of caught points in each layer may have a varying amount, so I collected such points inside the cavity perturbing structure with a cell
P2={}
but the resulting cell is
P2 =
201×1 cell array
[1059×3 double]
[1059×3 double]
..
[1059×3 double]
so at least for such simple device to vary the resonant frequency it seems ok to use the following:
syms tx ty tz
fEy=@(tx,ty,tz) A*sin(pi*tx/a).*sin(pi*tz/d);
fHx=@(tx,ty,tz) -1j*A/(etha0)*sin(pi*tx/a).*cos(pi*tz/d);
fHz=@(tx,ty,tz) 1j*pi*A/(k0*etha0*a)*cos(pi*tx/a).*sin(pi*tz/d);
fE=@(tx,ty,tz) [zeros(numel(fEy(tx,ty,tz)),1)...
fEy(tx,ty,tz)...
zeros(numel(fEy(tx,ty,tz)),1)]
fH=@(tx,ty,tz) [fHx(tx,ty,tz)...
zeros(numel(fHx(tx,ty,tz)),1)...
fHz(tx,ty,tz)]
% numerator: only use points captured with volumes intersection
E_dv=fE(P2(:,1),P2(:,2),P2(:,3));
H_dv=fH(P2(:,1),P2(:,2),P2(:,3));
sum_E02_dv=abs(dot(E_dv(:,1),conj(E_dv(:,1))))+...
abs(dot(E_dv(:,2),conj(E_dv(:,2))))+...
abs(dot(E_dv(:,3),conj(E_dv(:,3))));
de=e0*(er-1)
% this is the permittivity delta , do not use the relative permittivity directly,
% or the frequency deviation shows up positive when it should be negative
dWe=de*sum_E02_dv
% dWe=e0*sum_E02_dv
sum_H02_dv=abs(dot(H_dv(:,1),conj(H_dv(:,1))))+...
abs(dot(H_dv(:,2),conj(H_dv(:,2))))+...
abs(dot(H_dv(:,3),conj(H_dv(:,3))));
du=mu0*(mur-1) % permeability delta
% if no ferromagnetic materials used, this term is null.
dWm=du*sum_H02_dv
% dWm=mu0*sum_H02_dv
% denominator : use all points that configure the cavity
E_cav=fE(P(:,1),P(:,2),P(:,3));
H_cav=fH(P(:,1),P(:,2),P(:,3));
sum_E02_cav=abs(dot(E_cav(:,1),conj(E_cav(:,1))))+...
abs(dot(E_cav(:,2),conj(E_cav(:,2))))+...
abs(dot(E_cav(:,3),conj(E_cav(:,3))));
We=e0*sum_E02_cav
sum_H02_cav=abs(dot(H_cav(:,1),conj(H_cav(:,1))))+...
abs(dot(H_cav(:,2),conj(H_cav(:,2))))+...
abs(dot(H_cav(:,3),conj(H_cav(:,3))));
Wm=mu0*sum_H02_cav
% dWm=mu0*mur*sum(H.*conj(H))
Therefore df/d0 = (f-f0)/f0 ~
(dWm-dWe)/(Wm+We)
de =
1.770800000000000e-11
dWe =
1.807597647858942e-06
du =
0
dWm =
0
We =
1.779653999998257e-05
Wm =
5.828171981278552e-05
=
-0.023759713383396