]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/propulsion/FGTank.h
Better fix for a compilation problem with MSVC 2012
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGTank.h
index 9fbce75b8057ce29a27a6a1f44e64b1f5f5b82f1..c1cfa020fbb8b40ccbc2f03e6cc57154c00724cd 100644 (file)
@@ -4,7 +4,7 @@
  Author:       Jon S. Berndt
  Date started: 01/21/99
 
- ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
+ ------------- Copyright (C) 1999  Jon S. Berndt (jon@jsbsim.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
  the terms of the GNU Lesser General Public License as published by the Free Software
@@ -44,26 +44,15 @@ SENTRY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include <FGJSBBase.h>
-#include <input_output/FGXMLElement.h>
-#include <math/FGColumnVector3.h>
-#include <models/FGAuxiliary.h>
-
-#ifdef FGFS
-#  include <simgear/compiler.h>
-#endif
-
+#include "FGJSBBase.h"
+#include "math/FGColumnVector3.h"
 #include <string>
-using std::string;
-using std::cerr;
-using std::endl;
-using std::cout;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_TANK "$Id$"
+#define ID_TANK "$Id: FGTank.h,v 1.26 2011/10/31 14:54:41 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -71,6 +60,10 @@ FORWARD DECLARATIONS
 
 namespace JSBSim {
 
+class Element;
+class FGPropertyManager;
+class FGFDMExec;
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DOCUMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -107,12 +100,24 @@ CLASS DOCUMENTATION
     tree at <tt>propulsion/tank[i]/contents-lbs</tt>, where i is the tank number (Tanks
     are automatically numbered, starting at zero, in the order in which they are read in
     the aircraft configuration file).  The latter method allows one to use a system of FCS
-    components to control tank contents. 
+    components to control tank contents.
+
+    There is also a property <tt>propulsion/tank[i]/external-flow-rate-pps</tt>. Setting
+    this property to a positive value causes the tank to fill at the rate specified.
+    Setting a negative number causes the tank to drain. The value is the rate in pounds
+    of fuel per second. The tank will not fill past 100% full and will not drain below 0%.
+    Fuel may be transfered between two tanks by setting the source tank's external flow rate
+    to a negative value and the destination's external flow rate to the same positive value.
+    Care must be taken to stop fuel flow before the source tank becomes empty to prevent
+    phantom fuel being created.
 
 <h3>Configuration File Format:</h3>
 
 @code
 <tank type="{FUEL | OXIDIZER}">
+  <grain_config type="{CYLINDRICAL | ENDBURNING}">
+    <length unit="{IN | FT | M}"> {number} </radius>
+  </grain_config>
   <location unit="{FT | M | IN}">
     <x> {number} </x>
     <y> {number} </y>
@@ -123,11 +128,14 @@ CLASS DOCUMENTATION
     <y> {number} </y>
     <z> {number} </z>
   </drain_location>
-  <radius unit="{FT | M}"> {number} </radius>
+  <radius unit="{IN | FT | M}"> {number} </radius>
   <capacity unit="{LBS | KG}"> {number} </capacity>
   <contents unit="{LBS | KG}"> {number} </contents>
   <temperature> {number} </temperature> <!-- must be degrees fahrenheit -->
   <standpipe unit="{LBS | KG"}> {number} </standpipe>
+  <priority> {integer} </priority>
+  <density unit="{KG/L | LBS/GAL}"> {number} </density>
+  <type> {string} </type> <!-- will override previous density setting -->
 </tank>
 @endcode
 
@@ -135,10 +143,17 @@ CLASS DOCUMENTATION
 
 - \b type - One of FUEL or OXIDIZER.  This is required.
 - \b radius - Equivalent radius of tank for modeling slosh, defaults to inches.
+- \b grain_config type - One of CYLINDRICAL or ENDBURNING.
+- \b length - length of tank for modeling solid fuel propellant grain, defaults to inches.
 - \b capacity - Capacity, defaults to pounds.
 - \b contents - Initial contents, defaults to pounds.
 - \b temperature - Initial temperature, defaults to degrees Fahrenheit.
 - \b standpipe - Minimum contents to which tank can dump, defaults to pounds.
+- \b priority - Establishes feed sequence of tank. "1" is the highest priority.
+- \b density - Density of liquid tank contents.
+- \b type - Named fuel type. One of AVGAS, JET-A, JET-A1, JET-B, JP-1, JP-2, JP-3,
+- \b        JP-4, JP-5, JP-6, JP-7, JP-8, JP-8+100, RP-1, T-1, ETHANOL, HYDRAZINE,
+- \b        F-34, F-35, F-40, F-44, AVTAG, AVCAT
 
 location:
 - \b x - Location of tank on aircraft's x-axis, defaults to inches.
@@ -159,10 +174,12 @@ be printed to the console if the location is not given
 - \b y - 0.0  (both full and drained CG locations)
 - \b z - 0.0  (both full and drained CG locations)
 - \b radius - 0.0
-- \b capacity - 0.0
+- \b capacity - 0.00001 (tank capacity must not be zero)
 - \b contents - 0.0
-- \b temperature - -9999.0
-- \b standpipe - 0.0
+- \b temperature - -9999.0 (flag which indicates no temperature is set)
+- \b standpipe - 0.0 (all contents may be dumped)
+- \b priority - 1 (highest feed sequence priority)
+- \b density - 6.6
 
     @author Jon Berndt, Dave Culp
     @see Akbar, Raza et al. "A Simple Analysis of Fuel Addition to the CWT of
@@ -187,6 +204,9 @@ public:
   /// Destructor
   ~FGTank();
 
+  enum TankType {ttUNKNOWN, ttFUEL, ttOXIDIZER};
+  enum GrainType {gtUNKNOWN, gtCYLINDRICAL, gtENDBURNING};
+
   /** Removes fuel from the tank.
       This function removes fuel from a tank. If the tank empties, it is
       deselected.
@@ -198,51 +218,118 @@ public:
   /** Performs local, tanks-specific calculations, such as fuel temperature.
       This function calculates the temperature of the fuel in the tank.
       @param dt the time step for this model.
+      @param TempC the Total Air Temperature in degrees Celsius.
       @return the current temperature in degrees Celsius.
   */
-  double Calculate(double dt);
+  double Calculate(double dt, double TempC);
 
   /** Retrieves the type of tank: Fuel or Oxidizer.
       @return the tank type, 0 for undefined, 1 for fuel, and 2 for oxidizer.
   */
-  int GetType(void) {return Type;}
+  int GetType(void) const {return Type;}
 
   /** Resets the tank parameters to the initial conditions */
   void ResetToIC(void);
 
-  bool GetSelected(void) {return Selected;}
-  double GetPctFull(void) {return PctFull;}
-  double GetCapacity(void) {return Capacity;}
+  /** If the tank is set to supply fuel, this function returns true.
+      @return true if this tank is set to a non-zero priority.*/
+  bool GetSelected(void) const {return Selected;}
+
+  /** Gets the tank fill level.
+      @return the fill level in percent, from 0 to 100.*/
+  double GetPctFull(void) const {return PctFull;}
+
+  /** Gets the capacity of the tank.
+      @return the capacity of the tank in pounds. */
+  double GetCapacity(void) const {return Capacity;}
+
+  /** Gets the capacity of the tank.
+      @return the capacity of the tank in gallons. */
+  double GetCapacityGallons(void) const {return Capacity/Density;}
+
+  /** Gets the contents of the tank.
+      @return the contents of the tank in pounds. */
   double GetContents(void) const {return Contents;}
-  double GetTemperature_degC(void) {return Temperature;}
-  double GetTemperature(void) {return CelsiusToFahrenheit(Temperature);}
-  double GetStandpipe(void) {return Standpipe;}
-  const FGColumnVector3 GetXYZ(void);
-  const double GetXYZ(int idx);
+
+  /** Gets the contents of the tank.
+      @return the contents of the tank in gallons. */
+  double GetContentsGallons(void) const {return Contents/Density;}
+
+  /** Gets the temperature of the fuel.
+      The temperature of the fuel is calculated if an initial tempearture is
+      given in the configuration file. 
+      @return the temperature of the fuel in degrees C IF an initial temperature
+      is given, otherwise 0.0 C is returned. */
+  double GetTemperature_degC(void) const {return Temperature;}
+
+  /** Gets the temperature of the fuel.
+      The temperature of the fuel is calculated if an initial tempearture is
+      given in the configuration file. 
+      @return the temperature of the fuel in degrees F IF an initial temperature
+      is given, otherwise 32 degrees F is returned. */
+  double GetTemperature(void) const {return CelsiusToFahrenheit(Temperature);}
+
+  /** Returns the density of a named fuel type.
+      @return the density, in lbs/gal, or 6.6 if name cannot be resolved. */
+  double ProcessFuelName(const std::string& name); 
+
+  double GetIxx(void) const {return Ixx;}
+  double GetIyy(void) const {return Iyy;}
+  double GetIzz(void) const {return Izz;}
+
+  double GetStandpipe(void) const {return Standpipe;}
+
+  int  GetPriority(void) const {return Priority;}
+  void SetPriority(int p) { Priority = p; Selected = p>0 ? true:false; } 
+
+  double GetDensity(void) const {return Density;}
+  void   SetDensity(double d) { Density = d; }
+
+  double GetExternalFlow(void) const {return ExternalFlow;}
+  void   SetExternalFlow(double f) { ExternalFlow = f; }
+
+  FGColumnVector3 GetXYZ(void) const;
+  double GetXYZ(int idx) const;
+
+  const GrainType GetGrainType(void) const {return grainType;}
 
   double Fill(double amount);
   void SetContents(double amount);
+  void SetContentsGallons(double gallons);
   void SetTemperature(double temp) { Temperature = temp; }
   void SetStandpipe(double amount) { Standpipe = amount; }
-
-  enum TankType {ttUNKNOWN, ttFUEL, ttOXIDIZER};
+  void SetSelected(bool sel) { sel==true ? SetPriority(1):SetPriority(0); }
 
 private:
   TankType Type;
+  GrainType grainType;
   int TankNumber;
-  string type;
+  std::string type;
+  std::string strGType;
   FGColumnVector3 vXYZ;
   FGColumnVector3 vXYZ_drain;
   double Capacity;
   double Radius;
+  double InnerRadius;
+  double Length;
+  double Volume;
+  double Density;
+  double Ixx;
+  double Iyy;
+  double Izz;
   double PctFull;
   double Contents, InitialContents;
+  double PreviousUsed;
   double Area;
   double Temperature, InitialTemperature;
   double Standpipe, InitialStandpipe;
+  double ExternalFlow;
   bool  Selected;
-  FGAuxiliary* Auxiliary;
+  int Priority, InitialPriority;
+  FGFDMExec* Exec;
   FGPropertyManager* PropertyManager;
+
+  void CalculateInertias(void);
   void Debug(int from);
 };
 }