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) {}
00050       
00054       ~Eigenanalysis() {}
00055 
00060       void analyse(DynamicSystemSolver& system);
00061 
00066       void setInitialGuess(const fmatvec::Vec &z0_) { z0 = z0_; }
00067 
00072       void setInitialDeviation(const fmatvec::Vec &deltaz0_) { deltaz0 = deltaz0_; }
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 setEquilibriumState(const fmatvec::Vec &zEq_) { zEq = zEq_; }
00097 
00102       const fmatvec::Vector<fmatvec::Ref, std::complex<double> >& getEigenvalues() const { return w; }
00103 
00108       const fmatvec::SquareMatrix<fmatvec::Ref, std::complex<double> >& getEigenvectors() const { return V; }
00109 
00114       void setOutputFileName(const std::string &fileName_) { fileName = fileName_; }
00115 
00116     protected:
00117 
00118       static DynamicSystemSolver* system;
00119 
00120       fmatvec::Vec z0, deltaz0, zEq;
00121       double tStart, tEnd, dtPlot;
00122 
00123       fmatvec::SquareMatrix<fmatvec::Ref, std::complex<double> > V;
00124       fmatvec::Vector<fmatvec::Ref, std::complex<double> > w;
00125 
00126       std::string fileName;
00127  };
00128 
00129 }
00130 
00131 #endif