##### Tangential force calculation CT = (pt1_star + pt2_star * cosa + pt3_star * cosa**3) * sina**2 ##### Conversion to wind axes CL = CN * cosa + CT * sina CD = CN * sina - CT * cosa CM = np.zeros_like(CL) # TODO return CL, CD, CM if __name__ == '__main__': af = Airfoil("naca0012") alpha = np.linspace(0, 360, 721) CL, CD, CM = airfoil_coefficients_post_stall(af, alpha) from aerosandbox.tools.pretty_plots import plt, show_plot, set_ticks fig, ax = plt.subplots(1, 2, figsize=(8, 5)) plt.sca(ax[0]) plt.plot(alpha, CL) plt.xlabel("AoA") plt.ylabel("CL") set_ticks(45, 15, 0.5, 0.1) plt.sca(ax[1]) plt.plot(alpha, CD) plt.xlabel("AoA") plt.ylabel("CD") set_ticks(45, 15, 0.5, 0.1) show_plot()
"Reynolds Number [-]", ) ##### Plot Polars fig, ax = plt.subplots(2, 2, figsize=(8, 8)) Re = 1e6 alpha_lowres = np.linspace(-15, 15, 31) ma = alpha mCL = af.CL_function(alpha, Re) mCD = af.CD_function(alpha, Re) xf_run = asb.XFoil(af, Re=Re, max_iter=20).alpha(alpha_lowres) xa = xf_run["alpha"] xCL = xf_run["CL"] xCD = xf_run["CD"] plt.sca(ax[0, 0]) plt.plot(ma, mCL) plt.plot(xa, xCL, ".") plt.xlabel("Angle of Attack [deg]") plt.ylabel("Lift Coefficient $C_L$ [-]") plt.sca(ax[0, 1]) plt.plot(ma, mCD) plt.plot(xa, xCD, ".") plt.ylim(0, 0.05) plt.xlabel("Angle of Attack [deg]") plt.ylabel("Drag Coefficient $C_D$ [-]") plt.sca(ax[1, 0]) plt.plot(mCD, mCL) plt.plot(xCD, xCL, ".")
from aerosandbox.tools.pretty_plots import plt, show_plot, equal vars_to_plot = { **dyn.state, "alpha" : dyn.alpha, "beta" : dyn.beta, "speed" : dyn.speed, "altitude": dyn.altitude, "CL" : aero["CL"], "CY" : aero["CY"], "CD" : aero["CD"], "Cl" : aero["Cl"], "Cm" : aero["Cm"], "Cn" : aero["Cn"], } fig, axes = plt.subplots(6, 4, figsize=(15, 10), sharex=True) for var_to_plot, ax in zip(vars_to_plot.items(), axes.flatten(order="F")): plt.sca(ax) k, v = var_to_plot plt.plot(dyn.time, v) plt.ylabel(k) show_plot() fig, ax = plt.subplots() plt.plot(dyn.xe, dyn.altitude, "k") sc = plt.scatter(dyn.xe, dyn.altitude, c=dyn.speed, cmap=plt.get_cmap("rainbow"), zorder=4) plt.axis('equal') plt.colorbar(label="Airspeed [m/s]") show_plot("Trajectory using `asb.AeroBuildup` Flight Dynamics", "$x_e$", "$-z_e$")