2 # $Id: airfoil.dem,v 1.10 2006/06/30 02:17:21 sfeam Exp $
4 # This demo shows how to use bezier splines to define NACA four
5 # series airfoils and complex variables to define Joukowski
6 # Airfoils. It will be expanded after overplotting in implemented
7 # to plot Coefficient of Pressure as well.
10 # The definitions below follows: "Bezier presentation of airfoils",
11 # by Wolfgang Boehm, Computer Aided Geometric Design 4 (1987) pp 17-22.
13 # Gershon Elber, Nov. 1992
16 # p = percent chord with maximum camber
17 print "NACA four series airfoils by bezier splines"
18 print "Will add pressure distribution later with Overplotting"
22 # nine percent NACAxx09
25 # Combined this implies NACA6409 airfoil
27 # Airfoil thickness function.
29 set xlabel "NACA6409 -- 9% thick, 40% max camber, 6% camber"
49 # Directly defining the order 8 Bezier basis function for a faster evaluation.
51 bez_d4_i0(x) = (1 - x)**4
52 bez_d4_i1(x) = 4 * (1 - x)**3 * x
53 bez_d4_i2(x) = 6 * (1 - x)**2 * x**2
54 bez_d4_i3(x) = 4 * (1 - x)**1 * x**3
57 bez_d8_i0(x) = (1 - x)**8
58 bez_d8_i1(x) = 8 * (1 - x)**7 * x
59 bez_d8_i2(x) = 28 * (1 - x)**6 * x**2
60 bez_d8_i3(x) = 56 * (1 - x)**5 * x**3
61 bez_d8_i4(x) = 70 * (1 - x)**4 * x**4
62 bez_d8_i5(x) = 56 * (1 - x)**3 * x**5
63 bez_d8_i6(x) = 28 * (1 - x)**2 * x**6
64 bez_d8_i7(x) = 8 * (1 - x) * x**7
73 mean_y(t) = m0 * mm * bez_d4_i0(t) + \
74 m1 * mm * bez_d4_i1(t) + \
75 m2 * mm * bez_d4_i2(t) + \
76 m3 * mm * bez_d4_i3(t) + \
77 m4 * mm * bez_d4_i4(t)
84 mean_x(t) = p0 * bez_d4_i0(t) + \
90 z_x(x) = x0 * bez_d8_i0(x) + x1 * bez_d8_i1(x) + x2 * bez_d8_i2(x) + \
91 x3 * bez_d8_i3(x) + x4 * bez_d8_i4(x) + x5 * bez_d8_i5(x) + \
92 x6 * bez_d8_i6(x) + x7 * bez_d8_i7(x) + x8 * bez_d8_i8(x)
95 y0 * tk * bez_d8_i0(x) + y1 * tk * bez_d8_i1(x) + y2 * tk * bez_d8_i2(x) + \
96 y3 * tk * bez_d8_i3(x) + y4 * tk * bez_d8_i4(x) + y5 * tk * bez_d8_i5(x) + \
97 y6 * tk * bez_d8_i6(x) + y7 * tk * bez_d8_i7(x) + y8 * tk * bez_d8_i8(x)
100 # Given t value between zero and one, the airfoild curve is defined as
102 # c(t) = mean(t1(t)) +/- z(t2(t)) n(t1(t)),
104 # where n is the unit normal to the mean line. See the above paper for more.
106 # Unfortunately, the parametrization of c(t) is not the same for mean(t1)
107 # and z(t2). The mean line (and its normal) can assume linear function t1 = t,
109 # but the thickness z_y is, in fact, a function of z_x (t). Since it is
110 # not obvious how to compute this inverse function analytically, we instead
111 # replace t in c(t) equation above by z_x(t) to get:
113 # c(z_x(t)) = mean(z_x(t)) +/- z(t) n(z_x(t)),
115 # and compute and display this instead. Note we also ignore n(t) and assumes
116 # n(t) is constant in the y direction,
119 airfoil_y1(t, thick) = mean_y(z_x(t)) + z_y(t, thick)
120 airfoil_y2(t, thick) = mean_y(z_x(t)) - z_y(t, thick)
121 airfoil_y(t) = mean_y(z_x(t))
122 airfoil_x(t) = mean_x(z_x(t))
126 set xrange [-0.1:1.1]
128 set trange [ 0.0:1.0]
129 set title "NACA6409 Airfoil"
130 plot airfoil_x(t), airfoil_y(t) title "mean line" w l lt 2, \
131 airfoil_x(t), airfoil_y1(t, thick) title "upper surface" w l lt 1, \
132 airfoil_x(t), airfoil_y2(t, thick) title "lower surface" w l lt 1
133 pause -1 "Press Return"
137 set title "NACA0012 Airfoil"
138 set xlabel "12% thick, no camber -- classical test case"
139 plot airfoil_x(t), airfoil_y(t) title "mean line" w l lt 2, \
140 airfoil_x(t), airfoil_y1(t, thick) title "upper surface" w l lt 1, \
141 airfoil_x(t), airfoil_y2(t, thick) title "lower surface" w l lt 1
142 pause -1 "Press Return"
150 set style function lines
151 print "Joukowski Airfoil using Complex Variables"
152 set title "Joukowski Airfoil using Complex Variables" offset 0,0
154 set yrange [-.2 : 1.8]
157 zeta(t) = -eps + (a+eps)*exp(t*{0,1})
158 eta(t) = zeta(t) + a*a/zeta(t)
161 set xlabel "eps = 0.06 real"
162 plot real(eta(t)),imag(eta(t))
163 pause -1 "Press Return"
165 set xlabel "eps = 0.06 + i0.06"
166 plot real(eta(t)),imag(eta(t))
167 pause -1 "Press Return"