-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectTwoPostFilterNL.m
More file actions
99 lines (86 loc) · 2.51 KB
/
Copy pathProjectTwoPostFilterNL.m
File metadata and controls
99 lines (86 loc) · 2.51 KB
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
%% ProjectTwoPostFilterNL - Nonlinear two-post filter with Kerr effect (single-frequency)
clear all; clc;
Config();
%% Setup
Sys.pOrd = 2;
Sys.hOrd = 1;
a = 19.05;
b = a / 2;
r = 0.05 * a;
c = 0.4 * a;
L = 1.4 * a;
EpsR = 112.5;
nt = 60;
WriteTwoPosts(a, c, r, L, nt);
prjName = 'TwoPosts';
Mesh = IOrPoly(prjName, 'q34a1A', Sys.hOrd, 1e-3);
prjName = [prjName, 'NL'];
Sys.WPnModes = 1;
Sys.WPportPlot = 1;
Sys.WPmodePlot = 1;
Sys.WPpow = 1;
Sys.Einc = 10e3 * sqrt(1.651e-03 / 2);
Mesh.epsr = [1 EpsR];
Mesh.kerr = [0 1.625e-10];
Mesh.BC.Dir = 1;
Mesh.BC.WP = [11 12];
Sys = CalcDoFsNumber(Sys, Mesh);
Sys.u = zeros(Sys.NDOFs, 1);
%% Frequency loop with nonlinear iteration
fc = 7.868577546294576e+09;
Sys.nFreqs = 1;
Sys.freqs = 1.43 * fc;
Sys.fPlot = Sys.freqs(1);
Sys.Sparams = zeros(length(Mesh.BC.WP) * Sys.WPnModes, Sys.nFreqs);
for kf = 1:Sys.nFreqs
freq = Sys.freqs(kf);
fprintf('freq = %g GHz\n', freq / 1e9);
error = 1;
Sys.u0 = Sys.u;
while error > 1e-4
[Sys, Mesh] = AssembNL(Sys, Mesh);
Sys = AssembWP(Sys, freq);
X = Sys.A \ Sys.B;
%% Extract S-parameters
sp = X(1:length(Sys.WP) * Sys.WPnModes, ...
1:length(Sys.WP) * Sys.WPnModes) ...
- eye(length(Sys.WP) * Sys.WPnModes);
Sys.Sparams(:, kf) = sp(:, ...
(Sys.WPportPlot - 1) * Sys.WPnModes + Sys.WPmodePlot);
%% Recover field
Sys.u = zeros(Sys.NDOFs, ...
(Sys.WPportPlot - 1) * Sys.WPnModes + Sys.WPmodePlot);
Sys.u(Sys.nnWP) = X(length(Sys.WP) * Sys.WPnModes + 1:end, ...
(Sys.WPportPlot - 1) * Sys.WPnModes + Sys.WPmodePlot);
for ip = 1:length(Sys.WP)
Sys.u(Sys.WP{ip}) = Sys.WPgvec{ip} ...
* X((1:Sys.WPnModes) + (ip - 1) * Sys.WPnModes, ...
(Sys.WPportPlot - 1) * Sys.WPnModes + Sys.WPmodePlot);
end
error = norm(Sys.u - Sys.u0) / norm(Sys.u);
Sys.u0 = Sys.u;
fprintf(' %g\n', error);
end
if freq == Sys.fPlot
Sys.uPlot = Sys.u;
end
end
%% Postprocessing: S-parameters plot
figure;
plot(Sys.freqs, ...
Sys.db(Sys.Sparams(Sys.WPmodePlot:Sys.WPnModes:end, :).'));
%% Postprocessing: field visualization
Sys.u = Sys.uPlot;
if exist('pdeplot', 'file')
figure;
pdeplot(Mesh.refNode.', [], Mesh.refEle.', ...
'xydata', (abs(Sys.u)), ...
'mesh', 'off', ...
'colormap', 'jet', 'xygrid', 'off');
axis equal;
axis tight;
camlight left;
lighting phong;
else
IOwVTK(Sys, Mesh, prjName);
end