Start to modify the way disturbances are configured
This commit is contained in:
parent
825f626961
commit
31d4dd5f24
@ -27,157 +27,203 @@
|
|||||||
args.Frz_z logical {mustBeNumericOrLogical} = true
|
args.Frz_z logical {mustBeNumericOrLogical} = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
% Initialization of random numbers
|
||||||
|
rng("shuffle");
|
||||||
|
|
||||||
|
%% Ground Motion
|
||||||
load('dist_psd.mat', 'dist_f');
|
load('dist_psd.mat', 'dist_f');
|
||||||
|
|
||||||
|
% Frequency Data
|
||||||
|
Dw.f = dist_f.f(2:end);
|
||||||
|
Dw.psd_x = dist_f.psd_gm(2:end);
|
||||||
|
Dw.psd_y = dist_f.psd_gm(2:end);
|
||||||
|
Dw.psd_z = dist_f.psd_gm(2:end);
|
||||||
|
|
||||||
|
% Time data
|
||||||
|
Fs = 2*Dw.f(end); % Sampling Frequency of data is twice the maximum frequency of the PSD vector [Hz]
|
||||||
|
N = 2*length(Dw.f); % Number of Samples match the one of the wanted PSD
|
||||||
|
T0 = N/Fs; % Signal Duration [s]
|
||||||
|
Dw.t = linspace(0, T0, N+1)'; % Time Vector [s]
|
||||||
|
|
||||||
|
C = zeros(N/2,1);
|
||||||
|
for i = 1:N/2
|
||||||
|
C(i) = sqrt(Dw.psd_x(i)/T0);
|
||||||
|
end
|
||||||
|
|
||||||
|
if args.Dwx && args.enable
|
||||||
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
|
Dw.x = N/sqrt(2)*ifft(Cx); % Ground Motion - x direction [m]
|
||||||
|
else
|
||||||
|
Dw.x = zeros(length(Dw.t), 1);
|
||||||
|
end
|
||||||
|
|
||||||
|
if args.Dwy && args.enable
|
||||||
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
|
Dw.y = N/sqrt(2)*ifft(Cx); % Ground Motion - y direction [m]
|
||||||
|
else
|
||||||
|
Dw.y = zeros(length(Dw.t), 1);
|
||||||
|
end
|
||||||
|
|
||||||
|
if args.Dwy && args.enable
|
||||||
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
|
Dw.z = N/sqrt(2)*ifft(Cx); % Ground Motion - z direction [m]
|
||||||
|
else
|
||||||
|
Dw.z = zeros(length(Dw.t), 1);
|
||||||
|
end
|
||||||
|
|
||||||
|
load('dist_psd.mat', 'dist_f');
|
||||||
dist_f.f = dist_f.f(2:end);
|
dist_f.f = dist_f.f(2:end);
|
||||||
dist_f.psd_gm = dist_f.psd_gm(2:end);
|
dist_f.psd_gm = dist_f.psd_gm(2:end);
|
||||||
dist_f.psd_ty = dist_f.psd_ty(2:end);
|
dist_f.psd_ty = dist_f.psd_ty(2:end);
|
||||||
dist_f.psd_rz = dist_f.psd_rz(2:end);
|
dist_f.psd_rz = dist_f.psd_rz(2:end);
|
||||||
|
|
||||||
Fs = 2*dist_f.f(end); % Sampling Frequency of data is twice the maximum frequency of the PSD vector [Hz]
|
%% Translation Stage
|
||||||
N = 2*length(dist_f.f); % Number of Samples match the one of the wanted PSD
|
load('dist_psd.mat', 'dist_f');
|
||||||
|
|
||||||
|
% Frequency Data
|
||||||
|
Ty.f = dist_f.f(2:end);
|
||||||
|
Ty.psd_x = dist_f.psd_ty(2:end); % TODO - we take here the vertical direction which is wrong but approximate
|
||||||
|
Ty.psd_z = dist_f.psd_ty(2:end);
|
||||||
|
|
||||||
|
% Time data
|
||||||
|
Fs = 2*Ty.f(end); % Sampling Frequency of data is twice the maximum frequency of the PSD vector [Hz]
|
||||||
|
N = 2*length(Ty.f); % Number of Samples match the one of the wanted PSD
|
||||||
T0 = N/Fs; % Signal Duration [s]
|
T0 = N/Fs; % Signal Duration [s]
|
||||||
df = 1/T0; % Frequency resolution of the DFT [Hz]
|
Ty.t = linspace(0, T0, N+1)'; % Time Vector [s]
|
||||||
% Also equal to (dist_f.f(2)-dist_f.f(1))
|
|
||||||
t = linspace(0, T0, N+1)'; % Time Vector [s]
|
|
||||||
Ts = 1/Fs; % Sampling Time [s]
|
|
||||||
|
|
||||||
phi = dist_f.psd_gm;
|
|
||||||
C = zeros(N/2,1);
|
C = zeros(N/2,1);
|
||||||
for i = 1:N/2
|
for i = 1:N/2
|
||||||
C(i) = sqrt(phi(i)*df);
|
C(i) = sqrt(Ty.psd_x(i)/T0);
|
||||||
end
|
|
||||||
|
|
||||||
if args.Dwx && args.enable
|
|
||||||
rng(111);
|
|
||||||
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
|
||||||
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
|
||||||
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
|
||||||
Dwx = N/sqrt(2)*ifft(Cx); % Ground Motion - x direction [m]
|
|
||||||
else
|
|
||||||
Dwx = zeros(length(t), 1);
|
|
||||||
end
|
|
||||||
|
|
||||||
if args.Dwy && args.enable
|
|
||||||
rng(112);
|
|
||||||
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
|
||||||
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
|
||||||
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
|
||||||
Dwy = N/sqrt(2)*ifft(Cx); % Ground Motion - y direction [m]
|
|
||||||
else
|
|
||||||
Dwy = zeros(length(t), 1);
|
|
||||||
end
|
|
||||||
|
|
||||||
if args.Dwy && args.enable
|
|
||||||
rng(113);
|
|
||||||
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
|
||||||
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
|
||||||
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
|
||||||
Dwz = N/sqrt(2)*ifft(Cx); % Ground Motion - z direction [m]
|
|
||||||
else
|
|
||||||
Dwz = zeros(length(t), 1);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
% Translation Stage - X
|
||||||
if args.Fty_x && args.enable
|
if args.Fty_x && args.enable
|
||||||
phi = dist_f.psd_ty; % TODO - we take here the vertical direction which is wrong but approximate
|
phi = Ty.psd_x;
|
||||||
C = zeros(N/2,1);
|
C = zeros(N/2,1);
|
||||||
for i = 1:N/2
|
for i = 1:N/2
|
||||||
C(i) = sqrt(phi(i)*df);
|
C(i) = sqrt(phi(i)/T0);
|
||||||
end
|
end
|
||||||
rng(121);
|
|
||||||
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Ty x [N]
|
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Ty x [N]
|
||||||
Fty_x = u;
|
Ty.x = u;
|
||||||
else
|
else
|
||||||
Fty_x = zeros(length(t), 1);
|
Ty.x = zeros(length(Ty.t), 1);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
% Translation Stage - Z
|
||||||
if args.Fty_z && args.enable
|
if args.Fty_z && args.enable
|
||||||
phi = dist_f.psd_ty;
|
phi = Ty.psd_z;
|
||||||
C = zeros(N/2,1);
|
C = zeros(N/2,1);
|
||||||
for i = 1:N/2
|
for i = 1:N/2
|
||||||
C(i) = sqrt(phi(i)*df);
|
C(i) = sqrt(phi(i)/T0);
|
||||||
end
|
end
|
||||||
rng(122);
|
|
||||||
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Ty z [N]
|
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Ty z [N]
|
||||||
Fty_z = u;
|
Ty.z = u;
|
||||||
else
|
else
|
||||||
Fty_z = zeros(length(t), 1);
|
Ty.z = zeros(length(Ty.t), 1);
|
||||||
end
|
end
|
||||||
|
|
||||||
% if args.Frz_x && args.enable
|
%% Translation Stage
|
||||||
% phi = dist_f.psd_rz;
|
load('dist_psd.mat', 'dist_f');
|
||||||
% C = zeros(N/2,1);
|
|
||||||
% for i = 1:N/2
|
|
||||||
% C(i) = sqrt(phi(i)*df);
|
|
||||||
% end
|
|
||||||
% rng(131);
|
|
||||||
% theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
|
||||||
% Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
|
||||||
% Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
|
||||||
% u = N/sqrt(2)*ifft(Cx); % Disturbance Force Rz z [N]
|
|
||||||
% Frz_x = u;
|
|
||||||
% else
|
|
||||||
Frz_x = zeros(length(t), 1);
|
|
||||||
% end
|
|
||||||
|
|
||||||
% if args.Frz_y && args.enable
|
% Frequency Data
|
||||||
% phi = dist_f.psd_rz;
|
Rz.f = dist_f.f(2:end);
|
||||||
% C = zeros(N/2,1);
|
Rz.psd_x = dist_f.psd_rz(2:end); % TODO - we take here the vertical direction which is wrong but approximate
|
||||||
% for i = 1:N/2
|
Rz.psd_y = dist_f.psd_rz(2:end); % TODO - we take here the vertical direction which is wrong but approximate
|
||||||
% C(i) = sqrt(phi(i)*df);
|
Rz.psd_z = dist_f.psd_rz(2:end);
|
||||||
% end
|
|
||||||
% rng(131);
|
% Time data
|
||||||
% theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
Fs = 2*Rz.f(end); % Sampling Frequency of data is twice the maximum frequency of the PSD vector [Hz]
|
||||||
% Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
N = 2*length(Rz.f); % Number of Samples match the one of the wanted PSD
|
||||||
% Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
T0 = N/Fs; % Signal Duration [s]
|
||||||
% u = N/sqrt(2)*ifft(Cx); % Disturbance Force Rz z [N]
|
Rz.t = linspace(0, T0, N+1)'; % Time Vector [s]
|
||||||
% Frz_z = u;
|
|
||||||
% else
|
|
||||||
Frz_y = zeros(length(t), 1);
|
|
||||||
% end
|
|
||||||
|
|
||||||
if args.Frz_z && args.enable
|
|
||||||
phi = dist_f.psd_rz;
|
|
||||||
C = zeros(N/2,1);
|
C = zeros(N/2,1);
|
||||||
for i = 1:N/2
|
for i = 1:N/2
|
||||||
C(i) = sqrt(phi(i)*df);
|
C(i) = sqrt(Rz.psd_x(i)/T0);
|
||||||
|
end
|
||||||
|
|
||||||
|
% Translation Stage - X
|
||||||
|
if args.Frz_x && args.enable
|
||||||
|
phi = Rz.psd_x;
|
||||||
|
C = zeros(N/2,1);
|
||||||
|
for i = 1:N/2
|
||||||
|
C(i) = sqrt(phi(i)/T0);
|
||||||
|
end
|
||||||
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
|
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Rz x [N]
|
||||||
|
Rz.x = u;
|
||||||
|
else
|
||||||
|
Rz.x = zeros(length(Rz.t), 1);
|
||||||
|
end
|
||||||
|
|
||||||
|
% Translation Stage - Y
|
||||||
|
if args.Frz_y && args.enable
|
||||||
|
phi = Rz.psd_y;
|
||||||
|
C = zeros(N/2,1);
|
||||||
|
for i = 1:N/2
|
||||||
|
C(i) = sqrt(phi(i)/T0);
|
||||||
|
end
|
||||||
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
|
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Rz y [N]
|
||||||
|
Rz.y = u;
|
||||||
|
else
|
||||||
|
Rz.y = zeros(length(Rz.t), 1);
|
||||||
|
end
|
||||||
|
|
||||||
|
% Translation Stage - Z
|
||||||
|
if args.Frz_z && args.enable
|
||||||
|
phi = Rz.psd_z;
|
||||||
|
C = zeros(N/2,1);
|
||||||
|
for i = 1:N/2
|
||||||
|
C(i) = sqrt(phi(i)/T0);
|
||||||
end
|
end
|
||||||
rng(131);
|
|
||||||
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Rz z [N]
|
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Rz z [N]
|
||||||
Frz_z = u;
|
Rz.z = u;
|
||||||
else
|
else
|
||||||
Frz_z = zeros(length(t), 1);
|
Rz.z = zeros(length(Rz.t), 1);
|
||||||
end
|
end
|
||||||
|
|
||||||
u = zeros(length(t), 6);
|
u = zeros(100, 6);
|
||||||
Fd = u;
|
Fd = u;
|
||||||
|
|
||||||
Dwx = Dwx - Dwx(1);
|
Dw.x = Dw.x - Dw.x(1);
|
||||||
Dwy = Dwy - Dwy(1);
|
Dw.y = Dw.y - Dw.y(1);
|
||||||
Dwz = Dwz - Dwz(1);
|
Dw.z = Dw.z - Dw.z(1);
|
||||||
Fty_x = Fty_x - Fty_x(1);
|
Ty.x = Ty.x - Ty.x(1);
|
||||||
Fty_z = Fty_z - Fty_z(1);
|
Ty.z = Ty.z - Ty.z(1);
|
||||||
Frz_z = Frz_z - Frz_z(1);
|
Rz.x = Rz.x - Rz.x(1);
|
||||||
|
Rz.y = Rz.y - Rz.y(1);
|
||||||
|
Rz.z = Rz.z - Rz.z(1);
|
||||||
|
|
||||||
if exist('./mat', 'dir')
|
if exist('./mat', 'dir')
|
||||||
if exist('./mat/nass_disturbances.mat', 'file')
|
if exist('./mat/nass_disturbances.mat', 'file')
|
||||||
save('mat/nass_disturbances.mat', 'Dwx', 'Dwy', 'Dwz', 'Fty_x', 'Fty_z', 'Frz_x', 'Frz_y', 'Frz_z', 'Fd', 'Ts', 't', 'args', '-append');
|
save('mat/nass_disturbances.mat', 'Dw', 'Ty', 'Rz', 'Fd', 'args', '-append');
|
||||||
else
|
else
|
||||||
save('mat/nass_disturbances.mat', 'Dwx', 'Dwy', 'Dwz', 'Fty_x', 'Fty_z', 'Frz_x', 'Frz_y', 'Frz_z', 'Fd', 'Ts', 't', 'args');
|
save('mat/nass_disturbances.mat', 'Dw', 'Ty', 'Rz', 'Fd', 'args');
|
||||||
end
|
end
|
||||||
elseif exist('./matlab', 'dir')
|
elseif exist('./matlab', 'dir')
|
||||||
if exist('./matlab/mat/nass_disturbances.mat', 'file')
|
if exist('./matlab/mat/nass_disturbances.mat', 'file')
|
||||||
save('matlab/mat/nass_disturbances.mat', 'Dwx', 'Dwy', 'Dwz', 'Fty_x', 'Fty_z', 'Frz_x', 'Frz_y', 'Frz_z', 'Fd', 'Ts', 't', 'args', '-append');
|
save('matlab/mat/nass_disturbances.mat', 'Dw', 'Ty', 'Rz', 'Fd', 'args', '-append');
|
||||||
else
|
else
|
||||||
save('matlab/mat/nass_disturbances.mat', 'Dwx', 'Dwy', 'Dwz', 'Fty_x', 'Fty_z', 'Frz_x', 'Frz_y', 'Frz_z', 'Fd', 'Ts', 't', 'args');
|
save('matlab/mat/nass_disturbances.mat', 'Dw', 'Ty', 'Rz', 'Fd', 'args');
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Binary file not shown.
@ -299,8 +299,11 @@ Procedure:
|
|||||||
|
|
||||||
[[*=initializeDisturbances=: Initialize Disturbances][=initializeDisturbances=: Initialize Disturbances]]
|
[[*=initializeDisturbances=: Initialize Disturbances][=initializeDisturbances=: Initialize Disturbances]]
|
||||||
|
|
||||||
- [ ] It is suppose in this script that all disturbances have the same frequency vectors, and therefore the same time vector...
|
- [X] It is suppose in this script that all disturbances have the same frequency vectors, and therefore the same time vector...
|
||||||
- [ ] See how to deal with that
|
It does not anymore
|
||||||
|
- [X] See how to deal with that
|
||||||
|
|
||||||
|
Be able to pass custom =.mat= files (one mat file per disturbance)?
|
||||||
|
|
||||||
- [ ] Ground motion, X, Y and Z
|
- [ ] Ground motion, X, Y and Z
|
||||||
- [ ] Ty stage, X and Z
|
- [ ] Ty stage, X and Z
|
||||||
@ -2486,8 +2489,8 @@ initializeDisturbances(...
|
|||||||
'Dwz', true, ... % Ground Motion - Z direction
|
'Dwz', true, ... % Ground Motion - Z direction
|
||||||
'Fty_x', false, ... % Translation Stage - X direction
|
'Fty_x', false, ... % Translation Stage - X direction
|
||||||
'Fty_z', false, ... % Translation Stage - Z direction
|
'Fty_z', false, ... % Translation Stage - Z direction
|
||||||
'Frz_x', false, ... % Spindle - X direction
|
'Frz_x', true, ... % Spindle - X direction
|
||||||
'Frz_y', false, ... % Spindle - Y direction
|
'Frz_y', true, ... % Spindle - Y direction
|
||||||
'Frz_z', true); % Spindle - Z direction
|
'Frz_z', true); % Spindle - Z direction
|
||||||
|
|
||||||
initializeReferences(...
|
initializeReferences(...
|
||||||
@ -2501,9 +2504,9 @@ tomo_align_dist = simout;
|
|||||||
#+begin_src matlab :exports none
|
#+begin_src matlab :exports none
|
||||||
figure;
|
figure;
|
||||||
hold on;
|
hold on;
|
||||||
plot(tomo_align_dist.y.x.Time, tomo_align_dist.y.x.Data)
|
plot(tomo_align_dist.y.x.Time, 1e6*tomo_align_dist.y.x.Data)
|
||||||
plot(tomo_align_dist.y.y.Time, tomo_align_dist.y.y.Data)
|
plot(tomo_align_dist.y.y.Time, 1e6*tomo_align_dist.y.y.Data)
|
||||||
plot(tomo_align_dist.y.z.Time, tomo_align_dist.y.z.Data)
|
plot(tomo_align_dist.y.z.Time, 1e6*tomo_align_dist.y.z.Data)
|
||||||
hold off;
|
hold off;
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
@ -2540,7 +2543,6 @@ hold off;
|
|||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Raster Scans with the translation stage
|
** Raster Scans with the translation stage
|
||||||
<<sec:ty_scans>>
|
|
||||||
#+begin_src matlab
|
#+begin_src matlab
|
||||||
initializeReferences('Dy_type', 'triangular', 'Dy_amplitude', 10e-3, 'Dy_period', 1);
|
initializeReferences('Dy_type', 'triangular', 'Dy_amplitude', 10e-3, 'Dy_period', 1);
|
||||||
sim(mdl);
|
sim(mdl);
|
||||||
@ -2551,7 +2553,6 @@ hold off;
|
|||||||
* Conclusion
|
* Conclusion
|
||||||
<<sec:uniaxial_conclusion>>
|
<<sec:uniaxial_conclusion>>
|
||||||
|
|
||||||
|
|
||||||
* Bibliography :ignore:
|
* Bibliography :ignore:
|
||||||
#+latex: \printbibliography[heading=bibintoc,title={Bibliography}]
|
#+latex: \printbibliography[heading=bibintoc,title={Bibliography}]
|
||||||
|
|
||||||
@ -2979,200 +2980,228 @@ arguments
|
|||||||
end
|
end
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Load Data
|
|
||||||
#+begin_src matlab
|
#+begin_src matlab
|
||||||
load('dist_psd.mat', 'dist_f');
|
% Initialization of random numbers
|
||||||
|
rng("shuffle");
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
*** Ground Motion
|
||||||
|
#+begin_src matlab
|
||||||
|
%% Ground Motion
|
||||||
|
load('dist_psd.mat', 'dist_f');
|
||||||
|
|
||||||
|
% Frequency Data
|
||||||
|
Dw.f = dist_f.f(2:end);
|
||||||
|
Dw.psd_x = dist_f.psd_gm(2:end);
|
||||||
|
Dw.psd_y = dist_f.psd_gm(2:end);
|
||||||
|
Dw.psd_z = dist_f.psd_gm(2:end);
|
||||||
|
|
||||||
|
% Time data
|
||||||
|
Fs = 2*Dw.f(end); % Sampling Frequency of data is twice the maximum frequency of the PSD vector [Hz]
|
||||||
|
N = 2*length(Dw.f); % Number of Samples match the one of the wanted PSD
|
||||||
|
T0 = N/Fs; % Signal Duration [s]
|
||||||
|
Dw.t = linspace(0, T0, N+1)'; % Time Vector [s]
|
||||||
|
|
||||||
|
C = zeros(N/2,1);
|
||||||
|
for i = 1:N/2
|
||||||
|
C(i) = sqrt(Dw.psd_x(i)/T0);
|
||||||
|
end
|
||||||
|
|
||||||
|
if args.Dwx && args.enable
|
||||||
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
|
Dw.x = N/sqrt(2)*ifft(Cx); % Ground Motion - x direction [m]
|
||||||
|
else
|
||||||
|
Dw.x = zeros(length(Dw.t), 1);
|
||||||
|
end
|
||||||
|
|
||||||
|
if args.Dwy && args.enable
|
||||||
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
|
Dw.y = N/sqrt(2)*ifft(Cx); % Ground Motion - y direction [m]
|
||||||
|
else
|
||||||
|
Dw.y = zeros(length(Dw.t), 1);
|
||||||
|
end
|
||||||
|
|
||||||
|
if args.Dwy && args.enable
|
||||||
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
|
Dw.z = N/sqrt(2)*ifft(Cx); % Ground Motion - z direction [m]
|
||||||
|
else
|
||||||
|
Dw.z = zeros(length(Dw.t), 1);
|
||||||
|
end
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
*** Translation Stage
|
||||||
|
|
||||||
|
|
||||||
We remove the first frequency point that usually is very large.
|
We remove the first frequency point that usually is very large.
|
||||||
#+begin_src matlab :exports none
|
#+begin_src matlab :exports none
|
||||||
|
load('dist_psd.mat', 'dist_f');
|
||||||
dist_f.f = dist_f.f(2:end);
|
dist_f.f = dist_f.f(2:end);
|
||||||
dist_f.psd_gm = dist_f.psd_gm(2:end);
|
dist_f.psd_gm = dist_f.psd_gm(2:end);
|
||||||
dist_f.psd_ty = dist_f.psd_ty(2:end);
|
dist_f.psd_ty = dist_f.psd_ty(2:end);
|
||||||
dist_f.psd_rz = dist_f.psd_rz(2:end);
|
dist_f.psd_rz = dist_f.psd_rz(2:end);
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Parameters
|
|
||||||
We define some parameters that will be used in the algorithm.
|
|
||||||
#+begin_src matlab
|
#+begin_src matlab
|
||||||
Fs = 2*dist_f.f(end); % Sampling Frequency of data is twice the maximum frequency of the PSD vector [Hz]
|
%% Translation Stage
|
||||||
N = 2*length(dist_f.f); % Number of Samples match the one of the wanted PSD
|
load('dist_psd.mat', 'dist_f');
|
||||||
|
|
||||||
|
% Frequency Data
|
||||||
|
Ty.f = dist_f.f(2:end);
|
||||||
|
Ty.psd_x = dist_f.psd_ty(2:end); % TODO - we take here the vertical direction which is wrong but approximate
|
||||||
|
Ty.psd_z = dist_f.psd_ty(2:end);
|
||||||
|
|
||||||
|
% Time data
|
||||||
|
Fs = 2*Ty.f(end); % Sampling Frequency of data is twice the maximum frequency of the PSD vector [Hz]
|
||||||
|
N = 2*length(Ty.f); % Number of Samples match the one of the wanted PSD
|
||||||
T0 = N/Fs; % Signal Duration [s]
|
T0 = N/Fs; % Signal Duration [s]
|
||||||
df = 1/T0; % Frequency resolution of the DFT [Hz]
|
Ty.t = linspace(0, T0, N+1)'; % Time Vector [s]
|
||||||
% Also equal to (dist_f.f(2)-dist_f.f(1))
|
|
||||||
t = linspace(0, T0, N+1)'; % Time Vector [s]
|
|
||||||
Ts = 1/Fs; % Sampling Time [s]
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** Ground Motion
|
|
||||||
#+begin_src matlab
|
|
||||||
phi = dist_f.psd_gm;
|
|
||||||
C = zeros(N/2,1);
|
C = zeros(N/2,1);
|
||||||
for i = 1:N/2
|
for i = 1:N/2
|
||||||
C(i) = sqrt(phi(i)*df);
|
C(i) = sqrt(Ty.psd_x(i)/T0);
|
||||||
end
|
end
|
||||||
#+end_src
|
|
||||||
|
|
||||||
#+begin_src matlab
|
% Translation Stage - X
|
||||||
if args.Dwx && args.enable
|
|
||||||
rng(111);
|
|
||||||
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
|
||||||
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
|
||||||
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
|
||||||
Dwx = N/sqrt(2)*ifft(Cx); % Ground Motion - x direction [m]
|
|
||||||
else
|
|
||||||
Dwx = zeros(length(t), 1);
|
|
||||||
end
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
#+begin_src matlab
|
|
||||||
if args.Dwy && args.enable
|
|
||||||
rng(112);
|
|
||||||
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
|
||||||
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
|
||||||
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
|
||||||
Dwy = N/sqrt(2)*ifft(Cx); % Ground Motion - y direction [m]
|
|
||||||
else
|
|
||||||
Dwy = zeros(length(t), 1);
|
|
||||||
end
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
#+begin_src matlab
|
|
||||||
if args.Dwy && args.enable
|
|
||||||
rng(113);
|
|
||||||
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
|
||||||
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
|
||||||
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
|
||||||
Dwz = N/sqrt(2)*ifft(Cx); % Ground Motion - z direction [m]
|
|
||||||
else
|
|
||||||
Dwz = zeros(length(t), 1);
|
|
||||||
end
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** Translation Stage - X direction
|
|
||||||
#+begin_src matlab
|
|
||||||
if args.Fty_x && args.enable
|
if args.Fty_x && args.enable
|
||||||
phi = dist_f.psd_ty; % TODO - we take here the vertical direction which is wrong but approximate
|
phi = Ty.psd_x;
|
||||||
C = zeros(N/2,1);
|
C = zeros(N/2,1);
|
||||||
for i = 1:N/2
|
for i = 1:N/2
|
||||||
C(i) = sqrt(phi(i)*df);
|
C(i) = sqrt(phi(i)/T0);
|
||||||
end
|
end
|
||||||
rng(121);
|
|
||||||
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Ty x [N]
|
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Ty x [N]
|
||||||
Fty_x = u;
|
Ty.x = u;
|
||||||
else
|
else
|
||||||
Fty_x = zeros(length(t), 1);
|
Ty.x = zeros(length(Ty.t), 1);
|
||||||
end
|
end
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** Translation Stage - Z direction
|
% Translation Stage - Z
|
||||||
#+begin_src matlab
|
|
||||||
if args.Fty_z && args.enable
|
if args.Fty_z && args.enable
|
||||||
phi = dist_f.psd_ty;
|
phi = Ty.psd_z;
|
||||||
C = zeros(N/2,1);
|
C = zeros(N/2,1);
|
||||||
for i = 1:N/2
|
for i = 1:N/2
|
||||||
C(i) = sqrt(phi(i)*df);
|
C(i) = sqrt(phi(i)/T0);
|
||||||
end
|
end
|
||||||
rng(122);
|
|
||||||
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Ty z [N]
|
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Ty z [N]
|
||||||
Fty_z = u;
|
Ty.z = u;
|
||||||
else
|
else
|
||||||
Fty_z = zeros(length(t), 1);
|
Ty.z = zeros(length(Ty.t), 1);
|
||||||
end
|
end
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Spindle - X direction
|
*** Spindle
|
||||||
#+begin_src matlab
|
#+begin_src matlab
|
||||||
% if args.Frz_x && args.enable
|
%% Translation Stage
|
||||||
% phi = dist_f.psd_rz;
|
load('dist_psd.mat', 'dist_f');
|
||||||
% C = zeros(N/2,1);
|
|
||||||
% for i = 1:N/2
|
|
||||||
% C(i) = sqrt(phi(i)*df);
|
|
||||||
% end
|
|
||||||
% rng(131);
|
|
||||||
% theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
|
||||||
% Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
|
||||||
% Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
|
||||||
% u = N/sqrt(2)*ifft(Cx); % Disturbance Force Rz z [N]
|
|
||||||
% Frz_x = u;
|
|
||||||
% else
|
|
||||||
Frz_x = zeros(length(t), 1);
|
|
||||||
% end
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** Spindle - Y direction
|
% Frequency Data
|
||||||
#+begin_src matlab
|
Rz.f = dist_f.f(2:end);
|
||||||
% if args.Frz_y && args.enable
|
Rz.psd_x = dist_f.psd_rz(2:end); % TODO - we take here the vertical direction which is wrong but approximate
|
||||||
% phi = dist_f.psd_rz;
|
Rz.psd_y = dist_f.psd_rz(2:end); % TODO - we take here the vertical direction which is wrong but approximate
|
||||||
% C = zeros(N/2,1);
|
Rz.psd_z = dist_f.psd_rz(2:end);
|
||||||
% for i = 1:N/2
|
|
||||||
% C(i) = sqrt(phi(i)*df);
|
% Time data
|
||||||
% end
|
Fs = 2*Rz.f(end); % Sampling Frequency of data is twice the maximum frequency of the PSD vector [Hz]
|
||||||
% rng(131);
|
N = 2*length(Rz.f); % Number of Samples match the one of the wanted PSD
|
||||||
% theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
T0 = N/Fs; % Signal Duration [s]
|
||||||
% Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
Rz.t = linspace(0, T0, N+1)'; % Time Vector [s]
|
||||||
% Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
|
||||||
% u = N/sqrt(2)*ifft(Cx); % Disturbance Force Rz z [N]
|
|
||||||
% Frz_z = u;
|
|
||||||
% else
|
|
||||||
Frz_y = zeros(length(t), 1);
|
|
||||||
% end
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** Spindle - Z direction
|
|
||||||
#+begin_src matlab
|
|
||||||
if args.Frz_z && args.enable
|
|
||||||
phi = dist_f.psd_rz;
|
|
||||||
C = zeros(N/2,1);
|
C = zeros(N/2,1);
|
||||||
for i = 1:N/2
|
for i = 1:N/2
|
||||||
C(i) = sqrt(phi(i)*df);
|
C(i) = sqrt(Rz.psd_x(i)/T0);
|
||||||
|
end
|
||||||
|
|
||||||
|
% Translation Stage - X
|
||||||
|
if args.Frz_x && args.enable
|
||||||
|
phi = Rz.psd_x;
|
||||||
|
C = zeros(N/2,1);
|
||||||
|
for i = 1:N/2
|
||||||
|
C(i) = sqrt(phi(i)/T0);
|
||||||
|
end
|
||||||
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
|
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Rz x [N]
|
||||||
|
Rz.x = u;
|
||||||
|
else
|
||||||
|
Rz.x = zeros(length(Rz.t), 1);
|
||||||
|
end
|
||||||
|
|
||||||
|
% Translation Stage - Y
|
||||||
|
if args.Frz_y && args.enable
|
||||||
|
phi = Rz.psd_y;
|
||||||
|
C = zeros(N/2,1);
|
||||||
|
for i = 1:N/2
|
||||||
|
C(i) = sqrt(phi(i)/T0);
|
||||||
|
end
|
||||||
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
|
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Rz y [N]
|
||||||
|
Rz.y = u;
|
||||||
|
else
|
||||||
|
Rz.y = zeros(length(Rz.t), 1);
|
||||||
|
end
|
||||||
|
|
||||||
|
% Translation Stage - Z
|
||||||
|
if args.Frz_z && args.enable
|
||||||
|
phi = Rz.psd_z;
|
||||||
|
C = zeros(N/2,1);
|
||||||
|
for i = 1:N/2
|
||||||
|
C(i) = sqrt(phi(i)/T0);
|
||||||
end
|
end
|
||||||
rng(131);
|
|
||||||
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
theta = 2*pi*rand(N/2,1); % Generate random phase [rad]
|
||||||
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
Cx = [0 ; C.*complex(cos(theta),sin(theta))];
|
||||||
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
Cx = [Cx; flipud(conj(Cx(2:end)))];;
|
||||||
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Rz z [N]
|
u = N/sqrt(2)*ifft(Cx); % Disturbance Force Rz z [N]
|
||||||
Frz_z = u;
|
Rz.z = u;
|
||||||
else
|
else
|
||||||
Frz_z = zeros(length(t), 1);
|
Rz.z = zeros(length(Rz.t), 1);
|
||||||
end
|
end
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Direct Forces
|
*** Direct Forces
|
||||||
#+begin_src matlab
|
#+begin_src matlab
|
||||||
u = zeros(length(t), 6);
|
u = zeros(100, 6);
|
||||||
Fd = u;
|
Fd = u;
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Set initial value to zero
|
*** Set initial value to zero
|
||||||
#+begin_src matlab
|
#+begin_src matlab
|
||||||
Dwx = Dwx - Dwx(1);
|
Dw.x = Dw.x - Dw.x(1);
|
||||||
Dwy = Dwy - Dwy(1);
|
Dw.y = Dw.y - Dw.y(1);
|
||||||
Dwz = Dwz - Dwz(1);
|
Dw.z = Dw.z - Dw.z(1);
|
||||||
Fty_x = Fty_x - Fty_x(1);
|
Ty.x = Ty.x - Ty.x(1);
|
||||||
Fty_z = Fty_z - Fty_z(1);
|
Ty.z = Ty.z - Ty.z(1);
|
||||||
Frz_z = Frz_z - Frz_z(1);
|
Rz.x = Rz.x - Rz.x(1);
|
||||||
|
Rz.y = Rz.y - Rz.y(1);
|
||||||
|
Rz.z = Rz.z - Rz.z(1);
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Save the Structure
|
*** Save the Structure
|
||||||
#+begin_src matlab
|
#+begin_src matlab
|
||||||
if exist('./mat', 'dir')
|
if exist('./mat', 'dir')
|
||||||
if exist('./mat/nass_disturbances.mat', 'file')
|
if exist('./mat/nass_disturbances.mat', 'file')
|
||||||
save('mat/nass_disturbances.mat', 'Dwx', 'Dwy', 'Dwz', 'Fty_x', 'Fty_z', 'Frz_x', 'Frz_y', 'Frz_z', 'Fd', 'Ts', 't', 'args', '-append');
|
save('mat/nass_disturbances.mat', 'Dw', 'Ty', 'Rz', 'Fd', 'args', '-append');
|
||||||
else
|
else
|
||||||
save('mat/nass_disturbances.mat', 'Dwx', 'Dwy', 'Dwz', 'Fty_x', 'Fty_z', 'Frz_x', 'Frz_y', 'Frz_z', 'Fd', 'Ts', 't', 'args');
|
save('mat/nass_disturbances.mat', 'Dw', 'Ty', 'Rz', 'Fd', 'args');
|
||||||
end
|
end
|
||||||
elseif exist('./matlab', 'dir')
|
elseif exist('./matlab', 'dir')
|
||||||
if exist('./matlab/mat/nass_disturbances.mat', 'file')
|
if exist('./matlab/mat/nass_disturbances.mat', 'file')
|
||||||
save('matlab/mat/nass_disturbances.mat', 'Dwx', 'Dwy', 'Dwz', 'Fty_x', 'Fty_z', 'Frz_x', 'Frz_y', 'Frz_z', 'Fd', 'Ts', 't', 'args', '-append');
|
save('matlab/mat/nass_disturbances.mat', 'Dw', 'Ty', 'Rz', 'Fd', 'args', '-append');
|
||||||
else
|
else
|
||||||
save('matlab/mat/nass_disturbances.mat', 'Dwx', 'Dwy', 'Dwz', 'Fty_x', 'Fty_z', 'Frz_x', 'Frz_y', 'Frz_z', 'Fd', 'Ts', 't', 'args');
|
save('matlab/mat/nass_disturbances.mat', 'Dw', 'Ty', 'Rz', 'Fd', 'args');
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#+end_src
|
#+end_src
|
||||||
|
Loading…
Reference in New Issue
Block a user