]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_coef_sideforce.cpp
Add speed-brake and spoilers controlls
[flightgear.git] / src / FDM / UIUCModel / uiuc_coef_sideforce.cpp
1 /**********************************************************************
2
3  FILENAME:     uiuc_coef_sideforce.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  computes aggregated aerodynamic sideforce 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                             (CYfxxf0)
25                11/12/2001   (RD) Added new variables needed for the non-
26                             linear Twin Otter model with flaps
27                             (CYfxxf).  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                -sideforce coefficient components
50                -icing parameters
51                -b_2U multiplier
52
53 ----------------------------------------------------------------------
54
55  OUTPUTS:      -CY
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_sideforce.h"
90
91
92 void uiuc_coef_sideforce()
93 {
94   string linetoken1;
95   string linetoken2;
96   stack command_list;
97
98   double p_nondim;
99   double r_nondim;
100
101   command_list = aeroSideforceParts -> getCommands();
102   
103   for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
104     {
105       linetoken1 = aeroSideforceParts -> getToken(*command_line, 1);
106       linetoken2 = aeroSideforceParts -> getToken(*command_line, 2);
107
108       switch(CY_map[linetoken2])
109         {
110         case CYo_flag:
111           {
112             if (ice_on)
113               {
114                 CYo = uiuc_ice_filter(CYo_clean,kCYo);
115               }
116             CYo_save = CYo;
117             CY += CYo;
118             break;
119           }
120         case CY_beta_flag:
121           {
122             if (ice_on)
123               {
124                 CY_beta = uiuc_ice_filter(CY_beta_clean,kCY_beta);
125               }
126             CY_beta_save = CY_beta * Beta;
127             //       CY += CY_beta * Beta;
128             if (eta_q_CY_beta_fac)
129               {
130                 CY += CY_beta_save * eta_q_CY_beta_fac;
131               }
132             else
133               {
134                 CY += CY_beta_save;
135               }
136             break;
137           }
138         case CY_p_flag:
139           {
140             if (ice_on)
141               {
142                 CY_p = uiuc_ice_filter(CY_p_clean,kCY_p);
143               }
144             /* CY_p must be mulitplied by b/2U 
145                (see Roskam Control book, Part 1, pg. 147) */
146             CY_p_save = CY_p * P_body * b_2U;
147             //    CY += CY_p * P_body * b_2U;
148             if (eta_q_CY_p_fac)
149               {
150                 CY += CY_p_save * eta_q_CY_p_fac;
151               }
152             else
153               {
154                 CY += CY_p_save;
155               }
156             break;
157           }
158         case CY_r_flag:
159           {
160             if (ice_on)
161               {
162                 CY_r = uiuc_ice_filter(CY_r_clean,kCY_r);
163               }
164             /* CY_r must be mulitplied by b/2U 
165                (see Roskam Control book, Part 1, pg. 147) */
166             CY_r_save = CY_r * R_body * b_2U;
167             //    CY += CY_r * R_body * b_2U;
168             if (eta_q_CY_r_fac)
169               {
170                 CY += CY_r_save * eta_q_CY_r_fac;
171               }
172             else
173               {
174                 CY += CY_r_save;
175               }
176             break;
177           }
178         case CY_da_flag:
179           {
180             if (ice_on)
181               {
182                 CY_da = uiuc_ice_filter(CY_da_clean,kCY_da);
183               }
184             CY_da_save = CY_da * aileron;
185             CY += CY_da * aileron;
186             break;
187           }
188         case CY_dr_flag:
189           {
190             if (ice_on)
191               {
192                 CY_dr = uiuc_ice_filter(CY_dr_clean,kCY_dr);
193               }
194             CY_dr_save = CY_dr * rudder;
195             //     CY += CY_dr * rudder;
196             if (eta_q_CY_dr_fac)
197               {
198                 CY += CY_dr_save * eta_q_CY_dr_fac;
199               }
200             else
201               {
202                 CY += CY_dr_save;
203               }
204             break;
205           }
206         case CY_dra_flag:
207           {
208             if (ice_on)
209               {
210                 CY_dra = uiuc_ice_filter(CY_dra_clean,kCY_dra);
211               }
212             CY_dra_save = CY_dra * rudder * Alpha;
213             CY += CY_dra * rudder * Alpha;
214             break;
215           }
216         case CY_bdot_flag:
217           {
218             if (ice_on)
219               {
220                 CY_bdot = uiuc_ice_filter(CY_bdot_clean,kCY_bdot);
221               }
222             CY_bdot_save = CY_bdot * Beta_dot * b_2U;
223             CY += CY_bdot * Beta_dot * b_2U;
224             break;
225           }
226         case CYfada_flag:
227           {
228             CYfadaI = uiuc_2Dinterpolation(CYfada_aArray,
229                                            CYfada_daArray,
230                                            CYfada_CYArray,
231                                            CYfada_nAlphaArray,
232                                            CYfada_nda,
233                                            Alpha,
234                                            aileron);
235             CY += CYfadaI;
236             break;
237           }
238         case CYfbetadr_flag:
239           {
240             CYfbetadrI = uiuc_2Dinterpolation(CYfbetadr_betaArray,
241                                               CYfbetadr_drArray,
242                                               CYfbetadr_CYArray,
243                                               CYfbetadr_nBetaArray,
244                                               CYfbetadr_ndr,
245                                               Beta,
246                                               rudder);
247             CY += CYfbetadrI;
248             break;
249           }
250         case CYfabetaf_flag:
251           {
252             if (CYfabetaf_nice == 1)
253               CYfabetafI = uiuc_3Dinterp_quick(CYfabetaf_fArray,
254                                                CYfabetaf_aArray_nice,
255                                                CYfabetaf_bArray_nice,
256                                                CYfabetaf_CYArray,
257                                                CYfabetaf_na_nice,
258                                                CYfabetaf_nb_nice,
259                                                CYfabetaf_nf,
260                                                flap_pos,
261                                                Alpha,
262                                                Beta);
263             else
264               CYfabetafI = uiuc_3Dinterpolation(CYfabetaf_fArray,
265                                                 CYfabetaf_aArray,
266                                                 CYfabetaf_betaArray,
267                                                 CYfabetaf_CYArray,
268                                                 CYfabetaf_nAlphaArray,
269                                                 CYfabetaf_nbeta,
270                                                 CYfabetaf_nf,
271                                                 flap_pos,
272                                                 Alpha,
273                                                 Beta);
274             CY += CYfabetafI;
275             break;
276           }
277         case CYfadaf_flag:
278           {
279             if (CYfadaf_nice == 1)
280               CYfadafI = uiuc_3Dinterp_quick(CYfadaf_fArray,
281                                              CYfadaf_aArray_nice,
282                                              CYfadaf_daArray_nice,
283                                              CYfadaf_CYArray,
284                                              CYfadaf_na_nice,
285                                              CYfadaf_nda_nice,
286                                              CYfadaf_nf,
287                                              flap_pos,
288                                              Alpha,
289                                              aileron);
290             else
291               CYfadafI = uiuc_3Dinterpolation(CYfadaf_fArray,
292                                               CYfadaf_aArray,
293                                               CYfadaf_daArray,
294                                               CYfadaf_CYArray,
295                                               CYfadaf_nAlphaArray,
296                                               CYfadaf_nda,
297                                               CYfadaf_nf,
298                                               flap_pos,
299                                               Alpha,
300                                               aileron);
301             CY += CYfadafI;
302             break;
303           }
304         case CYfadrf_flag:
305           {
306             if (CYfadrf_nice == 1)
307               CYfadrfI = uiuc_3Dinterp_quick(CYfadrf_fArray,
308                                              CYfadrf_aArray_nice,
309                                              CYfadrf_drArray_nice,
310                                              CYfadrf_CYArray,
311                                              CYfadrf_na_nice,
312                                              CYfadrf_ndr_nice,
313                                              CYfadrf_nf,
314                                              flap_pos,
315                                              Alpha,
316                                              rudder);
317             else
318               CYfadrfI = uiuc_3Dinterpolation(CYfadrf_fArray,
319                                               CYfadrf_aArray,
320                                               CYfadrf_drArray,
321                                               CYfadrf_CYArray,
322                                               CYfadrf_nAlphaArray,
323                                               CYfadrf_ndr,
324                                               CYfadrf_nf,
325                                               flap_pos,
326                                               Alpha,
327                                               rudder);
328             CY += CYfadrfI;
329             break;
330           }
331         case CYfapf_flag:
332           {
333             p_nondim = P_body * b_2U;
334             if (CYfapf_nice == 1)
335               CYfapfI = uiuc_3Dinterp_quick(CYfapf_fArray,
336                                             CYfapf_aArray_nice,
337                                             CYfapf_pArray_nice,
338                                             CYfapf_CYArray,
339                                             CYfapf_na_nice,
340                                             CYfapf_np_nice,
341                                             CYfapf_nf,
342                                             flap_pos,
343                                             Alpha,
344                                             p_nondim);
345             else
346               CYfapfI = uiuc_3Dinterpolation(CYfapf_fArray,
347                                              CYfapf_aArray,
348                                              CYfapf_pArray,
349                                              CYfapf_CYArray,
350                                              CYfapf_nAlphaArray,
351                                              CYfapf_np,
352                                              CYfapf_nf,
353                                              flap_pos,
354                                              Alpha,
355                                              p_nondim);
356             CY += CYfapfI;
357             break;
358           }
359         case CYfarf_flag:
360           {
361             r_nondim = R_body * b_2U;
362             if (CYfarf_nice == 1)
363               CYfarfI = uiuc_3Dinterp_quick(CYfarf_fArray,
364                                             CYfarf_aArray_nice,
365                                             CYfarf_rArray_nice,
366                                             CYfarf_CYArray,
367                                             CYfarf_na_nice,
368                                             CYfarf_nr_nice,
369                                             CYfarf_nf,
370                                             flap_pos,
371                                             Alpha,
372                                             r_nondim);
373             else
374               CYfarfI = uiuc_3Dinterpolation(CYfarf_fArray,
375                                              CYfarf_aArray,
376                                              CYfarf_rArray,
377                                              CYfarf_CYArray,
378                                              CYfarf_nAlphaArray,
379                                              CYfarf_nr,
380                                              CYfarf_nf,
381                                              flap_pos,
382                                              Alpha,
383                                              r_nondim);
384             CY += CYfarfI;
385             break;
386           }
387        };
388     } // end CY map
389   
390   return;
391 }
392
393 // end uiuc_coef_sideforce.cpp