MBSim

Project Page
eigenanalysis.h
00001 /* Copyright (C) 2004-2014 MBSim Development Team
00002  *
00003  * This library is free software; you can redistribute it and/or 
00004  * modify it under the terms of the GNU Lesser General Public 
00005  * License as published by the Free Software Foundation; either 
00006  * version 2.1 of the License, or (at your option) any later version. 
00007  *  
00008  * This library is distributed in the hope that it will be useful, 
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00011  * Lesser General Public License for more details. 
00012  *  
00013  * You should have received a copy of the GNU Lesser General Public 
00014  * License along with this library; if not, write to the Free Software 
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
00016  *
00017  * Contact: martin.o.foerg@googlemail.com
00018  */
00019 
00020 #ifndef _EIGENANALYSIS_H_
00021 #define _EIGENANALYSIS_H_
00022 
00023 #include "fmatvec/fmatvec.h"
00024 #include "fmatvec/function.h"
00025 
00026 namespace MBSim {
00027 
00028   class DynamicSystemSolver;
00029 
00034   class Eigenanalysis {
00035 
00036     class Residuum : public fmatvec::Function<fmatvec::Vec(fmatvec::Vec)> {
00037       public:
00038         Residuum(DynamicSystemSolver *sys_, double t_);
00039         fmatvec::Vec operator()(const fmatvec::Vec &z);
00040       private:
00041         DynamicSystemSolver *sys;
00042         double t;
00043     };
00044 
00045     public:
00049       Eigenanalysis() : tStart(0), tEnd(1), dtPlot(1e-2), A(1), compEq(false), autoUpdate(false) {}
00050       
00054       ~Eigenanalysis() {}
00055 
00060       void analyse(DynamicSystemSolver& system);
00061 
00066       void setInitialDeviation(const fmatvec::Vec &deltaz0_) { deltaz0 = deltaz0_; }
00067 
00072       void setAmplitude(double A_) { A = A_; }
00073 
00078       void setStartTime(double tStart_) { tStart=tStart_; }
00079 
00084       void setEndTime(double tEnd_) { tEnd = tEnd_; }
00085 
00090       void setPlotStepSize(double dtPlot_) { dtPlot = dtPlot_; }
00091 
00096       void setInitialState(const fmatvec::Vec &z0) { zEq = z0; }
00097 //      void setEquilibriumState(const fmatvec::Vec &zEq_) { zEq = zEq_; }
00098 
00103       void setDetermineEquilibriumState(bool eq) { compEq = eq; }
00104 
00109       void setAutoUpdateAnalysis(bool update) { autoUpdate = update; }
00110 
00115       const fmatvec::Vector<fmatvec::Ref, std::complex<double> >& getEigenvalues() const { return w; }
00116 
00121       const fmatvec::SquareMatrix<fmatvec::Ref, std::complex<double> >& getEigenvectors() const { return V; }
00122 
00127       const fmatvec::Vec& getEigenfrequencies() const { return freq; }
00128 
00133       void setOutputFileName(const std::string &fileName_) { fileName = fileName_; }
00134 
00139       void eigenmode(int i, DynamicSystemSolver& system);
00140 
00145       void eigenmodes(DynamicSystemSolver& system);
00146 
00151       void eigenmotion(DynamicSystemSolver& system);
00152 
00153     protected:
00154 
00155       static DynamicSystemSolver* system;
00156 
00157       fmatvec::Vec z0, deltaz0, zEq;
00158       double tStart, tEnd, dtPlot, A;
00159       bool compEq, autoUpdate;
00160 
00161       fmatvec::SquareMatrix<fmatvec::Ref, std::complex<double> > V;
00162       fmatvec::Vector<fmatvec::Ref, std::complex<double> > w;
00163       fmatvec::Vec freq;
00164       std::vector<std::pair<double,int> > f;
00165 
00166       std::string fileName;
00167 
00168       bool saveEigenanalyis(const std::string &fileName);
00169       bool loadEigenanalyis(const std::string &fileName);
00170       void computeEigenfrequencies();
00171  };
00172 
00173 }
00174 
00175 #endif