]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_coef_roll.cpp
Make sure sign is preserved for turbulence direction.
[flightgear.git] / src / FDM / UIUCModel / uiuc_coef_roll.cpp
1 /**********************************************************************
2
3  FILENAME:     uiuc_coef_roll.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  computes aggregated aerodynamic roll coefficient
8
9 ----------------------------------------------------------------------
10
11  STATUS:       alpha version
12
13 ----------------------------------------------------------------------
14
15  REFERENCES:   Roskam, Jan.  Airplane Flight Dynamics and Automatic
16                Flight Controls, Part I.  Lawrence, KS: DARcorporation,
17                1995.
18
19 ----------------------------------------------------------------------
20
21  HISTORY:      04/15/2000   initial release
22                10/25/2001   (RD) Added new variables needed for the non-
23                             linear Twin Otter model at zero flaps
24                             (Clfxxf0)
25                11/12/2001   (RD) Added new variables needed for the non-
26                             linear Twin Otter model with flaps
27                             (Clfxxf).  Zero flap vairables removed.
28                02/13/2002   (RD) Added variables so linear aero model
29                             values can be recorded
30                02/18/2002   (RD) Added uiuc_3Dinterp_quick() function
31                             for a quicker 3D interpolation.  Takes
32                             advantage of "nice" data.
33
34 ----------------------------------------------------------------------
35
36  AUTHOR(S):    Bipin Sehgal       <bsehgal@uiuc.edu>
37                Jeff Scott         <jscott@mail.com>
38                Robert Deters      <rdeters@uiuc.edu>
39
40 ----------------------------------------------------------------------
41
42  VARIABLES:
43
44 ----------------------------------------------------------------------
45
46  INPUTS:       -Alpha
47                -aileron
48                -rudder
49                -roll coefficient components
50                -icing parameters
51                -b_2U multiplier
52
53 ----------------------------------------------------------------------
54
55  OUTPUTS:      -Cl
56
57 ----------------------------------------------------------------------
58
59  CALLED BY:    uiuc_coefficients.cpp
60
61 ----------------------------------------------------------------------
62
63  CALLS TO:     uiuc_1Dinterpolation
64                uiuc_2Dinterpolation
65                uiuc_ice_filter
66                uiuc_3Dinterpolation
67                uiuc_3Dinterp_quick
68
69 ----------------------------------------------------------------------
70
71  COPYRIGHT:    (C) 2000 by Michael Selig
72
73  This program is free software; you can redistribute it and/or
74  modify it under the terms of the GNU General Public License
75  as published by the Free Software Foundation.
76
77  This program is distributed in the hope that it will be useful,
78  but WITHOUT ANY WARRANTY; without even the implied warranty of
79  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
80  GNU General Public License for more details.
81
82  You should have received a copy of the GNU General Public License
83  along with this program; if not, write to the Free Software
84  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
85  USA or view http://www.gnu.org/copyleft/gpl.html.
86
87 **********************************************************************/
88
89 #include "uiuc_coef_roll.h"
90
91
92 void uiuc_coef_roll()
93 {
94   string linetoken1;
95   string linetoken2;
96   stack command_list;
97
98   double p_nondim;
99   double r_nondim;
100
101   command_list = aeroRollParts -> getCommands();
102   
103   for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
104     {
105       linetoken1 = aeroRollParts -> getToken(*command_line, 1);
106       linetoken2 = aeroRollParts -> getToken(*command_line, 2);
107
108       switch(Cl_map[linetoken2])
109         {
110         case Clo_flag:
111           {
112             if (ice_on)
113               {
114                 Clo = uiuc_ice_filter(Clo_clean,kClo);
115               }
116             Clo_save = Clo;
117             Cl += Clo_save;
118             break;
119           }
120         case Cl_beta_flag:
121           {
122             if (ice_on)
123               {
124                 Cl_beta = uiuc_ice_filter(Cl_beta_clean,kCl_beta);
125               }
126             Cl_beta_save = Cl_beta * Std_Beta;
127             if (eta_q_Cl_beta_fac)
128               {
129                 Cl += Cl_beta_save * eta_q_Cl_beta_fac;
130               }
131             else
132               {
133                 Cl += Cl_beta_save;
134               }
135             break;
136           }
137         case Cl_p_flag:
138           {
139             if (ice_on)
140               {
141                 Cl_p = uiuc_ice_filter(Cl_p_clean,kCl_p);
142               }
143             /* Cl_p must be mulitplied by b/2U 
144                (see Roskam Control book, Part 1, pg. 147) */
145             Cl_p_save = Cl_p * P_body * b_2U;
146             if (eta_q_Cl_p_fac)
147               {
148                 Cl += Cl_p_save * eta_q_Cl_p_fac;
149               }
150             else
151               {
152                 Cl += Cl_p_save;
153               }
154             break;
155           }
156         case Cl_r_flag:
157           {
158             if (ice_on)
159               {
160                 Cl_r = uiuc_ice_filter(Cl_r_clean,kCl_r);
161               }
162             /* Cl_r must be mulitplied by b/2U 
163                (see Roskam Control book, Part 1, pg. 147) */
164             Cl_r_save = Cl_r * R_body * b_2U;
165             if (eta_q_Cl_r_fac)
166               {
167                 Cl += Cl_r_save * eta_q_Cl_r_fac;
168               }
169             else
170               {
171                 Cl += Cl_r_save;
172               }
173             break;
174           }
175         case Cl_da_flag:
176           {
177             if (ice_on)
178               {
179                 Cl_da = uiuc_ice_filter(Cl_da_clean,kCl_da);
180               }
181             Cl_da_save = Cl_da * aileron;
182             Cl += Cl_da_save;
183             break;
184           }
185         case Cl_dr_flag:
186           {
187             if (ice_on)
188               {
189                 Cl_dr = uiuc_ice_filter(Cl_dr_clean,kCl_dr);
190               }
191             Cl_dr_save = Cl_dr * rudder;
192             if (eta_q_Cl_dr_fac)
193               {
194                 Cl += Cl_dr_save * eta_q_Cl_dr_fac;
195               }
196             else
197               {
198                 Cl += Cl_dr_save;
199               }
200             break;
201           }
202         case Cl_daa_flag:
203           {
204             if (ice_on)
205               {
206                 Cl_daa = uiuc_ice_filter(Cl_daa_clean,kCl_daa);
207               }
208             Cl_daa_save = Cl_daa * aileron * Std_Alpha;
209             Cl += Cl_daa_save;
210             break;
211           }
212         case Clfada_flag:
213           {
214             ClfadaI = uiuc_2Dinterpolation(Clfada_aArray,
215                                            Clfada_daArray,
216                                            Clfada_ClArray,
217                                            Clfada_nAlphaArray,
218                                            Clfada_nda,
219                                            Std_Alpha,
220                                            aileron);
221             Cl += ClfadaI;
222             break;
223           }
224         case Clfbetadr_flag:
225           {
226             ClfbetadrI = uiuc_2Dinterpolation(Clfbetadr_betaArray,
227                                               Clfbetadr_drArray,
228                                               Clfbetadr_ClArray,
229                                               Clfbetadr_nBetaArray,
230                                               Clfbetadr_ndr,
231                                               Std_Beta,
232                                               rudder);
233             Cl += ClfbetadrI;
234             break;
235           }
236         case Clfabetaf_flag:
237           {
238             if (Clfabetaf_nice == 1)
239               ClfabetafI = uiuc_3Dinterp_quick(Clfabetaf_fArray,
240                                                Clfabetaf_aArray_nice,
241                                                Clfabetaf_bArray_nice,
242                                                Clfabetaf_ClArray,
243                                                Clfabetaf_na_nice,
244                                                Clfabetaf_nb_nice,
245                                                Clfabetaf_nf,
246                                                flap_pos,
247                                                Std_Alpha,
248                                                Std_Beta);
249             else
250               ClfabetafI = uiuc_3Dinterpolation(Clfabetaf_fArray,
251                                                 Clfabetaf_aArray,
252                                                 Clfabetaf_betaArray,
253                                                 Clfabetaf_ClArray,
254                                                 Clfabetaf_nAlphaArray,
255                                                 Clfabetaf_nbeta,
256                                                 Clfabetaf_nf,
257                                                 flap_pos,
258                                                 Std_Alpha,
259                                                 Std_Beta);
260             Cl += ClfabetafI;
261             break;
262           }
263         case Clfadaf_flag:
264           {
265             if (Clfadaf_nice == 1)
266               ClfadafI = uiuc_3Dinterp_quick(Clfadaf_fArray,
267                                              Clfadaf_aArray_nice,
268                                              Clfadaf_daArray_nice,
269                                              Clfadaf_ClArray,
270                                              Clfadaf_na_nice,
271                                              Clfadaf_nda_nice,
272                                              Clfadaf_nf,
273                                              flap_pos,
274                                              Std_Alpha,
275                                              aileron);
276             else
277               ClfadafI = uiuc_3Dinterpolation(Clfadaf_fArray,
278                                               Clfadaf_aArray,
279                                               Clfadaf_daArray,
280                                               Clfadaf_ClArray,
281                                               Clfadaf_nAlphaArray,
282                                               Clfadaf_nda,
283                                               Clfadaf_nf,
284                                               flap_pos,
285                                               Std_Alpha,
286                                               aileron);
287             Cl += ClfadafI;
288             break;
289           }
290         case Clfadrf_flag:
291           {
292             if (Clfadrf_nice == 1)
293               ClfadrfI = uiuc_3Dinterp_quick(Clfadrf_fArray,
294                                              Clfadrf_aArray_nice,
295                                              Clfadrf_drArray_nice,
296                                              Clfadrf_ClArray,
297                                              Clfadrf_na_nice,
298                                              Clfadrf_ndr_nice,
299                                              Clfadrf_nf,
300                                              flap_pos,
301                                              Std_Alpha,
302                                              rudder);
303             else
304               ClfadrfI = uiuc_3Dinterpolation(Clfadrf_fArray,
305                                               Clfadrf_aArray,
306                                               Clfadrf_drArray,
307                                               Clfadrf_ClArray,
308                                               Clfadrf_nAlphaArray,
309                                               Clfadrf_ndr,
310                                               Clfadrf_nf,
311                                               flap_pos,
312                                               Std_Alpha,
313                                               rudder);
314             Cl += ClfadrfI;
315             break;
316           }
317         case Clfapf_flag:
318           {
319             p_nondim = P_body * b_2U;
320             if (Clfapf_nice == 1)
321               ClfapfI = uiuc_3Dinterp_quick(Clfapf_fArray,
322                                             Clfapf_aArray_nice,
323                                             Clfapf_pArray_nice,
324                                             Clfapf_ClArray,
325                                             Clfapf_na_nice,
326                                             Clfapf_np_nice,
327                                             Clfapf_nf,
328                                             flap_pos,
329                                             Std_Alpha,
330                                             p_nondim);
331             else
332               ClfapfI = uiuc_3Dinterpolation(Clfapf_fArray,
333                                              Clfapf_aArray,
334                                              Clfapf_pArray,
335                                              Clfapf_ClArray,
336                                              Clfapf_nAlphaArray,
337                                              Clfapf_np,
338                                              Clfapf_nf,
339                                              flap_pos,
340                                              Std_Alpha,
341                                              p_nondim);
342             Cl += ClfapfI;
343             break;
344           }
345         case Clfarf_flag:
346           {
347             r_nondim = R_body * b_2U;
348             if (Clfarf_nice == 1)
349               ClfarfI = uiuc_3Dinterp_quick(Clfarf_fArray,
350                                             Clfarf_aArray_nice,
351                                             Clfarf_rArray_nice,
352                                             Clfarf_ClArray,
353                                             Clfarf_na_nice,
354                                             Clfarf_nr_nice,
355                                             Clfarf_nf,
356                                             flap_pos,
357                                             Std_Alpha,
358                                             r_nondim);
359             else
360               ClfarfI = uiuc_3Dinterpolation(Clfarf_fArray,
361                                              Clfarf_aArray,
362                                              Clfarf_rArray,
363                                              Clfarf_ClArray,
364                                              Clfarf_nAlphaArray,
365                                              Clfarf_nr,
366                                              Clfarf_nf,
367                                              flap_pos,
368                                              Std_Alpha,
369                                              r_nondim);
370             Cl += ClfarfI;
371             break;
372           }
373         };
374     } // end Cl map
375
376   return;
377 }
378
379 // end uiuc_coef_roll.cpp