-
Notifications
You must be signed in to change notification settings - Fork 0
Truncate the SVD in the least-squares Kulfan fit so crowded stations give bounded weights #342
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,6 +106,8 @@ function leading_edge_basis(x::AbstractVector{T}, n_weights::Int) where T | |
| return x .* max.(1 .- x, zero(T)).^(n_weights + 0.5) | ||
| end | ||
|
|
||
| const KULFAN_FIT_RTOL = 1e-4 # [-] singular values dropped below this times the largest | ||
|
|
||
| """ | ||
| fit_kulfan_parameters(x::Vector, y::Vector, method::KulfanFitMethod) | ||
| fit_kulfan_parameters(x::Vector, y::Vector; n_weights=8) | ||
|
|
@@ -128,7 +130,8 @@ end | |
|
|
||
| Least-squares fit matching AeroSandbox's `get_kulfan_parameters`: both surfaces | ||
| share a single least-squares system with a shared leading-edge weight and a | ||
| trailing-edge thickness. | ||
| trailing-edge thickness. Singular values below `1e-4` times the largest are dropped, so | ||
| stations crowded into part of the chord give bounded weights. | ||
| """ | ||
| function fit_kulfan_parameters(x::Vector{T}, y::Vector{T}, | ||
| method::LeastSquaresFit) where T | ||
|
|
@@ -144,12 +147,11 @@ function fit_kulfan_parameters(x::Vector{T}, y::Vector{T}, | |
| te_col = ifelse.(is_upper, xv ./ 2, .-xv ./ 2) | ||
|
|
||
| A = hcat((.!is_upper) .* CS, is_upper .* CS, le_col, te_col) | ||
| coeffs = A \ y_norm | ||
| coeffs = pinv(A; rtol=KULFAN_FIT_RTOL) * y_norm | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MINOR: Truncation happens silently, so a degenerate contour now gives a plausible-looking but wrong section instead of an obviously broken one, and nothing downstream checks it. Without the resampler or thickness fixes in this branch or a tracked issue for them, the failure gets harder to spot. |
||
| TE_thickness = coeffs[end] | ||
|
|
||
| if TE_thickness < 0 | ||
| A = hcat((.!is_upper) .* CS, is_upper .* CS, le_col) | ||
| coeffs = A \ y_norm | ||
| coeffs = pinv(A[:, 1:end-1]; rtol=KULFAN_FIT_RTOL) * y_norm | ||
| TE_thickness = zero(T) | ||
| end | ||
|
|
||
|
|
||
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.
MINOR: The entry says a crowded contour now fits to an airfoil-sized shape, but the card's own table shows the 0.03-band case still comes out 15× too thick. The entry should say the weights are bounded, not that the shape is correct, or users will trust sections that are still wrong.