📄 sonnet_inset_patch.m
字号:
function sonnet_inset_patch(Er, length, width, width_res, h, Ro, sonnet_file, Leff, yo)
% This function was created by Gazi K ASadullah
% This function creates the geometry file for Sonnet using the all the input parameters.
% width = width of microstrip Antenna
% Leff = Effective length of Microstrip Antenna
% h = Thickness of Microstrip Antenna
% length= length of Microstrip Antenna
% width_res = width of the feedline of microstrip Antenna
% Er= Dielectric constant
% Ro= Impedance of feedline
% Sonnet_file= Name of the file where the geometry will be created.
% yo= Point of inset feed.
% To convert to cm Uncomment this:
% length=length*2.54;
% width_res=width_res*2.54;
% h=0.5;
% width=width*2.54;
% Leff=Leff*2.54;
% yo=yo*2.54;
cell=0.0;
% Setting up the Cell size
if (width_res >= 0.2)
cell=0.1;
end
if ((width_res >= 0.1) & (width_res <0.2))
cell=0.05;
end
if (width_res < 0.1)
cell=0.025;
end
% Calculating the lamda based on cell size.
lamda=2*Leff;
dim4=lamda/cell;
dim4=round(dim4);
lamda=dim4*cell;
% if (lamda < 0.8)
% cell=cell/2;
% end
lamda=2*Leff;
dim4=lamda/cell;
dim4=round(dim4);
lamda=dim4*cell;
% Calculating the Width of feedline based on cell size.
dim_3=(width_res/cell);
dim_3=round(dim_3);
width_res=(cell*dim_3);
% Calculating the length of patch antenna based on cell size.
dim1=length/cell;
dim1=round(dim1);
length=(cell*dim1);
% Calculating the length of patch antenna based on cell size resolution.
dim_2=width/cell;
dim_2=round(dim_2);
width=(cell*dim_2);
% Calculating the inset feed of patch antenna based on cell size resolution.
dim_y=yo/cell;
dim_y=round(dim_y);
yo=(cell*dim_y);
%opening specific file to write on it
A=fopen(sonnet_file,'w');
n=2; % number of boxes:2
total_len=0;
%total_len=round_up(length);
%calculating to total length (outside box length) for Sonnet
total_len2=(lamda*6);
% dim=total_len2/cell;
% dim=round(dim);
% total_len2=cell*dim;
%Calculating number of boxes:
dimension = ((total_len2/cell))*2;
%dimension1=((total_width/cell))*2;
dimension=num2str(dimension);
fprintf (A, '%s\n', 'LEN IN 0.0254'); %Selecting working unit (inch here)
% fprintf (A, '%s\n', 'LEN CM 1e-002');
%fprintf (A, '%s\n', 'SYM');
fprintf(A, '%s\n' , 'REF 0 0 0 0 0 0 0 0');
fprintf(A, '%s\n' , 'TOP 376.7303136 0 0 0');
fprintf(A, '%s\n' , 'TON 0 Free Space'); %Declaring the Top wall in free space
fprintf(A, '%s\n' , 'BOT 0 0 0 0');
fprintf(A, '%s\n' , 'BON 0 Lossless');
%printing parameters
fprintf (A, 'box 1 %d %d %s %s 20 0\n', total_len2, total_len2, dimension, dimension);
fprintf (A, ' %d 1 1 0 0 0 2 "Air"\n', total_len2*5);
fprintf (A, ' %d %f 1 0.0013 0 0 2', h, Er);
fprintf (A, '\n%s', 'POR 0 3 0 1 ');
fprintf (A, '%d 0 0 0 0 0 \n', Ro);
% fprintf (A, '%s %d %s', 'POR', n-1,'1 0 2 ');
% fprintf (A, '%d 0 0 0 0 0\n', Ro);
fprintf (A, '%s %d\n', 'NUM', n);
p=9;
fprintf (A, '0 5 -1 N %d 1 1 100 100 0 0 0\n', p);
%Creating the first Box (feedline)
a=0;
b=0+((total_len2/2)-(width_res/2));
dim6=b/cell;
dim6=round(dim6);
b=dim6*cell;
m=b;
c= b+width_res;
n=c;
d=((total_len2/2)-(length/2));
dim5=d/cell;
dim5=round(dim5);
d=dim5*cell;
box=[d c;d b;a b; a c];
% printing out the points
fprintf (A, '%.3f %.3f\n', a, c);
fprintf (A, '%.3f %.3f\n%.3f %.3f\n%.3f %.3f\n%.3f %.3f\n ', d, c, d, b, a, b, a, c);
fprintf (A, '%s\n', 'END');
p=p+1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculation for the second box (inset feed patch Antenna)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a=d;
s=a-yo; % inset feed point
% normalizing the inset feed point based on cell size.
dim_s= s/cell;
dim_s=round(dim_s);
s=cell*dim_s;
b=((total_len2/2)-(width/2));
% Normalizing point based on cell size
dim7=b/cell;
dim7=round(dim7);
b=dim7*cell;
c=b+width;
q=n+(width_res/2);
dim=q/cell;
dim=round(dim);
q=dim*cell;
r=m-(width_res/2);
dim=r/cell;
dim=round(dim);
r=dim*cell;
%setting up the size of GAP.
% if (3*width_res > width)
% q=n+(width_res/2);
% r=m-(width_res/2);
% end
%
% if (3*width_res < width)
% q=n+(width_res);
% r=m-(width_res);
% end
% poind D
d=s+length;
%printing out the points
fprintf (A, '0 9 -1 N %d 1 1 100 100 0 0 0\n', p);
fprintf (A, '%.3f %.3f\n', s, r);
fprintf (A, '%.3f %.3f\n%.3f %.3f\n%.3f %.3f\n%.3f %.3f\n %.3f %.3f\n%.3f %.3f\n%.3f %.3f\n%.3f %.3f\n', s,b,d,b,d,c,s,c,s,q,a,q,a,r,s,r);
fprintf (A, '%s\n', 'END');
p=p+1;
fclose(A);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -