#+TITLE: Identification
:DRAWER:
#+STARTUP: overview
#+LANGUAGE: en
#+EMAIL: dehaeze.thomas@gmail.com
#+AUTHOR: Dehaeze Thomas
#+HTML_LINK_HOME: ../index.html
#+HTML_LINK_UP: ../index.html
#+HTML_HEAD:
#+HTML_HEAD:
#+HTML_HEAD:
#+HTML_HEAD:
#+HTML_HEAD:
#+HTML_HEAD:
#+HTML_HEAD:
#+HTML_MATHJAX: align: center tagside: right font: TeX
#+PROPERTY: header-args:matlab :session *MATLAB*
#+PROPERTY: header-args:matlab+ :comments org
#+PROPERTY: header-args:matlab+ :results none
#+PROPERTY: header-args:matlab+ :exports both
#+PROPERTY: header-args:matlab+ :eval no-export
#+PROPERTY: header-args:matlab+ :output-dir figs
#+PROPERTY: header-args:matlab+ :tangle matlab/modal_frf_coh.m
#+PROPERTY: header-args:matlab+ :mkdirp yes
#+PROPERTY: header-args:shell :eval no-export
#+PROPERTY: header-args:latex :headers '("\\usepackage{tikz}" "\\usepackage{import}" "\\import{$HOME/Cloud/thesis/latex/}{config.tex}")
#+PROPERTY: header-args:latex+ :imagemagick t :fit yes
#+PROPERTY: header-args:latex+ :iminoptions -scale 100% -density 150
#+PROPERTY: header-args:latex+ :imoutoptions -quality 100
#+PROPERTY: header-args:latex+ :results raw replace :buffer no
#+PROPERTY: header-args:latex+ :eval no-export
#+PROPERTY: header-args:latex+ :exports both
#+PROPERTY: header-args:latex+ :mkdirp yes
#+PROPERTY: header-args:latex+ :output-dir figs
:END:
* Introduction :ignore:
The goal here is to make an identification of the *micro-station* in order to compare the model with the measurements on the real micro-station.
In order to do so:
- Decide where to virtually excite the station and where to measure its motion
- Extract transfer functions from the excitation forces to the measured motion
- Compare those transfer functions with the modal analysis
For the excitation, we can choose the same excitation points as the one used for the modal test.
For the measurement points, we can choose the Center of Mass of each solid body.
The center of mass of each solid body is not easily defined using Simscape.
Indeed, we can define the center of mass of any solid body but not of multiple solid bodies. However, one solid body is composed of multiple STEP files.
One solution could be to use one STEP file for one solid body.
However, the position of the center of mass can be exported using simulink and then defined on Simscape.
* Identification of the Micro-Station
** Introduction :ignore:
** Matlab Init :noexport:ignore:
#+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name)
<>
#+end_src
#+begin_src matlab :exports none :results silent :noweb yes
<>
#+end_src
#+begin_src matlab :tangle no
simulinkproject('../');
#+end_src
** Compute the transfer functions
We first define some parameters for the identification.
The simulink file for the identification is =sim_micro_station_id.slx=.
#+begin_src matlab
open('identification/matlab/sim_micro_station_id.slx')
#+end_src
#+begin_src matlab
%% Options for Linearized
options = linearizeOptions;
options.SampleTime = 0;
%% Name of the Simulink File
mdl = 'sim_micro_station_id';
#+end_src
#+begin_src matlab
%% Micro-Hexapod
% Input/Output definition
io(1) = linio([mdl, '/Micro-Station/Fm_ext'],1,'openinput');
io(2) = linio([mdl, '/Micro-Station/Fg_ext'],1,'openinput');
io(3) = linio([mdl, '/Micro-Station/Dm_inertial'],1,'output');
io(4) = linio([mdl, '/Micro-Station/Ty_inertial'],1,'output');
io(5) = linio([mdl, '/Micro-Station/Ry_inertial'],1,'output');
io(6) = linio([mdl, '/Micro-Station/Dg_inertial'],1,'output');
#+end_src
#+begin_src matlab
% Run the linearization
G_ms = linearize(mdl, io, 0);
% Input/Output names
G_ms.InputName = {'Fmx', 'Fmy', 'Fmz',...
'Fgx', 'Fgy', 'Fgz'};
G_ms.OutputName = {'Dmx', 'Dmy', 'Dmz', ...
'Tyx', 'Tyy', 'Tyz', ...
'Ryx', 'Ryy', 'Ryz', ...
'Dgx', 'Dgy', 'Dgz'};
#+end_src
#+begin_src matlab
%% Save the obtained transfer functions
save('./mat/id_micro_station.mat', 'G_ms');
#+end_src
** Plots the transfer functions
** Compare with the measurements
* Modal Analysis of the Micro-Station
** Matlab Init :noexport:ignore:
#+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name)
<>
#+end_src
#+begin_src matlab :exports none :results silent :noweb yes
<>
#+end_src
#+begin_src matlab :tangle no
simulinkproject('../');
#+end_src
** Simscape Model
#+begin_src matlab
open('identification/matlab/sim_micro_station_modal_analysis.slx')
#+end_src
#+begin_src matlab
%% Options for Linearized
options = linearizeOptions;
options.SampleTime = 0;
%% Name of the Simulink File
mdl = 'sim_micro_station_modal_analysis';
#+end_src
#+begin_src matlab
%% Micro-Hexapod
% Input/Output definition
io(1) = linio([mdl, '/Micro-Station/F_hammer'],1,'openinput');
io(2) = linio([mdl, '/Micro-Station/acc9'],1,'output');
io(3) = linio([mdl, '/Micro-Station/acc10'],1,'output');
io(4) = linio([mdl, '/Micro-Station/acc11'],1,'output');
io(5) = linio([mdl, '/Micro-Station/acc12'],1,'output');
#+end_src
#+begin_src matlab
% Run the linearization
G_ms = linearize(mdl, io, 0);
% Input/Output names
G_ms.InputName = {'Fx', 'Fy', 'Fz'};
G_ms.OutputName = {'x9', 'y9', 'z9', ...
'x10', 'y10', 'z10', ...
'x11', 'y11', 'z11', ...
'x12', 'y12', 'z12'};
#+end_src
** Plot Results
#+begin_src matlab
figure;
hold on;
plot(freqs, abs(squeeze(freqresp(G_ms('x9', 'Fx'), freqs, 'Hz'))));
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [m/N]');
hold off;
#+end_src
** Compare with measurements
#+begin_src matlab
load('../meas/modal-analysis/mat/frf_coh_matrices.mat', 'FRFs', 'COHs', 'freqs');
#+end_src
#+begin_src matlab
dirs = {'x', 'y', 'z'};
n_acc = 9;
n_dir = 1; % x, y, z
n_exc = 1; % x, y, z
figure;
hold on;
plot(freqs, abs(squeeze(FRFs(3*(n_acc-1) + n_dir, n_exc, :)))./((2*pi*freqs).^2)');
plot(freqs, abs(squeeze(freqresp(G_ms([dirs{n_dir}, num2str(n_acc)], ['F', dirs{n_dir}]), freqs, 'Hz'))));
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [m/N]');
hold off;
#+end_src
* Compare with measurements at the CoM of each element
** Introduction :ignore:
[[file:../../meas/modal-analysis/index.org][here]]
** Matlab Init :noexport:ignore:
#+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name)
<>
#+end_src
#+begin_src matlab :exports none :results silent :noweb yes
<>
#+end_src
#+begin_src matlab :tangle no
simulinkproject('../');
#+end_src
** Prepare the Simulation
We load the configuration.
#+begin_src matlab
load('mat/conf_simscape.mat');
#+end_src
We set a small =StopTime=.
#+begin_src matlab
set_param(conf_simscape, 'StopTime', '0.5');
#+end_src
We initialize all the stages.
#+begin_src matlab
initializeGround();
initializeGranite();
initializeTy();
initializeRy();
initializeRz();
initializeMicroHexapod();
initializeAxisc();
initializeMirror();
initializeNanoHexapod(struct('actuator', 'piezo'));
initializeSample(struct('mass', 50));
#+end_src
#+begin_src matlab
open('identification/matlab/sim_micro_station_com.slx')
#+end_src
** Estimate the position of the CoM of each solid
#+begin_src matlab
sim('sim_micro_station_com')
#+end_src
#+begin_src matlab :exports results :results value table replace :tangle no :post addhdr(*this*)
stages_com = 1e3*[granite_bot_com.Data(end, :) ;
granite_top_com.Data(end, :) ;
ty_com.Data(end, :) ;
ry_com.Data(end, :) ;
rz_com.Data(end, :) ;
hexa_com.Data(end, :) ]';
data2orgtable(stages_com, {'X [mm]', 'Y [mm]', 'Z [mm]'}, {'granite bot', 'granite top', 'ty', 'ry', 'rz', 'hexa'}, ' %.1f ');
#+end_src
#+RESULTS:
| | granite bot | granite top | ty | ry | rz | hexa |
|--------+-------------+-------------+--------+--------+--------+--------|
| X [mm] | -52.4 | -51.7 | -0.9 | -0.1 | 0.0 | -0.0 |
| Y [mm] | -190.4 | -263.2 | -0.7 | 5.2 | -0.0 | 0.1 |
| Z [mm] | -1200.0 | -777.1 | -598.9 | -627.7 | -643.2 | -317.1 |
** Init
#+begin_src matlab :results none
initializeGround();
initializeGranite();
initializeTy();
initializeRy();
initializeRz();
initializeMicroHexapod();
initializeAxisc();
#+end_src
** TODO Center of Mass of each solid body
- [ ] Verify that this is coherent with the simscape and with the measurements
| | granite bot | granite top | ty | ry | rz | hexa |
|--------+-------------+-------------+------+------+------+------|
| X [mm] | 45 | 52 | 0 | 0 | 0 | -4 |
| Y [mm] | 144 | 258 | 14 | -5 | 0 | 6 |
| Z [mm] | -1251 | -778 | -600 | -628 | -580 | -319 |
#+begin_src matlab
open('identification/matlab/sim_micro_station_modal_analysis_com.slx')
#+end_src
** Simscape Model
#+begin_src matlab
%% Options for Linearized
options = linearizeOptions;
options.SampleTime = 0;
%% Name of the Simulink File
mdl = 'sim_micro_station_modal_analysis_com';
#+end_src
#+begin_src matlab
%% Micro-Hexapod
% Input/Output definition
io(1) = linio([mdl, '/Micro-Station/F_hammer'],1,'openinput');
io(2) = linio([mdl, '/Micro-Station/acc_gtop'],1,'output');
io(3) = linio([mdl, '/Micro-Station/acc_ty'],1,'output');
io(4) = linio([mdl, '/Micro-Station/acc_ry'],1,'output');
io(5) = linio([mdl, '/Micro-Station/acc_rz'],1,'output');
io(6) = linio([mdl, '/Micro-Station/acc_hexa'],1,'output');
#+end_src
#+begin_src matlab
% Run the linearization
G_ms = linearize(mdl, io, 0);
% Input/Output names
G_ms.InputName = {'Fx', 'Fy', 'Fz'};
G_ms.OutputName = {'gtop_x', 'gtop_y', 'gtop_z', 'gtop_rx', 'gtop_ry', 'gtop_rz', ...
'ty_x', 'ty_y', 'ty_z', 'ty_rx', 'ty_ry', 'ty_rz', ...
'ry_x', 'ry_y', 'ry_z', 'ry_rx', 'ry_ry', 'ry_rz', ...
'rz_x', 'rz_y', 'rz_z', 'rz_rx', 'rz_ry', 'rz_rz', ...
'hexa_x', 'hexa_y', 'hexa_z', 'hexa_rx', 'hexa_ry', 'hexa_rz'};
#+end_src
** Compare with measurements
#+begin_src matlab
load('../meas/modal-analysis/mat/frf_coh_matrices.mat', 'freqs');
load('../meas/modal-analysis/mat/frf_com.mat', 'FRFs_CoM');
#+end_src
#+begin_src matlab
dirs = {'x', 'y', 'z', 'rx', 'ry', 'rz'};
stages = {'gbot', 'gtop', 'ty', 'ry', 'rz', 'hexa'}
n_stg = 2;
n_dir = 5; % x, y, z, Rx, Ry, Rz
n_exc = 2; % x, y, z
f = logspace(0, 3, 1000);
figure;
hold on;
plot(freqs, abs(squeeze(FRFs_CoM(6*(n_stg-1) + n_dir, n_exc, :)))./((2*pi*freqs).^2)');
plot(f, abs(squeeze(freqresp(G_ms([stages{n_stg}, '_', dirs{n_dir}], ['F', dirs{n_exc}]), f, 'Hz'))));
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [m/N]');
hold off;
xlim([1, 200]);
#+end_src
#+begin_src matlab
dirs = {'x', 'y', 'z', 'rx', 'ry', 'rz'};
stages = {'gtop', 'ty', 'ry', 'rz', 'hexa'}
f = logspace(1, 3, 1000);
figure;
for n_stg = 1:2
for n_dir = 1:3
subplot(3, 2, (n_dir-1)*2 + n_stg);
title(['F ', dirs{n_dir}, ' to ', stages{n_stg}, ' ', dirs{n_dir}]);
hold on;
plot(freqs, abs(squeeze(FRFs_CoM(6*(n_stg) + n_dir, n_dir, :)))./((2*pi*freqs).^2)');
plot(f, abs(squeeze(freqresp(G_ms([stages{n_stg}, '_', dirs{n_dir}], ['F', dirs{n_dir}]), f, 'Hz'))));
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [m/N]');
if n_dir == 3
xlabel('Frequency [Hz]');
end
hold off;
xlim([10, 1000]);
ylim([1e-12, 1e-6]);
end
end
#+end_src
#+HEADER: :tangle no :exports results :results none :noweb yes
#+begin_src matlab :var filepath="figs/identification_comp_bot_stages.pdf" :var figsize="full-tall" :post pdf2svg(file=*this*, ext="png")
<>
#+end_src
#+NAME: fig:identification_comp_bot_stages
#+CAPTION: caption ([[./figs/identification_comp_bot_stages.png][png]], [[./figs/identification_comp_bot_stages.pdf][pdf]])
[[file:figs/identification_comp_bot_stages.png]]
#+begin_src matlab
dirs = {'x', 'y', 'z', 'rx', 'ry', 'rz'};
stages = {'ry', 'rz', 'hexa'}
f = logspace(1, 3, 1000);
figure;
for n_stg = 1:2
for n_dir = 1:3
subplot(3, 2, (n_dir-1)*2 + n_stg);
title(['F ', dirs{n_dir}, ' to ', stages{n_stg}, ' ', dirs{n_dir}]);
hold on;
plot(freqs, abs(squeeze(FRFs_CoM(6*(n_stg+2) + n_dir, n_dir, :)))./((2*pi*freqs).^2)');
plot(f, abs(squeeze(freqresp(G_ms([stages{n_stg}, '_', dirs{n_dir}], ['F', dirs{n_dir}]), f, 'Hz'))));
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [m/N]');
if n_dir == 3
xlabel('Frequency [Hz]');
end
hold off;
xlim([10, 1000]);
ylim([1e-12, 1e-6]);
end
end
#+end_src
#+HEADER: :tangle no :exports results :results none :noweb yes
#+begin_src matlab :var filepath="figs/identification_comp_mid_stages.pdf" :var figsize="full-tall" :post pdf2svg(file=*this*, ext="png")
<>
#+end_src
#+NAME: fig:identification_comp_mid_stages
#+CAPTION: caption ([[./figs/identification_comp_mid_stages.png][png]], [[./figs/identification_comp_mid_stages.pdf][pdf]])
[[file:figs/identification_comp_mid_stages.png]]
#+begin_src matlab
dirs = {'x', 'y', 'z', 'rx', 'ry', 'rz'};
stages = {'hexa'}
f = logspace(1, 3, 1000);
figure;
for n_stg = 1
for n_dir = 1:3
subplot(3, 1, (n_dir-1)*2 + n_stg);
title(['F ', dirs{n_dir}, ' to ', stages{n_stg}, ' ', dirs{n_dir}]);
hold on;
plot(freqs, abs(squeeze(FRFs_CoM(6*(n_stg+4) + n_dir, n_dir, :)))./((2*pi*freqs).^2)');
plot(f, abs(squeeze(freqresp(G_ms([stages{n_stg}, '_', dirs{n_dir}], ['F', dirs{n_dir}]), f, 'Hz'))));
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
ylabel('Amplitude [m/N]');
if n_dir == 3
xlabel('Frequency [Hz]');
end
hold off;
xlim([10, 1000]);
ylim([1e-12, 1e-6]);
end
end
#+end_src
#+HEADER: :tangle no :exports results :results none :noweb yes
#+begin_src matlab :var filepath="figs/identification_comp_top_stages.pdf" :var figsize="full-tall" :post pdf2svg(file=*this*, ext="png")
<>
#+end_src
#+NAME: fig:identification_comp_top_stages
#+CAPTION: caption ([[./figs/identification_comp_top_stages.png][png]], [[./figs/identification_comp_top_stages.pdf][pdf]])
[[file:figs/identification_comp_top_stages.png]]
* Other analysis
** Matlab Init :noexport:ignore:
#+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name)
<>
#+end_src
#+begin_src matlab :exports none :results silent :noweb yes
<>
#+end_src
#+begin_src matlab
simulinkproject('../');
#+end_src
#+begin_src matlab
open('identification/matlab/sim_micro_station_id.slx')
#+end_src
** Plot the obtained transfer functions
** Compare with the modal measurements
** Modal Identification of the micro station