Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
125 views
in Technique[技术] by (71.8m points)

python - NACA 4 digit airfoil

I have a NACA csv file containing the X and Y coordinates for an airfoil.

What I'm trying to do is, giving a circle from an angle theta to get the coordinate X. From that X, obtain the Y coordinate from the NACA profil.

For the needs of my problem, I want to divide the profil in two: extrados and intrados with: _ extrados: profil for y values positive _ intrados: profil for y values negative

For now, I have this:

def profil(r,theta):
    X = r*np.cos(theta)
    Y = r*np.sin(theta)
    with open('naca_2414.csv','r') as f:
        data = list(reader(f, delimiter=','))
        x = [i[0] for i in data]
        y = [i[1] for i in data]
        if (Y>0):
            val = np.interp(X,x,y)
        else:
            val = -np.interp(X,x,y)
    return val

I know this is wrong, I'm getting confused and mixed up with the values to use to realize the interpolation and can't see what to do, espacially to realize the interpolation for the "upper" and "lower" sufaces of the airfoil.

Can you help ?

Thank you

question from:https://stackoverflow.com/questions/65891539/naca-4-digit-airfoil

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Well I can't say I've fully understood the "circle" part exactly. But as you've asked for splitting the profile into upper and lower parts and then making interpolation work, this code can help you.


import numpy as np

# Read naca into a numpy array
# I've used a string here, but you can find resources how to read your csv.
naca = "1.00000,0.00147|0.99739,0.00210|0.98929,0.00396|0.97587,0.00700|0.95729,0.01112|0.93372,0.01620|0.90542,0.02207|0.87267,0.02857|0.83582,0.03552|0.79527,0.04274|0.75143,0.05004|0.70480,0.05723|0.65586,0.06412|0.60515,0.07053|0.55324,0.07629|0.50069,0.08120|0.44808,0.08512|0.39598,0.08787|0.34454,0.08913|0.29482,0.08866|0.24740,0.08645|0.20285,0.08255|0.16169,0.07707|0.12440,0.07014|0.09141,0.06198|0.06310,0.05281|0.03977,0.04289|0.02165,0.03245|0.00892,0.02171|0.00169,0.01085|0.00000,0.00000|0.00379,-0.01031|0.01293,-0.01956|0.02730,-0.02770|0.04669,-0.03471|0.07087,-0.04054|0.09957,-0.04516|0.13246,-0.04858|0.16918,-0.05082|0.20937,-0.05195|0.25260,-0.05208|0.29844,-0.05133|0.34644,-0.04987|0.39611,-0.04787|0.44739,-0.04537|0.49931,-0.04232|0.55129,-0.03886|0.60276,-0.03516|0.65316,-0.03132|0.70194,-0.02745|0.74857,-0.02365|0.79252,-0.01998|0.83331,-0.01650|0.87048,-0.01328|0.90360,-0.01035|0.93230,-0.00776|0.95626,-0.00557|0.97518,-0.00381|0.98886,-0.00252|0.99713,-0.00173|1.00000,-0.00147"
naca = np.genfromtxt(naca.split('|'), delimiter=',')
print(naca.shape)

# Split naca into upper and lower parts. We're using '<=' here
# instead of '<' to make interp work
extrados = naca[naca[:, 1] >= 0]
intrados = naca[naca[:, 1] <= 0]

# Sort arrays along column 0, for np.interp to work
intrados = intrados[np.argsort(intrados[:, 0])]
extrados = extrados[np.argsort(extrados[:, 0])]

# Now you can use np.interp as you'd like.
# For example:

print(np.interp(0.98929, intrados[:, 0], intrados[:, 1]))
# -0.0024789238210398993
print(np.interp(0.98929, extrados[:, 0], extrados[:, 1]))
# 0.00396


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...