]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_coef_sideforce.cpp
I have attached revisions to the UIUC code. The revisions include the
[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             break;
129           }
130         case CY_p_flag:
131           {
132             if (ice_on)
133               {
134                 CY_p = uiuc_ice_filter(CY_p_clean,kCY_p);
135               }
136             /* CY_p must be mulitplied by b/2U 
137                (see Roskam Control book, Part 1, pg. 147) */
138             CY_p_save = CY_p * P_body * b_2U;
139             CY += CY_p * P_body * b_2U;
140             break;
141           }
142         case CY_r_flag:
143           {
144             if (ice_on)
145               {
146                 CY_r = uiuc_ice_filter(CY_r_clean,kCY_r);
147               }
148             /* CY_r must be mulitplied by b/2U 
149                (see Roskam Control book, Part 1, pg. 147) */
150             CY_r_save = CY_r * R_body * b_2U;
151             CY += CY_r * R_body * b_2U;
152             break;
153           }
154         case CY_da_flag:
155           {
156             if (ice_on)
157               {
158                 CY_da = uiuc_ice_filter(CY_da_clean,kCY_da);
159               }
160             CY_da_save = CY_da * aileron;
161             CY += CY_da * aileron;
162             break;
163           }
164         case CY_dr_flag:
165           {
166             if (ice_on)
167               {
168                 CY_dr = uiuc_ice_filter(CY_dr_clean,kCY_dr);
169               }
170             CY_dr_save = CY_dr * rudder;
171             CY += CY_dr * rudder;
172             break;
173           }
174         case CY_dra_flag:
175           {
176             if (ice_on)
177               {
178                 CY_dra = uiuc_ice_filter(CY_dra_clean,kCY_dra);
179               }
180             CY_dra_save = CY_dra * rudder * Alpha;
181             CY += CY_dra * rudder * Alpha;
182             break;
183           }
184         case CY_bdot_flag:
185           {
186             if (ice_on)
187               {
188                 CY_bdot = uiuc_ice_filter(CY_bdot_clean,kCY_bdot);
189               }
190             CY_bdot_save = CY_bdot * Beta_dot * b_2U;
191             CY += CY_bdot * Beta_dot * b_2U;
192             break;
193           }
194         case CYfada_flag:
195           {
196             CYfadaI = uiuc_2Dinterpolation(CYfada_aArray,
197                                            CYfada_daArray,
198                                            CYfada_CYArray,
199                                            CYfada_nAlphaArray,
200                                            CYfada_nda,
201                                            Alpha,
202                                            aileron);
203             CY += CYfadaI;
204             break;
205           }
206         case CYfbetadr_flag:
207           {
208             CYfbetadrI = uiuc_2Dinterpolation(CYfbetadr_betaArray,
209                                               CYfbetadr_drArray,
210                                               CYfbetadr_CYArray,
211                                               CYfbetadr_nBetaArray,
212                                               CYfbetadr_ndr,
213                                               Beta,
214                                               rudder);
215             CY += CYfbetadrI;
216             break;
217           }
218         case CYfabetaf_flag:
219           {
220             if (CYfabetaf_nice == 1)
221               CYfabetafI = uiuc_3Dinterp_quick(CYfabetaf_fArray,
222                                                CYfabetaf_aArray_nice,
223                                                CYfabetaf_bArray_nice,
224                                                CYfabetaf_CYArray,
225                                                CYfabetaf_na_nice,
226                                                CYfabetaf_nb_nice,
227                                                CYfabetaf_nf,
228                                                flap_pos,
229                                                Alpha,
230                                                Beta);
231             else
232               CYfabetafI = uiuc_3Dinterpolation(CYfabetaf_fArray,
233                                                 CYfabetaf_aArray,
234                                                 CYfabetaf_betaArray,
235                                                 CYfabetaf_CYArray,
236                                                 CYfabetaf_nAlphaArray,
237                                                 CYfabetaf_nbeta,
238                                                 CYfabetaf_nf,
239                                                 flap_pos,
240                                                 Alpha,
241                                                 Beta);
242             CY += CYfabetafI;
243             break;
244           }
245         case CYfadaf_flag:
246           {
247             if (CYfadaf_nice == 1)
248               CYfadafI = uiuc_3Dinterp_quick(CYfadaf_fArray,
249                                              CYfadaf_aArray_nice,
250                                              CYfadaf_daArray_nice,
251                                              CYfadaf_CYArray,
252                                              CYfadaf_na_nice,
253                                              CYfadaf_nda_nice,
254                                              CYfadaf_nf,
255                                              flap_pos,
256                                              Alpha,
257                                              aileron);
258             else
259               CYfadafI = uiuc_3Dinterpolation(CYfadaf_fArray,
260                                               CYfadaf_aArray,
261                                               CYfadaf_daArray,
262                                               CYfadaf_CYArray,
263                                               CYfadaf_nAlphaArray,
264                                               CYfadaf_nda,
265                                               CYfadaf_nf,
266                                               flap_pos,
267                                               Alpha,
268                                               aileron);
269             CY += CYfadafI;
270             break;
271           }
272         case CYfadrf_flag:
273           {
274             if (CYfadrf_nice == 1)
275               CYfadrfI = uiuc_3Dinterp_quick(CYfadrf_fArray,
276                                              CYfadrf_aArray_nice,
277                                              CYfadrf_drArray_nice,
278                                              CYfadrf_CYArray,
279                                              CYfadrf_na_nice,
280                                              CYfadrf_ndr_nice,
281                                              CYfadrf_nf,
282                                              flap_pos,
283                                              Alpha,
284                                              rudder);
285             else
286               CYfadrfI = uiuc_3Dinterpolation(CYfadrf_fArray,
287                                               CYfadrf_aArray,
288                                               CYfadrf_drArray,
289                                               CYfadrf_CYArray,
290                                               CYfadrf_nAlphaArray,
291                                               CYfadrf_ndr,
292                                               CYfadrf_nf,
293                                               flap_pos,
294                                               Alpha,
295                                               rudder);
296             CY += CYfadrfI;
297             break;
298           }
299         case CYfapf_flag:
300           {
301             p_nondim = P_body * b_2U;
302             if (CYfapf_nice == 1)
303               CYfapfI = uiuc_3Dinterp_quick(CYfapf_fArray,
304                                             CYfapf_aArray_nice,
305                                             CYfapf_pArray_nice,
306                                             CYfapf_CYArray,
307                                             CYfapf_na_nice,
308                                             CYfapf_np_nice,
309                                             CYfapf_nf,
310                                             flap_pos,
311                                             Alpha,
312                                             p_nondim);
313             else
314               CYfapfI = uiuc_3Dinterpolation(CYfapf_fArray,
315                                              CYfapf_aArray,
316                                              CYfapf_pArray,
317                                              CYfapf_CYArray,
318                                              CYfapf_nAlphaArray,
319                                              CYfapf_np,
320                                              CYfapf_nf,
321                                              flap_pos,
322                                              Alpha,
323                                              p_nondim);
324             CY += CYfapfI;
325             break;
326           }
327         case CYfarf_flag:
328           {
329             r_nondim = R_body * b_2U;
330             if (CYfarf_nice == 1)
331               CYfarfI = uiuc_3Dinterp_quick(CYfarf_fArray,
332                                             CYfarf_aArray_nice,
333                                             CYfarf_rArray_nice,
334                                             CYfarf_CYArray,
335                                             CYfarf_na_nice,
336                                             CYfarf_nr_nice,
337                                             CYfarf_nf,
338                                             flap_pos,
339                                             Alpha,
340                                             r_nondim);
341             else
342               CYfarfI = uiuc_3Dinterpolation(CYfarf_fArray,
343                                              CYfarf_aArray,
344                                              CYfarf_rArray,
345                                              CYfarf_CYArray,
346                                              CYfarf_nAlphaArray,
347                                              CYfarf_nr,
348                                              CYfarf_nf,
349                                              flap_pos,
350                                              Alpha,
351                                              r_nondim);
352             CY += CYfarfI;
353             break;
354           }
355        };
356     } // end CY map
357   
358   return;
359 }
360
361 // end uiuc_coef_sideforce.cpp