def calculate_bounds():
    X = np.array([0.14391813, 0.18778261, 0.14634264, 0.15348147, 0.15107265, -0.09014438, -0.05862712, -0.03488944, -0.01428362, 0.03831908])
    lb = X - np.array([0.01, 0.05, 0.05, 0.05, 0.00, 0.05, 0.05, 0.05, 0.05, 0.05])
    ub = X + np.array([0.05, 0.05, 0.05, 0.05, 0.05, 0.01, 0.05, 0.05, 0.05, 0.00])
    af1 = airfoil.cst(lb[0:5],ub[5:10])
    af1.plot()
    af2 = airfoil.cst(ub[0:5],lb[5:10])
    af2.plot()
    
    fc = cfd.FlightConditions(22.0,0.0,0,0.24)
    result = aero_analysis(af1,fc,'thin.txt')
    result = aero_analysis(af2,fc,'thick.txt')
Example #2
0
def tmp_cst_plot():
    	
    Au = [0.120718,0.135291,0.174915,0.142468]
    Al = [-0.120718,-0.150704,-0.176010,-0.040013]
    af = airfoil.cst(Au,Al)
    print af.thickness
    af.plot()
Example #3
0
def calc_airfoil(name,polarPath):
    #Au = ny.array([0.178551,0.273254,0.268906,0.226346])
    #Al = ny.array([-0.178551,-0.101338,-0.255260,-0.043527])
    #Au = ny.array([0.1920,0.2887,0.2844,0.2304])
    #Al = ny.array([-0.1920,-0.0859,-0.2398,-0.0255])
    path = paths.CFD_paths()
    landing = Flight_conditions(0.0,60.0)
    #af = cst(Au,Al)
    #af = Airfoil()
    #af.read_airfoil_txt(name)
    #af.read_txt(name)
    #af.radius_LE=[]
    af = cst([0.1839,0.3790,0.2712,0.1635],[-0.1839,-0.0493,-0.2190,-0.0225])
    polarPath = 'optimum-polar.txt'
    af.create_af_CAT(save = path.file_igs)
    Airfoil_mesh(path,landing)
    Airfoil_mesh.yplus_wall = 1.0
    fluent = Solver(path,landing)
    fluent.turb_model = 'ke-realizable'
    #alphaSeq = ny.linspace(0,20,21)
    #alphaSeq = ny.linspace(0,10,5)
    alphaSeq = ny.linspace(0,20,21)#ny.array([10.0,12,14,16,18])
    for alpha in alphaSeq:
        fluent.run_fluent(alpha)
    af.polar.Re = landing.Re
    af.polar.M = landing.Mach
    af.polar.Mach = landing.Mach
    af.polar.alpha = fluent.alpha
    af.polar.cl = fluent.cl
    af.polar.cd = fluent.cd
    af.polar.cm = fluent.cm

    #af.write_polar_txt(r'D:\3. Projects\afOpt\results\af_GA20120716\landingCFDpolar_01_.pol')
    af.write_polar_txt(polarPath)
def run_test1():
    A = np.array([0.15225392, 0.17285363, 0.15722004, 0.13938069,-0.08884681, -0.05170833, -0.01974148, 0.02985025])
#    A[3] += -0.04
#    A[7] += 0.04
    af = airfoil.cst(A[0:4],A[4:8])
    af.plot()
    fc = cfd.FlightConditions(22.0,0.0,0,0.24)
    result = aero_analysis(af,fc,'testPolar.txt')
Example #5
0
 def _obj(x,*args):
     up,lo = args
     Au = x[0:5]
     Al = x[5:10]
     afcst = airfoil.cst(Au,Al)
     sqErr = 0.0
     for i,pt in enumerate(up[:,0]):
         sqErr += (afcst.upCurve(pt) - up[i,1])**2.0
     for i,pt in enumerate(lo[:,0]):
         sqErr += (afcst.loCurve(pt) - lo[i,1])**2.0
     return sqErr
Example #6
0
 def _err(x,*args):
     up,lo = args
     Au = x[0:5]
     Al = x[5:10]
     afcst = airfoil.cst(Au,Al)
     upErr = zeros(len(up))
     loErr = zeros(len(lo))
     for i,pt in enumerate(up[:,0]):
         upErr[i] = afcst.upCurve(pt) - up[i,1]
     for i,pt in enumerate(lo[:,0]):
         loErr[i] = (afcst.loCurve(pt) - lo[i,1])
     return upErr, loErr
