Exemple #1
0
    def read_xls(self, sheetName, dbPath=""):
        r"""
        Parameters
        ----------
        
        sheetName : string
            name of xls sheet with airfoil data
        dbPath : path
            file path of xls format airfoil database. If dbPath='' then default database will be 
            used. 

        Default db path is 'database/airfoil.xls'.
        Default paths can be edited in paths.py
        Data read are: coordinates, optional: aerodynamic data
        """
        if dbPath == "":
            dbPath = self.dbPath
        dbPath = paths.fixPaths(dbPath)  # TODO: update using io.path
        db = dbTools.read(dbPath, sheetName)
        self.name = sheetName
        xCoord = db.readRow(0, 1)
        yCoord = db.readRow(1, 1)
        self.coord = transpose([xCoord, yCoord])
        self.separate_coordinates()
        i = db.findHeader("GEOMETRY")
        if i == -1:
            self.analyze_geometry()
        else:
            self.thickness = float(db.readRow(i + 1, 1))
            self.camber = db.readRow(i + 2, 1)
        i = db.findHeader("ANALYSIS")
        if i == -1:
            self.build_aero_table()
        else:
            self.polar.source = db.readRow(i + 1, 1)
            i = db.findHeader("LIFT COEFFICIENT")
            nAlpha = db.findHeader("DRAG COEFFICIENT") - i - 2
            self.polar.Mach = array(db.readRow(i + 1, 1))
            self.polar.alpha = array(db.readCol(i + 2, 0, nAlpha))
            self.polar.cl = db.readRange(i + 2, 1, nAlpha)
            i = db.findHeader("DRAG COEFFICIENT")
            self.polar.cd = db.readRange(i + 2, 1, nAlpha)
            i = db.findHeader("MOMENT COEFFICIENT")
            self.polar.cm = db.readRange(i + 2, 1, nAlpha)
            self.polar.cl = transpose(self.polar.cl)
            self.polar.cd = transpose(self.polar.cd)
            self.polar.cm = transpose(self.polar.cm)
            self.polar.create_splines(mach=True)
        self.polar.calc_clmax()
        self.create_splines()
 def __init__(self,inputFilePath,flightConditions):
     self.results=list()
     for i in range(len(flightConditions)):
         self.results.append(_results())
     self.inputFilePath=paths.fixPaths(inputFilePath)
     self.flightConditions=flightConditions
     pth=paths.MyPaths()
     cmd=pth.avl+' '+inputFilePath
     args=shlex.split(cmd,False,os.name=='posix')
     self._ps=sp.Popen(args,stdin=sp.PIPE,stderr=sp.PIPE,stdout=sp.PIPE)
     self._ps.stderr.close()                
     self._runFlightConditions(self.flightConditions)        
     self.rawOutput=str(self._ps.stdout.read()).replace('\r','')
     self._processOutput()
     self._setStabResults()
Exemple #3
0
 def _read_db(self,sheetName='Sheet1',dbPath=''):
     if dbPath=='':
         dbPath = self.dbPath
     dbPath = paths.fixPaths(dbPath)
     dragDb = dbTools.loadDB(dbPath)
     sheet = dragDb.selectByName(sheetName)
     db = dbTools.readDB(sheet)
     nComp = sheet.nrows - 1
     self.name = db.readCol(1,0,nComp)
     self.desc = db.readCol(1,1,nComp)
     self.relCD = db.readCol(1,2,nComp)
     mode = db.readCol(1,3,nComp)
     for m in mode:
         if m=='*':
             self.mode.append(True)
         else:
             self.mode.append(False)        
Exemple #4
0
    def read_xls(self,propName, dbPath=None, afDbPath=None):
        """
        reads in excel propeller database. Two database files are needed: 
        propeller, airfoil.
        
        Parameters
        ----------
        
        propName : string
            propeller name
        dbPath : path
            path of the propeller database. Default db will be used if not 
            specified.
        afDbPath : path
            path of the airfoil database. Default db will be used if not 
            specified.

        """
        if dbPath==None:
            dbPath = self.defaultPath.prop
        if afDbPath==None:
            afDbPath = self.defaultPath.propAirfoil
        dbPath = paths.fixPaths(dbPath)
        propDb = dbTools.loadDB(dbPath)
        sheet = propDb.selectByName(propName)
        db = dbTools.readDB(sheet)
        self.name        = propName
        self.diameter    = db.readRow(1,1)
        self.radius      = self.diameter / 2.0
        self.hubDiameter = db.readRow(2,1)
        self.numBlades   = db.readRow(3,1)
        self.betaRange   = db.readRow(4,1)
        self.r           = db.readRow(5,1)
        self.x           = 2*self.r / self.diameter
        self.chord       = db.readRow(7,1)
        self.beta        = db.readRow(8,1)
        self.airfoilName = db.readRow(9,1)
        self.numStations = len(self.r)
        self.betaCurrent = 0.0
        self.betaXstation = 0.0
        for afName in self.airfoilName:
            af = airfoil.Airfoil()
            af.read_xls(afName,afDbPath)
            self.airfoil.append(af)
        self.analyze_geometry()
