This lab covers concepts and methods used for interpolating polynomial and estimating functional relationships using linear regression.
AERO 300 Laboratory 5 Interpolation and Linear Regression The pre-lab assignment (Section 4) is due at the beginning of this lab (can be hand-written or typed). The lab (Section 5) will be due before your next lab section (.zip file submitted to polylearn). 1 Objectives This lab covers concepts and methods used for interpolating polynomial and estimating functional relationships using linear regression. In this lab, you will: • Create a surface which models a wing using interpolation and the surf() command • Load wind-tunnel data • Estimate the lift coefficient of the wing using linear regression 2 Introduction Interpolation and linear regression are two sides of the same coin. With interpolation, you are typically trying to find the coefficients of a polynomial that passes through a set of known points. Conversely, with linear regression, you are trying to find the coefficients of a polynomial that passes as close to (but not through) a set of known points. The table below summarizes the nature of each problem. Interpolation Linear Regression • ? ???? ?????? ⟹ ? ???????????? ?? ?? (? − 1)?ℎ ????? ?????????? • “Exact” fit • ? ???? ?????? ⟹ ? ???????????? ?? ?? (? − 1)?ℎ ????? ?????????? (? > ?) • “Best” fit In this lab, you will explore different ways to use interpolation and linear regression for representing and analyzing data. 2.1 Interpolation Interpolation techniques are used in solid modeling to define the shape of a surface that is constrained to pass through known points. In this way, every point on the surface does not have to be stored, only the coefficients of the polynomial which approximates a slice of the surface are stored. When the solid model is rendered (or shown on the screen) the polynomial can be evaluated as needed, and the resulting data displayed. In this lab, you will use Newton’s Divided Differences technique to find a polynomial to approximate the surface of an airfoil at two different span wise locations of a wing. 2.2 Linear Regression Once a solid model of a wing is created, we can import the surface into a grid generation program and run a Computational Fluid Dynamics code to solve for the flow properties. If we have wind tunnel data, we could compare the CFD results with the experimental results to validate our CFD analysis. In this lab, you will find the coefficients of a line used to model the angle of attack of a wing versus the lift coefficient of the wing. The physics of this model is based on thin airfoil theory. 2.3 This Airfoil Theory See this Wikipedia article for more information on thin airfoil theory https://en.wikipedia.org/wiki/Airfoil#Thin_airfoil_theory. If you concentrate in Aeronautics you will learn more about thin airfoil theory in Aero 306. Regardless of your concentration, the important result of thin airfoil theory states that the lift coefficient of an airfoil ??, is proportional to the angle of attack ?, of the airfoil for ‘small’ angles of attack. Figure 1 shows the geometry and other nomenclature used to describe airfoils. Figure 1 – A thin airfoil by Olivier Cleynen The physics used in thin airfoil results in ?? = 2??. This result is only good for an infinite and symmetric airfoil (no camber). If an airfoil is not symmetric, the airfoil will have some lift at zero angle of attack and the equation for the lift coefficient becomes, ?? = ??? + 2??. Finally, if an airfoil is not infinite, the proportionality coefficient is not 2?. Keep in mind, this result only applies when the angle of attack is measured in radians. 3 Help Potentially useful terms for this lab: • polyfit • polyval • linspace • QR • inv and ‘\’ • find • Zeros • ones • get • gca • plot • plot3 • surf • axis • grid • hold • legend • title • xlabel • ylabel 4 Pre-lab Assignment NOTE: This must be done before lab. If it is not completed, you will not be allowed into lab. https://en.wikipedia.org/wiki/Airfoil#Thin_airfoil_theory Use the polyfit() command to find the coefficients of a 3rd order polynomial that passes through the points (-5,4), (-2, -1), (4, 2), and (5,-5). Evaluate and plot the polynomial on the interval [-5:.1:5] using the polyval() command. Also, plot the points on the line from above using red x’s as data markers. Be sure to label your plot. Finally, comment on how is the polyfit() command similar to Newton’s Divided Difference method? 5 Lab Assignment Complete the following problems with a single script and custom functions as appropriate. Important lines of code should include descriptive comments. You are encouraged to work in groups, however the code you submit must be your own. All graphs/figures/sketches should include a grid, labels, legend (if necessary), and the appropriate fontsize/linewidth/markersize. 1. Plot the wing – Interpolation a. Import the data from the airfoil_1.txt document. This data contains the normalized y and z locations of an airfoil surface at 6 locations from trailing to leading edge at the root of the wing. Use the polyfit() command to find a 5th order polynomial that interpolates the airfoil. b. Import the data from the airfoil_2.txt document. This data contains the normalized y and z locations of an airfoil surface at 6 locations from trailing to leading edge at the tip of the wing. Use the polyfit() command to find a 5th order polynomial that interpolates the airfoil. c. Using both polynomials from part a and b, use the surf() command to plot the wing. Use the ‘lineStyle’ property to remove the grid from the surface. With the default colormap, you should get something that looks like the following: 2. Plot the wind tunnel data – Regression a. Import the data from the files ‘cl_data.txt’ and ‘cd_data.txt’. The data is formatted as, first column – angle of attack in degrees, second column – lift/drag coefficient. b. Plot the data from part a and label the figure. Remember the data in the files are data points. It is generally never appropriate to connect measured data points with a line. c. Use the polyfit() command to determine the zero angle of attack lift coefficient, ??? , and the proportionality constant between angle of attack and lift coefficient. In this case, not all the data fits are line. Be sure to limit your regression line to use only points applicable to thin airfoil theory. (Hint: you can use the find() command to help find the valid data points.) d. Use the polyfit() command to determine a quadratic fit to the angle of attack versus drag coefficient data. e. Plot both regression lines on the same figure as the data points. Label your figure and be sure to include a legend. 6 Material to be Submitted Submit the code for the lab assignment (titled: yourname_Lab5) into your lab sections Poly Learn Assignment before the start of the next laboratory. Zip all your code into one file and put your name on every piece of code you turn in. Do not forget the master file. 1 Objectives 2 Introduction 2.1 Interpolation 2.2 Linear Regression 2.3 This Airfoil Theory 3 Help 4 Pre-lab Assignment 5 Lab Assignment 6 Material to be Submitted