2 // Author: Phil Schubert
3 // Date started: 12/03/99
4 // Purpose: Models a Continental IO-520-M Engine
5 // Called by: FGSimExec
7 // Copyright (C) 1999 Philip L. Schubert (philings@ozemail.com.au)
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.
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.
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
24 // Further information about the GNU General Public License can also
25 // be found on the world wide web at http://www.gnu.org.
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
36 // ------------------------------------------------------------------------
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
45 // 15/03/99 PLS Added Oil Pressure, Oil Temperature and CH Temp
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
53 #include <simgear/compiler.h>
60 #if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
61 SG_USING_STD(ofstream);
68 float CONVERT_HP_TO_WATTS;
69 float CONVERT_CUBIC_INCHES_TO_METERS_CUBED;
71 // Control and environment inputs
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;
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
88 float Mag_Derate_Percent;
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
96 float Fuel_Flow_gals_hr; // gals/hour
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
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
109 float Torque_Imbalance;
110 bool started; //flag to indicate the engine is running self sustaining
111 bool cranking; //flag to indicate the engine is being cranked
114 float volumetric_efficiency;
115 float combustion_efficiency;
116 float equivalence_ratio;
121 float True_Manifold_Pressure; //in Hg
122 float rho_air_manifold;
124 float p_amb_sea_level; // Pascals
125 float p_amb; // Pascals
126 float T_amb; // deg Kelvin
127 float calorific_value_fuel;
129 float rho_fuel; // kg/m^3
131 float delta_T_exhaust;
132 float displacement; // Engine displacement in cubic inches - to be read in from config file for each engine
133 float displacement_SI; // ditto in meters cubed
134 float Cp_air; // J/KgK
135 float Cp_fuel; // J/KgK
136 float heat_capacity_exhaust;
137 float enthalpy_exhaust;
138 float Percentage_of_best_power_mixture_power;
139 float abstract_mixture; //temporary hack
140 float engine_inertia; //kg.m^2
141 float prop_inertia; //kg.m^2
142 float angular_acceleration; //rad/s^2
145 // Propellor Variables
146 float FGProp1_Thrust;
148 float FGProp1_Blade_Angle;
149 float prop_torque; // Nm
150 float prop_thrust; // Newtons
151 float blade_length; // meters
152 float forward_velocity; // m/s
153 float angular_velocity_SI; // rad/s
154 float prop_power_consumed_SI; // Watts
155 float prop_power_consumed_HP; // HP
156 double prop_diameter; // meters
157 double J; // advance ratio - dimensionless
158 double Cp_20; // coefficient of power for 20 degree blade angle
159 double Cp_25; // coefficient of power for 25 degree blade angle
160 double Cp; // Our actual coefficient of power
161 double blade_angle; // degrees
164 double neta_prop; // prop efficiency
166 // Calculate Engine RPM based on Propellor Lever Position
167 float Calc_Engine_RPM(float Position);
169 // Calculate Manifold Pressure based on throttle lever position
170 // Note that this is simplistic and needs altering to include engine speed effects
171 float Calc_Manifold_Pressure( float LeverPosn, float MaxMan, float MinMan);
173 // Calculate combustion efficiency based on equivalence ratio
174 float Lookup_Combustion_Efficiency(float thi_actual);
176 // Calculate percentage of best power mixture power based on equivalence ratio
177 float Power_Mixture_Correlation(float thi_actual);
179 // Calculate exhaust gas temperature rise
180 float Calculate_Delta_T_Exhaust(void);
182 // Calculate Oil Temperature
183 float Calc_Oil_Temp (float Fuel_Flow, float Mixture, float IAS);
185 // Calculate Oil Pressure
186 float Calc_Oil_Press (float Oil_Temp, float Engine_RPM);
194 // outfile.open("FGNewEngine.dat", ios::out|ios::trunc);
202 // set initial default values
203 void init(double dt);
205 // update the engine model based on current control positions
208 inline void set_IAS( float value ) { IAS = value; }
209 inline void set_Throttle_Lever_Pos( float value ) {
210 Throttle_Lever_Pos = value;
212 inline void set_Propeller_Lever_Pos( float value ) {
213 Propeller_Lever_Pos = value;
215 inline void set_Mixture_Lever_Pos( float value ) {
216 Mixture_Lever_Pos = value;
218 // set ambient pressure - takes pounds per square foot
219 inline void set_p_amb( float value ) {
220 p_amb = value * 47.88026;
221 // Convert to Pascals
223 // set ambient temperature - takes degrees Rankine
224 inline void set_T_amb( float value ) {
225 T_amb = value * 0.555555555556;
226 // Convert to degrees Kelvin
230 inline float get_RPM() const { return RPM; }
231 inline float get_Manifold_Pressure() const { return True_Manifold_Pressure; }
232 inline float get_FGProp1_Thrust() const { return FGProp1_Thrust; }
233 inline float get_FGProp1_Blade_Angle() const { return FGProp1_Blade_Angle; }
235 // inline float get_Rho() const { return Rho; }
236 inline float get_MaxHP() const { return MaxHP; }
237 inline float get_Percentage_Power() const { return Percentage_Power; }
238 inline float get_EGT() const { return EGT_degF; } // Returns EGT in Fahrenheit
239 inline float get_CHT() const { return CHT_degF; } // Note this returns CHT in Fahrenheit
240 inline float get_prop_thrust_SI() const { return prop_thrust; }
241 inline float get_prop_thrust_lbs() const { return (prop_thrust * 0.2248); }
242 inline float get_fuel_flow_gals_hr() const { return (Fuel_Flow_gals_hr); }
246 #endif // _IO360_HXX_