Change initialization of simulation configuration

This commit is contained in:
Thomas Dehaeze 2018-06-21 11:42:46 +02:00
parent e065ab61e8
commit 91ab166b3e
14 changed files with 88 additions and 45 deletions

Binary file not shown.

View File

@ -1,9 +1,17 @@
%% %%
clear; close all; clc; clear; close all; clc;
%% Initialize simulation configuration
opts_sim = struct(...
'Tsim', 60 ...
);
initializeSimConf(opts_sim);
%% Initialize Inputs %% Initialize Inputs
opts_inputs = struct(... opts_inputs = struct(...
'ground_motion', true ... 'ground_motion', true, ...
'rz', true ...
); );
initializeInputs(opts_inputs); initializeInputs(opts_inputs);
@ -33,7 +41,9 @@ initializeMicroHexapod();
initializeAxisc(); initializeAxisc();
%% Initialize NASS %% Initialize NASS
initializeNanoHexapod(); opts_nano_hexapod = struct('actuator', 'lorentz');
initializeNanoHexapod(opts_nano_hexapod);
%% Initialize Sample %% Initialize Sample
opts_sample = struct('mass', 20); opts_sample = struct('mass', 20);

View File

@ -1,6 +0,0 @@
%% Solver Configuration
Ts = 1e-3; % Sampling time [s]
Tsim = 1; % Simulation time [s]
%% Gravity
g = 0 ; % Gravity along the z axis [m/s^2]

View File

@ -1,5 +1,5 @@
%% Load Simulation configuration %% Load Simulation configuration
run init_sim_configuration.m load('./mat/sim_conf.mat', 'sim_conf');
%% Load SolidWorks Data %% Load SolidWorks Data
% load('./mat/smiData.mat', 'smiData'); % load('./mat/smiData.mat', 'smiData');

View File

@ -8,7 +8,7 @@ function [axisc] = initializeAxisc()
axisc.m = smiData.Solid(30).mass; axisc.m = smiData.Solid(30).mass;
axisc.k.ax = 1; % TODO [N*m/deg)] axisc.k.ax = 1; % TODO [N*m/deg)]
axisc.c.ax = axisc.k.ax/1000; axisc.c.ax = (1/1)*sqrt(axisc.k.ax/axisc.m);
%% Save if no output argument %% Save if no output argument
if nargout == 0 if nargout == 0

View File

@ -8,7 +8,7 @@ function [granite] = initializeGranite()
granite.m = smiData.Solid(5).mass; granite.m = smiData.Solid(5).mass;
granite.k.ax = 1e8; % x-y-z Stiffness of the granite [N/m] granite.k.ax = 1e8; % x-y-z Stiffness of the granite [N/m]
granite.c.ax = granite.k.ax/1000; granite.c.ax = 100*(1/1)*sqrt(granite.k.ax/granite.m);
%% Save if no output argument %% Save if no output argument
if nargout == 0 if nargout == 0

View File

