mbsimcontrol  4.0.0
MBSim Control Module
linear_system_analyzer.h
1 /* Copyright (C) 2004-2021 MBSim Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact: martin.o.foerg@gmail.com
18  */
19 
20 #ifndef _LINEAR_SYSTEM_ANALYZER_H_
21 #define _LINEAR_SYSTEM_ANALYZER_H_
22 
23 #include "mbsim/solver.h"
24 #include "mbsim/functions/function.h"
25 #include "mbsim/utils/index.h"
26 #include <mbsim/utils/boost_parameters.h>
27 
28 namespace MBSim {
29 
30  BOOST_PARAMETER_NAME(modeRange)
31  BOOST_PARAMETER_NAME(frequencyRange)
32  BOOST_PARAMETER_NAME(inputNumber)
33 
34 }
35 
36 namespace MBSimControl {
37 
43  public:
44  LinearSystemAnalyzer() : mRange("[0;9]"), fRange("[0;1e4]") { }
45  ~LinearSystemAnalyzer() override;
46  void execute() override;
47  void setInitialTime(double t0_) { t0 = t0_; }
48  void setInitialState(const fmatvec::Vec &z0_) { z0 <<= z0_; }
49  void setInitialInput(const fmatvec::Vec &u0_) { u0 <<= u0_; }
50  void setMinimumNaturalFrequency(double fmin_) { fmin = fmin_; }
51  void setMaximumNaturalFrequency(double fmax_) { fmax = fmax_; }
52  void setNaturalModeScale(const fmatvec::VecV &modeScale_) { modeScale <<= modeScale_; }
53  void setExcitationFrequencies(const fmatvec::VecV &fex_) { fex <<= fex_; }
54  void setExcitationAmplitudeFunction(MBSim::Function<fmatvec::VecV(double)> *Amp_) { Amp = Amp_; }
55  void setPlotStepSize(double dtPlot_) { dtPlot = dtPlot_; }
56  void setLoops(double loops_) { loops = loops_; }
57  const fmatvec::Vec& getInitialState() const override { return z0; }
58  void initializeUsingXML(xercesc::DOMElement *element) override;
59 
60  BOOST_PARAMETER_MEMBER_FUNCTION( (void), visualizeNaturalModeShapes, MBSim::tag, (optional (modeRange,(fmatvec::Vec2),"[0;9]"))) {
61  msv = true;
62  mRange = modeRange;
63  }
64 
65  BOOST_PARAMETER_MEMBER_FUNCTION( (void), visualizeFrequencyResponse, MBSim::tag, (optional (frequencyRange,(fmatvec::Vec2),"[0;1e4]")(inputNumber,(double),0))) {
66  frv = true;
67  fRange = frequencyRange;
68  inum = inputNumber;
69  }
70 
71  protected:
72  double t0{0};
73  double fmin{1e-2};
74  double fmax{1e4};
75  fmatvec::VecV modeScale;
76  MBSim::Function<fmatvec::VecV(double)> *Amp{nullptr};
77  fmatvec::Vec z0, zEq, u0, fex;
78  bool msv{false};
79  bool frv{false};
80  fmatvec::Vec2 mRange, fRange;
81  MBSim::Index inum{0};
82  int loops{5};
83  double dtPlot{1e-2};
84  };
85 
86 }
87 
88 #endif
Linear system analyzer.
Definition: linear_system_analyzer.h:42