JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
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 (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
17  details.
18 
19  You should have received a copy of the GNU Lesser 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 Lesser 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 #include <vector>
42 #include <iosfwd>
43 
44 #include "simgear/props/propertyObject.hxx"
45 #include "FGModel.h"
46 #include "propulsion/FGEngine.h"
47 #include "math/FGMatrix33.h"
48 
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 DEFINITIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52 
53 #define ID_PROPULSION "$Id: FGPropulsion.h,v 1.37 2017/02/25 14:23:19 bcoconni Exp $"
54 
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 FORWARD DECLARATIONS
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58 
59 namespace JSBSim {
60 
61 class FGTank;
62 class FGEngine;
63 
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 CLASS DOCUMENTATION
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 
102 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103 CLASS DECLARATION
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
105 
106 class FGPropulsion : public FGModel
107 {
108 public:
112  ~FGPropulsion();
113 
123  bool Run(bool Holding);
124 
125  bool InitModel(void);
126 
131  bool Load(Element* el);
132 
134  unsigned int GetNumEngines(void) const {return (unsigned int)Engines.size();}
135 
140  FGEngine* GetEngine(unsigned int index) const {
141  if (index < Engines.size()) return Engines[index];
142  else return 0L; }
143 
145  unsigned int GetNumTanks(void) const {return (unsigned int)Tanks.size();}
146 
151  FGTank* GetTank(unsigned int index) const {
152  if (index < Tanks.size()) return Tanks[index];
153  else return 0L; }
154 
156  int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
157 
159  int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
160 
162  bool GetSteadyState(void);
163 
165  void InitRunning(int n);
166 
167  std::string GetPropulsionStrings(const std::string& delimiter) const;
168  std::string GetPropulsionValues(const std::string& delimiter) const;
169  std::string GetPropulsionTankReport();
170 
171  const FGColumnVector3& GetForces(void) const {return vForces; }
172  double GetForces(int n) const { return vForces(n);}
173  const FGColumnVector3& GetMoments(void) const {return vMoments;}
174  double GetMoments(int n) const {return vMoments(n);}
175 
176  double Transfer(int source, int target, double amount);
177  void DoRefuel(double time_slice);
178  void DumpFuel(double time_slice);
179 
180  const FGColumnVector3& GetTanksMoment(void);
181  double GetTanksWeight(void) const;
182 
183  SGPath FindFullPathName(const SGPath& path) const;
184  inline int GetActiveEngine(void) const {return ActiveEngine;}
185  inline bool GetFuelFreeze(void) const {return FuelFreeze;}
186 
187  void SetMagnetos(int setting);
188  void SetStarter(int setting);
189  void SetCutoff(int setting=0);
190  void SetActiveEngine(int engine);
191  void SetFuelFreeze(bool f);
192  const FGMatrix33& CalculateTankInertias(void);
193 
194  struct FGEngine::Inputs in;
195 
196 private:
197  std::vector <FGEngine*> Engines;
198  std::vector <FGTank*> Tanks;
199  unsigned int numSelectedFuelTanks;
200  unsigned int numSelectedOxiTanks;
201  unsigned int numFuelTanks;
202  unsigned int numOxiTanks;
203  unsigned int numEngines;
204  unsigned int numTanks;
205  int ActiveEngine;
206  FGColumnVector3 vForces;
207  FGColumnVector3 vMoments;
208  FGColumnVector3 vTankXYZ;
209  FGColumnVector3 vXYZtank_arm;
210  FGMatrix33 tankJ;
211  simgear::PropertyObject<bool> refuel;
212  simgear::PropertyObject<bool> dump;
213  bool FuelFreeze;
214  simgear::PropertyObject<double> TotalFuelQuantity;
215  simgear::PropertyObject<double> TotalOxidizerQuantity;
216  double DumpRate;
217  double RefuelRate;
218  bool IsBound;
219  bool HavePistonEngine;
220  bool HaveTurbineEngine;
221  bool HaveTurboPropEngine;
222  bool HaveRocketEngine;
223  bool HaveElectricEngine;
224  void ConsumeFuel(FGEngine* engine);
225 
226  bool ReadingEngine;
227 
228  void bind();
229  void Debug(int from);
230 };
231 }
232 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
233 #endif
234 
FGTank * GetTank(unsigned int index) const
Retrieves a tank object pointer from the list of tanks.
Definition: FGPropulsion.h:151
int GetnumSelectedOxiTanks(void) const
Returns the number of oxidizer tanks currently actively supplying oxidizer.
Definition: FGPropulsion.h:159
FGEngine * GetEngine(unsigned int index) const
Retrieves an engine object pointer from the list of engines.
Definition: FGPropulsion.h:140
~FGPropulsion()
Destructor.
bool Load(Element *el)
Loads the propulsion system (engine[s] and tank[s]).
Models a fuel tank.
Definition: FGTank.h:200
Propulsion management class.
Definition: FGPropulsion.h:106
FGPropulsion(FGFDMExec *)
Constructor.
Base class for all scheduled JSBSim models.
Definition: FGModel.h:74
This class implements a 3 element column vector.
int GetnumSelectedFuelTanks(void) const
Returns the number of fuel tanks currently actively supplying fuel.
Definition: FGPropulsion.h:156
bool GetSteadyState(void)
Loops the engines until thrust output steady (used for trimming)
Base class for all engines.
Definition: FGEngine.h:121
void InitRunning(int n)
Sets up the engines as running.
unsigned int GetNumTanks(void) const
Retrieves the number of tanks defined for the aircraft.
Definition: FGPropulsion.h:145
Handles matrix math operations.
Definition: FGMatrix33.h:92
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:189
bool Run(bool Holding)
Executes the propulsion model.
unsigned int GetNumEngines(void) const
Retrieves the number of engines defined for the aircraft.
Definition: FGPropulsion.h:134