@ -15,24 +15,14 @@ function [inputs] = initializeInputs(opts_param)
end end
%% Load Sampling Time and Simulation Time %% Load Sampling Time and Simulation Time
run init_sim_configuration.m load('./mat/sim_conf.mat', 'sim_conf');
%% Define the time vector %% Define the time vector
time_vector = 0:Ts:Tsim; time_vector = 0:sim_conf.Ts:sim_conf.Tsim;
%% Create the input Structure that will contain all the inputs %% Create the input Structure that will contain all the inputs
inputs = struct(); inputs = struct();
%% Set point [m, rad]
if opts.setpoint
setpoint = zeros(length(time_vector), 6);
setpoint(ceil(10/Ts):end, 2) = 1e-6; % Step of 1 micro-meter in y direction
else
setpoint = zeros(length(time_vector), 6);
end
inputs.setpoint = timeseries(setpoint, time_vector);
%% Ground motion %% Ground motion
if opts.ground_motion if opts.ground_motion
load('./mat/weight_Wxg.mat', 'Wxg'); load('./mat/weight_Wxg.mat', 'Wxg');
@ -56,7 +46,7 @@ function [inputs] = initializeInputs(opts_param)
inputs.ty = timeseries(ty, time_vector); inputs.ty = timeseries(ty, time_vector);
%% Tilt Stage [rad] %% Tilt Stage [rad]
if opts.ty if opts.ry
ry = 3*(2*pi/360)*sin(2*pi*0.2*time_vector); ry = 3*(2*pi/360)*sin(2*pi*0.2*time_vector);
else else
ry = zeros(length(time_vector), 1); ry = zeros(length(time_vector), 1);
@ -65,7 +55,7 @@ function [inputs] = initializeInputs(opts_param)
inputs.ry = timeseries(ry, time_vector); inputs.ry = timeseries(ry, time_vector);
%% Spindle [rad] %% Spindle [rad]
if opts.ty if opts.rz
rz = 2*pi*0.5*time_vector; rz = 2*pi*0.5*time_vector;
else else
rz = zeros(length(time_vector), 1); rz = zeros(length(time_vector), 1);
@ -88,9 +78,20 @@ function [inputs] = initializeInputs(opts_param)
inputs.nano_hexapod = timeseries(n_hexa, time_vector); inputs.nano_hexapod = timeseries(n_hexa, time_vector);
%% Set point [m, rad]
if opts.setpoint
setpoint = zeros(length(time_vector), 6);
setpoint(ceil(10/sim_conf.Ts):end, 2) = 1e-6; % Step of 1 micro-meter in y direction
else
setpoint = zeros(length(time_vector), 6);
end
setpoint(:, 6) = rz;
inputs.setpoint = timeseries(setpoint, time_vector);
%% Save if no output argument %% Save if no output argument
if nargout == 0 if nargout == 0
save('./mat/inputs.mat', 'inputs'); save('./mat/inputs.mat', 'inputs');
end end
end end

View File

@ -1,6 +1,6 @@
function [nano_hexapod] = initializeNanoHexapod(opts_param) function [nano_hexapod] = initializeNanoHexapod(opts_param)
%% Default values for opts %% Default values for opts
opts = struct(); opts = struct('actuator', 'piezo');
%% Populate opts with input parameters %% Populate opts with input parameters
if exist('opts_param','var') if exist('opts_param','var')
@ -42,7 +42,11 @@ function [nano_hexapod] = initializeNanoHexapod(opts_param)
Leg = struct(); Leg = struct();
Leg.stroke = 80e-6; % Maximum Stroke of each leg [m] Leg.stroke = 80e-6; % Maximum Stroke of each leg [m]
if strcmp(opts.actuator, 'piezo')
Leg.k.ax = 5e7; % Stiffness of each leg [N/m] Leg.k.ax = 5e7; % Stiffness of each leg [N/m]
else
Leg.k.ax = 1e5; % Stiffness of each leg [N/m]
end
Leg.ksi.ax = 10; % Maximum amplification at resonance [] Leg.ksi.ax = 10; % Maximum amplification at resonance []
Leg.rad.bottom = 12; % Radius of the cylinder of the bottom part [mm] Leg.rad.bottom = 12; % Radius of the cylinder of the bottom part [mm]
Leg.rad.top = 10; % Radius of the cylinder of the top part [mm] Leg.rad.top = 10; % Radius of the cylinder of the top part [mm]

View File

@ -12,10 +12,10 @@ function [ry] = initializeRy()
ry.k.rrad = 238e6/4; % Stiffness in the side direction [N/m] ry.k.rrad = 238e6/4; % Stiffness in the side direction [N/m]
ry.k.tilt = 1e4 ; % Rotation stiffness around y [N*m/deg] ry.k.tilt = 1e4 ; % Rotation stiffness around y [N*m/deg]
ry.c.h = ry.k.h/1000; ry.c.h = 10*(1/5)*sqrt(ry.k.h/ry.m);
ry.c.rad = ry.k.rad/1000; ry.c.rad = 10*(1/5)*sqrt(ry.k.rad/ry.m);
ry.c.rrad = ry.k.rrad/1000; ry.c.rrad = 10*(1/5)*sqrt(ry.k.rrad/ry.m);
ry.c.tilt = ry.k.tilt/1000; ry.c.tilt = 10*(1/1)*sqrt(ry.k.tilt/ry.m);
%% Save if no output argument %% Save if no output argument
if nargout == 0 if nargout == 0

View File

