You are on page 1of 39

THE PENNSYLVANIA STATE UNIVERSITY

AERSP 312 Honors Option Project


Final Report
Peter Blasco, Davide Conte, Param Desai, Swarna Sinha, Shiang-Ting Yeh 4/27/2012

Table of Contents
1 Project Summary: the Use of the Boundary Layer Equations ........................................... 2
1.1 Nomenclature .................................................................................................................................. 3 1.2 Boundary Conditions ........................................................................................................................ 4

2 Discretizing the Boundary Layer Equations ........................................................................ 4


2.1 Different Methods............................................................................................................................ 5 2.2 Blottners Method ............................................................................................................................ 5 2.2.1 How to approximate and .................................................................................................... 7

2.2.2 Developing the matrix for the discretized BL equations......................................................... 10 2.2.3 The Thomas Algorithm ............................................................................................................ 12

3 Developing an Algorithm for Solving the BL Equations Numerically............................. 17


3.1 Pseudocode .................................................................................................................................... 17

4 Implementing the Algorithm in a Computer Language (MATLAB) .............................. 19


4.1 How to compare the numerical results to the Blasius solution ..................................................... 20 4.1.1 Boundary Layer Thickness ....................................................................................................... 20 4.1.2 Displacement Thickness and Momentum Thickness .............................................................. 20 4.1.3 Coefficient of Skin Friction ...................................................................................................... 21 4.2 Blottner Method Using the Thomas Algorithm MATLAB Code................................................... 24 4.2.1 Sample Output ........................................................................................................................ 30

5 Discussion of Results ............................................................................................................. 36


5.1 Variable Grid Implementation ....................................................................................................... 37

1|Page

1 Project Summary: the Use of the Boundary Layer Equations


The goal of the first part of the project is to develop a numerical solution to the case of uniform, incompressible, and laminar flow over a flat plate. Boundary layer analysis is an effective strategy used in industry to quickly and accurately predict flow parameters when the flow regime is relatively straightforward and does not require lengthy, advanced CFD methods to describe it. Flow properties for this project are given as follows:

The equations used to create such algorithm are the incompressible boundary layer equations for laminar flow, which are summarized below: (1) continuity equation:

(2) x-momentum:

(3) y-momentum:

Equations (1) and (2) will be the main focus since equation (3) has the trivial solution that pressure is constant in the y-direction throughout the boundary layer (BL). Therefore, equations (1) and (2) will be solved numerically for layer thickness, defined as when and . Subsequently, the solution for the boundary , will be calculated and compared to the Blasius

solution. In fact, the Blasius solution is an exact solution to the BL equations for the case of flow
2|Page

over a flat plate. For the first case of this project, a pressure gradient while for later cases, the analysis will include an adverse pressure gradient,

will be considered, , so that

further investigation can be conducted on the location of flow separation. As a matter of fact, flow separation can occur on a flat plate only if an adverse pressure gradient is present in the flow, making the case of more interesting than a favorable pressure gradient, .

1.1 Nomenclature
The symbols and units of the various variables used in this project are summarized by the following table.
Symbol Uinf u v p X or i Y or j Re Description Freestream velocity Horizontal velocity Vertical velocity Density of air Kinematic viscosity of air Boundary layer thickness Pressure Direction parallel to the surface Direction perpendicular to the surface Boundary layer thickness Reynolds number Units m/s m/s m/s kg/m^3 m^2/s m or mm N/m^2 (or Pa) N/A N/A m or mm Unitless

3|Page

1.2 Boundary Conditions


The BL equations mentioned above will be governed by boundary conditions based on knowledge of the free stream velocity and knowledge of the no slip condition at the surface of the flat plat. They are as follows: (no slip condition) (no slip condition) (freestream; no initial vertical velocity) (uniform horizontal flow) (duplicated boundary condition; explanation below) (uniform horizontal flow when really far away from the plate)

2 Discretizing the Boundary Layer Equations


Since a numerical approach will be used, it is necessary to set up a grid with a finite number of points in the x and y directions. The number of intersections, nodes, will be defined by the maximum length used divided by the distance between each point in that specific direction. For example, the number of nodes in the x-direction can be calculated as with being the maximum length and ,

