1 /**********************************************************************
3 FILENAME: uiuc_coefficients.cpp
5 ----------------------------------------------------------------------
7 DESCRIPTION: computes aggregated aerodynamic coefficients
9 ----------------------------------------------------------------------
13 ----------------------------------------------------------------------
17 ----------------------------------------------------------------------
19 HISTORY: 01/29/2000 initial release
20 02/01/2000 (JS) changed map name from aeroData to
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 Std_Alpha and
32 Std_Beta. Added aileron_input and rudder_input.
33 Added pilot_elev_no, pilot_ail_no, and
35 07/05/2001 (RD) Added pilot_(elev,ail,rud)_no=false
36 01/11/2002 (AP) Added call to uiuc_iceboot()
37 12/02/2002 (RD) Moved icing demo interpolations to its
40 ----------------------------------------------------------------------
42 AUTHOR(S): Bipin Sehgal <bsehgal@uiuc.edu>
43 Jeff Scott <jscott@mail.com>
44 Robert Deters <rdeters@uiuc.edu>
45 Ann Peedikayil <peedikay@uiuc.edu>
46 ----------------------------------------------------------------------
50 ----------------------------------------------------------------------
52 INPUTS: -V_rel_wind (or U_body)
57 ----------------------------------------------------------------------
66 ----------------------------------------------------------------------
68 CALLED BY: uiuc_wrapper
70 ----------------------------------------------------------------------
72 CALLS TO: uiuc_coef_lift
80 ----------------------------------------------------------------------
82 COPYRIGHT: (C) 2000 by Michael Selig
84 This program is free software; you can redistribute it and/or
85 modify it under the terms of the GNU General Public License
86 as published by the Free Software Foundation.
88 This program is distributed in the hope that it will be useful,
89 but WITHOUT ANY WARRANTY; without even the implied warranty of
90 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
91 GNU General Public License for more details.
93 You should have received a copy of the GNU General Public License
94 along with this program; if not, write to the Free Software
95 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
96 USA or view http://www.gnu.org/copyleft/gpl.html.
98 **********************************************************************/
100 #include "uiuc_coefficients.h"
102 void uiuc_coefficients(double dt)
104 static string uiuc_coefficients_error = " (from uiuc_coefficients.cpp) ";
105 double l_trim, l_defl;
106 double V_rel_wind_dum, U_body_dum;
108 if (Alpha_init_true && Simtime==0)
109 Std_Alpha = Alpha_init;
111 if (Beta_init_true && Simtime==0)
112 Std_Beta = Beta_init;
114 // calculate rate derivative nondimensionalization factors
115 // check if speed is sufficient to compute dynamic pressure terms
118 uiuc_warnings_errors(5, uiuc_coefficients_error);
120 if (nondim_rate_V_rel_wind || use_V_rel_wind_2U) // c172_aero uses V_rel_wind
122 if (V_rel_wind > dyn_on_speed)
124 cbar_2U = cbar / (2.0 * V_rel_wind);
125 b_2U = bw / (2.0 * V_rel_wind);
126 // chord_h is the horizontal tail chord
127 ch_2U = chord_h / (2.0 * V_rel_wind);
129 else if (use_dyn_on_speed_curve1)
131 V_rel_wind_dum = dyn_on_speed_zero + V_rel_wind * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
132 cbar_2U = cbar / (2.0 * V_rel_wind_dum);
133 b_2U = bw / (2.0 * V_rel_wind_dum);
134 ch_2U = chord_h / (2.0 * V_rel_wind_dum);
145 else if(use_abs_U_body_2U) // use absolute(U_body)
147 if (fabs(U_body) > dyn_on_speed)
149 cbar_2U = cbar / (2.0 * fabs(U_body));
150 b_2U = bw / (2.0 * fabs(U_body));
151 ch_2U = chord_h / (2.0 * fabs(U_body));
153 else if (use_dyn_on_speed_curve1)
155 U_body_dum = dyn_on_speed_zero + fabs(U_body) * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
156 cbar_2U = cbar / (2.0 * U_body_dum);
157 b_2U = bw / (2.0 * U_body_dum);
158 ch_2U = chord_h / (2.0 * U_body_dum);
171 if (U_body > dyn_on_speed)
173 cbar_2U = cbar / (2.0 * U_body);
174 b_2U = bw / (2.0 * U_body);
175 ch_2U = chord_h / (2.0 * U_body);
177 else if (use_dyn_on_speed_curve1)
179 U_body_dum = dyn_on_speed_zero + U_body * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
180 cbar_2U = cbar / (2.0 * U_body_dum);
181 b_2U = bw / (2.0 * U_body_dum);
182 ch_2U = chord_h / (2.0 * U_body_dum);
184 beta_flow_clean_tail = cbar_2U;
195 // check if speed is sufficient to "trust" Std_Alpha_dot value
196 if (use_Alpha_dot_on_speed)
198 if (V_rel_wind < Alpha_dot_on_speed)
203 // check to see if icing model engaged
210 // check to see if data files are used for control deflections
211 if (outside_control == false)
213 pilot_elev_no = false;
214 pilot_ail_no = false;
215 pilot_rud_no = false;
217 if (elevator_step || elevator_singlet || elevator_doublet || elevator_input || aileron_input || rudder_input || flap_pos_input)
222 //if (Simtime >=10.0)
225 // ap_Psi_ref_rad = 0*DEG_TO_RAD;
228 if (ap_pah_on || ap_alh_on || ap_rah_on || ap_hh_on)
233 CD = CX = CL = CZ = Cm = CY = Cl = Cn = 0.0;
234 CLclean_wing = CLiced_wing = CLclean_tail = CLiced_tail = 0.0;
235 CZclean_wing = CZiced_wing = CZclean_tail = CZiced_tail = 0.0;
236 CXclean_wing = CXiced_wing = CXclean_tail = CXiced_tail = 0.0;
237 CL_clean = CL_iced = 0.0;
238 CY_clean = CY_iced = 0.0;
239 CD_clean = CD_iced = 0.0;
240 Cm_iced = Cm_clean = 0.0;
241 Cl_iced = Cl_clean = 0.0;
242 Cn_iced = Cn_clean = 0.0;
247 uiuc_coef_sideforce();
251 //uncomment next line to always run icing functions
252 //nonlin_ice_case = 1;
258 if (eta_tail_input) {
259 double time = Simtime - eta_tail_input_startTime;
260 eta_tail = uiuc_1Dinterpolation(eta_tail_input_timeArray,
261 eta_tail_input_daArray,
262 eta_tail_input_ntime,
265 if (eta_wing_left_input) {
266 double time = Simtime - eta_wing_left_input_startTime;
267 eta_wing_left = uiuc_1Dinterpolation(eta_wing_left_input_timeArray,
268 eta_wing_left_input_daArray,
269 eta_wing_left_input_ntime,
272 if (eta_wing_right_input) {
273 double time = Simtime - eta_wing_right_input_startTime;
274 eta_wing_right = uiuc_1Dinterpolation(eta_wing_right_input_timeArray,
275 eta_wing_right_input_daArray,
276 eta_wing_right_input_ntime,
281 delta_CL = delta_CD = delta_Cm = delta_Cl = delta_Cn = 0.0;
285 if (eta_tail == 0.2 && tactile_pitch && tactilefadef)
287 if (tactilefadef_nice == 1)
288 tactilefadefI = uiuc_3Dinterp_quick(tactilefadef_fArray,
289 tactilefadef_aArray_nice,
290 tactilefadef_deArray_nice,
291 tactilefadef_tactileArray,
292 tactilefadef_na_nice,
293 tactilefadef_nde_nice,
299 tactilefadefI = uiuc_3Dinterpolation(tactilefadef_fArray,
301 tactilefadef_deArray,
302 tactilefadef_tactileArray,
303 tactilefadef_nAlphaArray,
310 else if (demo_tactile)
312 double time = Simtime - demo_tactile_startTime;
313 tactilefadefI = uiuc_1Dinterpolation(demo_tactile_timeArray,
314 demo_tactile_daArray,
325 Lat_control = - aileron / damax * RAD_TO_DEG;
327 Lat_control = - aileron / damin * RAD_TO_DEG;
330 // can go past real limits
331 // add flag to behave like trim_case2 later
334 if (outside_control == false)
336 l_trim = elevator_tab;
337 l_defl = elevator - elevator_tab;
339 Long_trim = l_trim / demax * RAD_TO_DEG;
341 Long_trim = l_trim / demin * RAD_TO_DEG;
343 Long_control = l_defl / demax * RAD_TO_DEG;
345 Long_control = l_defl / demin * RAD_TO_DEG;
352 Rudder_pedal = - rudder / drmax * RAD_TO_DEG;
354 Rudder_pedal = - rudder / drmin * RAD_TO_DEG;
360 // end uiuc_coefficients.cpp