]> git.mxchange.org Git - flightgear.git/blob - src/FDM/IO360.hxx
Enclosed is the latest engine model update that supercedes the
[flightgear.git] / src / FDM / IO360.hxx
1 // Module:        10520c.c
2 //  Author:       Phil Schubert
3 //  Date started: 12/03/99
4 //  Purpose:      Models a Continental IO-520-M Engine
5 //  Called by:    FGSimExec
6 // 
7 //  Copyright (C) 1999  Philip L. Schubert (philings@ozemail.com.au)
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 // General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 // 02111-1307, USA.
23 //
24 // Further information about the GNU General Public License can also
25 // be found on the world wide web at http://www.gnu.org.
26 //
27 // FUNCTIONAL DESCRIPTION
28 // ------------------------------------------------------------------------
29 // Models a Continental IO-520-M engine. This engine is used in Cessna
30 // 210, 310, Beechcraft Bonaza and Baron C55. The equations used below
31 // were determined by a first and second order curve fits using Excel. 
32 // The data is from the Cessna Aircraft Corporations Engine and Flight
33 // Computer for C310. Part Number D3500-13
34 // 
35 // ARGUMENTS
36 // ------------------------------------------------------------------------
37 // 
38 // 
39 // HISTORY
40 // ------------------------------------------------------------------------
41 // 12/03/99     PLS     Created
42 // 07/03/99     PLS     Added Calculation of Density, and Prop_Torque
43 // 07/03/99     PLS     Restructered Variables to allow easier implementation
44 //                      of Classes
45 // 15/03/99     PLS     Added Oil Pressure, Oil Temperature and CH Temp
46 // ------------------------------------------------------------------------
47 // INCLUDES
48 // ------------------------------------------------------------------------
49
50 #ifndef _IO360_HXX_
51 #define _IO360_HXX_
52
53 #include <simgear/compiler.h>
54
55 #include <math.h>
56
57 #include STL_IOSTREAM
58 #include STL_FSTREAM
59
60 #if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
61 SG_USING_STD(ofstream);
62 #endif
63
64 class FGNewEngine {
65
66 private:
67
68     float CONVERT_HP_TO_WATTS;
69     float CONVERT_CUBIC_INCHES_TO_METERS_CUBED;
70
71     // Control and environment inputs
72     float IAS;
73     // 0 = Closed, 100 = Fully Open
74     float Throttle_Lever_Pos;
75     // 0 = Full Course 100 = Full Fine
76     float Propeller_Lever_Pos;
77     // 0 = Idle Cut Off 100 = Full Rich
78     float Mixture_Lever_Pos;
79
80     // Engine Specific Variables used by this program that have limits.
81     // Will be set in a parameter file to be read in to create
82     // and instance for each engine.
83     float Max_Manifold_Pressure;  //will be lower than ambient pressure for a non turbo/super charged engine due to losses through the throttle.  This is the sea level full throttle value.
84     float Min_Manifold_Pressure;  //Closed throttle valueat idle - governed by the idle bypass valve
85     float Max_RPM;
86     float Min_RPM;
87     float Max_Fuel_Flow;
88     float Mag_Derate_Percent;
89     float MaxHP;
90     float Gear_Ratio;
91
92     // Initialise Engine Variables used by this instance
93     float Percentage_Power;     // Power output as percentage of maximum power output
94     float Manifold_Pressure;    // Inches
95     float RPM;
96     float Fuel_Flow_gals_hr;    // gals/hour
97     float Torque;
98     float CHT;                  // Cylinder head temperature deg K
99     float CHT_degF;             // Ditto in deg Fahrenheit
100     float EGT;                  // Exhaust gas temperature deg K
101     float EGT_degF;             // Exhaust gas temperature deg Fahrenheit
102     float Mixture;
103     float Oil_Pressure;         // PSI
104     float Oil_Temp;             // Deg C
105     float HP;                   // Current power output in HP
106     float Power_SI;             // Current power output in Watts
107     float Torque_SI;            // Torque in Nm
108     float Torque_FMEP;          // The component of Engine torque due to FMEP (Nm)
109     float RPS;
110     float Torque_Imbalance;
111     bool  running;              //flag to indicate the engine is running self sustaining
112     bool  cranking;             //flag to indicate the engine is being cranked
113     bool  spark;                //flag to indicate a spark is available
114     bool  fuel;                 //flag to indicate fuel is available
115
116     //DCL
117     float volumetric_efficiency;
118     float combustion_efficiency;
119     float equivalence_ratio;
120     float v_dot_air;
121     float m_dot_air;
122     float m_dot_fuel;
123     float swept_volume;
124     float True_Manifold_Pressure;   //in Hg
125     float rho_air_manifold;
126     float R_air;
127     float p_amb_sea_level;      // Pascals
128     float p_amb;                // Pascals
129     float T_amb;                // deg Kelvin
130     float calorific_value_fuel;
131     float rho_air;
132     float rho_fuel;             // kg/m^3
133     float thi_sea_level;
134     float delta_T_exhaust;
135     float displacement;         // Engine displacement in cubic inches - to be read in from config file for each engine
136     float displacement_SI;      // ditto in meters cubed
137     float Cp_air;               // J/KgK
138     float Cp_fuel;              // J/KgK
139     float heat_capacity_exhaust;
140     float enthalpy_exhaust;
141     float Percentage_of_best_power_mixture_power;
142     float abstract_mixture;     //temporary hack
143     float engine_inertia;       //kg.m^2
144     float prop_inertia;         //kg.m^2
145     float angular_acceleration; //rad/s^2
146     float n_R;                  //Number of cycles per power stroke
147     float FMEP;                 //Friction Mean Effective Pressure (Pa)
148     double time_step;
149
150     // Propellor Variables
151     float FGProp1_Thrust;
152     float FGProp1_RPS;
153     float FGProp1_Blade_Angle;
154     float prop_torque;          // Nm
155     float prop_thrust;          // Newtons
156     float blade_length;         // meters
157     float forward_velocity;             // m/s
158     float angular_velocity_SI;          // rad/s
159     float prop_power_consumed_SI;       // Watts
160     float prop_power_consumed_HP;       // HP
161     double prop_diameter;               // meters
162     double J;                           // advance ratio - dimensionless
163     double Cp_20;                   // coefficient of power for 20 degree blade angle
164     double Cp_25;                   // coefficient of power for 25 degree blade angle
165     double Cp;                      // Our actual coefficient of power
166     double blade_angle;             // degrees
167     double neta_prop_20;
168     double neta_prop_25;
169     double neta_prop;               // prop efficiency
170
171     // Calculate Engine RPM based on Propellor Lever Position
172     float Calc_Engine_RPM(float Position);
173
174     // Calculate Manifold Pressure based on throttle lever position
175     // Note that this is simplistic and needs altering to include engine speed effects
176     float Calc_Manifold_Pressure( float LeverPosn, float MaxMan, float MinMan);
177
178     // Calculate combustion efficiency based on equivalence ratio
179     float Lookup_Combustion_Efficiency(float thi_actual);
180
181     // Calculate percentage of best power mixture power based on equivalence ratio
182     float Power_Mixture_Correlation(float thi_actual);
183
184     // Calculate exhaust gas temperature rise
185     float Calculate_Delta_T_Exhaust(void);
186
187     // Calculate Oil Temperature
188     float Calc_Oil_Temp (float Fuel_Flow, float Mixture, float IAS);
189     
190     // Calculate Oil Pressure
191     float Calc_Oil_Press (float Oil_Temp, float Engine_RPM);
192
193 public:
194
195     ofstream outfile;
196
197     //constructor
198     FGNewEngine() {
199 //      outfile.open("FGNewEngine.dat", ios::out|ios::trunc);
200     }
201
202     //destructor
203     ~FGNewEngine() {
204 //      outfile.close();
205     }
206
207     // set initial default values
208     void init(double dt);
209
210     // update the engine model based on current control positions
211     void update();
212
213     inline void set_IAS( float value ) { IAS = value; }
214     inline void set_Throttle_Lever_Pos( float value ) {
215         Throttle_Lever_Pos = value;
216     }
217     inline void set_Propeller_Lever_Pos( float value ) {
218         Propeller_Lever_Pos = value;
219     }
220     inline void set_Mixture_Lever_Pos( float value ) {
221         Mixture_Lever_Pos = value;
222     }
223     // set ambient pressure - takes pounds per square foot
224     inline void set_p_amb( float value ) { 
225         p_amb = value * 47.88026;
226         // Convert to Pascals
227     }
228     // set ambient temperature - takes degrees Rankine
229     inline void set_T_amb( float value ) { 
230         T_amb = value * 0.555555555556;
231         // Convert to degrees Kelvin
232     }
233
234     // accessors
235     inline float get_RPM() const { return RPM; }
236     inline float get_Manifold_Pressure() const { return True_Manifold_Pressure; }
237     inline float get_FGProp1_Thrust() const { return FGProp1_Thrust; }
238     inline float get_FGProp1_Blade_Angle() const { return FGProp1_Blade_Angle; }
239
240  //   inline float get_Rho() const { return Rho; }
241     inline float get_MaxHP() const { return MaxHP; }
242     inline float get_Percentage_Power() const { return Percentage_Power; }
243     inline float get_EGT() const { return EGT_degF; }    // Returns EGT in Fahrenheit
244     inline float get_CHT() const { return CHT_degF; }    // Note this returns CHT in Fahrenheit
245     inline float get_prop_thrust_SI() const { return prop_thrust; }
246     inline float get_prop_thrust_lbs() const { return (prop_thrust * 0.2248); }
247     inline float get_fuel_flow_gals_hr() const { return (Fuel_Flow_gals_hr); }
248 };
249
250
251 #endif // _IO360_HXX_