]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_coefficients.cpp
Updates to the UIUCModel code. This includes some big compile time
[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_2U   = ch /   (2.0 * V_rel_wind);
121         }
122       else if (use_dyn_on_speed_curve1)
123         {
124           V_rel_wind_dum = dyn_on_speed_zero + V_rel_wind * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
125           cbar_2U        = cbar / (2.0 * V_rel_wind_dum);
126           b_2U           = bw /   (2.0 * V_rel_wind_dum);
127           ch_2U          = ch /   (2.0 * V_rel_wind_dum);
128         }
129       else
130         {
131           cbar_2U = 0.0;
132           b_2U    = 0.0;
133           ch_2U   = 0.0;
134         }
135     }
136   else if(use_abs_U_body_2U)      // use absolute(U_body)
137     {
138       if (fabs(U_body) > dyn_on_speed)
139         {
140           cbar_2U = cbar / (2.0 * fabs(U_body));
141           b_2U    = bw /   (2.0 * fabs(U_body));
142           ch_2U   = ch /   (2.0 * fabs(U_body));
143         }
144       else if (use_dyn_on_speed_curve1)
145         {
146           U_body_dum = dyn_on_speed_zero + fabs(U_body) * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
147           cbar_2U    = cbar / (2.0 * U_body_dum);
148           b_2U       = bw /   (2.0 * U_body_dum);
149           ch_2U      = ch /   (2.0 * U_body_dum);
150         }
151       else
152         {
153           cbar_2U = 0.0;
154           b_2U    = 0.0;
155           ch_2U   = 0.0;
156         }
157     }
158   else      // use U_body
159     {
160       if (U_body > dyn_on_speed)
161         {
162           cbar_2U = cbar / (2.0 * U_body);
163           b_2U    = bw /   (2.0 * U_body);
164           ch_2U   = ch /   (2.0 * U_body);
165         }
166       else if (use_dyn_on_speed_curve1)
167         {
168           U_body_dum = dyn_on_speed_zero + U_body * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
169           cbar_2U    = cbar / (2.0 * U_body_dum);
170           b_2U       = bw /   (2.0 * U_body_dum);
171           ch_2U      = ch /   (2.0 * U_body_dum);
172           beta_flow_clean_tail = cbar_2U;
173         }
174       else
175         {
176           cbar_2U = 0.0;
177           b_2U    = 0.0;
178           ch_2U   = 0.0;
179         }
180     }
181
182   // check to see if icing model engaged
183   if (ice_model)
184     {
185       uiuc_iceboot(dt);
186       uiuc_ice_eta();
187     }
188
189   // check to see if data files are used for control deflections
190   pilot_elev_no = false;
191   pilot_ail_no = false;
192   pilot_rud_no = false;
193   if (elevator_step || elevator_singlet || elevator_doublet || elevator_input || aileron_input || rudder_input)
194     {
195       uiuc_controlInput();
196     }
197
198   CD = CX = CL = CZ = Cm = CY = Cl = Cn = 0.0;
199   CLclean_wing = CLiced_wing = CLclean_tail = CLiced_tail = 0.0;
200   CZclean_wing = CZiced_wing = CZclean_tail = CZiced_tail = 0.0;
201   CXclean_wing = CXiced_wing = CXclean_tail = CXiced_tail = 0.0;
202
203   uiuc_coef_lift();
204   uiuc_coef_drag();
205   uiuc_coef_pitch();
206   uiuc_coef_sideforce();
207   uiuc_coef_roll();
208   uiuc_coef_yaw();
209   if (ice_case)
210     {
211       eta_tail = sublimation(OATemperature_F, eta_tail, dt);
212       eta_wing_left = sublimation(OATemperature_F, eta_wing_left, dt);
213       eta_wing_right = sublimation(OATemperature_F, eta_wing_right, dt);
214       //removed shed until new model is created
215       //eta_tail = shed(0.0, eta_tail, OATemperature_F, 0.0, dt);
216       //eta_wing_left = shed(0.0, eta_wing_left, OATemperature_F, 0.0, dt);
217       //eta_wing_right = shed(0.0, eta_wing_right, OATemperature_F, 0.0, dt);
218       
219       Calc_Iced_Forces();
220       add_ice_effects();
221     }
222
223   if (pilot_ail_no)
224     {
225       if (aileron <=0)
226         Lat_control = - aileron / damax * RAD_TO_DEG;
227       else
228         Lat_control = - aileron / damin * RAD_TO_DEG;
229     }
230
231   if (pilot_elev_no)
232     {
233       l_trim = elevator_tab;
234       l_defl = elevator - elevator_tab;
235       if (l_trim <=0 )
236         Long_trim = l_trim / demax * RAD_TO_DEG;
237       else
238         Long_trim = l_trim / demin * RAD_TO_DEG;
239       if (l_defl <= 0)
240         Long_control = l_defl / demax * RAD_TO_DEG;
241       else
242         Long_control = l_defl / demin * RAD_TO_DEG;
243     }
244
245   if (pilot_rud_no)
246     {
247       if (rudder <=0)
248         Rudder_pedal = - rudder / drmax * RAD_TO_DEG;
249       else
250         Rudder_pedal = - rudder / drmin * RAD_TO_DEG;
251     }
252
253   return;
254 }
255
256 // end uiuc_coefficients.cpp