Beispiel #1
0
 def _read_xls(self,name=None,dbName=None):
     if dbName==None:
         dbName = self.pth.engineExp
     if name==None:
         name = 'ROTAX_912'
     engDb = dbTools.loadDB(dbName)
     engSh = engDb.selectByName(name)
     db = dbTools.readDB(engSh)
     idx = db.findHeader('SETTING')
     self.rpmLb = np.zeros(len(idx))
     self.rpmUb = np.zeros(len(idx))
     psetList   = np.zeros(len(idx))
     for i,j in enumerate(idx):
         rpm = db.readRow(j+1,1,True)
         psetList[i] = db.readRow(j,1,False)
         pset = np.ones(len(rpm))*psetList[i]
         self.rpmLb[i] = rpm[0]
         self.rpmUb[i] = rpm[-1]
         if i==0:
             self.powerSetting = pset
             self.rpm = rpm
             self.power = db.readRow(j+2,1,True)
             self.fuelFlow = db.readRow(j+3,1,True)
         else:
             self.powerSetting = np.hstack([self.powerSetting,pset])
             self.rpm = np.hstack([self.rpm,rpm])
             self.power = np.hstack([self.power,db.readRow(j+2,1,True)])
             self.fuelFlow = np.hstack([self.fuelFlow,db.readRow(j+3,1,True)])
         self.rps = self.rpm / 60.0
     self.power = self.power * 745.699872 # HP to Watt
     self.powerSurf = Rbf(self.powerSetting,self.rpm,self.power)
     self.fuelFlowSurf = Rbf(self.powerSetting,self.rpm,self.fuelFlow)
     self.rpmLbCurve = interp1d(psetList,self.rpmLb,'cubic')
     self.rpmUbCurve = interp1d(psetList,self.rpmUb,'cubic')
     self.powerSettingList = psetList
Beispiel #2
0
def load(name):
    """
    function to load aircraft from xls database.

    Parameters
    ----------

    name : string
        name of the aircraft configuration (sheet name in db)

    Examples
    --------

    load aircraft configuration from db and store it into *ac* variable

    >>> import aircraft
    >>> ac = aircraft.load('sampleInput1')
    >>> ac.display()
    >>> print ac.get_mass_empty() # print empty mass
    >>> print ac.get_mass_total() # print total mass
    >>> print ac.get_drag() # print total drag
    """
    pth=paths.Database()
    acDB =dbTools.loadDB(pth.aircraft)
    return aircraft(acDB.selectByName(name))
Beispiel #3
0
 def read_from_db(self,name,dbFile=None):
     if dbFile==None:
         dbFile = 'LargeTypeASM.xls'
     wb = dbTools.loadDB(dbFile,'r')
     sh = dbTools.readDB(wb.selectByName(name))
     
     i = sh.findHeader('SECTION: BODY')
     self.body.xprofile = sh.readRow(i+1,1,True)
     self.body.yprofile = sh.readRow(i+2,1,True)
     self.body.set_length(sh.readRow(i+3,1))
     self.body.set_diameter(sh.readRow(i+4,1))
     
     i = sh.findHeader('SECTION: WING')
     self.wing.chords         = sh.readRow(i+1,1,True)
     self.wing.incidenceAngle = sh.readRow(i+2,1,True)
     self.wing.sectionSpan    = sh.readRow(i+3,1)
     self.wing.leSweep        = sh.readRow(i+4,1)
     self.wing.dihedral       = sh.readRow(i+5,1)
     self.wing._set_airfoil(sh.readRow(i+6,1))
     self.wing.location       = sh.readRow(i+7,1)
     
     i = sh.findHeader('SECTION: TAIL')
     self.tail.chords             = sh.readRow(i+1,1,True)
     self.tail.incidenceAngle     = sh.readRow(i+2,1,True)
     self.tail.sectionSpan        = sh.readRow(i+3,1)
     self.tail.leSweep            = sh.readRow(i+4,1)
     self.tail.dihedral           = sh.readRow(i+5,1)
     self.tail._set_airfoil(sh.readRow(i+6,1))
     self.tail.location           = sh.readRow(i+7,1)
     self.tail.xangle             = sh.readRow(i+8,1)
     self.tail.centerOffset       = sh.readRow(i+9,1)
     self.tail.elevatorChordRatio = sh.readRow(i+10,1)
