Skip to content

Commit ec46c4d

Browse files
committed
Add test and fix bug
1 parent 4d84d2f commit ec46c4d

2 files changed

Lines changed: 44 additions & 5 deletions

File tree

src/solver.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,11 @@ function gamma_loop!(
825825
reltol = solver.rtol,
826826
)
827827
solver.nonlin_cache = nonlin_cache
828+
else
829+
SciMLBase.reinit!(
830+
nonlin_cache, solver.lr.gamma_new;
831+
p=SciMLBase.NullParameters(),
832+
)
828833
end
829834
sol = NonlinearSolve.solve!(nonlin_cache)
830835
gamma .= sol.u

test/solver/test_solver.jl

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,62 @@ end
99
@testset "Solver Constructor with VSMSettings" begin
1010
# Use module-specific test data files
1111
settings_file = create_temp_wing_settings("solver", "solver_test_wing.yaml"; alpha=5.0, beta=0.0, wind_speed=10.0)
12-
12+
1313
try
1414
# Test Solver constructor with VSMSettings
1515
settings = VSMSettings(settings_file)
1616
wing = Wing(settings)
1717
refine!(wing)
1818
body_aero = BodyAerodynamics([wing])
1919
solver = Solver(body_aero, settings)
20-
20+
2121
# Verify solver properties match settings
2222
@test solver.aerodynamic_model_type == VSM
2323
@test solver.density == 1.225
24-
25-
# Test that the solver can solve
24+
25+
# Test that the solver can solve
2626
va = [10.0, 0.0, 0.0]
2727
set_va!(body_aero, va)
2828
sol = solve!(solver, body_aero)
2929
@test sol isa VSMSolution
30-
30+
3131
finally
3232
# Cleanup
3333
rm(settings_file; force=true)
3434
end
3535
end
3636
end
37+
38+
@testset "NONLIN solve! re-runs across calls" begin
39+
settings_file = create_temp_wing_settings(
40+
"solver", "solver_test_wing.yaml";
41+
alpha=5.0, beta=0.0, wind_speed=10.0,
42+
)
43+
try
44+
settings = VSMSettings(settings_file)
45+
wing = Wing(settings)
46+
refine!(wing)
47+
48+
body_aero = BodyAerodynamics([wing])
49+
solver = Solver(
50+
body_aero;
51+
solver_type=NONLIN,
52+
aerodynamic_model_type=VSM,
53+
type_initial_gamma_distribution=ELLIPTIC,
54+
)
55+
56+
set_va!(body_aero, [10.0, 0.0, 0.0])
57+
solve!(solver, body_aero)
58+
gamma_low = copy(solver.sol.gamma_distribution)
59+
60+
set_va!(body_aero, [10.0, 0.0, 5.0])
61+
solve!(solver, body_aero)
62+
gamma_high = copy(solver.sol.gamma_distribution)
63+
64+
@test !isapprox(gamma_low, gamma_high; atol=1e-6, rtol=1e-4)
65+
@test norm(gamma_high .- gamma_low) >
66+
1e-3 * max(norm(gamma_low), norm(gamma_high))
67+
finally
68+
rm(settings_file; force=true)
69+
end
70+
end

0 commit comments

Comments
 (0)