The aircraft dynamic models are presented as MATLAB functions that are called by the program FLIGHT. FLIGHT illustrates the essential features of flight analysis and simulation using a modular framework. Aircraft characteristics are described in the functions, AeroModel and DataTable.
FLIGHT is a tutorial program, heavily commented to make interpretation easy. It provides a full six-degree-of-freedom simulation of an aircraft, as well as trimming calculations and the generation of a linearized model at any flight condition chosen by the user. Changes to aircraft control histories, initial conditions, flag settings, and other program control actions are made by changing the numbers contained in the code; there is no separate user interface. The code has been designed for simplicity and clarity not for speed of execution, leaving a challenge to the reader to find ways to make the program run faster. Numerous additions could be made to the code, including implementation of feedback control logic, simulation of random turbulence or microburst wind shear, and interfaces for real-time execution. No explicit or implicit warranties are made regarding the accuracy or correctness of the computer code.
FLIGHT is the executive file (or script) that calls program functions. Initial conditions are defined here, the three primary features (trim, linearization, and simulation) are enabled, and output is generated. Initial perturbations to trim state and control allow transient effects to be simulated. As shown, trimming for steady, level flight is accomplished by first defining a cost function, J, that contains elements of the state rate, then minimizing the cost using the Downhill Simplex (Nelder-Mead) algorithm contained in fminsearch. The longitudinal trimming parameters are stabilator angle, throttle setting, and pitch angle. The linear model is generated by numjac, a numerical evaluation of the Jacobian matrices associated with the equations of motion. The linear model is saved to disk files in the variables Fmodel and Gmodel. MATLAB's ode23 integrates the equations of motion to produce the state history; ode45 or ode15s also could be used by simply changing the code. The state history is displayed in time plots, with angles converted from the radians used in calculation to degrees. The reader can readily change the units of plotted quantities or add additional plots through minor modifications to the code. Any result (e.g., numerical values of the state history) can be displayed in the MATLAB Command Window simply by removing the semi-colon at the end of the line. The flag MODEL selects either the low-angle-of-attack, Mach-dependent or the high-angle-of-attack, low-subsonic aerodynamic model.
This version of AeroModel uses aerodynamic and dimensional data contained in Ref. B-1 with estimates of inertial properties of the generic business jet. Details of the configuration, such as sweep and aspect ratio of the wing and tail, are used in the estimates of Mach effects. Wind tunnel results were reviewed for all test conditions and control settings, then reduced to simple linear and quadratic coefficients that describe significant aerodynamics for low angles of attack and sideslip (within about +/-8 degrees of zero). Increments for landing gear, symmetric spoilers, and flaps are added, as appropriate. Estimates of Mach effects are based on the Prandtl factor (Section 2.4) or the modified Helmbold equation (eq. 2.4-9). Thrust available is assumed to be proportional to the air density ratio raised to a power that fits both static thrust at sea level and the thrust required for flight at maximum Mach number (0.81) at an altitude of 13,720 m (45,000 ft).
This version of AeroModel uses aerodynamic and dimensional data contained in Ref. B-1 with estimates of inertial properties of the generic business jet. The angle-of attack range extends from -10 to 90 deg, with tunnel data used where it is available and estimates where it is not. Linear interpolation of tabulated data (contained in DataTable.m) is used to model nonlinearities in aerodynamic coefficients. Control surface effects are linear in their respective deflections, and static lateral-directional effects are linear in sideslip angle. The derivatives for both vary with angle of attack to the limits of data presented in the reference and are constant at higher angle. Angular rate derivatives are constant throughout the angle of attack range. No Mach, landing gear, or flap effects are modeled. The thrust model used for the Mach-dependent AeroModel also is used here.
The equations of motion for function EoM are written using the flat-earth assumption, as described in Section 3.2. Linear and translational rates are expressed in body axes, linear position is expressed in earth-relative axes, and the Euler angles describe the orientation of the body frame with respect to the earth frame. The lift and drag coefficients produced by AeroModel are transformed to body-axis coefficients; the remaining coefficents and thrust produced by the function are expressed in body axes. Effects of the wind and control settings are calculated by WindField and ControlSystem prior to calling AeroModel; hence, they are accounted for in the aerodynamic calculations. An ad hoc limit on the cosine of the pitch angle is imposed to prevent singular calculations in near-vertical flight. This expediency introduces a small error when the pitch angle is near +/-90 deg. The function event.m specifies a stopping condition that terminates the simulation before the final time if the altitude goes below zero.
Trim control settings are calculated by minimizing the quadratic function of longitudinal accelerations (i.e., rates of change of axial velocity, normal velocity, and pitch rate) contained in TrimCost. As shown, equal weight is given to each component in the cost function, J, because the defining matrix, R, is an identity matrix. The parameters that are adjusted to minimize J are the stabilator angle, the throttle setting, and the pitch angle (which equals the angle of attack in steady, level flight). TrimCost calls EoM to generate the needed accelerations. x1 and x3 are varied to maintain constant airspeed with varying angle of attack.
The direction-cosine (or rotation) matrix given by eq. 2.1-11 is implemented in the function DCM. The matrix transforms vectors from the earth-relative frame of reference to the body-axis frame.
The function LinModel calls function EoM to generate f(x,u) and appends seven dummy elements to account for the controls. Thus, xdotj is a function of [xT uT], and numjac calculates the Jacobian matrix evaluated at the nominal values of state and control. The stability matrix, F, is contained in the upper-left (12 x 12) partition, and the control-effect matrix, G, is contained in the upper-right (12 x 7) partition of the Jacobian.
WindField produces a three-component wind vector as a function of altitude, with linear interpolation between tabulated points. The first point is tabulated at negative altitude to assure that no computational problems occur at zero altitude. The wind vector is rotated to body axes for application in FLIGHT and EoM.
1976 U.S. Standard Atmosphere air density, air pressure, air temperature, and sound speed are generated as functions of altitude by Atmos. The first point is tabulated at negative altitude to assure that no computational problems occur at zero altitude.