]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_coefficients.cpp
Updated Cameron's entry.
[flightgear.git] / src / FDM / UIUCModel / uiuc_coefficients.cpp
1 /**********************************************************************
2
3  FILENAME:     uiuc_coefficients.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  computes aggregated aerodynamic coefficients
8
9 ----------------------------------------------------------------------
10
11  STATUS:       alpha version
12
13 ----------------------------------------------------------------------
14
15  REFERENCES:   
16
17 ----------------------------------------------------------------------
18
19  HISTORY:      01/29/2000   initial release
20                02/01/2000   (JS) changed map name from aeroData to 
21                             aeroPart
22                02/18/2000   (JS) added calls to 1Dinterpolation 
23                             function from CLfa and CDfa switches
24                02/24/2000   added icing model functions
25                02/29/2000   (JS) added calls to 2Dinterpolation 
26                             function from CLfade, CDfade, Cmfade, 
27                             CYfada, CYfbetadr, Clfada, Clfbetadr, 
28                             Cnfada, and Cnfbetadr switches
29                04/15/2000   (JS) broke up into multiple 
30                             uiuc_coef_xxx functions
31                06/18/2001   (RD) Added initialization of Alpha and
32                             Beta.  Added aileron_input and rudder_input.
33                             Added pilot_elev_no, pilot_ail_no, and
34                             pilot_rud_no.
35                07/05/2001   (RD) Added pilot_(elev,ail,rud)_no=false
36
37 ----------------------------------------------------------------------
38
39  AUTHOR(S):    Bipin Sehgal       <bsehgal@uiuc.edu>
40                Jeff Scott         <jscott@mail.com>
41                Robert Deters      <rdeters@uiuc.edu>
42
43 ----------------------------------------------------------------------
44
45  VARIABLES:
46
47 ----------------------------------------------------------------------
48
49  INPUTS:       -V_rel_wind (or U_body)
50                -dyn_on_speed
51                -ice on/off
52                -phugoid on/off
53
54 ----------------------------------------------------------------------
55
56  OUTPUTS:      -CL
57                -CD
58                -Cm
59                -CY
60                -Cl
61                -Cn
62
63 ----------------------------------------------------------------------
64
65  CALLED BY:    uiuc_wrapper
66
67 ----------------------------------------------------------------------
68
69  CALLS TO:     uiuc_coef_lift
70                uiuc_coef_drag
71                uiuc_coef_pitch
72                uiuc_coef_sideforce
73                uiuc_coef_roll
74                uiuc_coef_yaw
75                uiuc_controlInput
76
77 ----------------------------------------------------------------------
78
79  COPYRIGHT:    (C) 2000 by Michael Selig
80
81  This program is free software; you can redistribute it and/or
82  modify it under the terms of the GNU General Public License
83  as published by the Free Software Foundation.
84
85  This program is distributed in the hope that it will be useful,
86  but WITHOUT ANY WARRANTY; without even the implied warranty of
87  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
88  GNU General Public License for more details.
89
90  You should have received a copy of the GNU General Public License
91  along with this program; if not, write to the Free Software
92  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
93  USA or view http://www.gnu.org/copyleft/gpl.html.
94
95 **********************************************************************/
96
97 #include "uiuc_coefficients.h"
98
99
100 void uiuc_coefficients()
101 {
102   double l_trim, l_defl;
103
104   if (Alpha_init_true && Simtime==0)
105     Alpha = Alpha_init;
106
107   if (Beta_init_true && Simtime==0)
108     Beta = Beta_init;
109
110   // calculate rate derivative nondimensionalization factors
111   // check if speed is sufficient to compute dynamic pressure terms
112   if (nondim_rate_V_rel_wind)         // c172_aero uses V_rel_wind
113     {
114       if (V_rel_wind > dyn_on_speed)
115         {
116           cbar_2U = cbar / (2.0 * V_rel_wind);
117           b_2U = bw / (2.0 * V_rel_wind);
118           ch_2U = ch / (2.0 * V_rel_wind);
119         }
120       else
121         {
122           cbar_2U = 0.0;
123           b_2U = 0.0;
124           ch_2U = 0.0;
125         }
126     }
127   else      // use U_body which is probably more correct
128     {
129       if (U_body > dyn_on_speed)
130         {
131           cbar_2U = cbar / (2.0 * U_body);
132           b_2U = bw / (2.0 * U_body);
133           ch_2U = ch / (2.0 * U_body);
134         }
135       else
136         {
137           cbar_2U = 0.0;
138           b_2U = 0.0;
139           ch_2U = 0.0;
140         }
141     }
142
143   // check to see if icing model engaged
144   if (ice_model)
145     {
146       uiuc_ice_eta();
147     }
148
149   // check to see if data files are used for control deflections
150   pilot_elev_no = false;
151   pilot_ail_no = false;
152   pilot_rud_no = false;
153   if (elevator_step || elevator_singlet || elevator_doublet || elevator_input || aileron_input || rudder_input)
154     {
155       uiuc_controlInput();
156     }
157
158   CD = CX = CL = CZ = Cm = CY = Cl = Cn = 0.0;
159   CLclean_wing = CLiced_wing = CLclean_tail = CLiced_tail = 0.0;
160   CZclean_wing = CZiced_wing = CZclean_tail = CZiced_tail = 0.0;
161   CXclean_wing = CXiced_wing = CXclean_tail = CXiced_tail = 0.0;
162
163   uiuc_coef_lift();
164   uiuc_coef_drag();
165   uiuc_coef_pitch();
166   uiuc_coef_sideforce();
167   uiuc_coef_roll();
168   uiuc_coef_yaw();
169
170   if (pilot_ail_no)
171     {
172       if (aileron <=0)
173         Lat_control = - aileron / damax * RAD_TO_DEG;
174       else
175         Lat_control = - aileron / damin * RAD_TO_DEG;
176     }
177
178   if (pilot_elev_no)
179     {
180       l_trim = elevator_tab;
181       l_defl = elevator - elevator_tab;
182       if (l_trim <=0 )
183         Long_trim = l_trim / demax * RAD_TO_DEG;
184       else
185         Long_trim = l_trim / demin * RAD_TO_DEG;
186       if (l_defl <= 0)
187         Long_control = l_defl / demax * RAD_TO_DEG;
188       else
189         Long_control = l_defl / demin * RAD_TO_DEG;
190     }
191
192   if (pilot_rud_no)
193     {
194       if (rudder <=0)
195         Rudder_pedal = - rudder / drmax * RAD_TO_DEG;
196       else
197         Rudder_pedal = - rudder / drmin * RAD_TO_DEG;
198     }
199
200   return;
201 }
202
203 // end uiuc_coefficients.cpp