JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGGasCell.h
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 DEFINITIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52 
53 #define ID_GASCELL "$Id: FGGasCell.h,v 1.16 2015/03/28 14:49:02 bcoconni Exp $"
54 
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 FORWARD DECLARATIONS
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58 
59 namespace JSBSim {
60 
61 class FGBallonet;
62 class Element;
63 
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 CLASS DOCUMENTATION
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 
169 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
170 CLASS DECLARATION
171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
172 class FGGasCell : public FGForce
173 {
174 public:
175  struct Inputs {
176  double Pressure;
177  double Temperature;
178  double Density;
179  double gravity;
180  };
181 
186  FGGasCell(FGFDMExec* exec, Element* el, unsigned int num,
187  const struct Inputs& input);
188  ~FGGasCell();
189 
192  void Calculate(double dt);
193 
196  int GetIndex(void) const {return CellNum;}
197 
201  const FGColumnVector3& GetXYZ(void) const {return vXYZ;}
202 
206  double GetXYZ(int idx) const {return vXYZ(idx);}
207 
210  double GetMass(void) const {return Mass;}
211 
215  const FGMatrix33& GetInertia(void) const {return gasCellJ;}
216 
222  const FGColumnVector3& GetMassMoment(void) const {return gasCellM;}
223 
226  double GetTemperature(void) const {return Temperature;}
227 
230  double GetPressure(void) const {return Pressure;}
231 
232  const struct Inputs& in;
233 
234 private:
235 
236  enum GasType {ttUNKNOWN, ttHYDROGEN, ttHELIUM, ttAIR};
237 
238  GasType Type;
239  std::string type;
240  unsigned int CellNum;
241  // Structural constants
242  double MaxVolume; // [ft^3]
243  double MaxOverpressure; // [lbs/ft^2]
244  FGColumnVector3 vXYZ; // [in]
245  double Xradius, Yradius, Zradius; // [ft]
246  double Xwidth, Ywidth, Zwidth; // [ft]
247  double ValveCoefficient; // [ft^4 sec / slug]
248  typedef std::vector <FGFunction*> CoeffArray;
249  CoeffArray HeatTransferCoeff;
250  typedef std::vector <FGBallonet*> BallonetArray;
251  BallonetArray Ballonet;
252  // Variables
253  double Pressure; // [lbs/ft^2]
254  double Contents; // [mol]
255  double Volume; // [ft^3]
256  double dVolumeIdeal; // [ft^3]
257  double Temperature; // [Rankine]
258  double Buoyancy; // [lbs] Note: Gross lift.
259  // Does not include the weight of the gas itself.
260  double ValveOpen; // 0 <= ValveOpen <= 1 (or higher).
261  double Mass; // [slug]
262  FGMatrix33 gasCellJ; // [slug foot^2]
263  FGColumnVector3 gasCellM; // [lbs in]
264 
265  FGMassBalance* MassBalance;
266  void Debug(int from);
267 
268  /* Constants. */
269  const static double R; // [lbs ft/(mol Rankine)]
270  const static double M_air; // [slug/mol]
271  const static double M_hydrogen; // [slug/mol]
272  const static double M_helium; // [slug/mol]
273 
274  double M_gas() { // [slug/mol]
275  switch (Type) {
276  case ttHYDROGEN:
277  return M_hydrogen;
278  case ttHELIUM:
279  return M_helium;
280  case ttAIR:
281  return M_air;
282  default:
283  return M_air;
284  }
285  }
286 
287  double Cv_gas() { // [??]
288  switch (Type) {
289  case ttHYDROGEN:
290  return 5.0/2.0;
291  case ttHELIUM:
292  return 3.0/2.0;
293  case ttAIR:
294  return 5.0/2.0;
295  default:
296  return 5.0/2.0;
297  }
298  }
299 
300 };
301 
302 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
308 class FGBallonet : public FGJSBBase
309 {
310 public:
311  FGBallonet(FGFDMExec* exec, Element* el, unsigned int num, FGGasCell* parent,
312  const struct FGGasCell::Inputs& input);
313  ~FGBallonet();
314 
317  void Calculate(double dt);
318 
319 
322  const FGColumnVector3& GetXYZ(void) const {return vXYZ;}
325  double GetXYZ(int idx) const {return vXYZ(idx);}
326 
329  double GetMass(void) const {return Contents * M_air;}
330 
334  const FGMatrix33& GetInertia(void) const {return ballonetJ;}
335 
338  double GetVolume(void) const {return Volume;}
341  double GetHeatFlow(void) const {return dU;} // [lbs ft / sec]
342 
343  const struct FGGasCell::Inputs& in;
344 
345 private:
346  unsigned int CellNum;
347  // Structural constants
348  double MaxVolume; // [ft^3]
349  double MaxOverpressure; // [lbs/ft^2]
350  FGColumnVector3 vXYZ; // [in]
351  double Xradius, Yradius, Zradius; // [ft]
352  double Xwidth, Ywidth, Zwidth; // [ft]
353  double ValveCoefficient; // [ft^4 sec / slug]
354  typedef std::vector <FGFunction*> CoeffArray;
355  CoeffArray HeatTransferCoeff; // [lbs ft / sec]
356  FGFunction* BlowerInput; // [ft^3 / sec]
357  FGGasCell* Parent;
358  // Variables
359  double Pressure; // [lbs/ft^2]
360  double Contents; // [mol]
361  double Volume; // [ft^3]
362  double dVolumeIdeal; // [ft^3]
363  double dU; // [lbs ft / sec]
364  double Temperature; // [Rankine]
365  double ValveOpen; // 0 <= ValveOpen <= 1 (or higher).
366  FGMatrix33 ballonetJ; // [slug foot^2]
367 
368  FGMassBalance* MassBalance;
369  void Debug(int from);
370 
371  /* Constants. */
372  const static double R; // [lbs ft/(mol Rankine)]
373  const static double M_air; // [slug/mol]
374  const static double Cv_air; // [??]
375 };
376 }
377 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
378 #endif
Models a gas cell.
Definition: FGGasCell.h:172
FGGasCell(FGFDMExec *exec, Element *el, unsigned int num, const struct Inputs &input)
Constructor.
Definition: FGGasCell.cpp:65
double GetXYZ(int idx) const
Get the center of gravity location of the ballonet.
Definition: FGGasCell.h:325
double GetMass(void) const
Get the current mass of the gas cell (including any ballonets)
Definition: FGGasCell.h:210
void Calculate(double dt)
Runs the gas cell model; called by BuoyantForces.
Definition: FGGasCell.cpp:262
double GetTemperature(void) const
Get the current gas temperature inside the gas cell.
Definition: FGGasCell.h:226
const FGColumnVector3 & GetXYZ(void) const
Get the center of gravity location of the ballonet.
Definition: FGGasCell.h:322
double GetPressure(void) const
Get the current gas pressure inside the gas cell.
Definition: FGGasCell.h:230
double GetVolume(void) const
Get the current volume of the ballonet.
Definition: FGGasCell.h:338
const FGMatrix33 & GetInertia(void) const
Get the moments of inertia of the gas cell (including any ballonets)
Definition: FGGasCell.h:215
JSBSim Base class.
Definition: FGJSBBase.h:80
const FGColumnVector3 & GetXYZ(void) const
Get the center of gravity location of the gas cell (including any ballonets)
Definition: FGGasCell.h:201
double GetXYZ(int idx) const
Get the center of gravity location of the gas cell (including any ballonets)
Definition: FGGasCell.h:206
Represents a mathematical function.
Definition: FGFunction.h:699
double GetHeatFlow(void) const
Get the current heat flow into the ballonet.
Definition: FGGasCell.h:341
This class implements a 3 element column vector.
double GetMass(void) const
Get the current mass of the ballonets.
Definition: FGGasCell.h:329
Handles matrix math operations.
Definition: FGMatrix33.h:92
const FGColumnVector3 & GetMassMoment(void) const
Get the moment due to mass of the gas cell (including any ballonets)
Definition: FGGasCell.h:222
Models a ballonet inside a gas cell.
Definition: FGGasCell.h:308
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:189
Utility class that aids in the conversion of forces between coordinate systems and calculation of mom...
Definition: FGForce.h:225
Models weight, balance and moment of inertia information.
int GetIndex(void) const
Get the index of this gas cell.
Definition: FGGasCell.h:196
const FGMatrix33 & GetInertia(void) const
Get the moments of inertia of the ballonet.
Definition: FGGasCell.h:334