mbsim  4.0.0
MBSim Kernel
radau5_integrator.h
1/* Copyright (C) 2004-2006 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 _RADAU5_INTEGRATOR_H_
24#define _RADAU5_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
68 double dt0{0};
70 int maxSteps{std::numeric_limits<int>::max()};
72 double dtMax{0};
73
74 int mlJac, muJac;
75 std::vector<int> iWorkExtended; int *iWork;
76 fmatvec::Vec work;
77
78 int maxNewtonIter { 0 };
79 double newtonIterTol { 0 };
80 double jacobianRecomputation { 0 };
81 bool jacobianRecomputationAtRejectedSteps { true };
82 bool drift { false };
83 StepSizeControl stepSizeControl { StepSizeControl::ModPred };
84 double stepSizeSaftyFactor { 0.9 };
85
86 std::exception_ptr exception;
87
88 public:
89 ~RADAU5Integrator() override = default;
90
91 void setInitialStepSize(double dt0_) { dt0 = dt0_; }
92 void setMaximumStepSize(double dtMax_) { dtMax = dtMax_; }
93 void setStepLimit(int maxSteps_) { maxSteps = maxSteps_; }
94 void setMaximalNumberOfNewtonIterations(int iter) { maxNewtonIter = iter; }
95 void setNewtonIterationTolerance(double tol) { newtonIterTol = tol; }
96 void setJacobianRecomputation(double value) { jacobianRecomputation = value; }
97 void setJacobianRecomputationAtRejectedSteps(bool recomp) { jacobianRecomputationAtRejectedSteps = recomp; }
98 void setStepSizeControl(StepSizeControl ssc) { stepSizeControl = ssc; }
99 void setStepSizeSaftyFactor(double fac) { stepSizeSaftyFactor = fac; }
100
102 void integrate() override;
103
104 void initializeUsingXML(xercesc::DOMElement *element) override;
105 };
106
107}
108
109#endif
Definition: homotopysolver.cc:19
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 RADAU5.
Definition: radau5_integrator.h:32
double dtMax
Definition: radau5_integrator.h:72
double dt0
Definition: radau5_integrator.h:68
void initializeUsingXML(xercesc::DOMElement *element) override
initialize integrator
Definition: radau5_integrator.cc:776
void integrate() override
start the integration of the system set by setSystem. Each class implemeting this function should cal...
Definition: radau5_integrator.cc:546
int maxSteps
Definition: radau5_integrator.h:70
namespace MBSim
Definition: bilateral_constraint.cc:30