JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
An Open Source Flight Dynamics and Control Software Library in C++
FGTank Class Reference

Detailed Description

Models a fuel tank.

Fuel Temperature:

Fuel temperature is calculated using the following assumptions:

Fuel temperature will only be calculated for tanks which have an initial
fuel temperature specified in the configuration file.

The surface area of the tank is estimated from the capacity in pounds.  It
is assumed that the tank is a wing tank with dimensions h by 4h by 10h. The
volume of the tank is then 40(h)(h)(h). The area of the upper or lower 
surface is then 40(h)(h).  The volume is also equal to the capacity divided
by 49.368 lbs/cu-ft, for jet fuel.  The surface area of one side can then be
derived from the tank's capacity.  

The heat capacity of jet fuel is assumed to be 900 Joules/lbm/K, and the 
heat transfer factor of the tank is 1.115 Watts/sq-ft/K.

Fuel Dump:

Fuel dumping is handled by the FGPropulsion class.  A standpipe can be
defined here for each tank which sets the level of contents (in pounds)
which is not dumpable.  Default standpipe level is zero, making all contents
dumpable.

Fuel Transfer:

Fuel transfer is handled by the FGPropulsion class, however the contents of
tanks may be manipulated directly using the SetContents() function here, or
via the property tree at <tt>propulsion/tank[i]/contents-lbs</tt>, where i
is the tank number (Tanks are automatically numbered, starting at zero, in
the order in which they are read in the aircraft configuration file).  The
latter method allows one to use a system of FCS components to control tank
contents.

There is also a property
<tt>propulsion/tank[i]/external-flow-rate-pps</tt>. Setting this property to
a positive value causes the tank to fill at the rate specified.  Setting a
negative number causes the tank to drain. The value is the rate in pounds of
fuel per second. The tank will not fill past 100% full and will not drain
below 0%.  Fuel may be transfered between two tanks by setting the source
tank's external flow rate to a negative value and the destination's external
flow rate to the same positive value.  Care must be taken to stop fuel flow
before the source tank becomes empty to prevent phantom fuel being created.

Configuration File Format:

<tank type="{FUEL | OXIDIZER}">
<grain_config type="{CYLINDRICAL | ENDBURNING | FUNCTION}">
<length unit="{IN | FT | M}"> {number} </length>
<bore_diameter unit="{IN | FT | M}"> {number} </bore_diameter>
[<ixx unit="{IN | FT | M}"> {function} </ixx>
<iyy unit="{IN | FT | M}"> {function} </iyy>
<izz unit="{IN | FT | M}"> {function} </izz>]
</grain_config>
<location unit="{FT | M | IN}">
<x> {number} </x>
<y> {number} </y>
<z> {number} </z>
</location>
<drain_location unit="{FT | M | IN}">
<x> {number} </x>
<y> {number} </y>
<z> {number} </z>
</drain_location>
<radius unit="{IN | FT | M}"> {number} </radius>
<capacity unit="{LBS | KG}"> {number} </capacity>
<inertia_factor> {number:0-1} </inertia_factor>
<contents unit="{LBS | KG}"> {number} </contents>
<temperature> {number} </temperature> <!-- must be degrees fahrenheit -->
<standpipe unit="{LBS | KG"}> {number} </standpipe>
<unusable unit="{GAL | LTR | M3 | IN3 | FT3 | CC}"> {number} </unusable>
<priority> {integer} </priority>
<density unit="{KG/L | LBS/GAL}"> {number} </density>
<type> {string} </type> <!-- will override previous density setting -->
</tank>

Definition of the tank configuration file parameters:

  • type - One of FUEL or OXIDIZER. This is required.
  • radius - Equivalent radius of tank for modeling slosh, defaults to inches.
  • grain_config type - One of CYLINDRICAL or ENDBURNING.
  • length - length of tank for modeling solid fuel propellant grain, defaults to inches.
  • capacity - Capacity, defaults to pounds.
  • contents - Initial contents, defaults to pounds.
  • temperature - Initial temperature, defaults to degrees Fahrenheit.
  • standpipe - Minimum contents to which tank can dump, defaults to pounds.
  • unusable - Contents that cannot be used for combustion in the engine, defaults to gallons.
  • priority - Establishes feed sequence of tank. "1" is the highest priority.
  • density - Density of liquid tank contents.
  • type - Named fuel type. One of AVGAS, JET-A, JET-A1, JET-B, JP-1, JP-2, JP-3, JP-4, JP-5, JP-6, JP-7, JP-8, JP-8+100, RP-1, T-1, ETHANOL, HYDRAZINE, F-34, F-35, F-40, F-44, AVTAG, AVCAT