Beispiel #4
0
 def write_to_db(self,name,dbFile=None):
     if dbFile==None:
         dbFile = 'LargeTypeASM.xls'
     db = dbTools.loadDB(dbFile,mode='w')
     sh = dbTools.writeDB(db.add_sheet(name))
     sh.writeRow('SECTION: BODY')
     sh.writeRow('x profile',self.body.xprofile)
     sh.writeRow('y profile',self.body.yprofile)
     sh.writeRow('length',self.body.length)
     sh.writeRow('diameter',self.body.diameter)
     sh.writeRow('SECTION: WING')
     sh.writeRow('chords',self.wing.chords)
     sh.writeRow('incidence',self.wing.incidenceAngle)
     sh.writeRow('span',self.wing.sectionSpan)
     sh.writeRow('leading edge sweep',self.wing.leSweep)
     sh.writeRow('dihedral',self.wing.dihedral)
     sh.writeRow('airfoil',self.wing.airfoilPath)
     sh.writeRow('location X,Z',self.wing.location)
     sh.writeRow('SECTION: TAIL')
     sh.writeRow('chords',self.tail.chords)
     sh.writeRow('incidence',self.tail.incidenceAngle)
     sh.writeRow('span',self.tail.sectionSpan)
     sh.writeRow('leading edge sweep',self.tail.leSweep)
     sh.writeRow('dihedral',self.tail.dihedral)
     sh.writeRow('airfoil',self.tail.airfoilPath)
     sh.writeRow('location X,Z',self.tail.location)
     sh.writeRow('tail X-angle',self.tail.xangle)
     sh.writeRow('tail center offset', self.tail.centerOffset)
     sh.writeRow('elevator chord ratio',self.tail.elevatorChordRatio)
     db.save_db()
Beispiel #5
0
 def __init__(self,nameList,CG_X,CG_Y,CG_Z):
     """
     Parameters
     ----------
     
     nameList : list, string
         list of engine names
     CG_X : float, meters
         x coordinate of engine CG
     CG_Y : float, meters
         y coordinate of engine CG
     CG_Z : float, meters
         z coordinate of engine CG
     """
     pth=paths.Database()                
     self.CG_X                               =CG_X
     self.CG_Y                               =CG_Y
     self.CG_Z                               =CG_Z
     self.engineList                         =list()
     database                                =dbTools.loadDB(pth.engine)
     if type(nameList)==type(list()):
         self.nameList=nameList
     else:
         self.nameList=list()
         self.nameList.append(nameList)
     for name in self.nameList:
         dataSheet=database.selectByName(name)
         self.engineList.append(eng.pistonEngine(dataSheet))
Beispiel #6
0
def read_exp_data():
    wbName = r'D:\propeller_results.xls'
    wb = dbTools.loadDB(wbName)
    sh = wb.selectByName('Sheet1')
    sh = dbTools.readDB(sh)
    
    J = list()
    J.append(sh.readCol(3,0,13))
#    J.append(sh.readCol(3,2,17))
#    J.append(sh.readCol(3,4,18))
    J.append(sh.readCol(3,6,21))
#    J.append(sh.readCol(3,8,17))
#    J.append(sh.readCol(3,10,16))
    J.append(sh.readCol(3,12,17))
    
    effy = list()
    effy.append(sh.readCol(3,1,13))
#    effy.append(sh.readCol(3,3,17))
#    effy.append(sh.readCol(3,5,18))
    effy.append(sh.readCol(3,7,21))
#    effy.append(sh.readCol(3,9,17))
#    effy.append(sh.readCol(3,11,16))
    effy.append(sh.readCol(3,13,17))
    
    return J, effy
Beispiel #7
0
def runTest():
    import paths
    db          =paths.Database()
    engineDB    =dbTools.loadDB(db.engine)
    engineSheet =engineDB.selectByName("ROTAX_912ULS")
    eng         =pistonEngine(engineSheet,False)
    print eng.get_availablePower(1.05,2000.,100)
    print eng.sfc[0]
    print eng.get_idle_parameters()
Beispiel #8
0
def read_data():
    import dbTools
    dbname = r'D:\light aircraft\V05\propeller analysis\elprop_results\prop_results.xls'
    sheetname = ['15deg_2000rpm','25deg_2000rpm','35deg_2000rpm']
    wb = dbTools.loadDB(dbname)
    J = list()
    effy = list()
    for name in sheetname:
        sh = dbTools.readDB(wb.selectByName(name))
        J.append(sh.readCol(0,3,30))
        effy.append(sh.readCol(0,11,30))
    return J,effy
Beispiel #9
0
def load(name):
    """
    function to load aircraft from xls database.

    Parameters
    ----------

    name : string
        name of the aircraft configuration (sheet name in db)


    """
    pth=paths.Database()
    acDB =dbTools.loadDB(pth.aircraft)
    return aircraft(acDB.selectByName(name))
