]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGTrimLong.h
Fixes to jsbsim.
[flightgear.git] / src / FDM / JSBSim / FGTrimLong.h
1 /*******************************************************************************
2  
3  Header:       FGTrimLong.h
4  Author:       Tony Peden
5  Date started: 7/1/99
6  
7  ------------- Copyright (C) 1999  Anthony K. Peden (apeden@earthlink.net) -------------
8  
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU 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 General Public License for more
17  details.
18  
19  You should have received a copy of the GNU 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 General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25  
26  
27  HISTORY
28 --------------------------------------------------------------------------------
29 9/8/99   TP   Created
30  
31  
32 FUNCTIONAL DESCRIPTION
33 --------------------------------------------------------------------------------
34  
35 This class takes the given set of IC's and finds the angle of attack, elevator,
36 and throttle setting required to fly steady level. This is currently for in-air
37 conditions only.  It is implemented using an iterative, one-axis-at-a-time 
38 scheme.  
39  
40  
41  
42 ********************************************************************************
43 SENTRY
44 *******************************************************************************/
45
46 #ifndef FGTRIMLONG_H
47 #define FGTRIMLONG_H
48
49 /*******************************************************************************
50 INCLUDES
51 *******************************************************************************/
52
53 #include "FGFDMExec.h"
54 #include "FGRotation.h"
55 #include "FGAtmosphere.h"
56 #include "FGState.h"
57 #include "FGFCS.h"
58 #include "FGAircraft.h"
59 #include "FGTranslation.h"
60 #include "FGPosition.h"
61 #include "FGAuxiliary.h"
62 #include "FGOutput.h"
63 #include "FGTrimLong.h"
64
65 #define ELEV_MIN -1
66 #define ELEV_MAX 1
67
68 #define THROTTLE_MIN 0
69 #define THROTTLE_MAX 1
70
71 /*******************************************************************************
72 CLASS DECLARATION
73 *******************************************************************************/
74
75
76 class FGTrimLong {
77 private:
78   typedef float (FGTrimLong::*trimfp)(float);
79   int Ncycles,Naxis,Debug;
80   float Tolerance, A_Tolerance;
81   float alphaMin, alphaMax;
82   float wdot,udot,qdot;
83   float dth;
84   float udot_subits, wdot_subits, qdot_subits;
85   int total_its;
86   bool trimudot;
87   int axis_count;
88
89   trimfp udotf,wdotf,qdotf;
90   FGFDMExec* fdmex;
91   FGInitialCondition* fgic;
92
93   void setThrottlesPct(float tt);
94   int checkLimits(trimfp fp,float current,float min, float max);
95   // returns false if no sign change in fp(min)*fp(max) => no solution
96   bool solve(trimfp fp,float guess,float desired,float *result,float eps,float min, float max,int max_iterations,int *actual_its );
97   bool findInterval(trimfp fp, float *lo, float *hi,float guess,float desired,int max_iterations);
98
99   float udot_func(float x);
100   float wdot_func(float x);
101   float qdot_func(float x);
102
103 public:
104   FGTrimLong(FGFDMExec *FDMExec, FGInitialCondition *FGIC);
105   ~FGTrimLong(void);
106
107   bool DoTrim(void);
108
109   void Report(void);
110   void ReportState(void);
111   void TrimStats();
112
113   inline void SetUdotTrim(bool bb) { trimudot=bb; }
114
115   inline bool GetUdotTrim(void) { return trimudot; }
116
117   inline void SetMaxCycles(int ii) { Ncycles = ii; }
118   inline void SetMaxCyclesPerAxis(int ii) { Naxis = ii; }
119   inline void SetTolerance(float tt) {
120     Tolerance = tt;
121     A_Tolerance = tt / 10;
122   }
123   //Debug level 1 shows results of each top-level iteration
124   //Debug level 2 shows level 1 & results of each per-axis iteration
125   inline void SetDebug(int level) { Debug = level; }
126   inline void ClearDebug(void) { Debug = 0; }
127
128 };
129
130
131 #endif
132
133
134
135
136
137
138
139
140