-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_various_systems.m
225 lines (208 loc) · 10.1 KB
/
example_various_systems.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
clc;
clear all;
close all;
addpath("src")
%% Time
ts = 0:100e-6:0.04;
n_t = length(ts);
wt = 2*pi*50*ts;
%% Input: Clarke's transform A and required voltage y
% SKIPPING 16
for j = 1:18
j
switch j
case 1
% Three-phase system, DOF: V0
fi = 2/3*pi;
A = 2/3*[1, cos(fi), cos(-fi);...
0, sin(fi), sin(-fi)];
ys = 1*[cos(wt); sin(wt)];
case 2
% Three-phase four-leg system, DOF: V0
fi = 2/3*pi;
A1 = 2/3*[1, cos(fi), cos(-fi);...
0, sin(fi), sin(-fi)];
A2 = [1, 0, 0, -1;...
0, 1, 0, -1;...
0, 0, 1, -1];
A = A1*A2;
ys = 1*[cos(wt); sin(wt)];
case 3
% Three-phase four-leg system, defined V0
fi = 2/3*pi;
A1 = 2/3*[1, cos(fi), cos(-fi);...
0, sin(fi), sin(-fi);...
1/2, 1/2, 1/2];
A2 = [1, 0, 0, -1;...
0, 1, 0, -1;...
0, 0, 1, -1];
A = A1*A2;
ys = 1*[cos(wt); sin(wt); -cos(wt)];
case 4
% Five-phase system, DOF: Vx1, Vy1, V0
fi = 2/5*pi;
A = 2/5*[1, cos(fi), cos(2*fi), cos(-2*fi), cos(-fi);...
0, sin(fi), sin(2*fi), sin(-2*fi), sin(-fi)];
ys = 1*[cos(wt); sin(wt)];
case 5
% Five-phase system, DOF: V0
fi = 2/5*pi;
A = 2/5*[1, cos(fi), cos(2*fi), cos(-2*fi), cos(-fi);...
0, sin(fi), sin(2*fi), sin(-2*fi), sin(-fi);...
1, cos(-2*fi), cos(fi), cos(-fi), cos(2*fi);...
0, sin(-2*fi), sin(fi), sin(-fi), sin(2*fi)];
ys = 1*[cos(wt); sin(wt); 0.15*cos(3*wt); 0.15*sin(3*wt)];
% Alternatively
% ys = 1*[cos(wt); sin(wt); zeros(1,n_t); zeros(1,n_t)];
case 6
% Five-phase system, fault-tolerant mode, DOF: Vx1, Vy1, V0
fi = 2/5*pi;
A = 2/5*[0, cos(fi), cos(2*fi), cos(-2*fi), cos(-fi);...
0, sin(fi), sin(2*fi), sin(-2*fi), sin(-fi)];
ys = 1*[cos(wt); sin(wt)];
case 7
% Five-phase system, multilevel converter, fault-tolerant mode, DOF: Vx1, Vy1, V0
fi = 2/5*pi;
A = 2/5*[0.5, cos(fi), cos(2*fi), cos(-2*fi), cos(-fi);...
0, sin(fi), sin(2*fi), sin(-2*fi), sin(-fi)];
ys = 1*[cos(wt); sin(wt)];
case 8
% Seven-phase system, DOF: Vx1, Vy1, Vx2, Vy2, V0
fi = 2/7*pi;
A = 2/7*[1, cos(fi), cos(2*fi), cos(3*fi), cos(-3*fi), cos(-2*fi), cos(-fi);...
0, sin(fi), sin(2*fi), sin(3*fi), sin(-3*fi), sin(-2*fi), sin(-fi);];
ys = 1*[cos(wt); sin(wt)];
case 9
% Seven-phase system, DOF: Vx2, Vy2, V0
fi = 2/7*pi;
A = 2/7*[1, cos(fi), cos(2*fi), cos(3*fi), cos(-3*fi), cos(-2*fi), cos(-fi);...
0, sin(fi), sin(2*fi), sin(3*fi), sin(-3*fi), sin(-2*fi), sin(-fi);...
1, cos(3*fi), cos(-fi), cos(2*fi), cos(-2*fi), cos(fi), cos(-3*fi);...
0, sin(3*fi), sin(-fi), sin(2*fi), sin(-2*fi), sin(fi), sin(-3*fi)];
ys = 1*[cos(wt); sin(wt); 0.15*cos(3*wt); 0.15*sin(3*wt)];
% Alternatively
% ys = 1*[cos(wt); sin(wt); zeros(1,n_t); zeros(1,n_t)];
case 10
% Seven-phase system, DOF: Vx1, Vy1, V0
fi = 2/7*pi;
A = 2/7*[1, cos(fi), cos(2*fi), cos(3*fi), cos(-3*fi), cos(-2*fi), cos(-fi);...
0, sin(fi), sin(2*fi), sin(3*fi), sin(-3*fi), sin(-2*fi), sin(-fi);...
1, cos(-2*fi), cos(3*fi), cos(fi), cos(-fi), cos(-3*fi), cos(2*fi);...
0, sin(-2*fi), sin(3*fi), sin(fi), sin(-fi), sin(-3*fi), sin(2*fi)];
ys = 1*[cos(wt); sin(wt); 0.08*cos(5*wt); 0.08*sin(5*wt)];
% Alternatively
% ys = 1*[cos(wt); sin(wt); zeros(1,n_t); zeros(1,n_t)];
case 11
% Seven-phase system, DOF: V0
fi = 2/7*pi;
A = 2/7*[1, cos(fi), cos(2*fi), cos(3*fi), cos(-3*fi), cos(-2*fi), cos(-fi);...
0, sin(fi), sin(2*fi), sin(3*fi), sin(-3*fi), sin(-2*fi), sin(-fi);...
1, cos(3*fi), cos(-fi), cos(2*fi), cos(-2*fi), cos(fi), cos(-3*fi);...
0, sin(3*fi), sin(-fi), sin(2*fi), sin(-2*fi), sin(fi), sin(-3*fi);...
1, cos(-2*fi), cos(3*fi), cos(fi), cos(-fi), cos(-3*fi), cos(2*fi);...
0, sin(-2*fi), sin(3*fi), sin(fi), sin(-fi), sin(-3*fi), sin(2*fi)];
ys = 1*[cos(wt); sin(wt); 0.15*cos(3*wt); 0.15*sin(3*wt); 0.08*cos(5*wt); 0.08*sin(5*wt)];
% Alternatively
% ys = 1*[cos(wt); sin(wt); zeros(1,n_t); zeros(1,n_t); zeros(1,n_t); zeros(1,n_t)];
case 12
% Seven-phase system, fault-tolerant mode, DOF: Vx1, Vy1, Vx2, Vy2, V0
fi = 2/7*pi;
A = 2/7*[0, cos(fi), cos(2*fi), cos(3*fi), cos(-3*fi), cos(-2*fi), cos(-fi);...
0, sin(fi), sin(2*fi), sin(3*fi), sin(-3*fi), sin(-2*fi), sin(-fi);];
ys = 1*[cos(wt); sin(wt)];
case 13
% Nine-phase system, DOF: Vx1, Vy1, Vx2, Vy2, Vx3, Vy3, V0
fi = 2/9*pi;
A = 2/9*[1, cos(fi), cos(2*fi), cos(3*fi), cos(4*fi), cos(-4*fi), cos(-3*fi), cos(-2*fi), cos(-fi);...
0, sin(fi), sin(2*fi), sin(3*fi), sin(4*fi), sin(-4*fi), sin(-3*fi), sin(-2*fi), sin(-fi)];
ys = 1*[cos(wt); sin(wt)];
case 14
% Nine-phase system, DOF: Vx2, Vy2, Vx3, Vy3, V0
fi = 2/9*pi;
A = 2/9*[1, cos(fi), cos(2*fi), cos(3*fi), cos(4*fi), cos(-4*fi), cos(-3*fi), cos(-2*fi), cos(-fi);...
0, sin(fi), sin(2*fi), sin(3*fi), sin(4*fi), sin(-4*fi), sin(-3*fi), sin(-2*fi), sin(-fi);...
1, cos(3*fi), cos(-3*fi), 1, cos(3*fi), cos(-3*fi), 1, cos(3*fi), cos(-3*fi);...
0, sin(3*fi), sin(-3*fi), 0, sin(3*fi), sin(-3*fi), 0, sin(3*fi), sin(-3*fi)];
ys = 1*[cos(wt); sin(wt); 0.15*cos(3*wt); 0.15*sin(3*wt)];
% Alternatively
% ys = 1*[cos(wt); sin(wt); zeros(1,n_t); zeros(1,n_t)];
case 15
% Nine-phase system, DOF: Vx3, Vy3, V0
fi = 2/9*pi;
A = 2/9*[1, cos(fi), cos(2*fi), cos(3*fi), cos(4*fi), cos(-4*fi), cos(-3*fi), cos(-2*fi), cos(-fi);...
0, sin(fi), sin(2*fi), sin(3*fi), sin(4*fi), sin(-4*fi), sin(-3*fi), sin(-2*fi), sin(-fi);...
1, cos(3*fi), cos(-3*fi), 1, cos(3*fi), cos(-3*fi), 1, cos(3*fi), cos(-3*fi);...
0, sin(3*fi), sin(-3*fi), 0, sin(3*fi), sin(-3*fi), 0, sin(3*fi), sin(-3*fi);...
1, cos(-4*fi), cos(fi), cos(-3*fi), cos(2*fi), cos(-2*fi), cos(3*fi), cos(-fi), cos(4*fi);...
0, sin(-4*fi), sin(fi), sin(-3*fi), sin(2*fi), sin(-2*fi), sin(3*fi), sin(-fi), sin(4*fi);...
];
ys = 1*[cos(wt); sin(wt); 0.15*cos(3*wt); 0.15*sin(3*wt); 0.08*cos(5*wt); 0.08*sin(5*wt)];
% Alternatively
% ys = 1*[cos(wt); sin(wt); zeros(1,n_t); zeros(1,n_t); zeros(1,n_t); zeros(1,n_t)];
case 16
% Nine-phase system, DOF: V0
continue;
fi = 2/9*pi;
A = 2/9*[1, cos(fi), cos(2*fi), cos(3*fi), cos(4*fi), cos(-4*fi), cos(-3*fi), cos(-2*fi), cos(-fi);...
0, sin(fi), sin(2*fi), sin(3*fi), sin(4*fi), sin(-4*fi), sin(-3*fi), sin(-2*fi), sin(-fi);...
1, cos(3*fi), cos(-3*fi), 1, cos(3*fi), cos(-3*fi), 1, cos(3*fi), cos(-3*fi);...
0, sin(3*fi), sin(-3*fi), 0, sin(3*fi), sin(-3*fi), 0, sin(3*fi), sin(-3*fi);...
1, cos(-4*fi), cos(fi), cos(-3*fi), cos(2*fi), cos(-2*fi), cos(3*fi), cos(-fi), cos(4*fi);...
0, sin(-4*fi), sin(fi), sin(-3*fi), sin(2*fi), sin(-2*fi), sin(3*fi), sin(-fi), sin(4*fi);...
1, cos(-2*fi), cos(-4*fi), cos(3*fi), cos(fi), cos(-fi), cos(-3*fi), cos(4*fi), cos(2*fi);...
0, sin(-2*fi), sin(-4*fi), sin(3*fi), sin(fi), sin(-fi), sin(-3*fi), sin(4*fi), sin(2*fi);...
];
ys = 1*[cos(wt); sin(wt); 0.15*cos(3*wt); 0.15*sin(3*wt); 0.08*cos(5*wt); 0.08*sin(5*wt); 0.05*cos(7*wt); 0.05*sin(7*wt)];
% Alternatively
% ys = 1*[cos(wt); sin(wt); zeros(1,n_t); zeros(1,n_t); zeros(1,n_t); zeros(1,n_t); zeros(1,n_t); zeros(1,n_t)];
case 17
% Nine-phase system, fault-tolerant mode, DOF: Vx1, Vy1, Vx2, Vy2, Vx3, Vy3, V0
fi = 2/9*pi;
A = 2/9*[0, cos(fi), cos(2*fi), cos(3*fi), cos(4*fi), cos(-4*fi), cos(-3*fi), cos(-2*fi), cos(-fi);...
0, sin(fi), sin(2*fi), sin(3*fi), sin(4*fi), sin(-4*fi), sin(-3*fi), sin(-2*fi), sin(-fi)];
ys = 1*[cos(wt); sin(wt)];
case 18
% Triple three-phase inverter for new compensator
fi = 2/3*pi;
A1 = 2/3*[1, cos(fi), cos(-fi);...
0, sin(fi), sin(-fi);...
1/2, 1/2, 1/2];
A2 = [ 1 0 -1 0 -1 1 0 0 0;... % ua = u11 - u13 + u23 - u22
0 0 0 1 0 -1 0 -1 1;... % ub = u21 - u23 + u33 - u32
0 -1 1 0 0 0 1 0 -1;]; % uc = u31 - u33 + u13 - u12
A = A1*A2;
ys = 1*[cos(wt); sin(wt); -cos(wt)];
% Alternatively
% ys = 1*[cos(wt); sin(wt); zeros(1,n_t)];
otherwise
disp("Error: System matrix A not defined.");
end
file_name = 'data/test_pars_' + string(j) + '.mat';
if isfile(file_name)
load(file_name, "pars");
else
pars = Pars(A);
save(file_name, "pars");
end
solver = Solver(pars);
[n_y, n_x] = size(A);
xs = zeros(n_x, n_t);
for k = 1:n_t
xs(:,k) = solver.min_effort(ys(:,k));
end
ylims = 1.1*[-max(xs(:)); max(xs(:))];
fig = figure();
set(gcf, 'Position', get(0, 'Screensize'));
subplot(1, 2, 1);
plot(ts, ys');
xlabel('Time [s]');
ylabel('Required voltage');
title('Case ' + string(j))
subplot(1, 2, 2);
plot(ts, xs');
xlabel('Time [s]');
ylabel('Input voltage');
title('Our approach');
ylim(ylims);
pars.analyze_solution();
end