-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_rec_WG.m
144 lines (110 loc) · 4.12 KB
/
test_rec_WG.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
% test_microstrip_line.m
% test_horn_antenna.m
warning off;
clc
clear
close all
pkg load geometry
pkg load miscellaneous
modelerPath = './Modeler_2D';
mesherPath = '../mesh2d';
meshWrapperPath = './Mesh_2D';
solver2DPath = './Solver_2D';
solver1DPath = './Solver_1D';
miscPath = './misc';
addpath(modelerPath);
addpath(genpath(mesherPath));
addpath(meshWrapperPath);
addpath(solver2DPath);
addpath(solver1DPath);
addpath(miscPath);
% Simulation properties
simProps = cem2D_createSimPropsStruct(...
'fMin',1,...
'fMax',3.5,...
'polarizationType','TE');
% Global mesh properties
meshProps = mesh2D_createMeshPropsStruct(...
'relWLmeshMax',0.1, ...
'boundingBoxAddSpace',1, ...
'algorithmType','delfront',...
'maxRadiusEdgeRatio',1.5);
% Unless overridden, f_sim will be set to the average between fMin and fMax
% f_sim = 3;
% Line Properties
WG_H = 55;
WG_W = 110;
WG_Box = mod2D_createRectangleStruct([-0.5*WG_W 0],[0.5*WG_W WG_H]);
% Create the materials for this simulation
material_default = cem2D_createMaterialDefs;
material_PEC = cem2D_createMaterialDefs('name','PEC','type','PEC');
%material_FR4 = cem2D_createMaterialDefs('name','FR4','type','normal','er',4.3);
% Create the material list with only the default material
materialList = cem2D_addMaterialToList(material_default);
materialList = cem2D_addMaterialToList(material_PEC,materialList);
%materialList = cem2D_addMaterialToList(material_FR4,materialList);
% Create polygon list
polList = {WG_Box};
% Assign materials per-shape
materialAssignement = {'default'};
%%%%%%%%%%%%%%%%%%%%%
% Plot the geometry %
%%%%%%%%%%%%%%%%%%%%%
figHdl = figure;
axHdl = axes;
mod2D_showPolygon(axHdl,WG_Box,[1 1 1],[0 0 0]);
set(gca,'fontsize',14);
xlabel('x [mm]','fontsize',16);
ylabel('y [mm]','fontsize',16);
%%%%%%%%%%%%%%%%%%%%%
% Plot the geometry %
%%%%%%%%%%%%%%%%%%%%%
lineList = {};
% Test mesh of bounding box
meshData = mesh2D_generateInitialMesh(...
polList,... % Entire polygon list. This is mainly to calculate the maximum\minimum edge length
lineList,... % List of lines. Used for porst, mainly.
materialAssignement,... % Material assignments for initial LFS assignment
materialList,... % Corresponding material properties
meshProps,... % Darrens Mesher properties
simProps); % Simulation properties. This is to assign spatial meshing rules, most
% Smooth the mesh
meshData = mesh2D_smoothMesh(meshData,meshProps);
if exist('f_sim','var')
if isempty(f_sim)
f_sim = 0.5*(simProps.fMin + simProps.fMax);
end
else
f_sim = 0.5*(simProps.fMin + simProps.fMax);
end
%[fc_TE,fc_TM,Et,Ez,edgeTriplets] = cem2D_calcPortModes(meshData,meshProps,materialList,materialAssignement,simProps,f_sim);
[fc_TE,fc_TM,Et,Ez,edgeTriplets] = cem2D_calcModesByCutoff(meshData,meshProps,materialList,materialAssignement,simProps);
%%[fc_TE,fc_TM,Ete,Htm,edgeTriplets] = cem2D_calcModesByCutoff_TETM(meshData,meshProps,materialList,materialAssignement,simProps);
fc_large_idxs = find(fc_TE > 1e9);
c0 = physical_constant('speed of light in vacuum');
kc_TE = 2*pi*fc_TE/c0;
kc_TM = 2*pi*fc_TM/c0;
ref_TE = kc_TE*(WG_W/1000);
ref_TM = kc_TM*(WG_W/1000);
hold(axHdl,'on');
for tIdx = unique(meshData.tnum).'
patch('faces',meshData.tria(meshData.tnum == tIdx,1:3),'vertices',meshData.vert, ...
'facecolor','none', ...
'edgecolor',[0,0,0]) ;
end
%hold on;
%for eIdx = unique(meshData.etri(:))
% plot(meshData.vert(eIdx,1),meshData.vert(eIdx,2),'.r','markersize',10);
%end
%hold off;
[Xm,Ym] = meshgrid(linspace(-0.5*WG_W,0.5*WG_W,25),linspace(0,WG_H,15));
EI = cem2D_vectorElementInterp(...
meshData.vert,...
meshData.tria,...
edgeTriplets,...
Et(:,fc_large_idxs(1)));
Exy = EI(Xm,Ym);
qHdl = quiver(Xm(:),Ym(:),abs(Exy(:,1)),abs(Exy(:,2)));
set(qHdl,'color',[1 0 0]);
hold(axHdl,'off');
warning off;