MBSim

Project Page
eigenanalyser.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 _EIGENANALYSER_H_
00021 #define _EIGENANALYSER_H_
00022 
00023 #include "fmatvec/fmatvec.h"
00024 #include "mbsim/functions/function.h"
00025 #include "mbsim/solver.h"
00026 
00027 namespace MBSimAnalyser {
00028 
00029   const MBXMLUtils::NamespaceURI MBSIMANALYSER("http://mbsim.berlios.de/MBSimAnalyser");
00030 
00035   class Eigenanalyser : public MBSim::Solver {
00036 
00037     class Residuum : public MBSim::Function<fmatvec::Vec(fmatvec::Vec)> {
00038       public:
00039         Residuum(MBSim::DynamicSystemSolver *sys_, double t_);
00040         fmatvec::Vec operator()(const fmatvec::Vec &z);
00041       private:
00042         MBSim::DynamicSystemSolver *sys;
00043         double t;
00044     };
00045 
00046     public:
00047 
00048       enum Task { eigenfrequencies, eigenmodes, eigenmode, eigenmotion };
00049 
00053       Eigenanalyser() : tStart(0), tEnd(1), dtPlot(1e-2), A(1), n(1), compEq(false), autoUpdate(false), task(eigenmode) {}
00054       
00058       ~Eigenanalyser() {}
00059 
00060       void execute(MBSim::DynamicSystemSolver& system) { analyse(system); }
00061 
00066       void analyse(MBSim::DynamicSystemSolver& system);
00067 
00072       void setInitialDeviation(const fmatvec::Vec &deltaz0_) { deltaz0 = deltaz0_; }
00073 
00078       void setAmplitude(double A_) { A = A_; }
00079 
00084       void setMode(int n_) { n = n_; }
00085 
00090       void setStartTime(double tStart_) { tStart=tStart_; }
00091 
00096       void setEndTime(double tEnd_) { tEnd = tEnd_; }
00097 
00102       void setPlotStepSize(double dtPlot_) { dtPlot = dtPlot_; }
00103 
00108       void setInitialState(const fmatvec::Vec &z0) { zEq = z0; }
00109 //      void setEquilibriumState(const fmatvec::Vec &zEq_) { zEq = zEq_; }
00110 
00115       void setDetermineEquilibriumState(bool eq) { compEq = eq; }
00116 
00121       void setAutoUpdate(bool update) { autoUpdate = update; }
00122 
00123       void setTask(Task task_) { task = task_; }
00124 
00125       const fmatvec::Vec& getInitialState() const { return z0; }
00126 
00131       const fmatvec::Vector<fmatvec::Ref, std::complex<double> >& getEigenvalues() const { return w; }
00132 
00137       const fmatvec::SquareMatrix<fmatvec::Ref, std::complex<double> >& getEigenvectors() const { return V; }
00138 
00143       const fmatvec::Vec& getEigenfrequencies() const { return freq; }
00144 
00149       void setOutputFileName(const std::string &fileName_) { fileName = fileName_; }
00150 
00151       void initializeUsingXML(xercesc::DOMElement *element);
00152 
00153     protected:
00154 
00155       fmatvec::Vec z0, deltaz0, zEq;
00156       double tStart, tEnd, dtPlot, A;
00157       int n;
00158       bool compEq, autoUpdate;
00159       Task task;
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       void computeEigenvalues();
00172       void computeEigenmodes();
00173       void computeEigenmode();
00174       void computeEigenmotion();
00175  };
00176 
00177 }
00178 
00179 #endif