def fit_airfoil(): import airfoil af = airfoil.load('GA37A315mod') curveUp = interp1d(af.ptsUp[:,0],af.ptsUp[:,1],'cubic') curveLo = interp1d(af.ptsLo[:,0],af.ptsLo[:,1],'cubic') args = (curveUp,curveLo,) def func(x,curveUp,curveLo): ptsUp,ptsLo = get_bezier_airfoil(x) err = 0.0 for pt in ptsUp: err += (curveUp(pt[0])-pt[1])**2.0 for pt in ptsLo: err += (curveLo(pt[0])-pt[1])**2.0 return err x0 = np.array([0.03,0.04,0.06,0.04, 0.01,0.01,-0.03]) rslt = minimize(func,x0,method='SLSQP',args=args) ptsUp,ptsLo = get_bezier_airfoil(rslt.x,30) plt.figure() plt.hold(True) plt.plot(ptsUp[:,0],ptsUp[:,1],'r-') plt.plot(ptsLo[:,0],ptsLo[:,1],'r-') plt.plot(af.pts[:,0],af.pts[:,1],'k--') plt.axis('equal') plt.show()
def _load_airfoils(self,xlsPath=None): if xlsPath==None: xlsPath = path.db.airfoil self.secThickness = np.zeros(self.nSec) for i,name in enumerate(self.airfoilNames): self.airfoils.append(airfoil.load(name)) self.secThickness[i] = self.airfoils[i].thickness
def read_db(self,name,xlsPath=None,airfoilXlsPath=None): if xlsPath==None: xlsPath = pth.db.prop if airfoilXlsPath==None: airfoilXlsPath = pth.db.propAirfoil sh = db_tools.ReadDatabase(xlsPath,name) self.name = name self.diameter = sh.read_row(1,1) self.diameterHub = sh.read_row(-1,1) self.numBlades = sh.read_row(-1,1) self.betaRange = sh.read_row(-1,1) self.r = sh.read_row(-1,1) self.chord = sh.read_row(-1,1) self.beta = sh.read_row(-1,1) self.airfoilNames = sh.read_row(-1,1) self._numSections = len(self.r) for afname in self.airfoilNames: self.airfoils.append(airfoil.load(afname, airfoilXlsPath)) self._analyze_geometry()
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()
def create_with_airfoil_name(self,name,diam,numBlade,hubDiam,chord,beta,airfoilName,x,betaSet): afList = list() for afName in airfoilName: af = airfoil.load(afName) afList.append(af) self.create_with_airfoil(self,name,diam,numBlade,hubDiam,chord,beta,afList,x,betaSet)
def run_test_01(): af1 = af.load('GA37A315') fit = CSTfit() fit.fit(af1.upPts)