Beispiel #1
0
import mesh
import mesh_c
import mesh_o
import mesh_su2
from potential import potential_flow_o, velocity, pressure,\
    lift_n_drag, streamlines, potential_flow_o_n
import util

########################
# PERFIL AERODINAMICO
########################
# importar desde archivo
airfoil_points = 549
c = 1
filename = 'nombre_archivo_nube_de_puntos.csv'
perfil = airfoil.airfoil(c)
perfil.create(filename)

# perfil NACA 4
m = 0
p = 0
t = 12
c = 1
perfil = airfoil.NACA4(m, p, t, c)
perfil.create_sin(airfoil_points)

#########
# FLAP
#########
# importar desde archivo
filename_flap = 'nombre_archivo_nube_de_puntos_flap.csv'
def from_txt_mesh(filename='./garbage/mesh_own.txt_mesh'):
    '''
    importa malla de archivo txt_mesh. formato propio
    '''

    if filename[-8:] != 'txt_mesh':
        print('WARNING!')
        print('La extensión del archivo a importar no coincide con la \
              extensión utilizada por este programa')
        print('FINALIZANDO EJECUCIÓN')

        exit()

        return

    with open(filename, 'r') as f:
        mesh = f.readlines()

    tipo = str(mesh[0].split()[-1])
    d_eta = float(mesh[1].split()[-1])
    d_xi = float(mesh[2].split()[-1])
    R = float(mesh[3].split()[-1])
    M = int(mesh[4].split()[-1])
    N = int(mesh[5].split()[-1])
    airfoil_alone = str(mesh[6].split()[-1])
    airfoil_join = int(mesh[7].split()[-1])

    if airfoil_alone == 'True':
        airfoil_alone = True
    elif airfoil_alone == 'False':
        airfoil_alone = False

    airfoil_boundary = np.fromstring(mesh[9], sep=',')
    X = np.zeros((M, N))
    Y = np.zeros((M, N))

    i = 0
    line = 11
    for line_ in range(line, M + line):
        X[i, :] = np.fromstring(mesh[line_], sep=',')
        i += 1

    line += M + 1
    i = 0
    for line_ in range(line, M + line):
        Y[i, :] = np.fromstring(mesh[line_], sep=',')
        i += 1

    perfil = airfoil.airfoil(c=1)
    perfil.x = X[:, 0]
    perfil.y = Y[:, 0]
    if tipo == 'O':
        # mesh = mesh_o.mesh_O(R, M, N, perfil)
        mesh = mesh_o.mesh_O(R, N, perfil)
    elif tipo == 'C':
        # mesh = mesh_c.mesh_C(R, M, N, perfil, from_file=True)
        mesh = mesh_c.mesh_C(R, N, perfil, from_file=True)

    # se asignan atributos a malla
    mesh.d_eta = d_eta
    mesh.d_xi = d_xi
    mesh.R = R
    mesh.M = M
    mesh.N = N
    mesh.airfoil_alone = airfoil_alone
    mesh.airfoil_join = airfoil_join
    mesh.airfoil_boundary = airfoil_boundary
    mesh.X = X
    mesh.Y = Y

    return mesh
Beispiel #3
0
#!/usr/bin/python

import airfoil

reload(airfoil)

myairfoil = airfoil.airfoil()

myairfoil.load('clarky.dat')

myairfoil.createSketch()
Beispiel #4
0
from airfoil import airfoil
from meshsolv import meshgen, solver

camber = 0
position = 0
thickness = 12
AoA = 0
points = 10

#airfoil(camber,position,thickness,AoA(degree),half_the_points_on_airfoil)
airfoil(camber, position, thickness, AoA, points)

# Input: airfoil data points
#meshgen()
# Output: cgns_unstr

# Input: cgns_unstr
#solver()
# Output: solution file along with multiple files.
Beispiel #5
0
#########################################################################################################
########################################### Input data ##################################################
#########################################################################################################
N = 101  # Airfoil number of points
M = 50  # 20
c = 1.  # Chord [m]
m = 2.  # Is the maximum camber (100 m is the first of the four digits),
p = 5.  # Is the location of maximum camber (10 p is the second digit in the NACA xxxx description).
t = 12.  # Is the maximum thickness as a fraction of the chord
# (so t gives the last two digits in the NACA 4-digit denomination divided by 100)
#########################################################################################################
#########################################################################################################
#########################################################################################################

af.airfoil(c, N, m, p, t)

cordxy = np.loadtxt('perfilCoordenadas.txt', float)

[X, Y] = mh.mesh(1., M, cordxy)

########################### Plot mesh & airfoil ###############################
plt.plot(X, Y, "b", X.T, Y.T, "g")
plt.title('Airfoil NACA %d%d%d' % (m, p, t))
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.axis("equal")

##################### Coordinates, Mesh & Boundary ############################
X = X[:-1, :]  # remove the last element from the column
niter = f['step 1']['Niter']

#loop through the flap deflection range
for i in range(N_df):
	#set the flap deflection for this loop iteration
	df = df_min + float(i) * delta_df
	
	#determine the filename
	if df < 0.:
		sgn = 'n'
	else:
		sgn = 'p'
	filename = '{}{:0>2d}'.format(sgn,int(abs(df)))       # filename cannot be greater than 6 characters long
	
	#create the airfoil and run xfoil
	myaf = af.airfoil(naca=NACA,xf=xf,flapType=0,delta=df)
	m.add_airfoil(myaf)
	m.write_xfoil(filename = filename+'.txt')
	deflection_set = xfoil.generate_machup_from_xfoil(airfoils			= [filename+'.txt'],
									alpha_min			= aoa_min,
									alpha_max			= aoa_max,
									delta_alpha			= delta_aoa,
									reynolds_number		= Re,
									grid_size			= grid,
									niter				= niter,
									ncrit				= ncrit,
									xtrt				= xtr,
									xtrb				= xtr,
									flap				= df,
									xf					= xf,
									yf					= 0.0)
 def f_one_delta(self, x, naca, xf, flapType, alpha, targetCL):
     self.myaf = af.airfoil(naca=naca, xf=xf, flapType=flapType, delta=x)
     CL, CmLE, dummy = self.single(alpha)
     return (CL - targetCL)