]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGPropulsion.h
Adjust the turbine names for N1, N2 and EGT_degC to match those already specified...
[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 SG_HAVE_STD_INCLUDES
44 #    include <vector>
45 #    include <iterator>
46 #  else
47 #    include <vector.h>
48 #    include <iterator.h>
49 #  endif
50 #else
51 #  include <vector>
52 #  include <iterator>
53 #endif
54
55 #include "FGModel.h"
56
57 #include "FGRocket.h"
58 #include "FGPiston.h"
59 #include "FGTurbine.h"
60 #include "FGSimTurbine.h"
61 #include "FGTank.h"
62 #include "FGPropeller.h"
63 #include "FGNozzle.h"
64
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 DEFINITIONS
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68
69 #define ID_PROPULSION "$Id$"
70
71 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 FORWARD DECLARATIONS
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
74
75 namespace JSBSim {
76
77 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 CLASS DOCUMENTATION
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
80
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:
87
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.
91
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.
98     @author Jon S. Berndt
99     @version $Id$
100     @see
101     FGEngine
102     FGTank
103     FGThruster
104 */
105
106 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 CLASS DECLARATION
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
109
110 class FGPropulsion : public FGModel
111 {
112 public:
113   /// Constructor
114   FGPropulsion(FGFDMExec*);
115   /// Destructor
116   ~FGPropulsion();
117
118   /** Executes the propulsion model.
119       The initial plan for the FGPropulsion class calls for Run() to be executed,
120       performing the following tasks:
121       <ol>
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>
131
132       [Note: Should we be checking the Starved flag here?] */
133   bool Run(void);
134
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);
141
142   /// Retrieves the number of engines defined for the aircraft.
143   inline unsigned int GetNumEngines(void) const {return Engines.size();}
144
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
148               available */
149   inline FGEngine* GetEngine(unsigned int index) {
150                       if (index <= Engines.size()-1) return Engines[index];
151                       else                           return 0L;      }
152
153   /// Retrieves the number of tanks defined for the aircraft.
154   inline unsigned int GetNumTanks(void) const {return Tanks.size();}
155
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
159               available */
160   inline FGTank* GetTank(unsigned int index) {
161                       if (index <= Tanks.size()-1) return Tanks[index];
162                       else                         return 0L;        }
163
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
167               available */
168   inline FGThruster* GetThruster(unsigned int index) {
169                       if (index <= Thrusters.size()-1) return Thrusters[index];
170                       else                             return 0L;    }
171
172   /** Returns the number of fuel tanks currently actively supplying fuel */
173   inline int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
174
175   /** Returns the number of oxidizer tanks currently actively supplying oxidizer */
176   inline int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
177
178   /** Loops the engines/thrusters until thrust output steady (used for trimming) */
179   bool GetSteadyState(void);
180   
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);
184   
185   string GetPropulsionStrings(void);
186   string GetPropulsionValues(void);
187
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);}
192   
193   FGColumnVector3& GetTanksMoment(void);
194   double GetTanksWeight(void);
195
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);
201
202   inline int GetActiveEngine(void) const
203   {
204     return ActiveEngine;
205   }
206
207   inline int GetActiveEngine(void);
208
209   void SetMagnetos(int setting);
210   void SetStarter(int setting);
211   void SetCutoff(int setting=0);
212   void SetActiveEngine(int engine);
213   
214   void bind();
215   void unbind();
216    
217 private:
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;
229   int ActiveEngine;
230   double dt;
231   FGColumnVector3 vForces;
232   FGColumnVector3 vMoments;
233   FGColumnVector3 vXYZtank;
234   void Debug(int from);
235 };
236 }
237 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
238 #endif
239