LCOV - code coverage report
Current view: top level - models - FGGasCell.h (source / functions) Hit Total Coverage
Test: JSBSim-Coverage-Statistics Lines: 0 24 0.0 %
Date: 2010-08-24 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 20 0.0 %

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

Generated by: LCOV version 1.9