Exemplo n.º 1
0
    sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/../lib'))
    import airfoil
    import contour
    import layout

rchord = 8.0
tchord = 5.0
twist = 0

width = 8.5
height = 11

print "coutouts demo"
layout = layout.Layout( 'demo-cutouts', width, height )

root = airfoil.Airfoil("naca633618", 1000, True)
tip = airfoil.Airfoil("naca0015", 1000, True);

steps = 8
dp = 1.0 / steps

for p in range(0, steps+1):
    print "Making rib " + str(p)
    percent = p*dp

    blend = airfoil.blend( root, tip, percent )
    blend.fit( 500, 0.0001 )
    size = rchord * (1.0 - percent) + tchord * percent
    blend.scale( size, size )
    blend.move(-size / 3.0, 0)
Exemplo n.º 2
0
import sys
import airfoil

if len(sys.argv) < 2:
    print('Usage:')
    print('  python3 {} <airfoil data directory>'.format(sys.argv[0]))
    sys.exit(0)

inputdir = sys.argv[1]

try:
    a = airfoil.Airfoil(inputdir)
except RuntimeError as e:
    print('ERROR: {}'.format(e))
    sys.exit(2)

print(a)






Exemplo n.º 3
0
 def load_airfoils(self, root, tip=None):
     self.root = airfoil.Airfoil(root, self.airfoil_samples, True)
     if tip:
         self.tip = airfoil.Airfoil(tip, self.airfoil_samples, True)
Exemplo n.º 4
0
except ImportError:
    # if airfoil is not 'installed' append parent dir of __file__ to sys.path
    import sys, os
    sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/../lib'))
    import airfoil
    import layout

chord = 8.0

width = 8.5
height = 11

print "resampling and adaptive fit demo"
layout = layout.Layout( 'demo-fit', width, height )

root = airfoil.Airfoil("naca633618", 0, False)

rib = copy.deepcopy(root)
rib.scale( chord, chord )
tx = chord/3.0
ty = rib.simple_interp(rib.top, tx)
by = rib.simple_interp(rib.bottom, tx)
vd = (ty - by)
hy = by + vd / 2.0
rib.add_label( tx, hy, 14, 0, "Original Points" )
layout.draw_part_vertices( rib )

rib = copy.deepcopy(root)
rib.resample(1000, True)
rib.scale( chord, chord )
rib.fit( 200, 0.00005 )
Exemplo n.º 5
0
import sys

import airfoil

if len(sys.argv) < 2:
    print("Usage:")
    print("    $ python %s <airfoil_data_directory>" % sys.argv[0])
    sys.exit(0)

input_dir = sys.argv[1]

try:
    a = airfoil.Airfoil(input_dir)
except RuntimeError as e:
    print("ERROR: %s" % e)
    sys.exit(2)

