[REFACTORING] Huge changes, WIP.

This commit is contained in:
Thomas Dehaeze
2018-06-16 22:57:54 +02:00
parent 971a520edd
commit 92b66cb8bb
67 changed files with 3313 additions and 2421 deletions

View File

@@ -0,0 +1,28 @@
%%
clear; close all; clc;
%% Load Plant
load('./mat/G_xg_to_d.mat', 'G_xg_to_d');
%% Load shape of the perturbation
load('./mat/weight_Wxg.mat', 'Wxg');
%% Effect of the perturbation on the output
freqs = logspace(-1, 3, 1000);
dx_out = squeeze(abs(freqresp(Wxg*G_xg_to_d(1, 1), freqs, 'Hz')));
dy_out = squeeze(abs(freqresp(Wxg*G_xg_to_d(2, 2), freqs, 'Hz')));
dz_out = squeeze(abs(freqresp(Wxg*G_xg_to_d(3, 3), freqs, 'Hz')));
figure;
hold on;
plot(freqs, dx_out, 'DisplayName', 'Effect of $Dg$ on $D_{x}$');
plot(freqs, dy_out, 'DisplayName', 'Effect of $Dg$ on $D_{y}$');
plot(freqs, dz_out, 'DisplayName', 'Effect of $Dg$ on $D_{z}$');
xlabel('Frequency [Hz]'); ylabel('PSD [$m/\sqrt{Hz}$]');
set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log');
legend('location', 'southwest');
xlim([freqs(1), freqs(end)]);
hold off;
exportFig('ground_motion_effect', 'normal-normal')

View File

@@ -1,15 +1,20 @@
%% Load open loop data
gm_ol = load('../data/ground_motion_001.mat');
% gm_ol = load('../data/ground_motion_001.mat');
%%
clear; close all; clc;
%%
Dmeas.Data = Dmeas.Data - Dmeas.Data(1, :);
sim Assemblage
%%
Dsample.Data = Dsample.Data - Dsample.Data(1, :);
%% Time domain X-Y-Z
figure;
hold on;
plot(Dmeas.Time, Dmeas.Data(:, 1));
plot(Dmeas.Time, Dmeas.Data(:, 2));
plot(Dmeas.Time, Dmeas.Data(:, 3));
plot(Dsample.Time, Dsample.Data(:, 1));
plot(Dsample.Time, Dsample.Data(:, 2));
plot(Dsample.Time, Dsample.Data(:, 3));
legend({'x', 'y', 'z'})
hold off;
xlabel('Time [s]'); ylabel('Displacement [m]');
@@ -19,21 +24,21 @@ exportFig('tomo_time_translations', 'normal-normal')
%% Time domain angles
figure;
hold on;
plot(Dmeas.Time, Dmeas.Data(:, 4));
plot(Dmeas.Time, Dmeas.Data(:, 5));
plot(Dmeas.Time, Dmeas.Data(:, 6));
plot(Dsample.Time, Dsample.Data(:, 4));
plot(Dsample.Time, Dsample.Data(:, 5));
plot(Dsample.Time, Dsample.Data(:, 6));
legend({'$\theta_x$', '$\theta_y$', '$\theta_z$'})
hold off;
xlabel('Time [s]'); ylabel('Displacement [m]');
xlabel('Time [s]'); ylabel('Angle [rad]');
exportFig('tomo_time_rotations', 'normal-normal')
%% PSD X-Y-Z
han_windows = hanning(ceil(length(Dmeas.Time)/10));
han_windows = hanning(ceil(length(Dsample.Time)/10));
[psd_x, freqs_x] = pwelch(Dmeas.Data(:, 1), han_windows, 0, [], 1/Ts);
[psd_y, freqs_y] = pwelch(Dmeas.Data(:, 2), han_windows, 0, [], 1/Ts);
[psd_z, freqs_z] = pwelch(Dmeas.Data(:, 3), han_windows, 0, [], 1/Ts);
[psd_x, freqs_x] = pwelch(Dsample.Data(:, 1), han_windows, 0, [], 1/Ts);
[psd_y, freqs_y] = pwelch(Dsample.Data(:, 2), han_windows, 0, [], 1/Ts);
[psd_z, freqs_z] = pwelch(Dsample.Data(:, 3), han_windows, 0, [], 1/Ts);
figure;
hold on;
@@ -48,11 +53,11 @@ hold off;
exportFig('tomo_psd_translations', 'normal-normal')
%% PSD X-Y-Z
han_windows = hanning(ceil(length(Dmeas.Time)/10));
han_windows = hanning(ceil(length(Dsample.Time)/10));
[psd_x, freqs_x] = pwelch(Dmeas.Data(:, 4), han_windows, 0, [], 1/Ts);
[psd_y, freqs_y] = pwelch(Dmeas.Data(:, 5), han_windows, 0, [], 1/Ts);
[psd_z, freqs_z] = pwelch(Dmeas.Data(:, 6), han_windows, 0, [], 1/Ts);
[psd_x, freqs_x] = pwelch(Dsample.Data(:, 4), han_windows, 0, [], 1/Ts);
[psd_y, freqs_y] = pwelch(Dsample.Data(:, 5), han_windows, 0, [], 1/Ts);
[psd_z, freqs_z] = pwelch(Dsample.Data(:, 6), han_windows, 0, [], 1/Ts);
figure;
hold on;
@@ -66,6 +71,5 @@ hold off;
exportFig('tomo_psd_rotations', 'normal-normal')
%%
save('../data/ground_motion.mat', 'Dmeas')
save('./data/ground_motion.mat', 'Dsample')

