JSBSim Flight Dynamics Model 1.3.0 (09 Apr 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
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}" name="{string}">
<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.
  • name - Tank name for easier identification in the reports. Optional.
  • 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 202 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. More...
 
enum  { eP = 1 , eQ , eR }
 Rates P, Q, R. More...
 
enum  { eU = 1 , eV , eW }
 Velocities U, V, W. More...
 
enum  { eX = 1 , eY , eZ }
 Positions X, Y, Z. More...
 
enum  { ePhi = 1 , eTht , ePsi }
 Euler angles Phi, Theta, Psi. More...
 
enum  { eDrag = 1 , eSide , eLift }
 Stability axis forces, Drag, Side force, Lift. More...
 
enum  { eRoll = 1 , ePitch , eYaw }
 Local frame orientation Roll, Pitch, Yaw. More...
 
enum  { eNorth = 1 , eEast , eDown }
 Local frame position North, East, Down. More...
 
enum  { eLat = 1 , eLong , eRad }
 Locations Radius, Latitude, Longitude. More...
 
enum  {
  inNone = 0 , inDegrees , inRadians , inMeters ,
  inFeet
}
 Conversion specifiers. More...
 

Public Member Functions

 FGTank (FGFDMExec *exec, Element *el, int tank_number)
 Constructor.
 
 ~FGTank ()
 Destructor.
 
double Calculate (double dt, double TempC)
 Performs local, tanks-specific calculations, such as fuel temperature.
 
double Drain (double used)
 Removes fuel from the tank.
 
double Fill (double amount)
 
double GetCapacity (void) const
 Gets the capacity of the tank.
 
double GetCapacityGallons (void) const
 Gets the capacity of the tank.
 
double GetContents (void) const
 Gets the contents of the tank.
 
double GetContentsGallons (void) const
 Gets the contents of the tank.
 
double GetDensity (void) const
 Returns the fuel density.
 
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
 
const std::string & GetName (void) const
 Retrieves the tank name.
 
double GetPctFull (void) const
 Gets the tank fill level.
 
int GetPriority (void) const
 
bool GetSelected (void) const
 If the tank is set to supply fuel, this function returns true.
 
double GetStandpipe (void) const
 
double GetTemperature (void) const
 Gets the temperature of the fuel.
 
double GetTemperature_degC (void) const
 Gets the temperature of the fuel.
 
int GetType (void) const
 Retrieves the type of tank: Fuel or Oxidizer.
 
double GetUnusable (void) const
 Returns the amount of unusable fuel in the tank.
 
double GetUnusableVolume (void) const
 Returns the unusable volume of fuel in the tank.
 
double GetXYZ (int idx) const
 
FGColumnVector3 GetXYZ (void) const
 
double ProcessFuelName (const std::string &name)
 Returns the density of a named fuel type.
 
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.
 
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.
 
- Public Member Functions inherited from FGJSBBase
 FGJSBBase ()
 Constructor for FGJSBBase.
 
virtual ~FGJSBBase ()
 Destructor for FGJSBBase.
 
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.
 
static constexpr double KelvinToFahrenheit (double kelvin)
 Converts from degrees Kelvin to degrees Fahrenheit.
 
static constexpr double CelsiusToRankine (double celsius)
 Converts from degrees Celsius to degrees Rankine.
 
static constexpr double RankineToCelsius (double rankine)
 Converts from degrees Rankine to degrees Celsius.
 
static constexpr double KelvinToRankine (double kelvin)
 Converts from degrees Kelvin to degrees Rankine.
 
static constexpr double RankineToKelvin (double rankine)
 Converts from degrees Rankine to degrees Kelvin.
 
static constexpr double FahrenheitToCelsius (double fahrenheit)
 Converts from degrees Fahrenheit to degrees Celsius.
 
static constexpr double CelsiusToFahrenheit (double celsius)
 Converts from degrees Celsius to degrees Fahrenheit.
 
static constexpr double CelsiusToKelvin (double celsius)
 Converts from degrees Celsius to degrees Kelvin.
 
static constexpr double KelvinToCelsius (double kelvin)
 Converts from degrees Kelvin to degrees Celsius.
 
static constexpr double FeetToMeters (double measure)
 Converts from feet to meters.
 
static bool EqualToRoundoff (double a, double b)
 Finite precision comparison.
 
static bool EqualToRoundoff (float a, float b)
 Finite precision comparison.
 
static bool EqualToRoundoff (float a, double b)
 Finite precision comparison.
 
static bool EqualToRoundoff (double a, float b)
 Finite precision comparison.
 
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 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 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 fttom = 0.3048
 
static constexpr double ktstofps = 1852./(3600*fttom)
 
static constexpr double fpstokts = 1.0 / ktstofps
 
static constexpr double inchtoft = 1.0/12.0
 
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.
 
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__
 

Member Enumeration Documentation

◆ GrainType

enum GrainType

Definition at line 217 of file FGTank.h.

