test_pdi_plot_BOSCH_report.m 14.3 KB
Newer Older
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
%% ***********************************************************************
% ************************************************************************
% ************************* plots , additional script ********************
% ************************************************************************
% ************************************************************************
%
% Author Pascal Dietrich 2011 - pdi@akustik.rwth-aachen.de
% For BOSCH Report
%   --- CONFIDENTIAL ---
%
% ************************************************************************
% ************************************************************************
% ************************************************************************
% ************************************************************************

% <ITA-Toolbox>
% This file is part of the application TPA-TPS for the ITA-Toolbox. All rights reserved.
% You can find the license for this m-file in the application folder.
% </ITA-Toolbox>


%% Yc test
Yr_in_raw = ita_AudioAnalyticRationalMatrix2itaAudioMatrix(Yr_backup,   'fftDegree',fftDegree,'samplingRate',sr);
Ys_in_raw = ita_AudioAnalyticRationalMatrix2itaAudioMatrix(Ys_backup,   'fftDegree',fftDegree,'samplingRate',sr);
Yr_in_raw(1,1).comment = 'Yr';
Ys_in_raw(1,1).comment = 'Ys';
ita_disp('conversion done.')
ext = '';
ylimits = [-60 -30];

%% all DOF
close all
comment  = 'All DOFs';
filename = comment(isstrprop(comment,'alpha'));
Yr2 = Yr_in_raw;
Ys2 = Ys_in_raw;
Yc = Yr2*pinv(Yr2 + Ys2)*Ys2;
Yc(1,1).comment = 'Yc';
ita_tpa_plot_matrix({Ys2, Yr2,Yc},'freqVector',200,'filename',filename,'ticksF',{'FZ','MX','MY'} ,'ticksV',{'UZ','RX','RY'} )
count = 0;
clear aux
for idx = 1:3:size(Yc,1)
    count = count + 1;
    aux(count) = Yc(idx,idx);
end

Yc_noFoot_selected = aux.merge;
Yc_noFoot_selected.plot_spkphase('ylim',ylimits);
title(comment)
ita_savethisplot_gle('filename',[filename ext]);

%cond number
cYr2 = ita_tpa_plot_matrix_condition_number(Yr2);
cYr2.channelNames = {'Yr'};

cYs2 = ita_tpa_plot_matrix_condition_number(Ys2);
cYs2.channelNames = {'Ys'};

cYc2 = ita_tpa_plot_matrix_condition_number(Yc);
cYc2.channelNames = {'Yc'};

ita_plot_spk(merge(cYs2, cYr2, cYc2),'nodb')

%% all DOF - no foot coupling Yr Ys
close all
comment  = 'All DOFs -- No Coupling Between Feet (Yr, Ys)';
filename = comment(isstrprop(comment,'alpha'));
Yr2 = diag(Yr_in_raw,[],3);
Ys2 = diag(Ys_in_raw,[],3);
Yc = Yr2*pinv(Yr2 + Ys2)*Ys2;
Yc(1,1).comment = 'Yc';
ita_tpa_plot_matrix({Ys2, Yr2,Yc},'freqVector',200,'filename',filename,'ticksF',{'FZ','MX','MY'} ,'ticksV',{'UZ','RX','RY'} )
count = 0;
clear aux
for idx = 1:3:size(Yc,1)
    count = count + 1;
    aux(count) = Yc(idx,idx);
end

Yc_noFoot_selected = aux.merge;
Yc_noFoot_selected.plot_spkphase('ylim',ylimits);
title(comment)
ita_savethisplot_gle('filename',[filename ext]);

% all DOF - no foot coupling Yr
close all
comment  = 'All DOFs -- No Coupling Between Feet (Yr)';
filename = comment(isstrprop(comment,'alpha'));
Yr2 = diag(Yr_in_raw,[],3);
Ys2 = Ys_in_raw;
Yc = Yr2*pinv(Yr2 + Ys2)*Ys2;
Yc(1,1).comment = 'Yc';
ita_tpa_plot_matrix({Ys2, Yr2,Yc},'freqVector',200,'filename',filename,'ticksF',{'FZ','MX','MY'} ,'ticksV',{'UZ','RX','RY'} )
count = 0;
clear aux
for idx = 1:3:size(Yc,1)
    count = count + 1;
    aux(count) = Yc(idx,idx);
