JSBSim Flight Dynamics Model 1.0 (23 February 2013)
An Open Source Flight Dynamics and Control Software Library in C++

FGGasCell.h

00001 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00002 
00003  Header:       FGGasCell.h
00004  Author:       Anders Gidenstam
00005  Date started: 01/21/2006
00006 
00007  ----- Copyright (C) 2006 - 2011  Anders Gidenstam (anders(at)gidenstam.org) --
00008 
00009  This program is free software; you can redistribute it and/or modify it under
00010  the terms of the GNU Lesser General Public License as published by the Free Software
00011  Foundation; either version 2 of the License, or (at your option) any later
00012  version.
00013 
00014  This program is distributed in the hope that it will be useful, but WITHOUT
00015  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00016  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00017  details.
00018 
00019  You should have received a copy of the GNU Lesser General Public License along with
00020  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021  Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023  Further information about the GNU Lesser General Public License can also be found on
00024  the world wide web at http://www.gnu.org.
00025 
00026 FUNCTIONAL DESCRIPTION
00027 --------------------------------------------------------------------------------
00028 
00029 This class simulates a generic gas cell for static buoyancy.
00030 
00031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00032 SENTRY
00033 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00034 
00035 #ifndef FGGASCELL_H
00036 #define FGGASCELL_H
00037 
00038 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00039 INCLUDES
00040 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00041 
00042 #include "FGJSBBase.h"
00043 #include "math/FGColumnVector3.h"
00044 #include "models/propulsion/FGForce.h"
00045 #include "math/FGFunction.h"
00046 
00047 #include <string>
00048 
00049 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00050 DEFINITIONS
00051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00052 
00053 #define ID_GASCELL "$Id: FGGasCell.h,v 1.12 2011/08/06 13:47:59 jberndt Exp $"
00054 
00055 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00056 FORWARD DECLARATIONS
00057 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00058 
00059 namespace JSBSim {
00060 
00061 class FGBallonet;
00062 class Element;
00063 
00064 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00065 CLASS DOCUMENTATION
00066 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00067 
00169 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00170 CLASS DECLARATION
00171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
00172 class FGGasCell : public FGForce
00173 {
00174 public:
00175   struct Inputs {
00176     double Pressure;
00177     double Temperature;
00178     double Density;
00179     double gravity;
00180   };
00181 
00186   FGGasCell(FGFDMExec* exec, Element* el, int num, const struct Inputs& input);
00187   ~FGGasCell();
00188 
00191   void Calculate(double dt);
00192 
00195   int GetIndex(void) const {return CellNum;}
00196 
00200   const FGColumnVector3& GetXYZ(void) const {return vXYZ;}
00201 
00205   double GetXYZ(int idx) const {return vXYZ(idx);}
00206 
00209   double GetMass(void) const {return Mass;}
00210 
00214   const FGMatrix33& GetInertia(void) const {return gasCellJ;}
00215 
00221   const FGColumnVector3& GetMassMoment(void) const {return gasCellM;}
00222 
00225   double GetTemperature(void) const {return Temperature;}
00226 
00229   double GetPressure(void) const {return Pressure;}
00230 
00231   const struct Inputs& in;
00232 
00233 private:
00234 
00235   enum GasType {ttUNKNOWN, ttHYDROGEN, ttHELIUM, ttAIR};
00236 
00237   GasType Type;
00238   std::string type;
00239   int CellNum;
00240   // Structural constants
00241   double MaxVolume;                 // [ft^2]
00242   double MaxOverpressure;           // [lbs/ft^2]
00243   FGColumnVector3 vXYZ;             // [in]
00244   double Xradius, Yradius, Zradius; // [ft]
00245   double Xwidth, Ywidth, Zwidth;    // [ft]
00246   double ValveCoefficient;          // [ft^4 sec / slug]
00247   typedef vector <FGFunction*> CoeffArray;
00248   CoeffArray HeatTransferCoeff;
00249   typedef vector <FGBallonet*> BallonetArray;
00250   BallonetArray Ballonet;
00251   // Variables
00252   double Pressure;          // [lbs/ft^2]
00253   double Contents;          // [mol]
00254   double Volume;            // [ft^2]
00255   double dVolumeIdeal;      // [ft^2]
00256   double Temperature;       // [Rankine]
00257   double Buoyancy;          // [lbs] Note: Gross lift.
00258                             // Does not include the weight of the gas itself.
00259   double ValveOpen;         // 0 <= ValveOpen <= 1 (or higher).
00260   double Mass;              // [slug]
00261   FGMatrix33 gasCellJ;      // [slug foot^2]
00262   FGColumnVector3 gasCellM; // [lbs in]
00263 
00264   FGPropertyManager* PropertyManager;
00265   FGMassBalance* MassBalance;
00266   void Debug(int from);
00267 
00268   /* Constants. */
00269   const static double R;          // [lbs ft/(mol Rankine)]
00270   const static double M_air;      // [slug/mol]
00271   const static double M_hydrogen; // [slug/mol]
00272   const static double M_helium;   // [slug/mol]
00273 
00274   double M_gas() {                // [slug/mol]
00275     switch (Type) {
00276     case ttHYDROGEN:
00277       return M_hydrogen;
00278     case ttHELIUM:
00279       return M_helium;
00280     case ttAIR:
00281       return M_air;
00282     default:
00283       return M_air;
00284     }
00285   }
00286 
00287   double Cv_gas() {               // [??]
00288     switch (Type) {
00289     case ttHYDROGEN:
00290       return 5.0/2.0;
00291     case ttHELIUM:
00292       return 3.0/2.0;
00293     case ttAIR:
00294       return 5.0/2.0;
00295     default:
00296       return 5.0/2.0;
00297     }
00298   }
00299 
00300 };
00301 
00302 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00308 class FGBallonet : public FGJSBBase
00309 {
00310 public:
00311   FGBallonet(FGFDMExec* exec, Element* el, int num, FGGasCell* parent, const struct FGGasCell::Inputs& input);
00312   ~FGBallonet();
00313 
00316   void Calculate(double dt);
00317 
00318 
00321   const FGColumnVector3& GetXYZ(void) const {return vXYZ;}
00324   double GetXYZ(int idx) const {return vXYZ(idx);}
00325 
00328   double GetMass(void) const {return Contents * M_air;}
00329 
00333   const FGMatrix33& GetInertia(void) const {return ballonetJ;}
00334 
00337   double GetVolume(void) const {return Volume;}
00340   double GetHeatFlow(void) const {return dU;}       // [lbs ft / sec]
00341 
00342   const struct FGGasCell::Inputs& in;
00343 
00344 private:
00345   int CellNum;
00346   // Structural constants
00347   double MaxVolume;                 // [ft^2]
00348   double MaxOverpressure;           // [lbs/ft^2]
00349   FGColumnVector3 vXYZ;             // [in]
00350   double Xradius, Yradius, Zradius; // [ft]
00351   double Xwidth, Ywidth, Zwidth;    // [ft]
00352   double ValveCoefficient;          // [ft^4 sec / slug]
00353   typedef vector <FGFunction*> CoeffArray;
00354   CoeffArray HeatTransferCoeff;     // [lbs ft / sec]
00355   FGFunction* BlowerInput;          // [ft^3 / sec]
00356   FGGasCell* Parent;
00357   // Variables
00358   double Pressure;         // [lbs/ft^2]
00359   double Contents;         // [mol]
00360   double Volume;           // [ft^2]
00361   double dVolumeIdeal;     // [ft^2]
00362   double dU;               // [lbs ft / sec]
00363   double Temperature;      // [Rankine]
00364   double ValveOpen;        // 0 <= ValveOpen <= 1 (or higher).
00365   FGMatrix33 ballonetJ;     // [slug foot^2]
00366 
00367   FGPropertyManager* PropertyManager;
00368   FGMassBalance* MassBalance;
00369   void Debug(int from);
00370 
00371   /* Constants. */
00372   const static double R;          // [lbs ft/(mol Rankine)]
00373   const static double M_air;      // [slug/mol]
00374   const static double Cv_air;     // [??]
00375 };
00376 }
00377 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00378 #endif