217{gtUNKNOWN, gtCYLINDRICAL, gtENDBURNING, gtFUNCTION};

◆ TankType

enum TankType

Definition at line 216 of file FGTank.h.

216{ttUNKNOWN, ttFUEL, ttOXIDIZER};

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

◆ ~FGTank()

~FGTank ( )

Destructor.

Definition at line 247 of file FGTank.cpp.

248{
249 Debug(1);
250}

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 345 of file FGTank.cpp.

346{
347 if(ExternalFlow < 0.) Drain( -ExternalFlow *dt);
348 else Fill(ExternalFlow * dt);
349
350 if (Temperature == -9999.0) return 0.0;
351 double HeatCapacity = 900.0; // Joules/lbm/C
352 double TempFlowFactor = 1.115; // Watts/sqft/C
353 double Tdiff = TAT_C - Temperature;
354 double dTemp = 0.0; // Temp change due to one surface
355 if (fabs(Tdiff) > 0.1 && Contents > 0.01) {
356 dTemp = (TempFlowFactor * Area * Tdiff * dt) / (Contents * HeatCapacity);
357 }
358
359 return Temperature += (dTemp + dTemp); // For now, assume upper/lower the same
360}
double Drain(double used)
Removes fuel from the tank.
Definition FGTank.cpp:280
+ 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 280 of file FGTank.cpp.

281{
282 double remaining = Contents - used;
283
284 if (remaining >= GetUnusable()) { // Reduce contents by amount used.
285 Contents -= used;
286 } else { // This tank must be empty.
287 if (Contents > GetUnusable())
288 Contents = GetUnusable();
289
290 remaining = Contents;
291 }
292
293 PctFull = 100.0*Contents/Capacity;
294 CalculateInertias();
295
296 return remaining;
297}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Fill()

double Fill ( double  amount)

Definition at line 301 of file FGTank.cpp.

302{
303 double overage = 0.0;
304
305 Contents += amount;
306
307 if (Contents > Capacity) {
308 overage = Contents - Capacity;
309 Contents = Capacity;
310 PctFull = 100.0;
311 } else {
312 PctFull = Contents/Capacity*100.0;
313 }
314
315 CalculateInertias();
316
317 return overage;
318}

◆ GetCapacity()

double GetCapacity ( void  ) const
inline

Gets the capacity of the tank.

Returns
the capacity of the tank in pounds.

Definition at line 258 of file FGTank.h.

