You are on page 1of 64

Shape Optimization of Low Speed Airfoils

using MATLAB and Automatic Differentiation

Christian Wauquiez

Stockholm 2000
Licentiates Thesis
Royal Institute of Technology
Department of Numerical Analysis and Computing Science

Abstract
The goal of the project is to develop an innovative tool to perform shape optimization of low
speed airfoils. This tool is written in Matlab, and is constructed by coupling the Matlab
Optimization Toolbox with a parametrised numerical aerodynamic solver.
The airfoil shape is expressed analytically as a function of some design parameters. The
NACA 4 digits library is used with design parameters that control the camber and the
thickness of the airfoil.
The solver has to provide fast and robust computation of the lift, pitching moment and drag
of an airfoil placed in a low-speed viscous flow. A one-way coupled inviscid - boundary
layer model is used.
The inviscid flow is computed with a linear vortex panel method, which provides the lift and
moment coefficients. The boundary layer is computed using an integral formulation : the
laminar part of the flow is computed with a two-equation formulation, and the turbulent part
is solved with Heads model. An e9-type amplification formulation is used to locate the
transition area. Finally, the drag coefficient is computed using the Squire-Young formula.
In order to be used in optimization, the solver must provide derivatives of the objective
function and limiting constraints with the solution for each set of parameters.
These derivatives are computed by automatic differentiation, a technique for augmenting
computer programs with the computation of derivatives based on the chain rule of differential calculus. The recent Matlab automatic differentiation toolbox ADMAT is used.
Finally as an application, sample optimization problems are solved using the Matlab Optimization Toolbox, and the resulting optimal airfoils are analysed.
ISBN 91-7170-520-1 TRITA-NA-0004 ISSN 0348-2952 ISRN KTH/NA/R--00/04--SE

Contents
Introduction
1- The Aerodynamics Solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.1- Introduction - Overview of the Model
1.2- Airfoil and Flow Parameters
1.3- Inviscid Flow Model
1.4- Boundary Layer Model
2- Automatic Differentiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.1- Introduction
2.2- Method Fundamentals
2.3- Computer Implementation
2.4- ADMAT, Automatic Differentiation Toolbox for Matlab
2.5- Application of ADMAT to the Aerodynamic Solver
3- Airfoil Shape Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.1- Definition of the Optimization Problems
3.2- Solving the Optimization Problems
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
References

Acknowledgements
I would like to thank my supervisor, Associate Professor Jesper Oppelstrup, for his interest
and support throughout this work, and Professor Arthur Rizzi for providing information and
for many helpful discussions.
I would also like to thank, for advice and technical support, Associate Professor Ilan Kroo
from Stanford University and Desktop Aeronautics, and Doctor Arun Verma from the
Cornell University Theory Center.
Financial support from NUTEK through the Parallel Scientific Computing Institute, KTH,
and TFR through the Center for Computational Mathematics and Mechanics, KTH, is
gratefully acknowledged.
3

Introduction
The performance of an airfoil can be characterized by three quantities : the lift, moment and
drag coefficients : Cl, Cm and Cd respectively. They represent the aerodynamic loads applied
to the airfoil. The actual loads are proportional to the coefficients times the square of the flow
velocity.
Cl corresponds to the force acting on the airfoil in the direction orthogonal to the flow,
which allows an aircraft to fly by compensating its weight.
Cm corresponds to the moment of the aerodynamic force with respect to the quarter of the
airfoil chord length. For the equilibrium of an aircraft, the pitching moment of the main
wing has to be compensated by the moment of a negative-lift tail. Cm should therefore not
be too large.
Finally, Cd corresponds to the component of the force in the flow direction, which hinders
aerodynamic performances and causes fuel consumption.
The present work focuses on shape optimization of airfoils in low speed viscous flows, based
on the analysis of Cl, Cm and Cd.
The airfoils are chosen from the NACA 4 digits library [1], in which the shape is expressed
analytically as a function of three parameters. The library is presented in section 1.2 of this
report.
The formulation used to compute the aerodynamic coefficients is an inviscid - boundary
layer model. The advantage of this kind of approach is that it provides a fast computation of
the flow solution, the disadvantage being that cases with massive flow separation are
impossible to handle. Famous codes based on this formulation include for 2D cases Desktop
Aeronautics Panda [9], and Mark Drelas ISES [10] and Xfoil [12], and for 3D cases Brian
Maskews VSAERO [3]. The solver is presented in section 1.
In order to perform optimization, the solver has to provide the derivatives of the defined
objective function and limiting constraints with the solution for a given set of parameters.
The most common method used to compute these derivatives is finite differences. In the
present work, a new approach, called automatic differentiation (AD), is used. Is is a chainrule-based technique to compute the derivative of functions defined by computer programs
with respect to their input variables, and has been investigated since 1960. In 1998, a general
AD toolbox for programs written in Matlab, called ADMAT [19], has been developped at
Cornell University by Arun Verma and Thomas F. Coleman. The present work uses this
toolbox. Automatic differentiation is presented in section 2.
Finally, airfoil shape optimization is performed using the Matlab Optimization Toolbox [20],
which uses a Sequential Quadratic Programming algorithm for non linear constrained
problems. The formulation of sample optimization problems and their resolution are
presented in section 3.

1- The Aerodynamic Solver


The solver used to provide the objective function as well as the limiting constraints of the
optimization is presented. The solution is computed using an inviscid-boundary layer model,
and consists in the lift, moment, and drag coefficients : Cl, Cm and Cd respectively.

1.1- Introduction - Overview of the Model


The general Navier-Stokes equations are very powerful since they give a complete
description of all possible flow situations. However it is very time-consuming to obtain a
numerical solution using them. In our particular case, the incompressible turbulent flow past
an airfoil, the viscous effects are important only in a small region near the profile. In this
region, the Navier-Stokes equations can be approximated by the so-called boundary layer
equations. Outside, viscous effects can be neglected, and one can use an inviscid flow model.
Euler

Navier-Stokes

Boundary Layer
The inviscid flow model
The inviscid part of the flow can be solved in several ways. A finite difference discretization
of the steady Euler equation on a grid around the airfoil can be used, as in ISES [10], or a panel
method, as in Xfoil [12] and Panda [9]. One advantage of the first option is that by applying
a periodic boundary condition to the outer boundary, cascade flows can be simulated. This is
done in MISES [13], an extension of ISES.
In the present work, a panel method is used. A variety of such methods exists, they differ in
the choice of the singularity used to represent the velocity potential on the airfoil (sources,
doublets or vortices), and by the choice of the Kutta condition, an extra condition that one
must add to the final system of equations in order to obtain a unique solution. Details about
different panel methods can be found in [2]. The present work uses a linear vortex distribution, which gives a good solution accuracy, even with only a few panels. The Kutta
condition chosen is especially well suited for linearly varying singularity distributions.
The inviscid flow solver provides the tangential velocity distribution on the airfoils surface
(Ue). The pressure distribution is then computed from the velocity field using the Bernoulli
equation. The lift and moment coefficients, as well as the pressure drag, are calculated by
integrating the pressure over the body surface.

1- The Aerodynamic Solver

The boundary layer model


The boundary layer formulation consists of a model for the laminar part of the flow, a
transition criterion, and a model for the turbulent part of the flow. The flow models rely on
one or two differential equations derived from the integration of the Falker-Skan equations
accross the boundary layer thickness, and on additional semi-empirical equations which
close the sytem.
Xfoil and ISES use the same viscous formulation : a set of two differential equations
(integral momentum and kinetic energy shape parameter equations) for both laminar and
turbulent flows, and different closure relations depending on the flow regime. Panda on the
other hand uses simpler formulations : Thwaites one equation method [4] for the laminar
part, and Heads two equations method [5] for the turbulent part. The present work initially
used simple models, thus Thwaites and Heads. But since Thwaites model cannot represent
separated flow, Xfoils laminar boundary layer model, which can describe thin separated
regions, has been implemented instead.
Concerning the transition criterion, Panda uses Michels criterion, and Xfoil uses a more
advanced e9-type formulation. The second method has been chosen after testing.
Details about the reasons of these choices are found in sections 1.4.1 and 1.4.2.
The results provided by the boundary layer solver include the displacement thickness , the
momentum thickness , the shape factor H, and the skin friction coefficient Cf. These
quantities are used to compute the drag coefficient. Different methods can be used depending
on the coupling between the inviscid flow and the boundary layer.
The coupling
The coupling between the two models is as follows :
The effect of the boundary layer is that it modifies the shape of the airfoil as seen by the
external flow. This gives the inviscid flow a zero normal velocity condition on a boundary
obtained by adding the boundary layer displacement thickness to the airfoils surface.
The boundary layer equations depend on the external tangential velocity distribution.
Inviscid Flow with
zero normal velocity condition
on Airfoil +

Ue
Boundary Layer

Two different approaches are possible for the coupling of inviscid - boundary layer flows.
Two-way coupled computation
In this case, the modification of the boundary where the zero normal velocity condition has
to be met due to the boundary layer thickness is taken into account.
The solution begins with the inviscid flow problem, which produces the velocity field. This
data is then fed into the boundary layer model which results the local wall friction coefficient
and the displacement thickness. Then a second iteration is performed, now with modified
8

1.2- Airfoil Shape Parameters

surface geometry. This modification can be obtained by displacing the body panels
according to the local displacement thickness, and the procedure is reiterated until a
converged solution is obtained.
Another way to account for the displacement effects is to modify the boundary condition
instead of the geometry. In this case the normal flow is made non-zero to account for the
effect of . This formulation, known as the transpiration velocity concept, states that :
d
V n = ------ ( U e ) on the airfoils surface.
dx
Using a two-ways coupled model, the total drag is found by adding the friction drag,
obtained by integrating the skin friction coefficient Cf, to the pressure drag, obtained by
integrating the inviscid pressure distribution.
A study of such iterative methods can be found in [14], where it appears that convergence is
not easy to obtain. A more recent approach is the one used in ISES and Xfoil. The
transpiration velocity concept is used, and the entire nonlinear equation set is solved
simultaneously as a fully coupled system by a Newton-Raphson method. This method
provides more robust results than the iterative approach.
One-way coupled computation
In this case the effect of the boundary layer thickness is neglected. One single iteration is
performed : the external tangential velocity is computed by the inviscid model with the
condition V.n=0 on the airfoils surface, and then fed into the boundary layer model.
The drag coefficient is obtained using the Squire-Young formula [8], which in effect
computes the momentum deficit. It is a function of some of the boundary layer results
(momentum thickness and shape factor) at the trailing edge.
Compared to coupled computations, the accuracy of the lift is very good, but not as good for
the drag. However the sensitivity of the results with respect to airfoil shape or flow
parameters is well reproduced. This method is used in Panda, as well as in the present work.

1.2- Airfoil Shape Parameters


The shape of the airfoil can be chosen in the famous Naca 4 digits library [1]. This simple
library is interesting because the shape is expressed analytically as a function of three
parameters, which control the maximum camber, maximum camber location, and maximum
thickness of the airfoil.
y

2412

Maximum Thickness

8412

Maximum Camber

4212

4812
4406

Maximum Camber Location

4420

1- The Aerodynamic Solver

