]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGPropulsion.h
Updated to latest JSBSim, including preliminary support for
[flightgear.git] / src / FDM / JSBSim / FGPropulsion.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGPropulsion.h
4  Author:       Jon S. Berndt
5  Date started: 08/20/00
6  
7  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
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 HISTORY
27 --------------------------------------------------------------------------------
28 08/20/00   JSB   Created
29  
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGPROPULSION_H
35 #define FGPROPULSION_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #ifdef FGFS
42 #  include <simgear/compiler.h>
43 #  ifdef SG_HAVE_STD_INCLUDES
44 #    include <vector>
45 #    include <iterator>
46 #  else
47 #    include <vector.h>
48 #    include <iterator.h>
49 #  endif
50 #else
51 #  include <vector>
52 #  include <iterator>
53 #endif
54
55 #include "FGModel.h"
56
57 #include "FGRocket.h"
58 #include "FGPiston.h"
59 #include "FGTurboShaft.h"
60 #include "FGTurboJet.h"
61 #include "FGTurboProp.h"
62 #include "FGTank.h"
63 #include "FGPropeller.h"
64 #include "FGNozzle.h"
65
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 DEFINITIONS
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69
70 #define ID_PROPULSION "$Id$"
71
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 FORWARD DECLARATIONS
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75
76 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
79
80 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 CLASS DOCUMENTATION
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
83
84 /** Propulsion management class.
85     FGPropulsion manages all aspects of propulsive force generation, including
86     containment of engines, tanks, and thruster class instances in STL vectors,
87     and the interaction and communication between them.
88     @author Jon S. Berndt
89     @version $Id$
90     @see FGEngine
91     @see FGTank
92     @see FGThruster
93 */
94
95 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96 CLASS DECLARATION
97 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
98
99 class FGPropulsion : public FGModel {
100 public:
101   FGPropulsion(FGFDMExec*);
102   ~FGPropulsion();
103
104   /** Executes the propulsion model.
105       The initial plan for the FGPropulsion class calls for Run() to be executed,
106       performing the following tasks:
107       <ol>
108   <li>Determine the drag - or power required - for the attached thrust effector
109       for this engine so that any feedback to the engine can be performed. This
110       is done by calling FGThruster::CalculatePReq()</li>
111   <li>Given 1, above, calculate the power available from the engine. This is
112       done by calling FGEngine::CalculatePAvail()</li>
113   <li>Next, calculate the thrust output from the thruster model given the power
114       available and the power required. This may also result in new performance
115       numbers for the thruster in the case of the propeller, at least. This
116       result is returned from a call to Calculate().</li></ol>
117
118       [Note: Should we be checking the Starved flag here?] */
119   bool Run(void);
120
121   /** Loads the propulsion system (engine[s], tank[s], thruster[s]).
122       Characteristics of the propulsion system are read in from the config file.
123       @param AC_cfg pointer to the config file instance that describes the
124              aircraft being modeled.
125       @return true if successfully loaded, otherwise false */
126   bool Load(FGConfigFile* AC_cfg);
127
128   /// Retrieves the number of engines defined for the aircraft.
129   inline unsigned int GetNumEngines(void) {return Engines.size();}
130
131   /** Retrieves an engine object pointer from the list of engines.
132       @param index the engine index within the vector container
133       @return the address of the specific engine, or zero if no such engine is
134               available */
135   inline FGEngine* GetEngine(unsigned int index) {
136                       if (index <= Engines.size()-1) return Engines[index];
137                       else                           return 0L;      }
138
139   /** Retrieves a tank object pointer from the list of tanks.
140       @param index the tank index within the vector container
141       @return the address of the specific tank, or zero if no such tank is
142               available */
143   inline FGTank* GetTank(unsigned int index) {
144                       if (index <= Tanks.size()-1) return Tanks[index];
145                       else                         return 0L;        }
146
147   /** Retrieves a thruster object pointer from the list of thrusters.
148       @param index the thruster index within the vector container
149       @return the address of the specific thruster, or zero if no such thruster is
150               available */
151   inline FGThruster* GetThruster(unsigned int index) {
152                       if (index <= Thrusters.size()-1) return Thrusters[index];
153                       else                             return 0L;    }
154
155   /** Returns the number of fuel tanks currently actively supplying fuel */
156   inline int GetnumSelectedFuelTanks(void) {return numSelectedFuelTanks;}
157
158   /** Returns the number of oxidizer tanks currently actively supplying oxidizer */
159   inline int GetnumSelectedOxiTanks(void)  {return numSelectedOxiTanks;}
160
161   /** Loops the engines/thrusters until thrust output steady (used for trimming) */
162   bool GetSteadyState(void);
163   
164   /** starts the engines in IC mode (dt=0).  All engine-specific setup must
165       be done before calling this (i.e. magnetos, starter engage, etc.) */
166   bool ICEngineStart(void);
167   
168   string GetPropulsionStrings(void);
169   string GetPropulsionValues(void);
170
171   inline FGColumnVector3& GetForces(void)  {return vForces; }
172   inline double GetForces(int n) { return vForces(n);}
173   inline FGColumnVector3& GetMoments(void) {return vMoments;}
174   inline double GetMoments(int n) {return vMoments(n);}
175   
176   FGColumnVector3& GetTanksCG(void);
177   double GetTanksWeight(void);
178
179   double GetTanksIxx(const FGColumnVector3& vXYZcg);
180   double GetTanksIyy(const FGColumnVector3& vXYZcg);
181   double GetTanksIzz(const FGColumnVector3& vXYZcg);
182   double GetTanksIxz(const FGColumnVector3& vXYZcg);
183   double GetTanksIxy(const FGColumnVector3& vXYZcg);
184
185 private:
186   vector <FGEngine*>   Engines;
187   vector <FGTank*>     Tanks;
188   vector <FGTank*>::iterator iTank;
189   vector <FGThruster*> Thrusters;
190   unsigned int numSelectedFuelTanks;
191   unsigned int numSelectedOxiTanks;
192   unsigned int numFuelTanks;
193   unsigned int numOxiTanks;
194   unsigned int numEngines;
195   unsigned int numTanks;
196   unsigned int numThrusters;
197   double dt;
198   FGColumnVector3 vForces;
199   FGColumnVector3 vMoments;
200   FGColumnVector3 vXYZtank;
201   void Debug(int from);
202 };
203
204 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
205 #endif
206