print(a)
Exemplo n.º 6
0
    def __init__(self, root, windowName):
        """ INITIALIZE THE UI CLASS """
        # SET UP VARIABLES
        self.CWINX = 500
        self.CWINY = 350
        self.fileName = ""
        self.NPTS = ""
        self.foil = airfoil.Airfoil()

        # WIDGET VARIABLES
        self.foilNameLbl = Tkinter.StringVar()
        self.foilTypeOpt = Tkinter.StringVar()

        # INITIALIZE LABEL VALUES
        self.updateFoilName("")
        self.updateFoilType("n4")  # SET N4 AS DEFAULT

        # SET ROOT WINDOW NAME
        root.title(windowName)
        # SET WINDOW TO NOT RESIZE
        root.resizable(width="NO", height="NO")

        # SET UP MENU
        # CODE TAKEN FROM EFFBOT.ORG
        # MODIFIED FOR USE WITH THIS PROGRAM
        self.menuBar = Tkinter.Menu(root)

        # create a pulldown menu, and add it to the menu bar
        self.fileMenu = Tkinter.Menu(self.menuBar, tearoff=0)
        self.fileMenu.add_command(label="Open",
                                  command=lambda: self.fileOpen(root))
        self.fileMenu.add_command(label="Save",
                                  command=lambda: self.fileSaveAs(root))
        self.fileMenu.add_separator()
        self.fileMenu.add_command(label="Exit", command=root.quit)
        self.menuBar.add_cascade(label="File", menu=self.fileMenu)

        # create more pulldown menus
        self.modifierMenu = Tkinter.Menu(self.menuBar, tearoff=0)
        self.modifierMenu.add_command(
            label="Invert", command=lambda: self.foilModsWrapper("invert"))
        self.modifierMenu.add_command(label="Scale", command=hello)
        self.modifierMenu.add_command(
            label="Rotate")  #, command=lambda: self.foilModsWrapper("rotate"))
        self.menuBar.add_cascade(label="Modifiers", menu=self.modifierMenu)

        self.helpMenu = Tkinter.Menu(self.menuBar, tearoff=0)
        self.helpMenu.add_command(label="About", command=hello)
        self.menuBar.add_cascade(label="Help", menu=self.helpMenu)

        # display the menu
        root.config(menu=self.menuBar)

        # SET UP GUI
        # ======================================================================
        # FRAME FL - HOLDER FOR CANVAS
        self.FL = Tkinter.Frame(root, height=self.CWINY, width=self.CWINX)
        self.FL.pack(side=Tkinter.LEFT, fill=Tkinter.Y)

        # SETUP CANVAS
        self.plot = Tkinter.Canvas(self.FL,
                                   height=self.CWINY,
                                   width=self.CWINX,
                                   bg="#000000")
        self.plot.pack(side=Tkinter.TOP)

        # FRAME FLA - HOLDER FOR AIRFOIL BUTTONS THAT CONTROL FLIPBOOK
        self.FLA = Tkinter.Frame(self.FL, width=self.CWINX)
        self.FLA.pack(fill=Tkinter.X)

        # SET UP ANGLE OF ATTACK SLIDER IN FLA
        #self.foilRotate = Tkinter.Scale(self.FLA,from_=-50,to=50,resolution=1,label="Angle of Attack",orient=Tkinter.HORIZONTAL)
        #self.foilRotate.pack(side=Tkinter.LEFT,fill=Tkinter.X)

        # SETUP FOIL NAME LABEL
        self.lblFoilName = Tkinter.Label(self.FLA,
                                         justify="center",
                                         textvariable=self.foilNameLbl)
        self.lblFoilName.pack(side=Tkinter.LEFT, fill=Tkinter.X)

        # FRAME FLA - HOLDER FOR AIRFOIL BUTTONS THAT CONTROL FLIPBOOK
        self.FLB = Tkinter.Frame(self.FL, width=self.CWINX)
        self.FLB.pack(side=Tkinter.BOTTOM, fill=Tkinter.X)

        # FRAME FR - MAIN FRAME FOR FLIPPABLE FRAME AND BUTTONS
        self.FR = Tkinter.Frame(root, height=275, width=200)
        self.FR.pack(side=Tkinter.RIGHT, fill=Tkinter.Y)

        # CREATE FLIPPING FRAME HOLDER
        self.FRA = Tkinter.Frame(self.FR)
        self.FRA.pack(fill=Tkinter.BOTH)

        # CREATE FLIPPABLE FRAMES - DO NOT PACK FRAMES THEMSELVES, ONLY WIDGETS ON THEM
        # ==============================================

        # ==========================================================================
        # **************************************************************************
        # **************************************************************************
        # ==========================================================================

        # ==============================================
        # NACA 4 PAGE
        self.FRA2 = Tkinter.Frame(self.FRA)

        # NACA 4 MAX CAMBER SLIDER
        self.n4CPlace = Tkinter.Scale(self.FRA2,
                                      from_=2,
                                      to=9,
                                      resolution=1,
                                      label="Maximum Camber",
                                      orient=Tkinter.HORIZONTAL)
        self.n4CPlace.pack(side=Tkinter.TOP, fill=Tkinter.X)

        # NACA 4 MAX CAMBER POSITION SLIDER
        self.n4MCLPos = Tkinter.Scale(self.FRA2,
                                      from_=2,
                                      to=9,
                                      resolution=1,
                                      label="Max Camber Position",
                                      orient=Tkinter.HORIZONTAL)
        self.n4MCLPos.pack(side=Tkinter.TOP, fill=Tkinter.X)

        # NACA 4 AIRFOIL THICKNESS SLIDER
        self.n4TCRatio = Tkinter.Scale(self.FRA2,
                                       from_=0.02,
                                       to=0.99,
                                       resolution=.01,
                                       label="Airfoil Thickness Ratio",
                                       orient=Tkinter.HORIZONTAL)
        self.n4TCRatio.pack(side=Tkinter.TOP, fill=Tkinter.X)

        # PACK THE FLIPPING FRAME AND SET AS HIDDEN
        self.FRA2.pack(fill=Tkinter.BOTH, expand=1)
        self.active_fr = self.FRA2

        # ==============================================
        # NACA 5 PAGE
        self.FRA3 = Tkinter.Frame(self.FRA)

        # NACA 5 TYPE SLIDER
        self.n5MCLPos = Tkinter.Scale(self.FRA3,
                                      from_=210,
                                      to=250,
                                      resolution=10,
                                      label="NACA 5 Type",
                                      orient=Tkinter.HORIZONTAL)
        self.n5MCLPos.pack(side=Tkinter.TOP, fill=Tkinter.X)

        # NACA 5 AIRFOIL THICKNESS SLIDER
        self.n5TCRatio = Tkinter.Scale(self.FRA3,
                                       from_=0.02,
                                       to=0.99,
                                       resolution=.01,
                                       label="Airfoil Thickness Ratio",
                                       orient=Tkinter.HORIZONTAL)
        self.n5TCRatio.pack(side=Tkinter.TOP, fill=Tkinter.X)

        # PACK THE FLIPPING FRAME AND SET AS HIDDEN
        self.FRA3.pack(fill=Tkinter.BOTH, expand=1)
        self.FRA3.forget()

        # ==============================================
        # BICONVEX PAGE
        self.FRA4 = Tkinter.Frame(self.FRA)

        # BICONVEX THICKNESS SLIDER
        self.bxTCRatio = Tkinter.Scale(self.FRA4,
                                       from_=0.02,
                                       to=0.99,
                                       resolution=.01,
                                       label="Airfoil Thickness Ratio",
                                       orient=Tkinter.HORIZONTAL)
        self.bxTCRatio.pack(side=Tkinter.TOP, fill=Tkinter.X)

        # PACK THE FLIPPING FRAME AND SET AS HIDDEN
        self.FRA4.pack(fill=Tkinter.BOTH, expand=1)
        self.FRA4.forget()

        # ==============================================
        # JOUKOWSKI PAGE
        self.FRA5 = Tkinter.Frame(self.FRA)

        # JOUKOWSKI MR VALUE SLIDER - SET FOR CHORD = 1
        self.juMR = Tkinter.Scale(self.FRA5,
                                  from_=0.001,
                                  to=0.04,
                                  resolution=0.001,
                                  label="MR Value",
                                  orient=Tkinter.HORIZONTAL)
        self.juMR.pack(side=Tkinter.TOP, fill=Tkinter.X)

        # JOUKOWSKI ML VALUE SLIDER - SET FOR CHORD = 1
        self.juML = Tkinter.Scale(self.FRA5,
                                  from_=0.001,
                                  to=0.04,
                                  resolution=0.001,
                                  label="ML Value",
                                  orient=Tkinter.HORIZONTAL)
        self.juML.pack(side=Tkinter.TOP, fill=Tkinter.X)

        # PACK THE FLIPPING FRAME AND SET AS HIDDEN
        self.FRA5.pack(fill=Tkinter.BOTH, expand=1)
        self.FRA5.forget()

        # SET UP RADIO BUTTONS FOR AIRFOIL TYPE - PUT INTO FLB

        # ==========================================================================
        # **************************************************************************
        # **************************************************************************
        # ==========================================================================

        self.foilN4 = Tkinter.Radiobutton(
            self.FLB,
            text="NACA 4",
            variable=self.foilTypeOpt,
            value="n4",
            command=lambda: self.display(self.FRA2))
        self.foilN4.pack(side=Tkinter.LEFT, fill=Tkinter.X)

        self.foilN5 = Tkinter.Radiobutton(
            self.FLB,
            text="NACA 5",
            variable=self.foilTypeOpt,
            value="n5",
            command=lambda: self.display(self.FRA3))
        self.foilN5.pack(side=Tkinter.LEFT, fill=Tkinter.X)

        self.foilBX = Tkinter.Radiobutton(
            self.FLB,
            text="Biconvex",
            variable=self.foilTypeOpt,
            value="bx",
            command=lambda: self.display(self.FRA4))
        self.foilBX.pack(side=Tkinter.LEFT, fill=Tkinter.X)

        self.foilJU = Tkinter.Radiobutton(
            self.FLB,
            text="Joukowski",
            variable=self.foilTypeOpt,
            value="ju",
            command=lambda: self.display(self.FRA5))
        self.foilJU.pack(side=Tkinter.LEFT, fill=Tkinter.X)

        # FRAME FRB - RIGHT SUBFRAME FOR FOIL TYPES AND BUTTONS
        self.FRB = Tkinter.Frame(self.FR, bg="#FCFCFC")
        self.FRB.pack(side=Tkinter.BOTTOM, fill=Tkinter.X)

        # AIRFOIL NUMBER OF POINTS
        self.foilNPtsLbl = Tkinter.Label(self.FRB,
                                         justify="center",
                                         text="\nNumber of Points")
        self.foilNPtsLbl.pack(fill=Tkinter.X)
        self.foilNPts = Tkinter.Spinbox(self.FRB,
                                        from_=51,
                                        to=1001,
                                        increment=10,
                                        command=self.updateNPTS)
        self.foilNPts.pack(fill=Tkinter.X)
        # UPDATE NUMBER OF POINTS RIGHT AFTER CREATION
        self.updateNPTS()

        # SET UP COMMAND BUTTONS IN FRB
        self.spacerLbl = Tkinter.Label(self.FRB, justify="center")
        self.spacerLbl.pack(fill=Tkinter.X)
        self.btnGenFoil = Tkinter.Button(self.FRB,
                                         text="Generate Airfoil",
                                         command=self.genFoil)
        self.btnGenFoil.pack(fill=Tkinter.X)
Exemplo n.º 7
0
"""Just some testing."""
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from base import Base
import blade
import airfoil
import flosim
import flosolver

engine = create_engine('sqlite:///my_test_db.sqlite3')
Session = sessionmaker(bind=engine)
session = Session()

# Create table
Base.metadata.create_all(engine)

myblade = blade.Blade()
myairfoil = airfoil.Airfoil(airfoil_name='jfoil')
airfoil2 = airfoil.Airfoil(airfoil_name='bfoil')

myblade.airfoils.append(myairfoil)
myblade.airfoils.append(airfoil2)

session.add(myblade)
session.commit()