Exemple #5
0
    def write_xls(self, dbPath="", includePolars=True):
        r"""
        Writes airfoil data (geometry, aerodynamics) to database.

        Parameters
        ----------
        
        dbPath : path
            file path of airfoil database in xls format. If dbPath is not 
            specified then default database will be used
        """
        if dbPath == "":
            dbPath = self.dbPath
        dbPath = paths.fixPaths(dbPath)
        afDB = dbTools.loadDB(dbPath, mode="w")
        newSheet = afDB.add_sheet(self.name)
        sheet = dbTools.writeDB(newSheet)
        sheet.writeRow("X", self.coord[:, 0])
        sheet.writeRow("Y", self.coord[:, 1])
        sheet.writeRow("GEOMETRY")
        sheet.writeRow("thickness", self.thickness)
        sheet.writeRow("camber", self.camber)
        if includePolars:
            sheet.writeRow("ANALYSIS")
            sheet.writeRow("method", self.polar.source)
            sheet.writeRow("LIFT COEFFICIENT")
            sheet.writeRow("Mach list", self.polar.Mach)
            i = sheet._prevRow + 1
            sheet.writeCol(self.polar.alpha)
            sheet.writeRange(transpose(self.polar.cl), i, 1)
            sheet.writeRow("DRAG COEFFICIENT")
            sheet.writeRow("Mach list", self.polar.Mach)
            i = sheet._prevRow + 1
            sheet.writeCol(self.polar.alpha)
            sheet.writeRange(transpose(self.polar.cd), i, 1)
            sheet.writeRow("MOMENT COEFFICIENT")
            sheet.writeRow("Mach list", self.polar.Mach)
            i = sheet._prevRow + 1
            sheet.writeCol(self.polar.alpha)
            sheet.writeRange(transpose(self.polar.cm), i, 1)
        afDB.save_db()
Exemple #6
0
 def write_xls(self,dbPath='',afDbPath=''):
     if dbPath=='':
         dbPath = self.defaultPath.prop
     if afDbPath=='':
         afDbPath = self.defaultPath.propAirfoil
     dbPath   = paths.fixPaths(dbPath)
     print dbPath, afDbPath
     db       = dbTools.loadDB(dbPath,mode='w')
     newSheet = db.add_sheet(self.name)
     sheet    = dbTools.writeDB(newSheet)
     sheet.writeRow('name',self.name)
     sheet.writeRow('diameter',self.diameter)
     sheet.writeRow('hub diameter',self.hubDiameter)
     sheet.writeRow('num blades',self.numBlades)
     sheet.writeRow('beta range deg',self.betaRange)
     sheet.writeRow('r',self.r)
     sheet.writeRow('x',self.x)
     sheet.writeRow('chord',self.chord)
     sheet.writeRow('beta',self.beta)
     sheet.writeRow('airfoils',self.airfoilName)
     db.save_db()
     for af in self.airfoil:
         af.write_xls(afDbPath)
Exemple #7
0
 def write_xls(self,dbPath=None,afDbPath=None):
     """
     saves propeller and all airfoil sections into propeller and propAirfoil 
     xls sheets.
     
     Parameters
     ----------
     
     dbPath : string
         path to propeller sheet file. If path is not specified then 
         default is used
     afDbPath : string
         path to propelller airfoil sheet file. If path is not specified then 
         default is used
     """
     if dbPath==None:
         dbPath = self.defaultPath.prop
     if afDbPath==None:
         afDbPath = self.defaultPath.propAirfoil
     dbPath   = paths.fixPaths(dbPath)
     print dbPath, afDbPath
     db       = dbTools.loadDB(dbPath,mode='w')
     newSheet = db.add_sheet(self.name)
     sheet    = dbTools.writeDB(newSheet)
     sheet.writeRow('name',self.name)
     sheet.writeRow('diameter',self.diameter)
     sheet.writeRow('hub diameter',self.hubDiameter)
     sheet.writeRow('num blades',self.numBlades)
     sheet.writeRow('beta range deg',self.betaRange)
     sheet.writeRow('r',self.r)
     sheet.writeRow('x',self.x)
     sheet.writeRow('chord',self.chord)
     sheet.writeRow('beta',self.beta)
     sheet.writeRow('airfoils',self.airfoilName)
     db.save_db()
     for af in self.airfoil:
         af.write_xls(afDbPath)
Exemple #8
0
 def read_xls(self,name,dbPath='',afDbPath=''):
     if dbPath=='':
         dbPath = self.defaultPath.prop
     if afDbPath=='':
         afDbPath = self.defaultPath.propAirfoil
     dbPath = paths.fixPaths(dbPath)
     propDb = dbTools.loadDB(dbPath)
     sheet = propDb.selectByName(name)
     db = dbTools.readDB(sheet)
     self.name = name
     self.diameter = db.readRow(1,1)
     self.hubDiam  = db.readRow(2,1)
     self.numBlades= db.readRow(3,1)
     self.betaRange= db.readRow(4,1)
     self.r        = db.readRow(5,1)
     self.x = 2.0*self.r / self.diameter
     self.chord = db.readRow(7,1)
     self.beta = db.readRow(8,1)
     afname = db.readRow(9,1)
     self.airfoil = list()
     for afn in afname:
         af = airfoil.load(afn)
         self.airfoil.append(af)
     self._get_prop_data()