A wide variety of airfoils can be obtained by varying the three parameters, as shown on the
previous figure.
A numbering system is used to define NACA 4-digits wing sections. The first digit indicates
the maximum value of the mean-line ordinate in percent of the chord. The second integer
indicates the distance from the leading edge to the location of the maximum camber in tens
of the chord. The last two integers indicate the section thickness in percent of the chord.
Thus, the NACA 4512 has 4% camber located at 50 % of the chord from the leading edge,
and is 12% thick.
We note that these digits do not really have to be integers. By extension of the notation, a
NACA 4.23 2.21 17.2 would have 4.23% camber located at 22.1% of the chord from the
leading edge, and be 17.2% thick
The wing section is obtained by combining the camber line and the thickness distribution as
shown on the following figure
y

yc
y th

y th

x U = x y th cos

y U = y c + y th sin

And :

x L = x + y th cos

y L = y c y th sin

where ( x U, y U ) and ( x L, y L ) are points on the upper and lower surface respectively.
The thickness distribution and the camber line are given by :
x
x 2
x 3
x 4
x
y th = 5c 0.2969 --- 0.126 --- 0.3537 --- + 0.2843 --- 0.1015 ---

c
c
c
c
c
And :

m
x x 2
x
y c = ----2- 2p --- --- for --- p

c
c
c
p
m
x x 2
x
= ------------------2- 1 2p + 2 p --- --- for --- p

c
c
c
(1 p)

In these expressions, c is the airfoil chord length, m is the maximum camber, p is the
maximum camber location, and is the maximum thickness.

10

1.3- Inviscid Flow Model

1.3- Inviscid Flow Model


The incompressible potential flow governed by the Laplace equation is solved numerically
with a panel method, which provides the tangential external velocity. The pressure is then
obtained using the Bernoulli equation, and Cl and Cm are derived by integrating the
pressure over the airfoil.
Theoretical equation of the flow
n

Inviscid
Incompressible
Irrotational

airfoil A

For an irrotational flow, the velocity is the gradient of a quantity called the velocity potential.
V = ( u, v ) =
Substituting this into the continuity equation for an inviscid incompressible flow leads to :
2


+
= 0 or : = 0 (Laplace equation)
x2 y2
On the airfoils surface A, the external Neumann boundary condition must be satisfied :

------ = V n ,
n
where V n can be related to integral boundary layer quantities through the transpiration
velocity model. In our case, the effect of the boundary layer is neglected and V n is simply set
to zero, which produces the classical zero normal velocity condition.
General solution of the incompressible potential flow
A general solution to the Laplace equation is obtained by adding a distribution of vortices
on the airfoils surface to the potential of the free stream. The solution at any field point P is
thus given by :
P = u x + v y + v ds,
A

where v is the potential of a unit strength vortex :


1
v = ------
2
( r, ) being the polar coordinate of P relative to (ds).
11

1- The Aerodynamic Solver

This equation has to satisfy the boundary condition for every point on A, which gives :
v
P n = 0 ( u , v ) n + -------- ds = 0
n
A

This is the basis equation for the panel method. To construct a numerical solution the body is
divided into N flat panels and the boundary condition equation is specified on each of them at
a "collocation point" defined as the panel mid-point.
3
2
1
N-1

Panel corner point


Collocation point

Moreover, the integration is performed on each panel and the boundary condition becomes :
N

( u , v ) n +

v
-------- ds = 0
n
panel

i=1

Singularity element
Now, the integral on each panel must be computed :
v
v
v

-------- ds = -------- ds, -------- ds n ( u, v ) n


n
y
panel x
panel
panel

We will first compute u and v in the panel coordinate system, and then transform them back
in the global coordinate system.
We now consider the coordinates (x,y) in the panel coordinate system. They are obtained
using the following transformation :
x
=
y p

cos i sin i x x 0

,
sin i cos i y y 0 G

where ( x 0, y 0 ) are the coordinates of the panel origin in the global coordinate system.
y

Global CS

yp

Panel CS

Panel i

xp
x

12

1.3- Inviscid Flow Model

On each panel, we choose a linear vortex distribution ( x ) = 0 + 1 x .


yp
0
0 + 1x

xp

This is simply the superposition of a constant-strength element and a linearly varying


element. For simplicity, we consider the two elements separately to compute the potential
and the velocity induced by one panel.
L

0
y
= -------- atan -------------- dx 0
2
x x0
0

So :

u 0


0
y
= ----------0 = ------ --------------------------------dx
2 ( x x 0 ) 2 + y 2 0
x
0

And :

v 0


x x0
0
= ----------0 = -------- --------------------------------dx
2 ( x x 0 ) 2 + y 2 0
y
0

Details of the computation of the integrals appear in [2]. The result is :


0
0 r
u 0 = ------ ( 2 1 ) and : v 0 = ------ ln ---22
2 r 1
We consider the linear term now :
L

1x

1
y
= -------- x 0 atan -------------- dx 0
2
x x0
0

So :

u 1x

1 x
x0 y
1
- = ------ --------------------------------= ----------dx
2 ( x x 0 ) 2 + y 2 0
x
0

And :

v 1x

1 x
1 x0 ( x x0 )
= ----------- = -------- --------------------------------dx
2 ( x x 0 ) 2 + y 2 0
y
0

13

1- The Aerodynamic Solver

Solving the integrals gives :


1
r
u 1 x = -------- 2z ln ---1- 2x ( 2 1 )
4
r2
1
r
v 1 x = -------- x ln ---1- + L + z ( 2 1 )
2
r2

And :

Now, what we really want is a piecewise linear continuous vortex distribution on the whole
airfoil surface. So we have to set the strength of at the beginning of each panel equal to the
strength of the vortex at the end point of the previous panel as shown on the following figure.
j1
j

yp

P(x,y)

rj
rj + 1

j+1
j-1
j

j
j + 1
j+1

xp
j+2

j+2

The relation between the vortex strengths of the elements shown above and the panel end
values 0 and 1 is :
j = 0 and j + 1 = 0 + 1 L
Thus, rearranging the expressions for u and v in terms of j and j + 1 gives :
r j + 1 j(x j + 1 x j) + ( j + 1 j)(x x j)
z j+1 j
- + -------------------------------------------------------------------------------------- ( j + 1 j )
u = ------ ----------------------- ln ---------

2 x j + 1 x j
2 ( x j + 1 x j )
rj
j(x j + 1 x j) + ( j + 1 j)(x x j)
rj
z j + 1 j xj + 1 xj
v = -------------------------------------------------------------------------------------- ln ---------- + (j + 1 j)
- + ------ ----------------------- ---------------------2 ( x j + 1 x j )
z
r j + 1 2 x j + 1 x j

These two equations can be divided into velocity induced by j and j + 1, such that :
( u, v ) = ( u a, v a ) + ( u b, v b ) ,
where the subscripts a and b represent the contribution due to the leading and trailing
singularity respectively. By rearranging the equations, we obtain the a part of the velocity :
j
rj + 1
u a = ---------------------------------- z ln ---------- + (x j + 1 x)( j + 1 j)
2 ( x j + 1 x j )
rj
j
rj
v a = ---------------------------------- ( x j + 1 x ) ln ---------- + (x j + 1 x j) + z( j + 1 j)
2 ( x j + 1 x j )
rj + 1

14

1.3- Inviscid Flow Model

And the b part of the velocity :


j+1
rj + 1
u b = ---------------------------------- z ln ---------- + (x x j)( j + 1 j)
2 ( x j + 1 x j )
rj
j+1
rj
v b = ---------------------------------- ( x x j ) ln ---------- + (x j + 1 x j) + z( j + 1 j)
2 ( x j + 1 x j )
rj + 1

To transform these velocity components back to the global coordinate system, a rotation by
the panel orientation angle i is performed as given by :
u
cos i sin i u
=

v G
sin i cos i w p

(1)

The expressions above can be included in an induced velocity function F, which will
compute the velocity (u,v) at an arbitrary point (x,y) in the global coordinate system due to
the j-th panel.
u a, v a

= F ( j, j + 1, x, z, x j, y j, x j + 1, y j + 1 )
u b, v b
Discretization of geometry
In most cases involving thick airfoils, a denser paneling is used near the leading and trailing
edges. A frequently used method for dividing the chord into panels with larger density near
the edges is the full cosine method. It is shown on the figure below.
y

1 2

3
8

9 10

Corner point
Collocation point

4
3

10
11 12

13

14

15

16

1
17 18 19

If nine chordwise panels are needed, then the semicircle is divided by this number, and
= 9 . The corresponding x stations are found by using the following formula :
c
x = --- ( 1 cos )
2
Then the airfoil points coordinates are computed using the airfoil shape function.
15

1- The Aerodynamic Solver

Influence coefficients
In this phase, the zero normal flow boundary condition is implemented. For example, the
velocity induced by the jth element with a unit strength at the first collocation point is
obtained by :
u a, v a

= F ( j = 1, j + 1 = 1, x 1, z 1, x j, y j, x j + 1, y j + 1 )
u b, v b 1 j
This shows that the velocity at each collocation point is influenced by the two edges of the
jth panel. When adding the influence of the j+1 panel and on, the local induced velocity will
have the form :
( u, v ) 1 = ( u a, v a ) 11 1 + [ ( u b, v b ) 11 + ( u a, v a ) 12 ] 2 + + [ ( u b, v b ) 1N 1 + ( u a, v a ) 1N ] N + ( u b, v b ) 1N N + 1

This equation can be reduced to the form :


( u, v ) 1 = ( u, v ) 11 1 + ( u, v ) 12 2 + + ( u, v ) 1N N + ( u, v ) 1N + 1 N + 1
Such that for the first and last terms :
( u, v ) 11 = ( u a, v a ) 11 and : ( u, v ) 1N + 1 = ( u b, v b ) 1N
And for all other terms :
( u, v ) 1 j = [ ( u b, v b ) 1 j 1 + ( u a, v a ) 1 j ]
The influence coefficient a ij is then defined as the velocity component normal to the surface.
The contribution of a unit strength singularity element j at collocation point 1 is therefore :
a 1 j = ( u, v ) 1 j n 1 ,
where : n i = ( sin i, cos i )
n i = ( sin i, cos i )

t i = ( cos i, sin i )
i

16

1.3- Inviscid Flow Model

Establishing boundary conditions


The free stream normal velocity component is found as :
RHS i = ( u , v ) ( sin i, cos i )
Specifying the boundary condition equation for each (i= 1 to N) of the collocation points
results in N linear equations with the unknowns j (j = 1 to N+1).
a 11 a 12 a 1N + 1 1

a 21 a 22 a 2N + 1 2

a N1 a N2 a NN + 1 N + 1

RHS
1

RHS
2
=

RHS N

An additional condition must be established in order to obtain a unique solution. Physical


considerations lead to the choice of the Kutta condition, which specifies that the circulation
at the trailing edge must be zero : TE = 0
With our model, the circulation is given by TE = 1 + N + 1 , and the Kutta condition is :
1 + N + 1 = 0
This extra condition is added to the system of equations to give :
a 11 a 12 a 1N + 1
1
a 21 a 22 a 2N + 1

2


a N1 a N2 a NN + 1
N + 1
1 0
1

RHS
1

RHS

RHS N

(2)

The above set of equations has well defined diagonal, and can be solved for i by using
standard methods of linear algebra.
Modification of the Kutta condition
With the implementation of the Kutta condition above, strange results can be obtained.
Indeed the condition 1 + N + 1 = 0 makes possible results such as :
1 = 1e6 and N + 1 = 1 e6
A better Kutta condition would require in addition that both vorticities must be small.
We apply the following :
1 = 0 and N + 1 = 0

17

1- The Aerodynamic Solver

It is thus necessary to introduce an additional unknown. A wake panel with a constantstrength vortex w is added to the model as shown on the following figure. The panel leaves
the trailing edge at its median angle and extends to infinity, so that in practice the far portion
(starting vortex) will have no influence.
3
2
1
N-1

In the panel coordinate system, the velocity induced by the constant-strength vortex w of
the wake panel at point P ( x i, y i ) is :
1
u iw = ------ iw w
2
r i1
1
v iw = ------ ln ------ w
2 r i
where iw is the angle at which P sees the wake panel, and r i1 and r i are the distances from
P to the wake panel end points, as shown on the following figure.
P(x , y )
i i

r i1
Y

x1
X

r i
iw

Wake panel

These velocity components are computed at each collocation point, and transfered in the
global coordinate system using equation (1). The influence coefficient is then obtained by :
a iw = ( u, v ) iw n i ,
where : n i = ( sin i, cos i )
This is then included in the influence matrix, as well as the new Kutta condition.
We obtain :
a 11 a 12 a 1N + 1 a 1w
1
a 21 a 22 a 2N + 1 a 2w
2

a N1 a N2 a NN + 1 a Nw

N+1
1 0
0
0
W
0 0
1
0

Which can be solved for i .


18

RHS 1

RHS 2

RHS N

(3)

1.3- Inviscid Flow Model

Results are now presented using the regular and modified Kutta conditions. The test case is a
NACA 9912 at zero angle of attack, with 100 panels.

This example clearly shows the improvement of the solution.


Calculation of the velocity
The velocity is obtained by adding the tangential components of (u,v) of each panel to the
tangential component of the external flow velocity.
So we have to build the N N + 1 matrix b of coefficients b ij such that :
b ij = ( u, v ) ij t i ,
where : t i = ( cos i, sin i )
And the vector U e of terms : ( U e ) i = ( u , v ) ( cos i, sin i )
Then, we have :

Ue1
b 11

b 21
U e2
=

b N1
U eN

b 12 b 1N + 1 1

b 22 b 2N + 1 2

b N2 b NN + 1 N + 1

U e
1

U
+ e2


U eN

Which gives the tangential velocity at each airfoil collocation point.

19

1- The Aerodynamic Solver

Computation of the pressure


The Bernoulli equation applied to a streamline between the upstream infinity and a point on
the airfoils surface gives :
1
1
2
2
p + --- U e = p + --- U
2
2
So :

1
2 1
2
p = p + --- U --- U e
2
2

Then :

p p
Cp = -------------------------2
1 2 U

Gives :

Ue
Cp = 1 --------2
U

We can thus compute the pressure coefficient at each airfoil collocation point.
Computation of the aerodynamic coefficients
We are looking for the lift coefficient Cl, and the moment coefficient Cm, which represents
the moment of the aerodynamic force with respect to the point of coordinates ( c 4, 0 ) .
Dimensionless coefficients are obtained by integrating Cp.
Cp j

( x j + 1, y j + 1 )

panel j

( x j, y j )

The elementary forces f xj and f yj acting on panel j is obtained as :


f xj = Cp j ( y j + 1 y j ) and : f yj = Cp j ( x j + 1 x j )
And the elementary moment m j is given by :
yj + 1 + yj
x j + 1 + x j c
m j = f xj ----------------------- + f yj ---------------------- --

2
2
4
By doing this for each panel and by adding the elementary forces and moments, the total
load applied to the airfoil is obtained : (Fx, Fy) and Cm.

20

1.3- Inviscid Flow Model

The lift coefficient is then simply the component of F normal to the flow direction :
C l = sin F x + cos F y
And the pressure drag coefficient is the component of F in the flow direction :
C dp = F x cos + F y sin
Validation of the inviscid flow model
First, the accuracy of the solver is tested. The lift, moment and drag coefficients of a NACA
4412 airfoil at 5 degrees angle of attack are computed with 50, 100, 200, 400 and 800 panels.
The results is a clear convergence for all coefficients, as can be seen on the following figures.

Note that the pressure drag coefficient tends to zero. This result is known as the dAlembert
paradox : if the effect of the displacement thickness is not taken into account, the pressure
drag of an airfoil is theoretically equal to zero. Fortunately, the method we use to compute
the drag (the Squire-Young formula, see 1.4.4) provides directly the total drag, so we do not
have to estimate the pressure and friction parts of the drag separately.
The results are then compared to the solution provided by Xfoil, which uses exactly the same
formulation and has been validated with respect to experimental data [12]. On the following
graphs, our program is referred to as PMBL (Panel Method / Boundary Layer).
Graphical results obtained with the two programs are seen in the following figure. The test
case is the inviscid flow past a Naca 4512 at zero angle of attack.

PMBL

Xfoil

21

1- The Aerodynamic Solver

The lift coefficients Cl computed by the two programs are compared in several test cases.
Each case shows the sensitivity, i.e. the evolution, of the results with respect to the angle of
attack and to shape parameters.

The moment coefficients Cm computed by the two programs are now compared in two test
cases. Cm does not vary much with respect to the angle of attack and the thickness, so we test
the sensitivity with respect to the camber and camber location parameters only.

22

1.4- Boundary Layer Model

1.4- Boundary Layer Model


An integral model is used : the laminar part of the flow is computed with a two-equation
formulation previously used in ISES [10], and the turbulent part is solved with Heads model
[5]. An e9-type amplification formulation also used in ISES is used to locate the transition
area. Finally, the drag coefficient is computed using the Squire-Young formula [8], and the
results are compared to the solution provided by Xfoil [12].

1.4.1- Preliminary Work


x
3

2
1

1
2

Upper surface boundary layer

x
Lower surface boundary layer

Before using them in the boundary layer model, the external velocity distribution and the
coordinates of the airfoil must be made dimensionless. The external velocity is thus
divided by the far field flow velocity and the airfoil point coordinates are divided by the
airfoil chord length.
The boundary layer should start at the stagnation point, and follow the flow along the
upper or lower surface toward the trailing edge. This requires identifying the stagnation
point in the inviscid solution and using the panel discretization to compute the arc length
along the surface from the stagnation point, which is the length x in the boundary layer
equations.
The discretization of each side can be given directly by the panels used for the external
flow computation. But in order to be able to solve the boundary layer accurately without
having to use many panels for the inviscid flow solution, it is more convenient to build a
uniform arc length grid on each side. This grid is based on a spline interpolation of the
airfoil panels corner points.
The boundary layer model uses the external tangential velocity, as well as its first spatial
derivative. The value of the velocity at each mesh point is obtained using a spline interpolation of the velocity field known at the panel nodes. The derivative of the velocity is
obtained by differentiating the spline interpolation.

23

1- The Aerodynamic Solver

1.4.2- The Laminar Boundary Layer


Theoretical equation of the flow
By analyzing and comparing the order of magnitude of the terms of the steady
incompressible Navier-Stokes equations, we can derive the following Prandtl boundary layer
equations (details of the computations and approximations can be found in [6]) :
u v
+
= 0
x y

(4)
2

u
u
u
p
+ 2
u + v =
x

y
x
y
p
= 0
y

(5)
(6)

Note : x and y are not Cartesian coordinates. x is measured along the airfoils surface with
x=0 locating the stagnation point, and y is measured normally to the surface.
The most important assumptions used in the derivation are :
The boundary layer thickness is very small compared to L for large Reynolds numbers,
The tangential velocity u is much larger than the normal component v,
The pressure is essentially constant across the boundary layer (in the y direction).
These results naturally lead to the concept of an integral boundary layer formulation, where
the properties are assumed to depend only on x.
Integral momentum equation
By combining the boundary layer equations, and integrating the resulting expression from
zero to infinity with respect to y, the well known Von Karman integral momentum equation
is obtained.
1
d
dU e
+ ------ 2 + -----
= --- C f
2
d x Ue
dx
See [6] for more details about the derivation. The displacement and momentum thicknesses
and , and the skin friction coefficient C f are defined as follows.

1 U-----e- dy

- dy
U-----e- 1 ----U e
u

w
u
- , where : w =
C f = -----------------------2
y
1 2 U e
24

y=0

1.4- Boundary Layer Model

Note : The displacement thickness can be seen as the displacement of the airfoils surface
needed to construct a constant velocity profile through the boundary layer having the same
flow volume as in the real case.
y

Ue

Ue

real BL thickness

(x)

Displacement thickness ( x )
x

x
Airfoils surface

Airfoils surface

This flow volume equivalence can be analytically expressed as :

( Ue u ) dy

= U e

By introducing the shape factor H = , the momentum equation can be written as :


dU e
1
d
+ ------ ( 2 + H )
= --- C f
dx
2
d x Ue

(7)

Kinetic energy integral equation


If the momentum equation is multiplied by u and then integrated, the kinetic energy integral
equation results :
dU e
d
--------- + 3 ------ --------- = 2C D ,
U e dx
dx

(8)

where the kinetic energy thickness , and the dissipation coefficient C D are defined by :

1
u
u 2 u
= 1 ------ ------ dy and : C D = ---------3- 2 dy

U e U e
U e y
Then, by introducing the second shape parameter H = and substracting equation (7)
from equation (8), the kinetic energy equation can be written as :
Cf
dH
dU e
---------- + [ H ( H 1 ) ] ------ --------- = 2C D H ----dx
U e dx
2

(9)

25

1- The Aerodynamic Solver

Thwaites model
This simple model relies on the integral momentum equation, and is derived as follows.
Multiplying equation (7) by the Reynolds number based on the momentum thickness
Re = ReU e , we obtain :
d 2
ReU e --------- = 2 [ L ( 2 + H ) ) ],
dx
Cf
dU e
where : L = ReU e ----- and : = Re 2 --------- ,
2
dx
Then, Thwaites found that the right hand side can be approximated by the linear formula :
2 [ l ( 2 + H ) ) ] 0.45 6
When this and the definition of are substituted in the equation, we obtain :
dU e
d 2
ReU e --------- = 0.45 6Re 2 --------dx
dx
Which leads to the differential equation :
Re

d 2 6
( U e ) = 0.45U e5
dx

The value of at the stagnation point is known :


(x = 0) =

0.075
------------------------dU e
Re --------- ( 0 )
dx

Starting from that, the integration is performed as follows :


xi
i
Re ( 2 U e6 )
i1

= 0.45

U e5 dx

xi 1

The integral is evaluated using a 5th-order Gauss quadrature, which gives a better accuracy
than the 1st-order trapezoidal rule recommended in [6] or [7] :
xi

dx
3 dx
3 dx
U e5 ( x ) dx ------ 5U e5 x m --- ------ + 8U e5 ( x m ) + 5U e5 x m + --- ------ ,

18
52
5 2

xi 1

where dx = x i x i 1 and x m = ( x i + x i 1 ) 2 .
26

1.4- Boundary Layer Model

Once is known, can be calculated. The shape factor H and the skin friction coefficient C f
are then computed from semi-empirical formulas given by Cebeci and Bradshaw [4] :
H ( ) = 2.61 3.75 + 5.24 2 for 0 < < 0.1
0.0731
= 2.088 + -------------------- for 0.1 < < 0
+ 0.14
And :
with :

2L ( )
C f = ------------------ ,
ReVe
L ( ) = 0.22 + 1.57 1.8 2 for 0 < < 0.1
0.018
= 0.22 + 1.402 + ----------------------- for 0.1 < < 0
+ 0.107

As all the one-equation methods, Thwaites method can not represent separated flows since it
uniquely ties the shape parameter to the local pressure gradient which is, in fact, a nonunique
relationship in separating flows. Therefore, for some cases, laminar separation (detected by
the vanishing of C f ) is obtained before transition. After that, following what is done in
Panda, laminar separation is considered as a trigger for transition and the computation is
carried on with the turbulent flow model.
There are thus two different effective transition criteria, which may impair the
differentiability of the solution with respect to the design parameters. A slight modification
of the airfoil geometry can make a change in the active criterion, and since this implies a
jump in the start of the turbulent flow, a resulting jump is obtained in the drag results.
As an example, we consider a 12 % thick airfoil, with 4% maximum camber. The location of
the maximum camber p varies between 20 and 30% of the chord length by increment of 1%.

As p increases, we have first laminar separation on both sides up to p=22%, then transition
happens on the lower side from p=23%, and finally transition takes place on the upper side as
well from p=27%.
The discontinuities in the solution which are seen on the above graph result from the move of
the start of the turbulent flow : from 9.1% of the chord for p=22% to 15,5% for p=23%, and
from 26.5% of the chord for p=26% to 43% for p=27%.
27

1- The Aerodynamic Solver

Two-equation model
This more advanced model is based on the integral momentum and kinetic energy equations.
It adequately describes thin separated regions. Thus the computation of the laminar flow is
always carried out until transition, and there are no longer any discontinuities in the solution.
Closure relations
Since the system of equations (7) and (9) contains too many unknowns, it must be
supplemented by other equations. Semi-empirical relations derived from the Falkner-Skan
one-parameter velocity profile family are used to close the system. The following functional
dependencies are assumed :
( 4 H )2
H = H ( H ) = 1.515 + 0.076 -------------------- for H < 4
H
( 4 H )2
= 1.515 + 0.040 -------------------- for H 4
H
Cf
( 7.4 H ) 2
Re ----- = f 1 ( H ) = 0.067 + 0.01977 ------------------------- for H < 7.4
2
H1
1.4 2
= 0.067 + 0.022 1 ------------- for H 7.4

H 6
2C D
Re ---------- = f 2 ( H ) = 0.207 + 0.00205 ( 4 H ) 5.5 for H < 4
H
( 4 H )2
= 0.207 0.003 ----------------------------------------2- for H 4
1 + 0.02 ( H 4 )
Note : The correlation between H* and H indicates that H* can never be lower than 1.515
which occurs for H = 4. Equation (9), however, does not guarantee that dH*/dx = 0 at this
point. Now H = 4 is obtained very seldom, but still there are cases where the solution
suddenly ceases to exist because (9) indicates dH*/dx * = 0 close to H =4. In this case we
force transition to be able to continue the calculation downstream.
Practical equations
The equations are written in terms of H and = Re 2 . Multiplying equation (7) by Re
and arranging the derivative to make d 2 dx appear gives :
V ( x ) d
------------ ------- + ( 2 + H )W ( x ) = f 1 ( H )
2 dx
And multiplying equation (9) by Re H , and expanding the derivative to make dH dx
appear results in :
dH
V ( x )g ( H ) ------- + ( 1 H )W ( x ) = f 3 ( H ),
dx
where V = U e, W = dU e dx, g ( H ) = d ( ln H ) dH , and f 3 ( H ) = f 2 ( H ) f 1 ( H ).
28

1.4- Boundary Layer Model

Initial values at the stagnation point


They are chosen such that d dx and dH dx are equal to zero. This choice avoids any
initial transient and allows large steps to be taken from x=0. H(0) and ( 0 ) are computed
from :

And :

f 3(H)
1H
- , with the root H 0 2.24
------------- = ------------f 1(H)
2+H
f 1 ( H0 )
0 = ---------------------------------W ( 0 ) ( 2 + H0 )

Implicit scheme
We apply a backward Euler with slight modification to avoid implicit iterations. In the step
from x n to x n + 1, f 1 and f 3 are linearized around H n and g is taken as g n. This results in a
system of two bilinear equations in H = H n + 1 and = n + 1 which can be solved exactly.
Vn + 1
n+1
V
------------+ 2W n + 1 + W n + 1 H f' 1n H ------------- n f 1n + f' 1n H n = 0
2x

2x
gV n + 1
gH n V n + 1
W
----------------------- + ---------------- W n + 1 H f' 3n H f 3n + f' 3n H n = 0
n+1

x
x
This procedure is used until transition is predicted or until the trailing edge point is reached.

1.4.2- Locating Transition


Transition from laminar to turbulent flow is a result of the growth of disturbances which
make the laminar boundary layer unstable. Accurate prediction of the transition region is a
crucial point in obtaining a good drag estimate since it separates the laminar flow region,
where the skin-friction drag is low, from the turbulent flow region, where the skin friction
drag increases dramatically.
Michels criterion
This criterion is based on the idea that transition starts at a specific Reynolds number based
on the distance x from the start of the boundary layer. The value of the transition Reynolds
number depends on many factors, the most important being the pressure gradient imposed on
the boundary layer by the inviscid flow and the surface roughness.
For incompressible flows without heat transfer, Michel [15] examined a variety of data and
concluded that, for airfoil-type applications, transition should be expected when :
22.4
Re > Re max = 1.174 1 + ---------- ( Re x ) 0.46 ,

Re x
where : Re = ReU e and : Re x = ReU e x .
29

1- The Aerodynamic Solver

This formula does account for the effect of the pressure gradient, because the momentum
thickness grows more rapidly in a positive pressure gradient. However, it does not include
the effect of surface roughness, but being based on data taken on airfoils, it should be good
for wing analysis.
Implementation of this criterion reveals that for cases where the external flow velocity is not
monotone past the suction peak, the function Re R e max is not monotone either, and can
therefore have several zeros. Since transition is predicted as soon as the function vanishes,
this can result in a discontinuity in the solution with respect to the design parameters, as
illustrated on the following example.
We consider a 12% thick airfoil with 4% maximum camber. For a slight modification of the
maximum camber location from 71 to 72%, the active root of the criterion changes.

Transition therefore moves suddenly forward by approximately 17%, and a jump in the drag
results is obtained. Transition then keeps moving forward, which explains the increase of the
drag.

This behavior is suspect with respect to reality. It is moreover problematic for the present
work, because it makes the drag solution discontinuous and non differentiable. Another
transition criterion is thus considered.
30

1.4- Boundary Layer Model

ISES e9-type method


ISES uses a spatial amplification theory based on the Orr-Sommerfeld equation, also known
in the literature as the e 9 method. This equation governs the growth and decay of
infinitesimal wave-like disturbances in two or three dimensional shear layers. Since the
unstable growth of disturbances is known to be the precursor of free transition in boundary
layers, the calculation of the growth of such disturbances is a good basis for the prediction of
transition.
The procedure is to compute the maximum amplification ratio downstream and to assume
that transition occurs when the amplitude has grown by more than a factor of e 9 8100 .
This is a wholly empirical assumption. The exponent "9" actually can vary between 7 and 11
depending on quantities such as free stream turbulence, surface roughness, and background
noise level as discussed in Cebeci and Bradshaw [4].
Using the Falker-Skan profile family, the spatial amplification curve envelopes can be related
to the local boundary layer parameters. The procedure is described in [11]. The envelopes
are then approximated by straight lines, giving :
dn
n = ------------ ( H ) [ Re Re 0 ],
dRe

(10)

where n is the logarithm of the maximum amplification ratio. The slope dn dRe and the
critical Reynolds number Re 0 are expressed by the following empirical formulas :
dn
------------ = 0.01 { [ 2.4H 3.7 + 2.5 tanh ( 1.5H 4.65 ) ] 2 + 0.25 } 1 2
dRe
And :

1.415
20
3.295
log 10 ( Re 0 ) = ------------- 0.489 tanh ------------- 12.9 + ------------- + 0.44
H 1
H1
H 1

For simple cases such as symmetric airfoils at zero angle of attack and flat plates, Re is
uniquely related to the streamwise coordinate x, and equation (10) immediately gives the
amplitude ratio n as a unique function of x. Transition is assumed to occur where n ( x ) = 9 .
For more general cases, where the external flow velocity may not be monotone past the
suction peak, it is more physically realistic to use x as the spatial amplification coordinate
rather than Re . This is where the present transition criterion becomes better than Michels
formulation.
Using some basic properties of the Falkner-Skan profile family, the conversion from Re to
x is accomplished as follows by Drela [10] :
U e 2 1
dn dRe
dn 1 x dU e
dn

------ = ------------ ------------ = ------------ --- ------ --------- + 1 ---------------- -- x


dRe dx
dRe 2 U e dx
dx

31

1- The Aerodynamic Solver

Using the empirical relations :

And :

U e 2
---------------- = p ( H ) = ( 6.54H 14.07 ) H 2
x
( H 4 )2
1
x dU
------ ---------e = m ( H ) = 0.058 -------------------- 0.068 -----------

H1
p(H)
U e dx

The spatial amplification rate is expressed as a function of H and :


dn
dn
1
m(H) + 1
------ ( H, ) = ------------ ( H ) -----------------------p ( H ) --dx
dRe
2

And this amplification rate is then integrated downstream from the instability point x cr ,
where Re = Re 0 :
x

dn

- dx
----dx

n ( x ) =

x cr

Again transition is assumed to occur when n ( x ) = 9 .


Using this criterion, there is no longer a discontinuity in the solution.
Implementation
Transition to turbulence is not an instantaneous process. Rather, over a certain length of the
airfoil, the flow is intermittently laminar and turbulent. Since no method exists for describing
this transition process, we have to adopt the fiction of a transition point. After using a
laminar boundary layer model up to the transition point, one switches to a different method
for the turbulent part.
For an accurate and reliable solution, it is essential that no discontinuities are admitted as the
transition point moves across a grid point. The transition is first located in an interval (i, i+1),
such that Re ( x i ) < Re max ( x i ) and Re ( x i + 1 ) > Re max ( x i + 1 ) for Michels criterion, or
n ( x i ) < 9 and n ( x i + 1 ) > 9 for the e9-type criterion.
This interval is then treated as two subintervals as shown in the following figure.
Laminar step

Turbulent step
x

x tr

i+1

x tr is the exact point where Re ( x ) = Re max ( x ) , or n ( x ) = 9 . It is found as the root of a