Beispiel #10
0
def write_xls_data(dbPath,name,J,CP,CT,effy,betaRange):
    db = dbTools.loadDB(dbPath,mode='w')
    newSheet = db.add_sheet(name)
    sh = dbTools.writeDB(newSheet)
    for i,beta in enumerate(betaRange):
        sh.writeRow('beta:',float(beta))
        sh.writeRow('J',['effy','CP','CT'])
        for j in range(len(J[i])):
            nyu = effy[i][j]
            cp = CP[i][j]
            ct = CT[i][j]
            if nyu!=None and cp!=None and ct!=None:
                line = [J[i][j], nyu, cp, ct]
                sh.writeRow('',line)
        sh._prevRow +=1
    db.save_db()
Beispiel #11
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)        
Beispiel #12
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()
Beispiel #13
0
 def __init__(self,nameList,propHub_X,propHub_Y,propHub_Z,minBeta,maxBeta):
     pth=paths.Database()    
     self.hub_X                              =propHub_X
     self.hub_Y                              =propHub_Y
     self.hub_Z                              =propHub_Z
     self.betaRange                          =[minBeta,maxBeta]
     self._database                          =dbTools.loadDB(pth.prop)
     if type(nameList)==type(list()):
         self.nameList=nameList
     else:
         self.nameList=list()
         self.nameList.append(nameList)
     self.propellerList                      =list()
     for i,name in enumerate(self.nameList):
         P=prop.propeller()
         P.read_xls(name)
         betaLo=self.betaRange[0][i]
         betaHi=self.betaRange[1][i]
         P.betaRange=[betaLo,betaHi]
         self.propellerList.append(P)
Beispiel #14
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()
def read_exp_data():
    dataPath = r'D:\engauge\propeller\digitized_results.xls'
    wb = dbTools.loadDB(dataPath)
    db = dbTools.readDB(wb.selectByName('NACA5868-9'))
    J = list()
    CP = list()
    CT = list()
    
    J.append(db.readCol(2,0,10))
    J.append(db.readCol(2,3,13))
    J.append(db.readCol(2,6,13))
    J.append(db.readCol(2,9,13))
    CP.append(db.readCol(2,1,10))
    CP.append(db.readCol(2,4,13))
    CP.append(db.readCol(2,7,13))
    CP.append(db.readCol(2,10,13))
    CT.append(db.readCol(2,2,10))
    CT.append(db.readCol(2,5,13))
    CT.append(db.readCol(2,8,13))
    CT.append(db.readCol(2,11,13))
    return J, CP, CT
Beispiel #16
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)
Beispiel #17
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)
Beispiel #18
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()
Beispiel #19
0
def runTest1():
    pth=paths.Database()
    acDB =dbTools.loadDB(pth.aircraft)
    #acDB=dbTools.loadDB("//database//aircraft.xls")
    workbook = acDB.workbook
    worksheets = workbook.sheet_names()
    for worksheet_name in worksheets:
        worksheet = workbook.sheet_by_name(worksheet_name)
        print worksheet
    sheetList,sheetNames=acDB.loadData()
    print sheetList
    print sheetNames
    acData=acDB.selectByName("sampleInput1")
    print acData
    ac=aircraft(acData)
    ac=load("sampleInput2")
    print ac.wing.airfoilName
    print ac.wing.aapex
    print ac.wing.incidence
    print ac.engine.CG_X
    print ac.landingGear.groundContact_X
    print ac.VLMsetup.wing_spanwise  
    print ac.mass[0].name
    print ac.mass.nameList()
    print 'HT'
    print ac.hStab.segmentDihedrals
    print ac.hStab.segmentOffsets
    print ac.vStab.segmentSpans

    ac.mass.removeItem("passenger")
    print ac.wing.airfoilName
    print ac.fuselage.sideProfile_X
    print ac.mass.nameList()
    print ac.engine.nameList
    print ac.propeller.nameList
    print ac.engine.engineList[0].RPM
Beispiel #20
0
 def __init__(self):
     pth=paths.Database()
     self.db=dbTools.loadDB(pth.constants)
     self.data=list()
     self.dict=dict()
     self._headers=1
Beispiel #21
0
def load(name):
    db          =paths.Database()
    engineDB    =dbTools.loadDB(db.engine)
    engineSheet =engineDB.selectByName("ROTAX_912ULS")
    eng         =pistonEngine(engineSheet,False)
    return eng
Beispiel #22
0
def load(name):
    pth=paths.Database()
    acDB =dbTools.loadDB(pth.aircraft)
    return Design(acDB.selectByName(name))