JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
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 FORWARD DECLARATIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52 
53 namespace JSBSim {
54 
55 class FGTank;
56 class FGEngine;
57 
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 CLASS DOCUMENTATION
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 
95 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96 CLASS DECLARATION
97 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
98 
99 class FGPropulsion : public FGModel
100 {
101 public:
105  ~FGPropulsion() override;
106 
116  bool Run(bool Holding) override;
117 
118  bool InitModel(void) override;
119 
124  bool Load(Element* el) override;
125 
127  unsigned int GetNumEngines(void) const {return (unsigned int)Engines.size();}
128 
133  FGEngine* GetEngine(unsigned int index) const {
134  if (index < Engines.size()) return Engines[index];
135  else return 0L; }
136 
138  unsigned int GetNumTanks(void) const {return (unsigned int)Tanks.size();}
139 
144  FGTank* GetTank(unsigned int index) const {
145  if (index < Tanks.size()) return Tanks[index];
146  else return 0L; }
147 
149  int GetnumSelectedFuelTanks(void) const {return numSelectedFuelTanks;}
150 
152  int GetnumSelectedOxiTanks(void) const {return numSelectedOxiTanks;}
153 
155  bool GetSteadyState(void);
156 
158  void InitRunning(int n);
159 
160  std::string GetPropulsionStrings(const std::string& delimiter) const;
161  std::string GetPropulsionValues(const std::string& delimiter) const;
162  std::string GetPropulsionTankReport();
163 
164  const FGColumnVector3& GetForces(void) const {return vForces; }
165  double GetForces(int n) const { return vForces(n);}
166  const FGColumnVector3& GetMoments(void) const {return vMoments;}
167  double GetMoments(int n) const {return vMoments(n);}
168 
169  double Transfer(int source, int target, double amount);
170  void DoRefuel(double time_slice);
171  void DumpFuel(double time_slice);
172 
173  const FGColumnVector3& GetTanksMoment(void);
174  double GetTanksWeight(void) const;
175 
176  SGPath FindFullPathName(const SGPath& path) const override;
177  inline int GetActiveEngine(void) const {return ActiveEngine;}
178  inline bool GetFuelFreeze(void) const {return FuelFreeze;}
179 
180  void SetMagnetos(int setting);
181  void SetStarter(int setting);
182  int GetStarter(void) const;
183  void SetCutoff(int setting=0);
184  int GetCutoff(void) const;
185  void SetActiveEngine(int engine);
186  void SetFuelFreeze(bool f);
187  const FGMatrix33& CalculateTankInertias(void);
188 
189  struct FGEngine::Inputs in;
190 
191 private:
192  std::vector <FGEngine*> Engines;
193  std::vector <FGTank*> Tanks;
194  unsigned int numSelectedFuelTanks;
195  unsigned int numSelectedOxiTanks;
196  unsigned int numFuelTanks;
197  unsigned int numOxiTanks;
198  unsigned int numEngines;
199  unsigned int numTanks;
200  int ActiveEngine;
201  FGColumnVector3 vForces;
202  FGColumnVector3 vMoments;
203  FGColumnVector3 vTankXYZ;
204  FGColumnVector3 vXYZtank_arm;
205  FGMatrix33 tankJ;
206  simgear::PropertyObject<bool> refuel;
207  simgear::PropertyObject<bool> dump;
208  bool FuelFreeze;
209  simgear::PropertyObject<double> TotalFuelQuantity;
210  simgear::PropertyObject<double> TotalOxidizerQuantity;
211  double DumpRate;
212  double RefuelRate;
213  bool IsBound;
214  bool HavePistonEngine;
215  bool HaveTurbineEngine;
216  bool HaveTurboPropEngine;
217  bool HaveRocketEngine;
218  bool HaveElectricEngine;
219  void ConsumeFuel(FGEngine* engine);
220 
221  bool ReadingEngine;
222 
223  void bind();
224  void Debug(int from) override;
225 };
226 }
227 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
228 #endif
JSBSim::FGFDMExec
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:185
JSBSim::FGColumnVector3
This class implements a 3 element column vector.
Definition: FGColumnVector3.h:63
JSBSim::FGModel
Base class for all scheduled JSBSim models.
Definition: FGModel.h:68
JSBSim::FGPropulsion::FGPropulsion
FGPropulsion(FGFDMExec *)
Constructor.
Definition: FGPropulsion.cpp:70
JSBSim::FGTank
Models a fuel tank.
Definition: FGTank.h:201
JSBSim::FGPropulsion::GetEngine
FGEngine * GetEngine(unsigned int index) const
Retrieves an engine object pointer from the list of engines.
Definition: FGPropulsion.h:133
JSBSim::FGPropulsion::GetSteadyState
bool GetSteadyState(void)
Loops the engines until thrust output steady (used for trimming)
Definition: FGPropulsion.cpp:279
JSBSim::FGPropulsion::GetNumTanks
unsigned int GetNumTanks(void) const
Retrieves the number of tanks defined for the aircraft.
Definition: FGPropulsion.h:138
JSBSim::FGPropulsion::GetnumSelectedFuelTanks
int GetnumSelectedFuelTanks(void) const
Returns the number of fuel tanks currently actively supplying fuel.
Definition: FGPropulsion.h:149
JSBSim::FGPropulsion::InitRunning
void InitRunning(int n)
Sets up the engines as running.
Definition: FGPropulsion.cpp:329
JSBSim::FGPropulsion::GetNumEngines
unsigned int GetNumEngines(void) const
Retrieves the number of engines defined for the aircraft.
Definition: FGPropulsion.h:127
JSBSim::FGPropulsion::GetTank
FGTank * GetTank(unsigned int index) const
Retrieves a tank object pointer from the list of tanks.
Definition: FGPropulsion.h:144
JSBSim::FGPropulsion::Run
bool Run(bool Holding) override
Executes the propulsion model.
Definition: FGPropulsion.cpp:127
JSBSim::FGPropulsion
Propulsion management class.
Definition: FGPropulsion.h:99
JSBSim::FGPropulsion::GetnumSelectedOxiTanks
int GetnumSelectedOxiTanks(void) const
Returns the number of oxidizer tanks currently actively supplying oxidizer.
Definition: FGPropulsion.h:152
JSBSim::FGEngine
Base class for all engines.
Definition: FGEngine.h:103
JSBSim::FGPropulsion::~FGPropulsion
~FGPropulsion() override
Destructor.
Definition: FGPropulsion.cpp:94
JSBSim::FGPropulsion::Load
bool Load(Element *el) override
Loads the propulsion system (engine[s] and tank[s]).
Definition: FGPropulsion.cpp:357
JSBSim::Element
Definition: FGXMLElement.h:143