linear interpolation of Re ( x ) R e max ( x ) , or n ( x ) 9 , on the interval.
32

1.4- Boundary Layer Model

1.4.3- The Turbulent Boundary Layer


For a large enough Reynolds number, the boundary layer can become turbulent i.e.
experience an unsteadiness due to an unstable response to small disturbances. This
unsteadiness is due to weak viscosity which is unsufficient to damp out disturbances that
naturally appear and results in a random unstable flow. In such a case, there is little hope of
following the fluid motion in detail. It is necessary and, for practical purposes, sufficient to
use some form of average description for the flow.
For this we define the time-average of any flow quantity by :
1 to + T
a ( x, y, t ) dt
a ( x, y ) = lim ---
T T to
and label the fluctuating part of a ( a a ) with the symbol a, so :
a ( x, y, t ) = a ( x, y ) + a' ( x, y, t )
Theoretical equation of the flow
By time-averaging and comparing the order of magnitude of the terms of the steady
incompressible Navier-Stokes equations, the following turbulent boundary layer equations
can be derived :
u v
----- + ----- = 0
x y
u
u
p u
u ----- + v ----- = ----- + ----- u'v'
x

y
x y y
p
v
----- =
----- v' 2

y
y y

(11)
(12)
(13)

Note : x and y are not Cartesian coordinates : x is measured along the airfoils surface with
x=0 locating the transition point, and y is measured normally to the surface.
Calculation details can be found in [6]. The approximations that lead to the equations above
are the same as in the laminar case, the difference here is that the neglected terms are less
negligible in this case.
Von Karman momentum integral equation
The Von Karman integral equation can also be derived from the turbulent equations. The
differences with respect to the laminar case are :
The inclusion in equation (12) of a term u'v' , called Reynolds stress. Fortunately this
term vanishes at the airfoils surface because of the no-slip condition.
The term p y is non zero in equation (13). However the boundary layer is so thin that
we can assume that the pressure is constant in the y direction,
The integral quantities , , H and C f are now expressed with time-averaged velocities.
33

1- The Aerodynamic Solver

Heads model
Heads model is described in detail in [2]. It is a typical integral method, wherein some
analytical procedures have been carried out before the numerical problem is posed. It is a
reasonably accurate and especially fast method.
The model uses the Von Karman equation and, as in the laminar case, some semi-empirical
relations to close the system. The method has been derived as follows.
We consider the volume rate of flow within the boundary layer at x :
Q(x) =

(x)

u dy,

where ( x ) is the boundary layer thickness. Combining this with the definition of the
displacement thickness, we find :
Q
= -----Ue
We introduce the entrainment velocity :
E =

dQ
d
=
U ( )
dx
dx e

Which we write :
E =
With :

d
( U H )
dx e 1


H 1 = -------------

Head assumed that the dimensionless entrainment velocity E U e depends only on H 1 and
that H 1 , in turn, is a function of H. Cebeci and Bradshaw [4] fit several sets of experimental
data to the following formulas :
1 d
------ ( U H ) = 0.0306 ( H 1 3 ) 0.6169
Ue d x e 1
And :

(14)

H 1 = k ( H ) = 3.3 + 0.8234 ( H 1.1 ) 1.287 for H 1.6


= 3.3 + 1.5501 ( H 0.6778 ) 3.064 for H > 1.6

The fourth equation used to solve for the unknowns , H, H 1 and C f is the Ludwieg-Tillman
skin friction law :
C f = 0.246 ( 10 0.678H ) Re 0.268
34

1.4- Boundary Layer Model

Explicit scheme
To integrate the Head equations, a 2nd order Runge Kutta method is used.
We have :

dU e 1

d
= ------ ( 2 + H ) --------- + --- C f
Ue
dx 2
dx
dH 1
0.0306
1 dU e 1 d
---------- = H 1 ------ --------- + --- + ---------------- ( H 1 3 ) 0.6169
U e dx d x

dx

Which we write :

dY
= f ( Y, x ) with : Y = H
1
ds

The initial values at the beginning of the turbulent boundary layer are given by the value at
the end of the laminar run.
The procedure follows :
f 1 = f ( Y i, x i ), then Y = Yi + ( x i + 1 x i )f 1
f 2 = f ( Y, x i + 1 )
f1 + f2
Yi + 1 = Yi + ( x i + 1 x i ) -----------------
2
The procedure is used until one of these two things happen :
The trailing edge point is reached,
Turbulent separation takes place.
Turbulent separation
The turbulent boundary layer equations can not always be solved because of the closure
relation H 1 = k ( H ), which is not defined for all values of H and H 1. It is obvious on the
following graph of the function.

35

1- The Aerodynamic Solver

H 1 can not be computed for H < 1.1, and H can not be computed for H 1 < 3.3 , so that tests
have to be included in the Runge-Kutta procedure.
Turbulent separation really corresponds to the case when H 1 approaches 3.3, and H increases
rapidly. A typical value for H at separation often presented in the literature (see for instance
[7] and [9]) is H = 2.4. This can be used as a separation criterion, since H increases very
rapidly close to separation anyway. In our case, we use the criterion H 1 = 3.3.

1.4.4- Computation of the Drag Coefficient


The Squire-Young formula [8] provides a means of predicting the profile drag by relating the
momentum defect far downstream to the values of the flow field given at the trailing edge.
Given the dimensionless momentum thickness , shape factor H and dimensionless velocity
U e at the trailing edge on the upper and lower sides, the drag is found from :

Cd =

H TE + 5
------------------2 TE ( U e ) TE 2

+
UP

H TE + 5
------------------2 TE ( U e ) TE 2

LOW

This formula gives directly the total profile drag (i.e. the sum of pressure drag and friction
drag) as a function of the values of Ue, , and H at the trailing edge, computed from both
sides of the airfoil. It is thus particularly well suited for one-way coupled methods, in which
the computation of the pressure drag is not possible because the inviscid flow is not
influenced by the effect of the boundary layer.

1.4.5- Special Characteristics


The effect of the boundary layer on the inviscid flow is especially important near the trailing
edge, where it reduces the adverse pressure gradient. This can be seen on the following
figure, which presents results obtained using Xfoil (the solid line is the viscous Cp distribution, the dashed line is the inviscid solution).

36

1.4- Boundary Layer Model

In our case, the external velocity is not modified by the presence of the boundary layer, and
we have to deal with an unrealistic very high adverse gradient at the trailing edge.
The problem is that it makes the boundary layer separate very easily in the last percents of
the chord length : even on a NACA 0012 at zero angle of attack with a Reynolds number of
1e6, turbulent separation takes place. The drag coefficient can not be computed in such a
case because the computation of the turbulent boundary layer can not be carried on after
separation.
The solution to this problem consists in not solving the boundary layer up to the trailing
edge, but up to C off % of the chord length. Separation of the boundary layer which was
happening in the last percents of the chord is thus avoided, and the Squire-Young formula
still gives good results, since it is based on a loss of momentum.
The exact value of C off is chosen so that a large variety of airfoils can be analysed without
any turbulent separation. It should not be too small though, because then a big part of the
information would be lost. The following test cases illustrate the situation.

NACA 0012 at
NACA 9412 at
NACA 4412 at
NACA 4812 at
NACA 6812 at

=
=
=
=
=

0 and Re = 1e6 : turbulent separation at 100% on both sides,


0 and Re = 1e6 : turbulent separation at 98.54% on the upper side,
5 and Re = 1e6 : turbulent separation at 98.98% on the upper side,
5 and Re = 1e6 : turbulent separation at 98.11% on the upper side,
0 and Re = 1e6 : turbulent separation at 97.85% on the upper side.

It appears that a reasonable value of C off is 98%. This means that we do not consider the
boundary layer on the last 2% of the chord length, and that the Squire-Young formula is
applied not at the trailing edge, but at 98% of the chord on the upper and lower surfaces.

1.4.6- Validation of the Boundary Layer Model


First, the accuracy of the solver is tested. The drag coefficient of a NACA 4412 airfoil at zero
angle of attack and Re=1e6 is computed with 50, 100, 200, 400 and 800 grid points for the
boundary layers.

The result is a clear convergence, as can be seen on this figure.


37

1- The Aerodynamic Solver

Then, the results are compared to results provided by Xfoil. The drag coefficient computed
by the two programs are compared in several test cases. Each test case shows the sensitivity
of the results with respect to the angle of attack and to the shape parameters.

We have to recall the differences between Xfoil and PMBL :


The turbulent flow models are different. Xfoils can handle thin separated flow regions,
while Heads model cannot.
The couplings between the boundary layer and the inviscid flow are different. In Xfoil, it
is performed in two ways, while in PMBL, only one-way coupling is modelled.
The drag coefficient computation is different. In Xfoil the drag estimate includes the
integration of the pressure distribution and of the boundary layer friction, while PMBL
uses the Squire-Young formula.
The graphs show that the drag coefficient computed by PMBL is higher than Xfoils
solution. This might be a characteristic of one-way coupled methods, since results computed
with Panda behave the same. However, the sensitivity of the results with respect to the design
parameters is well reproduced, which makes PMBL an appropriate solver for optimization.
The main difference is seen on the graph of the solution as a function of the maximum
camber location, where the position of the minimum is not the same.
38

2- Automatic Differentiation
Automatic differentiation (AD) is a technique for augmenting computer programs with the
computation of derivatives based on the chain rule of differential calculus. In this section,
the method is presented. Then ADMAT, a toolbox for automatic differentiation of Matlab
functions, is introduced and used to produce the derivatives of the aerodynamic coefficients.

2.1- Introduction
The methods employed for the solution of many scientific computing problems require the
evaluation of derivatives of some functions. Probably best known are gradient methods for
optimization, Newtons method for the solution of non-linear problems, and the numerical
solution of stiff differential equations.
In the context of optimization for instance, given a function f : R n R , one can find a
minimizer x of f using variable metric methods that involve the iteration :
while not converged do
Solve B i s i = f ( x i )
xi + 1 = xi + i si
end do
For suitable step multipliers i > 0 . f ( x ) is the gradient of f at a particular point x, and B i
is a positive definite approximation to the Hessian of f.
In many cases, the function f is not represented in closed form, but in the form of a computer
program. For purpose of illustration, we assume that f : x R n y R and that we wish to
compute the derivatives of y with respect to x. We call x the input variable, and y the output
variable. There are four approaches to computing derivatives.
By Hand : One can differentiate the code by hand and thus arrive at a code that also
computes derivatives. However, handcoding of derivatives for a large code is a difficult and
error-prone process, especially as the problem complexity increases. It is liable to be a
considerable amount of work in comparison with the development of the original code,
although it is likely to result in the most efficient code.
Finite Differences : The derivative of f with respect to the ith component of x at a particular
point x o is approximated by either :
One-Sided Differences :

f ( x0 h ei ) f ( x0 )

f ( x 0 ) ------------------------------------------------h
xi

or Central Differences :

f ( x0 + h ei ) f ( x0 h ei )

f ( x 0 ) ----------------------------------------------------------------2h
xi

where e i is the ith cartesian basis vector.

39

2- Automatic Differentiation

