]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGTank.h
33e3430d05b7dd4bf7a5a1c8389b8c6a91ba1b1e
[flightgear.git] / src / FDM / JSBSim / models / propulsion / 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 (jsb@hal-pc.org) -------------
8
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
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 General Public License for more
17  details.
18
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.
22
23  Further information about the GNU 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 <input_output/FGXMLElement.h>
49 #include <math/FGColumnVector3.h>
50 // #include <FGAuxiliary.h>
51
52 #ifdef FGFS
53 #  include <simgear/compiler.h>
54 #  include STL_STRING
55   SG_USING_STD(string);
56   SG_USING_STD(cerr);
57   SG_USING_STD(endl);
58   SG_USING_STD(cout);
59 #else
60 # include <string>
61   using std::string;
62 # if !defined(sgi) || defined(__GNUC__) || (_COMPILER_VERSION >= 740)
63    using std::cerr;
64    using std::endl;
65    using std::cout;
66 # endif
67 #endif
68
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 DEFINITIONS
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72
73 #define ID_TANK "$Id$"
74
75 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 FORWARD DECLARATIONS
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
78
79 namespace JSBSim {
80
81 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 CLASS DOCUMENTATION
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
84
85 /** Models a fuel tank.
86     @author Jon Berndt
87     @see Akbar, Raza et al. "A Simple Analysis of Fuel Addition to the CWT of
88     747", California Institute of Technology, 1998
89 <P>
90     Fuel temperature is calculated using the following assumptions:
91 <P>
92     Fuel temperature will only be calculated for tanks which have an initial fuel
93     temperature specified in the configuration file.
94 <P>
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.  
101 <P>
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.
104 <P>
105 Configuration File Format
106 <pre>
107 \<AC_TANK TYPE="\<FUEL | OXIDIZER>" NUMBER="\<n>">
108   XLOC        \<x location>
109   YLOC        \<y location>
110   ZLOC        \<z location>
111   RADIUS      \<radius>
112   CAPACITY    \<capacity>
113   CONTENTS    \<contents>
114   TEMPERATURE \<fuel temperature>
115 \</AC_TANK>
116 </pre>
117 Definition of the tank configuration file parameters:
118 <pre>
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.
127 </pre>
128   */
129
130 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131 CLASS DECLARATION
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
133
134 class FGTank : public FGJSBBase
135 {
136 public:
137   FGTank(FGFDMExec* exec, Element* el);
138   ~FGTank();
139
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);}
150
151   double Fill(double amount);
152   void SetContents(double amount);
153   void SetTemperature(double temp) { Temperature = temp; }
154
155   enum TankType {ttUNKNOWN, ttFUEL, ttOXIDIZER};
156
157 private:
158   TankType Type;
159   string type;
160   FGColumnVector3 vXYZ;
161   double Capacity;
162   double Radius;
163   double PctFull;
164   double Contents;
165   double Area;
166   double Temperature;      
167   bool  Selected;
168   FGAuxiliary* Auxiliary;
169   void Debug(int from);
170 };
171 }
172 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173 #endif
174