being the interval between each point. Therefore,

the solution for the horizontal velocity, , and the vertical velocity, , will be computed at each node. Note that smaller intervals give a more accurate solution, although they may conflict with the constraints of convergence depending on the numerical method used. Additionally, a drastic increase in or may cause the machine on which the code run to crash due to the lack of

memory required.

4|Page

2.1 Different Methods


In order to simultaneously solve equations (1) and (2) for a discretized grid, implicit or explicit methods can be used. The main issue with explicit methods is that most of them are not accurate enough and/or their constraints of convergence are extremely limited. Some of these methods are discussed in Basic Fluid Mechanics by David C. Wilcox at the end of chapters 11, 12, 13, and 14, in the sections dedicated to computational fluid dynamics. These methods include Crank-Nicholson, parabolic marching methods, and Blottners method. After reading more about marching methods and studying finite difference molecules, it was decided that the finite difference molecule for Blottners method was the best way to solve the boundary layer equations numerically.

2.2 Blottners Method


From chapter 14 in Basic Fluid Mechanics by David C. Wilcox, Blottners variablegrid method was applied to produce a solution. As mentioned above, this method applies for the case of incompressible flow. The grid spacing used was uniform, meaning that increments in the x and y directions used in the solution algorithm were held constant. In fact, uniform grids are easier to implement in computer languages although they contain approximation errors. Differencing coefficients used in Blottners method are geared towards non-constant differencing coefficients, which were solved for the case of uniform spacing to yield the equations below.

5|Page

One way to approximate a derivative is by using two 2nd order Taylor series expansions of a function to give a 2nd order accurate numerical derivative. This process is outlined below (taken from notes written by Dr. Lyle Long in AERSP 313, Fall 2011):

There were many different discretization techniques in Wilcox that utilized finite difference methods to approximate derivatives within the boundary layer equations. The technique used for our analysis is discussed below. Since and are functions of x and y, the second order method accurate of

approximating derivatives can be applied on both the x-axis and the y-axis. This way, throughout each step of the algorithm, a numerical value of the derivatives of and can be found. This

allows the procedure to continue to the next level and repeat the process until the grid is filled. Adhering to the above approximation and referring to a table based on it for obtaining numerical derivatives, the derivatives of the s and and can be approximated to even higher accuracy. Setting all and can

s respectively equal to each other (uniform grid), the derivatives of and in the following manner:

be computed with respected to

6|Page

The discretization approximations above are substituted into the boundary layer equations to give the governing equations. These governing equations, updated with numerical discretization terms, are essential to constructing a matrix that can solve for the velocities for any i step in the grid. The updated continuity equation and momentum equation are as follows: Continuity Equation

Momentum Equation

-Rearranged and simplified for

yields to

2.2.1 How to approximate

and

In order to start the iteration procedure, a value for the

and

velocity components must be

approximated for every node for a fixed value of . A first order accurate approximation can be achieved using linear interpolation. In fact, knowing two previous values for the velocities, the third one can be computed as follows: and

7|Page

Figure 1 This figure shows how linear interpolation can be used to calculate the value of u(I,j) knowing the previous two values

For a uniform grid,

, and therefore the above equation can be simplified to

Similarly, the

component can be calculated as follows

Note that this procedure needs a number of iterations in order for the values of converge to their exact values. Actually, after guessing and

and

to

the first time and running them location is

through the Thomas Algorithm, linear interpolation is no longer needed until the reached. Instead, the newly computed values for and

are used for the second iteration and so

on. The number of iterations used may vary, although 4 or more iterations seem to give extremely close (if not the same) results.

8|Page

Implementing an iterative method in MATLAB is fairly simple. In fact, after setting a value for the total number of iterations, a while or for loop can be used as shown below. Additionally, an if-statement must be included to make sure that linear interpolation is run only the first time. Note that and correspond to the special variables listed above. Moreover, for coding location; the location is the location, and

purposes, the location is considered the so on.