Computing derivatives by divided differences has the advantage that we need only the
function as a "black box". The main drawback is that their accuracy is hard to assess. A small
step size h is needed to minimize the truncation error resulting from the omission of higher order terms for properly approximating derivatives, yet may lead to numerical cancellation
and the loss of many digits of accuracy. In addition, different scales of the x is may require
different step sizes for the various independent variables.
Symbolic Differentiation : This functionality is provided by symbolic packages such as
Maple or Mathematica. Given a string describing the definition of a function, symbolic
manipulation packages provide exact derivatives, expressing the derivatives in terms of the
intermediate variables. Symbolic differentiation is a powerful technique, but it may not
derive good computational recipes, and it may run into resource limitation when the function
description is complicated. Moreover, functions involving branches or loops cannot be
readily handled by symbolic differentiation.
Automatic Differentiation (AD) : AD techniques rely on the fact that every function, no
matter how complicated, is executed on a computer as a (potentially very long) sequence of
operations such as additions, multiplications, and elementary functions such as sin and cos,
for which the derivative can be easily computed. Then, by applying the chain rule :

f (g(x))
x

x = x0

= f (s)
s

s = g ( x0

g(x)
x
)

x = x0

over and over again to the composition of those elementary operations, one can compute
derivatives of f exactly, and in a completely mechanical fashion. By applying the chain rule
step by step to the elementary operations executed in the course of computing the function,
AD computes exact derivatives (up to machine precision, of course), and avoids the potential
pitfalls of divided differences. The technique of automatic differentiation is directly
applicable to functions with branches and loops. We also note that, unlike handcoding or
symbolic assisted approaches, automatic differentiation enables derivatives to be updated
easily when the original code changes.

2.2- Method Fundamentals


We consider the case of a function f : R n R , of n variables x 1, , x n which we will call
input variables. The case of a function with several results f : R n R m will be treated as an
extension of this case.
The function is represented by a computer program, which for the input of x = ( x 1, , x n )
returns y = f(x). We want to generate a program which will also return the value of f ( x ) ,
i.e. all the first order partial derivatives f x 1 ( x ), , f x n ( x ).
Original program
We start by considering the general form of a program to compute f ( x 1, , x n ) , using N
intermediate variables x n + 1, , x N.

40

2.2- Method Fundamentals

The simplest thing is to consider that at each statement, a new intermediate variable is
introduced, and that its value is computed using the previously introduced variables. In this
context, the program can be written :
For i = n+1 to N, do

x i = i ( x 1, , x i 1 )

f = xN

The program is manipulating N variables (n input variables, and N-n intermediate variables),
and uses N-n statements.
Usually, the intermediate functions i do not depend on all the previously computed
variables : there is a set P i { 1, 2, , i 1 } such that x i = i ( x Pi ), where
x Pi = { x j, j P i }. With these new notations, we can write the program like :
For i = n+1 to N, do x i = i ( x Pi )
f = xN

This model is not general enough because some programs may have intermediate variables
that are redefined several times, which is impossible here. Since the explanation become
more complex if we want to account for this case, and since a program which such
redefinition of variables can easily be turned into a program without any, we consider the
program above as general enough for our point.
The intermediate functions
An intermediate function can be anything, from elementary functions (+, -, *, /, sin, cos, ...)
to some higher-level functions such as the multiplication of two matrices, or the resolution of
a linear system of equations. It can actually be any sub-program y = f(x).
So, the choice of the intermediate functions is open, and depends on the implementation. We
will return to this issue in the section dealing with the Matlab AD tool ADMAT.
Forward mode
This technique is easy to understand as well as to program on a computer. The method
computes derivatives alongside the evaluation of the function itself, and propagates the
derivatives using the chain rule. So when the function evaluation has completed, the
derivatives of the results have also been calculated.
We denote by x i, i = 1, ..., N the gradient of x i with respect to the input variables. We have
of course x i = e i for i = 1, ..., n where e i is the ith cartesian basis vector.
For i = n+1, ..., N, the definition of x i and the chain rule give :
x i =

i
-------- x j
x j
jP

The forward mode consists in performing this kind of computation for each statement of the
original code.
41

2- Automatic Differentiation

Applying this to our programs leads to :


For i = 1 to n, do x i = e i
For i = n+1 to N, do {

xi = i ( xP )
i

x i =
f = x N
f = xN

j Pi

i
-------- x j }
x j

This program evaluates both functions and gradients simultaneously, each assignment to an
intermediate quantity being simply augmented by the calculation of its gradient. Therefore,
the forward mode increases the number of operations by a factor proportional to n (number
of input variables).
Reverse mode
This technique is based on a not as obvious way of using the chain rule. The first step of the
method is to evaluate the function itself while storing information about intermediate values.
When the evaluation is done, the derivatives are calculated by traversing the recording in
reverse order, propagating derivatives of the result with respect to the intermediate variables
down to the initial values. Because of the recording and the reverse propagation, this method
is also the most difficult to program on a computer.
We associate with each intermediate variable x i , the derivative :
xi =

f
xi

By definition, we have x N = 1, and f = ( x i ) i = 1, , n .


As a consequence of the chain rule applied to an elementary statement of our program
x i = i ( x Pi ), these adjoint quantities satisfy the relation :
f
------- =
x j

Or : x j =

i Qj

i Qj

i f
-------- ------- ,
x j x i

i
-------- x i , where Q j = { i N ; j P i }
x j

Thus, we can see that x j can be computed once all x i with i > j are known. In terms of the
program structure, it is slightly more convenient to increment all x j with j P i for a known
i by the appropriate contribution x i i x j .

42

2.2- Method Fundamentals

This mathematically equivalent looping leads to the following extended program :


Forward step :
For i = n+1 to N, do x i = i ( x Pi )
f = xN

Reverse step :
For i = 1 to N-1, do x i = 0
xN = 0

For i = N down to n+1, do x j = x j + i x j x i for all j P i


For i = 1 to n, do f = x i
xi

This program evaluates the function in the first step, and computes all the adjoints including
the components of the gradient in the second step. In this case, the increase in the number of
operations is independent of n, and an estimation of an upper bound of 5 for the increase in
work can be found in [16].
Extension to f : R n R m
We consider the function given by the following program :
For i = n+1 to N, do x i = i ( x Pi )
f
x
1
Nm+1
f = =

xN
fm

where the m results are the m last variables of the program. We are looking for the Jacobian
matrix J, which (i,j) term is :
f
J ij = -------i .
x j
Using the forward mode, the application is straight-forward. Row i of J is nothing but the
gradient of component i of f, f i = x N m + i . We have the same relative computation cost
as in the scalar case, the increase in the number of operations is n.
Using the reverse mode, we have exactly the same algorithm as in the scalar value function
case. The difference is that the adjoint associated with each intermediate variable is now a
vector with m components. Component p of this vector is the derivative of the elementary
variable with respect to results p, p = 1, ..., m. Therefore, the reverse mode increases the
number of operations by a factor proportional to m.

43

2- Automatic Differentiation

2.3- Computer Implementation


AD can be seen as a particular semantic transformation problem : given a code for
computing a function, we would like to generate a code that computes the derivatives of that
function. To affect this transformation, two approaches can be employed.
Operator Overloading : Modern computer languages like C++ or Fortran 90, and Matlab
(version 5.0 and above), make it possible to redefine the meaning of elementary operators.
That is, we can for example define a type for floating point numbers that have gradient
objects associated with them (lets call them adouble, say), and for each elementary
operation such as multiplication, we can define the meaning of the operator * for variables
of type adouble. If we define the usual product rule ( z = xy z = xy + yx ), then
each occurence of a multiplication of two variables of type adouble in the code will also
effect the update of the associated derivatives in a transparent fashion.
Tools using this implementation include ADOL-C for algorithms written in C/C++, and
ADMAT for algorithms written in Matlab.
Source transformation : Another way is to rewrite the code explicitly. This is what we have
done to explain how AD works in the previous section. For example, the assignment z = xy is
rewritten into a piece of code that not only contains the computation of z, but also an
implementation of the derivative z = xy + yx.
Tools using this implementation include ADIFOR for algorithms written in Fortran.
For more information, refer to [17]. Check also a collection of AD tools which includes
ADOL-C and ADIFOR, presented at :
http://www-unix.mcs.anl.gov/autodiff/AD_Tools/index.html

2.4- ADMAT, Automatic Differentiation Toolbox for Matlab


ADMAT computes gradients, Jacobian matrices and Hessian matrices of nonlinear maps
defined via M-files. This is the first ever AD tool written for differentiating M-files. It
belongs to the operator overloading class of AD tools, and uses the Object Oriented
Programming feature present in MATLAB 5 for implementation. A direct consequence of
this being that ADMAT can be used only with MATLAB version 5 or above.
Implementation of derivative classes
ADMAT is designed as a three-layer toolbox with the top layers inheriting from the bottom
layers. The core of the toolbox is the class deriv, which is the basic forward mode computing
engine. The layer above deriv contains the class derivtape, the basic reverse mode computing
engine, and the topmost layer is concerned with the computation of second order derivatives
and consists of the class derivtapeH for computing the Hessian of a function.

44

2.4- ADMAT, Automatic Differentiation Toolbox for MATLAB

Implementation of the forward mode : class deriv


deriv is an extension of double (Matlab floating point numbers belong to class double). A
deriv object has two fields, val and deriv, which stand for the value of the variable and its
derivative. In the AD mode, the function computation is carried out with deriv variables,
causing all the operations to be used in the overloaded mode, thus invoking the rules which
update the derivative of the output along with the value.
The constructor is used as follows : y = deriv(x,V). It constructs a deriv object y with the
given derivative V. Here is a simplified version of the code for the constructor (the
simplification consists in not reporting all tests on the dimensions of s1, s2 and sout and
consequent branches) :
function s = deriv(a,V)
s.val = a;
if nargin == 1
s.deriv = zeros(size(a));
else
s.deriv = V;
end;
s = class(s,deriv);

To illustrate how the operators are modified, we present the simplified functions for addition,
cosinus, and exponential of a deriv class variable.
function sout=plus(s1,s2)
sout.val=s1.val+s2.val;
if ~isa(s1,deriv)
sout.deriv=s2.deriv;
elseif ~isa(s2,deriv)
sout.deriv=s1.deriv;
else
sout.deriv=s1.deriv+s2.deriv;
end;
sout=class(sout,deriv);

function sout=cos(s1)
sout.val=cos(s1.val);
sout.deriv=-sin(s1.val).*s1.deriv;
sout=class(sout,deriv);
function sout=exp(s1)
sout.val=exp(s1.val);
sout.deriv=sout.val*s1.deriv;
sout=class(sout,deriv);

The following example illustrates the way to use the deriv class to compute the Jacobian of a
Matlab function y = fun(x). The steps are :

Define the input point : x = ones(N,1);


Initialise the Jacobian of x : xdot = eye(N);
Make x belong to the deriv class : x = deriv(x,xdot);
Compute the function (as well as the derivatives via overloading) : y = fun(x);
Get the value of the function : val = y.val;
Get the value of the Jacobian : J = y.deriv;

Implementation of the reverse mode : class derivtape and function parsetape


To implement the reverse mode, ADMAT uses a tape, which records all the intermediate
values and operations performed in the function evaluation. Computation of adjoints is then
done in a reverse pass on the tape, and at the end of the pass the adjoints of the input
variables are picked up from the front of the tape.

