% Team 4
% AAE 451
% Fall 2007
%
clear
% BasicConstants_MPX5   Version 9.2 1/18/06
% This version requires Xcg and low_wing to be defined here.
%  
% OBJECTIVE: Collect into one location all the vehicle specific constants (a.k.a. basic constants).
%            From these basic constants all the stability and control derivatives 
%            can be determined.
% INPUTS: None
% OUTPUTS: Many basic constants defined in the Matlab workspace.
%

% This version is the second one
% Arbitrary reference point is the firewall
% Moment reference point is the c.g.
% Trim velocity assumed to be 90 ft/s
%
% *********************************************
% BasicConstants - Identifies, describes, and assigns all of the 
%                  the most basic variables for analyzing the control
%                  and stability of a generic aircraft.
% *********************************************     
% 
% A&AE 565 Spring 2003 - Purdue University
% 
% Note: This code is provided for a first order approximation of the dynamic 
%       analysis of an airplane and is not intended for final designs.
%
% Equations/Figures can be found in :
% 
% (Ref.1) Roskam, Jan. "Airplane Flight Dynamics and Automatic Flight
%         Controls"
%         Published by DARcorporation
%         120 E. Ninth St., Suite 2
%         Lawrence, KS 66044
%         Third Printing, 2001.
%
% (Ref.2) Roskam, Jan. "Methods for Estimating Stability and
%         Control Derivatives of Conventional Subsonic Airplanes"
%         Published by the Author 
%         519 Boulder 
%         Lawrence, Kansas 66044
%         Third Printing, 1997.
%  
% (Ref.3) Roskam, Jan. "Airplane Design: Part IV: Preliminary Calculation
%         of Aerodynamic, Thrust and Power Characteristics"
%         Published by Roskam Aviation and Engineering Corporation
%         Rt4, Box 274
%         Ottawa, Kansas 66067
%         Second Printing, 1990.
%
aircraft='Squirrel';
adelf = 0;            % Two dimensional lift effectiveness parameter Ref.(2),Equ(8.7)
alpha = 0*pi/180;     % Trim Ange of attack [rad]. This should be zero since our
% %                            equations of motion are body axis system rather then the stability axis system.
alpha_0 = -0.0695;    % Airfoil zero-lift AOA [rad]
altitude= 15;        % Trim altitude [ft] ******************************************************************************
AR_h = 0.3102; %(0.295^2)/0.295;         % Aspect ratio of the horizontal tail
AR_w = 1.5;         % Aspect ratio of the wing
b_f = 1.11;         % Span of the flap [ft] (Alieron total span)****
b_h = 0.3102;           % Span of the horizontal tail [ft]
b_h_oe = b_h/2;         % Elevator outboard position [ft]
b_h_ie = 0.0;        % Elevator inboard position [ft]
b_w = 1.392; %Assumed flat plate          % Span of the wing [ft]
b_v = 0.1538;          % Vertical tail span measured from fuselage centerline[ft]
b_v_or = 0; %b_v;         % Outboard position of rudder [ft]
b_v_ir = 0;           % Inboard position of rudder [ft]
c_a = 1.2/12;         % Chord of aileron [ft]
C_bar_D_o = 0.0482;    % Parasite drag
Cd_0 = 0.03;         % Drag coefficient at zero lift (parasite drag)
c_e = 0.32;  %0.2;        % Elevator chord [ft]
cf = 0;              % Chord of the wing flap [ft]
c_h = 1;              % Mean aerodynamic chord of the horizontal tail [ft]
CL =(180/pi)*0.849;     %0.4075;            % Lift coefficient (3-D) CL=W/(1/2*rho*U^2)
CL_hb = 0;            % Lift coefficient of the horzontal tail/body
CL_wb= (.27);        % Lift coefficient of the wing/body - assuming iw=0
Cl_alpha_h = 6.2831;%(180/pi)*(0.096); %6.2831;  % 2-D Lift curve slope of horizontal tail
Cl_alpha_v = 6.2831;%(180/pi)*(0.096); %6.2831;  % 2-D Lift curve slope of vertical tail
Cl_alpha = (180/pi)*(0.0923);    %4.4066;    % Two-dimensional lift curve slope of whole aircraft******************************************************************
Cl_alpha_w = (180/pi)*(0.0923); %3.44;  % Two-dimensional lift curve slope of wing
Cm_0_r = -0.09;     % Zero lift pitching moment coefficient of the wing root 
Cm_o_t = -0.09;     % Zero lift pitching moment coefficient of the wing tip **Cm_0_r = Cm_o_t because wing has no twist
c_r =  0;          % MEAN Chord of the rudder [ft]
c_w = 13.17/12;       % Mean aerodynamic chord of the wing [ft]
c_v = 1;          % Mean aerodynamic chord of the vertical tail [ft]
D_p = 8/12;          % Diameter of propeller [ft]
d = 3/12;           % Average diameter of the fuselage [ft]
delf = 0;            % Streamwise flap deflection [rad] NO FLAPS
delta_e = 0;          % Elevator deflection [rad]
delta_r = 0;          % Rudder deflection [rad]
dihedral = 0;         % Geometric dihedral angle of the wing [rad], positive for 
% %                           dihedral (wing tips up), negative for
% %                           anhedral(tips down) [rad] ***EST
dihedral_h = 0;       % Geometric dihedral angle of the horizontal tail [rad]
e = 0.7877;            % Oswald's efficiency factor
epsilon_t = 0;        % Horizontal tail twist angle [rad]
epsilon_0_h = 0;      % Downwash angle at the horizontal tail (see Note in 
% %                                Ref.(3) under section 8.1.5.2) [rad] ***EST
eta_h = 0.99;         % Ratio of dynamic pressure at the horizontal tail to that of the freestream ***EST
eta_ia = 0.1;         % Percent semi-span position of inboard edge of aileron
eta_oa = 1.0;        % Percent semi-span position of outboard edge of aileron
eta_p = 0.657;         % Propeller Efficiency ***EST
eta_v = 1;          % Ratio of the dynamic pressure at the vertical tail ***********************************************************
% %                              to that of the freestream
h1_fuse =0.125;      % Height of the fuselage at 1/4 of the its length 
h2_fuse = 0.078;     % Height of the fuselage at 3/4 of the its length 
h_h = 0;          % Height from chord plane of wing to chord plane of
% %                              horizontal tail [ft] - Fig 3.7, Ref. 2
hmax_fuse = 0.125;   % Maximum height of the fuselage [ft]  
Ixx = 1.613e-4;       %  0.001;          % Airplane moment of inertia about x-axis [slug-ft^2] *** With 4 lb load
Iyy = 8.976e-4;           % Airplane moment of inertia about y-axis [slug-ft^2]
Izz = 0.001;           % Airplane moment of inertia about z-axis [slug-ft^2]
Ixz = 0;              % Airplane product of inertia [slug-ft^2]
i_h = deg2rad(0);     % Incidence angle of horizontal tail [rad]  
i_w = deg2rad(0);     % Incidence angle of wing [rad]  
k = 1/(pi*AR_w*e);           % k of the drag polar, generally= 1/(pi*AR*e)
% Lambda = deg2rad(14.036);       % Sweep angle of wing [rad]
Lambda_c2 = 0;   %deg2rad(6.9958);    % Sweep angle at the c/2 of the wing [rad]  ************************************************
Lambda_c4 = 0;  %deg2rad(10.6685);   % Sweep angle at the c/4 of the wing [rad]  ************************************************   
Lambda_c2_v = 0; %deg2rad(14.7078); % Sweep angle at the c/2 of the vertical tail [rad]
Lambda_c4_v = 0; %deg2rad(20.8728); % Sweep angle at the c/4 of the vertical tail [rad]
Lambda_c2_h = 0; %deg2rad(5.1050);  % Sweep angle at the c/2 of the horizontal tail [rad]
Lambda_c4_h = 0; %deg2rad(7.6833);  % Sweep angle at the c/4 of the horizontal tail [rad]
lambda = 1;                 % Taper ratio of wing
lambda_h = 1;               % Taper ratio of horizontal tail
lambda_v = 1;         	% Taper ratio of vertical tail
l_f = 1;                   	% Horizontal length of fuselage [ft]  
l_v = 1.25;                   	% Horizontal distance from aircraft arbitrary reference point to vertical tail AC [ft]
% %Ref fig 2.1 in thesis for l_v, ref pt is c/4
low_wing=-1;            % low_wing=-1 if the wing is high  ;  % low_wing=1 if the wing is low  
%                         % low_wing=0 if the wing is mid 
% %u = 115; % ft/sec	% Trim Airspeed <<<<<<<<<old
u = 16; % ft/sec	% Trim Airspeed <<<<<<<Frontside
% %u = 20; % ft/sec	% Trim Airspeed <<<<<<<Backside
M = u/1125;            	% Mach number 
S_b_s = .4002;          % Body side area [ft^2]
S_h = 0.3102;             % Area of horizontal tail [ft^2]
S_h_slip = 0.2806;      % Area of horizontal tail that is covered in 
% %                                prop-wash [ft^2] - See Fig.(8.64) - Ref.(3) ***EST
S_o = 0.0138;          % Fuselage x-sectional area at Xo [ft^2] - 
% %                                 See Fig.(7.2) - Ref.(2)
% %                                 Xo is determined by plugging X1/l_b into: 
% %                                 0.378 + 0.527 * (X1/l_b) = (Xo/l_b)
S_w = 1.292;         % Surface area of wing [ft^2]
S_v = 0.1538;         % Surface area of vertical tail [ft^2]
tc_w = 0.0033;         % Thickness to chord ratio of wing 
tc_h = 0.0098;         % Thickness to chord ratio of horizontal tail
theta = 0*pi/180;    % Wing twist - negative for washout [rad]
theta_h = 0*pi/180;  % Horizontal tail twist between the root and tip 
% %                                 stations,negative for washout [rad]
two_r_one = 0;  % Fuselage depth in region of vertical tail [ft] Ref.(2),Figure 7.5
U = u/1.7; % knots   % Free Stream Velocity (Trim velocity) [KNOTS true]
W = .18;            % Weight of Airplane [lbf] REDUCED FROM 4.38 TO ALLOW FLIGHT ON BACKSIDE
wingloc = 1;         % If the aircraft is a highwing: (wingloc=1), low-wing:(wingloc=0) 
wmax_fuse = 0.25;  % Maximum fuselage width [ft]
X1 = .6;           % Distance from the front of the fuselage where the 
% %                              x-sectional area decrease (dS_x/dx) 
% %                              is greatest (most negative) [ft] - Ref.(2),Fig. 7.2  
x_m = .0583;         % Distance from nose of aircraft to arbitrary reference point [ft]
% %                              measured positive aftward.
x_over_c_v = .25;    % PARAMETER ACCOUNTING FOR THE RELATIVE POSITIONS OF THE HORIZONTAL AND VERTICAL TAILS
% %                               defined as the fore-and-aft distance from leading edge of vertical fin to the
% %                               aerodynamic center of the horizontal tail divided by the chord of the vertical tail 
% %                               [nondimensional] - See Fig 7.6 of Ref. 2 
Xach = 1.25;       % Distance from the leading edge of the wing mean aerodynamic chord
% %                               to the aerodynamic center of the horizontal tail (positive aftward) [ft]
Xacwb = 0.4453*c_w;    % Distance from the leading edge of the wing mean aerodynamic chord
% %                               to the aerodynamic center of the wing and body. 
% %                               Measured as positive aft, starting from the leading edge of the mean aero. chord. [ft]
Xacw = 0.4453*c_w;   % Distance from the leading edge of the wing mean aerodynamic chord
% %                               to the aerodynamic center of the wing ALONE. 
% %                               Measured as positive aft, starting from the leading edge of the mean aero. chord. [ft]
Xref = 0.25*c_w;     % Distance from the leading edge of the wing mean aerodynamic chord***********************************************************
% %                               to the arbitrary moment reference point. The equivalent force system
% %                               for the aerodynamic force system is given about this point.
% %                               Measured as positive aft, starting from the leading edge of the mean aero. chord. [ft]
Xcg = 0.280*c_w;      % Distance from the leading edge of the wing mean aerodynamic chord
% %                               to the center of gravity. 
% %				Measured as positive aft, starting from the leading edge of the mean aero. chord. [ft]
% %                    % Xcg is ignored until Step 2. It an be changed later in Step 2.
% %                       
Z_h = -0.0625;          % Negative of the VERTICAL distance from the fuselage 
% %                               centerline to the horizontal tail aero center 
% %                               (Z_h is a negative number FOR TAILS ABOVE THE CENTERLINE)
% %                               - Ref.(2), Fig.7.6
% %                               ***This produces a bunch of interpolation errors because 
% %                               Roskam doesn't have data for horizontal tails below the 
% %                               centerline of the fuselage
Z_v = -0.0717;      % Vertical distance from the aircraft arbirary reference point to the vertical 
% %                           tail aero center (positive up) - Ref.(2), Fig. 7.18
Z_w = .04*c_w+1.25/2;      % This is the vertical distance from the wing root c/4 [ft]
% %                           to the fuselage centerline, 
% %                           positive downward - Ref.(2), Equ(7.5)
Z_w1 = -Z_w;     % Distance from body centerline to c/4 of wing root 
% %                           chord,positive for c/4 point
% %                           below body centerline (ft) - Ref.(2), Fig. 7.1  