location:

  • x - Location of tank on aircraft's x-axis, defaults to inches.
  • y - Location of tank on aircraft's y-axis, defaults to inches.
  • z - Location of tank on aircraft's z-axis, defaults to inches.

drain_location:

  • x - Location of tank drain on aircraft's x-axis, defaults to inches.
  • y - Location of tank drain on aircraft's y-axis, defaults to inches.
  • z - Location of tank drain on aircraft's z-axis, defaults to inches.

Default values of the tank configuration file parameters:

  • type - ttUNKNOWN (causes a load error in the propulsion configuration)
  • location, drain_location - both optional, but a warning message will be printed to the console if the location is not given
  • x - 0.0 (both full and drained CG locations)
  • y - 0.0 (both full and drained CG locations)
  • z - 0.0 (both full and drained CG locations)
  • radius - 0.0
  • capacity - 0.00001 (tank capacity must not be zero)
  • contents - 0.0
  • temperature - -9999.0 (flag which indicates no temperature is set)
  • standpipe - 0.0 (all contents may be dumped)
  • unusable - 0.0 (all contents may be burnt)
  • priority - 1 (highest feed sequence priority)
  • density - 6.6

    Author
    Jon Berndt, Dave Culp
    See also
    Akbar, Raza et al. "A Simple Analysis of Fuel Addition to the CWT of 747", California Institute of Technology, 1998, http://www.galcit.caltech.edu/EDL/projects/JetA/reports/lumped.pdf

Definition at line 201 of file FGTank.h.

#include <FGTank.h>

+ Inheritance diagram for FGTank:
+ Collaboration diagram for FGTank:

Public Types

enum  GrainType { gtUNKNOWN, gtCYLINDRICAL, gtENDBURNING, gtFUNCTION }
 
enum  TankType { ttUNKNOWN, ttFUEL, ttOXIDIZER }
 
- Public Types inherited from FGJSBBase
enum  { eL = 1, eM, eN }
 Moments L, M, N.
 
enum  { eP = 1, eQ, eR }
 Rates P, Q, R.
 
enum  { eU = 1, eV, eW }
 Velocities U, V, W.
 
enum  { eX = 1, eY, eZ }
 Positions X, Y, Z.
 
enum  { ePhi = 1, eTht, ePsi }
 Euler angles Phi, Theta, Psi.
 
enum  { eDrag = 1, eSide, eLift }
 Stability axis forces, Drag, Side force, Lift.
 
enum  { eRoll = 1, ePitch, eYaw }
 Local frame orientation Roll, Pitch, Yaw.
 
enum  { eNorth = 1, eEast, eDown }
 Local frame position North, East, Down.
 
enum  { eLat = 1, eLong, eRad }
 Locations Radius, Latitude, Longitude.
 
enum  {
  inNone = 0, inDegrees, inRadians, inMeters,
  inFeet
}
 Conversion specifiers.
 

Public Member Functions

 FGTank (FGFDMExec *exec, Element *el, int tank_number)
 Constructor. More...
 
 ~FGTank ()
 Destructor.
 
double Calculate (double dt, double TempC)
 Performs local, tanks-specific calculations, such as fuel temperature. More...
 
double Drain (double used)
 Removes fuel from the tank. More...
 
double Fill (double amount)
 
double GetCapacity (void) const
 Gets the capacity of the tank. More...
 
double GetCapacityGallons (void) const
 Gets the capacity of the tank. More...
 
double GetContents (void) const
 Gets the contents of the tank. More...
 
double GetContentsGallons (void) const
 Gets the contents of the tank. More...
 
double GetDensity (void) const
 Returns the fuel density. More...
 
double GetExternalFlow (void) const
 
GrainType GetGrainType (void) const
 
double GetIxx (void) const
 
