From ed4ac36c01e997bdbf22098c9e95be7adf051510 Mon Sep 17 00:00:00 2001 From: Thomas Dehaeze Date: Wed, 5 Feb 2020 13:36:41 +0100 Subject: [PATCH] Generation of disturbances is now reproducible --- active_damping/index.org | 6 +++- .../src/prepareLinearizeIdentification.m | 30 +++++++++++++++++++ .../src/prepareTomographyExperiment.m | 8 +++-- simscape_subsystems/index.org | 6 ++++ src/initializeDisturbances.m | 6 ++++ 5 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 active_damping/src/prepareLinearizeIdentification.m diff --git a/active_damping/index.org b/active_damping/index.org index e8a32bc..d05595b 100644 --- a/active_damping/index.org +++ b/active_damping/index.org @@ -3675,11 +3675,15 @@ The nano-hexapod is a piezoelectric hexapod and the sample has a mass of 50kg. initializeSample('mass', args.sample_mass); #+end_src -We set the references to zero. +We set the references that corresponds to a tomography experiment. #+begin_src matlab initializeReferences('Rz_type', 'rotating', 'Rz_period', args.Rz_period); #+end_src +#+begin_src matlab + initializeDisturbances(); +#+end_src + And all the controllers are set to 0. #+begin_src matlab K = tf(zeros(6)); diff --git a/active_damping/src/prepareLinearizeIdentification.m b/active_damping/src/prepareLinearizeIdentification.m new file mode 100644 index 0000000..9b3e555 --- /dev/null +++ b/active_damping/src/prepareLinearizeIdentification.m @@ -0,0 +1,30 @@ +function [] = prepareLinearizeIdentification(args) + +arguments + args.nass_actuator char {mustBeMember(args.nass_actuator,{'piezo', 'lorentz'})} = 'piezo' + args.sample_mass (1,1) double {mustBeNumeric, mustBePositive} = 50 % [kg] +end + +initializeGround(); +initializeGranite(); +initializeTy(); +initializeRy(); +initializeRz(); +initializeMicroHexapod(); +initializeAxisc(); +initializeMirror(); + +initializeNanoHexapod('actuator', args.nass_actuator); +initializeSample('mass', args.sample_mass); + +initializeReferences(); +initializeDisturbances('enable', false); + +K = tf(zeros(6)); +save('./mat/controllers.mat', 'K', '-append'); +K_ine = tf(zeros(6)); +save('./mat/controllers.mat', 'K_ine', '-append'); +K_iff = tf(zeros(6)); +save('./mat/controllers.mat', 'K_iff', '-append'); +K_dvf = tf(zeros(6)); +save('./mat/controllers.mat', 'K_dvf', '-append'); diff --git a/active_damping/src/prepareTomographyExperiment.m b/active_damping/src/prepareTomographyExperiment.m index 6fd73d1..7a65466 100644 --- a/active_damping/src/prepareTomographyExperiment.m +++ b/active_damping/src/prepareTomographyExperiment.m @@ -2,8 +2,8 @@ function [] = prepareTomographyExperiment(args) arguments args.nass_actuator char {mustBeMember(args.nass_actuator,{'piezo', 'lorentz'})} = 'piezo' - args.sample_mass (1,1) double {mustBeNumeric, mustBePositive} = 50 - args.Ry_period (1,1) double {mustBeNumeric, mustBePositive} = 1 + args.sample_mass (1,1) double {mustBeNumeric, mustBePositive} = 50 % [kg] + args.Rz_period (1,1) double {mustBeNumeric, mustBePositive} = 1 % [s] end initializeGround(); @@ -18,7 +18,9 @@ initializeMirror(); initializeNanoHexapod('actuator', args.nass_actuator); initializeSample('mass', args.sample_mass); -initializeReferences('Rz_type', 'rotating', 'Rz_period', args.Ry_period); +initializeReferences('Rz_type', 'rotating', 'Rz_period', args.Rz_period); + +initializeDisturbances(); K = tf(zeros(6)); save('./mat/controllers.mat', 'K', '-append'); diff --git a/simscape_subsystems/index.org b/simscape_subsystems/index.org index 6c32212..d98b951 100644 --- a/simscape_subsystems/index.org +++ b/simscape_subsystems/index.org @@ -1401,6 +1401,7 @@ We define some parameters that will be used in the algorithm. #+begin_src matlab 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)))];; @@ -1412,6 +1413,7 @@ We define some parameters that will be used in the algorithm. #+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)))];; @@ -1423,6 +1425,7 @@ We define some parameters that will be used in the algorithm. #+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)))];; @@ -1443,6 +1446,7 @@ We define some parameters that will be used in the algorithm. for i = 1:N/2 C(i) = sqrt(phi(i)*df); end + rng(121); 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)))];; @@ -1464,6 +1468,7 @@ We define some parameters that will be used in the algorithm. for i = 1:N/2 C(i) = sqrt(phi(i)*df); end + rng(122); 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)))];; @@ -1485,6 +1490,7 @@ We define some parameters that will be used in the algorithm. 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)))];; diff --git a/src/initializeDisturbances.m b/src/initializeDisturbances.m index c6bc777..9f5b6c1 100644 --- a/src/initializeDisturbances.m +++ b/src/initializeDisturbances.m @@ -45,6 +45,7 @@ for i = 1:N/2 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)))];; @@ -54,6 +55,7 @@ else 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)))];; @@ -63,6 +65,7 @@ else 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)))];; @@ -77,6 +80,7 @@ if args.Fty_x && args.enable for i = 1:N/2 C(i) = sqrt(phi(i)*df); end + rng(121); 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)))];; @@ -92,6 +96,7 @@ if args.Fty_z && args.enable for i = 1:N/2 C(i) = sqrt(phi(i)*df); end + rng(122); 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)))];; @@ -107,6 +112,7 @@ if args.Frz_z && args.enable 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)))];;