1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
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
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
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.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
27 --------------------------------------------------------------------------------
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34 #ifndef FGPROPULSION_H
35 #define FGPROPULSION_H
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42 # include <simgear/compiler.h>
43 # ifdef FG_HAVE_STD_INCLUDES
56 #include "FGTurboShaft.h"
57 #include "FGTurboJet.h"
58 #include "FGTurboProp.h"
60 #include "FGPropeller.h"
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 #define ID_PROPULSION "$Id$"
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
73 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
77 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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.
92 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
96 class FGPropulsion : public FGModel {
98 FGPropulsion(FGFDMExec*);
101 /** Executes the propulsion model.
102 The initial plan for the FGPropulsion class calls for Run() to be executed,
103 performing the following tasks:
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>
115 [Note: Should we be checking the Starved flag here?] */
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);
125 /// Retrieves the number of engines defined for the aircraft.
126 inline unsigned int GetNumEngines(void) {return Engines.size();}
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
132 inline FGEngine* GetEngine(unsigned int index) {
133 if (index <= Engines.size()-1) return Engines[index];
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
140 inline FGTank* GetTank(unsigned int index) {
141 if (index <= Tanks.size()-1) return Tanks[index];
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
148 inline FGThruster* GetThruster(unsigned int index) {
149 if (index <= Thrusters.size()-1) return Thrusters[index];
152 /** Returns the number of fuel tanks currently actively supplying fuel */
153 inline int GetnumSelectedFuelTanks(void) {return numSelectedFuelTanks;}
155 /** Returns the number of oxidizer tanks currently actively supplying oxidizer */
156 inline int GetnumSelectedOxiTanks(void) {return numSelectedOxiTanks;}
158 bool GetSteadyState(void);
161 inline FGColumnVector& GetForces(void) {return *Forces; }
162 inline FGColumnVector& GetMoments(void) {return *Moments;}
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;
176 FGColumnVector *Forces;
177 FGColumnVector *Moments;
181 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%