View File

@@ -1,25 +1,70 @@
gm_ol = load('../data/ground_motion_ol.mat', 'Dmeas');
gm_cl = load('../data/ground_motion_001.mat', 'Dmeas');
%%
clear; close all; clc;
%% Used to get Ts
run init_sim_configuration;
%% Load simulation results
gm_ol = load('./data/ground_motion_ol.mat', 'Dsample');
gm_cl = load('./data/ground_motion.mat', 'Dsample');
%% Compare OL and CL - Time
figure;
hold on;
plot(gm_ol.Dmeas.Time, gm_ol.Dmeas.Data(:, 2));
plot(gm_cl.Dmeas.Time, gm_cl.Dmeas.Data(:, 2));
plot(gm_ol.Dsample.Time, gm_ol.Dsample.Data(:, 1));
plot(gm_cl.Dsample.Time, gm_cl.Dsample.Data(:, 1));
legend({'x - OL', 'x - CL'})
hold off;
xlabel('Time [s]'); ylabel('Displacement [m]');
exportFig('gm_control_time_x', 'normal-normal')
%% Compare OL and CL - Time
figure;
hold on;
plot(gm_ol.Dsample.Time, gm_ol.Dsample.Data(:, 2));
plot(gm_cl.Dsample.Time, gm_cl.Dsample.Data(:, 2));
legend({'y - OL', 'y - CL'})
hold off;
xlabel('Time [s]'); ylabel('Displacement [m]');
exportFig('gm_control_time_y', 'normal-normal')
%% Compare OL and CL - Time
figure;
hold on;
plot(gm_ol.Dsample.Time, gm_ol.Dsample.Data(:, 3));
plot(gm_cl.Dsample.Time, gm_cl.Dsample.Data(:, 3));
legend({'z - OL', 'z - CL'})
hold off;
xlabel('Time [s]'); ylabel('Displacement [m]');
exportFig('gm_control_time_z', 'normal-normal')
%% Compare OL and CL - PSD
han_windows_ol = hanning(ceil(length(gm_ol.Dmeas.Time)/10));
[psd_y_ol, freqs_y_ol] = pwelch(gm_ol.Dmeas.Data(:, 2), han_windows, 0, [], 1/Ts);
han_windows_ol = hanning(ceil(length(gm_ol.Dsample.Time)/10));
[psd_x_ol, freqs_x_ol] = pwelch(gm_ol.Dsample.Data(:, 1), han_windows_ol, 0, [], 1/Ts);
han_windows = hanning(ceil(length(gm_cl.Dmeas.Time)/10));
[psd_y, freqs_y] = pwelch(gm_cl.Dmeas.Data(:, 2), han_windows, 0, [], 1/Ts);
han_windows = hanning(ceil(length(gm_cl.Dsample.Time)/10));
[psd_x, freqs_x] = pwelch(gm_cl.Dsample.Data(:, 1), han_windows, 0, [], 1/Ts);
figure;
hold on;
plot(freqs_x_ol, sqrt(psd_x_ol));
plot(freqs_x, sqrt(psd_x));
set(gca,'xscale','log'); set(gca,'yscale','log');
xlabel('Frequency [Hz]'); ylabel('PSD [$m/\sqrt{Hz}$]');
legend({'y - OL', 'y - CL'})
hold off;
exportFig('gm_control_psd_x', 'normal-normal')
%% Compare OL and CL - PSD
han_windows_ol = hanning(ceil(length(gm_ol.Dsample.Time)/10));
[psd_y_ol, freqs_y_ol] = pwelch(gm_ol.Dsample.Data(:, 2), han_windows_ol, 0, [], 1/Ts);
han_windows = hanning(ceil(length(gm_cl.Dsample.Time)/10));
[psd_y, freqs_y] = pwelch(gm_cl.Dsample.Data(:, 2), han_windows, 0, [], 1/Ts);
figure;
hold on;
@@ -31,3 +76,31 @@ legend({'y - OL', 'y - CL'})
hold off;
exportFig('gm_control_psd_y', 'normal-normal')
%% Compare OL and CL - PSD
load('./mat/G_xg_to_d.mat', 'G_xg_to_d');
load('./mat/weight_Wxg.mat', 'Wxg');
load('./mat/T_S.mat', 'S', 'T');
freqs = logspace(-1, 3, 1000);
dz_ol = squeeze(abs(freqresp(Wxg*G_xg_to_d(3, 3), freqs, 'Hz')));
dz_cl = squeeze(abs(freqresp(Wxg*G_xg_to_d(3, 3)*S(3, 3), freqs, 'Hz')));
han_windows_ol = hanning(ceil(length(gm_ol.Dsample.Time)/10));
[psd_z_ol, freqs_z_ol] = pwelch(gm_ol.Dsample.Data(:, 3), han_windows_ol, 0, [], 1/Ts);
han_windows = hanning(ceil(length(gm_cl.Dsample.Time)/10));
[psd_z, freqs_z] = pwelch(gm_cl.Dsample.Data(:, 3), han_windows, 0, [], 1/Ts);
figure;
hold on;
plot(freqs_z_ol, sqrt(psd_z_ol), '-', 'Color', [0 0.4470 0.7410], 'DisplayName', '$Dg \rightarrow D_x$ - OL (sim)');
plot(freqs, dz_ol, '--', 'Color', [0 0.4470 0.7410], 'DisplayName', '$Dg \rightarrow D_x$ - OL (th)');
plot(freqs_z, sqrt(psd_z), '-', 'Color', [0.8500 0.3250 0.0980], 'DisplayName', '$Dg \rightarrow D_x$ - CL (sim)');
plot(freqs, dz_cl, '--', 'Color', [0.8500 0.3250 0.0980], 'DisplayName', '$Dg \rightarrow D_x$ - CL (th)');
set(gca,'xscale','log'); set(gca,'yscale','log');
xlabel('Frequency [Hz]'); ylabel('PSD [$m/\sqrt{Hz}$]');
legend('location', 'southwest');
hold off;
exportFig('gm_control_psd_z', 'normal-normal')