for i=2:(nx-1) iterations = 10; % number of iterations counter = 0; % used to iterate 10 times for fixed i-position/x-position while counter<iterations for j=2:(ny-1) if counter==0 % Linear Interpolation to guess u and v velocities % This assumption is used for the first iteration only u(i+1,j) = Z4*u(i,j)-Z5*u(i-1,j); v(i+1,j) = Z4*v(i,j)-Z5*v(i-1,j); end % Tridiagonal Matrix Coefficients % A-coefficient end % Call ThomasAlg function % Compute horizontal velocity % Computation of BL for numerical solution % Compute vertical velocity counter = counter + 1; % goes to the next iteration end end

9|Page

2.2.2 Developing the matrix for the discretized BL equations

Knowing the values of used to solve for the

and

implies that the momentum equation can now be

velocities in the grid. This is done by creating one tridiagonal matrix that value simultaneously using known values from previous and

solves for each unknown

points. This solution algorithm is then stepped forward for all values until the entire grid has been solved. The key to this solution is finding the matrix coefficients. This is done by rearranging the momentum equation with unknowns on the left-hand side of the equation and the known terms on the right-hand side of the equation. This is shown below:

The equation above is the matrix equation for a particular and step where the unknowns are , , and . However, the boundary conditions of the grid indicate that , will be known as

at the lower boundary,

, will be known and at the upper boundary,

well. This information is critical to creating correct tridiagonal matrix that can be solved by a the use of the Thomas Algorithm. The small sample matrix below shows the construction of the tridiagonal matrix and role of the boundary conditions in this matrix. The matrix is designed to solve for the point to . It is important to note that values at and and

are boundary conditions and

will be known. For simplicity, the value of points is disregarded. Any subscript denotes a value. Note that the pressure term, no pressure gradient. , goes to zero since the initial assumption is that there is

10 | P a g e

The above matrix is not yet solvable. In order to create a true tridiagonal matrix, the boundary conditions at and must be taken into account and removed from the A

matrix. This is done by moving known terms from the A matrix over into the b matrix. The final matrix for to is shown below:

It is fairly simple to use information from the sample matrix and convert back into and form. This shows how the code will fill in the matrix where condition and is the lower boundary

is the upper boundary condition. That final matrix is displayed below:

11 | P a g e

2.2.3 The Thomas Algorithm

Blottners method relates five different points at a time, as depicted by Figure 1. As indicated in section 1.2, the boundary conditions for the freestream velocity were duplicated for and so that . From the bottom left corner of the grid, the values of

three out of the five points are known because of the boundary conditions. The remaining two points, circled with a red dotted line in Figure 1, must be solved using a system of equations given by all the iterations in they-direction. When put in the form of , where is the vector whose entries

are the solution for a fixed x, the matrix

velocities at all y locations for is tridiagonal. Therefore,


Figure 2 Molecule/stencil used in the Blottner's Method

using the Thomas Algorithm becomes extremely convenient, since it only requires instead of the operations

operations if using Gaussian elimination. The Thomas Algorithm is a

simplified form of Gaussian elimination that can be used to solve for tridiagonal systems of equations. A first sweep eliminates the s and then an abbreviated backward substitution , all values in the y-direction can

produces the solution. With this method, for a fixed be solved for simultaneously. The equations for

have the following format:

The equation looks essentially like figure 2 in matrix form

12 | P a g e

Figure 3 Thomas Algorithm Matrix

Implementing this algorithm into MATLab requires the coefficients which were derived from discretizing boundary layer equations with Blottners method are as follows: A-coefficient: If If 0

B-coefficient:

C-coefficient: If If 0

D-coefficient: If

13 | P a g e

If

If

and

The MATLAB code inside the main code setting these coefficients is as follows:
% Tridiagonal Matrix Coefficients % A-coefficient if j==2 A(i-1,1) = 0; else A(i-1,j-1) = -v(i+1,j)/(2*dy) - nu/(2*(dy)^2); end % B-coefficient B(i-1,j-1) = 3*u(i+1,j)/(2*dx) + (nu)/(dy)^2; % C-coefficient if j==(ny-1) C(i-1,j-1) = 0; else C(i-1,j-1) = v(i+1,j)/(2*dy) - nu/(2*(dy)^2); end % D-coefficient if j==2 D(i-1,j-1) = -(u(i+1,j)/(2*dx))*(u(i-1,j)-4*u(i,j)) + ... (v(i+1,j)/(2*dy) + nu/(2*(dy)^2))*(u(i+1,1)); end if j==(ny-1) D(i-1,j-1) = -(u(i+1,j)/(2*dx))*(u(i-1,j)-4*u(i,j)) + ... (-v(i+1,j)/(2*dy) + nu/(2*(dy)^2))*(u(i+1,ny)); else D(i-1,j-1) = -(u(i+1,j)/(2*dx))*(u(i-1,j)-4*u(i,j)); end