45

2- Automatic Differentiation

The tape is generated by the methods of class derivtape. derivtape objects have two fields,
val which contains the value of the variable and counter, a unique counter which serves as an
index to the tape. Every Matlab operation is overloaded to update the value, and record the
operation onto the tape.
Here is the constructor of class derivtape :
function s= derivtape(a)
global tape;
global varcounter;
s.val=a;
s.varcount=varcounter;
s=class(s,derivtape);

To illustrate how the operators are modified, we present the functions for the addition,
cosinus, and exponential of a derivtape class variable.
function sout=plus(s1,s2)
global varcounter
if (~isa(s2,derivtape))
sout.val=s1.val+s2;
sout.varcount=varcounter;
sout=class(sout,derivtape);
savetape(plus,sout,s1.varcount);
elseif (~isa(s1,derivtape))
sout.val=s1+s2.val;
sout.varcount=varcounter;
sout=class(sout,derivtape);
savetape(plus,sout,s2.varcount);
else
sout.val=s1.val+s2.val;
sout.varcount=varcounter;
sout=class(sout,derivtape);
savetape(plus,sout,s1.varcount,s2.varcount);
end

function sout=cos(s1)
global varcounter;
sout.val=cos(s1.val);
sout.varcount=varcounter;
sout=class(sout,derivtape);
savetape(cos,sout,s1.varcount);
function sout=tan(s1)
global varcounter;
sout.val=exp(s1.val);
sout.varcount=varcounter;
sout=class(sout,derivtape);
savetape(exp,sout,s1.varcount);

In these programs, function savetape is used to record the operator, the value of the function,
and the index of the operands of the elementary operation in the object tape(varcounter).
Then the computation of the adjoints is performed by function parsetape. This function
processes the tape backwards, and, at each step, invokes a function to compute the adjoint
corresponding to the operator involved.
To illustrate how the adjoints of the operators are computed and propagated, we present the
simplified functions for the addition, cosinus, and exponential.
function adjplus(i)
global tape
if (tape(i).arg2vc > 0)
tape(tape(i).arg1vc).W=tape(tape(i).arg1vc).W+tape(i).W;
tape(tape(i).arg2vc).W=tape(tape(i).arg2vc).W+tape(i).W;
else
tape(tape(i).arg1vc).W=tape(tape(i).arg1vc).W+tape(i).W;
end

46

2.4- ADMAT, Automatic Differentiation Toolbox for MATLAB

function adjcos(i)
global tape
tape(tape(i).arg1vc).W=tape(tape(i).arg1vc).W-sin(tape(tape(i).arg1vc).val).*tape(i).W;
function adjexp(i)
global tape
tape(tape(i).arg1vc).W=tape(tape(i).arg1vc).W+exp(tape(tape(i).arg1vc).val).*tape(i).W;

The following example illustrates the way to use the derivtape class and the parsetape
function to compute the Jacobian of a Matlab scalar value function y = fun(x). The steps are :

Define the input point : x = ones(N,1);


Make x belong to the derivtape class : x = derivtape(x);
Compute the function (taping every intermediate via overloading) : y = fun(x);
Initialize the adjoint matrix : W = 1;
Parse and process the tape backwards to compute the adjoints : parsetape(W);
Grab the Jacobian as the transpose of the front end of the tape : J = transp(tape(1).W);

Computation of the Hessian : class derivtapeH and function parsetape


Computing the Hessian matrix of f(x) combines the forward and reverse modes. We first compute
w = ( f ) T using the forward mode, and then ( dw dt ) T by reverse mode, since w has
fewer number of variables than x.
Then :

d ( f ) T T
2 f = ------------------
dx

Thus the derivtapeH object has the two same fields as the deriv class, val and deriv, except
that they are themselves instances of the derivtape class. This way the value of the function
as well as its gradient are computed and recorded on the tape. Here is the simplified version
of the constructor of class derivtapeH :
function s= derivtapeH(a,V)
a = derivtape(a);
s.val=a;
s.deriv=derivtape(V);
s=class(s,derivtapeH);

The operators on derivtapeH variables are the same as those of class deriv, they compute and
propagate the forward mode derivative of the results.
The following example illustrates the way to use the derivtapeH class and the parsetape
function to compute the Hessian of a Matlab scalar value function y = fun(x). The steps are :

Define the input point : x = ones(N,1);


Initialise the Jacobian of x : xdot = eye(N);
Make x belong to the derivtapeH class : x = derivtape(x, xdot);
Forward mode : compute the function and the derivatives and create the tape : y = fun(x);
Initialize the adjoint matrix : W = eye(N);
Reverse mode : parse and process the tape backwards : parsetape(W);
Grab the Hessian as the front end of the tape : H = tape(1).W;
47

2- Automatic Differentiation

Elementary operations
All arithmetic operations, as well as the comparison and assignment operators, are
overloaded so that any or all of their operands can be an active variable. This means around
120 functions.
Matlab features some high-level operators, such as matrix matrix product, or the solution of
a linear system of equation. Thinking about AD in terms of high-level matrix vector
operations as opposed to the scalar level operations has a lot of advantages, for example it
saves the storage of the intermediate variables in the reverse mode, where you only have to
save the high level vectors instead. A lot of discussion on this subject, and more details on
high-level differentiation can be found in the work by Coleman and Verma, see [18].
In the following table, we present a listing of how some of the matrix-vector operations are
handled using the forward and reverse mode.
Operation

Gradient

Adjoints

z = xTy

z = y T x + x T y

x = yz , y = xz

z = x+y

z = x + y

x = z , y = z

z = x *y

z = x *y + x *y

x = diag ( y ) z , y = diag ( x ) z

y = Ax

y = Ax + Ax

x = A T y , A = yx T

y = A\x

y = A\ ( x Ay )

x = A T \y , A = ( A T \y )y T

2.5- Application of ADMAT to the Aerodynamic Solver


The Matlab automatic differentiation toolbox is used to compute the gradient of the lift,
moment and drag coefficients. The three quantities are computed by one Matlab program
which is introduced. The accuracy and running time of the computation of the derivatives are
then tested on several cases.
Note : The application of ADMAT to the aerodynamic solver has not been straight-forward,
because the toolbox was not bug-free. The correction of around 30 bugs has made the
differentiation of the solver possible.

2.5.1- Aerodynamic Solver Program


The input variables are the shape parameters (i.e. the 4 digits, with the same scaling as in the
NACA notation), and the angle of attack. The computations are performed at a constant
Reynolds number equal to 1e6. The number of panels for the inviscid flow solution and the
number of grid points in the boundary layer are also specified, but as constant parameters.
The solution for a NACA 4512 at 3 degrees angle of attack using 100 panels and 200 grid
points for the boundary layer is thus computed by invoking : solver([4;5;12;3],[100;200]);
48

2.5- Application of ADMAT to the Aerodynamic Solver

The program procedure is shown on the following figure :


Shape Parameters

Angle of Attack

Airfoil Shape

Inviscid Flow
Velocity

Boundary Layer

Pressure Distribution

Squire Young Formula

C L and C m

Cd

2.5.2- Accuracy
The analytic derivatives computed by automatic differentiation are compared to central finite
differences derivatives with a step size h = 1e-4. The test case is a NACA 4412 at = 0
with 100 panels and 200 grid points for the boundary layer.
We have three results, Cl, Cm and Cd, which are noted f 1 , f 2 and f 3 respectively, and four
parameters, maximum camber, maximum camber location, maximum thickness, and angle
of attack, which are noted p 1, p 2, p 3 and p 4 respectively.
The derivatives are presented in a Jacobian matrix J, which (i,j) element is :
f
J ij = -------i
p j
The element-by-element ratio between the Jacobian computed by automatic differentiation
and the Jacobian computed by finite differences is :
1.00000000010672 1.00000000024421 0.99999998912999 0.99999999998496
1.00000000042880 1.00000000040818 0.99999995238333 1.00000000013184
1.00000000670311 1.00000026823053 1.00000000787586 1.00000632378303

This proves that automatic differentiation of the program has been well performed. It also
shows that computing the derivatives by central finite differences, thus considering the solver
program as a black box, gives a very good accuracy.

2.5.3- Running Time


The same test case is used to measure the time required to compute the derivatives by
automatic differentiation and finite differences. Since automatic differentiation compute both
the function and the derivatives at the same time, the time performance of AD will be
compared to the time it takes to compute the derivatives by finite differences and the
function.
49

2- Automatic Differentiation

Forward mode
The computation of the aerodynamic coefficients and their derivatives is performed on two
different problem sizes : 50 and 100 panels, and 100 and 200 grid points for the boundary
layer. The test case is still a NACA 4412 at = 0 .
The CPU times are the following :
time AD (s)

time FD (s) ratio AD/FD

50 and 100

24.46

3.79

6.45

100 and 200

47.35

7.77

6.15

Computing the derivatives of our function by AD is therefore approximately six times slower
than computing them by central finite differences.
In section 2.2, we saw that the forward mode increases the number of operations of the
function computation by a factor proportional to the number of input variables. For the (50
and 100) case, one function computation takes 0.42 s, and for the (100 and 200) case, 0.86 s.
An approximate value for the proportion factor in our case can thus be given : around 14.
Reverse mode
The reverse mode is extremely slow because recording all the elementary operations takes a
very long time. For our test case, with only 10 panels and 50 grid points for the boundary
layer, the size of the tape is 18060. The following table shows the CPU times for the
computation of the derivatives.
time AD (s)
739.67

time FD (s) ratio AD/FD


1.74

425

Since the size of the tape is a priori unknown, it is reallocated through the recording at each
new elementary operation. By allocating the tape at the beginning of the program, the time
required by AD goes down to 623.17 s, and 15% of time are saved.
For larger problems, 50 panels and 100 grid points for the boundary layer for instance, the
differentiation procedure results in a crash of the program.
The conclusion is that we are going to use the forward mode for the optimization.
Hessian
The computation of the Hessian has been tested on simple examples, but it does not work for
the aerodynamic solver. Because of time constraints, the problems within the derivtapeH
operators have not been fixed.
50

3- Airfoil Shape Optimization


The solver is used to perform airfoil design. Sample optimization problems are formulated,
and solved using the Matlab optimization toolbox [20].

3.1- Definition of the Optimization Problems


We consider the airfoil as a section of the main wing of a low speed aircraft. We have three
shape parameters : maximum camber, maximum camber location, and maximum thickness.
The flow angle of attack can also be considered a parameter since it is possible to design the
airplane so that the wing has a non zero incidence angle when the aircraft is in cruise
conditions.
We are interested in three results : lift, moment, and drag coefficients. They represent the
aerodynamic loads applied to the airfoil, the actual loads being given by :
1
L = C l --- U 2 S
2
1
D = C d --- U 2 S
2
1
M = C m --- U 2 Sc
2
where S is the airfoils planform area, and c is the airfoils chord length. Planform area is the
area of a projection of the airfoils shape onto a horizontal surface beneath it, similar to the
airfoils shadow when the sun is directly overhead.
Lift L

U
Drag D

Pitching Moment M

