-
Notifications
You must be signed in to change notification settings - Fork 0
/
lmm_robust_design.m
215 lines (149 loc) · 5.27 KB
/
lmm_robust_design.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
clear all
close all
clc
% Add path of functions
addpath('functions')
return
%% SYSTEM PARAMTERS
% Primary system
m1=1;
k1=1E5;
c1=500;
wn_s=sqrt(k1/m1)/(2*pi);
% Absorber system
m2=0.05*m1;
k2=(k1*m2)/m1;
c2=500;
% Frequency range
omega=0:0.1:100*2*pi;
%% FRF INITIAL DESIGN
freq=omega/(2*pi);
Hs=zeros(1,length(omega));
Hc_init=zeros(1,length(omega));
% Receptance of primary system
for i=1:length(omega)
Hs(i)=1/(k1+1j*c1-omega(i)^2*m1);
end
% Receptance of coupled system (inital design)
Hc_init=recept2MCK(omega,m1,k1,c1,m2,k2,c2);
% DISPLAY RESULTS
figure()
semilogy(freq,abs(Hs)); hold on
semilogy(freq,abs(Hc_init)); hold on
set(gca,'FontSize',12,'TickLabelInterpreter','latex')
ylabel('$ \left | H (\lambda) \right | $','interpreter','latex')
xlabel('$ \lambda $','interpreter','latex')
%% DESIGN OPTIMIZATION - DETERMINISTIC
% Analytical solution of optimal values
mu=m2/m1;
gamma_opt_ana=1/(1+mu);
ka_opt_ana=(gamma_opt_ana*sqrt(k1/m1)*sqrt(m2))^2;
eta_opt_ana=sqrt(3*mu/(8*(1+mu)));
ca_opt_ana=eta_opt_ana*2*sqrt(m2*ka_opt_ana);
% Numerical solution of the problem
% x0 = [1e3,1];
% sol_det_num = fminsearch(@(x)recept2MCK_opt(omega,m1,k1,c1,m2,x(1),x(2)),x0)
x0 = [1e3];
sol_det_num = fminsearch(@(x)recept2MCK_opt(omega,m1,k1,c1,m2,x(1),c2),x0)
% recept_abs_damp_opt(omega,ms,ks,ma,x(1),x(2)),x0);
ka_opt_num=sol_det_num(1);
% ca_opt_num=sol_det_num(2);
ca_opt_num=c2;
% Frequency response curve of optimal design
Hc_opt=recept2MCK(omega,m1,k1,c1,m2,ka_opt_ana,ca_opt_ana);
Hc_opt_num=recept2MCK(omega,m1,k1,c1,m2,ka_opt_num,ca_opt_num);
% Propgation of uncertainty using Monte Carlo
Nm=1000;
k_dist=zeros(1,Nm);
h=zeros(Nm,length(omega));
h_norm=zeros(1,Nm);
for i=1:Nm
k_dist(i)=unifrnd(0.6*k1,1.4*k1);
h(i,:)=abs(recept2MCK(omega,m1,k_dist(i),c1,m2,ka_opt_num,ca_opt_num));
h_norm(i)=norm(h(i,:),Inf);
end
% Display envelope of samples H
lamb_vec = [omega/wn_s, fliplr(omega/wn_s)];
env = [min(h,[],1) fliplr(max(h,[],1))];
figure()
semilogy(freq,abs(Hc_opt_num)); hold on
fill([freq, fliplr(freq)], env,'k','edgecolor','none','FaceAlpha',0.1); hold on
set(gca,'FontSize',12,'TickLabelInterpreter','latex')
ylabel('$|G (\omega)|$ [m/N]','interpreter','latex')
xlabel('Frequency [Hz]','interpreter','latex')
% legend({'LTVA - Analytical','Envelope of samples'},'Location','Best')
[~,h_legend] = legend({'LTVA Deterministic','Envelope of samples'},'Location','Best');
% PatchInLegend = findobj(h_legend, 'type', 'patch');
% set(PatchInLegend(1), 'FaceAlpha', 0.1);
%% ROBUST DESIGN OPTIMIZATION
% Risk level vector
e_vec=[0.01 0.1:0.1:1];
% e_vec=[0.01];
sol_rob_vec=zeros(length(e_vec),2);
% Create the subset of your random variable
for i=1:length(e_vec)
i
e=e_vec(i); % Risk level
beta=1e-10; % Confidence level
d = 3;
Nm=fix((2/e)*(d-log(beta)))+1;
ks_rnd=unifrnd(k1-0.2*(1-e)*k1,k1+0.2*(1-e)*k1,[1,Nm]);
% Setup of optimization problem
options = optimoptions('fmincon','Display','iter','PlotFcns',@optimplotfval,'Algorithm','sqp');
problem.options = options;
problem.solver = 'fmincon';
problem.objective = @(q)objFcn_abs_damp(q);
problem.x0 = [5e3 5];
problem.lb = [0 0];
problem.nonlcon = @(q)cnstFcn_abs_damp_mod(q,m1,ks_rnd,c1,m2,omega,c2);
% Run optimization
% Estimated time : 86s
tic
sol_rob = fmincon(problem)
toc
sol_rob_vec(i,:)=sol_rob;
end
%% Propgation of uncertainty using Monte Carlo
clear env_rob h_rob
Nm=10000;
% Solve the optimization above or run the saved results frol
% DESIGN_ROBUST.mat
sol= sol_rob_vec(1,:)
e=0.01;
k_dist=unifrnd(0.8*k1,1.2*k1,[1,Nm]);
for i=1:Nm
h_rob(i,:)=abs(recept2MCK(omega,m1,k_dist(i),c1,m2,sol(1),c2));
end
Hc_rob=abs(recept2MCK(omega,m1,k1,c1,m2,sol(1),c2));
env_rob = [min(h_rob,[],1), fliplr(max(h_rob,[],1))];
co=lines(7)
figure()
set(gcf,'units','normalized','outerposition',[0 0 1 1])
fill([freq, fliplr(freq)],env,co(1,:),'edgecolor','none','FaceAlpha',0.1); hold on
plot(freq,abs(Hc_opt_num),'Color',co(1,:),'linewidth',2); hold on
fill([freq, fliplr(freq)], env_rob,co(2,:),'edgecolor','none','FaceAlpha',0.1); hold on
plot(freq,abs(Hc_rob),'Color',co(2,:),'linewidth',2); hold on
set(gca,'FontSize',28)
[~,h_legend] = legend({'Equal-peak design','Mean sample - deterministic','Robust equal-peak design','Mean sample - robust'},'Location','Best','interpreter','latex');
PatchInLegend = findobj(h_legend, 'type', 'patch');
set(PatchInLegend(1), 'FaceAlpha',0.1);
set(PatchInLegend(2), 'FaceAlpha',0.1);
% set(gca,'YScale','log')
ylabel('$|G (\omega)|$ [m/N]','interpreter','latex')
xlabel('Frequency [Hz]','interpreter','latex')
set(gca,'FontSize',28,'TickLabelInterpreter','latex')
set(gcf,'PaperOrientation','landscape');;
set(gcf,'PaperSize',[38,21])
print(gcf, '-dpdf','-fillpage', 'figures/H_robust_v2.pdf');
% TRADE-OFF PERFORMANCE x ROBUSTNESS
co=lines(7);
figure()
set(gcf,'units','normalized','outerposition',[0 0 1 1])
plot(e_vec*100,sol_rob_vec(:,2)*1e-4,'o-','linewidth',2,'color',co(1,:),'markerfacecolor',co(1,:))
set(gca,'FontSize',28,'TickLabelInterpreter','latex')
ylabel('$g^*$','interpreter','latex')
xlabel('$ \varepsilon$ $[\%]$','interpreter','latex')
xlim([0 100])
set(gcf,'PaperOrientation','landscape');;
set(gcf,'PaperSize',[38,21])
print(gcf, '-dpdf','-fillpage', 'figures/tradeoff_v2.pdf');