示例#1
0
def my_func(M,P,T,aoa,span,tip_chord):
        chord[1] = tip_chord
	mesh_utils.write_wing_file(M,P,T,chord,span,n_sections,n_naca_pts)
	NACA.create_wing('current_wing','output')
	run_apame(aoa)
	fid = open('output_polar.dat','r')
	nb_lines=0
	while fid.readline():
		nb_lines+=1
	if nb_lines==0:
		raise TypeError("Empty file")
	fid.close()
	fid = open('output_polar.dat','r')
	# revenir au debut
	alpha=numpy.zeros(nb_lines)
	cx=numpy.zeros(nb_lines)
	cz=numpy.zeros(nb_lines)
	for i in xrange(nb_lines):
		tmp=fid.readline()
		tmp=tmp.split()
		alpha[i]=float(tmp[0])
		cx[i]=float(tmp[2])
		cz[i]=float(tmp[1])
	fid.close()
	ind = cx.argmin()
	Cf = 0.0583/Re**0.2
	Sw = (chord[0]+chord[1])*span/2.
        Cd_friction = Sw/Sref*Cf
	return min(cx)+Cd_friction,cz[ind]
示例#2
0
def my_func(M, P, T, span, tip_chord):
    chord[1] = tip_chord
    mesh_utils.write_wing_file(M, P, T, chord, span, n_sections, n_naca_pts)
    NACA.create_wing("current_wing", "output")
    run_apame()
    fid = open("output_polar.dat", "r")
    nb_lines = 0
    while fid.readline():
        nb_lines += 1
    if nb_lines == 0:
        raise TypeError("Empty file")
    fid.close()
    fid = open("output_polar.dat", "r")
    # revenir au debut
    alpha = numpy.zeros(nb_lines)
    cx = numpy.zeros(nb_lines)
    cz = numpy.zeros(nb_lines)
    finesse = numpy.zeros(nb_lines)
    Cf = 0.0583 / Re ** 0.2
    Sw = (chord[0] + chord[1]) * span / 2.0
    Cd_friction = Sw / Sref * Cf
    for i in xrange(nb_lines):
        tmp = fid.readline()
        tmp = tmp.split()
        alpha[i] = float(tmp[0])
        cx[i] = float(tmp[2]) + Cd_friction
        cz[i] = float(tmp[1])
        finesse[i] = cz[i] / cx[i]
    fid.close()
    return max(finesse)
示例#3
0
def my_func(X):
	chord=[1.,1.]
	M=X[0:2]
	P=X[2:4]
	T=X[4:6]
	alpha=X[6]
	span=X[7]
	chord[1]=X[8]
	n_sections=31
	n_naca_pts=50
	Sref=10.
	Re=5.e5
	mesh_utils.write_wing_file(M,P,T,chord,span,n_sections,n_naca_pts)
	NACA.create_wing('current_wing','output')
	run_apame(alpha)
	fid = open('output_polar.dat','r')
	nb_lines=0
	while fid.readline():
		nb_lines+=1
	if nb_lines==0:
		raise TypeError("Empty file")
	fid.close()
	fid = open('output_polar.dat','r')
	# revenir au debut
	alpha=numpy.zeros(nb_lines)
	cx=numpy.zeros(nb_lines)
	cz=numpy.zeros(nb_lines)
	for i in xrange(nb_lines):
		tmp=fid.readline()
		tmp=tmp.split()
		alpha[i]=float(tmp[0])
		cx[i]=float(tmp[2])
		cz[i]=float(tmp[1])
	fid.close()
	#f = interpolate.interp1d(numpy.array(cz), numpy.array(cx), kind='cubic')
	#print 'DRAG >>> ', min(cx)
	#cx=f(0.5)
	
	ind = cx.argmin()
	Cf = 0.0583/Re**0.2
	Sw = (chord[0]+chord[1])*span/2.
	Cd_friction = Sw/Sref*Cf
	print 'DRAG >>> ', cx+Cd_friction
	cx_tab[k]=cx+Cd_friction
	contrainte_tab[k]=0.5-cz
	k=k+1
	return cx+Cd_friction#,cz[ind]
		 beta=beta_list,
		 v=airspeed,
		 rho=rho,
		 P=Patm,
		 Mach=0.,
		 origin=[0.,0.,0.],
		 wingspan=10.,
		 ref_chord=1.,
		 Sref=Sref,
		 method=0,
		 farfield_dist=50.,
		 velorder=1)

if nb==8415:
	nb_angles=11
	M=[0.08,0.08]
	P=[0.4,0.4]
	T=[0.15,0.15]
	
elif nb==12:
	nb_angles=21
	M=[0.0,0.0]
	P=[0.4,0.4]
	T=[0.12,0.12]

mesh_utils.write_wing_file(M,P,T,chord,span,n_sections,n_naca_pts)
NACA.create_wing('current_wing','initial'+str(nb))
run_apame(nb_angles)