]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGPiston.h
Syncing with the very latest JSBSim development code.
[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 COMMENTS, REFERENCES,  and NOTES
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 SENTRY
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
38
39 #ifndef FGPISTON_H
40 #define FGPISTON_H
41
42 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 INCLUDES
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45
46 #include "FGEngine.h"
47 #include "FGConfigFile.h"
48
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50 DEFINITIONS
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52
53 #define ID_PISTON "$Id$";
54
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 FORWARD DECLARATIONS
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58
59 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 COMMENTS, REFERENCES,  and NOTES
61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
62
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 DOCUMENTATION
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66
67 /** Models Dave Luff's engine model as ported into JSBSim by David Megginson.
68     @author Jon S. Berndt (Engine framework code and framework-related mods)
69     @author Dave Luff (engine operational code)
70     @author David Megginson (porting and additional code)
71     @version $Id$
72   */
73
74 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 CLASS DECLARATION
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
77
78 class FGPiston : public FGEngine
79 {
80 public:
81   /// Constructor
82   FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg);
83   /// Destructor
84   ~FGPiston();
85
86   float Calculate(float PowerRequired);
87   float GetPowerAvailable(void) {return PowerAvailable;}
88
89 private:
90   float BrakeHorsePower;
91   float SpeedSlope;
92   float SpeedIntercept;
93   float AltitudeSlope;
94   float PowerAvailable;
95
96   // timestep
97   float dt;
98
99   // engine state
100   bool running;
101   bool cranking;
102
103   void doEngineStartup(void);
104   void doManifoldPressure(void);
105   void doAirFlow(void);
106   void doFuelFlow(void);
107   void doEnginePower(void);
108   void doEGT(void);
109   void doCHT(void);
110   void doOilPressure(void);
111   void doOilTemperature(void);
112
113   //
114   // constants
115   //
116   const float CONVERT_CUBIC_INCHES_TO_METERS_CUBED;
117
118   const float R_air;
119   const float rho_fuel;    // kg/m^3
120   const float calorific_value_fuel;  // W/Kg (approximate)
121   const float Cp_air;      // J/KgK
122   const float Cp_fuel;     // J/KgK
123
124   //
125   // Configuration
126   //
127   float MinManifoldPressure_inHg; // Inches Hg
128   float MaxManifoldPressure_inHg; // Inches Hg
129   float Displacement;             // cubic inches
130   float MaxHP;                    // horsepower
131   float Cycles;                   // cycles/power stroke
132   float IdleRPM;                  // revolutions per minute
133
134   //
135   // Inputs (in addition to those in FGEngine).
136   //
137   float p_amb;              // Pascals
138   float p_amb_sea_level;    // Pascals
139   float T_amb;              // degrees Kelvin
140   float RPM;                // revolutions per minute
141   float IAS;                // knots
142
143   //
144   // Outputs (in addition to those in FGEngine).
145   //
146   float rho_air;
147   float volumetric_efficiency;
148   float m_dot_air;
149   float equivalence_ratio;
150   float m_dot_fuel;
151   float Percentage_Power;
152   float HP;
153   float combustion_efficiency;
154
155   void Debug(void);
156 };
157
158 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159 #endif