Example #7
0
 def _upd_cst(self,x,_norm=True):
     if _norm:
         x = denormalize(x,self.lb,self.ub)
     n = len(x)
     if n%2==0:
         Au = x[:n/2]
         Al = x[n/2:]
     else:
         Au = x[:int(n/2)+1]
         Al = hstack([-x[0],x[int(n/2)+1:]])
     self.af = Af.cst(Au,Al,25,'cos')
     self.thickness = self.af.thickness
def run_baseline():
    #X = np.array([0.14391813, 0.18778261, 0.14634264, 0.15348147, 0.15107265, -0.09014438, -0.05862712, -0.03488944, -0.01428362, 0.03831908])
    #X = np.array([0.1639, 0.2078, 0.1663, 0.1629, 0.1511, -0.1049, -0.0548, -0.0149, -0.0009, 0.0383])
    X = np.array([0.1439, 0.1878,0.1463,0.1535,0.1511,-0.0901,-0.0586,-0.0349,-0.0143,0.0383])
    fc = cfd.FlightConditions(22.0,0.0,0,0.24)
    fid = open('RENNbaseline.txt','wt')
    fid.write('Au0\tAu1\tAu2\tAu3\tAu4\tAl0\tAl1\tAl2\tAl3\tAl4\tLDmax\talphaLDmax\tClmax\talphaClmax\tCdAtLDmax\tthickness\n')
    fid.close()
    #designs = read_doe(pathDOE)
    #for i,design in enumerate(designs):
    af = airfoil.cst(X[0:5],X[5:10])
    result = aero_analysis(af, fc, 'tmp1z.txt')
    write_output(X,result,'RENNbaseline.txt')
Example #9
0
def test_plot_airfoil():
    af1 = airfoil.Airfoil()
    af1.read_txt('GA37A315.txt')
    Au = [0.1823,0.3380,0.2650,0.2016]
    Al = [-0.1823,-0.0708,-0.1885,-0.0384]
    af2 = airfoil.cst(Au,Al)
    
    rslt1 = af1.get_X_polar(0.18,4.4e6,[-10,20,1.0])
    rslt2 = af2.get_X_polar(0.18,4.4e6,[-10,20,1.0])
    
    alpha1 = [0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,18,19,20]
    cl1 = [0.243296,0.453613,0.558244,0.661459,0.763304,0.859225,0.951732,1.04177,1.12103,1.19799,1.26788,1.32786,1.38623,1.41998,1.42465,1.23664,1.18999,1.17667]
    
    alpha2 = [0,1,2,5,7,8,12,13,14,15,16,17,18,19,20]
    cl2 = [0.264347,0.372483,0.481921,0.801596,0.998552,1.09719,1.41826,1.46123,1.52317,1.54066,1.4781,1.35913,1.31233,1.27969,1.26525]    
    print af2.thickness
    af1.analyze_geometry()
    print af1.thickness
    
    plt.figure(1)
    plt.grid(True)
    plt.hold(True)
    plt.plot(af1.coord[:,0],af1.coord[:,1],'b-')
    plt.plot(af2.coord[:,0],af2.coord[:,1],'r*-')
    plt.legend(['Baseline','Optimum'])
    plt.figure(2)
    plt.grid(True)
    plt.hold(True)
    plt.plot(rslt1.cd,rslt1.cl,'b-')
    plt.plot(rslt2.cd,rslt2.cl,'r*-')
    plt.axis([0.002,0.012,-0.5,1.0])
    plt.legend(['Baseline','Optimum'])
    plt.xlabel('drag coefficient')
    plt.ylabel('lift coefficient')
    
    plt.figure(3)
    plt.grid(True)
    plt.hold(True)
    #plt.plot(rslt1.alpha,rslt1.cl,'b-')
    plt.plot(alpha1,cl1,'b-')
    #plt.plot(rslt2.alpha,rslt2.cl,'r-')
    plt.plot(alpha2,cl2,'r*-')
    plt.axis([0,20,0,1.8])
    #plt.legend(['baseline-low','baseline-high','optimum-low','optimum-high'],'lower right')
    plt.legend(['Baseline','Optimum'],'lower right')
    plt.show()
