-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speed up the airfoil drag calculations #118
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #118 +/- ##
==========================================
- Coverage 78.49% 78.43% -0.06%
==========================================
Files 79 79
Lines 13499 13514 +15
==========================================
+ Hits 10596 10600 +4
- Misses 2903 2914 +11 ☔ View full report in Codecov by Sentry. |
9ef62ab
to
5e1bcf6
Compare
0f2839c
to
43661ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks good to me. The aerodynamic functions in airfun.jl
in general are the least readable in all of TASOPT: they have essentially no comments or documentation and the variable names are not descriptive. Since the PR is not any worse in this regard than main, I believe it can be pulled in.
@@ -34,29 +34,28 @@ Looks up airfoil performance data at specified conditions, as precomputed and fo | |||
end | |||
|
|||
@views function airfun(cl, τ, Mach, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function in general is very poorly commented. Not relevant for this PR but this is very hard to interpret.
@@ -125,26 +135,48 @@ Returns im and io s.t. `xarr[im] < x < xarr[io]`. | |||
|
|||
Additionally returns the interval `dx = xarr[io] - xarr[im]` | |||
""" | |||
function findsegment(x::Float64, xarr::AbstractArray{Float64}) | |||
function findsegment(x::Float64, xarr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These functions have no comments or documentation.
@@ -87,12 +81,12 @@ function surfcd2( | |||
Snorm = 0.0 | |||
ARe = wing.airsection.Re | |||
|
|||
for i = 1:n/2 | |||
frac = (float(i) - 0.5) / float(n / 2) | |||
for i = 1:n÷2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to comment on why the integer division is used
1. Stop searching for the right interval over and over and over. 2. Make functions type stable.
c152882
to
383570a
Compare
This PR makes some improvements to the airfoil drag calculations to speed up the airsection calculations by roughly ~5x. The airfoil type wasn't really type stable/ it's field types weren't inferable by the compiler. Also the spline evaluations have been cleaned up a little and optimized for better performance.
On my M2 mac the performance of the airfoil section calculations are:
This PR: