mbsim  4.0.0
MBSim Kernel
lsoda_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 _LSODA_INTEGRATOR_H_
24#define _LSODA_INTEGRATOR_H_
25
26#include "implicit_integrator.h"
27
28namespace MBSim {
29
39
40 private:
41 double delta(int i, double z) const override;
42 static void fzdot(int* neq, double* t, double* z_, double* zd_);
43 static void jac(int *neq, double* t, double* z_, int* ml, int* mu, double* J_, int* nrowp);
44
45 void init() override;
46
48 double dtMax{0};
50 double dtMin{0};
52 fmatvec::Vec aTol;
54 fmatvec::Vec rTol;
56 double dt0{0};
58 int maxSteps{std::numeric_limits<int>::max()};
59
60 fmatvec::Vec rWork;
61 int lewt;
62 double r0;
63
64 std::exception_ptr exception;
65
66 public:
67
68 void setMaximumStepSize(double dtMax_) { dtMax = dtMax_; }
69 void setMinimumStepSize(double dtMin_) { dtMin = dtMin_; }
70 void setAbsoluteTolerance(const fmatvec::Vec &aTol_) { aTol <<= aTol_; }
71 void setAbsoluteTolerance(double aTol_) { aTol.resize(1,fmatvec::INIT,aTol_); }
72 void setRelativeTolerance(const fmatvec::Vec &rTol_) { rTol <<= rTol_; }
73 void setRelativeTolerance(double rTol_) { rTol.resize(1,fmatvec::INIT,rTol_); }
74 void setInitialStepSize(double dt0_) { dt0 = dt0_; }
75 void setStepLimit(int maxSteps_) { maxSteps = maxSteps_; }
76
78 void integrate();
79
80 virtual void initializeUsingXML(xercesc::DOMElement *element);
81 };
82
83}
84
85#endif
Base class for all implicit integrators.
Definition: implicit_integrator.h:34
virtual void integrate()=0
start the integration of the system set by setSystem. Each class implemeting this function should cal...
Hindmarsh’s ODE solver LSODA.
Definition: lsoda_integrator.h:38
void integrate()
start the integration of the system set by setSystem. Each class implemeting this function should cal...
Definition: lsoda_integrator.cc:93
int maxSteps
Definition: lsoda_integrator.h:58
fmatvec::Vec rTol
Definition: lsoda_integrator.h:54
double dtMax
Definition: lsoda_integrator.h:48
double dtMin
Definition: lsoda_integrator.h:50
fmatvec::Vec aTol
Definition: lsoda_integrator.h:52
double dt0
Definition: lsoda_integrator.h:56
virtual void initializeUsingXML(xercesc::DOMElement *element)
initialize integrator
Definition: lsoda_integrator.cc:303
namespace MBSim
Definition: bilateral_constraint.cc:30