The lift must be large enough in order to allow the aircraft to fly by compensating its
weight,
The pitching moment of the main wing must not be too large, because for the equilibrium
of the aircraft, it must be compensated by the moment of a negative-lift tail.
The drag should be as low as possible, since it has no positive effect at all on the aircraft
performance.

51

3- Airfoil Shape Optimization

Two different design problems are derived depending on the flight conditions. During takeoff and landing, the crucial issue is to have a high lift coefficient, since the aircraft has to be
flying at very low speed. In this context, the optimization problem is formulated as :
max (Cl)
subject to bounds on Cm and Cd

(15)

On the other hand, during cruise conditions, the important issue is to minimize the drag of
the plane, in order to save fuel. A second optimization problem is thus formulated as :
min (Cd)
subject to bounds on Cl and Cm

(16)

The value of the bounds are derived by making a survey on the performances of a variety of
airfoils. For simplicity, the Reynolds number is taken to be equal to 1e6 in all cases.
For both problems, the maximum negative value of Cm is chosen to correspond to the
solution of the NACA 4812 airfoil at zero angle of attack : C m 0, 23 ,
For problem (15), the maximum value of Cd is chosen to correspond to the solution of the
NACA 0015 airfoil at zero angle of attack : C d 0, 0070 ,
And finally for problem (16), the minimum value of Cl is chosen to correspond to the
solution of the NACA 5412 airfoil at zero angle of attack : C l 0, 65 .
The solutions for the airfoils above are presented in the following figures.

52

3.2- Solving the Optimization Problems

For both optimization problems, we also have to add bounds on the parameters themselves,
so that the optimization is performed in a space of reasonable airfoils. We choose the
following minimum and maximum values :
0% Maximum camber 9%
20% Maximum camber location 80%
7% Maximum Thickness 20%
0 Angle of Attack 3
The solver uses the same scaling of the variables as the NACA 4 digits notation (see 1.2).

3.2- Solving the Optimization Problems


The Matlab Optimization Toolbox [20] is used. For non linear inequality constrained
problems like ours, it uses a Sequential Quadratic Programming algorithm with a BFGS
update of the Hessian matrix and a linesearch method. The quadratic subproblems are solved
with a modified projection method.
The exact Hessian information is not used, and thus the only analytic derivatives provided by
the solver are the gradients of Cl, Cm and Cd. They are computed using the forward mode of
automatic differentiation. In order to see the differences, all the optimization problems are
also solved with finite difference derivatives, with a constant step size h=0.0001.
Two different initial points are chosen for the optimization : the symmetric NACA 0016, and
the cambered NACA 4416, both considered at zero angle of attack. The initial points
solutions are presented on the two following figures.

Maximization of the lift coefficient at zero angle of attack


In this case, the angle of attack is not considered as a parameter. The problem is :
max (Cl)
subject to : C m 0, 23 and : C d 0, 0070 ,
without forgetting the bounds on the shape parameters.
53

3- Airfoil Shape Optimization

With NACA 0016 as initial point, we obtain the following convergence of Cl :

And starting from NACA 4416 :

All converge to the same optimizer. More iterations are used starting from NACA 4416,
because cases with turbulent separation, where the results are not accurate, are obtained
along the optimization process. In both cases, the use of AD derivatives provides a faster
convergence, which was expected theoretically.
The optimal airfoil shape and solution are shown on the following figure.

54

3.2- Solving the Optimization Problems

At the optimal solution, the constraints on the pitching moment and on the drag are both
active, which means that they are both useful. The large lift is obtained by strong camber,
located approximately at the middle of the chord. The thickness, which has a greater
negative effect on the drag than positive effect on the lift, is equal to its minimum value.
Observe that the pressure distribution is very smooth.
Maximization of the lift coefficient considering the angle of attack as a parameter
The point is to determine what happens when the angle of attack can be modified. In order to
avoid cases with separation of the turbulent boundary layer, which can not be handled by the
solver, the upper bound we use on is not very large (3 degrees).
Starting from NACA 0016 at =0, we obtain the following convergence of Cl :

And starting from NACA 4416 at =0 :

All converge to the same optimizer, and the use of analytic derivatives gives a faster
convergence.

55

3- Airfoil Shape Optimization

The optimal solution is presented on the following figure.

Compared with the previous case, when the angle of attack was kept constant and equal to
zero, the result here is a higher lift coefficient. The optimal airfoil has a little less camber, but
located at the same place, and it has the same thickness as in the previous case.
The angle of attack is equal to its maximum value, which gives a lot of lift, and the
consequent increase in drag is compensated by a smaller amount of camber. Observe that the
boundary layer is fully laminar on the lower side, which contributes to a low drag.
Minimization of the drag coefficient at zero angle of attack
First, we do not consider the angle of attack as a parameter. The problem is :
max (Cd)
subject to : C m 0, 23 and : C l 0, 65 ,
and bounds on the shape parameters.
With NACA 0016 as initial point, we obtain the following convergence of the objective
function Cd :

56

3.2- Solving the Optimization Problems

And starting from NACA 4416 :

Starting from NACA 0016, and using finite differences derivatives, we do not manage to
reach the same optimum as the three other cases.
We also note that with both initial points, convergence is slower with the use of analytic
derivatives. This can be explained by the fact that the variable is obviously crawling along
the boundary. It is possible that the lack of precision of the finite differences derivatives helps
in making the optimization procedure actually violating the constraint without realizing it,
and thus go faster to the optimum.
The optimal airfoil shape and solution are shown on the following figure.

The resulting shape is very different from the solution of the previous optimization problem.
The thickness is equal to its minimum value, which gives a low drag. The lift is obtained
thanks to a small amount of camber, located completely rearward. This rearward location of
the camber is also a factor of low drag ; remember the sensitivity curves seen in 1.4.6.
Observe that the constraint on the pitching moment is inactive this time.
57

3- Airfoil Shape Optimization

Mimimisation of the drag coefficient considering the angle of attack as a parameter


The angle of attack can now vary between 0 and 3 degrees.
Starting from NACA 0016 at =0, we obtain the following convergence of Cd :

And starting from NACA 4416 at =0 :

All four procedures converge to the same optimizer, and the use of AD derivatives gives a
faster convergence.

58

3.2- Solving the Optimization Problems

The optimal solution is presented on the following figure.

Compared with the previous case, when the angle of attack was kept constant and equal to
zero, the result here is a lower drag coefficient. The optimal airfoil has a little less camber,
but it is located at the same place, and it has the same thickness as in the previous case.
The angle of attack is equal to 0.65 degrees, which gives some more lift, so that less camber
can be used. This smaller amount of camber allows a reduction of the drag.
Stability of the optimal airfoils
The result of the maximization of the lift problem is very stable. A slight modification of the
optimal value of the design parameter gives a differentiable variation of the results.
On the other hand, it should be underlined that the airfoil which results from the
minimization of the drag problem is less stable. The suction peak present at the rear of the
chord is a factor of separation of the turbulent boundary layer, which gives a large increase of
the drag.

59

Conclusion
The three main parts of the project, development of an aerodynamic solver, computation of
analytic derivatives, and exercises of airfoil shape optimization have been presented in detail.
The resulting optimization tool has proven to be a useful airfoil design system, and could be
used to solve a real optimization problem. The principal conditions are that the airfoil shape
be defined analytically, and that the solution does not correspond to a case with separation of
the turbulent boundary layer.
An improvement to the solver method is possible, by modelling a full coupling between the
external flow and the boundary layer, as done in Xfoil. This was envisionned at one point,
but not realized because of time constraints.
Automatic differentiation has been performed on the aerodynamic solver using the forward
and the reverse mode. It has been demonstrated to provide accurate derivatives, but at a large
time cost. It would be interesting to test the computation of the Hessian by ADMAT.
Then an improvement of the optimization algorithm would be possible, by modifying the
Matlab optimization toolbox so that it uses the Hessian provided by automatic differentiation
instead of a BFGS update.

61

References
[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]
[10]
[11]
[12]
[13]
[14]
[15]
[16]

[17]

[18]
[19]
[20]

I.H. Abbott and A.E. Von Doenhoff : Theory of Wing Sections. Dover Publications Inc,
New York, 1959.
J. Katz and A. Plotkin : Low Speed Aerodynamics, From Wing Theory to Panel
Methods. Mac-Graw Hill, 1991.
B. Maskew, Program VSAERO Theory document. NASA CR 4023, Sept 1987.
T. Cebeci and P. Bradshaw, Momentum Transfer in Boundary Layers. Hemisphere
Publishing Corporation 1977.
W.C. Reynolds and T. Cebeci : Calculation of Turbulent Flows. In Turbulence, P.
Bradshaw, ed., Springer-Verlag, Topics in Applied Physics Series, Vol. 12, 1978.
J. Moran : An Introduction to Theoretical and Computational Aerodynamics. John
Wiley and sons, 1984.
W.H.Mason : Boundary Layer Analysis methods. Aerocal, 1981.
H. B. Squire and A. D. Young : The Calculation of the Profile Drag of Aerofoils. R. &
M. No1838. A.R.C. Technical report, London, 1938.
I. Kroo : PANDA - A Program for Analysis and Design of Airfoils. Desktop
Aeronautics, Stanford, 1988. Available on www.desktopaero.com.
M. Drela and M. B. Giles : Viscous-Inviscid Analysis of Transonic and Low Reynolds
Number Airfoils. AIAA Journal, 25 (10), Oct. 1987.
M. Drela : Two-Dimensional Transonic Aerodynamic Design and Analysis using the
Euler Equations. PhD Thesis. MIT, Gas Turbine Laboratory Rept. 187, Feb. 1986
M. Drela : Xfoil : An Analysis and Design System for Low Reynolds Number Airfoils.
Low Reynolds Number Aerodynamics, Springer-Verlag, Lec. Notes in Eng. 54, 1989.
H. Youngren and M. Drela : Viscous / Inviscid Method for Preliminary Design of
Transonic Cascades, MIT, Department of Aeronautics and Astronautics, 1991.
E.G.M Coenen : Computational Techniques for Viscous-Inviscid Boundary Layer
Interaction. KTH, Dept. of Aeronautics, Stockholm, 1996.
R. Michel : Etude de la Transition sur les Profiles dAiles, Onera Report 1/1578A,
1951.
A. Griewank : On Automatic Differentiation, In Mathematical Programming : Recents
Developments and Applications, M. Iri and K. Tanabe, eds., Kluwer Academic
Publishers, Dordrecht, 1991.
D. Juedes : A Taxonomy of Automatic Differentiation Tools, in Automatic
Differentiation of Algorithms : Theory, Implementations and Applications, A.
Griewank and G. F. Corliss, eds., SIAM, Philadelphia, Penn., 1991.
A. Verma, Structured Automatic Differentiation, PhD Thesis, Cornell University, 1998.
T. F. Coleman and A. Verma : ADMAT : An Automatic Differentiation Toolbox for
MATLAB, Technical report, Cornell University Theory Center, 1998.
Matlab Optimization Toolbox 2.0, User Guide and Theory Document. Available at
http://www.mathworks.com/access/helpdesk/help/pdf_doc/optim/optim_tb.pdf
63

You might also like