From 9dbda81c44892d99b334d61d02840248afb47ea7 Mon Sep 17 00:00:00 2001 From: Ethan Alan Hereth Date: Tue, 10 Dec 2019 14:00:20 -0600 Subject: [PATCH 1/3] Trailing whitespace cleanup --- AirfoilGenerator.glf | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/AirfoilGenerator.glf b/AirfoilGenerator.glf index c24a94f..782d641 100644 --- a/AirfoilGenerator.glf +++ b/AirfoilGenerator.glf @@ -1,9 +1,9 @@ # # Copyright 2010 (c) Pointwise, Inc. # All rights reserved. -# +# # This sample Glyph script is not supported by Pointwise, Inc. -# It is provided freely for demonstration purposes only. +# It is provided freely for demonstration purposes only. # SEE THE WARRANTY DISCLAIMER AT THE BOTTOM OF THIS FILE. # @@ -43,11 +43,11 @@ proc airfoilGen {} { # AIRFOIL INPUTS # ----------------------------------------------- -# m = maximum camber -# p = maximum camber location +# m = maximum camber +# p = maximum camber location # t = maximum thickness -set m [expr {[string index $::naca 0]/100.0}] -set p [expr {[string index $::naca 1]/10.0}] +set m [expr {[string index $::naca 0]/100.0}] +set p [expr {[string index $::naca 1]/10.0}] set a [string index $::naca 2] set b [string index $::naca 3] set c "$a$b" @@ -161,12 +161,12 @@ exit # TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, POINTWISE DISCLAIMS # ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED # TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE, WITH REGARD TO THIS SCRIPT. TO THE MAXIMUM EXTENT PERMITTED -# BY APPLICABLE LAW, IN NO EVENT SHALL POINTWISE BE LIABLE TO ANY PARTY -# FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES -# WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF -# BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE -# USE OF OR INABILITY TO USE THIS SCRIPT EVEN IF POINTWISE HAS BEEN -# ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS OF THE +# PURPOSE, WITH REGARD TO THIS SCRIPT. TO THE MAXIMUM EXTENT PERMITTED +# BY APPLICABLE LAW, IN NO EVENT SHALL POINTWISE BE LIABLE TO ANY PARTY +# FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES +# WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF +# BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE +# USE OF OR INABILITY TO USE THIS SCRIPT EVEN IF POINTWISE HAS BEEN +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS OF THE # FAULT OR NEGLIGENCE OF POINTWISE. # From 8f0ef873befabac82f4a81fa62e44c32316da346 Mon Sep 17 00:00:00 2001 From: Ethan Alan Hereth Date: Tue, 10 Dec 2019 14:03:48 -0600 Subject: [PATCH 2/3] Improve how points are distributed on the airfoil This commit changes the x-distribution of points along the airfoil from using a constant step size to using a variable step size as explained near the bottom of the following page: http://airfoiltools.com/airfoil/naca4digit?MNaca4DigitForm%5Bcamber%5D=0&MNaca4DigitForm%5Bposition%5D=0&MNaca4DigitForm%5Bthick%5D=12&MNaca4DigitForm%5BnumPoints%5D=81&MNaca4DigitForm%5BcosSpace%5D=0&MNaca4DigitForm%5BcosSpace%5D=1&MNaca4DigitForm%5BcloseTe%5D=0&MNaca4DigitForm%5BcloseTe%5D=1&yt0=Plo The leading edge is resolved significantly better when using this distribution. --- AirfoilGenerator.glf | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/AirfoilGenerator.glf b/AirfoilGenerator.glf index 782d641..9e9241b 100644 --- a/AirfoilGenerator.glf +++ b/AirfoilGenerator.glf @@ -66,14 +66,19 @@ set yl {} set yc {0} set yt {} +# Define pi +set pi [expr {355.0/113.0}] + +# Airfoil number of steps +set nsteps 1000 # Airfoil step size -set ds 0.001 +set ds [expr {$pi/$nsteps}] # Check if airfoil is symmetric or cambered if {$m == 0 && $p == 0 || $m == 0 || $p == 0} {set symm 1} else {set symm 0} -# Get x coordinates -for {set i 0} {$i < [expr {1+$ds}]} {set i [expr {$i+$ds}]} {lappend x $i} +# Get x coordinates; improved distribution explained here: http://airfoiltools.com/airfoil/naca4digit?MNaca4DigitForm%5Bcamber%5D=0&MNaca4DigitForm%5Bposition%5D=0&MNaca4DigitForm%5Bthick%5D=12&MNaca4DigitForm%5BnumPoints%5D=81&MNaca4DigitForm%5BcosSpace%5D=0&MNaca4DigitForm%5BcosSpace%5D=1&MNaca4DigitForm%5BcloseTe%5D=0&MNaca4DigitForm%5BcloseTe%5D=1&yt0=Plot +for {set i 0} {$i < [expr {$pi+$ds}]} {set i [expr {$i+$ds}]} {lappend x [expr {0.5*(1.0 - cos($i))}]} # Calculate mean camber line and thickness distribution foreach xx $x { From 2980278d598f237954bd23f202763228e35265e3 Mon Sep 17 00:00:00 2001 From: Ethan Alan Hereth Date: Tue, 10 Dec 2019 14:12:14 -0600 Subject: [PATCH 3/3] Use the math::constants package to get pi This commit adds a dependency but should theoretically be a better way to get the value of pi. --- AirfoilGenerator.glf | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/AirfoilGenerator.glf b/AirfoilGenerator.glf index 9e9241b..b1ca9f1 100644 --- a/AirfoilGenerator.glf +++ b/AirfoilGenerator.glf @@ -20,6 +20,9 @@ package require PWI_Glyph pw::Script loadTk +# Load math constants for pi +package require math::constants + # AIRFOIL GUI INFORMATION # ----------------------------------------------- set naca 0012 @@ -67,7 +70,10 @@ set yc {0} set yt {} # Define pi -set pi [expr {355.0/113.0}] +# The easy way; see the section named "Practical approximations" here: https://en.wikipedia.org/wiki/Approximations_of_π +# set pi [expr {355.0/113.0}] +# Another easy way that has a dependency: it requires the math::constants package +math::constants::constants pi # Airfoil number of steps set nsteps 1000