Skip to content
Snippets Groups Projects
Commit c00bc367 authored by Arthur Reis's avatar Arthur Reis
Browse files

v 0.2.2 changed constructor of TestMass and AcmeSim

parent f0b44dc1
Branches
No related tags found
No related merge requests found
Showing
with 189 additions and 40 deletions
......@@ -8,6 +8,9 @@
resources
Acme.prj
# XHPS stuff
simulations/Tutorial/xhps_integration
# OSX / *nix default autosave extension
*.m~
......
......@@ -3,56 +3,68 @@ classdef AcmeSim
% Detailed explanation goes here
properties
mdl
stopTime = 1e4;
nSteps = 1e4;
freqs
tStep
fSample
t
enbw
ModelName
ModelHandle
StopTime
NumberOfSteps
Frequencies
StepSize
SampleFrequency
Time
ENBW
eps0 = 8.86e-12; %F/m, vacuum permittivity
kb = 1.3806e-23; %boltzmann
T = 300; % K
lpsdopts
flpsdOpts
% lpsd
end
methods
function obj = AcmeSim(mdl,varargin)
function obj = AcmeSim(varargin)
%ACMESIM Construct an instance of this class
% Detailed explanation goes here
obj.mdl = mdl;
if length(varargin) == 2
obj.stopTime = varargin{1};
obj.nSteps = varargin{2};
end
obj.tStep = obj.stopTime/obj.nSteps;
obj.fSample = 1/obj.tStep;
obj.freqs = logspace(-log10(obj.stopTime),log10(obj.fSample/2),100);
obj.enbw = 1/obj.stopTime;
obj.t = (0:obj.tStep:(obj.stopTime-obj.tStep))';
obj.lpsdopts = {'fs',obj.fSample,...
'Kdes', 100,...
'olap', 30,...
'Jdes', 1000,...
flpsdopts = {'fs', 1,...
'Lmin' , 1,...
'order', 0,...
'olap' , 30,...
'Kdes' , 100,...
'Jdes' , 1000,...
'scale', 'ASD',...
'LTPDAmode',false,...
'win' , 'hanning',...
'LTPDAmode',false,...
};
end
function initModel(obj)
load_system(obj.mdl);
p = inputParser;
p.addRequired('ModelName', @(x) ischar(x));
p.addRequired('StopTime', @(x) isscalar(x));
p.addRequired('NumberOfSteps',@(x) isscalar(x));
p.addOptional('flpsdOpts', flpsdopts);
p.parse(varargin{:});
obj.ModelName = p.Results.ModelName;
obj.StopTime = p.Results.StopTime;
obj.NumberOfSteps = p.Results.NumberOfSteps;
obj.flpsdOpts = p.Results.flpsdOpts;
obj.ENBW = 1/obj.StopTime;
obj.StepSize = obj.StopTime/obj.NumberOfSteps;
obj.Time = (0:obj.StepSize:(obj.StopTime-obj.StepSize))';
obj.SampleFrequency = 1/obj.StepSize;
obj.Frequencies = logspace(-log10(obj.StopTime),log10(obj.SampleFrequency/2),100);
obj.flpsdOpts{2} = {obj.SampleFrequency};
% Load simulink model
obj.ModelHandle = load_system(obj.ModelName);
end
function TM = addTestMass(obj,mass,sideLength,gap,geometricFactor,block,varargin)
TM = TestMass(mass,sideLength,gap,geometricFactor);
TM = TM.setDoubleIntegrator(obj.mdl,block,varargin);
function obj = initModel(obj)
obj.ModelHandle = load_system(obj.ModelName);
end
function initModelParameters(obj)
get_param(obj.ModelHandle,'ObjectParameters');
set_param(obj.ModelHandle,'StopTime',num2str(obj.StopTime));
set_param(obj.ModelHandle,'MaxStep', num2str(obj.StepSize));
% set_param(obj.ModelHandle)
end
end
end
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
classdef TestMass
%TESTMASS Summary of this class goes here
% Detailed explanation goes here
properties
mass (1,1) double
gaps (1,3) double
areas (1,3) double
sides (1,3) double
volume (1,1) double
density (1,1) double
gap = struct('x', 0, 'y', 0, 'z', 0);
l = struct('x', 0, 'y', 0, 'z', 0);
area = struct('x', 0, 'y', 0, 'z', 0);
% geometricFactor (1,1) double ...
% {mustBePositive,mustBeLessThanOrEqual(geometricFactor,1)} = 1;
attachedDoubleIntegratorBlock char
% attachedDoubleIntegratorBlocks
attachedModel char
end
methods
function obj = TestMass(varargin)
% TESTMASS Construct an instance of this class
% Either mass or density must be defined
% Syntax
% TM = TestMass(sideLength, gap, ...
% 'mass'/'density', mass/density,...
% [geometricFactor]
% Inputs:
% sideLength - m, side of the cube, 1x1 double OR
% - m, sides of the cuboid, m, 1x3 double
% gap - m, size of the gaps (equal sizes), 1x1 double OR
% - m, sizes of gaps, 1x3 double
% mass - kg, mass of the test mass
% density - kg/m3, density of the material
% [geometricFactor] - ?
p = inputParser;
p.addRequired('SideLength');
p.addRequired('Gap');
p.addParameter('Mass', 0, @(x) isscalar(x));
p.addParameter('Density', 0, @(x) isscalar(x));
p.addParameter('Model', '', @(x) ischar(x));
p.addParameter('Block', '', @(x) ischar(x));
p.addParameter('Blocks', [''], @(x) (x));
%p.addParameter('geometricFactor', 1);
p.parse(varargin{:});
gap = p.Results.Gap;
mass = p.Results.Mass;
density = p.Results.Density;
sideLength = p.Results.SideLength;
block = p.Results.Block;
% blocks = p.Results.Blocks;
model = p.Results.Model;
%geometricFactor = p.Results.geometricFactor;
if ~xor(mass,density)
error('either mass or density has to be defined')
end
% obj.geometricFactor = geometricFactor;
obj = initGeometry(obj,sideLength,gap);
if mass == 0
obj.mass = obj.volume*density;
obj.density = density;
elseif density == 0
obj.density = mass/obj.volume;
obj.mass = mass;
end
if ~((model=="")||(block==""))
obj = attachBlock(obj,model,block);
obj = updateBlock(obj);
end
end
function obj = initGeometry(obj, sideLength,gap)
if length(sideLength) == 3
obj.l.x = sideLength(1);
obj.l.y = sideLength(2);
obj.l.z = sideLength(3);
else
obj.l.x = sideLength;
obj.l.y = sideLength;
obj.l.z = sideLength;
end
if length(gap) == 3
obj.gap.x = gap(1);
obj.gap.y = gap(2);
obj.gap.z = gap(3);
else
obj.gap.x = gap;
obj.gap.y = gap;
obj.gap.z = gap;
end
obj.area.x = obj.l.y * obj.l.z;
obj.area.y = obj.l.x * obj.l.z;
obj.area.z = obj.l.x * obj.l.y;
obj.volume = obj.l.x * obj.l.y * obj.l.z;
obj.gaps = [obj.gap.x obj.gap.y obj.gap.z ];
obj.sides = [obj.l.x obj.l.y obj.l.z ];
obj.areas = [obj.area.x obj.area.y obj.area.z];
end
function obj = attachBlock(obj, model, block)
obj.attachedModel = model;
obj.attachedDoubleIntegratorBlock = block;
end
function updateBlock(obj)
setDblIntTrans(obj.attachedModel, ...
obj.attachedDoubleIntegratorBlock, ...
obj.mass,obj.gap.x); % warning: 1DOF
end
function obj = setDoubleIntegrator(obj,mdl,name,varargin)
%METHOD1 Summary of this method goes here
% Detailed explanation goes here
obj.doubleIntegratorBlock = setDblIntTrans(mdl,name,obj.mass,obj.gap.x);
end
end
end
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -6,13 +6,16 @@
% email: arthur.reis@aei.mpg.de
% last review: 29.11.2022
clear;
acme = AcmeSim('sgrs_acc');
acme.initModel;
acme = AcmeSim('sgrs_acc',1000,1000);
%% Accelerometer Parameters
TM = acme.addTestMass(0.54,30e-3,1e-3,1,'dblInt',0.07);
TM = TestMass(30e-3,1e-3,'mass',0.54);
TM = TM.attachBlock('sgrs_acc','dblInt');
TM.mass = .60;
TM.updateBlock;
TM.mass = 0.54;
TM.updateBlock;
% If is non-drag-free:
% driverGain = -20;
% V_TM = 0.5;
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment