1 /**********************************************************************
3 FILENAME: uiuc_coefficients.cpp
5 ----------------------------------------------------------------------
7 DESCRIPTION: computes aggregated aerodynamic coefficients
9 ----------------------------------------------------------------------
13 ----------------------------------------------------------------------
15 REFERENCES: Roskam, Jan. Airplane Flight Dynamics and Automatic
16 Flight Controls, Part I. Lawrence, KS: DARcorporation,
19 ----------------------------------------------------------------------
21 HISTORY: 01/29/2000 initial release
22 02/01/2000 (JS) changed map name from aeroData to
24 02/18/2000 (JS) added calls to 1Dinterpolation
25 function from CLfa and CDfa switches
26 02/24/2000 added icing model functions
27 02/29/2000 (JS) added calls to 2Dinterpolation
28 function from CLfade, CDfade, Cmfade,
29 CYfada, CYfbetadr, Clfada, Clfbetadr,
30 Cnfada, and Cnfbetadr switches
32 ----------------------------------------------------------------------
34 AUTHOR(S): Bipin Sehgal <bsehgal@uiuc.edu>
35 Jeff Scott <jscott@mail.com>
37 ----------------------------------------------------------------------
41 ----------------------------------------------------------------------
47 -coefficient components
49 ----------------------------------------------------------------------
58 ----------------------------------------------------------------------
62 ----------------------------------------------------------------------
64 CALLS TO: uiuc_1Dinterpolation
68 ----------------------------------------------------------------------
70 COPYRIGHT: (C) 2000 by Michael Selig
72 This program is free software; you can redistribute it and/or
73 modify it under the terms of the GNU General Public License
74 as published by the Free Software Foundation.
76 This program is distributed in the hope that it will be useful,
77 but WITHOUT ANY WARRANTY; without even the implied warranty of
78 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
79 GNU General Public License for more details.
81 You should have received a copy of the GNU General Public License
82 along with this program; if not, write to the Free Software
83 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
84 USA or view http://www.gnu.org/copyleft/gpl.html.
86 **********************************************************************/
88 #include "uiuc_coefficients.h"
91 /* set speed at which dynamic pressure terms will be accounted for
92 since if velocity is too small, coefficients will go to infinity */
94 #define ON_VELOCITY 33 /* 20 kts */
97 void uiuc_coefficients()
102 double cbar_2U = 0, b_2U = 0;
106 // determine if speed is sufficient to compute dynamic pressure
107 if (U_body > ON_VELOCITY)
109 cbar_2U = cbar / (2.0 * U_body);
110 b_2U = bw / (2.0 * U_body);
118 //check to see if icing model engaged and set flag
119 if (Simtime >= iceTime)
124 // slowly increase icing severity over period of transientTime
125 if (Simtime >= iceTime && Simtime < (iceTime + transientTime))
127 slope = eta_final / transientTime;
128 eta = slope * (Simtime - iceTime);
135 CL = CD = Cm = CY = Cl = Cn = 0.0;
136 command_list = aeroParts -> getCommands();
139 for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
141 linetoken1 = aeroParts -> getToken(*command_line, 1); // function parameters gettoken(string,tokenNo);
142 linetoken2 = aeroParts -> getToken(*command_line, 2); // 2 represents token No 2
144 switch (Keyword_map[linetoken1])
148 switch(CD_map[linetoken2])
154 CDo = uiuc_ice(CDo_clean,kCDo,eta);
163 CDK = uiuc_ice(CDK_clean,kCDK,eta);
172 CD_a = uiuc_ice(CD_a_clean,kCD_a,eta);
181 CD_de = uiuc_ice(CD_de_clean,kCD_de,eta);
183 CD += CD_de * elevator;
188 CDfaI = uiuc_1Dinterpolation(CDfa_aArray,
197 CDfadeI = uiuc_2Dinterpolation(CDfade_aArray,
212 switch(CL_map[linetoken2])
218 CLo = uiuc_ice(CLo_clean,kCLo,eta);
227 CL_a = uiuc_ice(CL_a_clean,kCL_a,eta);
236 CL_adot = uiuc_ice(CL_adot_clean,kCL_a,eta);
238 /* CL_adot must be mulitplied by cbar/2U
239 (see Roskam Control book, Part 1, pg. 147) */
240 CL += CL_adot * Alpha_dot * cbar_2U;
247 CL_q = uiuc_ice(CL_q_clean,kCL_q,eta);
249 /* CL_q must be mulitplied by cbar/2U
250 (see Roskam Control book, Part 1, pg. 147) */
251 /* why multiply by Theta_dot instead of Q_body?
252 that is what is done in c172_aero.c; assume it
253 has something to do with axes systems */
254 CL += CL_q * Theta_dot * cbar_2U;
261 CL_de = uiuc_ice(CL_de_clean,kCL_de,eta);
263 CL += CL_de * elevator;
268 CLfaI = uiuc_1Dinterpolation(CLfa_aArray,
277 CLfadeI = uiuc_2Dinterpolation(CLfade_aArray,
292 switch(Cm_map[linetoken2])
298 Cmo = uiuc_ice(Cmo_clean,kCmo,eta);
307 Cm_a = uiuc_ice(Cm_a_clean,kCm_a,eta);
316 Cm_adot = uiuc_ice(Cm_adot_clean,kCm_a,eta);
318 /* Cm_adot must be mulitplied by cbar/2U
319 (see Roskam Control book, Part 1, pg. 147) */
320 Cm += Cm_adot * Alpha_dot * cbar_2U;
327 Cm_q = uiuc_ice(Cm_q_clean,kCm_q,eta);
329 /* Cm_q must be mulitplied by cbar/2U
330 (see Roskam Control book, Part 1, pg. 147) */
331 Cm += Cm_q * Q_body * cbar_2U;
338 Cm_de = uiuc_ice(Cm_de_clean,kCm_de,eta);
340 Cm += Cm_de * elevator;
345 CmfadeI = uiuc_2Dinterpolation(Cmfade_aArray,
360 switch(CY_map[linetoken2])
366 CYo = uiuc_ice(CYo_clean,kCYo,eta);
375 CY_beta = uiuc_ice(CY_beta_clean,kCY_beta,eta);
377 CY += CY_beta * Beta;
384 CY_p = uiuc_ice(CY_p_clean,kCY_p,eta);
386 /* CY_p must be mulitplied by b/2U
387 (see Roskam Control book, Part 1, pg. 147) */
388 CY += CY_p * P_body * b_2U;
395 CY_r = uiuc_ice(CY_r_clean,kCY_r,eta);
397 /* CY_r must be mulitplied by b/2U
398 (see Roskam Control book, Part 1, pg. 147) */
399 CY += CY_r * R_body * b_2U;
406 CY_da = uiuc_ice(CY_da_clean,kCY_da,eta);
408 CY += CY_da * aileron;
415 CY_dr = uiuc_ice(CY_dr_clean,kCY_dr,eta);
417 CY += CY_dr * rudder;
422 CYfadaI = uiuc_2Dinterpolation(CYfada_aArray,
434 CYfbetadrI = uiuc_2Dinterpolation(CYfbetadr_betaArray,
437 CYfbetadr_nBetaArray,
449 switch(Cl_map[linetoken2])
455 Clo = uiuc_ice(Clo_clean,kClo,eta);
464 Cl_beta = uiuc_ice(Cl_beta_clean,kCl_beta,eta);
466 Cl += Cl_beta * Beta;
473 Cl_p = uiuc_ice(Cl_p_clean,kCl_p,eta);
475 /* Cl_p must be mulitplied by b/2U
476 (see Roskam Control book, Part 1, pg. 147) */
477 Cl += Cl_p * P_body * b_2U;
484 Cl_r = uiuc_ice(Cl_r_clean,kCl_r,eta);
486 /* Cl_r must be mulitplied by b/2U
487 (see Roskam Control book, Part 1, pg. 147) */
488 Cl += Cl_r * R_body * b_2U;
495 Cl_da = uiuc_ice(Cl_da_clean,kCl_da,eta);
497 Cl += Cl_da * aileron;
504 Cl_dr = uiuc_ice(Cl_dr_clean,kCl_dr,eta);
506 Cl += Cl_dr * rudder;
511 ClfadaI = uiuc_2Dinterpolation(Clfada_aArray,
523 ClfbetadrI = uiuc_2Dinterpolation(Clfbetadr_betaArray,
526 Clfbetadr_nBetaArray,
538 switch(Cn_map[linetoken2])
544 Cno = uiuc_ice(Cno_clean,kCno,eta);
553 Cn_beta = uiuc_ice(Cn_beta_clean,kCn_beta,eta);
555 Cn += Cn_beta * Beta;
562 Cn_p = uiuc_ice(Cn_p_clean,kCn_p,eta);
564 /* Cn_p must be mulitplied by b/2U
565 (see Roskam Control book, Part 1, pg. 147) */
566 Cn += Cn_p * P_body * b_2U;
573 Cn_r = uiuc_ice(Cn_r_clean,kCn_r,eta);
575 /* Cn_r must be mulitplied by b/2U
576 (see Roskam Control book, Part 1, pg. 147) */
577 Cn += Cn_r * R_body * b_2U;
584 Cn_da = uiuc_ice(Cn_da_clean,kCn_da,eta);
586 Cn += Cn_da * aileron;
593 Cn_dr = uiuc_ice(Cn_dr_clean,kCn_dr,eta);
595 Cn += Cn_dr * rudder;
600 CnfadaI = uiuc_2Dinterpolation(Cnfada_aArray,
612 CnfbetadrI = uiuc_2Dinterpolation(Cnfbetadr_betaArray,
615 Cnfbetadr_nBetaArray,
631 // end uiuc_coefficients.cpp