mbsim 4.0.0 MBSim Kernel

daspk_integrator.h
1 /* Copyright (C) 2004-2018 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 _DASPK_INTEGRATOR_H_
24 #define _DASPK_INTEGRATOR_H_
25
26 #include "root_finding_integrator.h"
27
28 namespace MBSim {
29
34 class DASPKIntegrator : public RootFindingIntegrator {
35
36 public:
37 enum Formalism {
38 ODE=0,
39 DAE1,
40 DAE2,
41 GGL,
42 unknown
43 };
44
45 private:
46 typedef void (*Delta)(double* t, double* y_, double* yd_, double* cj, double* delta_, int *ires, double* rpar, int* ipar);
47 static Delta delta[4];
48 static void deltaODE(double* t, double* y_, double* yd_, double* cj, double* delta_, int *ires, double* rpar, int* ipar);
49 static void deltaDAE1(double* t, double* y_, double* yd_, double* cj, double* delta_, int *ires, double* rpar, int* ipar);
50 static void deltaDAE2(double* t, double* y_, double* yd_, double* cj, double* delta_, int *ires, double* rpar, int* ipar);
51 static void deltaGGL(double* t, double* y_, double* yd_, double* cj, double* delta_, int *ires, double* rpar, int* ipar);
52
53 void calcSize();
54
56 double dtMax{0};
58 fmatvec::Vec aTol;
60 fmatvec::Vec rTol;
62 double dt0{0};
64 Formalism formalism{DAE2};
66 bool excludeAlgebraicVariables{true};
67
68 int neq;
69
70 public:
71 void setMaximumStepSize(double dtMax_) { dtMax = dtMax_; }
72 void setAbsoluteTolerance(const fmatvec::Vec &aTol_) { aTol <<= aTol_; }
73 void setAbsoluteTolerance(double aTol_) { aTol.resize(1,fmatvec::INIT,aTol_); }
74 void setRelativeTolerance(const fmatvec::Vec &rTol_) { rTol <<= rTol_; }
75 void setRelativeTolerance(double rTol_) { rTol.resize(1,fmatvec::INIT,rTol_); }
76 void setInitialStepSize(double dt0_) { dt0 = dt0_; }
77 void setFormalism(Formalism formalism_) { formalism = formalism_; }
78 void setExcludeAlgebraicVariablesFromErrorTest(bool excludeAlgebraicVariables_) { excludeAlgebraicVariables = excludeAlgebraicVariables_; }
79
80 using Integrator::integrate;
81 void integrate();
82
83 virtual void initializeUsingXML(xercesc::DOMElement *element);
84 };
85
86 }
87
88 #endif
MBSim::DASPKIntegrator::dt0
double dt0
Definition: daspk_integrator.h:62
MBSim::DASPKIntegrator::aTol
fmatvec::Vec aTol
Definition: daspk_integrator.h:58
MBSim::RootFindingIntegrator
Integrator with root-finding.
Definition: root_finding_integrator.h:32
MBSim::Integrator::integrate
virtual void integrate()=0
start the integration of the system set by setSystem. Each class implemeting this function should cal...
MBSim::DASPKIntegrator
Petzold’s DAE solver DASPK.
Definition: daspk_integrator.h:34
MBSim::DASPKIntegrator::integrate
void integrate()
start the integration of the system set by setSystem. Each class implemeting this function should cal...
Definition: daspk_integrator.cc:102
MBSim::DASPKIntegrator::initializeUsingXML
virtual void initializeUsingXML(xercesc::DOMElement *element)
initialize integrator
Definition: daspk_integrator.cc:361
MBSim::DASPKIntegrator::dtMax
double dtMax
Definition: daspk_integrator.h:56
MBSim::DASPKIntegrator::rTol
fmatvec::Vec rTol
Definition: daspk_integrator.h:60
MBSim::DASPKIntegrator::excludeAlgebraicVariables
bool excludeAlgebraicVariables
Definition: daspk_integrator.h:66
MBSim::DASPKIntegrator::formalism
Formalism formalism
Definition: daspk_integrator.h:64
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30