]> git.mxchange.org Git - flightgear.git/blob - src/FDM/LaRCsim/cherokee_engine.c
Adds a basic FDM model for LaRCsim debugging purposes.
[flightgear.git] / src / FDM / LaRCsim / cherokee_engine.c
1 /*
2 cherokee_engine.c
3
4 very rough model of Lycoming engine built in PA-28 Cherokee
5 Only "AD" characteristics are modelled, no transient behaviour,
6 meaning that there is no time delay, engine acts as gain only.
7
8
9
10                 Based upon book:
11                                 Barnes W. McCormick,
12                                 "Aerodynamics, Aeronautics and Flight Mechanics",
13                                 John Wiley & Sons,1995, ISBN 0-471-11087-6
14
15         any suggestions, corrections, aditional data, flames, everything to 
16         Gordan Sikic
17         gsikic@public.srce.hr
18
19
20 This source is not checked in this configuration in any way.
21
22
23 */
24
25
26
27 #include <float.h>
28 #include <math.h>
29 #include "ls_types.h"
30 #include "ls_constants.h"
31 #include "ls_generic.h"
32 #include "ls_cockpit.h"
33 #include "ls_sim_control.h"
34
35
36
37
38
39 void cherokee_engine( SCALAR dt, int init )
40 {
41
42         static float
43                 dP = (180.0-117.0)*745.7,   // in Wats
44                 dn = (2700.0-2350.0)/60.0,  // d_rpm (I mean d_rps, in seconds)
45                 D  = 6.17*0.3048,                       // propeller diameter
46                 dPh = (58.0-180.0)*745.7,       // change of power as f-cn of height
47                 dH = 25000.0*0.3048;
48
49         float   n,                      // rps
50                         H,
51                         J,                      // advance ratio (ratio of horizontal speed to speed of propeller's tip)
52                         eta,            // iskoristivost elise
53                         T,
54                         V,
55                         P;
56
57 /* copied from  navion_engine.c */
58     if (init || sim_control_.sim_type != cockpit) 
59         Throttle[3] = Throttle_pct;
60
61         /*assumption -> 0.0 <= Throttle[3] <=1.0 */
62         P = fabs(Throttle[3])*180.0*745.7;              /*180.0*745.5 ->max avail power in W */
63         n = dn/dP*(P-117.0*745.7) + 2350.0/60.0;
64
65 /*  V  [m/s]   */
66         V = (V_rel_wind < 10.0*0.3048 ? 10.0 : V_rel_wind*0.3048);
67
68         J = V/n/D;  
69
70
71 /*
72         propeller efficiency
73
74 if J >0.7 & J < .85
75         eta = 0.8;
76 elseif J < 0.7
77         eta = (0.8-0.55)/(.7-.3)*(J-0.3) + 0.55;
78 else
79         eta = (0.6-0.8)/(1.0-0.85)*(J-0.85) + 0.8;
80 end
81 */
82         eta = (J < 0.7 ? ((0.8-0.55)/(.7-.3)*(J-0.3) + 0.55) : 
83                         (J > 0.85 ? ((0.6-0.8)/(1.0-0.85)*(J-0.85) + 0.8) : 0.8));
84
85
86
87 /* power on Altitude  (I mean Altitude, not Attitude...)*/
88
89         H = Altitude/0.3048; /* H == Altitude in [m] */
90         
91         P *= (dPh/dH*H + 180.0*745.7)/(180.0*745.7);
92
93         T = eta*P/V;    /* T in N (Thrust in Newtons) */ 
94
95 /*assumption: Engine's line of thrust passes through cg */
96
97     F_X_engine = T*0.2248;      /* F_X_engine in lb */
98     F_Y_engine = 0.0;
99     F_Z_engine = 0.0;
100
101 /* copied from  navion_engine.c */
102     Throttle_pct = Throttle[3];
103
104 }