def run_full_table_analysis(wdir):
    X,lb,ub,fc = get_initial_data()
    
    pathDOE = os.getcwd() + '\\' + wdir + '\\1. input.txt'
    pathOutput = os.getcwd() + '\\' + wdir + '\\2. outputAero.txt'
    clcruise = 0.4
    
    fid = open(pathOutput,'wt')
    fid.write('Au0\tAu1\tAu2\tAu3\tAu4\tAl0\tAl1\tAl2\tAl3\tAl4\tLDmax\talphaLDmax\tClmax\talphaClmax\tCdAtLDmax\tLD32max\tthickness\tcdcruise\n')
    fid.close()
    #designs = read_doe(pathDOE)
    designs = read_tabulated_data_without_header(pathDOE)
    for i,design in enumerate(designs):
        design = denormalize(design,lb,ub)
        af = airfoil.cst(design[0:5],design[5:10])
        filename = wdir + 'polar_%d.txt'%(i+1)
        result = aero_analysis(af, fc, filename)
        write_output(design,result,pathOutput,clcruise)
        af.write_txt(wdir + 'coordinates_%d.txt'%(i+1))
Example #11
0
def cst_fit():

    
    af = airfoil.Airfoil()
    af.read_txt(r'C:\Users\Maxim\Dropbox\2. projects\VCM\transonic airfoil\rae2822.txt',afType=2)
    #af.read_txt(r'D:\laptop_sync\1. Projects\RENN\airfoil design\AG24new.txt')
    #af.read_txt('pb092_closed.txt')
    af.coord[:,1] = af.coord[:,1] - af.coord[:,0]*0.001868
    af.separate_coordinates()
    af.plot()
    up, lo = af.upPts, af.loPts
    args1 = up,lo

    def _obj(x,*args):
        up,lo = args
        Au = x[0:5]
        Al = x[5:10]
        afcst = airfoil.cst(Au,Al)
        sqErr = 0.0
        for i,pt in enumerate(up[:,0]):
            sqErr += (afcst.upCurve(pt) - up[i,1])**2.0
        for i,pt in enumerate(lo[:,0]):
            sqErr += (afcst.loCurve(pt) - lo[i,1])**2.0
        return sqErr
    
    def _err(x,*args):
        up,lo = args
        Au = x[0:5]
        Al = x[5:10]
        afcst = airfoil.cst(Au,Al)
        upErr = zeros(len(up))
        loErr = zeros(len(lo))
        for i,pt in enumerate(up[:,0]):
            upErr[i] = afcst.upCurve(pt) - up[i,1]
        for i,pt in enumerate(lo[:,0]):
            loErr[i] = (afcst.loCurve(pt) - lo[i,1])
        return upErr, loErr
    
    bnds = ((0.0,1.0),(-0.3,1.0),(-0.3,1.0),(-0.3,1.0),(-0.3,1.0),(-1.0,0.0),(-1.0,0.3),(-1.0,0.3),(-1.0,0.3),(-1.0,0.3))
    rslt = minimize(_obj,x0=0.1*ones(10),bounds=bnds,method='SLSQP',args=args1)
    xnew = rslt.x
    upErr, lowErr = _err(xnew,up,lo)
    
    #xnew[:4] += +0.075
    #xnew[4:] += -0.075
    print xnew
    #xnew += 0.05
    afnew = airfoil.cst(xnew[0:5],xnew[5:10])
    print afnew.thickness
    fid = open('GA37A315cst.txt','wt')
    for xx in xnew:
        fid.write('%.8f\t'%xx)
    fid.close()
    fig = plt.figure(1)
    ax1 = fig.add_subplot(211)
    ax2 = fig.add_subplot(212)
    ax1.hold(True)
    ax1.set_title(af.name)
    ax2.set_title('Fit error')
    ax1.plot(af.coord[:,0],af.coord[:,1],'k-')
    ax1.plot(afnew.coord[:,0],afnew.coord[:,1],'r.-')
    ax1.axis('equal')
    ax1.legend(['Original Airfoil','CST fit'])
    ax2.hold(True)
    ax2.plot(up[:,0],upErr,'ks-',markevery=3)
    ax2.plot(lo[1:,0],lowErr[1:],'k^-',markevery=3)
    ax2.set_ylabel('error')
    ax2.legend(['Upper curve','Lower curve'],'lower left')
    plt.show()
 def _upd_cst(self,x):
     #x = denormalize(x,self.lb,self.ub)
     Au = x[:4]
     Al = array([-x[0],x[4],x[5],x[6]])
     self.af = Af.cst(Au,Al)
     self.thickness = self.af.thickness