1 /**********************************************************************
3 FILENAME: uiuc_engine.cpp
5 ----------------------------------------------------------------------
7 DESCRIPTION: determine the engine forces and moments
9 ----------------------------------------------------------------------
13 ----------------------------------------------------------------------
15 REFERENCES: simple and c172 models based on portions of
16 c172_engine.c, called from ls_model;
17 cherokee model based on cherokee_engine.c
19 ----------------------------------------------------------------------
21 HISTORY: 01/30/2000 initial release
22 06/18/2001 (RD) Added Throttle_pct_input.
24 ----------------------------------------------------------------------
26 AUTHOR(S): Bipin Sehgal <bsehgal@uiuc.edu>
27 Jeff Scott <jscott@mail.com>
28 Robert Deters <rdeters@uiuc.edu>
29 Michael Selig <m-selig@uiuc.edu>
31 ----------------------------------------------------------------------
35 ----------------------------------------------------------------------
39 ----------------------------------------------------------------------
45 ----------------------------------------------------------------------
47 CALLED BY: uiuc_wrapper.cpp
49 ----------------------------------------------------------------------
53 ----------------------------------------------------------------------
55 COPYRIGHT: (C) 2000 by Michael Selig
57 This program is free software; you can redistribute it and/or
58 modify it under the terms of the GNU General Public License
59 as published by the Free Software Foundation.
61 This program is distributed in the hope that it will be useful,
62 but WITHOUT ANY WARRANTY; without even the implied warranty of
63 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64 GNU General Public License for more details.
66 You should have received a copy of the GNU General Public License
67 along with this program; if not, write to the Free Software
68 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
69 USA or view http://www.gnu.org/copyleft/gpl.html.
71 **********************************************************************/
72 #include <simgear/compiler.h>
74 #include "uiuc_engine.h"
84 if (outside_control == false)
85 pilot_throttle_no = false;
86 if (Throttle_pct_input)
88 double Throttle_pct_input_endTime = Throttle_pct_input_timeArray[Throttle_pct_input_ntime];
89 if (Simtime >= Throttle_pct_input_startTime &&
90 Simtime <= (Throttle_pct_input_startTime + Throttle_pct_input_endTime))
92 double time = Simtime - Throttle_pct_input_startTime;
93 Throttle_pct = uiuc_1Dinterpolation(Throttle_pct_input_timeArray,
94 Throttle_pct_input_dTArray,
95 Throttle_pct_input_ntime,
97 pilot_throttle_no = true;
101 Throttle[3] = Throttle_pct;
103 command_list = engineParts -> getCommands();
106 if (command_list.begin() == command_list.end())
108 cerr << "ERROR: Engine not specified. Aircraft cannot fly without the engine" << endl;
113 for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
115 //cout << *command_line << endl;
117 linetoken1 = engineParts -> getToken(*command_line, 1);
118 linetoken2 = engineParts -> getToken(*command_line, 2);
120 switch(engine_map[linetoken2])
122 case simpleSingle_flag:
124 F_X_engine = Throttle[3] * simpleSingleMaxThrust;
132 case simpleSingleModel_flag:
134 /* simple model based on Hepperle's equation
135 * exponent dtdvvt was computed in uiuc_menu.cpp */
136 F_X_engine = Throttle[3] * t_v0 * (1 - pow((V_rel_wind/v_t0),dtdvvt));
142 if (b_slipstreamEffects) {
143 tc = F_X_engine/(Dynamic_pressure * LS_PI * propDia * propDia / 4);
144 w_induced = 0.5 * V_rel_wind * (-1 + pow((1+tc),.5));
145 eta_q = (2* w_induced + V_rel_wind)*(2* w_induced + V_rel_wind)/(V_rel_wind * V_rel_wind);
146 /* add in a die-off function so that eta falls off w/ alfa and beta */
147 eta_q = Cos_alpha * Cos_alpha * Cos_beta * Cos_beta * eta_q;
148 /* determine the eta_q values for the respective coefficients */
149 if (eta_q_Cm_q_fac) {eta_q_Cm_q *= eta_q * eta_q_Cm_q_fac;}
150 if (eta_q_Cm_adot_fac) {eta_q_Cm_adot *= eta_q * eta_q_Cm_adot_fac;}
151 if (eta_q_Cmfade_fac) {eta_q_Cmfade *= eta_q * eta_q_Cmfade_fac;}
152 if (eta_q_Cm_de_fac) {eta_q_Cm_de *= eta_q * eta_q_Cm_de_fac;}
153 if (eta_q_Cl_beta_fac) {eta_q_Cl_beta *= eta_q * eta_q_Cl_beta_fac;}
154 if (eta_q_Cl_p_fac) {eta_q_Cl_p *= eta_q * eta_q_Cl_p_fac;}
155 if (eta_q_Cl_r_fac) {eta_q_Cl_r *= eta_q * eta_q_Cl_r_fac;}
156 if (eta_q_Cl_dr_fac) {eta_q_Cl_dr *= eta_q * eta_q_Cl_dr_fac;}
157 if (eta_q_CY_beta_fac) {eta_q_CY_beta *= eta_q * eta_q_CY_beta_fac;}
158 if (eta_q_CY_p_fac) {eta_q_CY_p *= eta_q * eta_q_CY_p_fac;}
159 if (eta_q_CY_r_fac) {eta_q_CY_r *= eta_q * eta_q_CY_r_fac;}
160 if (eta_q_CY_dr_fac) {eta_q_CY_dr *= eta_q * eta_q_CY_dr_fac;}
161 if (eta_q_Cn_beta_fac) {eta_q_Cn_beta *= eta_q * eta_q_Cn_beta_fac;}
162 if (eta_q_Cn_p_fac) {eta_q_Cn_p *= eta_q * eta_q_Cn_p_fac;}
163 if (eta_q_Cn_r_fac) {eta_q_Cn_r *= eta_q * eta_q_Cn_r_fac;}
164 if (eta_q_Cn_dr_fac) {eta_q_Cn_dr *= eta_q * eta_q_Cn_dr_fac;}
166 /* Need engineOmega for gyroscopic moments */
167 engineOmega = minOmega + Throttle[3] * (maxOmega - minOmega);
172 //c172 engine lines ... looks like 0.83 is just a thrust increase
173 F_X_engine = Throttle[3] * 350 / 0.83;
174 F_Z_engine = Throttle[3] * 4.9 / 0.83;
175 M_m_engine = F_X_engine * 0.734 * cbar;
181 dP = (180.0-117.0)*745.7, // Watts
182 dn = (2700.0-2350.0)/60.0, // d_rpm (I mean d_rps, in seconds)
183 D = 6.17*0.3048, // prop diameter
184 dPh = (58.0-180.0)*745.7, // change of power as function of height
190 J, // advance ratio (ratio of horizontal speed to prop tip speed)
194 eta_engine; // engine efficiency
196 /* assumption -> 0.0 <= Throttle[3] <=1.0 */
197 P = fabs(Throttle[3]) * 180.0 * 745.7; /*180.0*745.7 ->max avail power [W]*/
198 n = dn/dP * (P-117.0*745.7) + 2350.0/60.0;
201 V = (V_rel_wind < 10.0 ? 10.0 : V_rel_wind*0.3048);
204 /* Propeller efficiency */
205 eta_engine = (J < 0.7 ? ((0.8-0.55)/(.7-.3)*(J-0.3) + 0.55) :
206 (J > 0.85 ? ((0.6-0.8)/(1.0-0.85)*(J-0.85) + 0.8) : 0.8));
208 /* power on Altitude */
209 H = Altitude * 0.3048; /* H == Altitude [m] */
210 P *= (dPh/dH * H + 180.0*745.7) / (180.0*745.7);
211 T = eta_engine * P/V; /* Thrust [N] */
213 /*assumption: Engine's line of thrust passes through cg */
214 F_X_engine = T * 0.2248; /* F_X_engine in lb */
221 double Xp_input_endTime = Xp_input_timeArray[Xp_input_ntime];
222 if (Simtime >= Xp_input_startTime &&
223 Simtime <= (Xp_input_startTime + Xp_input_endTime))
225 double time = Simtime - Xp_input_startTime;
226 F_X_engine = uiuc_1Dinterpolation(Xp_input_timeArray,
231 double Zp_input_endTime = Zp_input_timeArray[Zp_input_ntime];
232 if (Simtime >= Zp_input_startTime &&
233 Simtime <= (Zp_input_startTime + Zp_input_endTime))
235 double time = Simtime - Zp_input_startTime;
236 F_Z_engine = uiuc_1Dinterpolation(Zp_input_timeArray,
241 double Mp_input_endTime = Mp_input_timeArray[Mp_input_ntime];
242 if (Simtime >= Mp_input_startTime &&
243 Simtime <= (Mp_input_startTime + Mp_input_endTime))
245 double time = Simtime - Mp_input_startTime;
246 M_m_engine = uiuc_1Dinterpolation(Mp_input_timeArray,
257 // end uiuc_engine.cpp