]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_coefficients.cpp
Added static port system and a new altimeter model connected to it.
[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                01/11/2002   (AP) Added call to uiuc_bootTime()
37                
38 ----------------------------------------------------------------------
39
40  AUTHOR(S):    Bipin Sehgal       <bsehgal@uiuc.edu>
41                Jeff Scott         <jscott@mail.com>
42                Robert Deters      <rdeters@uiuc.edu>
43                Ann Peedikayil     <peedikay@uiuc.edu>
44 ----------------------------------------------------------------------
45
46  VARIABLES:
47
48 ----------------------------------------------------------------------
49
50  INPUTS:       -V_rel_wind (or U_body)
51                -dyn_on_speed
52                -ice on/off
53                -phugoid on/off
54
55 ----------------------------------------------------------------------
56
57  OUTPUTS:      -CL
58                -CD
59                -Cm
60                -CY
61                -Cl
62                -Cn
63
64 ----------------------------------------------------------------------
65
66  CALLED BY:    uiuc_wrapper
67
68 ----------------------------------------------------------------------
69
70  CALLS TO:     uiuc_coef_lift
71                uiuc_coef_drag
72                uiuc_coef_pitch
73                uiuc_coef_sideforce
74                uiuc_coef_roll
75                uiuc_coef_yaw
76                uiuc_controlInput
77
78 ----------------------------------------------------------------------
79
80  COPYRIGHT:    (C) 2000 by Michael Selig
81
82  This program is free software; you can redistribute it and/or
83  modify it under the terms of the GNU General Public License
84  as published by the Free Software Foundation.
85
86  This program is distributed in the hope that it will be useful,
87  but WITHOUT ANY WARRANTY; without even the implied warranty of
88  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
89  GNU General Public License for more details.
90
91  You should have received a copy of the GNU General Public License
92  along with this program; if not, write to the Free Software
93  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
94  USA or view http://www.gnu.org/copyleft/gpl.html.
95
96 **********************************************************************/
97
98 #include "uiuc_coefficients.h"
99
100
101 void uiuc_coefficients(double dt)
102 {
103   double l_trim, l_defl;
104   double V_rel_wind_dum, U_body_dum;
105
106   if (Alpha_init_true && Simtime==0)
107     Alpha = Alpha_init;
108
109   if (Beta_init_true && Simtime==0)
110     Beta = Beta_init;
111
112   // calculate rate derivative nondimensionalization factors
113   // check if speed is sufficient to compute dynamic pressure terms
114   if (nondim_rate_V_rel_wind || use_V_rel_wind_2U)         // c172_aero uses V_rel_wind
115     {
116       if (V_rel_wind > dyn_on_speed)
117         {
118           cbar_2U = cbar / (2.0 * V_rel_wind);
119           b_2U    = bw /   (2.0 * V_rel_wind);
120           // ch is the horizontal tail chord
121           ch_2U   = ch /   (2.0 * V_rel_wind);
122         }
123       else if (use_dyn_on_speed_curve1)
124         {
125           V_rel_wind_dum = dyn_on_speed_zero + V_rel_wind * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
126           cbar_2U        = cbar / (2.0 * V_rel_wind_dum);
127           b_2U           = bw /   (2.0 * V_rel_wind_dum);
128           ch_2U          = ch /   (2.0 * V_rel_wind_dum);
129           Alpha_dot      = 0.0;
130         }
131       else
132         {
133           cbar_2U   = 0.0;
134           b_2U      = 0.0;
135           ch_2U     = 0.0;
136           Alpha_dot = 0.0;
137         }
138     }
139   else if(use_abs_U_body_2U)      // use absolute(U_body)
140     {
141       if (fabs(U_body) > dyn_on_speed)
142         {
143           cbar_2U = cbar / (2.0 * fabs(U_body));
144           b_2U    = bw /   (2.0 * fabs(U_body));
145           ch_2U   = ch /   (2.0 * fabs(U_body));
146         }
147       else if (use_dyn_on_speed_curve1)
148         {
149           U_body_dum = dyn_on_speed_zero + fabs(U_body) * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
150           cbar_2U    = cbar / (2.0 * U_body_dum);
151           b_2U       = bw /   (2.0 * U_body_dum);
152           ch_2U      = ch /   (2.0 * U_body_dum);
153           Alpha_dot  = 0.0;
154         }
155       else
156         {
157           cbar_2U   = 0.0;
158           b_2U      = 0.0;
159           ch_2U     = 0.0;
160           Alpha_dot = 0.0;
161         }
162     }
163   else      // use U_body
164     {
165       if (U_body > dyn_on_speed)
166         {
167           cbar_2U = cbar / (2.0 * U_body);
168           b_2U    = bw /   (2.0 * U_body);
169           ch_2U   = ch /   (2.0 * U_body);
170         }
171       else if (use_dyn_on_speed_curve1)
172         {
173           U_body_dum = dyn_on_speed_zero + U_body * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
174           cbar_2U    = cbar / (2.0 * U_body_dum);
175           b_2U       = bw /   (2.0 * U_body_dum);
176           ch_2U      = ch /   (2.0 * U_body_dum);
177           Alpha_dot  = 0.0;
178           beta_flow_clean_tail = cbar_2U;
179         }
180       else
181         {
182           cbar_2U   = 0.0;
183           b_2U      = 0.0;
184           ch_2U     = 0.0;
185           Alpha_dot = 0.0;
186         }
187     }
188
189   // check if speed is sufficient to "trust" Alpha_dot value
190   if (use_Alpha_dot_on_speed)
191     {
192       if (V_rel_wind     < Alpha_dot_on_speed)
193           Alpha_dot = 0.0;
194     }
195
196
197   // check to see if icing model engaged
198   if (ice_model)
199     {
200       uiuc_iceboot(dt);
201       uiuc_ice_eta();
202     }
203
204   // check to see if data files are used for control deflections
205   pilot_elev_no = false;
206   pilot_ail_no = false;
207   pilot_rud_no = false;
208   if (elevator_step || elevator_singlet || elevator_doublet || elevator_input || aileron_input || rudder_input)
209     {
210       uiuc_controlInput();
211     }
212
213   CD = CX = CL = CZ = Cm = CY = Cl = Cn = 0.0;
214   CLclean_wing = CLiced_wing = CLclean_tail = CLiced_tail = 0.0;
215   CZclean_wing = CZiced_wing = CZclean_tail = CZiced_tail = 0.0;
216   CXclean_wing = CXiced_wing = CXclean_tail = CXiced_tail = 0.0;
217
218   uiuc_coef_lift();
219   uiuc_coef_drag();
220   uiuc_coef_pitch();
221   uiuc_coef_sideforce();
222   uiuc_coef_roll();
223   uiuc_coef_yaw();
224   if (ice_case)
225     {
226       eta_tail = sublimation(OATemperature_F, eta_tail, dt);
227       eta_wing_left = sublimation(OATemperature_F, eta_wing_left, dt);
228       eta_wing_right = sublimation(OATemperature_F, eta_wing_right, dt);
229       //removed shed until new model is created
230       //eta_tail = shed(0.0, eta_tail, OATemperature_F, 0.0, dt);
231       //eta_wing_left = shed(0.0, eta_wing_left, OATemperature_F, 0.0, dt);
232       //eta_wing_right = shed(0.0, eta_wing_right, OATemperature_F, 0.0, dt);
233       
234       Calc_Iced_Forces();
235       add_ice_effects();
236     }
237
238   if (pilot_ail_no)
239     {
240       if (aileron <=0)
241         Lat_control = - aileron / damax * RAD_TO_DEG;
242       else
243         Lat_control = - aileron / damin * RAD_TO_DEG;
244     }
245
246   if (pilot_elev_no)
247     {
248       l_trim = elevator_tab;
249       l_defl = elevator - elevator_tab;
250       if (l_trim <=0 )
251         Long_trim = l_trim / demax * RAD_TO_DEG;
252       else
253         Long_trim = l_trim / demin * RAD_TO_DEG;
254       if (l_defl <= 0)
255         Long_control = l_defl / demax * RAD_TO_DEG;
256       else
257         Long_control = l_defl / demin * RAD_TO_DEG;
258     }
259
260   if (pilot_rud_no)
261     {
262       if (rudder <=0)
263         Rudder_pedal = - rudder / drmax * RAD_TO_DEG;
264       else
265         Rudder_pedal = - rudder / drmin * RAD_TO_DEG;
266     }
267
268   return;
269 }
270
271 // end uiuc_coefficients.cpp