]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGPropulsion.h
Latest round of JSBSim updates.
[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 FG_HAVE_STD_INCLUDES
44 #    include <vector>
45 #  else
46 #    include <vector.h>
47 #  endif
48 #else
49 #  include <vector>
50 #endif
51
52 #include "FGModel.h"
53
54 #include "FGRocket.h"
55 #include "FGPiston.h"
56 #include "FGTurboShaft.h"
57 #include "FGTurboJet.h"
58 #include "FGTurboProp.h"
59 #include "FGTank.h"
60 #include "FGPropeller.h"
61 #include "FGNozzle.h"
62
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 DEFINITIONS
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66
67 #define ID_PROPULSION "$Id$"
68
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 FORWARD DECLARATIONS
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72
73 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
76
77 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 CLASS DOCUMENTATION
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
80
81 /** Propulsion management class.
82     FGPropulsion manages all aspects of propulsive force generation, including
83     containment of engines, tanks, and thruster class instances in STL vectors,
84     and the interaction and communication between them.
85     @author Jon S. Berndt
86     @version $Id$
87     @see FGEngine
88     @see FGTank
89     @see FGThruster
90 */
91
92 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 CLASS DECLARATION
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
95
96 class FGPropulsion : public FGModel {
97 public:
98   FGPropulsion(FGFDMExec*);
99   ~FGPropulsion();
100
101   /** Executes the propulsion model.
102       The initial plan for the FGPropulsion class calls for Run() to be executed,
103       performing the following tasks:
104       <ol>
105   <li>Determine the drag - or power required - for the attached thrust effector
106       for this engine so that any feedback to the engine can be performed. This
107       is done by calling FGThruster::CalculatePReq()</li>
108   <li>Given 1, above, calculate the power available from the engine. This is
109       done by calling FGEngine::CalculatePAvail()</li>
110   <li>Next, calculate the thrust output from the thruster model given the power
111       available and the power required. This may also result in new performance
112       numbers for the thruster in the case of the propeller, at least. This
113       result is returned from a call to Calculate().</li></ol>
114
115       [Note: Should we be checking the Starved flag here?] */
116   bool Run(void);
117
118   /** Loads the propulsion system (engine[s], tank[s], thruster[s]).
119       Characteristics of the propulsion system are read in from the config file.
120       @param AC_cfg pointer to the config file instance that describes the
121              aircraft being modeled.
122       @return true if successfully loaded, otherwise false */
123   bool LoadPropulsion(FGConfigFile* AC_cfg);
124
125   /// Retrieves the number of engines defined for the aircraft.
126   inline unsigned int GetNumEngines(void) {return Engines.size();}
127
128   /** Retrieves an engine object pointer from the list of engines.
129       @param index the engine index within the vector container
130       @return the address of the specific engine, or zero if no such engine is
131               available */
132   inline FGEngine* GetEngine(unsigned int index) {
133                       if (index <= Engines.size()-1) return Engines[index];
134                       else                           return 0L;      }
135
136   /** Retrieves a tank object pointer from the list of tanks.
137       @param index the tank index within the vector container
138       @return the address of the specific tank, or zero if no such tank is
139               available */
140   inline FGTank* GetTank(unsigned int index) {
141                       if (index <= Tanks.size()-1) return Tanks[index];
142                       else                         return 0L;        }
143
144   /** Retrieves a thruster object pointer from the list of thrusters.
145       @param index the thruster index within the vector container
146       @return the address of the specific thruster, or zero if no such thruster is
147               available */
148   inline FGThruster* GetThruster(unsigned int index) {
149                       if (index <= Thrusters.size()-1) return Thrusters[index];
150                       else                             return 0L;    }
151
152   /** Returns the number of fuel tanks currently actively supplying fuel */
153   inline int GetnumSelectedFuelTanks(void) {return numSelectedFuelTanks;}
154
155   /** Returns the number of oxidizer tanks currently actively supplying oxidizer */
156   inline int GetnumSelectedOxiTanks(void)  {return numSelectedOxiTanks;}
157
158   bool GetSteadyState(void);
159
160
161   inline FGColumnVector& GetForces(void)  {return *Forces; }
162   inline FGColumnVector& GetMoments(void) {return *Moments;}
163
164 private:
165   vector <FGEngine*>   Engines;
166   vector <FGTank*>     Tanks;
167   vector <FGThruster*> Thrusters;
168   unsigned int numSelectedFuelTanks;
169   unsigned int numSelectedOxiTanks;
170   unsigned int numFuelTanks;
171   unsigned int numOxiTanks;
172   unsigned int numEngines;
173   unsigned int numTanks;
174   unsigned int numThrusters;
175   float dt;
176   FGColumnVector *Forces;
177   FGColumnVector *Moments;
178   void Debug(void);
179 };
180
181 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
182 #endif
183