]> git.mxchange.org Git - flightgear.git/blob - src/FDM/IO360.hxx
de40ec730f7ada0db40c17e9d63137927ee7d583
[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 <iostream>
56 #include <fstream>
57 #include <math.h>
58
59 SG_USING_STD(ofstream);
60
61 class FGNewEngine {
62
63 private:
64
65     float CONVERT_HP_TO_WATTS;
66     float CONVERT_CUBIC_INCHES_TO_METERS_CUBED;
67
68     // Control and environment inputs
69     float IAS;
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;
76
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
82     float Max_RPM;
83     float Min_RPM;
84     float Max_Fuel_Flow;
85     float Mag_Derate_Percent;
86     float MaxHP;
87     float Gear_Ratio;
88
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
92     float RPM;
93     float Fuel_Flow_gals_hr;    // gals/hour
94     float Torque;
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
99     float Mixture;
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
105     float RPS;
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
109
110     //DCL
111     float volumetric_efficiency;
112     float combustion_efficiency;
113     float equivalence_ratio;
114     float v_dot_air;
115     float m_dot_air;
116     float m_dot_fuel;
117     float swept_volume;
118     float True_Manifold_Pressure;   //in Hg
119     float rho_air_manifold;
120     float R_air;
121     float p_amb_sea_level;      // Pascals
122     float p_amb;                // Pascals
123     float T_amb;                // deg Kelvin
124     float calorific_value_fuel;
125     float rho_air;
126     float rho_fuel;             // kg/m^3
127     float thi_sea_level;
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
140     double time_step;
141
142     // Propellor Variables
143     float FGProp1_Thrust;
144     float FGProp1_RPS;
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
159     double neta_prop_20;
160     double neta_prop_25;
161     double neta_prop;               // prop efficiency
162
163     // Calculate Engine RPM based on Propellor Lever Position
164     float Calc_Engine_RPM(float Position);
165
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);
169
170     // Calculate combustion efficiency based on equivalence ratio
171     float Lookup_Combustion_Efficiency(float thi_actual);
172
173     // Calculate percentage of best power mixture power based on equivalence ratio
174     float Power_Mixture_Correlation(float thi_actual);
175
176     // Calculate exhaust gas temperature rise
177     float Calculate_Delta_T_Exhaust(void);
178
179     // Calculate Oil Temperature
180     float Calc_Oil_Temp (float Fuel_Flow, float Mixture, float IAS);
181     
182     // Calculate Oil Pressure
183     float Calc_Oil_Press (float Oil_Temp, float Engine_RPM);
184
185 public:
186
187     ofstream outfile;
188
189     //constructor
190     FGNewEngine() {
191 //      outfile.open("FGNewEngine.dat", ios::out|ios::trunc);
192     }
193
194     //destructor
195     ~FGNewEngine() {
196 //      outfile.close();
197     }
198
199     // set initial default values
200     void init(double dt);
201
202     // update the engine model based on current control positions
203     void update();
204
205     inline void set_IAS( float value ) { IAS = value; }
206     inline void set_Throttle_Lever_Pos( float value ) {
207         Throttle_Lever_Pos = value;
208     }
209     inline void set_Propeller_Lever_Pos( float value ) {
210         Propeller_Lever_Pos = value;
211     }
212     inline void set_Mixture_Lever_Pos( float value ) {
213         Mixture_Lever_Pos = value;
214     }
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
219     }
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
224     }
225
226     // accessors
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; }
231
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); }
240 };
241
242
243 #endif // _IO360_HXX_