Ground-Wing / scripts /airfoils /xfoil_plotting.py
andreacenzato's picture
Added description and analysis files
f355580 verified
Raw History Blame Contribute Delete
1.6 kB
import os
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.serif": ["Computer Modern Roman"],
"font.size": 16
})
input_folder = "xfoil/inputs"
output_folder = "xfoil/outputs"
first_profile_name = "be"
second_profile_name = "e214"
# Correcting input paths
input_folder = os.path.normpath(input_folder)
output_folder = os.path.normpath(output_folder)
input_files = [
os.path.join(input_folder,f)
for f in os.listdir(input_folder)
if any(f.endswith(ftype) for ftype in [".dat"])
]
output_files = [
os.path.join(output_folder,f)
for f in os.listdir(output_folder)
if any(f.endswith(ftype) for ftype in [".dat"])
]
first_profile = [f for f in input_files if first_profile_name.casefold() in os.path.basename(f).casefold()]
second_profile = [f for f in input_files if second_profile_name.casefold() in os.path.basename(f).casefold()]
gen_profiles = [f for f in output_files if (first_profile_name.casefold() in os.path.basename(f).casefold() and second_profile_name.casefold() in os.path.basename(f).casefold())]
fig,ax = plt.subplots(layout="constrained")
ax.axis("equal")
ax.set_xlabel("Normalized Chord")
ax.set_ylabel("Normalized Height")
titles = ["BE 122-125","E214","Interpolated Profile"]
for i, file in enumerate(first_profile + second_profile + gen_profiles):
data = np.genfromtxt(file,autostrip=True,skip_header=1)
ax.plot(data[:,0],-data[:,1],label=titles[i])
ax.legend()
plt.savefig("interpolated_profile.svg",format="svg")