The following code that follows setting up the coefficients calls upon the Thomas Algorithm subroutine to solve for the u velocities.
% Call ThomasAlg function u_temp(i+1,:) = ThomasAlg(A(i-1,:),B(i-1,:),C(i-1,:),D(i-1,:));

The Thomas Algorithm subroutine code is:


14 | P a g e

function [ u ] = ThomasAlg( A, B, C, D ) %THOMASALG executes the Thomas Algorithm on a tridiagonal matrix N = length(A); % Modify the first-row coefficients C(1) = C(1)/B(1); % Division by zero risk. D(1) = D(1)/B(1); for i=2:(N-1) temp = B(i)-A(i)*C(i-1); C(i) = C(i)/temp; D(i) = (D(i)-A(i)*D(i-1))/temp; end D(N) = (D(N)-A(N)*D(N-1))/(B(N)-A(N)*C(N-1)); % Back substitution u(N) = D(N); for i=N-1:-1:1 u(i) = D(i)-C(i)*u(i+1); end end

Once the Thomas Algorithm is applied to solve for the u velocities, the following equation is used to get the v velocities at the i + 1 and j + 1 location:

2.2.3a Thomas Algorithm Example

Numerical Example Thomas Algorithm solving a tridiagonal system of equations that is 5x5

15 | P a g e

i = 1:

i = 2:

i = 3:

i = 4:

i = 5:

16 | P a g e

Solve using back substitution


i = 5:

i = 4: i = 3:

i = 2:

i = 1:

Running the Thomas Algorithm code verifies these results.

3 Developing an Algorithm for Solving the BL Equations Numerically


Once the main procedure for calculating the components of the horizontal and vertical velocities has been developed, using computer languages to set up the calculations becomes particularly useful. In fact, the nodes to solve for are usually in the order of thousands or tens of thousands.

3.1 Pseudocode
The general algorithm for the code is outlined below.
17 | P a g e

1. Set parameters (density, dynamic viscosity, freestream velocity) 2. Create mesh grid for x and y points 3. Create matrix of zeros for and
Formatted: Font: Not Highlight Formatted: Font: Not Highlight

4. Create matrix of ones for tridiagonal matrix coefficients A, B, C , D 3.5.Create dummy matrix of zeros for 6. Set boundary conditions 7. Set special coefficients for uniform grid spacing (Ys and Zs coefficients) 8. Create matrix of zeros for boundary layer thickness, delta 4.9.Create matrix for pressure gradient 10. For 5.11. to While loop for number of iterations a. For to (nested for loops)

Formatted: Font:

Formatted: Justified

i. Linear Interpolation to estimate u and v velocities (only in first iteration) i.ii. List coefficients A, B, C, D for Thomas Algorithm ii.iii. Pass coefficients to a Thomas Algorithm Function iii.iv. Solve for iv.v. Solve for velocities velocities

v.vi. Proceed to next 12. Create vector plot for 6.13. 7.14. and and and determine boundary layer thickness, displacement
Formatted: Font: Not Highlight

Create contour plot for Find where

thickness, and momentum thickness 8.15. Determine skin friction coefficient

18 | P a g e

9.16.

Plot and compare boundary layer thickness, displacement thickness, momentum

thickness, and skin friction coefficient with Blasius solution 10.17. Plot the percentage error

4 Implementing the Algorithm in a Computer Language (MATLAB)


