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

           Branch data     Line data    Source code
       1                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       2                 :            : 
       3                 :            :  Header:       FGPiston.h
       4                 :            :  Author:       Jon S. Berndt
       5                 :            :  Date started: 09/12/2000
       6                 :            : 
       7                 :            :  ------------- Copyright (C) 2000  Jon S. Berndt (jon@jsbsim.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                 :            : HISTORY
      27                 :            : --------------------------------------------------------------------------------
      28                 :            : 09/12/2000  JSB  Created
      29                 :            : 10/01/2001  DPM  Modified to use equations from Dave Luff's piston model.
      30                 :            : 11/01/2008  RKJ  Modified piston engine model for more general use.
      31                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      32                 :            : SENTRY
      33                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      34                 :            : 
      35                 :            : #ifndef FGPISTON_H
      36                 :            : #define FGPISTON_H
      37                 :            : 
      38                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      39                 :            : INCLUDES
      40                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      41                 :            : 
      42                 :            : #include "FGEngine.h"
      43                 :            : #include "math/FGTable.h"
      44                 :            : 
      45                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      46                 :            : DEFINITIONS
      47                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      48                 :            : 
      49                 :            : #define ID_PISTON "$Id: FGPiston.h,v 1.24 2010/08/21 18:08:13 jberndt Exp $";
      50                 :            : #define FG_MAX_BOOST_SPEEDS 3
      51                 :            : 
      52                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      53                 :            : FORWARD DECLARATIONS
      54                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      55                 :            : 
      56                 :            : namespace JSBSim {
      57                 :            : 
      58                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      59                 :            : CLASS DOCUMENTATION
      60                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      61                 :            : 
      62                 :            : /** Models Dave Luff's Turbo/Supercharged Piston engine model.
      63                 :            : 
      64                 :            : <h3>Configuration File Format:</h3>
      65                 :            : 
      66                 :            : @code
      67                 :            : <piston_engine name="{string}">
      68                 :            :   <minmp unit="{INHG | PA | ATM}"> {number} </minmp>
      69                 :            :   <maxmp unit="{INHG | PA | ATM}"> {number} </maxmp>
      70                 :            :   <displacement unit="{IN3 | LTR | CC}"> {number} </displacement>
      71                 :            :   <bore unit="{IN | M}"> {number} </bore>
      72                 :            :   <stroke unit="{IN | M}"> {number} </stroke>
      73                 :            :   <cylinders> {number} </cylinders>
      74                 :            :   <compression-ratio> {number} </compression-ratio>
      75                 :            :   <sparkfaildrop> {number} </sparkfaildrop>
      76                 :            :   <maxhp unit="{HP | WATTS}"> {number} </maxhp>
      77                 :            :   <cycles> {number} </cycles>
      78                 :            :   <idlerpm> {number} </idlerpm>
      79                 :            :   <maxrpm> {number} </maxrpm>
      80                 :            :   <maxthrottle> {number} </maxthrottle>
      81                 :            :   <minthrottle> {number} </minthrottle>
      82                 :            :   <bsfc unit="{LBS/HP*HR | "KG/KW*HR"}"> {number} </bsfc>
      83                 :            :   <volumetric-efficiency> {number} </volumetric-efficiency>
      84                 :            :   <dynamic-fmep unit="{INHG | PA | ATM}"> {number} </dynamic-fmep>
      85                 :            :   <static-fmep unit="{INHG | PA | ATM}"> {number} </static-fmep>
      86                 :            :   <numboostspeeds> {number} </numboostspeeds>
      87                 :            :   <boostoverride> {0 | 1} </boostoverride>
      88                 :            :   <boostmanual> {0 | 1} </boostmanual>
      89                 :            :   <ratedboost1 unit="{INHG | PA | ATM}"> {number} </ratedboost1>
      90                 :            :   <ratedpower1 unit="{HP | WATTS}"> {number} </ratedpower1>
      91                 :            :   <ratedrpm1> {number} </ratedrpm1>
      92                 :            :   <ratedaltitude1 unit="{FT | M}"> {number} </ratedaltitude1>
      93                 :            :   <ratedboost2 unit="{INHG | PA | ATM}"> {number} </ratedboost2>
      94                 :            :   <ratedpower2 unit="{HP | WATTS}"> {number} </ratedpower2>
      95                 :            :   <ratedrpm2> {number} </ratedrpm2>
      96                 :            :   <ratedaltitude2 unit="{FT | M}"> {number} </ratedaltitude2>
      97                 :            :   <ratedboost3 unit="{INHG | PA | ATM}"> {number} </ratedboost3>
      98                 :            :   <ratedpower3 unit="{HP | WATTS}"> {number} </ratedpower3>
      99                 :            :   <ratedrpm3> {number} </ratedrpm3>
     100                 :            :   <ratedaltitude3 unit="{FT | M}"> {number} </ratedaltitude3>
     101                 :            :   <takeoffboost unit="{INHG | PA | ATM}"> {number} </takeoffboost>
     102                 :            :   <air-intake-impedance-factor> {number} </air-intake-impedance-factor>
     103                 :            :   <ram-air-factor> {number} </ram-air-factor>
     104                 :            : </piston_engine>
     105                 :            : @endcode
     106                 :            : 
     107                 :            : <pre>
     108                 :            :     Additional elements are required for a supercharged engine.  These can be
     109                 :            :     left off a non-supercharged engine, ie. the changes are all backward
     110                 :            :     compatible at present.
     111                 :            : 
     112                 :            :     - NUMBOOSTSPEEDS - zero (or not present) for a naturally-aspirated engine,
     113                 :            :       either 1, 2 or 3 for a boosted engine.  This corresponds to the number of
     114                 :            :       supercharger speeds.  Merlin XII had 1 speed, Merlin 61 had 2, a late
     115                 :            :       Griffon engine apparently had 3.  No known engine more than 3, although
     116                 :            :       some German engines apparently had a continuously variable-speed
     117                 :            :       supercharger.
     118                 :            : 
     119                 :            :     - BOOSTOVERRIDE - whether the boost pressure control system (either a boost
     120                 :            :       control valve for superchargers or wastegate for turbochargers) can be
     121                 :            :       overriden by the pilot.  During wartime this was commonly possible, and
     122                 :            :       known as "War Emergency Power" by the Brits.  1 or 0 in the config file.
     123                 :            :       This isn't implemented in the model yet though, there would need to be
     124                 :            :       some way of getting the boost control cutout lever position (on or off)
     125                 :            :       from FlightGear first.
     126                 :            : 
     127                 :            :     - BOOSTMANUAL - whether a multispeed supercharger will manually or
     128                 :            :       automatically shift boost speeds.  On manual shifting the boost speeds
     129                 :            :       is accomplished by controling propulsion/engine/boostspeed
     130                 :            : 
     131                 :            :     - The next items are all appended with either 1, 2 or 3 depending on which
     132                 :            :       boost speed they refer to, eg RATEDBOOST1.  The rated values seems to have
     133                 :            :       been a common convention at the time to express the maximum continuously
     134                 :            :       available power, and the conditions to attain that power.
     135                 :            : 
     136                 :            :     - RATEDBOOST[123] - the absolute rated boost above sea level ambient for a
     137                 :            :       given boost speed, in psi.  Eg the Merlin XII had a rated boost of 9psi,
     138                 :            :       giving approximately 42inHg manifold pressure up to the rated altitude.
     139                 :            : 
     140                 :            :     - RATEDALTITUDE[123] - The altitude up to which rated boost can be
     141                 :            :       maintained.  Up to this altitude the boost is maintained constant for a
     142                 :            :       given throttle position by the BCV or wastegate.  Beyond this altitude the
     143                 :            :       manifold pressure must drop, since the supercharger is now at maximum
     144                 :            :       unregulated output.  The actual pressure multiplier of the supercharger
     145                 :            :       system is calculated at initialisation from this value.
     146                 :            : 
     147                 :            :     - RATEDPOWER[123] - The power developed at rated boost at rated altitude at
     148                 :            :       rated rpm.
     149                 :            : 
     150                 :            :     - RATEDRPM[123] - The rpm at which rated power is developed.
     151                 :            : 
     152                 :            :     - TAKEOFFBOOST - Takeoff boost in psi above ambient.  Many aircraft had an
     153                 :            :       extra boost setting beyond rated boost, but not totally uncontrolled as in
     154                 :            :       the already mentioned boost-control-cutout, typically attained by pushing
     155                 :            :       the throttle past a mechanical 'gate' preventing its inadvertant use. This
     156                 :            :       was typically used for takeoff, and emergency situations, generally for
     157                 :            :       not more than five minutes.  This is a change in the boost control
     158                 :            :       setting, not the actual supercharger speed, and so would only give extra
     159                 :            :       power below the rated altitude.  When TAKEOFFBOOST is specified in the
     160                 :            :       config file (and is above RATEDBOOST1), then the throttle position is
     161                 :            :       interpreted as:
     162                 :            : 
     163                 :            :     - 0 to 0.95 : idle manifold pressure to rated boost (where attainable)
     164                 :            :     - 0.96, 0.97, 0.98 : rated boost (where attainable).
     165                 :            :     - 0.99, 1.0 : takeoff boost (where attainable).
     166                 :            : 
     167                 :            :     A typical takeoff boost for an earlyish Merlin was about 12psi, compared
     168                 :            :     with a rated boost of 9psi.
     169                 :            : 
     170                 :            :     It is quite possible that other boost control settings could have been used
     171                 :            :     on some aircraft, or that takeoff/extra boost could have activated by other
     172                 :            :     means than pushing the throttle full forward through a gate, but this will
     173                 :            :     suffice for now.
     174                 :            : 
     175                 :            :     Note that MAXMP is still the non-boosted max manifold pressure even for
     176                 :            :     boosted engines - effectively this is simply a measure of the pressure drop
     177                 :            :     through the fully open throttle.
     178                 :            : </pre>
     179                 :            : 
     180                 :            :     @author Jon S. Berndt (Engine framework code and framework-related mods)
     181                 :            :     @author Dave Luff (engine operational code)
     182                 :            :     @author David Megginson (initial porting and additional code)
     183                 :            :     @author Ron Jensen (additional engine code)
     184                 :            :     @version $Id: FGPiston.h,v 1.24 2010/08/21 18:08:13 jberndt Exp $
     185                 :            :   */
     186                 :            : 
     187                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     188                 :            : CLASS DECLARATION
     189                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
     190                 :            : 
     191                 :            : class FGPiston : public FGEngine
     192                 :            : {
     193                 :            : public:
     194                 :            :   /// Constructor
     195                 :            :   FGPiston(FGFDMExec* exec, Element* el, int engine_number);
     196                 :            :   /// Destructor
     197                 :            :   ~FGPiston();
     198                 :            : 
     199                 :            :   std::string GetEngineLabels(const std::string& delimiter);
     200                 :            :   std::string GetEngineValues(const std::string& delimiter);
     201                 :            : 
     202                 :            :   void Calculate(void);
     203                 :          0 :   double GetPowerAvailable(void) {return PowerAvailable;}
     204                 :            :   double CalcFuelNeed(void);
     205                 :            : 
     206                 :            :   void ResetToIC(void);
     207                 :          0 :   void SetMagnetos(int magnetos) {Magnetos = magnetos;}
     208                 :            : 
     209                 :          0 :   double  GetEGT(void) { return EGT_degC; }
     210                 :            :   int     GetMagnetos(void) {return Magnetos;}
     211                 :            : 
     212                 :            :   double getExhaustGasTemp_degF(void) {return KelvinToFahrenheit(ExhaustGasTemp_degK);}
     213                 :          0 :   double getManifoldPressure_inHg(void) const {return ManifoldPressure_inHg;}
     214                 :          0 :   double getCylinderHeadTemp_degF(void) {return KelvinToFahrenheit(CylinderHeadTemp_degK);}
     215                 :          0 :   double getOilPressure_psi(void) const {return OilPressure_psi;}
     216                 :          0 :   double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
     217                 :          0 :   double getRPM(void) {return RPM;}
     218                 :            : 
     219                 :            : protected:
     220                 :            : 
     221                 :            : private:
     222                 :            :   int crank_counter;
     223                 :            : 
     224                 :            :   double IndicatedHorsePower;
     225                 :            :   double PMEP;
     226                 :            :   double FMEP;
     227                 :            :   double FMEPDynamic;
     228                 :            :   double FMEPStatic;
     229                 :            :   double PowerAvailable;
     230                 :            : 
     231                 :            :   // timestep
     232                 :            :   double dt;
     233                 :            : 
     234                 :            :   void doEngineStartup(void);
     235                 :            :   void doBoostControl(void);
     236                 :            :   void doMAP(void);
     237                 :            :   void doAirFlow(void);
     238                 :            :   void doFuelFlow(void);
     239                 :            :   void doEnginePower(void);
     240                 :            :   void doEGT(void);
     241                 :            :   void doCHT(void);
     242                 :            :   void doOilPressure(void);
     243                 :            :   void doOilTemperature(void);
     244                 :            : 
     245                 :            :   int InitRunning(void);
     246                 :            : 
     247                 :            :   //
     248                 :            :   // constants
     249                 :            :   //
     250                 :            : 
     251                 :            :   const double R_air;
     252                 :            :   const double rho_fuel;    // kg/m^3
     253                 :            :   const double calorific_value_fuel;  // W/Kg (approximate)
     254                 :            :   const double Cp_air;      // J/KgK
     255                 :            :   const double Cp_fuel;     // J/KgK
     256                 :            :   const double standard_pressure; //Pa
     257                 :            : 
     258                 :            : 
     259                 :            :   FGTable *Lookup_Combustion_Efficiency;
     260                 :            :   FGTable *Mixture_Efficiency_Correlation;
     261                 :            : 
     262                 :            :   //
     263                 :            :   // Configuration
     264                 :            :   //
     265                 :            :   double MinManifoldPressure_inHg; // Inches Hg
     266                 :            :   double MaxManifoldPressure_inHg; // Inches Hg
     267                 :            :   double MaxManifoldPressure_Percent; // MaxManifoldPressure / 29.92
     268                 :            :   double Displacement;             // cubic inches
     269                 :            :   double displacement_SI;          // cubic meters
     270                 :            :   double MaxHP;                    // horsepower
     271                 :            :   double SparkFailDrop;            // drop of power due to spark failure
     272                 :            :   double Cycles;                   // cycles/power stroke
     273                 :            :   double IdleRPM;                  // revolutions per minute
     274                 :            :   double MaxRPM;                   // revolutions per minute
     275                 :            :   double Bore;                     // inches
     276                 :            :   double Stroke;                   // inches
     277                 :            :   double Cylinders;                // number
     278                 :            :   double CompressionRatio;         // number
     279                 :            :   double Z_airbox; // number representing intake impediance before the throttle
     280                 :            :   double Z_throttle; // number representing slope of throttle impediance
     281                 :            :   double PeakMeanPistonSpeed_fps; // ft/sec speed where intake valves begin to choke. Typically 33-50 fps
     282                 :            :   double RatedMeanPistonSpeed_fps; // ft/sec derived from MaxRPM and stroke.
     283                 :            :   double Ram_Air_Factor;           // number
     284                 :            : 
     285                 :            :   double StarterHP;                // initial horsepower of starter motor
     286                 :            :   int BoostSpeeds;      // Number of super/turbocharger boost speeds - zero implies no turbo/supercharging.
     287                 :            :   int BoostSpeed;       // The current boost-speed (zero-based).
     288                 :            :   bool Boosted;         // Set true for boosted engine.
     289                 :            :   int BoostManual;      // The raw value read in from the config file - should be 1 or 0 - see description below.
     290                 :            :   bool bBoostManual;    // Set true if pilot must manually control the boost speed.
     291                 :            :   int BoostOverride;    // The raw value read in from the config file - should be 1 or 0 - see description below.
     292                 :            :   bool bBoostOverride;  // Set true if pilot override of the boost regulator was fitted.
     293                 :            :               // (Typically called 'war emergency power').
     294                 :            :   bool bTakeoffBoost;   // Set true if extra takeoff / emergency boost above rated boost could be attained.
     295                 :            :               // (Typically by extra throttle movement past a mechanical 'gate').
     296                 :            :   double TakeoffBoost;  // Sea-level takeoff boost in psi. (if fitted).
     297                 :            :   double RatedBoost[FG_MAX_BOOST_SPEEDS];       // Sea-level rated boost in psi.
     298                 :            :   double RatedAltitude[FG_MAX_BOOST_SPEEDS];    // Altitude at which full boost is reached (boost regulation ends)
     299                 :            :                           // and at which power starts to fall with altitude [ft].
     300                 :            :   double RatedRPM[FG_MAX_BOOST_SPEEDS]; // Engine speed at which the rated power for each boost speed is delivered [rpm].
     301                 :            :   double RatedPower[FG_MAX_BOOST_SPEEDS];       // Power at rated throttle position at rated altitude [HP].
     302                 :            :   double BoostSwitchAltitude[FG_MAX_BOOST_SPEEDS - 1];  // Altitude at which switchover (currently assumed automatic)
     303                 :            :                               // from one boost speed to next occurs [ft].
     304                 :            :   double BoostSwitchPressure[FG_MAX_BOOST_SPEEDS - 1];  // Pressure at which boost speed switchover occurs [Pa]
     305                 :            :   double BoostMul[FG_MAX_BOOST_SPEEDS]; // Pressure multipier of unregulated supercharger
     306                 :            :   double RatedMAP[FG_MAX_BOOST_SPEEDS]; // Rated manifold absolute pressure [Pa] (BCV clamp)
     307                 :            :   double TakeoffMAP[FG_MAX_BOOST_SPEEDS];       // Takeoff setting manifold absolute pressure [Pa] (BCV clamp)
     308                 :            :   double BoostSwitchHysteresis; // Pa.
     309                 :            : 
     310                 :            :   double minMAP;  // Pa
     311                 :            :   double maxMAP;  // Pa
     312                 :            :   double MAP;     // Pa
     313                 :            :   double TMAP;    // Pa - throttle manifold pressure e.g. before the supercharger boost
     314                 :            :   double ISFC;    // Indicated specific fuel consumption [lbs/horsepower*hour
     315                 :            : 
     316                 :            :   //
     317                 :            :   // Inputs (in addition to those in FGEngine).
     318                 :            :   //
     319                 :            :   double p_amb;              // Pascals
     320                 :            :   double p_ram;              // Pascals
     321                 :            :   double T_amb;              // degrees Kelvin
     322                 :            :   double RPM;                // revolutions per minute
     323                 :            :   double IAS;                // knots
     324                 :            :   bool Magneto_Left;
     325                 :            :   bool Magneto_Right;
     326                 :            :   int Magnetos;
     327                 :            : 
     328                 :            :   //
     329                 :            :   // Outputs (in addition to those in FGEngine).
     330                 :            :   //
     331                 :            :   double rho_air;
     332                 :            :   double volumetric_efficiency;
     333                 :            :   double map_coefficient;
     334                 :            :   double m_dot_air;
     335                 :            :   double equivalence_ratio;
     336                 :            :   double m_dot_fuel;
     337                 :            :   double HP;
     338                 :            :   double combustion_efficiency;
     339                 :            :   double ExhaustGasTemp_degK;
     340                 :            :   double EGT_degC;
     341                 :            :   double ManifoldPressure_inHg;
     342                 :            :   double CylinderHeadTemp_degK;
     343                 :            :   double OilPressure_psi;
     344                 :            :   double OilTemp_degK;
     345                 :            :   double MeanPistonSpeed_fps;
     346                 :            : 
     347                 :            :   void Debug(int from);
     348                 :            : };
     349                 :            : }
     350                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     351                 :            : #endif

Generated by: LCOV version 1.9