@ -9,17 +9,16 @@ function [rz] = initializeRz()
rz.k.ax = 2e9; % Axial Stiffness [N/m] rz.k.ax = 2e9; % Axial Stiffness [N/m]
rz.k.rad = 7e8; % Radial Stiffness [N/m] rz.k.rad = 7e8; % Radial Stiffness [N/m]
rz.k.tilt = 1e5; % TODO rz.k.tilt = 1e2; % TODO [N*m/deg]
rz.k.rot = 1e5; % Rotational Stiffness [N*m/deg] rz.k.rot = 1e2; % Rotational Stiffness [N*m/deg]
rz.c.ax = rz.k.ax/1000; rz.c.ax = 10*(1/5)*sqrt(rz.k.ax/rz.m);
rz.c.rad = rz.k.rad/1000; rz.c.rad = 10*(1/5)*sqrt(rz.k.rad/rz.m);
rz.c.tilt = rz.k.tilt/1000; rz.c.tilt = 100*(1/1)*sqrt(rz.k.tilt/rz.m);
rz.c.rot = rz.k.rot/1000; rz.c.rot = 100*(1/1)*sqrt(rz.k.rot/rz.m);
%% Save if no output argument %% Save if no output argument
if nargout == 0 if nargout == 0
save('./mat/rz.mat', 'rz'); save('./mat/rz.mat', 'rz');
end end
end end

View File

@ -0,0 +1,35 @@
function [] = initializeSimConf(opts_param)
%% Default values for opts
opts = struct('Ts', 1e-4, ... % Sampling time [s]
'Tsim', 10, ... % Simulation time [s]
'cl_time', 0, ... % Close Loop time [s]
'gravity', false ... % Gravity along the z axis [m/s^2]
);
%% Populate opts with input parameters
if exist('opts_param','var')
for opt = fieldnames(opts_param)'
opts.(opt{1}) = opts_param.(opt{1});
end
end
%%
sim_conf = struct();
%%
sim_conf.Ts = opts.Ts;
sim_conf.Tsim = opts.Tsim;
sim_conf.cl_time = opts.cl_time;
%% Gravity
if opts.gravity
sim_conf.g = -9.8;
else
sim_conf.g = 0;
end
%% Save
save('./mat/sim_conf.mat', 'sim_conf');
end

View File

@ -18,8 +18,8 @@ function [ty] = initializeTy()
ty.k.ax = 1e7/4; % Axial Stiffness for each of the 4 guidance (y) [N/m] ty.k.ax = 1e7/4; % Axial Stiffness for each of the 4 guidance (y) [N/m]
ty.k.rad = 9e9/4; % Radial Stiffness for each of the 4 guidance (x-z) [N/m] ty.k.rad = 9e9/4; % Radial Stiffness for each of the 4 guidance (x-z) [N/m]
ty.c.ax = ty.k.ax/1000; ty.c.ax = 100*(1/5)*sqrt(ty.k.ax/ty.m);
ty.c.rad = ty.k.rad/1000; ty.c.rad = 100*(1/5)*sqrt(ty.k.rad/ty.m);
%% Save if no output argument %% Save if no output argument
if nargout == 0 if nargout == 0

BIN
mat/sim_conf.mat Normal file

Binary file not shown.

View File

@ -25,8 +25,8 @@ function [G, G_raw] = identifyG(opts_param)
% Run the linearization % Run the linearization
G_raw = linearize(mdl,io, 0); G_raw = linearize(mdl,io, 0);
G.InputName = {'Fnx', 'Fny', 'Fnz', 'Mnx', 'Mny', 'Mnz'}; G_raw.InputName = {'Fnx', 'Fny', 'Fnz', 'Mnx', 'Mny', 'Mnz'};
G.OutputName = {'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz'}; G_raw.OutputName = {'Dx', 'Dy', 'Dz', 'Rx', 'Ry', 'Rz'};
G = preprocessIdTf(G_raw, opts.f_low, opts.f_high); G = preprocessIdTf(G_raw, opts.f_low, opts.f_high);
G.InputName = {'Fnx', 'Fny', 'Fnz', 'Mnx', 'Mny', 'Mnz'}; G.InputName = {'Fnx', 'Fny', 'Fnz', 'Mnx', 'Mny', 'Mnz'};