]> git.mxchange.org Git - flightgear.git/blob - src/FDM/UIUCModel/uiuc_coefficients.cpp
Updated to match changes in radiostack.[ch]xx
[flightgear.git] / src / FDM / UIUCModel / uiuc_coefficients.cpp
1 /**********************************************************************
2
3  FILENAME:     uiuc_coefficients.cpp
4
5 ----------------------------------------------------------------------
6
7  DESCRIPTION:  computes aggregated aerodynamic coefficients
8
9 ----------------------------------------------------------------------
10
11  STATUS:       alpha version
12
13 ----------------------------------------------------------------------
14
15  REFERENCES:   
16
17 ----------------------------------------------------------------------
18
19  HISTORY:      01/29/2000   initial release
20                02/01/2000   (JS) changed map name from aeroData to 
21                             aeroPart
22                02/18/2000   (JS) added calls to 1Dinterpolation 
23                             function from CLfa and CDfa switches
24                02/24/2000   added icing model functions
25                02/29/2000   (JS) added calls to 2Dinterpolation 
26                             function from CLfade, CDfade, Cmfade, 
27                             CYfada, CYfbetadr, Clfada, Clfbetadr, 
28                             Cnfada, and Cnfbetadr switches
29                04/15/2000   (JS) broke up into multiple 
30                             uiuc_coef_xxx functions
31                06/18/2001   (RD) Added initialization of Alpha and
32                             Beta.  Added aileron_input and rudder_input.
33                             Added pilot_elev_no, pilot_ail_no, and
34                             pilot_rud_no.
35                07/05/2001   (RD) Added pilot_(elev,ail,rud)_no=false
36
37 ----------------------------------------------------------------------
38
39  AUTHOR(S):    Bipin Sehgal       <bsehgal@uiuc.edu>
40                Jeff Scott         <jscott@mail.com>
41                Robert Deters      <rdeters@uiuc.edu>
42
43 ----------------------------------------------------------------------
44
45  VARIABLES:
46
47 ----------------------------------------------------------------------
48
49  INPUTS:       -V_rel_wind (or U_body)
50                -dyn_on_speed
51                -ice on/off
52                -phugoid on/off
53
54 ----------------------------------------------------------------------
55
56  OUTPUTS:      -CL
57                -CD
58                -Cm
59                -CY
60                -Cl
61                -Cn
62
63 ----------------------------------------------------------------------
64
65  CALLED BY:    uiuc_wrapper
66
67 ----------------------------------------------------------------------
68
69  CALLS TO:     uiuc_coef_lift
70                uiuc_coef_drag
71                uiuc_coef_pitch
72                uiuc_coef_sideforce
73                uiuc_coef_roll
74                uiuc_coef_yaw
75                uiuc_controlInput
76
77 ----------------------------------------------------------------------
78
79  COPYRIGHT:    (C) 2000 by Michael Selig
80
81  This program is free software; you can redistribute it and/or
82  modify it under the terms of the GNU General Public License
83  as published by the Free Software Foundation.
84
85  This program is distributed in the hope that it will be useful,
86  but WITHOUT ANY WARRANTY; without even the implied warranty of
87  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
88  GNU General Public License for more details.
89
90  You should have received a copy of the GNU General Public License
91  along with this program; if not, write to the Free Software
92  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
93  USA or view http://www.gnu.org/copyleft/gpl.html.
94
95 **********************************************************************/
96
97 #include "uiuc_coefficients.h"
98
99
100 void uiuc_coefficients()
101 {
102   double l_trim, l_defl;
103   double V_rel_wind_dum, U_body_dum;
104
105   if (Alpha_init_true && Simtime==0)
106     Alpha = Alpha_init;
107
108   if (Beta_init_true && Simtime==0)
109     Beta = Beta_init;
110
111   // calculate rate derivative nondimensionalization factors
112   // check if speed is sufficient to compute dynamic pressure terms
113   if (nondim_rate_V_rel_wind || use_V_rel_wind_2U)         // c172_aero uses V_rel_wind
114     {
115       if (V_rel_wind > dyn_on_speed)
116         {
117           cbar_2U = cbar / (2.0 * V_rel_wind);
118           b_2U    = bw /   (2.0 * V_rel_wind);
119           ch_2U   = ch /   (2.0 * V_rel_wind);
120         }
121       else if (use_dyn_on_speed_curve1)
122         {
123           V_rel_wind_dum = dyn_on_speed_zero + V_rel_wind * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
124           cbar_2U        = cbar / (2.0 * V_rel_wind_dum);
125           b_2U           = bw /   (2.0 * V_rel_wind_dum);
126           ch_2U          = ch /   (2.0 * V_rel_wind_dum);
127         }
128       else
129         {
130           cbar_2U = 0.0;
131           b_2U    = 0.0;
132           ch_2U   = 0.0;
133         }
134     }
135   else if(use_abs_U_body_2U)      // use absolute(U_body)
136     {
137       if (fabs(U_body) > dyn_on_speed)
138         {
139           cbar_2U = cbar / (2.0 * fabs(U_body));
140           b_2U    = bw /   (2.0 * fabs(U_body));
141           ch_2U   = ch /   (2.0 * fabs(U_body));
142         }
143       else if (use_dyn_on_speed_curve1)
144         {
145           U_body_dum = dyn_on_speed_zero + fabs(U_body) * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
146           cbar_2U    = cbar / (2.0 * U_body_dum);
147           b_2U       = bw /   (2.0 * U_body_dum);
148           ch_2U      = ch /   (2.0 * U_body_dum);
149         }
150       else
151         {
152           cbar_2U = 0.0;
153           b_2U    = 0.0;
154           ch_2U   = 0.0;
155         }
156     }
157   else      // use U_body
158     {
159       if (U_body > dyn_on_speed)
160         {
161           cbar_2U = cbar / (2.0 * U_body);
162           b_2U    = bw /   (2.0 * U_body);
163           ch_2U   = ch /   (2.0 * U_body);
164         }
165       else if (use_dyn_on_speed_curve1)
166         {
167           U_body_dum = dyn_on_speed_zero + U_body * (dyn_on_speed - dyn_on_speed_zero)/dyn_on_speed;
168           cbar_2U    = cbar / (2.0 * U_body_dum);
169           b_2U       = bw /   (2.0 * U_body_dum);
170           ch_2U      = ch /   (2.0 * U_body_dum);
171           beta_flow_clean_tail = cbar_2U;
172         }
173       else
174         {
175           cbar_2U = 0.0;
176           b_2U    = 0.0;
177           ch_2U   = 0.0;
178         }
179     }
180
181   // check to see if icing model engaged
182   if (ice_model)
183     {
184       uiuc_ice_eta();
185     }
186
187   // check to see if data files are used for control deflections
188   pilot_elev_no = false;
189   pilot_ail_no = false;
190   pilot_rud_no = false;
191   if (elevator_step || elevator_singlet || elevator_doublet || elevator_input || aileron_input || rudder_input)
192     {
193       uiuc_controlInput();
194     }
195
196   CD = CX = CL = CZ = Cm = CY = Cl = Cn = 0.0;
197   CLclean_wing = CLiced_wing = CLclean_tail = CLiced_tail = 0.0;
198   CZclean_wing = CZiced_wing = CZclean_tail = CZiced_tail = 0.0;
199   CXclean_wing = CXiced_wing = CXclean_tail = CXiced_tail = 0.0;
200
201   uiuc_coef_lift();
202   uiuc_coef_drag();
203   uiuc_coef_pitch();
204   uiuc_coef_sideforce();
205   uiuc_coef_roll();
206   uiuc_coef_yaw();
207
208   if (pilot_ail_no)
209     {
210       if (aileron <=0)
211         Lat_control = - aileron / damax * RAD_TO_DEG;
212       else
213         Lat_control = - aileron / damin * RAD_TO_DEG;
214     }
215
216   if (pilot_elev_no)
217     {
218       l_trim = elevator_tab;
219       l_defl = elevator - elevator_tab;
220       if (l_trim <=0 )
221         Long_trim = l_trim / demax * RAD_TO_DEG;
222       else
223         Long_trim = l_trim / demin * RAD_TO_DEG;
224       if (l_defl <= 0)
225         Long_control = l_defl / demax * RAD_TO_DEG;
226       else
227         Long_control = l_defl / demin * RAD_TO_DEG;
228     }
229
230   if (pilot_rud_no)
231     {
232       if (rudder <=0)
233         Rudder_pedal = - rudder / drmax * RAD_TO_DEG;
234       else
235         Rudder_pedal = - rudder / drmin * RAD_TO_DEG;
236     }
237
238   return;
239 }
240
241 // end uiuc_coefficients.cpp