]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_coef_yaw.cpp
Make sure sign is preserved for turbulence direction.
[flightgear.git] / src / FDM / UIUCModel / uiuc_coef_yaw.cpp
1 /**********************************************************************
2
3  FILENAME:     uiuc_coef_yaw.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  computes aggregated aerodynamic yaw 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                             (Cnfxxf0)
25                11/12/2001   (RD) Added new variables needed for the non-
26                             linear Twin Otter model with flaps
27                             (Cnfxxf).  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                -yaw coefficient components
50                -icing parameters
51                -b_2U multiplier
52
53 ----------------------------------------------------------------------
54
55  OUTPUTS:      -Cn
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_yaw.h"
90
91
92 void uiuc_coef_yaw()
93 {
94   string linetoken1;
95   string linetoken2;
96   stack command_list;
97
98   double p_nondim;
99   double r_nondim;
100
101   command_list = aeroYawParts -> getCommands();
102   
103   for (LIST command_line = command_list.begin(); command_line!=command_list.end(); ++command_line)
104     {
105       linetoken1 = aeroYawParts -> getToken(*command_line, 1);
106       linetoken2 = aeroYawParts -> getToken(*command_line, 2);
107
108       switch(Cn_map[linetoken2])
109         {
110         case Cno_flag:
111           {
112             if (ice_on)
113               {
114                 Cno = uiuc_ice_filter(Cno_clean,kCno);
115               }
116             Cno_save = Cno;
117             Cn += Cno_save;
118             break;
119           }
120         case Cn_beta_flag:
121           {
122             if (ice_on)
123               {
124                 Cn_beta = uiuc_ice_filter(Cn_beta_clean,kCn_beta);
125               }
126             Cn_beta_save = Cn_beta * Std_Beta;
127             if (eta_q_Cn_beta_fac)
128               {
129                 Cn += Cn_beta_save * eta_q_Cn_beta_fac;
130               }
131             else
132               {
133                 Cn += Cn_beta_save;
134               }
135             break;
136           }
137         case Cn_p_flag:
138           {
139             if (ice_on)
140               {
141                 Cn_p = uiuc_ice_filter(Cn_p_clean,kCn_p);
142               }
143             /* Cn_p must be mulitplied by b/2U 
144                (see Roskam Control book, Part 1, pg. 147) */
145             Cn_p_save = Cn_p * P_body * b_2U;
146             if (eta_q_Cn_p_fac)
147               {
148                 Cn += Cn_p_save * eta_q_Cn_p_fac;
149               }
150             else
151               {
152                 Cn += Cn_p_save;
153               }
154             break;
155           }
156         case Cn_r_flag:
157           {
158             if (ice_on)
159               {
160                 Cn_r = uiuc_ice_filter(Cn_r_clean,kCn_r);
161               }
162             /* Cn_r must be mulitplied by b/2U 
163                (see Roskam Control book, Part 1, pg. 147) */
164             Cn_r_save = Cn_r * R_body * b_2U;
165             if (eta_q_Cn_r_fac)
166               {
167                 Cn += Cn_r_save * eta_q_Cn_r_fac;
168               }
169             else
170               {
171                 Cn += Cn_r_save;
172               }
173             break;
174           }
175         case Cn_da_flag:
176           {
177             if (ice_on)
178               {
179                 Cn_da = uiuc_ice_filter(Cn_da_clean,kCn_da);
180               }
181             Cn_da_save = Cn_da * aileron;
182             Cn += Cn_da_save;
183             break;
184           }
185         case Cn_dr_flag:
186           {
187             if (ice_on)
188               {
189                 Cn_dr = uiuc_ice_filter(Cn_dr_clean,kCn_dr);
190               }
191             Cn_dr_save = Cn_dr * rudder;
192             if (eta_q_Cn_dr_fac)
193               {
194                 Cn += Cn_dr_save * eta_q_Cn_dr_fac;
195               }
196             else
197               {
198                 Cn += Cn_dr_save;
199               }
200             break;
201           }
202         case Cn_q_flag:
203           {
204             if (ice_on)
205               {
206                 Cn_q = uiuc_ice_filter(Cn_q_clean,kCn_q);
207               }
208             Cn_q_save = Cn_q * Q_body * cbar_2U;
209             Cn += Cn_q_save;
210             break;
211           }
212         case Cn_b3_flag:
213           {
214             if (ice_on)
215               {
216                 Cn_b3 = uiuc_ice_filter(Cn_b3_clean,kCn_b3);
217               }
218             Cn_b3_save = Cn_b3 * Std_Beta * Std_Beta * Std_Beta;
219             Cn += Cn_b3_save;
220             break;
221           }
222         case Cnfada_flag:
223           {
224             CnfadaI = uiuc_2Dinterpolation(Cnfada_aArray,
225                                            Cnfada_daArray,
226                                            Cnfada_CnArray,
227                                            Cnfada_nAlphaArray,
228                                            Cnfada_nda,
229                                            Std_Alpha,
230                                            aileron);
231             Cn += CnfadaI;
232             break;
233           }
234         case Cnfbetadr_flag:
235           {
236             CnfbetadrI = uiuc_2Dinterpolation(Cnfbetadr_betaArray,
237                                               Cnfbetadr_drArray,
238                                               Cnfbetadr_CnArray,
239                                               Cnfbetadr_nBetaArray,
240                                               Cnfbetadr_ndr,
241                                               Std_Beta,
242                                               rudder);
243             Cn += CnfbetadrI;
244             break;
245           }
246         case Cnfabetaf_flag:
247           {
248             if (Cnfabetaf_nice == 1)
249               CnfabetafI = uiuc_3Dinterp_quick(Cnfabetaf_fArray,
250                                                Cnfabetaf_aArray_nice,
251                                                Cnfabetaf_bArray_nice,
252                                                Cnfabetaf_CnArray,
253                                                Cnfabetaf_na_nice,
254                                                Cnfabetaf_nb_nice,
255                                                Cnfabetaf_nf,
256                                                flap_pos,
257                                                Std_Alpha,
258                                                Std_Beta);
259             else
260               CnfabetafI = uiuc_3Dinterpolation(Cnfabetaf_fArray,
261                                                 Cnfabetaf_aArray,
262                                                 Cnfabetaf_betaArray,
263                                                 Cnfabetaf_CnArray,
264                                                 Cnfabetaf_nAlphaArray,
265                                                 Cnfabetaf_nbeta,
266                                                 Cnfabetaf_nf,
267                                                 flap_pos,
268                                                 Std_Alpha,
269                                                 Std_Beta);
270             Cn += CnfabetafI;
271             break;
272           }
273         case Cnfadaf_flag:
274           {
275             if (Cnfadaf_nice == 1)
276               CnfadafI = uiuc_3Dinterp_quick(Cnfadaf_fArray,
277                                              Cnfadaf_aArray_nice,
278                                              Cnfadaf_daArray_nice,
279                                              Cnfadaf_CnArray,
280                                              Cnfadaf_na_nice,
281                                              Cnfadaf_nda_nice,
282                                              Cnfadaf_nf,
283                                              flap_pos,
284                                              Std_Alpha,
285                                              aileron);
286             else
287               CnfadafI = uiuc_3Dinterpolation(Cnfadaf_fArray,
288                                               Cnfadaf_aArray,
289                                               Cnfadaf_daArray,
290                                               Cnfadaf_CnArray,
291                                               Cnfadaf_nAlphaArray,
292                                               Cnfadaf_nda,
293                                               Cnfadaf_nf,
294                                               flap_pos,
295                                               Std_Alpha,
296                                               aileron);
297             Cn += CnfadafI;
298             break;
299           }
300         case Cnfadrf_flag:
301           {
302             if (Cnfadrf_nice == 1)
303               CnfadrfI = uiuc_3Dinterp_quick(Cnfadrf_fArray,
304                                              Cnfadrf_aArray_nice,
305                                              Cnfadrf_drArray_nice,
306                                              Cnfadrf_CnArray,
307                                              Cnfadrf_na_nice,
308                                              Cnfadrf_ndr_nice,
309                                              Cnfadrf_nf,
310                                              flap_pos,
311                                              Std_Alpha,
312                                              rudder);
313             else
314               CnfadrfI = uiuc_3Dinterpolation(Cnfadrf_fArray,
315                                               Cnfadrf_aArray,
316                                               Cnfadrf_drArray,
317                                               Cnfadrf_CnArray,
318                                               Cnfadrf_nAlphaArray,
319                                               Cnfadrf_ndr,
320                                               Cnfadrf_nf,
321                                               flap_pos,
322                                               Std_Alpha,
323                                               rudder);
324             Cn += CnfadrfI;
325             break;
326           }
327         case Cnfapf_flag:
328           {
329             p_nondim = P_body * b_2U;
330             if (Cnfapf_nice == 1)
331               CnfapfI = uiuc_3Dinterp_quick(Cnfapf_fArray,
332                                             Cnfapf_aArray_nice,
333                                             Cnfapf_pArray_nice,
334                                             Cnfapf_CnArray,
335                                             Cnfapf_na_nice,
336                                             Cnfapf_np_nice,
337                                             Cnfapf_nf,
338                                             flap_pos,
339                                             Std_Alpha,
340                                             p_nondim);
341             else
342               CnfapfI = uiuc_3Dinterpolation(Cnfapf_fArray,
343                                              Cnfapf_aArray,
344                                              Cnfapf_pArray,
345                                              Cnfapf_CnArray,
346                                              Cnfapf_nAlphaArray,
347                                              Cnfapf_np,
348                                              Cnfapf_nf,
349                                              flap_pos,
350                                              Std_Alpha,
351                                              p_nondim);
352             Cn += CnfapfI;
353             break;
354           }
355         case Cnfarf_flag:
356           {
357             r_nondim = R_body * b_2U;
358             if (Cnfarf_nice == 1)
359               CnfarfI = uiuc_3Dinterp_quick(Cnfarf_fArray,
360                                             Cnfarf_aArray_nice,
361                                             Cnfarf_rArray_nice,
362                                             Cnfarf_CnArray,
363                                             Cnfarf_na_nice,
364                                             Cnfarf_nr_nice,
365                                             Cnfarf_nf,
366                                             flap_pos,
367                                             Std_Alpha,
368                                             r_nondim);
369             else
370               CnfarfI = uiuc_3Dinterpolation(Cnfarf_fArray,
371                                              Cnfarf_aArray,
372                                              Cnfarf_rArray,
373                                              Cnfarf_CnArray,
374                                              Cnfarf_nAlphaArray,
375                                              Cnfarf_nr,
376                                              Cnfarf_nf,
377                                              flap_pos,
378                                              Std_Alpha,
379                                              r_nondim);
380             Cn += CnfarfI;
381             break;
382           }
383         };
384     } // end Cn map
385
386   return;
387 }
388
389 // end uiuc_coef_yaw.cpp