]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGPiston.h
Updated to match changes in radiostack.[ch]xx
[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 #include "FGTable.h"
49
50 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 DEFINITIONS
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
53
54 #define ID_PISTON "$Id$";
55
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 FORWARD DECLARATIONS
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59
60 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 COMMENTS, REFERENCES,  and NOTES
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
63
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 DOCUMENTATION
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67
68 /** Models Dave Luff's engine model as ported into JSBSim by David Megginson.
69     @author Jon S. Berndt (Engine framework code and framework-related mods)
70     @author Dave Luff (engine operational code)
71     @author David Megginson (porting and additional code)
72     @version $Id$
73     @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPiston.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">
74          Header File </a>
75     @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPiston.cpp?rev=HEAD&content-type=text/vnd.viewcvs-markup">
76          Source File </a>
77   */
78
79 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 CLASS DECLARATION
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
82
83 class FGPiston : public FGEngine
84 {
85 public:
86   /// Constructor
87   FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg);
88   /// Destructor
89   ~FGPiston();
90
91   double Calculate(double PowerRequired);
92   double GetPowerAvailable(void) {return PowerAvailable;}
93   double CalcFuelNeed(void);
94
95 private:
96   int crank_counter;
97
98   double BrakeHorsePower;
99   double SpeedSlope;
100   double SpeedIntercept;
101   double AltitudeSlope;
102   double PowerAvailable;
103
104   // timestep
105   double dt;
106
107   void doEngineStartup(void);
108   void doManifoldPressure(void);
109   void doAirFlow(void);
110   void doFuelFlow(void);
111   void doEnginePower(void);
112   void doEGT(void);
113   void doCHT(void);
114   void doOilPressure(void);
115   void doOilTemperature(void);
116
117   //
118   // constants
119   //
120   const double CONVERT_CUBIC_INCHES_TO_METERS_CUBED;
121
122   const double R_air;
123   const double rho_fuel;    // kg/m^3
124   const double calorific_value_fuel;  // W/Kg (approximate)
125   const double Cp_air;      // J/KgK
126   const double Cp_fuel;     // J/KgK
127
128   FGTable *Lookup_Combustion_Efficiency;
129   FGTable *Power_Mixture_Correlation;
130
131   //
132   // Configuration
133   //
134   double MinManifoldPressure_inHg; // Inches Hg
135   double MaxManifoldPressure_inHg; // Inches Hg
136   double Displacement;             // cubic inches
137   double MaxHP;                    // horsepower
138   double Cycles;                   // cycles/power stroke
139   double IdleRPM;                  // revolutions per minute
140
141   //
142   // Inputs (in addition to those in FGEngine).
143   //
144   double p_amb;              // Pascals
145   double p_amb_sea_level;    // Pascals
146   double T_amb;              // degrees Kelvin
147   double RPM;                // revolutions per minute
148   double IAS;                // knots
149
150   //
151   // Outputs (in addition to those in FGEngine).
152   //
153   bool Magneto_Left;
154   bool Magneto_Right;
155   double rho_air;
156   double volumetric_efficiency;
157   double m_dot_air;
158   double equivalence_ratio;
159   double m_dot_fuel;
160   double Percentage_Power;
161   double HP;
162   double combustion_efficiency;
163
164   void Debug(int from);
165 };
166
167 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
168 #endif