Exemplo n.º 1
0
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 03 21:15:26 2014

@author: Maxim
"""
import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import minimize
from mpl_toolkits.mplot3d import axes3d
from misc_tools import SaveTextData

out = SaveTextData('output1.py')

tol = 0.01
err = tol+1.

def f(x):
    f=x[0]+x[1]
    return f
def g1(x):
    C1=x[0]**2*x[1]/20.0-1.
    return C1

def g2(x):
    C2=(x[0]+x[1]-5.0)**2/30.+(x[0]-x[1]-12.0)**2/120.0-1.
    return C2
    
def g3(x):
    C3=80.0/(x[0]**2+8.0*x[1]+5.0)-1
    return C3
Exemplo n.º 2
0
def plot_result_af():
    x0 = array([0.1670, 0.3340, 0.2601, 0.1971, -0.0713, -0.1951, -0.0498])
    x1 = [0.1839,0.3520,0.2512,0.1835,-0.0493,-0.2190,-0.0225]
    x2 = [0.1729,0.3482,0.2707,0.2045,-0.0774,-0.1563,-0.0498]
    
    rsltFile = SaveTextData('af_sub_20141207.txt')
    
    def print_polar(pol):
        print '-->'
        for i in range(len(pol.alpha)):
            print '%.2f\t%.6f\t%.6f\t%.6f'%(pol.alpha[i],pol.cl[i],pol.cd[i],pol.cm[i])

    aa = AirfoilAnalysis()
    aa._upd_cst(x0,False)
    crd0 = copy(aa.af.coord)
    pol0 = aa._run_fluent(x0,False)
    pol0x = aa.af.get_X_polar(aa.Mldg,aa.landing.Re,alphaSeq=[-10,10,1])
    print_polar(pol0)
    print_polar(pol0x)
    
    aa._upd_cst(x1,False)
    crd1 = copy(aa.af.coord)
    pol1 = aa._run_fluent(x1,False)
    pol1x = aa.af.get_X_polar(aa.Mldg,aa.landing.Re,alphaSeq=[-10,10,1])
    print_polar(pol1)
    print_polar(pol1x)
    
    aa._upd_cst(x2,False)
    crd2 = copy(aa.af.coord)
    pol2 = aa._run_fluent(x2,False)
    pol2x = aa.af.get_X_polar(aa.Mldg,aa.landing.Re,alphaSeq=[-10,10,1])
    
    print_polar(pol0)
    print_polar(pol0x)
    print_polar(pol1)
    print_polar(pol1x)
    print_polar(pol2)    
    print_polar(pol2x)
    
    rsltFile.write_array(crd0[:,0],'x0')
    rsltFile.write_array(crd0[:,1],'y0')
    rsltFile.write_array(crd1[:,0],'x1')
    rsltFile.write_array(crd1[:,1],'y1')
    rsltFile.write_array(crd2[:,0],'x2')
    rsltFile.write_array(crd2[:,1],'y2')
    
    rsltFile.write_array(pol0x.cd,'cd0x')
    rsltFile.write_array(pol1x.cd,'cd1x')
    rsltFile.write_array(pol2x.cd,'cd2x')
    rsltFile.write_array(pol0x.cl,'cl0x')
    rsltFile.write_array(pol1x.cl,'cl1x')
    rsltFile.write_array(pol2x.cl,'cl2x')
    
    rsltFile.write_array(pol0.alpha,'a0')
    rsltFile.write_array(pol1.alpha,'a1')
    rsltFile.write_array(pol2.alpha,'a2')
    rsltFile.write_array(pol0.cl,'cl0')
    rsltFile.write_array(pol1.cl,'cl1')
    rsltFile.write_array(pol2.cl,'cl2')
    rsltFile.close()
    
    plt.figure(1)
    plt.hold(True)
    plt.grid(True)
    plt.plot(crd0[:,0],crd0[:,1],'k--',linewidth=2)
    plt.plot(crd1[:,0],crd1[:,1],'r-',linewidth=2)
    plt.plot(crd2[:,0],crd2[:,1],'b:',linewidth=2)
    plt.legend(['baseline','GVFM','VCM'])
    
    plt.figure(2)
    plt.hold(True)
    plt.grid(True)
    plt.axis([0.002, 0.012, -0.5, 1.0])
    plt.plot(pol0x.cd, pol0x.cl, 'ks--',linewidth=2)
    plt.plot(pol1x.cd, pol1x.cl, 'ro-',linewidth=2)
    plt.plot(pol2x.cd, pol2x.cl, 'b^:',linewidth=2)
    plt.xlabel('Drag coefficient')
    plt.ylabel('Lift coefficient')
    plt.legend(['baseline','GVFM','VCM'],'lower right')

    plt.figure(3)
    plt.hold(True)
    plt.grid(True)
    plt.axis([0,20,0,1.8])
    plt.plot(pol0.alpha, pol0.cl, 'ks--',linewidth=2)
    plt.plot(pol1.alpha, pol1.cl, 'ro-',linewidth=2)
    plt.plot(pol2.alpha, pol2.cl, 'b^:',linewidth=2)
    plt.xlabel('Angle of attack, deg')
    plt.ylabel('Lift coefficient')
    plt.legend(['baseline','GVFM','VCM'],'lower right')
    plt.show()