double GetIyy (void) const
 
double GetIzz (void) const
 
double GetLocationX (void) const
 
double GetLocationY (void) const
 
double GetLocationZ (void) const
 
double GetPctFull (void) const
 Gets the tank fill level. More...
 
int GetPriority (void) const
 
bool GetSelected (void) const
 If the tank is set to supply fuel, this function returns true. More...
 
double GetStandpipe (void) const
 
double GetTemperature (void) const
 Gets the temperature of the fuel. More...
 
double GetTemperature_degC (void) const
 Gets the temperature of the fuel. More...
 
int GetType (void) const
 Retrieves the type of tank: Fuel or Oxidizer. More...
 
double GetUnusable (void) const
 Returns the amount of unusable fuel in the tank. More...
 
double GetUnusableVolume (void) const
 Returns the unusable volume of fuel in the tank. More...
 
double GetXYZ (int idx) const
 
FGColumnVector3 GetXYZ (void) const
 
double ProcessFuelName (const std::string &name)
 Returns the density of a named fuel type. More...
 
void ResetToIC (void)
 Resets the tank parameters to the initial conditions.
 
void SetContents (double amount)
 
void SetContentsGallons (double gallons)
 
void SetDensity (double d)
 Sets the fuel density. More...
 
void SetExternalFlow (double f)
 
void SetLocationX (double x)
 
void SetLocationY (double y)
 
void SetLocationZ (double z)
 
void SetPriority (int p)
 
void SetSelected (bool sel)
 
void SetStandpipe (double amount)
 
void SetTemperature (double temp)
 
void SetUnusableVolume (double volume)
 Sets the volume of unusable fuel in the tank. More...
 
- Public Member Functions inherited from FGJSBBase
 FGJSBBase ()
 Constructor for FGJSBBase.
 
virtual ~FGJSBBase ()
 Destructor for FGJSBBase.
 
void PutMessage (const Message &msg)
 Places a Message structure on the Message queue. More...
 
void PutMessage (const std::string &text)
 Creates a message with the given text and places it on the queue. More...
 
void PutMessage (const std::string &text, bool bVal)
 Creates a message with the given text and boolean value and places it on the queue. More...
 
void PutMessage (const std::string &text, int iVal)
 Creates a message with the given text and integer value and places it on the queue. More...
 
void PutMessage (const std::string &text, double dVal)
 Creates a message with the given text and double value and places it on the queue. More...
 
int SomeMessages (void) const
 Reads the message on the queue (but does not delete it). More...
 
void ProcessMessage (void)
 Reads the message on the queue and removes it from the queue. More...
 
MessageProcessNextMessage (void)
 Reads the next message on the queue and removes it from the queue. More...
 
void disableHighLighting (void)
 Disables highlighting in the console output.
 

Additional Inherited Members

- Static Public Member Functions inherited from FGJSBBase
static const std::string & GetVersion (void)
 Returns the version number of JSBSim. More...
 
static constexpr double KelvinToFahrenheit (double kelvin)
 Converts from degrees Kelvin to degrees Fahrenheit. More...
 
static constexpr double CelsiusToRankine (double celsius)
 Converts from degrees Celsius to degrees Rankine. More...
 
static constexpr double RankineToCelsius (double rankine)
 Converts from degrees Rankine to degrees Celsius. More...
 
static constexpr double KelvinToRankine (double kelvin)
 Converts from degrees Kelvin to degrees Rankine. More...
 
static constexpr double RankineToKelvin (double rankine)
 Converts from degrees Rankine to degrees Kelvin. More...
 
static constexpr double FahrenheitToCelsius (double fahrenheit)
 Converts from degrees Fahrenheit to degrees Celsius. More...
 
static constexpr double CelsiusToFahrenheit (double celsius)
 Converts from degrees Celsius to degrees Fahrenheit. More...
 
static constexpr double CelsiusToKelvin (double celsius)
 Converts from degrees Celsius to degrees Kelvin. More...
 
static constexpr double KelvinToCelsius (double kelvin)
 Converts from degrees Kelvin to degrees Celsius. More...
 
static constexpr double FeetToMeters (double measure)
 Converts from feet to meters. More...
 
