peterdsharpe / AeroSandbox

Aircraft design optimization made fast through modern automatic differentiation. Composable analysis tools for aerodynamics, propulsion, structures, trajectory design, and much more.
https://peterdsharpe.github.io/AeroSandbox/
MIT License
687 stars 111 forks source link

Incorrect Inviscid Airfoil Analysis #54

Closed GodotMisogi closed 3 years ago

GodotMisogi commented 3 years ago

Bug Description

Running an inviscid analysis on a NACA 0012 airfoil at 0 degrees angle of attack produces non-zero lift coefficient.

Steps to Reproduce

from aerosandbox import Airfoil, AirfoilInviscid, OperatingPoint
a = AirfoilInviscid(
    airfoil=[
        Airfoil("naca0012")
            .repanel(50)
    ],
    op_point=OperatingPoint(
        velocity=1,
        alpha=0,
    )
)
print(f"CL: {a.Cl}")

CL: -0.17311351475463538

Expected Behavior

CL: 0

System Information

peterdsharpe commented 3 years ago

Interesting! Looks like a bug with how the trailing-edge panel is being handled; here's the C_p distribution for the NACA0012 run: (plotted via a.draw_cp()) image

I think I figured out what's wrong. The source panel that's created to bridge the nonzero trailing edge gap had source strength that linearly varied between gamma_TE and -gamma_TE; instead it needs to be uniform and equal to gamma_TE.

I just fixed this bug and can verify that the NACA0012 is returning C_L = 0 to within machine precision. Now, we get the correct C_p distribution, without the trailing edge funkiness: image

We can also plot the streamlines (via a.draw_streamlines()): image

And this looks like about what we would expect.

Thank you so much for catching this! :) I'm surprised this wasn't caught in unit testing - looks like I need to add more tests for nonzero-TE cases!

Patch will be pushed in a few minutes.

peterdsharpe commented 3 years ago

Version 3.0.14 just pushed, which includes this fix c43e79a2ff91ce98934a97f91c89d64415718808! Should be available via pip install --upgrade aerosandbox in just a few minutes after automated tests run.

peterdsharpe commented 3 years ago

Also, a unit test has been added for this case: 749cab5a2da3877013e122071f510c6ef377bb6b

GodotMisogi commented 3 years ago

Great, thanks for the quick fix! I suspected as much that there was some issue with the trailing edge after visualising the pressure coefficient distribution, but I assumed it may be due to an issue in enforcement of the Kutta condition. Some techniques, such as the constant-strength doublet-source panel method, do suffer from similar "spikes" at the trailing edge, and blunt ones are sometimes pretty screwy!