JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGEngine.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 
3  Header: FGEngine.h
4  Author: Jon S. Berndt
5  Date started: 01/21/99
6 
7  ------------- Copyright (C) 1999 Jon S. Berndt (jon@jsbsim.org) -------------
8 
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser 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 Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA.
21 
22  Further information about the GNU Lesser General Public License can also be found on
23  the world wide web at http://www.gnu.org.
24 
25 FUNCTIONAL DESCRIPTION
26 --------------------------------------------------------------------------------
27 
28 Based on Flightgear code, which is based on LaRCSim. This class simulates
29 a generic engine.
30 
31 HISTORY
32 --------------------------------------------------------------------------------
33 01/21/99 JSB Created
34 
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 SENTRY
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
38 
39 #ifndef FGENGINE_H
40 #define FGENGINE_H
41 
42 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 INCLUDES
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45 
46 #include <vector>
47 #include <string>
48 
49 #include "math/FGModelFunctions.h"
50 #include "math/FGColumnVector3.h"
51 
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 DEFINITIONS
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55 
56 #define ID_ENGINE "$Id: FGEngine.h,v 1.47 2015/09/27 10:16:57 bcoconni Exp $"
57 
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 FORWARD DECLARATIONS
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 
62 namespace JSBSim {
63 
64 class FGFDMExec;
65 class FGThruster;
66 class Element;
67 class FGPropertyManager;
68 
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 CLASS DOCUMENTATION
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72 
117 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
118 CLASS DECLARATION
119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
120 
122 {
123 public:
124  struct Inputs {
125  double Pressure;
126  double PressureRatio;
127  double Temperature;
128  double Density;
129  double DensityRatio;
130  double Soundspeed;
131  double TotalPressure;
132  double TAT_c;
133  double Vt;
134  double Vc;
135  double qbar;
136  double alpha;
137  double beta;
138  double H_agl;
139  FGColumnVector3 AeroUVW;
140  FGColumnVector3 AeroPQR;
141  FGColumnVector3 PQRi;
142  std::vector <double> ThrottleCmd;
143  std::vector <double> MixtureCmd;
144  std::vector <double> ThrottlePos;
145  std::vector <double> MixturePos;
146  std::vector <double> PropAdvance;
147  std::vector <bool> PropFeather;
148  double TotalDeltaT;
149  };
150 
151  FGEngine(int engine_number, struct Inputs& input);
152  virtual ~FGEngine();
153 
154  enum EngineType {etUnknown, etRocket, etPiston, etTurbine, etTurboprop, etElectric};
155 
156  EngineType GetType(void) const { return Type; }
157  virtual const std::string& GetName(void) const { return Name; }
158 
159  // Engine controls
160  virtual double GetThrottleMin(void) const { return MinThrottle; }
161  virtual double GetThrottleMax(void) const { return MaxThrottle; }
162  virtual bool GetStarter(void) const { return Starter; }
163 
164  virtual double getFuelFlow_gph () const {return FuelFlow_gph;}
165  virtual double getFuelFlow_pph () const {return FuelFlow_pph;}
166  virtual double GetFuelFlowRate(void) const {return FuelFlowRate;}
167  virtual double GetFuelFlowRateGPH(void) const {return FuelFlowRate*3600/FuelDensity;}
168  virtual double GetFuelUsedLbs(void) const {return FuelUsedLbs;}
169  virtual bool GetStarved(void) const { return Starved; }
170  virtual bool GetRunning(void) const { return Running; }
171  virtual bool GetCranking(void) const { return Cranking; }
172 
173  virtual void SetStarved(bool tt) { Starved = tt; }
174  virtual void SetStarved(void) { Starved = true; }
175 
176  virtual void SetRunning(bool bb) { Running=bb; }
177  virtual void SetName(const std::string& name) { Name = name; }
178  virtual void SetFuelFreeze(bool f) { FuelFreeze = f; }
179  virtual void SetFuelDensity(double d) { FuelDensity = d; }
180 
181  virtual void SetStarter(bool s) { Starter = s; }
182 
183  virtual int InitRunning(void){ return 1; }
184 
186  virtual void ResetToIC(void);
187 
189  virtual void Calculate(void) = 0;
190 
191  virtual double GetThrust(void) const;
192 
194  virtual void SetPlacement(const FGColumnVector3& location, const FGColumnVector3& orientation);
195 
200  virtual double CalcFuelNeed(void);
201 
202  virtual double CalcOxidizerNeed(void) {return 0.0;}
203 
204  virtual double GetPowerAvailable(void) {return 0.0;};
205 
206  virtual const FGColumnVector3& GetBodyForces(void);
207  virtual const FGColumnVector3& GetMoments(void);
208 
209  void LoadThruster(FGFDMExec* exec, Element *el);
210  FGThruster* GetThruster(void) const {return Thruster;}
211 
212  unsigned int GetSourceTank(unsigned int i) const;
213  size_t GetNumSourceTanks() const {return SourceTanks.size();}
214 
215  virtual std::string GetEngineLabels(const std::string& delimiter) = 0;
216  virtual std::string GetEngineValues(const std::string& delimiter) = 0;
217 
218  struct Inputs& in;
219  void LoadThrusterInputs();
220 
221 protected:
222 
223  std::string Name;
224  const int EngineNumber;
225  EngineType Type;
226  double X, Y, Z;
227  double EnginePitch;
228  double EngineYaw;
229  double SLFuelFlowMax;
230  double MaxThrottle;
231  double MinThrottle;
232 
233  double FuelExpended;
234  double FuelFlowRate;
235  double PctPower;
236  bool Starter;
237  bool Starved;
238  bool Running;
239  bool Cranking;
240  bool FuelFreeze;
241 
242  double FuelFlow_gph;
243  double FuelFlow_pph;
244  double FuelUsedLbs;
245  double FuelDensity;
246 
247  FGThruster* Thruster;
248 
249  std::vector <int> SourceTanks;
250 
251  virtual bool Load(FGFDMExec *exec, Element *el);
252  void Debug(int from);
253 };
254 }
255 
256 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
257 #endif
258 
Base class for specific thrusting devices such as propellers, nozzles, etc.
Definition: FGThruster.h:84
virtual double CalcFuelNeed(void)
The fuel need is calculated based on power levels and flow rate for that power level.
Definition: FGEngine.cpp:103
virtual void Calculate(void)=0
Calculates the thrust of the engine, and other engine functions.
This class implements a 3 element column vector.
Base class for all engines.
Definition: FGEngine.h:121
virtual void SetPlacement(const FGColumnVector3 &location, const FGColumnVector3 &orientation)
Sets engine placement information.
Definition: FGEngine.cpp:124
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:189
virtual void ResetToIC(void)
Resets the Engine parameters to the initial conditions.
Definition: FGEngine.cpp:87
The model functions class provides the capability for loading, storing, and executing arbitrary funct...