Debian Codegraph @

src/FDM/LaRCsim/cherokee_engine.c

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