mbsim  4.0.0
MBSim Kernel
radau_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 _RADAU_INTEGRATOR_H_
24#define _RADAU_INTEGRATOR_H_
25
26#include "dae_integrator.h"
27
28namespace MBSim {
29
33
34 public:
35 enum class StepSizeControl {
36 ModPred = 1,
37 Classic = 2,
38 };
39
40 private:
41 double delta(int i, double z) const override;
42 typedef void (*Fzdot)(int* n, double* t, double* y, double* yd, double* rpar, int* ipar);
43 typedef void (*Jac)(int* n, double *t, double *y, double *J, int *nn, double *rpar, int *ipar);
44 typedef void (*Mass)(int* n, double* m, int* lmas, double* rpar, int* ipar);
45 static Fzdot fzdot[5];
46 static Jac jac[5];
47 static Mass mass[2];
48 static void fzdotODE(int* n, double* t, double* z, double* zd, double* rpar, int* ipar);
49 static void fzdotDAE1(int* n, double* t, double* y, double* yd, double* rpar, int* ipar);
50 static void fzdotDAE2(int* n, double* t, double* y, double* yd, double* rpar, int* ipar);
51 static void fzdotDAE3(int* n, double* t, double* y, double* yd, double* rpar, int* ipar);
52 static void jacODE(int* n, double *t, double *z, double *J, int *nn, double *rpar, int *ipar);
53 static void jacDAE1(int* n, double *t, double *y, double *J, int *nn, double *rpar, int *ipar);
54 static void jacDAE2(int* n, double *t, double *y, double *J, int *nn, double *rpar, int *ipar);
55 static void jacDAE3(int* n, double *t, double *y, double *J, int *nn, double *rpar, int *ipar);
56 static void jacGGL(int* n, double *t, double *y, double *J, int *nn, double *rpar, int *ipar);
57 static void fzdotGGL(int* n, double* t, double* y, double* yd, double* rpar, int* ipar);
58 static void massFull(int* n, double* m, int* lmas, double* rpar, int* ipar);
59 static void massReduced(int* n, double* m, int* lmas, double* rpar, int* ipar);
60 static void plot(int* nr, double* told, double* t, double* y, double* cont, int* lrc, int* n, double* rpar, int* ipar, int* irtrn);
61
62 void reinit() override;
63
64 double tPlot{0};
65 double dtOut{0};
66 double s0;
67 double time{0};
68
70 double dt0{0};
72 int maxSteps{std::numeric_limits<int>::max()};
74 double dtMax{0};
75
76 int mlJac, muJac;
77 std::vector<int> iWorkExtended; int *iWork;
78 fmatvec::Vec work;
79
80 int maxNewtonIter { 0 };
81 double newtonIterTol { 0 };
82 double jacobianRecomputation { 0 };
83 bool jacobianRecomputationAtRejectedSteps { true };
84 bool drift { false };
85 StepSizeControl stepSizeControl { StepSizeControl::ModPred };
86 double stepSizeSaftyFactor { 0.9 };
87
88 std::exception_ptr exception;
89
90 public:
91 ~RADAUIntegrator() override = default;
92
93 void setInitialStepSize(double dt0_) { dt0 = dt0_; }
94 void setMaximumStepSize(double dtMax_) { dtMax = dtMax_; }
95 void setStepLimit(int maxSteps_) { maxSteps = maxSteps_; }
96 void setMaximalNumberOfNewtonIterations(int iter) { maxNewtonIter = iter; }
97 void setNewtonIterationTolerance(double tol) { newtonIterTol = tol; }
98 void setJacobianRecomputation(double value) { jacobianRecomputation = value; }
99 void setJacobianRecomputationAtRejectedSteps(bool recomp) { jacobianRecomputationAtRejectedSteps = recomp; }
100 void setStepSizeControl(StepSizeControl ssc) { stepSizeControl = ssc; }
101 void setStepSizeSaftyFactor(double fac) { stepSizeSaftyFactor = fac; }
102
104 void integrate() override;
105
106 void initializeUsingXML(xercesc::DOMElement *element) override;
107 };
108
109}
110
111#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...
DAE-Integrator RADAU.
Definition: radau_integrator.h:32
void integrate() override
start the integration of the system set by setSystem. Each class implemeting this function should cal...
Definition: radau_integrator.cc:540
void initializeUsingXML(xercesc::DOMElement *element) override
initialize integrator
Definition: radau_integrator.cc:737
double dtMax
Definition: radau_integrator.h:74
double dt0
Definition: radau_integrator.h:70
int maxSteps
Definition: radau_integrator.h:72
namespace MBSim
Definition: bilateral_constraint.cc:30