JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGTank.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 
3  Header: FGTank.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
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 FUNCTIONAL DESCRIPTION
27 --------------------------------------------------------------------------------
28 
29 Based on Flightgear code, which is based on LaRCSim. This class simulates
30 a generic Tank.
31 
32 HISTORY
33 --------------------------------------------------------------------------------
34 01/21/99 JSB Created
35 
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 SENTRY
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39 
40 #ifndef FGTank_H
41 #define FGTank_H
42 
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 INCLUDES
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46 
47 #include "FGJSBBase.h"
48 #include "math/FGColumnVector3.h"
49 #include "math/FGFunction.h"
50 #include <string>
51 
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 DEFINITIONS
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55 
56 #define ID_TANK "$Id: FGTank.h,v 1.32 2017/02/21 21:07:04 bcoconni Exp $"
57 
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 FORWARD DECLARATIONS
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 
62 namespace JSBSim {
63 
64 class Element;
65 class FGPropertyManager;
66 class FGFDMExec;
67 
68 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 CLASS DOCUMENTATION
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
71 
196 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
197 CLASS DECLARATION
198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
199 
200 class FGTank : public FGJSBBase
201 {
202 public:
209  FGTank(FGFDMExec* exec, Element* el, int tank_number);
211  ~FGTank();
212 
213  enum TankType {ttUNKNOWN, ttFUEL, ttOXIDIZER};
214  enum GrainType {gtUNKNOWN, gtCYLINDRICAL, gtENDBURNING, gtFUNCTION};
215 
222  double Drain(double used);
223 
230  double Calculate(double dt, double TempC);
231 
235  int GetType(void) const {return Type;}
236 
238  void ResetToIC(void);
239 
242  bool GetSelected(void) const {return Selected;}
243 
246  double GetPctFull(void) const {return PctFull;}
247 
250  double GetCapacity(void) const {return Capacity;}
251 
254  double GetCapacityGallons(void) const {return Capacity/Density;}
255 
258  double GetContents(void) const {return Contents;}
259 
262  double GetContentsGallons(void) const {return Contents/Density;}
263 
269  double GetTemperature_degC(void) const {return Temperature;}
270 
276  double GetTemperature(void) const {return CelsiusToFahrenheit(Temperature);}
277 
280  double ProcessFuelName(const std::string& name);
281 
282  double GetIxx(void) const {return Ixx;}
283  double GetIyy(void) const {return Iyy;}
284  double GetIzz(void) const {return Izz;}
285 
286  inline double GetLocationX(void) const { return vXYZ(eX); }
287  inline double GetLocationY(void) const { return vXYZ(eY); }
288  inline double GetLocationZ(void) const { return vXYZ(eZ); }
289  inline void SetLocationX(double x) { vXYZ(eX) = x; }
290  inline void SetLocationY(double y) { vXYZ(eY) = y; }
291  inline void SetLocationZ(double z) { vXYZ(eZ) = z; }
292 
293  double GetStandpipe(void) const {return Standpipe;}
294 
295  int GetPriority(void) const {return Priority;}
296  void SetPriority(int p) { Priority = p; Selected = p>0 ? true:false; }
297 
298  double GetDensity(void) const {return Density;}
299  void SetDensity(double d) { Density = d; }
300 
301  double GetExternalFlow(void) const {return ExternalFlow;}
302  void SetExternalFlow(double f) { ExternalFlow = f; }
303 
304  FGColumnVector3 GetXYZ(void) const;
305  double GetXYZ(int idx) const;
306 
307  const GrainType GetGrainType(void) const {return grainType;}
308 
309  double Fill(double amount);
310  void SetContents(double amount);
311  void SetContentsGallons(double gallons);
312  void SetTemperature(double temp) { Temperature = temp; }
313  void SetStandpipe(double amount) { Standpipe = amount; }
314  void SetSelected(bool sel) { sel==true ? SetPriority(1):SetPriority(0); }
315 
316 private:
317  TankType Type;
318  GrainType grainType;
319  int TankNumber;
320  std::string type;
321  std::string strGType;
322  double ixx_unit;
323  double iyy_unit;
324  double izz_unit;
325  FGColumnVector3 vXYZ;
326  FGColumnVector3 vXYZ_drain;
327  FGFunction* function_ixx;
328  FGFunction* function_iyy;
329  FGFunction* function_izz;
330  double Capacity;
331  double Radius;
332  double InnerRadius;
333  double Length;
334  double Volume;
335  double Density;
336  double Ixx;
337  double Iyy;
338  double Izz;
339  double InertiaFactor;
340  double PctFull;
341  double Contents, InitialContents;
342  double Area;
343  double Temperature, InitialTemperature;
344  double Standpipe, InitialStandpipe;
345  double ExternalFlow;
346  bool Selected;
347  int Priority, InitialPriority;
348 
349  void CalculateInertias(void);
350  void bind(FGPropertyManager* PropertyManager);
351  void Debug(int from);
352 };
353 }
354 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
355 #endif
356 
bool GetSelected(void) const
If the tank is set to supply fuel, this function returns true.
Definition: FGTank.h:242
FGTank(FGFDMExec *exec, Element *el, int tank_number)
Constructor.
Definition: FGTank.cpp:58
static double CelsiusToFahrenheit(double celsius)
Converts from degrees Celsius to degrees Fahrenheit.
Definition: FGJSBBase.h:239
double GetTemperature_degC(void) const
Gets the temperature of the fuel.
Definition: FGTank.h:269
~FGTank()
Destructor.
Definition: FGTank.cpp:226
double GetContentsGallons(void) const
Gets the contents of the tank.
Definition: FGTank.h:262
Models a fuel tank.
Definition: FGTank.h:200
double GetTemperature(void) const
Gets the temperature of the fuel.
Definition: FGTank.h:276
JSBSim Base class.
Definition: FGJSBBase.h:80
double Calculate(double dt, double TempC)
Performs local, tanks-specific calculations, such as fuel temperature.
Definition: FGTank.cpp:325
double GetContents(void) const
Gets the contents of the tank.
Definition: FGTank.h:258
Represents a mathematical function.
Definition: FGFunction.h:699
double GetCapacity(void) const
Gets the capacity of the tank.
Definition: FGTank.h:250
int GetType(void) const
Retrieves the type of tank: Fuel or Oxidizer.
Definition: FGTank.h:235
This class implements a 3 element column vector.
double ProcessFuelName(const std::string &name)
Returns the density of a named fuel type.
Definition: FGTank.cpp:410
double GetCapacityGallons(void) const
Gets the capacity of the tank.
Definition: FGTank.h:254
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:189
double GetPctFull(void) const
Gets the tank fill level.
Definition: FGTank.h:246
double Drain(double used)
Removes fuel from the tank.
Definition: FGTank.cpp:259
void ResetToIC(void)
Resets the tank parameters to the initial conditions.
Definition: FGTank.cpp:233