mbsim 4.0.0 MBSim Kernel

lsodi_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 _LSODI_INTEGRATOR_H_
24 #define _LSODI_INTEGRATOR_H_
25
26 #include "root_finding_integrator.h"
27
28 namespace MBSim {
29
30 extern bool odePackInUse;
31
39 class LSODIIntegrator : public RootFindingIntegrator {
40
41 public:
42 enum Formalism {
43 ODE=0,
44 DAE2,
45 GGL,
46 unknown
47 };
48
49 private:
50 typedef void (*Res)(int* neq, double* t, double* z_, double* zd_, double* res_, int* ires);
51 static Res res[3];
52 static void resODE(int* neq, double* t, double* z_, double* zd_, double* res_, int* ires);
53 static void resDAE2(int* neq, double* t, double* y_, double* yd_, double* res_, int* ires);
54 static void resGGL(int* neq, double* t, double* y_, double* yd_, double* res_, int* ires);
55 static void adda(int *neq, double* t, double* y_, int* ml, int* mu, double* P, int* nrowp);
56
57 void calcSize();
58
60 double dtMax{0};
62 double dtMin{0};
64 fmatvec::Vec aTol;
66 fmatvec::Vec rTol;
68 double dt0{0};
70 int maxSteps{10000};
72 Formalism formalism{DAE2};
74 bool excludeAlgebraicVariables{true};
75
76 int N;
77
78 public:
79 void setMaximumStepSize(double dtMax_) { dtMax = dtMax_; }
80 void setMinimumStepSize(double dtMin_) { dtMin = dtMin_; }
81 void setAbsoluteTolerance(const fmatvec::Vec &aTol_) { aTol <<= aTol_; }
82 void setAbsoluteTolerance(double aTol_) { aTol.resize(1,fmatvec::INIT,aTol_); }
83 void setRelativeTolerance(const fmatvec::Vec &rTol_) { rTol <<= rTol_; }
84 void setRelativeTolerance(double rTol_) { rTol.resize(1,fmatvec::INIT,rTol_); }
85 void setInitialStepSize(double dt0_) { dt0 = dt0_; }
86 void setStepLimit(int maxSteps_) { maxSteps = maxSteps_; }
87 void setFormalism(Formalism formalism_) { formalism = formalism_; }
88 void setExcludeAlgebraicVariablesFromErrorTest(bool excludeAlgebraicVariables_) { excludeAlgebraicVariables = excludeAlgebraicVariables_; }
89
90 using Integrator::integrate;
91 void integrate();
92
93 virtual void initializeUsingXML(xercesc::DOMElement *element);
94 };
95
96 }
97
98 #endif
MBSim::LSODIIntegrator::initializeUsingXML
virtual void initializeUsingXML(xercesc::DOMElement *element)
initialize integrator
Definition: lsodi_integrator.cc:358
MBSim::LSODIIntegrator
Hindmarsh’s ODE solver LSODI.
Definition: lsodi_integrator.h:39
MBSim::LSODIIntegrator::dtMax
double dtMax
Definition: lsodi_integrator.h:60
MBSim::LSODIIntegrator::integrate
void integrate()
start the integration of the system set by setSystem. Each class implemeting this function should cal...
Definition: lsodi_integrator.cc:96
MBSim::LSODIIntegrator::maxSteps
int maxSteps
Definition: lsodi_integrator.h:70
MBSim::RootFindingIntegrator
Integrator with root-finding.
Definition: root_finding_integrator.h:32
MBSim::LSODIIntegrator::dt0
double dt0
Definition: lsodi_integrator.h:68
MBSim::Integrator::integrate
virtual void integrate()=0
start the integration of the system set by setSystem. Each class implemeting this function should cal...
MBSim::LSODIIntegrator::excludeAlgebraicVariables
bool excludeAlgebraicVariables
Definition: lsodi_integrator.h:74
MBSim::LSODIIntegrator::aTol
fmatvec::Vec aTol
Definition: lsodi_integrator.h:64
MBSim::LSODIIntegrator::formalism
Formalism formalism
Definition: lsodi_integrator.h:72
MBSim::LSODIIntegrator::dtMin
double dtMin
Definition: lsodi_integrator.h:62
MBSim::LSODIIntegrator::rTol
fmatvec::Vec rTol
Definition: lsodi_integrator.h:66
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30