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 SG_HAVE_STD_INCLUDES
48 # include <iterator.h>
59 #include "FGTurbine.h"
60 #include "FGSimTurbine.h"
62 #include "FGPropeller.h"
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69 #define ID_PROPULSION "$Id$"
71 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
77 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
81 /** Propulsion management class.
82 The Propulsion class is the container for the entire propulsion system, which is
83 comprised of engines, tanks, and "thrusters" (the device that transforms the
84 engine power into a force that acts on the aircraft, such as a nozzle or
85 propeller). Once the Propulsion class gets the config file, it reads in
86 information which is specific to a type of engine. Then:
88 -# The appropriate engine type instance is created
89 -# A thruster object is instantiated, and is linked to the engine
90 -# At least one tank object is created, and is linked to an engine.
92 At Run time each engines Calculate() method is called to return the excess power
93 generated during that iteration. The drag from the previous iteration is sub-
94 tracted to give the excess power available for thrust this pass. That quantity
95 is passed to the thrusters associated with a particular engine - perhaps with a
96 scaling mechanism (gearing?) to allow the engine to give its associated thrust-
97 ers specific distributed portions of the excess power.
106 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
110 class FGPropulsion : public FGModel
114 FGPropulsion(FGFDMExec*);
118 /** Executes the propulsion model.
119 The initial plan for the FGPropulsion class calls for Run() to be executed,
120 performing the following tasks:
122 <li>Determine the drag - or power required - for the attached thrust effector
123 for this engine so that any feedback to the engine can be performed. This
124 is done by calling FGThruster::CalculatePReq()</li>
125 <li>Given 1, above, calculate the power available from the engine. This is
126 done by calling FGEngine::CalculatePAvail()</li>
127 <li>Next, calculate the thrust output from the thruster model given the power
128 available and the power required. This may also result in new performance
129 numbers for the thruster in the case of the propeller, at least. This
130 result is returned from a call to Calculate().</li></ol>
132 [Note: Should we be checking the Starved flag here?] */
135 /** Loads the propulsion system (engine[s], tank[s], thruster[s]).
136 Characteristics of the propulsion system are read in from the config file.
137 @param AC_cfg pointer to the config file instance that describes the
138 aircraft being modeled.
139 @return true if successfully loaded, otherwise false */
140 bool Load(FGConfigFile* AC_cfg);
142 /// Retrieves the number of engines defined for the aircraft.
143 inline unsigned int GetNumEngines(void) const {return Engines.size();}
145 /** Retrieves an engine object pointer from the list of engines.
146 @param index the engine index within the vector container
147 @return the address of the specific engine, or zero if no such engine is
149 inline FGEngine* GetEngine(unsigned int index) {
150 if (index <= Engines.size()-1) return Engines[index];
153 /// Retrieves the number of tanks defined for the aircraft.
154 inline unsigned int GetNumTanks(void) const {return Tanks.size();}
156 /** Retrieves a tank object pointer from the list of tanks.
157 @param index the tank index within the vector container
158 @return the address of the specific tank, or zero if no such tank is
160 inline FGTank* GetTank(unsigned int index) {
161 if (index <= Tanks.size()-1) return Tanks[index];
164 /** Retrieves a thruster object pointer from the list of thrusters.
165 @param index the thruster index within the vector container
166 @return the address of the specific thruster, or zero if no such thruster is
168 inline FGThruster* GetThruster(unsigned int index) {
169 if (index <= Thrusters.size()-1) return Thrusters[index];
172 /** Returns the number of fuel tanks currently actively supplying fuel */
173 inline int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
175 /** Returns the number of oxidizer tanks currently actively supplying oxidizer */
176 inline int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
178 /** Loops the engines/thrusters until thrust output steady (used for trimming) */
179 bool GetSteadyState(void);
181 /** starts the engines in IC mode (dt=0). All engine-specific setup must
182 be done before calling this (i.e. magnetos, starter engage, etc.) */
183 bool ICEngineStart(void);
185 string GetPropulsionStrings(void);
186 string GetPropulsionValues(void);
188 inline FGColumnVector3& GetForces(void) {return vForces; }
189 inline double GetForces(int n) const { return vForces(n);}
190 inline FGColumnVector3& GetMoments(void) {return vMoments;}
191 inline double GetMoments(int n) const {return vMoments(n);}
193 FGColumnVector3& GetTanksMoment(void);
194 double GetTanksWeight(void);
196 double GetTanksIxx(const FGColumnVector3& vXYZcg);
197 double GetTanksIyy(const FGColumnVector3& vXYZcg);
198 double GetTanksIzz(const FGColumnVector3& vXYZcg);
199 double GetTanksIxz(const FGColumnVector3& vXYZcg);
200 double GetTanksIxy(const FGColumnVector3& vXYZcg);
202 inline int GetActiveEngine(void) const
207 inline int GetActiveEngine(void);
209 void SetMagnetos(int setting);
210 void SetStarter(int setting);
211 void SetCutoff(int setting=0);
212 void SetActiveEngine(int engine);
218 vector <FGEngine*> Engines;
219 vector <FGTank*> Tanks;
220 vector <FGTank*>::iterator iTank;
221 vector <FGThruster*> Thrusters;
222 unsigned int numSelectedFuelTanks;
223 unsigned int numSelectedOxiTanks;
224 unsigned int numFuelTanks;
225 unsigned int numOxiTanks;
226 unsigned int numEngines;
227 unsigned int numTanks;
228 unsigned int numThrusters;
231 FGColumnVector3 vForces;
232 FGColumnVector3 vMoments;
233 FGColumnVector3 vXYZtank;
234 void Debug(int from);
237 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%