end

Yc_noFoot_selected = aux.merge;
Yc_noFoot_selected.plot_spkphase('ylim',ylimits);
title(comment)
ita_savethisplot_gle('filename',[filename ext]);

% all DOF - no foot coupling Ys
close all
comment  = 'All DOFs -- No Coupling Between Feet (Ys)';
filename = comment(isstrprop(comment,'alpha'));
Yr2 = Yr_in_raw;
Ys2 = diag(Ys_in_raw,[],3);
Yc = Yr2*pinv(Yr2 + Ys2)*Ys2;
Yc(1,1).comment = 'Yc';
ita_tpa_plot_matrix({Ys2, Yr2,Yc},'freqVector',200,'filename',filename,'ticksF',{'FZ','MX','MY'} ,'ticksV',{'UZ','RX','RY'} )
count = 0;
clear aux
for idx = 1:3:size(Yc,1)
    count = count + 1;
    aux(count) = Yc(idx,idx);
end

Yc_noFoot_selected = aux.merge;
Yc_noFoot_selected.plot_spkphase('ylim',ylimits);
title(comment)
ita_savethisplot_gle('filename',[filename ext]);

% all DOF - no foot coupling - no DOF coupling
close all
comment  = 'All DOFs -- No Coupling Between DOF';
filename = comment(isstrprop(comment,'alpha'));
Yr2 = diag(Yr_in_raw,3);
Ys2 = diag(Ys_in_raw,3);
Yc = Yr2*pinv(Yr2 + Ys2)*Ys2;
Yc(1,1).comment = 'Yc';
ita_tpa_plot_matrix({Ys2, Yr2,Yc},'freqVector',200,'filename',filename,'ticksF',{'FZ','MX','MY'} ,'ticksV',{'UZ','RX','RY'} )
count = 0;
clear aux
for idx = 1:3:size(Yc,1)
    count = count + 1;
    aux(count) = Yc(idx,idx);
end
Yc_noFoot_selected = aux.merge;
Yc_noFoot_selected.plot_spkphase('ylim',ylimits);
title(comment)
ita_savethisplot_gle('filename',[filename ext]);

% all DOF - no foot coupling - no DOF coupling
close all
comment  = 'All DOFs -- No Coupling Between Feet (Yr, Ys) and Between DOF';
filename = comment(isstrprop(comment,'alpha'));
Yr2 = diag(Yr_in_raw);
Ys2 = diag(Ys_in_raw);
Yc = Yr2*pinv(Yr2 + Ys2)*Ys2;
Yc(1,1).comment = 'Yc';
ita_tpa_plot_matrix({Ys2, Yr2,Yc},'freqVector',200,'filename',filename,'ticksF',{'FZ','MX','MY'} ,'ticksV',{'UZ','RX','RY'} )
count = 0;
clear aux
for idx = 1:3:size(Yc,1)
    count = count + 1;
    aux(count) = Yc(idx,idx);
end
Yc_noFoot_selected = aux.merge;
Yc_noFoot_selected.plot_spkphase('ylim',ylimits);
title(comment)
ita_savethisplot_gle('filename',[filename ext]);

%% normal direction only - Should be the same as "all DOF - no foot coupling - no DOF coupling"
close all
comment  = 'Normal Direction Only';
filename = comment(isstrprop(comment,'alpha'));
Yr2 = diag(Yr_in_raw(1:3:end,1:3:end));
Ys2 = diag(Ys_in_raw(1:3:end,1:3:end));
Yc = Yr2*pinv(Yr2 + Ys2)*Ys2;
Yc(1,1).comment = 'Yc';
ita_tpa_plot_matrix({Ys2, Yr2,Yc},'freqVector',200,'filename',filename,'ticksF',{'FZ'} ,'ticksV',{'UZ'} )
count = 0;
clear aux
for idx = 1:1:size(Yc,1)
    count = count + 1;
    aux(count) = Yc(idx,idx);
end
Yc_noFoot_selected = aux.merge;
Yc_noFoot_selected.plot_spkphase('ylim',ylimits);
title(comment)
ita_savethisplot_gle('filename',[filename ext]);

