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"
61 #include "FGPropeller.h"
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68 #define ID_PROPULSION "$Id$"
70 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
74 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
78 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
82 /** Propulsion management class.
83 FGPropulsion manages all aspects of propulsive force generation, including
84 containment of engines, tanks, and thruster class instances in STL vectors,
85 and the interaction and communication between them.
91 @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPropulsion.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">
93 @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPropulsion.cpp?rev=HEAD&content-type=text/vnd.viewcvs-markup">
97 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
101 class FGPropulsion : public FGModel
105 FGPropulsion(FGFDMExec*);
109 /** Executes the propulsion model.
110 The initial plan for the FGPropulsion class calls for Run() to be executed,
111 performing the following tasks:
113 <li>Determine the drag - or power required - for the attached thrust effector
114 for this engine so that any feedback to the engine can be performed. This
115 is done by calling FGThruster::CalculatePReq()</li>
116 <li>Given 1, above, calculate the power available from the engine. This is
117 done by calling FGEngine::CalculatePAvail()</li>
118 <li>Next, calculate the thrust output from the thruster model given the power
119 available and the power required. This may also result in new performance
120 numbers for the thruster in the case of the propeller, at least. This
121 result is returned from a call to Calculate().</li></ol>
123 [Note: Should we be checking the Starved flag here?] */
126 /** Loads the propulsion system (engine[s], tank[s], thruster[s]).
127 Characteristics of the propulsion system are read in from the config file.
128 @param AC_cfg pointer to the config file instance that describes the
129 aircraft being modeled.
130 @return true if successfully loaded, otherwise false */
131 bool Load(FGConfigFile* AC_cfg);
133 /// Retrieves the number of engines defined for the aircraft.
134 inline unsigned int GetNumEngines(void) const {return Engines.size();}
136 /** Retrieves an engine object pointer from the list of engines.
137 @param index the engine index within the vector container
138 @return the address of the specific engine, or zero if no such engine is
140 inline FGEngine* GetEngine(unsigned int index) {
141 if (index <= Engines.size()-1) return Engines[index];
144 // Retrieves the number of tanks defined for the aircraft.
145 inline unsigned int GetNumTanks(void) const {return Tanks.size();}
147 /** Retrieves a tank object pointer from the list of tanks.
148 @param index the tank index within the vector container
149 @return the address of the specific tank, or zero if no such tank is
151 inline FGTank* GetTank(unsigned int index) {
152 if (index <= Tanks.size()-1) return Tanks[index];
155 /** Retrieves a thruster object pointer from the list of thrusters.
156 @param index the thruster index within the vector container
157 @return the address of the specific thruster, or zero if no such thruster is
159 inline FGThruster* GetThruster(unsigned int index) {
160 if (index <= Thrusters.size()-1) return Thrusters[index];
163 /** Returns the number of fuel tanks currently actively supplying fuel */
164 inline int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
166 /** Returns the number of oxidizer tanks currently actively supplying oxidizer */
167 inline int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
169 /** Loops the engines/thrusters until thrust output steady (used for trimming) */
170 bool GetSteadyState(void);
172 /** starts the engines in IC mode (dt=0). All engine-specific setup must
173 be done before calling this (i.e. magnetos, starter engage, etc.) */
174 bool ICEngineStart(void);
176 string GetPropulsionStrings(void);
177 string GetPropulsionValues(void);
179 inline FGColumnVector3& GetForces(void) {return vForces; }
180 inline double GetForces(int n) const { return vForces(n);}
181 inline FGColumnVector3& GetMoments(void) {return vMoments;}
182 inline double GetMoments(int n) const {return vMoments(n);}
184 FGColumnVector3& GetTanksMoment(void);
185 double GetTanksWeight(void);
187 double GetTanksIxx(const FGColumnVector3& vXYZcg);
188 double GetTanksIyy(const FGColumnVector3& vXYZcg);
189 double GetTanksIzz(const FGColumnVector3& vXYZcg);
190 double GetTanksIxz(const FGColumnVector3& vXYZcg);
191 double GetTanksIxy(const FGColumnVector3& vXYZcg);
193 void SetMagnetos(int setting);
194 void SetStarter(int setting);
195 void SetActiveEngine(int engine);
201 vector <FGEngine*> Engines;
202 vector <FGTank*> Tanks;
203 vector <FGTank*>::iterator iTank;
204 vector <FGThruster*> Thrusters;
205 unsigned int numSelectedFuelTanks;
206 unsigned int numSelectedOxiTanks;
207 unsigned int numFuelTanks;
208 unsigned int numOxiTanks;
209 unsigned int numEngines;
210 unsigned int numTanks;
211 unsigned int numThrusters;
214 FGColumnVector3 vForces;
215 FGColumnVector3 vMoments;
216 FGColumnVector3 vXYZtank;
217 void Debug(int from);
220 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%