static double PitotTotalPressure (double mach, double p)
 Compute the total pressure in front of the Pitot tube. More...
 
static double MachFromImpactPressure (double qc, double p)
 Compute the Mach number from the differential pressure (qc) and the static pressure. More...
 
static double VcalibratedFromMach (double mach, double p)
 Calculate the calibrated airspeed from the Mach number. More...
 
static double MachFromVcalibrated (double vcas, double p)
 Calculate the Mach number from the calibrated airspeed.Based on the formulas in the US Air Force Aircraft Performance Flight Testing Manual (AFFTC-TIH-99-01). More...
 
static bool EqualToRoundoff (double a, double b)
 Finite precision comparison. More...
 
static bool EqualToRoundoff (float a, float b)
 Finite precision comparison. More...
 
static bool EqualToRoundoff (float a, double b)
 Finite precision comparison. More...
 
static bool EqualToRoundoff (double a, float b)
 Finite precision comparison. More...
 
static constexpr double Constrain (double min, double value, double max)
 Constrain a value between a minimum and a maximum value.
 
static constexpr double sign (double num)
 
static double GaussianRandomNumber (void)
 
- Static Public Attributes inherited from FGJSBBase
static char highint [5] = {27, '[', '1', 'm', '\0' }
 highlights text
 
static char halfint [5] = {27, '[', '2', 'm', '\0' }
 low intensity text
 
static char normint [6] = {27, '[', '2', '2', 'm', '\0' }
 normal intensity text
 
static char reset [5] = {27, '[', '0', 'm', '\0' }
 resets text properties
 
static char underon [5] = {27, '[', '4', 'm', '\0' }
 underlines text
 
static char underoff [6] = {27, '[', '2', '4', 'm', '\0' }
 underline off
 
static char fgblue [6] = {27, '[', '3', '4', 'm', '\0' }
 blue text
 
static char fgcyan [6] = {27, '[', '3', '6', 'm', '\0' }
 cyan text
 
static char fgred [6] = {27, '[', '3', '1', 'm', '\0' }
 red text
 
static char fggreen [6] = {27, '[', '3', '2', 'm', '\0' }
 green text
 
static char fgdef [6] = {27, '[', '3', '9', 'm', '\0' }
 default text
 
static short debug_lvl = 1
 
- Static Protected Member Functions inherited from FGJSBBase
static std::string CreateIndexedPropertyName (const std::string &Property, int index)
 
- Static Protected Attributes inherited from FGJSBBase
static Message localMsg
 
static std::queue< MessageMessages
 
static unsigned int messageId = 0
 
static constexpr double radtodeg = 180. / M_PI
 
static constexpr double degtorad = M_PI / 180.
 
static constexpr double hptoftlbssec = 550.0
 
static constexpr double psftoinhg = 0.014138
 
static constexpr double psftopa = 47.88
 
static constexpr double ktstofps = 1.68781
 
static constexpr double fpstokts = 1.0 / ktstofps
 
static constexpr double inchtoft = 1.0/12.0
 
static constexpr double fttom = 0.3048
 
static constexpr double m3toft3 = 1.0/(fttom*fttom*fttom)
 
static constexpr double in3tom3 = inchtoft*inchtoft*inchtoft/m3toft3
 
static constexpr double inhgtopa = 3386.38
 
static constexpr double slugtolb = 32.174049
 Note that definition of lbtoslug by the inverse of slugtolb and not to a different constant you can also get from some tables will make lbtoslug*slugtolb == 1 up to the magnitude of roundoff. More...
 
static constexpr double lbtoslug = 1.0/slugtolb
 
static constexpr double kgtolb = 2.20462
 
static constexpr double kgtoslug = 0.06852168
 
static const std::string needed_cfg_version = "2.0"
 
static const std::string JSBSim_version = JSBSIM_VERSION " " __DATE__ " " __TIME__
 
static int gaussian_random_number_phase = 0
 

Constructor & Destructor Documentation

◆ FGTank()

FGTank ( FGFDMExec exec,
Element el,
int  tank_number 
)

Constructor.

The constructor reads in the defining parameters from a configuration file.

Parameters
execa pointer to the base FGFDMExec instance.
ela pointer to the Tank element.
tank_numberthe tank number (zero based).

