Ejemplo n.º 1
0
def testFcn():
    path = paths.CFD_paths('GA_opt')
    cruise = Flight_conditions(1500, 48.92)
    af = Airfoil()
    af.CST_airfoil(ny.array([0.178551,0.273254,0.268906,0.226346]),ny.array([-0.178551,-0.101338,-0.255260,-0.043527]))
    af.write_airfoil_txt('optAirfoil.dat')
    af.create_af_CAT(save = path.file_igs)
    Airfoil_mesh(path,cruise)
    Airfoil_mesh.yplus_wall = 1.0
    fluent = Solver(path,cruise)
    fluent.turb_model = 'ke-realizable'
    for alpha in range(10, 21, 2):
        fluent.run_fluent(alpha)
    af.polar.Re = cruise.Re
    af.polar.M = cruise.Mach
    af.polar.alpha = fluent.alpha
    af.polar.CL = fluent.cl
    af.polar.CD = fluent.cd
    af.polar.CM = fluent.cm
    #af.calc_Jpolar(0.1463,2999951,ny.array([-2,20,2.]))
    af.write_polar_txt(r'D:\3. Projects\afOpt\experimental data\GAopt.pol')

#def batch_calculation():
    designs = open(r'D:\3. Projects\afOpt\results\CFD_20120719\Designs.txt','rt')
    Au = ny.zeros([4,1])
    Al = ny.zeros([4,1])
    lines = designs.readlines()
    designs.close()
    landing = Flight_conditions(0, 32.5)
    path = paths.CFD_paths()
    results = r'D:\3. Projects\afOpt\results\CFD_20120719'
    for N,line in enumerate(lines):
        path.set_name(('DoE_%d'%N))
        segLine = line.split()
        Au[0] = float(segLine[0])
        Au[1] = float(segLine[1])
        Au[2] = float(segLine[2])
        Au[3] = float(segLine[3])
        Al[0] = -float(segLine[0])
        Al[1] = float(segLine[4])
        Al[2] = float(segLine[5])
        Al[3] = float(segLine[6])

        af = Airfoil()
        af.name = ('DoE %d'%N)
        af.CST_airfoil(Au,Al)
        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.array([10, 12, 14, 16, 18, 20])
        for alpha in alphaSeq:
            fluent.run_fluent(alpha)
        af.polar.Re = landing.Re
        af.polar.M = landing.Mach
        af.polar.alpha = fluent.alpha
        af.polar.cl = fluent.cl
        af.polar.cd = fluent.cd
        af.polar.cm = fluent.cm
        af.write_airfoil_txt(('%s\\airfoil_%d_coord.dat'%(results,N)))
        af.write_polar_txt(('%s\\airfoil_%d.pol'%(results,N)))