1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
3 Header: FGPropulsion.h
\r
4 Author: Jon S. Berndt
\r
5 Date started: 08/20/00
\r
7 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
\r
9 This program is free software; you can redistribute it and/or modify it under
\r
10 the terms of the GNU General Public License as published by the Free Software
\r
11 Foundation; either version 2 of the License, or (at your option) any later
\r
14 This program is distributed in the hope that it will be useful, but WITHOUT
\r
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
\r
19 You should have received a copy of the GNU General Public License along with
\r
20 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
\r
21 Place - Suite 330, Boston, MA 02111-1307, USA.
\r
23 Further information about the GNU General Public License can also be found on
\r
24 the world wide web at http://www.gnu.org.
\r
27 --------------------------------------------------------------------------------
\r
28 08/20/00 JSB Created
\r
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
\r
34 #ifndef FGPROPULSION_H
\r
35 #define FGPROPULSION_H
\r
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
\r
42 # include <simgear/compiler.h>
\r
43 # ifdef SG_HAVE_STD_INCLUDES
\r
45 # include <iterator>
\r
47 # include <vector.h>
\r
48 # include <iterator.h>
\r
52 # include <iterator>
\r
55 #include "FGModel.h"
\r
57 #include "FGRocket.h"
\r
58 #include "FGPiston.h"
\r
59 #include "FGTurboShaft.h"
\r
60 #include "FGTurboJet.h"
\r
61 #include "FGTurboProp.h"
\r
63 #include "FGPropeller.h"
\r
64 #include "FGNozzle.h"
\r
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
\r
70 #define ID_PROPULSION "$Id$"
\r
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
73 FORWARD DECLARATIONS
\r
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
\r
76 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
77 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
\r
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
\r
80 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
\r
84 /** Propulsion management class.
\r
85 FGPropulsion manages all aspects of propulsive force generation, including
\r
86 containment of engines, tanks, and thruster class instances in STL vectors,
\r
87 and the interaction and communication between them.
\r
88 @author Jon S. Berndt
\r
93 @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPropulsion.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">
\r
95 @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPropulsion.cpp?rev=HEAD&content-type=text/vnd.viewcvs-markup">
\r
99 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
\r
103 class FGPropulsion : public FGModel
\r
107 FGPropulsion(FGFDMExec*);
\r
111 /** Executes the propulsion model.
\r
112 The initial plan for the FGPropulsion class calls for Run() to be executed,
\r
113 performing the following tasks:
\r
115 <li>Determine the drag - or power required - for the attached thrust effector
\r
116 for this engine so that any feedback to the engine can be performed. This
\r
117 is done by calling FGThruster::CalculatePReq()</li>
\r
118 <li>Given 1, above, calculate the power available from the engine. This is
\r
119 done by calling FGEngine::CalculatePAvail()</li>
\r
120 <li>Next, calculate the thrust output from the thruster model given the power
\r
121 available and the power required. This may also result in new performance
\r
122 numbers for the thruster in the case of the propeller, at least. This
\r
123 result is returned from a call to Calculate().</li></ol>
\r
125 [Note: Should we be checking the Starved flag here?] */
\r
128 /** Loads the propulsion system (engine[s], tank[s], thruster[s]).
\r
129 Characteristics of the propulsion system are read in from the config file.
\r
130 @param AC_cfg pointer to the config file instance that describes the
\r
131 aircraft being modeled.
\r
132 @return true if successfully loaded, otherwise false */
\r
133 bool Load(FGConfigFile* AC_cfg);
\r
135 /// Retrieves the number of engines defined for the aircraft.
\r
136 inline unsigned int GetNumEngines(void) const {return Engines.size();}
\r
138 /** Retrieves an engine object pointer from the list of engines.
\r
139 @param index the engine index within the vector container
\r
140 @return the address of the specific engine, or zero if no such engine is
\r
142 inline FGEngine* GetEngine(unsigned int index) {
\r
143 if (index <= Engines.size()-1) return Engines[index];
\r
146 // Retrieves the number of tanks defined for the aircraft.
\r
147 inline unsigned int GetNumTanks(void) const {return Tanks.size();}
\r
149 /** Retrieves a tank object pointer from the list of tanks.
\r
150 @param index the tank index within the vector container
\r
151 @return the address of the specific tank, or zero if no such tank is
\r
153 inline FGTank* GetTank(unsigned int index) {
\r
154 if (index <= Tanks.size()-1) return Tanks[index];
\r
157 /** Retrieves a thruster object pointer from the list of thrusters.
\r
158 @param index the thruster index within the vector container
\r
159 @return the address of the specific thruster, or zero if no such thruster is
\r
161 inline FGThruster* GetThruster(unsigned int index) {
\r
162 if (index <= Thrusters.size()-1) return Thrusters[index];
\r
165 /** Returns the number of fuel tanks currently actively supplying fuel */
\r
166 inline int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
\r
168 /** Returns the number of oxidizer tanks currently actively supplying oxidizer */
\r
169 inline int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
\r
171 /** Loops the engines/thrusters until thrust output steady (used for trimming) */
\r
172 bool GetSteadyState(void);
\r
174 /** starts the engines in IC mode (dt=0). All engine-specific setup must
\r
175 be done before calling this (i.e. magnetos, starter engage, etc.) */
\r
176 bool ICEngineStart(void);
\r
178 string GetPropulsionStrings(void);
\r
179 string GetPropulsionValues(void);
\r
181 inline FGColumnVector3& GetForces(void) {return vForces; }
\r
182 inline double GetForces(int n) const { return vForces(n);}
\r
183 inline FGColumnVector3& GetMoments(void) {return vMoments;}
\r
184 inline double GetMoments(int n) const {return vMoments(n);}
\r
186 FGColumnVector3& GetTanksMoment(void);
\r
187 double GetTanksWeight(void);
\r
189 double GetTanksIxx(const FGColumnVector3& vXYZcg);
\r
190 double GetTanksIyy(const FGColumnVector3& vXYZcg);
\r
191 double GetTanksIzz(const FGColumnVector3& vXYZcg);
\r
192 double GetTanksIxz(const FGColumnVector3& vXYZcg);
\r
193 double GetTanksIxy(const FGColumnVector3& vXYZcg);
\r
195 void SetMagnetos(int setting);
\r
196 void SetStarter(int setting);
\r
197 void SetActiveEngine(int engine);
\r
203 vector <FGEngine*> Engines;
\r
204 vector <FGTank*> Tanks;
\r
205 vector <FGTank*>::iterator iTank;
\r
206 vector <FGThruster*> Thrusters;
\r
207 unsigned int numSelectedFuelTanks;
\r
208 unsigned int numSelectedOxiTanks;
\r
209 unsigned int numFuelTanks;
\r
210 unsigned int numOxiTanks;
\r
211 unsigned int numEngines;
\r
212 unsigned int numTanks;
\r
213 unsigned int numThrusters;
\r
216 FGColumnVector3 vForces;
\r
217 FGColumnVector3 vMoments;
\r
218 FGColumnVector3 vXYZtank;
\r
219 void Debug(int from);
\r
222 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r