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 "dae_integrator.h"
27
28namespace MBSim {
29
30 extern bool odePackInUse;
31
40
41 private:
42 double delta(int i, double z) const override;
43 typedef void (*Res)(int* neq, double* t, double* y_, double* yd_, double* res_, int* ires);
44 typedef void (*Jac)(int *neq, double* t, double* y_, double *yd_, int* ml, int* mu, double* J_, int* nrowp);
45 static Res res[5];
46 static Jac jac[5];
47 static void resODE(int* neq, double* t, double* z_, double* zd_, double* res_, int* ires);
48 static void resDAE2(int* neq, double* t, double* y_, double* yd_, double* res_, int* ires);
49 static void resGGL(int* neq, double* t, double* y_, double* yd_, double* res_, int* ires);
50 static void adda(int *neq, double* t, double* y_, int* ml, int* mu, double* P, int* nrowp);
51 static void jacODE(int *neq, double* t, double* y_, double *yd_, int* ml, int* mu, double* J_, int* nrowp);
52 static void jacDAE2(int *neq, double* t, double* y_, double *yd_, int* ml, int* mu, double* J_, int* nrowp);
53 static void jacGGL(int *neq, double* t, double* y_, double *yd_, int* ml, int* mu, double* J_, int* nrowp);
54
55 void init() override;
56 void reinit() override;
57
59 double dtMax{0};
61 double dtMin{0};
63 double dt0{0};
65 int maxSteps{std::numeric_limits<int>::max()};
68
69 fmatvec::VecInt neq_;
70 fmatvec::Vec rWork;
71 int lewt;
72
73 std::exception_ptr exception;
74
75 public:
76 void setMaximumStepSize(double dtMax_) { dtMax = dtMax_; }
77 void setMinimumStepSize(double dtMin_) { dtMin = dtMin_; }
78 void setInitialStepSize(double dt0_) { dt0 = dt0_; }
79 void setStepLimit(int maxSteps_) { maxSteps = maxSteps_; }
80 void setExcludeAlgebraicVariablesFromErrorTest(bool excludeAlgebraicVariables_) { excludeAlgebraicVariables = excludeAlgebraicVariables_; }
81
83 void integrate();
84
85 virtual void initializeUsingXML(xercesc::DOMElement *element);
86 };
87
88}
89
90#endif
Base class for all DAE integrators.
Definition: dae_integrator.h:33
virtual void integrate()=0
start the integration of the system set by setSystem. Each class implemeting this function should cal...
Hindmarsh’s ODE solver LSODI.
Definition: lsodi_integrator.h:39
double dtMin
Definition: lsodi_integrator.h:61
double dtMax
Definition: lsodi_integrator.h:59
void integrate()
start the integration of the system set by setSystem. Each class implemeting this function should cal...
Definition: lsodi_integrator.cc:257
double dt0
Definition: lsodi_integrator.h:63
bool excludeAlgebraicVariables
Definition: lsodi_integrator.h:67
int maxSteps
Definition: lsodi_integrator.h:65
virtual void initializeUsingXML(xercesc::DOMElement *element)
initialize integrator
Definition: lsodi_integrator.cc:505
namespace MBSim
Definition: bilateral_constraint.cc:30