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

Fresh install of pip install aerosandbox[full,test], and it fails one test #129

Closed carsonwmoon closed 2 weeks ago

carsonwmoon commented 3 months ago

Bug Description / Observed Behavior

The following pytest error was returned after a fresh install of pip install aerosandbox[full,test] and asb.run_tests() in python.

================================================================================== FAILURES ================================================================================== __ test_repaneling_validity __

def test_repaneling_validity():
    try:
        import shapely
    except ModuleNotFoundError:
        pytest.skip("Shapely not installed; skipping this test.")

    afs = get_airfoil_database()

    for af in afs:
        try:
            similarity = af.jaccard_similarity(
                af.repanel()
            )
        except shapely.errors.GEOSException:
            similarity = np.nan
       assert similarity > 1 - 3 / af.n_points(), f"Airfoil {af.name} failed repaneling validity check with similarity {similarity}!"

E AssertionError: Airfoil hm50 failed repaneling validity check with similarity nan! E assert nan > (1 - (3 / 484)) E + where 484 = <bound method Polygon.n_points of Airfoil hm50 (484 points)>() E + where <bound method Polygon.n_points of Airfoil hm50 (484 points)> = Airfoil hm50 (484 points).n_points

.conda\Lib\site-packages\aerosandbox\geometry\airfoil\test_airfoil\test_airfoil_repaneling.py:34: AssertionError

Steps to Reproduce

Expected Behavior

====================== 250 passed, 36 warnings in 17.89s =======================

System Information

Other Information

peterdsharpe commented 3 months ago

Thank you for the report!

This is an issue I've been tracking lately, and it has to do with one of the recently-added airfoils to the built-in airfoil database, called "hm50". (This particular airfoil comes from the TRACfoil database.) Basically this airfoil has a near-zero trailing edge angle, which causes shapely to raise a geometric error upon repaneling (since it looks like a self-intersecting shape). This is a bit of an edge case, since most practical airfoils have a nonzero trailing edge angle.

Here's the airfoil, for a closer look at the zero-angle trailing edge: image

If this is the only error you're seeing, feel free to safely ignore this (as it will not have an effect outside of this edge case). In the meantime, we're working on a solution to handle these airfoils more gracefully in testing.