%% Ys invert due to ts
fmax = 2000;
sr   = 5000;
close all
clc
ts = 5e-3;
Geoms = itaCoordinates([lxs lys ts]); %create itaCoordinates / dimensions
Ys = repmat(itaAudioAnalyticRational,coordFeet.nPoints*DOF,coordFeet.nPoints*DOF);
for idx = 1:coordFeet.nPoints
    for jdx = 1:coordFeet.nPoints
        Ys((idx-1)*DOF+(1:DOF),(jdx-1)*DOF+(1:DOF)) = ita_tps_mobility_plate(Geoms,coordFeet.n(jdx),coordFeet.n(idx),EX,PRXY,RHO,DMPR,'f_max',fmax);
    end
end
nModes = numel(Ys(1,1).analyticData.f);
Ys(1,1) = 'Ys';
Ys      = Ys(idxF,idxF);
Ys      = ita_AudioAnalyticRationalMatrix2itaAudioMatrix(Ys,   'fftDegree',fftDegree,'samplingRate',sr);
Ys.merge.plot_spkphase('ylim',[-40 70])


fileStr = num2str(ts);
fileStr = fileStr(isstrprop(fileStr,'alphanum'));

titleStr = ['ts: ' num2str(ts) ' - ' num2str(nModes) ' Modes'];
title(titleStr)
ita_savethisplot_gle('filename',['YSts' fileStr ])

ita_tpa_plot_matrix({Ys},'freqVector',200,'ticksF',{'FZ','MX','MY'} ,'ticksV',{'UZ','RX','RY'} )
ita_plottools_aspectratio(1)
ita_savethisplot('matrix_0005.png')


ita_tpa_plot_matrix_condition_number(Ys);
title(titleStr)
ita_savethisplot_gle('filename',['condNumberts' fileStr ])

% % ita_tpa_plot_matrix({Ys},0,'freqVector',200,'ticksF',{'FZ','MX','MY'} ,'ticksV',{'UZ','RX','RY'} )
% % ita_plottools_aspectratio(1)
% % print('-dpng','-r300',['matrix_' num2str(ts) '.png'])



close all
clc
ts = 1e-3;
Geoms = itaCoordinates([lxs lys ts]); %create itaCoordinates / dimensions
Ys = repmat(itaAudioAnalyticRational,coordFeet.nPoints*DOF,coordFeet.nPoints*DOF);
for idx = 1:coordFeet.nPoints
    for jdx = 1:coordFeet.nPoints
        Ys((idx-1)*DOF+(1:DOF),(jdx-1)*DOF+(1:DOF)) = ita_tps_mobility_plate(Geoms,coordFeet.n(jdx),coordFeet.n(idx),EX,PRXY,RHO,DMPR,'f_max',fmax);
    end
end
nModes = numel(Ys(1,1).analyticData.f);
Ys(1,1) = 'Ys';
Ys      = Ys(idxF,idxF);
Ys      = ita_AudioAnalyticRationalMatrix2itaAudioMatrix(Ys,   'fftDegree',fftDegree,'samplingRate',sr);
Ys.merge.plot_spkphase('ylim',[-40 70])


fileStr = num2str(ts);
fileStr = fileStr(isstrprop(fileStr,'alphanum'));

titleStr = ['ts: ' num2str(ts) ' - ' num2str(nModes) ' Modes'];
title(titleStr)
ita_savethisplot_gle('filename',['YSts' fileStr ])

ita_tpa_plot_matrix_condition_number(Ys);
title(titleStr)
ita_savethisplot_gle('filename',['condNumberts' fileStr ])



close all
clc
ts = 0.1e-3;
Geoms = itaCoordinates([lxs lys ts]); %create itaCoordinates / dimensions
Ys = repmat(itaAudioAnalyticRational,coordFeet.nPoints*DOF,coordFeet.nPoints*DOF);
for idx = 1:coordFeet.nPoints
    for jdx = 1:coordFeet.nPoints
        Ys((idx-1)*DOF+(1:DOF),(jdx-1)*DOF+(1:DOF)) = ita_tps_mobility_plate(Geoms,coordFeet.n(jdx),coordFeet.n(idx),EX,PRXY,RHO,DMPR,'f_max',fmax);
    end
end
nModes = numel(Ys(1,1).analyticData.f);
Ys(1,1) = 'Ys';
Ys      = Ys(idxF,idxF);
Ys      = ita_AudioAnalyticRationalMatrix2itaAudioMatrix(Ys,   'fftDegree',fftDegree,'samplingRate',sr);
Ys.merge.plot_spkphase('ylim',[-40 70])


