FlightGear
next
FGRungeKutta.h
Go to the documentation of this file.
1
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3
Header: FGRungeKutta.h
4
Author: Thomas Kreitler
5
Date started: 04/9/2010
6
7
------------- Copyright (C) -------------
8
9
This program is free software; you can redistribute it and/or modify it under
10
the terms of the GNU Lesser General Public License as published by the Free Software
11
Foundation; either version 2 of the License, or (at your option) any later
12
version.
13
14
This program is distributed in the hope that it will be useful, but WITHOUT
15
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17
details.
18
19
You should have received a copy of the GNU Lesser General Public License along with
20
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21
Place - Suite 330, Boston, MA 02111-1307, USA.
22
23
Further information about the GNU Lesser General Public License can also be found on
24
the world wide web at http://www.gnu.org.
25
26
HISTORY
27
--------------------------------------------------------------------------------
28
29
30
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31
SENTRY
32
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34
#ifndef FGRUNGEKUTTA_H
35
#define FGRUNGEKUTTA_H
36
37
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38
INCLUDES
39
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41
namespace
JSBSim
{
42
43
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44
CLASS DOCUMENTATION
45
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46
47
57
58
59
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60
DECLARATION: FGRungeKuttaProblem
61
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
66
class
FGRungeKuttaProblem
{
67
public
:
68
virtual
double
pFunc
(
double
x,
double
y) = 0;
69
};
70
71
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72
DECLARATION: FGRungeKutta
73
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
77
78
class
FGRungeKutta
{
79
80
public
:
81
82
enum
eStates
{
eNoError
=0,
eMathError
=1,
eFaultyInit
=2,
eEvolve
=4,
eUnknown
=8} ;
83
84
int
init
(
double
x_start,
double
x_end,
int
intervals = 4);
85
86
double
evolve
(
double
y_0,
FGRungeKuttaProblem
*pf);
87
88
double
getXEnd
() {
return
x_end; }
89
double
getError
() {
return
err
; }
90
91
int
getStatus
() {
return
status; }
92
int
getIterations
() {
return
iterations; }
93
void
clearStatus
() { status =
eNoError
; }
94
void
setTrace
(
bool
t) { trace_values = t; }
95
96
protected
:
97
// avoid accidents
98
FGRungeKutta
(): status(
eNoError
), trace_values(false), iterations(0) {};
99
virtual
~FGRungeKutta
();
100
101
FGRungeKuttaProblem
*
pfo
;
102
103
double
h
;
104
double
h05
;
// h*0.5, halfwidth
105
double
err
;
106
107
private
:
108
109
virtual
double
approximate(
double
x,
double
y) = 0;
110
111
bool
sane_val(
double
x);
112
113
static
const
double
RealLimit;
114
115
double
x0, x1;
116
double
safer_x1;
117
double
x_end;
118
119
int
status;
120
bool
trace_values;
121
int
iterations;
122
123
};
124
125
126
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127
DECLARATION: FGRK4
128
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
132
133
class
FGRK4
:
public
FGRungeKutta
{
134
virtual
~FGRK4
();
135
private
:
136
double
approximate(
double
x,
double
y);
137
};
138
139
140
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
141
DECLARATION: FGRKFehlberg
142
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
143
154
155
156
class
FGRKFehlberg
:
public
FGRungeKutta
{
157
158
public
:
159
FGRKFehlberg
() : shrink_avail(4), epsilon(1e-12) { };
160
virtual
~FGRKFehlberg
();
161
double
getEpsilon
() {
return
epsilon; }
162
int
getShrinkAvail
() {
return
shrink_avail; }
163
void
setEpsilon
(
double
e) { epsilon = e; }
164
void
setShrinkAvail
(
int
s) { shrink_avail = s; }
165
166
private
:
167
168
double
approximate(
double
x,
double
y);
169
170
int
shrink_avail;
171
double
epsilon;
172
173
static
const
double
A2[], A3[], A4[], A5[], A6[];
174
static
const
double
B
[], Bs[],
C
[];
175
176
};
177
178
179
}
// namespace JSBSim
180
181
#endif
JSBSim::FGRK4
Classical RK4.
Definition
FGRungeKutta.h:133
JSBSim::FGRKFehlberg::FGRKFehlberg
FGRKFehlberg()
Definition
FGRungeKutta.h:159
JSBSim::FGRKFehlberg::setShrinkAvail
void setShrinkAvail(int s)
Definition
FGRungeKutta.h:164
JSBSim::FGRKFehlberg::setEpsilon
void setEpsilon(double e)
Definition
FGRungeKutta.h:163
JSBSim::FGRKFehlberg::getEpsilon
double getEpsilon()
Definition
FGRungeKutta.h:161
JSBSim::FGRKFehlberg::~FGRKFehlberg
virtual ~FGRKFehlberg()
Definition
FGRungeKutta.cpp:163
JSBSim::FGRKFehlberg::getShrinkAvail
int getShrinkAvail()
Definition
FGRungeKutta.h:162
JSBSim::FGRungeKuttaProblem
Minimalistic implementation of some Runge-Kutta methods.
Definition
FGRungeKutta.h:66
JSBSim::FGRungeKuttaProblem::pFunc
virtual double pFunc(double x, double y)=0
JSBSim::FGRungeKutta::eStates
eStates
Definition
FGRungeKutta.h:82
JSBSim::FGRungeKutta::eMathError
@ eMathError
Definition
FGRungeKutta.h:82
JSBSim::FGRungeKutta::eUnknown
@ eUnknown
Definition
FGRungeKutta.h:82
JSBSim::FGRungeKutta::eEvolve
@ eEvolve
Definition
FGRungeKutta.h:82
JSBSim::FGRungeKutta::eNoError
@ eNoError
Definition
FGRungeKutta.h:82
JSBSim::FGRungeKutta::eFaultyInit
@ eFaultyInit
Definition
FGRungeKutta.h:82
JSBSim::FGRungeKutta::h05
double h05
Definition
FGRungeKutta.h:104
JSBSim::FGRungeKutta::getStatus
int getStatus()
Definition
FGRungeKutta.h:91
JSBSim::FGRungeKutta::setTrace
void setTrace(bool t)
Definition
FGRungeKutta.h:94
JSBSim::FGRungeKutta::getIterations
int getIterations()
Definition
FGRungeKutta.h:92
JSBSim::FGRungeKutta::pfo
FGRungeKuttaProblem * pfo
Definition
FGRungeKutta.h:101
JSBSim::FGRungeKutta::h
double h
Definition
FGRungeKutta.h:103
JSBSim::FGRungeKutta::FGRungeKutta
FGRungeKutta()
Definition
FGRungeKutta.h:98
JSBSim::FGRungeKutta::~FGRungeKutta
virtual ~FGRungeKutta()
Definition
FGRungeKutta.cpp:54
JSBSim::FGRungeKutta::clearStatus
void clearStatus()
Definition
FGRungeKutta.h:93
JSBSim::FGRungeKutta::getError
double getError()
Definition
FGRungeKutta.h:89
JSBSim::FGRungeKutta::evolve
double evolve(double y_0, FGRungeKuttaProblem *pf)
Definition
FGRungeKutta.cpp:89
JSBSim::FGRungeKutta::init
int init(double x_start, double x_end, int intervals=4)
Definition
FGRungeKutta.cpp:56
JSBSim::FGRungeKutta::err
double err
Definition
FGRungeKutta.h:105
JSBSim::FGRungeKutta::getXEnd
double getXEnd()
Definition
FGRungeKutta.h:88
B
#define B
C
#define C
Definition
metar_main.cxx:60
JSBSim
Definition
FGFDMExec.cpp:67
src
FDM
JSBSim
math
FGRungeKutta.h
Generated on Tue Jun 3 2025 12:58:38 for FlightGear by
1.13.2