Definition at line 51 of file FGTank.cpp.

52  : TankNumber(tank_number)
53 {
54  string token, strFuelName;
55  Element* element;
56  Element* element_Grain;
57  FGPropertyManager *PropertyManager = exec->GetPropertyManager();
58  Area = 1.0;
59  Density = 6.6;
60  InitialTemperature = Temperature = -9999.0;
61  Ixx = Iyy = Izz = 0.0;
62  InertiaFactor = 1.0;
63  Radius = Contents = Standpipe = Length = InnerRadius = 0.0;
64  ExternalFlow = 0.0;
65  InitialStandpipe = 0.0;
66  Capacity = 0.00001; UnusableVol = 0.0;
67  Priority = InitialPriority = 1;
68  vXYZ.InitMatrix();
69  vXYZ_drain.InitMatrix();
70  ixx_unit = iyy_unit = izz_unit = 1.0;
71  grainType = gtUNKNOWN; // This is the default
72 
73  type = el->GetAttributeValue("type");
74  if (type == "FUEL") Type = ttFUEL;
75  else if (type == "OXIDIZER") Type = ttOXIDIZER;
76  else Type = ttUNKNOWN;
77 
78  element = el->FindElement("location");
79  if (element) vXYZ = element->FindElementTripletConvertTo("IN");
80  else cerr << el->ReadFrom() << "No location found for this tank."
81  << endl;
82 
83  vXYZ_drain = vXYZ; // Set initial drain location to initial tank CG
84 
85  element = el->FindElement("drain_location");
86  if (element) {
87  vXYZ_drain = element->FindElementTripletConvertTo("IN");
88  }
89 
90  if (el->FindElement("radius"))
91  Radius = el->FindElementValueAsNumberConvertTo("radius", "IN");
92  if (el->FindElement("inertia_factor"))
93  InertiaFactor = el->FindElementValueAsNumber("inertia_factor");
94  if (el->FindElement("capacity"))
95  Capacity = el->FindElementValueAsNumberConvertTo("capacity", "LBS");
96  if (el->FindElement("contents"))
97  InitialContents = Contents = el->FindElementValueAsNumberConvertTo("contents", "LBS");
98  if (el->FindElement("unusable-volume"))
99  UnusableVol = el->FindElementValueAsNumberConvertTo("unusable-volume", "GAL");
100  if (el->FindElement("temperature"))
101  InitialTemperature = Temperature = el->FindElementValueAsNumber("temperature");
102  if (el->FindElement("standpipe"))
103  InitialStandpipe = Standpipe = el->FindElementValueAsNumberConvertTo("standpipe", "LBS");
104  if (el->FindElement("priority"))
105  InitialPriority = Priority = (int)el->FindElementValueAsNumber("priority");
106  if (el->FindElement("density"))
107  Density = el->FindElementValueAsNumberConvertTo("density", "LBS/GAL");
108  if (el->FindElement("type"))
109  strFuelName = el->FindElementValue("type");
110 
111 
112  SetPriority( InitialPriority ); // this will also set the Selected flag
113 
114  if (Capacity == 0) {
115  cerr << el->ReadFrom()
116  << "Tank capacity must not be zero. Reset to 0.00001 lbs!" << endl;
117  Capacity = 0.00001;
118  Contents = 0.0;
119  }
120  if (Capacity <= GetUnusable()) {
121  cerr << el->ReadFrom() << "Tank capacity (" << Capacity
122  << " lbs) is lower than the amount of unusable fuel (" << GetUnusable()
123  << " lbs) for tank " << tank_number
124  << "! Did you accidentally swap unusable and capacity?" << endl;
125  throw("tank definition error");
126  }
127  if (Contents > Capacity) {
128  cerr << el->ReadFrom() << "Tank content (" << Contents
129  << " lbs) is greater than tank capacity (" << Capacity
130  << " lbs) for tank " << tank_number
131  << "! Did you accidentally swap contents and capacity?" << endl;
132  throw("tank definition error");
133  }
134  if (Contents < GetUnusable()) {
135  cerr << el->ReadFrom() << "Tank content (" << Contents
136  << " lbs) is lower than the amount of unusable fuel (" << GetUnusable()
137  << " lbs) for tank " << tank_number << endl;
138  }
139 
140  PctFull = 100.0*Contents/Capacity; // percent full; 0 to 100.0
141 
142  // Check whether this is a solid propellant "tank". Initialize it if true.
143 
144  element_Grain = el->FindElement("grain_config");
145  if (element_Grain) {
146 
147  strGType = element_Grain->GetAttributeValue("type");
148  if (strGType == "CYLINDRICAL") grainType = gtCYLINDRICAL;
149  else if (strGType == "ENDBURNING") grainType = gtENDBURNING;
150  else if (strGType == "FUNCTION") {
151  grainType = gtFUNCTION;
152  if (element_Grain->FindElement("ixx") != 0) {
153  Element* element_ixx = element_Grain->FindElement("ixx");
154  if (element_ixx->GetAttributeValue("unit") == "KG*M2") ixx_unit = 1.0/1.35594;
155  if (element_ixx->FindElement("function") != 0) {
156  function_ixx = new FGFunction(exec, element_ixx->FindElement("function"));
157  }
158  } else {
159  throw("For tank "+to_string(TankNumber)+" and when grain_config is specified an ixx must be specified when the FUNCTION grain type is specified.");
160  }
161 
162  if (element_Grain->FindElement("iyy")) {
163  Element* element_iyy = element_Grain->FindElement("iyy");
164  if (element_iyy->GetAttributeValue("unit") == "KG*M2") iyy_unit = 1.0/1.35594;
165  if (element_iyy->FindElement("function") != 0) {
166  function_iyy = new FGFunction(exec, element_iyy->FindElement("function"));
167  }
168  } else {
169  throw("For tank "+to_string(TankNumber)+" and when grain_config is specified an iyy must be specified when the FUNCTION grain type is specified.");
170  }
171 
172  if (element_Grain->FindElement("izz")) {
173  Element* element_izz = element_Grain->FindElement("izz");
174  if (element_izz->GetAttributeValue("unit") == "KG*M2") izz_unit = 1.0/1.35594;
175  if (element_izz->FindElement("function") != 0) {
176  function_izz = new FGFunction(exec, element_izz->FindElement("function"));
177  }
178  } else {
179  throw("For tank "+to_string(TankNumber)+" and when grain_config is specified an izz must be specified when the FUNCTION grain type is specified.");
180  }
181  }
182  else
183  cerr << el->ReadFrom() << "Unknown propellant grain type specified"
184  << endl;
185 
186  if (element_Grain->FindElement("length"))
187  Length = element_Grain->FindElementValueAsNumberConvertTo("length", "IN");
188  if (element_Grain->FindElement("bore_diameter"))
189  InnerRadius = element_Grain->FindElementValueAsNumberConvertTo("bore_diameter", "IN")/2.0;
190 
191  // Initialize solid propellant values for debug and runtime use.
192 
193  switch (grainType) {
194  case gtCYLINDRICAL:
195  if (Radius <= InnerRadius) {
196  const string s("The bore diameter should be smaller than the total grain diameter!");
197  cerr << element_Grain->ReadFrom() << endl << s << endl;
198  throw BaseException(s);
199  }
200  Volume = M_PI * Length * (Radius*Radius - InnerRadius*InnerRadius); // cubic inches
201  break;
202  case gtENDBURNING:
203  Volume = M_PI * Length * Radius * Radius; // cubic inches
204  break;
205  case gtFUNCTION:
206  Volume = 1; // Volume is irrelevant for the FUNCTION type, but it can't be zero!
207  break;
208  case gtUNKNOWN:
209  {
210  const string s("Unknown grain type found in this rocket engine definition.");
211  cerr << el->ReadFrom() << endl << s << endl;
212  throw BaseException(s);
213  }
214  }
215  Density = (Capacity*lbtoslug)/Volume; // slugs/in^3
216  }
217 
218  CalculateInertias();
219 
220  if (Temperature != -9999.0) InitialTemperature = Temperature = FahrenheitToCelsius(Temperature);
221  Area = 40.0 * pow(Capacity/1975, 0.666666667);
222 
223  // A named fuel type will override a previous density value
224  if (!strFuelName.empty()) Density = ProcessFuelName(strFuelName);
225 
226  bind(PropertyManager);
227 
228  Debug(0);
229 }
+ Here is the call graph for this function:

