Skip to content

Commit e5e1452

Browse files
committed
Refactoring
1 parent 98e2b2c commit e5e1452

5 files changed

Lines changed: 15 additions & 18 deletions

File tree

examples/bench.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ vsm_solver = Solver{P}(aerodynamic_model_type=VSM)
4646
# Step 5: Solve using both methods
4747
results_vsm = solve(vsm_solver, wa)
4848
sol = solve!(vsm_solver, wa)
49-
results_vsm_base = solve_base(vsm_solver, wa)
50-
println("Rectangular wing, solve_base:")
51-
@time results_vsm_base = solve_base(vsm_solver, wa)
52-
# time Python: 32.0 ms Ryzen 7950x
53-
# time Julia: 0.6 ms Ryzen 7950x
54-
# 0.8 ms laptop, performance mode, battery
49+
results_vsm_base = solve_base!(vsm_solver, wa)
50+
println("Rectangular wing, solve_base!:")
51+
@time results_vsm_base = solve_base!(vsm_solver, wa)
52+
# time Python: 32.0 ms Ryzen 7950x
53+
# time Julia: 0.42 ms Ryzen 7950x
5554
println("Rectangular wing, solve!:")
5655
@time sol = solve!(vsm_solver, wa)
5756
println("Rectangular wing, solve:")
@@ -83,8 +82,8 @@ set_va!(body_aero, vel_app)
8382

8483
# Solving and plotting distributions
8584
results = solve(vsm_solver, body_aero)
86-
results_base = solve_base(vsm_solver, body_aero)
85+
results_base = solve_base!(vsm_solver, body_aero)
8786
println("RAM-air kite:")
88-
@time results_base = solve_base(vsm_solver, body_aero)
87+
@time results_base = solve_base!(vsm_solver, body_aero)
8988

9089
nothing

src/VortexStepMethod.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using Pkg
2121
# Export public interface
2222
export Wing, Section, RamAirWing
2323
export BodyAerodynamics
24-
export Solver, solve, solve_base, solve!, VSMSolution
24+
export Solver, solve, solve_base!, solve!, VSMSolution
2525
export calculate_results
2626
export add_section!, set_va!
2727
export calculate_span, calculate_projected_area

src/body_aerodynamics.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,7 @@ function update_effective_angle_of_attack_if_VSM(body_aero::BodyAerodynamics,
438438
va_unit_array::Matrix{Float64})
439439

440440
# Calculate AIC matrices (keep existing optimized view)
441-
calculate_AIC_matrices!(
442-
body_aero, LLT, core_radius_fraction, va_norm_array, va_unit_array
443-
)
441+
calculate_AIC_matrices!(body_aero, LLT, core_radius_fraction, va_norm_array, va_unit_array)
444442
AIC_x, AIC_y, AIC_z = @views body_aero.AIC[1, :, :], body_aero.AIC[2, :, :], body_aero.AIC[3, :, :]
445443

446444
# Preallocate and calculate induced velocity directly

src/solver.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Struct for storing the solution of the [solve!](@ref) function. Must contain all
1515
- solver_status::SolverStatus: enum, see [SolverStatus](@ref)
1616
"""
1717
@with_kw mutable struct VSMSolution{P}
18-
### private vectors of solve_base
18+
### private vectors of solve_base!
1919
x_airf_array::Matrix{Float64} = zeros(P, 3)
2020
y_airf_array::Matrix{Float64} = zeros(P, 3)
2121
z_airf_array::Matrix{Float64} = zeros(P, 3)
@@ -146,7 +146,7 @@ function solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=
146146
log=false, reference_point=zeros(MVec3), moment_frac=0.1)
147147

148148
# calculate intermediate result
149-
solve_base(solver, body_aero, gamma_distribution; log, reference_point)
149+
solve_base!(solver, body_aero, gamma_distribution; log, reference_point)
150150
gamma_new = solver.lr.gamma_new
151151
if !isnothing(solver.sol.gamma_distribution)
152152
solver.sol.gamma_distribution .= gamma_new
@@ -312,7 +312,7 @@ A dictionary with the results.
312312
function solve(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=nothing;
313313
log=false, reference_point=zeros(MVec3))
314314
# calculate intermediate result
315-
solve_base(solver, body_aero, gamma_distribution; log, reference_point)
315+
solve_base!(solver, body_aero, gamma_distribution; log, reference_point)
316316

317317
# Calculate final results as dictionary
318318
results = calculate_results(
@@ -344,7 +344,7 @@ end
344344
end
345345
end
346346

347-
function solve_base(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=nothing;
347+
function solve_base!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=nothing;
348348
log=false, reference_point=zeros(MVec3))
349349

350350
# check arguments

test/bench2.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ P = length(wa.panels)
4343
vsm_solver = Solver{P}(aerodynamic_model_type=VSM)
4444

4545
# Step 5: Solve using both methods
46-
println("Rectangular wing, solve_base:")
47-
@btime results_vsm_base = solve_base($vsm_solver, $wa) # 112 allocations
46+
println("Rectangular wing, solve_base!:")
47+
@btime results_vsm_base = solve_base!($vsm_solver, $wa) # 112 allocations
4848
# time Python: 32.0 ms Ryzen 7950x
4949
# time Julia: 0.6 ms Ryzen 7950x
5050
# 0.47 ms laptop, performance mode, grid

0 commit comments

Comments
 (0)