Debian Codegraph @

src/FDM/JSBSim/models/FGGasCell.h

raw symbols SCIP
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Header: FGGasCell.h
4 Author: Anders Gidenstam
5 Date started: 01/21/2006
6
7 ----- Copyright (C) 2006 - 2013 Anders Gidenstam (anders(at)gidenstam.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 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 Lesser General Public License for more
17 details.
18
19 You should have received a copy of the GNU Lesser 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 Lesser 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 This class simulates a generic gas cell for static buoyancy.
30
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 SENTRY
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34
35 #ifndef FGGASCELL_H
36 #define FGGASCELL_H
37
38 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 INCLUDES
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41
42 #include "FGJSBBase.h"
43 #include "math/FGColumnVector3.h"
44 #include "models/propulsion/FGForce.h"
45 #include "math/FGFunction.h"
46
47 #include <string>
48
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 FORWARD DECLARATIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52
53 namespace JSBSim {
54
55 class FGBallonet;
56 class FGMassBalance;
57
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 CLASS DOCUMENTATION
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61
62 /** Models a gas cell.
63 @author Anders Gidenstam
64
65 <h3>Configuration File Format:</h3>
66 @code
67 <buoyant_forces>
68 <gas_cell type="{HYDROGEN | HELIUM | AIR}">
69 <location unit="{M | IN}">
70 <x> {number} </x>
71 <y> {number} </y>
72 <z> {number} </z>
73 </location>
74 <x_width unit="{M | IN}"> {number} </x_width>
75 <y_radius unit="{M | IN}"> {number} </y_radius>
76 <z_radius unit="{M | IN}"> {number} </z_radius>
77 <max_overpressure unit="{PA | PSI}"> {number} </max_overpressure>
78 <valve_coefficient unit="{M4*SEC/KG | FT4*SEC/SLUG}"> {number} </valve_coefficient>
79 <fullness> {number} </fullness>
80 <heat>
81 {heat transfer coefficients} [lbs ft / sec]
82 </heat>
83 <ballonet>
84 <location unit="{M | IN}">
85 <x> {number} </x>
86 <y> {number} </y>
87 <z> {number} </z>
88 </location>
89 <x_width unit="{M | IN}"> {number} </x_width>
90 <y_radius unit="{M | IN}"> {number} </y_radius>
91 <z_radius unit="{M | IN}"> {number} </z_radius>
92 <max_overpressure unit="{PA | PSI}"> {number} </max_overpressure>
93 <valve_coefficient unit="{M4*SEC/KG | FT4*SEC/SLUG}"> {number} </valve_coefficient>
94 <fullness> {number} </fullness>
95 <heat>
96 {heat transfer coefficients} [lb ft / (sec Rankine)]
97 </heat>
98 <blower_input>
99 {input air flow function} [ft^3 / sec]
100 </blower_input>
101 </ballonet>
102 </gas_cell>
103 </buoyant_forces>
104 @endcode
105
106 Definition of the gas cell configuration file parameters:
107 - <b>type</b> -
108 One of HYDROGEN, HELIUM or AIR.
109 - <b>location</b> -
110 Location of cell center in the aircraft's structural frame.
111 Currently this is were the forces of the cell is applied.
112 - <b>{x|y|z}_radius</b> -
113 Radius along in the respective direction (both ends).
114 - <b>{x|y|z}_width</b> -
115 Width in the respective direction.
116 <b>NOTE:</b> A 'x', 'y', 'z'-radius/width combination must be specified.
117 - <b>fullness</b> -
118 Initial fullness of the cell, normally [0,1],
119 values >1 initialize the cell at pressure.
120 - <b>max_overpressure</b> -
121 Maximum cell overpressure (excess is automatically valved off).
122 - <b>valve_coefficient</b> -
123 Capacity of the manual valve. The valve is
124 considered to be located at the top of the cell.
125 The valve coefficient determine the flow out
126 of the cell according to:
127 <i>dVolume/dt = ValveCoefficient * DeltaPressure</i>.
128 - <b>heat</b> -
129 Zero or more FGFunction:s describing the heat flow from
130 the atmosphere into the gas cell.
131 Unit: [lb ft / (sec Rankine)].
132 If there are no heat transfer functions at all the gas cell
133 temperature will equal that of the surrounding atmosphere.
134 A constant function returning 0 results in adiabatic behaviour.
135 - <b>ballonet</b> -
136 Zero or more ballonets, i.e. air bags inside the gas cell.
137 Ballonets are used to maintain the volume of the gas cell
138 and keep its internal pressure higher than that of the
139 surrounding environment.
140 - <b>location</b> -
141 Location of ballonet center in the aircraft's structural frame.
142 - <b>{x|y|z}_radius</b> -
143 Radius along in the respective direction (both ends).
144 - <b>{x|y|z}_width</b> -
145 Width in the respective direction.
146 - <b>max_overpressure</b> -
147 Maximum ballonet overpressure (excess is automatically valved off).
148 - <b>valve_coefficient</b> -
149 Capacity of the exit valve between the ballonet
150 and the atmosphere. The valve coefficient
151 determine the flow out of the cell according to:
152 <i>dVolume/dt = ValveCoefficient * DeltaPressure</i>.
153 - <b>heat</b> -
154 Zero or more FGFunction:s describing the heat flow from
155 the enclosing gas cell into the ballonet.
156 Unit: [lb ft / (sec Rankine)]
157 - <b>blower_input</b> -
158 One FGFunction describing the air flow into the
159 ballonet. Unit: [ft<sup>3</sup> / sec] (at the temperature and
160 pressure of the ballonet.)
161 */
162
163 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
164 CLASS DECLARATION
165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
166 class FGGasCell : public FGForce
167 {
168 public:
169 struct Inputs {
170 double Pressure;
171 double Temperature;
172 double Density;
173 double gravity;
174 };
175
176 /** Constructor
177 @param exec Executive a pointer to the parent executive object
178 @param el Pointer to configuration file XML node
179 @param num Gas cell index number. */
180 FGGasCell(FGFDMExec* exec, Element* el, unsigned int num,
181 const struct Inputs& input);
182 ~FGGasCell();
183
184 /** Runs the gas cell model; called by BuoyantForces
185 */
186 void Calculate(double dt);
187
188 /** Get the index of this gas cell
189 @return gas cell index. */
190 int GetIndex(void) const {return CellNum;}
191
192 /** Get the center of gravity location of the gas cell
193 (including any ballonets)
194 @return CoG location in the structural frame in inches. */
195 const FGColumnVector3& GetXYZ(void) const {return vXYZ;}
196
197 /** Get the center of gravity location of the gas cell
198 (including any ballonets)
199 @return CoG location in the structural frame in inches. */
200 double GetXYZ(int idx) const {return vXYZ(idx);}
201
202 /** Get the current mass of the gas cell (including any ballonets)
203 @return gas mass in slug. */
204 double GetMass(void) const {return Mass;}
205
206 /** Get the moments of inertia of the gas cell (including any ballonets)
207 @return moments of inertia matrix in the body frame
208 in slug ft<sup>2</sup>. */
209 const FGMatrix33& GetInertia(void) const {return gasCellJ;}
210
211 /** Get the moment due to mass of the gas cell (including any ballonets)
212
213 Note that the buoyancy of the gas cell is handled separately by the
214 FGForce part and not included here.
215 @return moment vector in the structural frame in lbs in. */
216 const FGColumnVector3& GetMassMoment(void) const {return gasCellM;}
217
218 /** Get the current gas temperature inside the gas cell
219 @return gas temperature in Rankine. */
220 double GetTemperature(void) const {return Temperature;}
221
222 /** Get the current gas pressure inside the gas cell
223 @return gas pressure in lbs / ft<sup>2</sup>. */
224 double GetPressure(void) const {return Pressure;}
225
226 const struct Inputs& in;
227
228 private:
229
230 enum GasType {ttUNKNOWN, ttHYDROGEN, ttHELIUM, ttAIR};
231
232 GasType Type;
233 std::string type;
234 unsigned int CellNum;
235 // Structural constants
236 double MaxVolume; // [ft^3]
237 double MaxOverpressure; // [lbs/ft^2]
238 FGColumnVector3 vXYZ; // [in]
239 double Xradius, Yradius, Zradius; // [ft]
240 double Xwidth, Ywidth, Zwidth; // [ft]
241 double ValveCoefficient; // [ft^4 sec / slug]
242 typedef std::vector <FGFunction*> CoeffArray;
243 CoeffArray HeatTransferCoeff;
244 typedef std::vector <FGBallonet*> BallonetArray;
245 BallonetArray Ballonet;
246 // Variables
247 double Pressure; // [lbs/ft^2]
248 double Contents; // [mol]
249 double Volume; // [ft^3]
250 double dVolumeIdeal; // [ft^3]
251 double Temperature; // [Rankine]
252 double Buoyancy; // [lbs] Note: Gross lift.
253 // Does not include the weight of the gas itself.
254 double ValveOpen; // 0 <= ValveOpen <= 1 (or higher).
255 double Mass; // [slug]
256 FGMatrix33 gasCellJ; // [slug foot^2]
257 FGColumnVector3 gasCellM; // [lbs in]
258
259 FGMassBalance* MassBalance;
260 void Debug(int from);
261
262 /* Constants. */
263 const static double R; // [lbs ft/(mol Rankine)]
264 const static double M_air; // [slug/mol]
265 const static double M_hydrogen; // [slug/mol]
266 const static double M_helium; // [slug/mol]
267
268 double M_gas() { // [slug/mol]
269 switch (Type) {
270 case ttHYDROGEN:
271 return M_hydrogen;
272 case ttHELIUM:
273 return M_helium;
274 case ttAIR:
275 return M_air;
276 default:
277 return M_air;
278 }
279 }
280
281 double Cv_gas() { // [??]
282 switch (Type) {
283 case ttHYDROGEN:
284 return 5.0/2.0;
285 case ttHELIUM:
286 return 3.0/2.0;
287 case ttAIR:
288 return 5.0/2.0;
289 default:
290 return 5.0/2.0;
291 }
292 }
293
294 };
295
296 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
297 /** Models a ballonet inside a gas cell.
298 Not intended to be used outside FGGasCell.
299 See FGGasCell for the configuration file format.
300 @author Anders Gidenstam
301 */
302 class FGBallonet : public FGJSBBase
303 {
304 public:
305 FGBallonet(FGFDMExec* exec, Element* el, unsigned int num, FGGasCell* parent,
306 const struct FGGasCell::Inputs& input);
307 ~FGBallonet();
308
309 /** Runs the ballonet model; called by FGGasCell
310 */
311 void Calculate(double dt);
312
313
314 /** Get the center of gravity location of the ballonet
315 @return CoG location in the structural frame in inches. */
316 const FGColumnVector3& GetXYZ(void) const {return vXYZ;}
317 /** Get the center of gravity location of the ballonet
318 @return CoG location in the structural frame in inches. */
319 double GetXYZ(int idx) const {return vXYZ(idx);}
320
321 /** Get the current mass of the ballonets
322 @return mass in slug. */
323 double GetMass(void) const {return Contents * M_air;}
324
325 /** Get the moments of inertia of the ballonet
326 @return moments of inertia matrix in the body frame in
327 slug ft<sup>2</sup>. */
328 const FGMatrix33& GetInertia(void) const {return ballonetJ;}
329
330 /** Get the current volume of the ballonet
331 @return volume in ft<sup>3</sup>. */
332 double GetVolume(void) const {return Volume;}
333 /** Get the current heat flow into the ballonet
334 @return heat flow in lbs ft / sec. */
335 double GetHeatFlow(void) const {return dU;} // [lbs ft / sec]
336
337 const struct FGGasCell::Inputs& in;
338
339 private:
340 unsigned int CellNum;
341 // Structural constants
342 double MaxVolume; // [ft^3]
343 double MaxOverpressure; // [lbs/ft^2]
344 FGColumnVector3 vXYZ; // [in]
345 double Xradius, Yradius, Zradius; // [ft]
346 double Xwidth, Ywidth, Zwidth; // [ft]
347 double ValveCoefficient; // [ft^4 sec / slug]
348 typedef std::vector <FGFunction*> CoeffArray;
349 CoeffArray HeatTransferCoeff; // [lbs ft / sec]
350 FGFunction* BlowerInput; // [ft^3 / sec]
351 FGGasCell* Parent;
352 // Variables
353 double Pressure; // [lbs/ft^2]
354 double Contents; // [mol]
355 double Volume; // [ft^3]
356 double dVolumeIdeal; // [ft^3]
357 double dU; // [lbs ft / sec]
358 double Temperature; // [Rankine]
359 double ValveOpen; // 0 <= ValveOpen <= 1 (or higher).
360 FGMatrix33 ballonetJ; // [slug foot^2]
361
362 FGMassBalance* MassBalance;
363 void Debug(int from);
364
365 /* Constants. */
366 const static double R; // [lbs ft/(mol Rankine)]
367 const static double M_air; // [slug/mol]
368 const static double Cv_air; // [??]
369 };
370 }
371 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
372 #endif