Member Function Documentation

◆ Calculate()

double Calculate ( double  dt,
double  TempC 
)

Performs local, tanks-specific calculations, such as fuel temperature.

This function calculates the temperature of the fuel in the tank.

Parameters
dtthe time step for this model.
TempCthe Total Air Temperature in degrees Celsius.
Returns
the current temperature in degrees Celsius.

Definition at line 331 of file FGTank.cpp.

332 {
333  if(ExternalFlow < 0.) Drain( -ExternalFlow *dt);
334  else Fill(ExternalFlow * dt);
335 
336  if (Temperature == -9999.0) return 0.0;
337  double HeatCapacity = 900.0; // Joules/lbm/C
338  double TempFlowFactor = 1.115; // Watts/sqft/C
339  double Tdiff = TAT_C - Temperature;
340  double dTemp = 0.0; // Temp change due to one surface
341  if (fabs(Tdiff) > 0.1 && Contents > 0.01) {
342  dTemp = (TempFlowFactor * Area * Tdiff * dt) / (Contents * HeatCapacity);
343  }
344 
345  return Temperature += (dTemp + dTemp); // For now, assume upper/lower the same
346 }
+ Here is the call graph for this function:

◆ Drain()

double Drain ( double  used)

Removes fuel from the tank.

This function removes fuel from a tank. If the tank empties, it is deselected.

