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

don't use generate_polar_function before AeroBuildup.run() #99

Closed Zcaic closed 11 months ago

Zcaic commented 11 months ago

In aerosandbox new version, when I define airfoil without calling generate_polar_function, then I use AreoBuildup to calculate aerodynamic, is there any different from calling generate_polar_function, Or if I don‘t call generate_polar_function manually, AeroBuildup.run() will call generate_polar_function automatically?

Zcaic commented 11 months ago

Now I know via read AeroBuildup code, I found it will call get_aero_from_neuralfoil() for aerofoil, So does this mean that I don't need to call generate_polar_function() explicitly?

peterdsharpe commented 11 months ago

Hey @Zcaic !

In AeroSandbox v4.1.0 and higher, asb.Airfoil.generate_polars() is no longer needed when performing asb.AeroBuildup analyses. (As you note, AeroBuildup now completely bypasses XFoil and instead only uses NeuralFoil. NeuralFoil requires no caching.) The output of AeroBuildup does not change whether you call asb.Airfoil.generate_polars() or not.

In previous versions of AeroSandbox (v4.0.9 and lower), users had to call asb.Airfoil.generate_polars() to build up an XFoil data-table (stored in asb.Airfoil.xfoil_data), so that AeroBuildup could analyze 2D wing sections. Now, that is no longer needed. :)

The asb.Airfoil.generate_polars() method may be deprecated in some future version (unless there is user demand otherwise), as it is no longer used internally within AeroSandbox. And, its performance is wholly superseded by asb.Airfoil.get_aero_from_neuralfoil().

Zcaic commented 11 months ago

hhh, I'm glad to hear it! And I modified some code about Airplane.generate_cadquery_geometry() function. Beaceuse when export *.step, I found it miss a leading edge like below: before

So I modify code in Airplane.generate_cadquery_geometry():

...
af = xsec.airfoil
if af.TE_thickness() < minimum_airfoil_TE_thickness:
       af = af.set_TE_thickness(thickness=minimum_airfoil_TE_thickness)

leindex = af.LE_index()
wp = cq.Workplane(
                    inPlane=cq.Plane(
                        origin=tuple(xsec.xyz_le),
                        xDir=tuple(csys[0]),
                        normal=tuple(-csys[1]),
                    )
                )
upperspline = wp.spline(
          listOfXYTuple=[
                        tuple(xy * xsec.chord) for xy in af.coordinates[: leindex + 1]
                    ]
        ).spline(
                    listOfXYTuple=[
                        tuple(xy * xsec.chord) for xy in af.coordinates[leindex:]
                    ]
         ).close()
xsec_wires.append(upperspline)

wire_collection = xsec_wires[0]
...

And the step file like below: after

Of course, It doesn't have any effect on aerosandbox, Maybe it is only a little helpful to get leading edge feature lines for those who want to generate mesh from cad file.

peterdsharpe commented 11 months ago

Oh awesome, that looks excellent! Your change also probably improves the accuracy of the STEP representation - one possible geometric inaccuracy of the previous code was if the wing section loft gets "twisted" when sweeping between two adjacent airfoil cross sections (i.e., the same effect as getting a hyperboloid from twisting a cylinder loft). This could happen if, for example, the airfoils at the inboard and outboard cross sections had a very different number of points or point spacing. By adding a leading-edge node into the spline, it constrains any possible twisting, at least at the critical leading-edge point. Nice work!

It would be great to merge your improvements into Airplane.generate_cadquery_geometry(). Feel free to submit a pull request (if you want to get GitHub "credit" for your contribution), or I can copy-paste add it for you if that's easier. Good find!

Zcaic commented 11 months ago

I'm happy that it is useful for aerosandbox. You can copy-paste directly because it is a small change.