Code: Select all
' In aerodynamics, the Youkowsky transform is used to map
' a circle in the real x-y plane into a airfoil in the
' complex u-v plane.
' Together with the circle, also the streamlines around the
' circle are mapped into the streamlines around the airfoil.
' From this streamline pattern, the velocities, pressures,
' and the forces (lift) can be deducted.
' Direct calculations of the streamlines around an airfoil
' are extremely difficult if not impossible.
' The streamline pattern around a circle however is easily
' established, and the Joukowsky transform gives the solutions
' for the airfoil.
' Also google for "conformal mapping".
{/initgraph}
init_app
start:
disp_circles(a,ksi,eta) ! disp_foil(a,ksi,eta)
wait: if not get_m then wait else start
end
def init_app
.a=140 ! .delta=5 ! .ksi=10 ! .eta=10
draw font size 20
slider "hor" value .67 at 50,800 hsize 400
draw text "profile thickness" at 150,850
slider "vert" value .67 at 500,400 vsize 400
draw text "camber" at 480,370
draw font size 30
draw text "Joukowsky transform (circle to airfoil)" at 30,10
end def
def disp_foil(a,ksi,eta)
graphics lock
fill rect 100,60 to 700,330
draw size 1 ! draw color .5,.5,.5
for y=60 to 330 step 30 ! draw line 100,y to 700,y ! next y
for x=100 to 700 step 30 ! draw line x,60 to x,330 ! next x
draw size 2 ! draw color 0,0,1
rr=(a+ksi)^2+eta^2 ! r=sqrt(rr) ! beta=-asin(eta/r) ! aa=a*a
for theta=beta to 360+beta step .delta
x=r*cos(theta)+ksi ! y=r*sin(theta)-eta ! xy=x*x+y*y
u=400+x*(aa+xy)/xy ! v=200+y*(xy-aa)/xy
if theta=beta then draw to u,v else draw line to u,v
next theta
graphics unlock
end def
def disp_circles(a,ksi,eta)
graphics lock
fill rect 40,360 to 430,770
draw size 2 ! draw color 0,0,0
draw line 50,580 to 430,580 ! draw line 250,390 to 250,740
ym=a*eta/(a+ksi) ! rm=sqrt(a*a+ym*ym)
draw line 245,580-ym to 255,580-ym
draw circle 250,580-ym size rm
draw color 0,0,1
rr=(a+ksi)^2+eta^2 ! r=sqrt(rr)
draw line 245-ksi,580-eta to 255-ksi,580-eta
draw line 250-ksi,575-eta to 250-ksi,585-eta
draw circle 250-ksi,580-eta size r
graphics unlock
end def
def get_m
get_m=0
mloop:
if slider_changed("hor") then
.ksi=(1-slider_value("hor"))*30 ! get_m=1 ! return
end if
if slider_changed("vert") then
.eta=(1-slider_value("vert"))*40 ! get_m=1 ! return
end if
goto mloop
end def