]> git.mxchange.org Git - flightgear.git/blob - src/FDM/IO360.hxx
99eacb29a78f96e3d361e3896d6de0775fbbf464
[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 #define DCL_PROP_MODEL
54 //#define NEVS_PROP_MODEL
55 //#define PHILS_PROP_MODEL
56
57 #include <simgear/compiler.h>
58
59 #include <iostream>
60 #include <fstream>
61 #include <math.h>
62
63 FG_USING_STD(ofstream);
64
65 class FGNewEngine {
66
67 private:
68
69
70
71     float CONVERT_HP_TO_WATTS;
72     float CONVERT_CUBIC_INCHES_TO_METERS_CUBED;
73
74     // Control and environment inputs
75     float IAS;
76     // 0 = Closed, 100 = Fully Open
77     float Throttle_Lever_Pos;
78     // 0 = Full Course 100 = Full Fine
79     float Propeller_Lever_Pos;
80     // 0 = Idle Cut Off 100 = Full Rich
81     float Mixture_Lever_Pos;
82
83     // Engine Specific Variables used by this program that have limits.
84     // Will be set in a parameter file to be read in to create
85     // and instance for each engine.
86     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.
87     float Min_Manifold_Pressure;  //Closed throttle valueat idle - governed by the idle bypass valve
88     float Max_RPM;
89     float Min_RPM;
90     float Max_Fuel_Flow;
91     float Mag_Derate_Percent;
92     float MaxHP;
93     float Gear_Ratio;
94
95     // Initialise Engine Variables used by this instance
96     float Percentage_Power;     // Power output as percentage of maximum power output
97     float Manifold_Pressure;    // Inches
98     float RPM;
99     float Fuel_Flow;            // lbs/hour
100     float Torque;
101     float CHT;                  // Cylinder head temperature deg K
102     float CHT_degF;             // Ditto in deg Fahrenheit
103     float EGT;                  // Exhaust gas temperature deg K
104     float EGT_degF;             // Exhaust gas temperature deg Fahrenheit
105     float Mixture;
106     float Oil_Pressure;         // PSI
107     float Oil_Temp;             // Deg C
108     float HP;                   // Current power output in HP
109     float Power_SI;             // Current power output in Watts
110     float Torque_SI;            // Torque in Nm
111     float RPS;
112     float Torque_Imbalance;
113     bool  started;              //flag to indicate the engine is running self sustaining
114     bool  cranking;             //flag to indicate the engine is being cranked
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 thi_sea_level;
132     float delta_T_exhaust;
133     float displacement;         // Engine displacement in cubic inches - to be read in from config file for each engine
134     float displacement_SI;      // ditto in meters cubed
135     float Cp_air;               // J/KgK
136     float Cp_fuel;              // J/KgK
137     float heat_capacity_exhaust;
138     float enthalpy_exhaust;
139     float Percentage_of_best_power_mixture_power;
140     float abstract_mixture;     //temporary hack
141     float engine_inertia;       //kg.m^2
142     float prop_inertia;         //kg.m^2
143     float angular_acceleration; //rad/s^2
144     double time_step;
145
146     // Initialise Propellor Variables used by this instance
147     float FGProp1_Angular_V;
148     float FGProp1_Coef_Drag;
149     float FGProp1_Torque;
150     float FGProp1_Thrust;
151     float FGProp1_RPS;
152     float FGProp1_Coef_Lift;
153     float Alpha1;
154     float FGProp1_Blade_Angle;
155     float FGProp_Fine_Pitch_Stop;
156
157 //#ifdef NEVS_PROP_MODEL
158     //Extra Propellor variables used by Nev's prop model
159     float prop_fudge_factor;
160     float prop_torque;          // Nm
161     float prop_thrust;          // Newtons
162     float blade_length;         // meters
163     float allowance_for_spinner;        // meters
164     float num_elements;
165     float distance;
166     float number_of_blades;
167     float forward_velocity;             // m/s
168     float angular_velocity_SI;          // rad/s
169     float element;
170     float element_drag;
171     float element_lift;
172     float element_torque;
173     float rho_air;
174     float prop_power_consumed_SI;       // Watts
175     float prop_power_consumed_HP;       // HP
176     float theta[6];     //prop angle of each element
177 //#endif // NEVS_PROP_MODEL
178
179     // Other internal values
180     float Rho;
181
182     // Calculate Engine RPM based on Propellor Lever Position
183     float Calc_Engine_RPM (float Position);
184
185     // Calculate combustion efficiency based on equivalence ratio
186     float Lookup_Combustion_Efficiency(float thi_actual);
187
188     // Calculate exhaust gas temperature rise
189     float Calculate_Delta_T_Exhaust(void);
190
191 public:
192
193     ofstream outfile;
194
195     //constructor
196     FGNewEngine() {
197 //      outfile.open("FGNewEngine.dat", ios::out|ios::trunc);
198     }
199
200     //destructor
201     ~FGNewEngine() {
202 //      outfile.close();
203     }
204
205     // set initial default values
206     void init(double dt);
207
208     // update the engine model based on current control positions
209     void update();
210
211     inline void set_IAS( float value ) { IAS = value; }
212     inline void set_Throttle_Lever_Pos( float value ) {
213         Throttle_Lever_Pos = value;
214     }
215     inline void set_Propeller_Lever_Pos( float value ) {
216         Propeller_Lever_Pos = value;
217     }
218     inline void set_Mixture_Lever_Pos( float value ) {
219         Mixture_Lever_Pos = value;
220     }
221
222     // accessors
223     inline float get_RPM() const { return RPM; }
224     inline float get_Manifold_Pressure() const { return Manifold_Pressure; }
225     inline float get_FGProp1_Thrust() const { return FGProp1_Thrust; }
226     inline float get_FGProp1_Blade_Angle() const { return FGProp1_Blade_Angle; }
227
228     inline float get_Rho() const { return Rho; }
229     inline float get_MaxHP() const { return MaxHP; }
230     inline float get_Percentage_Power() const { return Percentage_Power; }
231     inline float get_EGT() const { return EGT_degF; }    // Returns EGT in Fahrenheit
232     inline float get_CHT() const { return CHT_degF; }    // Note this returns CHT in Fahrenheit
233     inline float get_prop_thrust_SI() const { return prop_thrust; }
234     inline float get_prop_thrust_lbs() const { return (prop_thrust * 0.2248); }
235 };
236
237
238 #endif // _IO360_HXX_