JSBSim Flight Dynamics Model  1.2.0 (05 Nov 2023)
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 "FGModel.h"
45 #include "propulsion/FGEngine.h"
46 #include "math/FGMatrix33.h"
47 
48 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 FORWARD DECLARATIONS
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51 
52 namespace JSBSim {
53 
54 class FGTank;
55 class FGEngine;
56 
57 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 CLASS DOCUMENTATION
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
60 
94 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 CLASS DECLARATION
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
97 
98 class JSBSIM_API FGPropulsion : public FGModel
99 {
100 public:
104  ~FGPropulsion() override;
105 
115  bool Run(bool Holding) override;
116 
117  bool InitModel(void) override;
118 
123  bool Load(Element* el) override;
124 
126  size_t GetNumEngines(void) const {return Engines.size();}
127 
132  auto GetEngine(unsigned int index) const {
133  assert(index < Engines.size());
134  return Engines[index];
135  }
136 
138  size_t GetNumTanks(void) const {return Tanks.size();}
139 
144  auto GetTank(unsigned int index) const {
145  assert(index < Tanks.size());
146  return Tanks[index];
147  }
148 
150  bool GetSteadyState(void);
151 
153  void InitRunning(int n);
154 
155  std::string GetPropulsionStrings(const std::string& delimiter) const;
156  std::string GetPropulsionValues(const std::string& delimiter) const;
157  std::string GetPropulsionTankReport();
158 
159  const FGColumnVector3& GetForces(void) const {return vForces; }
160  double GetForces(int n) const { return vForces(n);}
161  const FGColumnVector3& GetMoments(void) const {return vMoments;}
162  double GetMoments(int n) const {return vMoments(n);}
163 
164  double Transfer(int source, int target, double amount);
165  void DoRefuel(double time_slice);
166  void DumpFuel(double time_slice);
167 
168  const FGColumnVector3& GetTanksMoment(void);
169  double GetTanksWeight(void) const;
170 
171  SGPath FindFullPathName(const SGPath& path) const override;
172  inline int GetActiveEngine(void) const {return ActiveEngine;}
173  inline bool GetFuelFreeze(void) const {return FuelFreeze;}
174 
175  void SetMagnetos(int setting);
176  void SetStarter(int setting);
177  int GetStarter(void) const;
178  void SetCutoff(int setting=0);
179  int GetCutoff(void) const;
180  void SetActiveEngine(int engine);
181  void SetFuelFreeze(bool f);
182  const FGMatrix33& CalculateTankInertias(void);
183 
184  struct FGEngine::Inputs in;
185 
186 private:
187  std::vector<std::shared_ptr<FGEngine>> Engines;
188  std::vector<std::shared_ptr<FGTank>> Tanks;
189  int ActiveEngine;
190  FGColumnVector3 vForces;
191  FGColumnVector3 vMoments;
192  FGColumnVector3 vTankXYZ;
193  FGColumnVector3 vXYZtank_arm;
194  FGMatrix33 tankJ;
195  bool refuel;
196  bool dump;
197  bool FuelFreeze;
198  double TotalFuelQuantity;
199  double TotalOxidizerQuantity;
200  double DumpRate;
201  double RefuelRate;
202  void ConsumeFuel(FGEngine* engine);
203 
204  bool ReadingEngine;
205 
206  void bind();
207  void Debug(int from) override;
208 };
209 }
210 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
211 #endif
This class implements a 3 element column vector.
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:184
Base class for all scheduled JSBSim models.
Definition: FGModel.h:70
Propulsion management class.
Definition: FGPropulsion.h:99
auto GetEngine(unsigned int index) const
Retrieves an engine object pointer from the list of engines.
Definition: FGPropulsion.h:132
size_t GetNumEngines(void) const
Retrieves the number of engines defined for the aircraft.
Definition: FGPropulsion.h:126
auto GetTank(unsigned int index) const
Retrieves a tank object pointer from the list of tanks.
Definition: FGPropulsion.h:144
size_t GetNumTanks(void) const
Retrieves the number of tanks defined for the aircraft.
Definition: FGPropulsion.h:138