Closed KikeM closed 4 years ago
Ah - thanks for bringing this up!
This is a great suggestion and I totally see where you're coming from! Unfortunately, using np.isclose
or any other numpy feature breaks automatic differentiability within CasADi ("cas", the AD engine that I've used throughout AeroSandbox v1.0.0+), which is important for coupled analysis and design optimization! In theory, it would be possible to recreate this effect with a series of nested cas.if_else()
statements, though - perhaps that's something I'll look into!
Another consideration is that realistic (optimized) designs (with some tacked-on profile drag) will almost never have CD
close to zero, as the point of CL/CD_max
is often fairly high up on the CD vs. CL polar. This line is really just there to keep the optimizer from NaNing with a divide-by-zero error in the middle of an optimization run.
Because of this, I think it's probably best to keep the line as written. However, feel free to change it in your local copy if you prefer (especially if you're not using AeroSandbox's built-in optimization tools) - there's the beauty of open-source code! :)
In the forces calculation you have this line of code:
https://github.com/peterdsharpe/AeroSandbox/blob/0bcc01ccaa3b38dd943cac52b17df777c08faa6a/aerosandbox/aerodynamics/casvlm1.py#L451
I think it is better to use
np.isclose
, as it is more robust to finding zeroes and to NaN values.Reference: https://docs.scipy.org/doc/numpy/reference/generated/numpy.isclose.html