FlightGear next
FGEngine.h
Go to the documentation of this file.
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
25FUNCTIONAL DESCRIPTION
26--------------------------------------------------------------------------------
27
28Based on Flightgear code, which is based on LaRCSim. This class simulates
29a generic engine.
30
31HISTORY
32--------------------------------------------------------------------------------
3301/21/99 JSB Created
34
35%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36SENTRY
37%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
38
39#ifndef FGENGINE_H
40#define FGENGINE_H
41
42/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43INCLUDES
44%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45
46#include <vector>
47#include <string>
48
51
52/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53FORWARD DECLARATIONS
54%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55
56namespace JSBSim {
57
58class FGFDMExec;
59class FGThruster;
60class Element;
62
63/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64CLASS DOCUMENTATION
65%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66
98
99/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
100CLASS DECLARATION
101%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
102
104{
105public:
106 struct Inputs {
107 double Pressure;
110 double Density;
114 double TAT_c;
115 double Vt;
116 double Vc;
117 double qbar;
118 double alpha;
119 double beta;
120 double H_agl;
124 std::vector <double> ThrottleCmd;
125 std::vector <double> MixtureCmd;
126 std::vector <double> ThrottlePos;
127 std::vector <double> MixturePos;
128 std::vector <double> PropAdvance;
129 std::vector <bool> PropFeather;
131 };
132
133 FGEngine(int engine_number, struct Inputs& input);
134 ~FGEngine() override;
135
137
138 EngineType GetType(void) const { return Type; }
139 virtual const std::string& GetName(void) const { return Name; }
140
141 // Engine controls
142 virtual double GetThrottleMin(void) const { return MinThrottle; }
143 virtual double GetThrottleMax(void) const { return MaxThrottle; }
144 virtual bool GetStarter(void) const { return Starter; }
145
146 virtual double getFuelFlow_gph () const {return FuelFlow_gph;}
147 virtual double getFuelFlow_pph () const {return FuelFlow_pph;}
148 virtual double GetFuelFlowRate(void) const {return FuelFlowRate;}
149 virtual double GetFuelFlowRateGPH(void) const {return FuelFlowRate*3600/FuelDensity;}
150 virtual double GetFuelUsedLbs(void) const {return FuelUsedLbs;}
151 virtual bool GetStarved(void) const { return Starved; }
152 virtual bool GetRunning(void) const { return Running; }
153 virtual bool GetCranking(void) const { return Cranking; }
154
155 virtual void SetStarved(bool tt) { Starved = tt; }
156 virtual void SetStarved(void) { Starved = true; }
157
158 virtual void SetRunning(bool bb) { Running=bb; }
159 virtual void SetName(const std::string& name) { Name = name; }
160 virtual void SetFuelFreeze(bool f) { FuelFreeze = f; }
161 virtual void SetFuelDensity(double d) { FuelDensity = d; }
162
163 virtual void SetStarter(bool s) { Starter = s; }
164
165 virtual int InitRunning(void){ return 1; }
166
168 virtual void ResetToIC(void);
169
171 virtual void Calculate(void) = 0;
172
173 virtual double GetThrust(void) const;
174
179 virtual double CalcFuelNeed(void);
180
181 virtual double CalcOxidizerNeed(void) {return 0.0;}
182
183 virtual double GetPowerAvailable(void) {return 0.0;};
184
185 virtual const FGColumnVector3& GetBodyForces(void);
186 virtual const FGColumnVector3& GetMoments(void);
187
188 void LoadThruster(FGFDMExec* exec, Element *el);
189 FGThruster* GetThruster(void) const {return Thruster;}
190
191 unsigned int GetSourceTank(unsigned int i) const;
192 size_t GetNumSourceTanks() const {return SourceTanks.size();}
193
194 virtual std::string GetEngineLabels(const std::string& delimiter) = 0;
195 virtual std::string GetEngineValues(const std::string& delimiter) = 0;
196
197 struct Inputs& in;
198 void LoadThrusterInputs();
199
200protected:
201
202 std::string Name;
203 const int EngineNumber;
208
211 double PctPower;
217
222
224
225 std::vector <int> SourceTanks;
226
227 bool Load(FGFDMExec *exec, Element *el);
228 void Debug(int from);
229};
230}
231
232//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
233#endif
#define i(x)
This class implements a 3 element column vector.
EngineType Type
Definition FGEngine.h:204
double FuelExpended
Definition FGEngine.h:209
virtual double GetThrust(void) const
Definition FGEngine.cpp:114
FGThruster * Thruster
Definition FGEngine.h:223
virtual std::string GetEngineLabels(const std::string &delimiter)=0
double FuelFlow_pph
Definition FGEngine.h:219
virtual double GetThrottleMax(void) const
Definition FGEngine.h:143
virtual double getFuelFlow_gph() const
Definition FGEngine.h:146
virtual bool GetCranking(void) const
Definition FGEngine.h:153
virtual std::string GetEngineValues(const std::string &delimiter)=0
virtual bool GetRunning(void) const
Definition FGEngine.h:152
virtual void SetStarter(bool s)
Definition FGEngine.h:163
virtual double GetThrottleMin(void) const
Definition FGEngine.h:142
double FuelFlowRate
Definition FGEngine.h:210
virtual bool GetStarved(void) const
Definition FGEngine.h:151
virtual const FGColumnVector3 & GetMoments(void)
Definition FGEngine.cpp:128
void Debug(int from)
Definition FGEngine.cpp:263
virtual const std::string & GetName(void) const
Definition FGEngine.h:139
struct Inputs & in
Definition FGEngine.h:197
bool Load(FGFDMExec *exec, Element *el)
Definition FGEngine.cpp:176
const int EngineNumber
Definition FGEngine.h:203
double FuelDensity
Definition FGEngine.h:221
double FuelFlow_gph
Definition FGEngine.h:218
EngineType GetType(void) const
Definition FGEngine.h:138
void LoadThruster(FGFDMExec *exec, Element *el)
Definition FGEngine.cpp:152
double MinThrottle
Definition FGEngine.h:207
unsigned int GetSourceTank(unsigned int i) const
Definition FGEngine.cpp:103
std::vector< int > SourceTanks
Definition FGEngine.h:225
virtual double GetPowerAvailable(void)
Definition FGEngine.h:183
std::string Name
Definition FGEngine.h:202
virtual double CalcFuelNeed(void)
The fuel need is calculated based on power levels and flow rate for that power level.
Definition FGEngine.cpp:93
virtual void SetName(const std::string &name)
Definition FGEngine.h:159
void LoadThrusterInputs()
Definition FGEngine.cpp:135
size_t GetNumSourceTanks() const
Definition FGEngine.h:192
virtual int InitRunning(void)
Definition FGEngine.h:165
virtual void SetFuelFreeze(bool f)
Definition FGEngine.h:160
virtual void SetRunning(bool bb)
Definition FGEngine.h:158
virtual double getFuelFlow_pph() const
Definition FGEngine.h:147
~FGEngine() override
Definition FGEngine.cpp:69
virtual bool GetStarter(void) const
Definition FGEngine.h:144
virtual double CalcOxidizerNeed(void)
Definition FGEngine.h:181
virtual void SetStarved(bool tt)
Definition FGEngine.h:155
virtual void SetStarved(void)
Definition FGEngine.h:156
FGEngine(int engine_number, struct Inputs &input)
Definition FGEngine.cpp:55
virtual void Calculate(void)=0
Calculates the thrust of the engine, and other engine functions.
virtual double GetFuelFlowRateGPH(void) const
Definition FGEngine.h:149
virtual const FGColumnVector3 & GetBodyForces(void)
Definition FGEngine.cpp:121
double FuelUsedLbs
Definition FGEngine.h:220
double MaxThrottle
Definition FGEngine.h:206
virtual double GetFuelFlowRate(void) const
Definition FGEngine.h:148
virtual void ResetToIC(void)
Resets the Engine parameters to the initial conditions.
Definition FGEngine.cpp:77
FGThruster * GetThruster(void) const
Definition FGEngine.h:189
virtual void SetFuelDensity(double d)
Definition FGEngine.h:161
double SLFuelFlowMax
Definition FGEngine.h:205
virtual double GetFuelUsedLbs(void) const
Definition FGEngine.h:150
The model functions class provides the capability for loading, storing, and executing arbitrary funct...
Base class for specific thrusting devices such as propellers, nozzles, etc.
Definition FGThruster.h:77
const char * name
std::vector< bool > PropFeather
Definition FGEngine.h:129
FGColumnVector3 AeroPQR
Definition FGEngine.h:122
std::vector< double > MixturePos
Definition FGEngine.h:127
std::vector< double > MixtureCmd
Definition FGEngine.h:125
std::vector< double > ThrottlePos
Definition FGEngine.h:126
FGColumnVector3 AeroUVW
Definition FGEngine.h:121
std::vector< double > PropAdvance
Definition FGEngine.h:128
std::vector< double > ThrottleCmd
Definition FGEngine.h:124
FGColumnVector3 PQRi
Definition FGEngine.h:123