]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGPiston.h
Adjust the turbine names for N1, N2 and EGT_degC to match those already specified...
[flightgear.git] / src / FDM / JSBSim / FGPiston.h
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 (jsb@hal-pc.org) --------------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU 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 General Public License for more
17  details.
18
19  You should have received a copy of the GNU 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 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
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 "FGConfigFile.h"
44 #include "FGTable.h"
45
46 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 DEFINITIONS
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49
50 #define ID_PISTON "$Id$";
51
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 FORWARD DECLARATIONS
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55
56 namespace JSBSim {
57
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 CLASS DOCUMENTATION
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61
62 /** Models Dave Luff's engine model as ported into JSBSim by David Megginson.
63     @author Jon S. Berndt (Engine framework code and framework-related mods)
64     @author Dave Luff (engine operational code)
65     @author David Megginson (porting and additional code)
66     @version "$Id$"
67   */
68
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 CLASS DECLARATION
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72
73 class FGPiston : public FGEngine
74 {
75 public:
76   /// Constructor
77   FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg);
78   /// Destructor
79   ~FGPiston();
80
81   double Calculate(double PowerRequired);
82   double GetPowerAvailable(void) {return PowerAvailable;}
83   double CalcFuelNeed(void);
84
85   void SetMagnetos(int magnetos) {Magnetos = magnetos;}
86
87   double  GetEGT(void) { return EGT_degC; }
88   int     GetMagnetos(void) {return Magnetos;}
89
90   double getExhaustGasTemp_degF(void) {return KelvinToFahrenheit(ExhaustGasTemp_degK);}
91   double getManifoldPressure_inHg(void) const {return ManifoldPressure_inHg;}
92   double getCylinderHeadTemp_degF(void) {return KelvinToFahrenheit(CylinderHeadTemp_degK);}
93   double getOilPressure_psi(void) const {return OilPressure_psi;}
94   double getOilTemp_degF (void) {return KelvinToFahrenheit(OilTemp_degK);}
95   double getRPM(void) {return RPM;} 
96
97 private:
98   int crank_counter;
99
100   double BrakeHorsePower;
101   double SpeedSlope;
102   double SpeedIntercept;
103   double AltitudeSlope;
104   double PowerAvailable;
105
106   // timestep
107   double dt;
108
109   void doEngineStartup(void);
110   void doManifoldPressure(void);
111   void doAirFlow(void);
112   void doFuelFlow(void);
113   void doEnginePower(void);
114   void doEGT(void);
115   void doCHT(void);
116   void doOilPressure(void);
117   void doOilTemperature(void);
118
119   //
120   // constants
121   //
122
123   const double R_air;
124   const double rho_fuel;    // kg/m^3
125   const double calorific_value_fuel;  // W/Kg (approximate)
126   const double Cp_air;      // J/KgK
127   const double Cp_fuel;     // J/KgK
128
129   FGTable *Lookup_Combustion_Efficiency;
130   FGTable *Power_Mixture_Correlation;
131
132   //
133   // Configuration
134   //
135   double MinManifoldPressure_inHg; // Inches Hg
136   double MaxManifoldPressure_inHg; // Inches Hg
137   double Displacement;             // cubic inches
138   double MaxHP;                    // horsepower
139   double Cycles;                   // cycles/power stroke
140   double IdleRPM;                  // revolutions per minute
141
142   //
143   // Inputs (in addition to those in FGEngine).
144   //
145   double p_amb;              // Pascals
146   double p_amb_sea_level;    // Pascals
147   double T_amb;              // degrees Kelvin
148   double RPM;                // revolutions per minute
149   double IAS;                // knots
150   bool Magneto_Left;
151   bool Magneto_Right;
152   int Magnetos;
153
154   //
155   // Outputs (in addition to those in FGEngine).
156   //
157   double rho_air;
158   double volumetric_efficiency;
159   double m_dot_air;
160   double equivalence_ratio;
161   double m_dot_fuel;
162   double Percentage_Power;
163   double HP;
164   double combustion_efficiency;
165   double ExhaustGasTemp_degK;
166   double EGT_degC;
167   double ManifoldPressure_inHg;
168   double CylinderHeadTemp_degK;
169   double OilPressure_psi;
170   double OilTemp_degK;
171
172   void Debug(int from);
173 };
174 }
175 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176 #endif