How to compute the boundary layer thickness of the numerical solution In order to compare the numerical method to the Blasius solution, the boundary layer thickness, , must be computed. Recall that is defined as the location at which while iterating in the y-direction, when since a numerical method is being used, use of the follows:
% Call ThomasAlg function for j=2:(ny-1) % Compute horizontal velocity % Computation of BL for numerical solution % Limit of BL is set at 0.99*U or 99% of freestream velocity if ((u(i+1,j)>=0.99*U)&&delta(i+1)==0) delta(i+1)=j*dy; end

. Therefore, . Note that , hence the

, might never be exactly equal to

sign. When implemented in MATLAB, the process described above is coded as

Note that the variable delta contains the values of the boundary layer thickness, which are unique for every location. Thus, an extra condition, delta(i+1)==0, must be used in the ifstatement in order to avoid overwriting an already existing value of the BL thickness. In fact, as the loop iterates for growing , once a value is assigned to delta, all following values of by definition, greater than for a fixed location.
19 | P a g e

are,

4.1 How to compare the numerical results to the Blasius solution


4.1.1 Boundary Layer Thickness

Once the boundary layer thickness for the numerical solution is computed, a direct comparison with the Blasius solution can be done. Recall that the Blasius solution is an exact solution to the BL equations and defines as follows

where
4.1.2 Displacement Thickness and Momentum Thickness

The displacement thickness is calculated with the following equation:

The momentum thickness is calculated with the following equation:

Both these values were calculated using numerical integration. This was implemented into the MATLAB relatively easily. A new delta variable was introduced to track the results when they reach the boundary layer and then calculate the limits for the integration for both equations. The actual integration is calculated from trapezoidal integration. A quick check is added to make sure these calculations were only made when the boundary layer is reached.

20 | P a g e

for i=2:(nx-2) lim = nDelta(i); temp1 = zeros(1,lim); temp2 = zeros(1,lim); if(lim>1) for j=1:lim temp1(1,j) = 1-(u(i,j))/U; temp2(1,j) = (u(i,j))*(1-(u(i,j))/U)/U; end dispTh(1,i) = 0.5*(delta(i,1)/(lim-1))*(2*sum(temp1)-temp1(1,1)temp1(1,lim)); momTh(1,i) = 0.5*(delta(i,1)/(lim-1))*(2*sum(temp2)-temp2(1,1)temp2(1,lim)); else dispTh(1,i) = 0; momTh(1,i) = 0; end end

4.1.3 Coefficient of Skin Friction

The above equation is the forward finite difference formula of second order accuracy that was used to estimate instantaneous u velocity with respect to y. This was used to calculate at the

wall in order to determine the shear force at the wall, allowing for calculation of the skin friction coefficient. The shear force equation is shown on the left below and the skin friction coefficient is shown on the right.

The implementation of this in MATLAB was done by simply calculating

after the u and v

velocities are calculated for each x value. Then the skin friction coefficient was calculated using

21 | P a g e

. Re-initialization of j was necessary to calculate

at the wall. The code below follows the

calculations for the u and v velocities are calculated for each x value.
j = 1; dudy(i+1) = (-3*u(i+1,j)+4*u(i+1,j+1)-u(i+1,j+2))/(2*dy); Cf(i+1) = mu./q.*(dudy(i+1));

These results were plotted with the Blasius solution for comparison. The Blasius solution for displacement thickness, momentum thickness, and skin friction coefficient are shown below. These plots matched relatively well with the numerical plots. The accuracy of the displacement thickness and the momentum thickness plots for the numerical solution were really close for the leading edge. The accuracy decreased along as flat plate distance from the leading edge increased. However, the accuracy of the numerical skin friction coefficient plot increased as flat plate distance from the leading edge increased. This is caused by the fact that the Blasius solution for skin friction coefficient is not directly proportional to the flat plate distance from the leading edge

22 | P a g e

Figure 4 A graph showing the exact (Blasius) solution vs. the numerical solution obtained using a uniform grid. Note that the steps in the curve of the numerical solution are given by the fact that is a finite value

23 | P a g e

4.2 Blottner Method Using the Thomas Algorithm MATLAB Code


Main_Project.m:
% ------------------------------------------------% Aersp 312 - Honors Option % Laminar Flow over a Flat Plate % ------------------------------------------------clc clear all; close all; % ------------------------------------------------% Constants U = 50; nu = 2e-4; rho = 1.225; mu = rho*nu;

