JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
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 FORWARD DECLARATIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52 
53 namespace JSBSim {
54 
55 class FGBallonet;
56 class FGMassBalance;
57 
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 CLASS DOCUMENTATION
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 
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 
180  FGGasCell(FGFDMExec* exec, Element* el, unsigned int num,
181  const struct Inputs& input);
182  ~FGGasCell();
183 
186  void Calculate(double dt);
187 
190  int GetIndex(void) const {return CellNum;}
191 
195  const FGColumnVector3& GetXYZ(void) const {return vXYZ;}
196 
200  double GetXYZ(int idx) const {return vXYZ(idx);}
201 
204  double GetMass(void) const {return Mass;}
205 
209  const FGMatrix33& GetInertia(void) const {return gasCellJ;}
210 
216  const FGColumnVector3& GetMassMoment(void) const {return gasCellM;}
217 
220  double GetTemperature(void) const {return Temperature;}
221 
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 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 
311  void Calculate(double dt);
312 
313 
316  const FGColumnVector3& GetXYZ(void) const {return vXYZ;}
319  double GetXYZ(int idx) const {return vXYZ(idx);}
320 
323  double GetMass(void) const {return Contents * M_air;}
324 
328  const FGMatrix33& GetInertia(void) const {return ballonetJ;}
329 
332  double GetVolume(void) const {return Volume;}
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
JSBSim::FGFDMExec
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:185
JSBSim::FGGasCell::Inputs
Definition: FGGasCell.h:169
JSBSim::FGGasCell::Calculate
void Calculate(double dt)
Runs the gas cell model; called by BuoyantForces.
Definition: FGGasCell.cpp:255
JSBSim::FGGasCell
Models a gas cell.
Definition: FGGasCell.h:166
JSBSim::FGFunction
Represents a mathematical function.
Definition: FGFunction.h:752
JSBSim::FGColumnVector3
This class implements a 3 element column vector.
Definition: FGColumnVector3.h:63
JSBSim::FGGasCell::GetXYZ
double GetXYZ(int idx) const
Get the center of gravity location of the gas cell (including any ballonets)
Definition: FGGasCell.h:200
JSBSim::FGBallonet::GetHeatFlow
double GetHeatFlow(void) const
Get the current heat flow into the ballonet.
Definition: FGGasCell.h:335
JSBSim::FGGasCell::GetIndex
int GetIndex(void) const
Get the index of this gas cell.
Definition: FGGasCell.h:190
JSBSim::FGGasCell::GetInertia
const FGMatrix33 & GetInertia(void) const
Get the moments of inertia of the gas cell (including any ballonets)
Definition: FGGasCell.h:209
JSBSim::FGMassBalance
Models weight, balance and moment of inertia information.
Definition: FGMassBalance.h:122
JSBSim::FGBallonet::GetVolume
double GetVolume(void) const
Get the current volume of the ballonet.
Definition: FGGasCell.h:332
JSBSim::FGBallonet::GetXYZ
const FGColumnVector3 & GetXYZ(void) const
Get the center of gravity location of the ballonet.
Definition: FGGasCell.h:316
JSBSim::FGBallonet::GetInertia
const FGMatrix33 & GetInertia(void) const
Get the moments of inertia of the ballonet.
Definition: FGGasCell.h:328
JSBSim::FGBallonet
Models a ballonet inside a gas cell.
Definition: FGGasCell.h:302
JSBSim::FGGasCell::GetTemperature
double GetTemperature(void) const
Get the current gas temperature inside the gas cell.
Definition: FGGasCell.h:220
JSBSim::FGGasCell::GetMass
double GetMass(void) const
Get the current mass of the gas cell (including any ballonets)
Definition: FGGasCell.h:204
JSBSim::FGMatrix33
Handles matrix math operations.
Definition: FGMatrix33.h:69
JSBSim::FGForce
Utility class that aids in the conversion of forces between coordinate systems and calculation of mom...
Definition: FGForce.h:221
JSBSim::FGJSBBase
JSBSim Base class.
Definition: FGJSBBase.h:78
JSBSim::FGGasCell::GetMassMoment
const FGColumnVector3 & GetMassMoment(void) const
Get the moment due to mass of the gas cell (including any ballonets)
Definition: FGGasCell.h:216
JSBSim::FGBallonet::GetXYZ
double GetXYZ(int idx) const
Get the center of gravity location of the ballonet.
Definition: FGGasCell.h:319
JSBSim::FGGasCell::FGGasCell
FGGasCell(FGFDMExec *exec, Element *el, unsigned int num, const struct Inputs &input)
Constructor.
Definition: FGGasCell.cpp:60
JSBSim::FGGasCell::GetXYZ
const FGColumnVector3 & GetXYZ(void) const
Get the center of gravity location of the gas cell (including any ballonets)
Definition: FGGasCell.h:195
JSBSim::FGGasCell::GetPressure
double GetPressure(void) const
Get the current gas pressure inside the gas cell.
Definition: FGGasCell.h:224
JSBSim::FGBallonet::GetMass
double GetMass(void) const
Get the current mass of the ballonets.
Definition: FGGasCell.h:323
JSBSim::FGBallonet::Calculate
void Calculate(double dt)
Runs the ballonet model; called by FGGasCell.
Definition: FGGasCell.cpp:681
JSBSim::Element
Definition: FGXMLElement.h:143