Parameters
usedthe amount of fuel used in lbs.
Returns
the remaining contents of the tank in lbs.

Definition at line 266 of file FGTank.cpp.

267 {
268  double remaining = Contents - used;
269 
270  if (remaining >= GetUnusable()) { // Reduce contents by amount used.
271  Contents -= used;
272  } else { // This tank must be empty.
273  if (Contents > GetUnusable())
274  Contents = GetUnusable();
275 
276  remaining = Contents;
277  }
278 
279  PctFull = 100.0*Contents/Capacity;
280  CalculateInertias();
281 
282  return remaining;
283 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCapacity()

double GetCapacity ( void  ) const
inline

Gets the capacity of the tank.

Returns
the capacity of the tank in pounds.

Definition at line 252 of file FGTank.h.

252 {return Capacity;}

◆ GetCapacityGallons()

double GetCapacityGallons ( void  ) const
inline

Gets the capacity of the tank.

Returns
the capacity of the tank in gallons.

Definition at line 256 of file FGTank.h.

256 {return Capacity/Density;}

◆ GetContents()

double GetContents ( void  ) const
inline

Gets the contents of the tank.

Returns
the contents of the tank in pounds.

Definition at line 260 of file FGTank.h.

260 {return Contents;}

◆ GetContentsGallons()

double GetContentsGallons ( void  ) const
inline

Gets the contents of the tank.

Returns
the contents of the tank in gallons.

Definition at line 264 of file FGTank.h.

264 {return Contents/Density;}

◆ GetDensity()

double GetDensity ( void  ) const
inline

Returns the fuel density.

Returns
the density in lbs/gal.

Definition at line 314 of file FGTank.h.

314 {return Density;}

◆ GetPctFull()

double GetPctFull ( void  ) const
inline

Gets the tank fill level.

Returns
the fill level in percent, from 0 to 100.

Definition at line 248 of file FGTank.h.

248 {return PctFull;}

◆ GetSelected()

bool GetSelected ( void  ) const
inline

If the tank is set to supply fuel, this function returns true.

Returns
true if this tank is set to a non-zero priority.

Definition at line 244 of file FGTank.h.

244 {return Selected;}

◆ GetTemperature()

double GetTemperature ( void  ) const
inline

Gets the temperature of the fuel.

The temperature of the fuel is calculated if an initial tempearture is given in the configuration file.

Returns
the temperature of the fuel in degrees F IF an initial temperature is given, otherwise 32 degrees F is returned.

Definition at line 278 of file FGTank.h.

278 {return CelsiusToFahrenheit(Temperature);}
+ Here is the call graph for this function:

◆ GetTemperature_degC()

double GetTemperature_degC ( void  ) const
inline

Gets the temperature of the fuel.

The temperature of the fuel is calculated if an initial tempearture is given in the configuration file.

Returns
the temperature of the fuel in degrees C IF an initial temperature is given, otherwise 0.0 C is returned.

Definition at line 271 of file FGTank.h.

271 {return Temperature;}

◆ GetType()

int GetType ( void  ) const
inline

Retrieves the type of tank: Fuel or Oxidizer.

Returns
the tank type, 0 for undefined, 1 for fuel, and 2 for oxidizer.

Definition at line 237 of file FGTank.h.

237 {return Type;}

◆ GetUnusable()

double GetUnusable ( void  ) const
inline

Returns the amount of unusable fuel in the tank.

Returns
the amount in lbs.

Definition at line 286 of file FGTank.h.

286 {return UnusableVol*Density;}
+ Here is the caller graph for this function:

◆ GetUnusableVolume()

double GetUnusableVolume ( void  ) const
inline

Returns the unusable volume of fuel in the tank.

Returns
the volume in gal.

Definition at line 290 of file FGTank.h.

290 {return UnusableVol;}

◆ ProcessFuelName()

double ProcessFuelName ( const std::string &  name)

Returns the density of a named fuel type.

Returns
the density, in lbs/gal, or 6.6 if name cannot be resolved.

Definition at line 419 of file FGTank.cpp.

420 {
421  if (name == "AVGAS") return 6.02;
422  else if (name == "JET-A") return 6.74;
423  else if (name == "JET-A1") return 6.74;
424  else if (name == "JET-B") return 6.48;
425  else if (name == "JP-1") return 6.76;
426  else if (name == "JP-2") return 6.38;
427  else if (name == "JP-3") return 6.34;
428  else if (name == "JP-4") return 6.48;
429  else if (name == "JP-5") return 6.81;
430  else if (name == "JP-6") return 6.55;
431  else if (name == "JP-7") return 6.61;
432  else if (name == "JP-8") return 6.66;
433  else if (name == "JP-8+100") return 6.66;
434  //else if (name == "JP-9") return 6.74;
435  //else if (name == "JPTS") return 6.74;
436  else if (name == "RP-1") return 6.73;
437  else if (name == "T-1") return 6.88;
438  else if (name == "ETHANOL") return 6.58;
439  else if (name == "HYDRAZINE")return 8.61;
440  else if (name == "F-34") return 6.66;
441  else if (name == "F-35") return 6.74;
442  else if (name == "F-40") return 6.48;
443  else if (name == "F-44") return 6.81;
444  else if (name == "AVTAG") return 6.48;
445  else if (name == "AVCAT") return 6.81;
446  else {
447  cerr << "Unknown fuel type specified: "<< name << endl;
448  }
449 
450  return 6.6;
451 }
+ Here is the caller graph for this function:

◆ SetDensity()

void SetDensity ( double  d)
inline

Sets the fuel density.

Parameters
dthe density in lbs/gal.

Definition at line 317 of file FGTank.h.

317 { Density = d; }

◆ SetUnusableVolume()

void SetUnusableVolume ( double  volume)
inline

Sets the volume of unusable fuel in the tank.

Parameters
amountthe amount of unusable fuel in gal.

Definition at line 294 of file FGTank.h.

294 {UnusableVol = volume;}

The documentation for this class was generated from the following files:
JSBSim::FGJSBBase::FahrenheitToCelsius
static constexpr double FahrenheitToCelsius(double fahrenheit)
Converts from degrees Fahrenheit to degrees Celsius.
Definition: FGJSBBase.h:230
JSBSim::FGTank::GetUnusable
double GetUnusable(void) const
Returns the amount of unusable fuel in the tank.
Definition: FGTank.h:286
JSBSim::FGTank::ProcessFuelName
double ProcessFuelName(const std::string &name)
Returns the density of a named fuel type.
Definition: FGTank.cpp:419
JSBSim::FGTank::Drain
double Drain(double used)
Removes fuel from the tank.
Definition: FGTank.cpp:266
JSBSim::FGJSBBase::CelsiusToFahrenheit
static constexpr double CelsiusToFahrenheit(double celsius)
Converts from degrees Celsius to degrees Fahrenheit.
Definition: FGJSBBase.h:237