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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
97 **********************************************************************/
99 #include "uiuc_coefficients.h"
101 void uiuc_coefficients(double dt)
103 static string uiuc_coefficients_error = " (from uiuc_coefficients.cpp) ";
104 double l_trim, l_defl;
105 double V_rel_wind_dum, U_body_dum;
107 if (Alpha_init_true && Simtime==0)
108 Std_Alpha = Alpha_init;
110 if (Beta_init_true && Simtime==0)
111 Std_Beta = Beta_init;
113 // calculate rate derivative nondimensionalization factors
114 // check if speed is sufficient to compute dynamic pressure terms
117 uiuc_warnings_errors(5, uiuc_coefficients_error);
119 if (nondim_rate_V_rel_wind || use_V_rel_wind_2U) // c172_aero uses V_rel_wind
121 if (V_rel_wind > dyn_on_speed)
123 cbar_2U = cbar / (2.0 * V_rel_wind);
124 b_2U = bw / (2.0 * V_rel_wind);
125 // chord_h is the horizontal tail chord
126 ch_2U = chord_h / (2.0 * V_rel_wind);
128 else if (use_dyn_on_speed_curve1)
130 V_rel_wind_dum = dyn_on_speed_zero + V_rel_wind * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
131 cbar_2U = cbar / (2.0 * V_rel_wind_dum);
132 b_2U = bw / (2.0 * V_rel_wind_dum);
133 ch_2U = chord_h / (2.0 * V_rel_wind_dum);
144 else if(use_abs_U_body_2U) // use absolute(U_body)
146 if (fabs(U_body) > dyn_on_speed)
148 cbar_2U = cbar / (2.0 * fabs(U_body));
149 b_2U = bw / (2.0 * fabs(U_body));
150 ch_2U = chord_h / (2.0 * fabs(U_body));
152 else if (use_dyn_on_speed_curve1)
154 U_body_dum = dyn_on_speed_zero + fabs(U_body) * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
155 cbar_2U = cbar / (2.0 * U_body_dum);
156 b_2U = bw / (2.0 * U_body_dum);
157 ch_2U = chord_h / (2.0 * U_body_dum);
170 if (U_body > dyn_on_speed)
172 cbar_2U = cbar / (2.0 * U_body);
173 b_2U = bw / (2.0 * U_body);
174 ch_2U = chord_h / (2.0 * U_body);
176 else if (use_dyn_on_speed_curve1)
178 U_body_dum = dyn_on_speed_zero + U_body * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
179 cbar_2U = cbar / (2.0 * U_body_dum);
180 b_2U = bw / (2.0 * U_body_dum);
181 ch_2U = chord_h / (2.0 * U_body_dum);
183 beta_flow_clean_tail = cbar_2U;
194 // check if speed is sufficient to "trust" Std_Alpha_dot value
195 if (use_Alpha_dot_on_speed)
197 if (V_rel_wind < Alpha_dot_on_speed)
202 // check to see if icing model engaged
209 // check to see if data files are used for control deflections
210 if (outside_control == false)
212 pilot_elev_no = false;
213 pilot_ail_no = false;
214 pilot_rud_no = false;
216 if (elevator_step || elevator_singlet || elevator_doublet || elevator_input || aileron_input || rudder_input || flap_pos_input)
221 //if (Simtime >=10.0)
224 // ap_Psi_ref_rad = 0*DEG_TO_RAD;
227 if (ap_pah_on || ap_alh_on || ap_rah_on || ap_hh_on)
232 CD = CX = CL = CZ = Cm = CY = Cl = Cn = 0.0;
233 CLclean_wing = CLiced_wing = CLclean_tail = CLiced_tail = 0.0;
234 CZclean_wing = CZiced_wing = CZclean_tail = CZiced_tail = 0.0;
235 CXclean_wing = CXiced_wing = CXclean_tail = CXiced_tail = 0.0;
236 CL_clean = CL_iced = 0.0;
237 CY_clean = CY_iced = 0.0;
238 CD_clean = CD_iced = 0.0;
239 Cm_iced = Cm_clean = 0.0;
240 Cl_iced = Cl_clean = 0.0;
241 Cn_iced = Cn_clean = 0.0;
246 uiuc_coef_sideforce();
250 //uncomment next line to always run icing functions
251 //nonlin_ice_case = 1;
257 if (eta_tail_input) {
258 double time = Simtime - eta_tail_input_startTime;
259 eta_tail = uiuc_1Dinterpolation(eta_tail_input_timeArray,
260 eta_tail_input_daArray,
261 eta_tail_input_ntime,
264 if (eta_wing_left_input) {
265 double time = Simtime - eta_wing_left_input_startTime;
266 eta_wing_left = uiuc_1Dinterpolation(eta_wing_left_input_timeArray,
267 eta_wing_left_input_daArray,
268 eta_wing_left_input_ntime,
271 if (eta_wing_right_input) {
272 double time = Simtime - eta_wing_right_input_startTime;
273 eta_wing_right = uiuc_1Dinterpolation(eta_wing_right_input_timeArray,
274 eta_wing_right_input_daArray,
275 eta_wing_right_input_ntime,
280 delta_CL = delta_CD = delta_Cm = delta_Cl = delta_Cn = 0.0;
284 if (eta_tail == 0.2 && tactile_pitch && tactilefadef)
286 if (tactilefadef_nice == 1)
287 tactilefadefI = uiuc_3Dinterp_quick(tactilefadef_fArray,
288 tactilefadef_aArray_nice,
289 tactilefadef_deArray_nice,
290 tactilefadef_tactileArray,
291 tactilefadef_na_nice,
292 tactilefadef_nde_nice,
298 tactilefadefI = uiuc_3Dinterpolation(tactilefadef_fArray,
300 tactilefadef_deArray,
301 tactilefadef_tactileArray,
302 tactilefadef_nAlphaArray,
309 else if (demo_tactile)
311 double time = Simtime - demo_tactile_startTime;
312 tactilefadefI = uiuc_1Dinterpolation(demo_tactile_timeArray,
313 demo_tactile_daArray,
324 Lat_control = - aileron / damax * RAD_TO_DEG;
326 Lat_control = - aileron / damin * RAD_TO_DEG;
329 // can go past real limits
330 // add flag to behave like trim_case2 later
333 if (outside_control == false)
335 l_trim = elevator_tab;
336 l_defl = elevator - elevator_tab;
338 Long_trim = l_trim / demax * RAD_TO_DEG;
340 Long_trim = l_trim / demin * RAD_TO_DEG;
342 Long_control = l_defl / demax * RAD_TO_DEG;
344 Long_control = l_defl / demin * RAD_TO_DEG;
351 Rudder_pedal = - rudder / drmax * RAD_TO_DEG;
353 Rudder_pedal = - rudder / drmin * RAD_TO_DEG;
359 // end uiuc_coefficients.cpp