Skip to content

Commit 9e7e320

Browse files
authored
Merge pull request #294 from OpenSourceAWE/agent/BeyondTheSim.jl-17
Fit the contour generate_airfoils is handed, not a second wrap of it
2 parents 0d7097b + 4b261f0 commit 9e7e320

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929

3030
### Fixed
3131

32+
- `generate_airfoils` fits the contour it is handed rather than shrink-wrapping it a
33+
second time. Both adapters wrap before they call, with the `wrap_method` their
34+
settings name, so the second wrap discarded that setting and degenerated the Kulfan
35+
fit: on the SK100's 45 mesh sections nine came out with `.dat` coordinates at 1e2 to
36+
1e4 instead of 0..1, and any consumer mapping the mesh onto a structure rejected the
37+
geometry.
3238
- The `NONLIN` solver backtracks along each Newton step instead of always taking
3339
it whole, so it converges past stall where the full step used to cycle: on the
3440
`test/solver/solver_test_wing.yaml` wing at 26.6° it stopped 3.6% below `LOOP`'s

src/airfoil_aero/geometry_gen.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ function generate_airfoils(airfoils, output_dir::String;
4242
alphas = deg2rad.(collect(Float64, alpha_range))
4343
deltas = isnothing(delta_range) ? [0.0] :
4444
deg2rad.(collect(Float64, delta_range))
45-
aero, sols = generate_airfoil_aero(aero_solver, af.x_fit, af.y_fit;
45+
aero, sols = generate_airfoil_aero(aero_solver,
46+
fit_kulfan_parameters(af.x_fit, af.y_fit, LeastSquaresFit());
4647
alpha_range=alphas, delta_range=deltas,
4748
reynolds_number=Float64(Re), crease_frac)
4849
clvals = collect(sol.cl for sol in sols[1])

test/airfoil_aero/test_airfoil_aero.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,20 @@ end
271271
cp(joinpath(weights_dir, "nn-medium.npz"), joinpath(partial, "nn-medium.npz"))
272272
@test_throws ErrorException load_neuralfoil_model("medium"; weights_dir=partial)
273273
end
274+
275+
@testset "generate_airfoils fits the wrapped contour it is handed" begin
276+
x_raw, y_raw = read_dat_coords(joinpath(@__DIR__, "data", "test_airfoil.dat"))
277+
x_fit, y_fit = shrink_wrap(x_raw, y_raw, ShrinkWrap(clearance=0.0))
278+
_, fitted_y = kulfan_to_coordinates(
279+
fit_kulfan_parameters(x_fit, y_fit, LeastSquaresFit()))
280+
out = mktempdir()
281+
_, ok = generate_airfoils([(; id=1, x_fit, y_fit, x_raw, y_raw)], out;
282+
Re=5e5, alpha_range=-2:2:2,
283+
aero_solver=NeuralFoilSolver(model_size="medium"), verbose=false)
284+
@test ok == [1]
285+
_, written_y = read_dat_coords(joinpath(out, "airfoils", "1.dat"))
286+
# A second shrink wrap inflates the section by its own clearance, 0.006, which is
287+
# three orders of magnitude above the resampling error this tolerance allows.
288+
@test maximum(abs, collect(extrema(written_y)) .-
289+
collect(extrema(fitted_y))) < 1e-4
290+
end

0 commit comments

Comments
 (0)