% % % %

velocity [m/s] kinematic viscosity [m^2/s] density [kg/m^3] dinamic viscosity [mkg/s]

% Parameters for grid dx = 0.0001; x = 0.25; nx = x/dx+1; dy = dx; y = 0.010; ny = y/dy+1; [x0,y0] = meshgrid(0:dx:x,0:dy:y); % u and v velocities - initialization u = zeros(nx,ny); v = zeros(nx,ny); % A B C D Tridiagonal Matrix Coefficients - initialization = ones(nx-1,ny-2); = ones(nx-1,ny-2); = ones(nx-1,ny-2); = ones(nx-1,ny-2);

% Temporary u-velocity - initialization u_temp = zeros(nx,ny-2); % Boundary conditions (flat plate starts at i=3; before it's all % freestream) u(1,:) = U*ones(1,ny); u(2,:) = u(1,:); u(:,1) = 0*ones(nx,1); u(1,1) = U; u(2,1) = U; u(:,ny) = U*ones(nx,1); % Spacial Coefficients (these are for uniform grid spacing)

24 | P a g e

Y1 = 1/(2*dy^2); Y2 = 1/(2*dy); Y3 = 1/(2*dy^2); Z1 Z2 Z3 Z4 Z5 = = = = = 3/(2*dx); 2/dx; 1/(2*dx); 2; 1;

% Dynamic Pressure based upon U q = 1/2*rho*U^2; % BL Thickness initialization delta = zeros(nx); % Skin Friction coefficient initialization Cf = zeros(nx); % du/d initialization dudy = zeros(nx); nDelta=zeros(1,nx-2); % Pressure Term (constant dp/dx) dpdx = 0; % arbitrary pressure gradient % Initialization of separation at zero (i.e. no separation) separation = 0; % Compute u and v velocities (this is where the magic happens) for i=2:(nx-1) iterations = 4; % number of iterations counter = 0; % used to iterate 4 times for fixed i-position/x-position while counter<iterations for j=2:(ny-1) if counter==0 % Linear Interpolation to guess u and v velocities % This assumption is used for the first iteration only u(i+1,j) = Z4*u(i,j)-Z5*u(i-1,j); v(i+1,j) = Z4*v(i,j)-Z5*v(i-1,j); end % Tridiagonal Matrix Coefficients % A-coefficient if j==2 A(i-1,1) = 0; else A(i-1,j-1) = -v(i+1,j)/(2*dy) - nu/(2*(dy)^2); end % B-coefficient B(i-1,j-1) = 3*u(i+1,j)/(2*dx) + (nu)/(dy)^2;

25 | P a g e

% C-coefficient if j==(ny-1) C(i-1,j-1) = 0; else C(i-1,j-1) = v(i+1,j)/(2*dy) - nu/(2*(dy)^2); end % D-coefficient if j==2 D(i-1,j-1) = -(u(i+1,j)/(2*dx))*(u(i-1,j)-4*u(i,j)) + ... (v(i+1,j)/(2*dy) + nu/(2*(dy)^2))*(u(i+1,1)); end if j==(ny-1) D(i-1,j-1) = -(u(i+1,j)/(2*dx))*(u(i-1,j)-4*u(i,j)) + ... (-v(i+1,j)/(2*dy) + nu/(2*(dy)^2))*(u(i+1,ny)); else D(i-1,j-1) = -(u(i+1,j)/(2*dx))*(u(i-1,j)-4*u(i,j))... -1/rho*dpdx; end end % Call ThomasAlg function % Note: used a dummy variable, u_temp, to match dimensions of % A, B, C, D since the Thomas Algorithm should not change the lower and % upper B.C.'s for the uvelocity u_temp(i+1,:) = ThomasAlg(A(i-1,:),B(i-1,:),C(i-1,:),D(i-1,:)); k = 1; % used to match right indices of u_temp and u for j=2:(ny-1) % Compute horizontal velocity u(i+1,j) = u_temp(i+1,k); k = k+1; % Computation of BL for numerical solution % Limit of BL is set at 0.99*U or 99% of freestream velocity if ((u(i+1,j)>=0.99*50)&&delta(i+1)==0) nDelta(i+1)=j; delta(i+1)=j*dy; end if ((u(i+1,j)<=0)&&separation==0) separation=i*dx; end end for j=2:(ny-1) % Compute vertical velocity v(i+1,j+1) = v(i+1,j-1)-(Z1*u(i+1,j)-Z2*u(i,j)+Z3*u(i-1,j))/Y2; % v(i+1,j+1) = -(v(i+1,j-1)-(Z1*u(i+1,j)-Z2*u(i,j)+Z3*u(i1,j))/Y2); end counter = counter + 1; % goes to the next iteration end j = 1; dudy(i+1) = (-3*u(i+1,j)+4*u(i+1,j+1)-u(i+1,j+2))/(2*dy); Cf(i+1) = mu./q.*(dudy(i+1)); end

26 | P a g e

% Displacement and Momentum Thicknesses dispTh=zeros(1,nx); momTh=zeros(1,nx); for i=2:(nx-2) lim = nDelta(i); temp1 = zeros(1,lim); temp2 = zeros(1,lim); if(lim>1) for j=1:lim temp1(1,j) = 1-(u(i,j))/U; temp2(1,j) = (u(i,j))*(1-(u(i,j))/U)/U; end dispTh(1,i) = 0.5*(delta(i,1)/(lim-1))*(2*sum(temp1)-temp1(1,1)temp1(1,lim)); momTh(1,i) = 0.5*(delta(i,1)/(lim-1))*(2*sum(temp2)-temp2(1,1)temp2(1,lim)); else dispTh(1,i) = 0; momTh(1,i) = 0; end end % Velocity Plots % Vector Plot of u velocity (may not be able to visualize result very well) X = x0'; Y = y0'; U0 = u; V0 = v; figure(1) quiver(X,Y,U0,V0) hold on % Contour Plot of u velocity (should be able to see result better with % this contour plot) [X0,Y0] = meshgrid(0:dx:x,0:dy:y); figure(2) Z = u'; contour(X0,Y0,Z) hold on length = 0:dx:x; % length of flat plate discretized into nx points

% Blasius Solution vs. Numerical Solution Plot % BL thickness calculated using the Blasius Solution (BS) deltaBS = 5.*length./((U.*length+0.0000001)./nu).^(1/2); % the 0.0000001 is used to avoid discontinuities at the leading edge dispThBS = 1.721.*length./((U.*length+0.0000001)./nu).^(1/2); momThBS = 0.664.*length./((U.*length+0.0000001)./nu).^(1/2); figure(3)

27 | P a g e

plot(length,deltaBS,length,delta) legend('Blasius Solution','Numerical Solution') title('BL Thickness - Blasius Solution vs. Numerical Solution') xlabel('Flat Plate Distance from LE [m]') ylabel('BL thickness [m]') hold on figure(4) plot(length,dispTh,length,momTh,length,dispThBS,length,momThBS) legend('Displacement Thickness Numerical','Momentum Thickness Numerical',... 'Displacement Thickness Blasius','Momentum Thickness Blasius') xlabel('Flat Plate Distance from LE [m]') ylabel('thickness [m]')

% Skin Friction Coefficient plot % Skin Friction Coefficient for the Blasius Solution CfBS = 0.664./((U.*length+0.1)./nu).^(1/2); figure(5) plot(length,CfBS,length,Cf) legend('Blasius Solution','Numerical Solution') title('Skin Friction Coefficient - Blasius Solution vs. Numerical Solution') xlabel('Flat Plate Distance from LE [m]') ylabel('Cf [unitless]') hold on % Percentage Error for BL errorBL = zeros(1,nx); errordt = zeros(1,nx); errormt = zeros(1,nx); errorCf = zeros(1,nx); for i=1:nx errorBL(1,i) = abs((deltaBS(i)-delta(i))./(deltaBS(i)))*100; errordt(1,i) = abs((dispThBS(i)-dispTh(i))./(dispThBS(i)))*100; errormt(1,i) = abs((momThBS(i)-momTh(i))./(momThBS(i)))*100; errorCf(1,i) = abs((CfBS(i)-Cf(i))./(CfBS(i)))*100; end hold off % Percentage Error Graphs figure(6) plot(length,errorBL,length,errordt,length,errormt,length,errorCf) legend('BL Thickness','Displacement Thickness','Momentum Thickness',... 'Skin Friction Coefficient') title('Percent Error - Blasius Solution vs. Numerical Solution') xlabel('Flat Plate Distance from LE [m]') ylabel('Percent Error') % code ends here

ThomasAlg.m:
function [ u ] = ThomasAlg( A, B, C, D ) %THOMASALG executes the Thomas Algorithm on a tridiagonal matrix

28 | P a g e

N = length(A); % Modify the first-row coefficients C(1) = C(1)/B(1); % Division by zero risk. D(1) = D(1)/B(1); for i=2:(N-1) temp = B(i)-A(i)*C(i-1); C(i) = C(i)/temp; D(i) = (D(i)-A(i)*D(i-1))/temp; end D(N) = (D(N)-A(N)*D(N-1))/(B(N)-A(N)*C(N-1)); % Back substitution u(N) = D(N); for i=N-1:-1:1 u(i) = D(i)-C(i)*u(i+1); end end

29 | P a g e

4.2.1 Sample Output

Figure 1

30 | P a g e

Figure 2

31 | P a g e

Figure 3

32 | P a g e

Figure 4

33 | P a g e

Figure 5

34 | P a g e

Figure 6

35 | P a g e

5 Discussion of Results
Numerical Solution vs. Blasius Solution The numerical solution given by the differencing code is similar to the Blasius solution. In fact, the two solutions begin predicting similar values. In some case, such as for the boundary layer thickness, the numerical solution then slowly diverges away from the Blasius solution. However, this result is not entirely discouraging. The maximum error in the boundary layer thickness is only about 25% and stops increasing at that point. That indicates that the solution will no longer diverge and may even converge towards the Blasius solution as x increases. This error is given by the following equation and the graph in Figure 6 (the equation shown applies to error calculations for all values compared to Blasius values obtained in this project):

Note that the percent error near the leading edge is particularly high. This is due to the fact that the BL equations on which this method is based are not valid for small values of x. Additionally, one theory explaining the error in the numerical solution is the fact that our code requires a large amount of computer memory to run. In fact, the numerical code could not be executed at step sizes below a certain value. The ability to decrease step size may have yielded a more accurate numerical solution. The limitations in computer processing and memory also limited the total length of the grid used. There was no way to increase the grid size and check if the numerical solution converged as x increased. A quick analysis of the code at a larger (and more inaccurate step size) yielded that the numerical boundary solution did indeed converge as x distance along the grid increased. However, the solution step size was too inaccurate to regard this evidence as comprehensive. In order to solve the problems of large step sizes and small plates, the required
36 | P a g e

computer memory to run the numerical code must be decreased. This can be done by incorporation a variable grid into the numerical solution. One last consideration is about the use of an adverse pressure gradient. In fact, by letting ,

the code can also predict when separation occurs (see the variable separation in the code). Note that after separation, the components of the velocity diverge (and the solution is not correct anymore) since the BL equations are no longer valid anymore for separated flow.

5.1 Variable Grid Implementation


The flow closest to the flat plates surface is often the most interesting part of the entire boundary layer. It is therefore common practice to implement a stretched grid rather than a uniformly spaced grid in order to visualize the flow directly above the flat plate with greater resolution. This grid will have many more grid points closer to the plate and fewer farther away into the freestream. Implementing a stretched grid also uses much less memory than a finite grid. A possible step for future projects could be to stretch the grid in the equation, shown below, determines how steps in the a number slightly greater than one. Certain values of on how turbulent the flow is. direction. A simple

direction vary. The constant k is typically are more effective than others, depending

The difference coefficients in the

direction will also have to be changed. As listed in Wilcox,

the difference coefficients are listed below:

37 | P a g e

An interesting problem for future projects is to determine how the boundary layer computed with the stretched grid differs from the one computed with the uniform grid. Also, comparing both with the Blasius solution and assessing which one is more accurate could show how much more effective a stretched grid method may be for boundary layer analysis.

38 | P a g e