258{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 262 of file FGTank.h.

262{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 266 of file FGTank.h.

266{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 270 of file FGTank.h.

270{return Contents/Density;}

◆ GetDensity()

double GetDensity ( void  ) const
inline

Returns the fuel density.

Returns
the density in lbs/gal.

Definition at line 320 of file FGTank.h.

320{return Density;}

◆ GetExternalFlow()

double GetExternalFlow ( void  ) const
inline

Definition at line 325 of file FGTank.h.

325{return ExternalFlow;}

◆ GetGrainType()

GrainType GetGrainType ( void  ) const
inline

Definition at line 331 of file FGTank.h.

331{return grainType;}

◆ GetIxx()

double GetIxx ( void  ) const
inline

Definition at line 302 of file FGTank.h.

302{return Ixx;}

◆ GetIyy()

double GetIyy ( void  ) const
inline

Definition at line 303 of file FGTank.h.

303{return Iyy;}

◆ GetIzz()

double GetIzz ( void  ) const
inline

Definition at line 304 of file FGTank.h.

304{return Izz;}

◆ GetLocationX()

double GetLocationX ( void  ) const
inline

Definition at line 306 of file FGTank.h.

306{ return vXYZ(eX); }

◆ GetLocationY()

double GetLocationY ( void  ) const
inline

Definition at line 307 of file FGTank.h.

307{ return vXYZ(eY); }

◆ GetLocationZ()

double GetLocationZ ( void  ) const
inline

Definition at line 308 of file FGTank.h.

308{ return vXYZ(eZ); }

◆ GetName()

const std::string & GetName ( void  ) const
inline

Retrieves the tank name.

Returns
the tank name.

Definition at line 243 of file FGTank.h.

243{ return Name; }

◆ GetPctFull()

double GetPctFull ( void  ) const
inline

Gets the tank fill level.

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

Definition at line 254 of file FGTank.h.

254{return PctFull;}

◆ GetPriority()

int GetPriority ( void  ) const
inline

Definition at line 315 of file FGTank.h.

315{return Priority;}

◆ 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 250 of file FGTank.h.

250{return Selected;}

◆ GetStandpipe()

double GetStandpipe ( void  ) const
inline

Definition at line 313 of file FGTank.h.

313{return Standpipe;}

◆ 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 284 of file FGTank.h.

284{return CelsiusToFahrenheit(Temperature);}
static constexpr double CelsiusToFahrenheit(double celsius)
Converts from degrees Celsius to degrees Fahrenheit.
Definition FGJSBBase.h:228

◆ 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 277 of file FGTank.h.

277{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 238 of file FGTank.h.

238{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 292 of file FGTank.h.

292{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 296 of file FGTank.h.

296{return UnusableVol;}

◆ GetXYZ() [1/2]

double GetXYZ ( int  idx) const

Definition at line 273 of file FGTank.cpp.

274{
275 return vXYZ_drain(idx) + (Contents/Capacity)*(vXYZ(idx)-vXYZ_drain(idx));
276}

◆ GetXYZ() [2/2]

FGColumnVector3 GetXYZ ( void  ) const

Definition at line 266 of file FGTank.cpp.

267{
268 return vXYZ_drain + (Contents/Capacity)*(vXYZ - vXYZ_drain);
269}

◆ 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 433 of file FGTank.cpp.

434{
435 if (name == "AVGAS") return 6.02;
436 else if (name == "JET-A") return 6.74;
437 else if (name == "JET-A1") return 6.74;
438 else if (name == "JET-B") return 6.48;
439 else if (name == "JP-1") return 6.76;
440 else if (name == "JP-2") return 6.38;
441 else if (name == "JP-3") return 6.34;
442 else if (name == "JP-4") return 6.48;
443 else if (name == "JP-5") return 6.81;
444 else if (name == "JP-6") return 6.55;
445 else if (name == "JP-7") return 6.61;
446 else if (name == "JP-8") return 6.66;
447 else if (name == "JP-8+100") return 6.66;
448 //else if (name == "JP-9") return 6.74;
449 //else if (name == "JPTS") return 6.74;
450 else if (name == "RP-1") return 6.73;
451 else if (name == "T-1") return 6.88;
452 else if (name == "ETHANOL") return 6.58;
453 else if (name == "HYDRAZINE")return 8.61;
454 else if (name == "F-34") return 6.66;
455 else if (name == "F-35") return 6.74;
456 else if (name == "F-40") return 6.48;
457 else if (name == "F-44") return 6.81;
458 else if (name == "AVTAG") return 6.48;
459 else if (name == "AVCAT") return 6.81;
460 else {
461 FGLogging log(LogLevel::ERROR);
462 log << "Unknown fuel type specified: "<< name << "\n";
463 }
464
465 return 6.6;
466}
+ Here is the caller graph for this function:

◆ ResetToIC()

void ResetToIC ( void  )

Resets the tank parameters to the initial conditions.

Definition at line 254 of file FGTank.cpp.

255{
256 SetTemperature( InitialTemperature );
257 SetStandpipe ( InitialStandpipe );
258 SetContents ( InitialContents );
259 PctFull = 100.0*Contents/Capacity;
260 SetPriority( InitialPriority );
261 CalculateInertias();
262}

◆ SetContents()

void SetContents ( double  amount)

Definition at line 322 of file FGTank.cpp.

323{
324 Contents = amount;
325 if (Contents > Capacity) {
326 Contents = Capacity;
327 PctFull = 100.0;
328 } else {
329 PctFull = Contents/Capacity*100.0;
330 }
331
332 CalculateInertias();
333}

◆ SetContentsGallons()

void SetContentsGallons ( double  gallons)

Definition at line 337 of file FGTank.cpp.

338{
339 SetContents(gallons * Density);
340}

◆ SetDensity()

void SetDensity ( double  d)
inline

Sets the fuel density.

Parameters
dthe density in lbs/gal.

Definition at line 323 of file FGTank.h.

323{ Density = d; }

◆ SetExternalFlow()

void SetExternalFlow ( double  f)
inline

Definition at line 326 of file FGTank.h.

326{ ExternalFlow = f; }

◆ SetLocationX()

void SetLocationX ( double  x)
inline

Definition at line 309 of file FGTank.h.

309{ vXYZ(eX) = x; }

◆ SetLocationY()

void SetLocationY ( double  y)
inline

Definition at line 310 of file FGTank.h.

310{ vXYZ(eY) = y; }

◆ SetLocationZ()

void SetLocationZ ( double  z)
inline

Definition at line 311 of file FGTank.h.

311{ vXYZ(eZ) = z; }

◆ SetPriority()

void SetPriority ( int  p)
inline

Definition at line 316 of file FGTank.h.

316{ Priority = p; Selected = p>0 ? true:false; }

◆ SetSelected()

void SetSelected ( bool  sel)
inline

Definition at line 338 of file FGTank.h.

338{ sel==true ? SetPriority(1):SetPriority(0); }

◆ SetStandpipe()

void SetStandpipe ( double  amount)
inline

Definition at line 337 of file FGTank.h.

337{ Standpipe = amount; }

◆ SetTemperature()

void SetTemperature ( double  temp)
inline

Definition at line 336 of file FGTank.h.

336{ Temperature = temp; }

◆ 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 300 of file FGTank.h.

300{UnusableVol = volume;}

The documentation for this class was generated from the following files: