mbsim  4.0.0
MBSim Kernel
radau5_integrator.h
1 /* Copyright (C) 2004-2006 Martin Förg
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  *
18  * Contact:
19  * martin.o.foerg@googlemail.com
20  *
21  */
22 
23 #ifndef _RADAU5_INTEGRATOR_H_
24 #define _RADAU5_INTEGRATOR_H_
25 
26 #include "root_finding_integrator.h"
27 
28 namespace MBSim {
29 
33 
34  public:
35  enum Formalism {
36  ODE=0,
37  DAE1,
38  DAE2,
39  DAE3,
40  GGL,
41  unknown
42  };
43 
44  private:
45  typedef void (*Fzdot)(int* n, double* t, double* y, double* yd, double* rpar, int* ipar);
46  typedef void (*Mass)(int* n, double* m, int* lmas, double* rpar, int* ipar);
47  static Fzdot fzdot[5];
48  static Mass mass[2];
49  static void fzdotODE(int* n, double* t, double* z, double* zd, double* rpar, int* ipar);
50  static void fzdotDAE1(int* n, double* t, double* y, double* yd, double* rpar, int* ipar);
51  static void fzdotDAE2(int* n, double* t, double* y, double* yd, double* rpar, int* ipar);
52  static void fzdotDAE3(int* n, double* t, double* y, double* yd, double* rpar, int* ipar);
53  static void fzdotGGL(int* n, double* t, double* y, double* yd, double* rpar, int* ipar);
54  static void massFull(int* n, double* m, int* lmas, double* rpar, int* ipar);
55  static void massReduced(int* n, double* m, int* lmas, double* rpar, int* ipar);
56  static void plot(int* nr, double* told, double* t, double* y, double* cont, int* lrc, int* n, double* rpar, int* ipar, int* irtrn);
57 
58  void calcSize();
59  void reinit();
60 
61  double tPlot{0};
62  double dtOut{0};
63  double s0;
64  double time{0};
65 
71  double dt0{0};
73  int maxSteps{0};
75  double dtMax{0};
77  Formalism formalism{ODE};
79  bool reduced{false};
80 
81  int neq, mlJac, muJac;
82  fmatvec::VecInt iWork;
83  fmatvec::Vec work;
84 
85  public:
86  ~RADAU5Integrator() override = default;
87 
88  void setAbsoluteTolerance(const fmatvec::Vec &aTol_) { aTol <<= aTol_; }
89  void setAbsoluteTolerance(double aTol_) { aTol.resize(1,fmatvec::INIT,aTol_); }
90  void setRelativeTolerance(const fmatvec::Vec &rTol_) { rTol <<= rTol_; }
91  void setRelativeTolerance(double rTol_) { rTol.resize(1,fmatvec::INIT,rTol_); }
92  void setInitialStepSize(double dt0_) { dt0 = dt0_; }
93  void setMaximumStepSize(double dtMax_) { dtMax = dtMax_; }
94  void setStepLimit(int maxSteps_) { maxSteps = maxSteps_; }
95  void setFormalism(Formalism formalism_) { formalism = formalism_; }
96  void setReducedForm(bool reduced_) { reduced = reduced_; }
97 
99  void integrate() override;
100 
101  void initializeUsingXML(xercesc::DOMElement *element) override;
102  };
103 
104 }
105 
106 #endif
fmatvec::Vec aTol
Definition: radau5_integrator.h:67
void integrate() override
start the integration of the system set by setSystem. Each class implemeting this function should cal...
Definition: radau5_integrator.cc:247
bool reduced
Definition: radau5_integrator.h:79
Formalism formalism
Definition: radau5_integrator.h:77
Integrator with root-finding.
Definition: root_finding_integrator.h:32
virtual void integrate()=0
start the integration of the system set by setSystem. Each class implemeting this function should cal...
double dtMax
Definition: radau5_integrator.h:75
DAE-Integrator RADAU5.
Definition: radau5_integrator.h:32
double dt0
Definition: radau5_integrator.h:71
void initializeUsingXML(xercesc::DOMElement *element) override
initialize integrator
Definition: radau5_integrator.cc:407
int maxSteps
Definition: radau5_integrator.h:73
fmatvec::Vec rTol
Definition: radau5_integrator.h:69
namespace MBSim
Definition: eigenanalyzer.cc:47