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()
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()
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 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)
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)