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(modeNumbers)
31 BOOST_PARAMETER_NAME(frequencyRange)
32
33 }
34
35 namespace MBSimControl {
36
41 class LinearSystemAnalyzer : public MBSim::Solver {
42 public:
43 LinearSystemAnalyzer() : fRange("[0;1e4]") { }
44 ~LinearSystemAnalyzer() override;
45 void execute() override;
46 void setInitialTime(double t0_) { t0 = t0_; }
47 void setInitialState(const fmatvec::Vec &z0_) { z0 <<= z0_; }
48 void setInitialInput(const fmatvec::Vec &u0_) { u0 <<= u0_; }
49 void setMinimumNaturalFrequency(double fmin_) { fmin = fmin_; }
50 void setMaximumNaturalFrequency(double fmax_) { fmax = fmax_; }
51 void setNormalModeScaleFactor(double modeScaleFactor_) { modeScaleFactor = modeScaleFactor_; }
52 void setNormalModeScale(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 setExcitationPhaseFunction(MBSim::Function<fmatvec::VecV(double)> *Phi_) { Phi = Phi_; }
56 void setPlotStepSize(double dtPlot_) { dtPlot = dtPlot_; }
57 void setLoops(double loops_) { loops = loops_; }
58 const fmatvec::Vec& getInitialState() const override { return z0; }
59 void initializeUsingXML(xercesc::DOMElement *element) override;
60
61 BOOST_PARAMETER_MEMBER_FUNCTION( (void), visualizeNormalModes, MBSim::tag, (optional (modeNumbers,(fmatvec::VecVI),fmatvec::VecVI()))) {
62 msv = true;
63 modes = modeNumbers;
64 }
65
66 BOOST_PARAMETER_MEMBER_FUNCTION( (void), visualizeFrequencyResponse, MBSim::tag, (optional (frequencyRange,(fmatvec::Vec2),"[0;1e4]"))) {
67 frv = true;
68 fRange = frequencyRange;
69 }
70
71 protected:
72 double t0{0};
73 double fmin{1e-2};
74 double fmax{1e5};
75 double modeScaleFactor{1};
76 fmatvec::VecV modeScale;
77 MBSim::Function<fmatvec::VecV(double)> *Amp{nullptr};
78 MBSim::Function<fmatvec::VecV(double)> *Phi{nullptr};
79 fmatvec::VecV amp, phi;
80 fmatvec::Vec z0, zEq, u0, fex;
81 bool msv{false};
82 bool frv{false};
83 bool srv{false};
84 bool its{true};
85 double tSpan{1};
86 fmatvec::VecVI modes;
87 fmatvec::Vec2 fRange;
88 std::vector<fmatvec::MatVx3> fap;
89 int loops{5};
90 double dtPlot{1e-2};
91 };
92
93 }
94
95 #endif
MBSim::Solver
MBSimControl::LinearSystemAnalyzer
Linear system analyzer.
Definition: linear_system_analyzer.h:41
MBSim::Function