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>
59 FG_USING_STD(ofstream);
65 float CONVERT_HP_TO_WATTS;
66 float CONVERT_CUBIC_INCHES_TO_METERS_CUBED;
68 // Control and environment inputs
70 // 0 = Closed, 100 = Fully Open
71 float Throttle_Lever_Pos;
72 // 0 = Full Course 100 = Full Fine
73 float Propeller_Lever_Pos;
74 // 0 = Idle Cut Off 100 = Full Rich
75 float Mixture_Lever_Pos;
77 // Engine Specific Variables used by this program that have limits.
78 // Will be set in a parameter file to be read in to create
79 // and instance for each engine.
80 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.
81 float Min_Manifold_Pressure; //Closed throttle valueat idle - governed by the idle bypass valve
85 float Mag_Derate_Percent;
89 // Initialise Engine Variables used by this instance
90 float Percentage_Power; // Power output as percentage of maximum power output
91 float Manifold_Pressure; // Inches
93 float Fuel_Flow_gals_hr; // gals/hour
95 float CHT; // Cylinder head temperature deg K
96 float CHT_degF; // Ditto in deg Fahrenheit
97 float EGT; // Exhaust gas temperature deg K
98 float EGT_degF; // Exhaust gas temperature deg Fahrenheit
100 float Oil_Pressure; // PSI
101 float Oil_Temp; // Deg C
102 float HP; // Current power output in HP
103 float Power_SI; // Current power output in Watts
104 float Torque_SI; // Torque in Nm
106 float Torque_Imbalance;
107 bool started; //flag to indicate the engine is running self sustaining
108 bool cranking; //flag to indicate the engine is being cranked
111 float volumetric_efficiency;
112 float combustion_efficiency;
113 float equivalence_ratio;
118 float True_Manifold_Pressure; //in Hg
119 float rho_air_manifold;
121 float p_amb_sea_level; // Pascals
122 float p_amb; // Pascals
123 float T_amb; // deg Kelvin
124 float calorific_value_fuel;
126 float rho_fuel; // kg/m^3
128 float delta_T_exhaust;
129 float displacement; // Engine displacement in cubic inches - to be read in from config file for each engine
130 float displacement_SI; // ditto in meters cubed
131 float Cp_air; // J/KgK
132 float Cp_fuel; // J/KgK
133 float heat_capacity_exhaust;
134 float enthalpy_exhaust;
135 float Percentage_of_best_power_mixture_power;
136 float abstract_mixture; //temporary hack
137 float engine_inertia; //kg.m^2
138 float prop_inertia; //kg.m^2
139 float angular_acceleration; //rad/s^2
142 // Propellor Variables
143 float FGProp1_Thrust;
145 float FGProp1_Blade_Angle;
146 float prop_torque; // Nm
147 float prop_thrust; // Newtons
148 float blade_length; // meters
149 float forward_velocity; // m/s
150 float angular_velocity_SI; // rad/s
151 float prop_power_consumed_SI; // Watts
152 float prop_power_consumed_HP; // HP
153 double prop_diameter; // meters
154 double J; // advance ratio - dimensionless
155 double Cp_20; // coefficient of power for 20 degree blade angle
156 double Cp_25; // coefficient of power for 25 degree blade angle
157 double Cp; // Our actual coefficient of power
158 double blade_angle; // degrees
161 double neta_prop; // prop efficiency
163 // Calculate Engine RPM based on Propellor Lever Position
164 float Calc_Engine_RPM(float Position);
166 // Calculate Manifold Pressure based on throttle lever position
167 // Note that this is simplistic and needs altering to include engine speed effects
168 float Calc_Manifold_Pressure( float LeverPosn, float MaxMan, float MinMan);
170 // Calculate combustion efficiency based on equivalence ratio
171 float Lookup_Combustion_Efficiency(float thi_actual);
173 // Calculate percentage of best power mixture power based on equivalence ratio
174 float Power_Mixture_Correlation(float thi_actual);
176 // Calculate exhaust gas temperature rise
177 float Calculate_Delta_T_Exhaust(void);
179 // Calculate Oil Temperature
180 float Calc_Oil_Temp (float Fuel_Flow, float Mixture, float IAS);
182 // Calculate Oil Pressure
183 float Calc_Oil_Press (float Oil_Temp, float Engine_RPM);
191 // outfile.open("FGNewEngine.dat", ios::out|ios::trunc);
199 // set initial default values
200 void init(double dt);
202 // update the engine model based on current control positions
205 inline void set_IAS( float value ) { IAS = value; }
206 inline void set_Throttle_Lever_Pos( float value ) {
207 Throttle_Lever_Pos = value;
209 inline void set_Propeller_Lever_Pos( float value ) {
210 Propeller_Lever_Pos = value;
212 inline void set_Mixture_Lever_Pos( float value ) {
213 Mixture_Lever_Pos = value;
215 // set ambient pressure - takes pounds per square foot
216 inline void set_p_amb( float value ) {
217 p_amb = value * 47.88026;
218 // Convert to Pascals
220 // set ambient temperature - takes degrees Rankine
221 inline void set_T_amb( float value ) {
222 T_amb = value * 0.555555555556;
223 // Convert to degrees Kelvin
227 inline float get_RPM() const { return RPM; }
228 inline float get_Manifold_Pressure() const { return True_Manifold_Pressure; }
229 inline float get_FGProp1_Thrust() const { return FGProp1_Thrust; }
230 inline float get_FGProp1_Blade_Angle() const { return FGProp1_Blade_Angle; }
232 // inline float get_Rho() const { return Rho; }
233 inline float get_MaxHP() const { return MaxHP; }
234 inline float get_Percentage_Power() const { return Percentage_Power; }
235 inline float get_EGT() const { return EGT_degF; } // Returns EGT in Fahrenheit
236 inline float get_CHT() const { return CHT_degF; } // Note this returns CHT in Fahrenheit
237 inline float get_prop_thrust_SI() const { return prop_thrust; }
238 inline float get_prop_thrust_lbs() const { return (prop_thrust * 0.2248); }
239 inline float get_fuel_flow_gals_hr() const { return (Fuel_Flow_gals_hr); }
243 #endif // _IO360_HXX_