JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
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
11  Software Foundation; either version 2 of the License, or (at your option) any
12  later 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
20  with this program; if not, write to the Free Software Foundation, Inc., 59
21  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23  Further information about the GNU Lesser General Public License can also be
24  found on 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 
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 FORWARD DECLARATIONS
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53 
54 namespace JSBSim {
55 
56 class Element;
57 class FGPropertyManager;
58 class FGFDMExec;
59 class FGFunction;
60 
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 CLASS DOCUMENTATION
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64 
197 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
198 CLASS DECLARATION
199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
200 
201 class FGTank : public FGJSBBase
202 {
203 public:
211  FGTank(FGFDMExec* exec, Element* el, int tank_number);
213  ~FGTank();
214 
215  enum TankType {ttUNKNOWN, ttFUEL, ttOXIDIZER};
216  enum GrainType {gtUNKNOWN, gtCYLINDRICAL, gtENDBURNING, gtFUNCTION};
217 
224  double Drain(double used);
225 
232  double Calculate(double dt, double TempC);
233 
237  int GetType(void) const {return Type;}
238 
240  void ResetToIC(void);
241 
244  bool GetSelected(void) const {return Selected;}
245 
248  double GetPctFull(void) const {return PctFull;}
249 
252  double GetCapacity(void) const {return Capacity;}
253 
256  double GetCapacityGallons(void) const {return Capacity/Density;}
257 
260  double GetContents(void) const {return Contents;}
261 
264  double GetContentsGallons(void) const {return Contents/Density;}
265 
271  double GetTemperature_degC(void) const {return Temperature;}
272 
278  double GetTemperature(void) const {return CelsiusToFahrenheit(Temperature);}
279 
282  double ProcessFuelName(const std::string& name);
283 
286  double GetUnusable(void) const {return UnusableVol*Density;}
287 
290  double GetUnusableVolume(void) const {return UnusableVol;}
291 
294  void SetUnusableVolume(double volume) {UnusableVol = volume;}
295 
296  double GetIxx(void) const {return Ixx;}
297  double GetIyy(void) const {return Iyy;}
298  double GetIzz(void) const {return Izz;}
299 
300  inline double GetLocationX(void) const { return vXYZ(eX); }
301  inline double GetLocationY(void) const { return vXYZ(eY); }
302  inline double GetLocationZ(void) const { return vXYZ(eZ); }
303  inline void SetLocationX(double x) { vXYZ(eX) = x; }
304  inline void SetLocationY(double y) { vXYZ(eY) = y; }
305  inline void SetLocationZ(double z) { vXYZ(eZ) = z; }
306 
307  double GetStandpipe(void) const {return Standpipe;}
308 
309  int GetPriority(void) const {return Priority;}
310  void SetPriority(int p) { Priority = p; Selected = p>0 ? true:false; }
311 
314  double GetDensity(void) const {return Density;}
317  void SetDensity(double d) { Density = d; }
318 
319  double GetExternalFlow(void) const {return ExternalFlow;}
320  void SetExternalFlow(double f) { ExternalFlow = f; }
321 
322  FGColumnVector3 GetXYZ(void) const;
323  double GetXYZ(int idx) const;
324 
325  GrainType GetGrainType(void) const {return grainType;}
326 
327  double Fill(double amount);
328  void SetContents(double amount);
329  void SetContentsGallons(double gallons);
330  void SetTemperature(double temp) { Temperature = temp; }
331  void SetStandpipe(double amount) { Standpipe = amount; }
332  void SetSelected(bool sel) { sel==true ? SetPriority(1):SetPriority(0); }
333 
334 private:
335  TankType Type;
336  GrainType grainType;
337  int TankNumber;
338  std::string type;
339  std::string strGType;
340  double ixx_unit;
341  double iyy_unit;
342  double izz_unit;
343  FGColumnVector3 vXYZ;
344  FGColumnVector3 vXYZ_drain;
345  FGFunction* function_ixx;
346  FGFunction* function_iyy;
347  FGFunction* function_izz;
348  double Capacity, UnusableVol;
349  double Radius;
350  double InnerRadius;
351  double Length;
352  double Volume;
353  double Density;
354  double Ixx;
355  double Iyy;
356  double Izz;
357  double InertiaFactor;
358  double PctFull;
359  double Contents, InitialContents;
360  double Area;
361  double Temperature, InitialTemperature;
362  double Standpipe, InitialStandpipe;
363  double ExternalFlow;
364  bool Selected;
365  int Priority, InitialPriority;
366 
367  void CalculateInertias(void);
368  void bind(FGPropertyManager* PropertyManager);
369  void Debug(int from);
370 };
371 }
372 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
373 #endif
JSBSim::FGFDMExec
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:185
JSBSim::FGTank::GetTemperature
double GetTemperature(void) const
Gets the temperature of the fuel.
Definition: FGTank.h:278
JSBSim::FGTank::SetUnusableVolume
void SetUnusableVolume(double volume)
Sets the volume of unusable fuel in the tank.
Definition: FGTank.h:294
JSBSim::FGTank::GetContents
double GetContents(void) const
Gets the contents of the tank.
Definition: FGTank.h:260
JSBSim::FGTank::GetType
int GetType(void) const
Retrieves the type of tank: Fuel or Oxidizer.
Definition: FGTank.h:237
JSBSim::FGTank::Calculate
double Calculate(double dt, double TempC)
Performs local, tanks-specific calculations, such as fuel temperature.
Definition: FGTank.cpp:331
JSBSim::FGTank::GetUnusable
double GetUnusable(void) const
Returns the amount of unusable fuel in the tank.
Definition: FGTank.h:286
JSBSim::FGTank::GetCapacity
double GetCapacity(void) const
Gets the capacity of the tank.
Definition: FGTank.h:252
JSBSim::FGTank::GetCapacityGallons
double GetCapacityGallons(void) const
Gets the capacity of the tank.
Definition: FGTank.h:256
JSBSim::FGTank
Models a fuel tank.
Definition: FGTank.h:201
JSBSim::FGTank::ProcessFuelName
double ProcessFuelName(const std::string &name)
Returns the density of a named fuel type.
Definition: FGTank.cpp:419
JSBSim::FGTank::GetPctFull
double GetPctFull(void) const
Gets the tank fill level.
Definition: FGTank.h:248
JSBSim::FGTank::Drain
double Drain(double used)
Removes fuel from the tank.
Definition: FGTank.cpp:266
JSBSim::FGTank::SetDensity
void SetDensity(double d)
Sets the fuel density.
Definition: FGTank.h:317
JSBSim::FGJSBBase
JSBSim Base class.
Definition: FGJSBBase.h:78
JSBSim::FGTank::GetSelected
bool GetSelected(void) const
If the tank is set to supply fuel, this function returns true.
Definition: FGTank.h:244
JSBSim::FGTank::ResetToIC
void ResetToIC(void)
Resets the tank parameters to the initial conditions.
Definition: FGTank.cpp:240
JSBSim::FGTank::GetUnusableVolume
double GetUnusableVolume(void) const
Returns the unusable volume of fuel in the tank.
Definition: FGTank.h:290
JSBSim::FGTank::FGTank
FGTank(FGFDMExec *exec, Element *el, int tank_number)
Constructor.
Definition: FGTank.cpp:51
JSBSim::FGJSBBase::CelsiusToFahrenheit
static constexpr double CelsiusToFahrenheit(double celsius)
Converts from degrees Celsius to degrees Fahrenheit.
Definition: FGJSBBase.h:237
JSBSim::FGTank::~FGTank
~FGTank()
Destructor.
Definition: FGTank.cpp:233
JSBSim::FGTank::GetDensity
double GetDensity(void) const
Returns the fuel density.
Definition: FGTank.h:314
JSBSim::FGTank::GetTemperature_degC
double GetTemperature_degC(void) const
Gets the temperature of the fuel.
Definition: FGTank.h:271
JSBSim::FGTank::GetContentsGallons
double GetContentsGallons(void) const
Gets the contents of the tank.
Definition: FGTank.h:264
JSBSim::Element
Definition: FGXMLElement.h:143