]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_engine.cpp
- catch exception from readProperties and exit
[flightgear.git] / src / FDM / UIUCModel / uiuc_engine.cpp
1 /**********************************************************************
2
3  FILENAME:     uiuc_engine.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  determine the engine forces and moments
8                
9 ----------------------------------------------------------------------
10
11  STATUS:       alpha version
12
13 ----------------------------------------------------------------------
14
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
18
19 ----------------------------------------------------------------------
20
21  HISTORY:      01/30/2000   initial release
22
23 ----------------------------------------------------------------------
24
25  AUTHOR(S):    Bipin Sehgal       <bsehgal@uiuc.edu>
26                Jeff Scott         <jscott@mail.com>
27                Michael Selig      <m-selig@uiuc.edu>
28
29 ----------------------------------------------------------------------
30
31  VARIABLES:
32
33 ----------------------------------------------------------------------
34
35  INPUTS:       -engine model
36
37 ----------------------------------------------------------------------
38
39  OUTPUTS:      -F_X_engine
40                -F_Z_engine
41                -M_m_engine
42
43 ----------------------------------------------------------------------
44
45  CALLED BY:   uiuc_wrapper.cpp 
46
47 ----------------------------------------------------------------------
48
49  CALLS TO:     none
50
51 ----------------------------------------------------------------------
52
53  COPYRIGHT:    (C) 2000 by Michael Selig
54
55  This program is free software; you can redistribute it and/or
56  modify it under the terms of the GNU General Public License
57  as published by the Free Software Foundation.
58
59  This program is distributed in the hope that it will be useful,
60  but WITHOUT ANY WARRANTY; without even the implied warranty of
61  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
62  GNU General Public License for more details.
63
64  You should have received a copy of the GNU General Public License
65  along with this program; if not, write to the Free Software
66  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
67  USA or view http://www.gnu.org/copyleft/gpl.html.
68
69 **********************************************************************/
70 #include <simgear/compiler.h>
71
72 #include "uiuc_engine.h"
73
74 #if !defined (SG_HAVE_NATIVE_SGI_COMPILERS)
75 SG_USING_STD(cerr);
76 #endif
77
78 void uiuc_engine() 
79 {
80   stack command_list;
81   string linetoken1;
82   string linetoken2;
83   
84   Throttle[3] = Throttle_pct;
85
86   command_list = engineParts -> getCommands();
87
88   /*
89   if (command_list.begin() == command_list.end())
90   {
91         cerr << "ERROR: Engine not specified. Aircraft cannot fly without the engine" << endl;
92         exit(-1);
93   }
94   */
95  
96   for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
97     {
98       //cout << *command_line << endl;
99       
100       linetoken1 = engineParts -> getToken(*command_line, 1);
101       linetoken2 = engineParts -> getToken(*command_line, 2);
102       
103       switch(engine_map[linetoken2])
104         {
105         case simpleSingle_flag:
106           {
107             F_X_engine = Throttle[3] * simpleSingleMaxThrust;
108             break;
109           }
110         case c172_flag:
111           {
112             //c172 engine lines ... looks like 0.83 is just a thrust increase
113             F_X_engine = Throttle[3] * 350 / 0.83;
114             F_Z_engine = Throttle[3] * 4.9 / 0.83;
115             M_m_engine = F_X_engine * 0.734 * cbar;
116             break;
117           }
118         case cherokee_flag:
119           {
120             static float
121               dP = (180.0-117.0)*745.7,   // Watts
122               dn = (2700.0-2350.0)/60.0,  // d_rpm (I mean d_rps, in seconds)
123               D  = 6.17*0.3048,           // prop diameter
124               dPh = (58.0-180.0)*745.7,   // change of power as function of height
125               dH = 25000.0*0.3048;
126
127             float
128               n,   // [rps]
129               H,   // altitude [m]
130               J,   // advance ratio (ratio of horizontal speed to prop tip speed)
131               T,   // thrust [N]
132               V,   // velocity [m/s]
133               P,   // power [W]
134               eta_engine; // engine efficiency
135
136             /* assumption -> 0.0 <= Throttle[3] <=1.0 */
137             P = fabs(Throttle[3]) * 180.0 * 745.7; /*180.0*745.7 ->max avail power [W]*/
138             n = dn/dP * (P-117.0*745.7) + 2350.0/60.0;
139
140             /*  V  [m/s]   */
141             V = (V_rel_wind < 10.0 ? 10.0 : V_rel_wind*0.3048);
142             J = V / n / D;
143
144             /* Propeller efficiency */
145             eta_engine = (J < 0.7 ? ((0.8-0.55)/(.7-.3)*(J-0.3) + 0.55) : 
146                           (J > 0.85 ? ((0.6-0.8)/(1.0-0.85)*(J-0.85) + 0.8) : 0.8));
147
148             /* power on Altitude */
149             H = Altitude * 0.3048;       /* H == Altitude [m] */
150             P *= (dPh/dH * H + 180.0*745.7) / (180.0*745.7);
151             T = eta_engine * P/V;        /* Thrust [N] */ 
152
153             /*assumption: Engine's line of thrust passes through cg */
154             F_X_engine = T * 0.2248;     /* F_X_engine in lb */
155             F_Y_engine = 0.0;
156             F_Z_engine = 0.0;
157             break;
158           }
159         };
160     }
161   return;
162 }
163
164 // end uiuc_engine.cpp