1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 ------------- Copyright (C) 1999 Jon S. Berndt (jsb@hal-pc.org) -------------
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
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 General Public License for more
19 You should have received a copy of the GNU 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.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
26 FUNCTIONAL DESCRIPTION
27 --------------------------------------------------------------------------------
29 Based on Flightgear code, which is based on LaRCSim. This class simulates
33 --------------------------------------------------------------------------------
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47 #include "FGJSBBase.h"
48 #include "FGConfigFile.h"
49 #include "FGColumnVector3.h"
50 #include "FGAuxiliary.h"
53 # include <simgear/compiler.h>
62 # if !defined(sgi) || defined(__GNUC__) || (_COMPILER_VERSION >= 740)
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
73 #define ID_TANK "$Id$"
75 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
81 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
85 /** Models a fuel tank.
87 @see Akbar, Raza et al. "A Simple Analysis of Fuel Addition to the CWT of
88 747", California Institute of Technology, 1998
90 Fuel temperature is calculated using the following assumptions:
92 Fuel temperature will only be calculated for tanks which have an initial fuel
93 temperature specified in the configuration file.
95 The surface area of the tank is estimated from the capacity in pounds. It
96 is assumed that the tank is a wing tank with dimensions h by 4h by 10h. The
97 volume of the tank is then 40(h)(h)(h). The area of the upper or lower
98 surface is then 40(h)(h). The volume is also equal to the capacity divided
99 by 49.368 lbs/cu-ft, for jet fuel. The surface area of one side can then be
100 derived from the tank's capacity.
102 The heat capacity of jet fuel is assumed to be 900 Joules/lbm/K, and the
103 heat transfer factor of the tank is 1.115 Watts/sq-ft/K.
105 Configuration File Format
107 \<AC_TANK TYPE="\<FUEL | OXIDIZER>" NUMBER="\<n>">
114 TEMPERATURE \<fuel temperature>
117 Definition of the tank configuration file parameters:
119 <b>TYPE</b> - One of FUEL or OXIDIZER.
120 <b>XLOC</b> - Location of tank on aircraft's x-axis, inches.
121 <b>YLOC</b> - Location of tank on aircraft's y-axis, inches.
122 <b>ZLOC</b> - Location of tank on aircraft's z-axis, inches.
123 <b>RADIUS</b> - Equivalent radius of tank, inches, for modeling slosh.
124 <b>CAPACITY</b> - Capacity in pounds.
125 <b>CONTENTS</b> - Initial contents in pounds.
126 <b>TEMPERATURE</b> - Initial temperature in degrees Fahrenheit.
130 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
134 class FGTank : public FGJSBBase
137 FGTank(FGConfigFile*, FGFDMExec*);
140 double Drain(double);
141 double Calculate(double dt);
142 int GetType(void) {return Type;}
143 bool GetSelected(void) {return Selected;}
144 double GetPctFull(void) {return PctFull;}
145 double GetContents(void) {return Contents;}
146 double GetTemperature_degC(void) {return Temperature;}
147 double GetTemperature(void) {return CelsiusToFahrenheit(Temperature);}
148 const FGColumnVector3& GetXYZ(void) {return vXYZ;}
149 double GetXYZ(int idx) {return vXYZ(idx);}
151 double Fill(double amount);
152 void SetContents(double amount);
153 void SetTemperature(double temp) { Temperature = temp; }
155 enum TankType {ttUNKNOWN, ttFUEL, ttOXIDIZER};
160 FGColumnVector3 vXYZ;
168 FGAuxiliary* Auxiliary;
169 void Debug(int from);
172 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%