fileStr = num2str(ts);
fileStr = fileStr(isstrprop(fileStr,'alphanum'));

titleStr = ['ts: ' num2str(ts) ' - ' num2str(nModes) ' Modes'];
title(titleStr)
ita_savethisplot_gle('filename',['YSts' fileStr ])

ita_tpa_plot_matrix_condition_number(Ys);
title(titleStr)
ita_savethisplot_gle('filename',['condNumberts' fileStr ])


%% condition number and damping
% close all
clc
sr = 5000; 
fmax = 2000;
ts = 0.1e-3;
DMPR = 10;
% DMPR  = 1e2;   %damping

Geoms = itaCoordinates([lxs lys ts]); %create itaCoordinates / dimensions
Ys = repmat(itaAudioAnalyticRational,coordFeet.nPoints*DOF,coordFeet.nPoints*DOF);
for idx = 1:coordFeet.nPoints
    for jdx = 1:coordFeet.nPoints
        Ys((idx-1)*DOF+(1:DOF),(jdx-1)*DOF+(1:DOF)) = ita_tps_mobility_plate(Geoms,coordFeet.n(jdx),coordFeet.n(idx),EX,PRXY,RHO,DMPR,'f_max',fmax);
    end
end

eigenFreq = Ys(1,1).analyticData.f;

nModes = numel(Ys(1,1).analyticData.f);
Ys(1,1) = 'Ys';
Ys      = Ys(idxF,idxF);
Ys      = ita_AudioAnalyticRationalMatrix2itaAudioMatrix(Ys,   'fftDegree',fftDegree,'samplingRate',sr);
% Ys.merge.plot_spkphase('ylim',[-40 70])

titleStr = ['ts: ' num2str(ts) ' - damping: ' num2str(DMPR) ' - ' num2str(nModes) ' Modes'];

fileStr = [num2str(ts) '_' num2str(DMPR) ];
fileStr = fileStr(isstrprop(fileStr,'alphanum'));

ita_tpa_plot_matrix_condition_number(Ys,eigenFreq);
title(titleStr)
legend off
ylim([0 5e5])

ita_savethisplot_gle('filename',['condNumbertDamping' fileStr ])


%% ***********************
%% *************** PLATE-BEAM ******************************************
% % ccx
% This link has to be adapted!
% % load('F:\pdi_daten\MATLAB\BoschReport\ANSYS_plate_beam\workspace_data.mat')

% unitsit
mulfac  = 3;
v_units = [repmat(itaValue(1,'m/s'),1,mulfac) repmat(itaValue(1,'1/s'),1,mulfac)];
F_units = [repmat(itaValue(1,'N'),1,mulfac)   repmat(itaValue(1,'N m'),1,mulfac)];
units   = repmat(itaValue,2*mulfac,2*mulfac); % just init

for idx = 1:numel(v_units)
    for jdx = 1:numel(F_units)
        aux = itaValue(v_units(idx)) / itaValue(F_units(jdx));
        units(jdx,idx) = aux;
    end
end
units = repmat(units,3,3)

%% get velocity
DOF = 6;
for idx = 1:DOF*3
    for jdx = 1:DOF*3
        Placa (idx,jdx)        = ita_differentiate( Placa (idx,jdx));
        Placa (idx,jdx).channelUnits = units(idx,jdx);
        PlacaViga (idx,jdx)    = ita_differentiate( PlacaViga (idx,jdx));
        PlacaViga (idx,jdx).channelUnits = units(idx,jdx);
        VigaMobility (idx,jdx) = ita_differentiate( VigaMobility (idx,jdx));
        VigaMobility (idx,jdx).channelUnits = units(idx,jdx);
    end
end

%% select DOF
selectDOF = 1:6;
% selectDOF = [3 4 5];
idxF = ita_tpa_DOF2index(selectDOF,3,DOF);
idxR = ita_tpa_DOF2index(selectDOF,3,DOF);
Ys = VigaMobility(idxF,idxR);
Yr = Placa(idxF,idxR);
Yc = PlacaViga(idxF,idxR);
Yc_sim = Yr*pinv(Yr + Ys,1e-5)*Ys;
% Yc2_sim = Yr2*pinv(Yr2 + Ys2)*Ys2;

%% naming
% Yc = Yc(idxF, idxR);
Yc(1,1).comment = 'Yc ANSYS';
% Yc_sim = Yc_sim(idxF, idxR);
Yc_sim(1,1).comment = 'Yc calculated';

%% save
save(['admittance_data_plate_beam_' num2str(numel(selectDOF)) 'DOF.mat'],'Yr','Ys','Yc','Yc_sim')

%%
if numel(selectDOF,3)
    ita_tpa_plot_matrix({Ys, Yr, Yc, Yc_sim},'filename',['ansys_numerik_' num2str(numel(selectDOF)) 'DOF'],'ticksF',{'FZ','MX','MY'} ,'ticksV',{'UZ','RX','RY'},'freqVector',350)
else
    ita_tpa_plot_matrix({Ys, Yr, Yc, Yc_sim},'filename',['ansys_numerik_' num2str(numel(selectDOF)) 'DOF'],'freqVector',350)
end

%% windowing
Ys_win = ita_matrixfun(@ita_time_window,Ys,[0.4 0.6],'time','symmetric');
Yr_win = ita_matrixfun(@ita_time_window,Yr,[0.4 0.6],'time','symmetric');

Yc_sim_win = Yr_win*pinv(Yr_win + Ys_win,1e-5)*Ys_win;

%%
ita_tpa_plot_matrix_condition_number(Yc)
legend off
ylim([0 4e8])
ita_savethisplot_gle('ansys_condnumber_yc')

%%
ita_tpa_plot_matrix_condition_number(Ys)
legend off
ylimits = ylim;
ylim([0 1e11])
ita_savethisplot_gle('ansys_condnumber_ys')

%%
ita_tpa_plot_matrix_condition_number(Yr)
legend off
ylimits = ylim;
ylim([0 4e10])
ita_savethisplot_gle('ansys_condnumber_yr')

%%
count = 0
clear aux
for idx = 1:3:size(Ys,1)
    count = count + 1;
    aux(count) = Yc_sim(idx,idx);
end
aux.merge.plot_spkphase();

%% Ys fit
for idx = 1:size(Ys,1)
    for jdx = 1:size(Ys,2)
        Ys_fit(idx,jdx) = ita_audio2zpk_rationalfit((Ys(idx,jdx)),'degree',15,'freqRange',[100 2000],'tendstozero',false);
    end
end
Ys2 = ita_AudioAnalyticRationalMatrix2itaAudioMatrix(Ys_fit,   'fftDegree',Ys(1,1).nSamples,'samplingRate',4000);

%%
for idx = 1:size(Ys,1)
    for jdx = 1:size(Ys,2)
        Ys(idx,jdx).signalType = 'energy';
        Ys_fit(idx,jdx).fftDegree = 16;
        Yr_fit(idx,jdx).fftDegree = 16;
        
        Ys_fit(idx,jdx).samplingRate = Ys(1,1).samplingRate;
        Yr_fit(idx,jdx).samplingRate = Ys(1,1).samplingRate;
        
    end
end

%%
for idx = 1:size(Ys,1)
    disp([num2str(idx)  ' of ' num2str(size(Ys,1))])
    for jdx = 1:size(Ys,2)
        Yr_fit(idx,jdx) = ita_audio2zpk_rationalfit((Yr(idx,jdx)),'degree',[200],'freqRange',[20 2000],'tendstozero',false);
    end
end
Yr2 = ita_AudioAnalyticRationalMatrix2itaAudioMatrix(Yr_fit,   'fftDegree',Ys(1,1).nSamples,'samplingRate',4000);

%% transpose?
Yr_trans = ita_tpa_matrix_transpose(Yr);
test = Yr.merge/Yr_trans.merge

%%
data = Yr
ita_plot_spkphase(merge(data(1,1),data(4,4), data(7,7)))
legend off
ylim([-80 20])
ita_savethisplot_gle('ansys_spkphase_Yr')

%%
data = Yr_fit;
ita_plot_spkphase(merge(data(1,1)',data(4,4)', data(7,7)'))
legend off
ylim([-80 20])
ita_savethisplot_gle('ansys_spkphase_Yr_fit')

%%
Yr_fit2 = Yr_fit';
Ys_fit2 = Ys_fit';
Yc_fit  = Yr_fit2 * pinv( Yr_fit2 + Ys_fit2) * Ys_fit2;