mbsimhydraulics  3.2.0
elastic_line_variational.h
00001 /* Copyright (C) 2004-2009 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: markus.ms.schneider@gmail.com
00018  */
00019 
00020 #ifndef  _ELASTIC_LINE_VARIATIONAL_H_
00021 #define  _ELASTIC_LINE_VARIATIONAL_H_
00022 
00023 #include "hline.h"
00024 
00025 namespace MBSimHydraulics {
00026 
00033   class ElasticLineVariational : public HLine {
00034 
00035     public:
00036 
00037       enum WindowFunction {
00038         None,
00039         Hann,
00040         Hamming,
00041         Riemann,
00042         BlackmanHarris
00043       };
00044       
00046       ElasticLineVariational(const std::string &name="");
00047       virtual std::string getType() const { return "ElasticLineVariational"; }
00048 
00050       void setp0(double p0_) {p0=p0_; }
00052       void setFracAir(double fracAir_) {fracAir=fracAir_; }
00054       void setDiameter(double d_) {r=d_/2.; }
00056       void setLength(double l_) {l=l_; }
00058       void setRelativePlotPoints(const fmatvec::Vec &rPP) {relPlotPoints=rPP; }
00060       void setWindowFunction(WindowFunction w) {window_function_type=w; }
00062       void setNumberOfAnsatzFunctions(unsigned int n_=4) {n=2*n_+1; }
00064       void printLineStateSpace(bool print=true) {printStateSpace=print; }
00065 
00066       fmatvec::Vec getQIn() {return QIn; }
00067       fmatvec::Vec getQOut() {return QOut; }
00068       fmatvec::Vec getInflowFactor() {return wI; }
00069       fmatvec::Vec getOutflowFactor() {return wO; }
00070 
00071       void init(MBSim::InitStage stage);
00072       void calcqSize() {qSize=n-1; }
00073       void calcuSize(int j) {uSize[j]=n; }
00074 
00075       void updateStateDependentVariables(double t);
00076       void updateh(double t, int j=0);
00077       void updateT(double t) {T=Tlocal; }
00078       void updateM(double t, int j=0) {M[j]=Mlocal; }
00079 
00080       void plot(double t, double dt);
00081       void plotParameters();
00082 
00083       void initializeUsingXML(MBXMLUtils::TiXmlElement * element);
00084 
00085     protected:
00086       double p0, fracAir, r, l;
00087       fmatvec::Vec relPlotPoints;
00088       WindowFunction window_function_type;
00089       int n;
00090       bool printStateSpace;
00091 
00092     private:
00093       fmatvec::Vec QIn, QOut, wO, wI;
00094       fmatvec::Vec hq, hu, hp0, cu, y;
00095       fmatvec::Mat Tlocal, relPlot;
00096       fmatvec::SymMat Mlocal;
00097       
00098       void doPrintStateSpace();
00099   };
00100 
00101 }
00102 
00103 
00104 #endif
00105