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