Skip to content

Commit 0de226e

Browse files
committed
add gamma dist field
1 parent 6c77535 commit 0de226e

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/solver.jl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Struct for storing the solution of the [solve!](@ref) function. Must contain all info needed by `KiteModels.jl`.
66
77
# Attributes
8+
- gamma_distribution::Union{Nothing, Vector{Float64}}: Vector containing the panel circulations
89
- aero_force::MVec3: Aerodynamic force vector in KB reference frame [N]
910
- aero_moments::MVec3: Aerodynamic moments [Mx, My, Mz] around the reference point [Nm]
1011
- force_coefficients::MVec3: Aerodynamic force coefficients [CFx, CFy, CFz] [-]
@@ -13,7 +14,8 @@ Struct for storing the solution of the [solve!](@ref) function. Must contain all
1314
- moment_coefficient_distribution::Vector{Float64}: Pitching moment coefficient around the spanwise vector of each panel. [-]
1415
- solver_status::SolverStatus: enum, see [SolverStatus](@ref)
1516
"""
16-
mutable struct VSMSolution
17+
mutable struct VSMSolution
18+
gamma_distribution::Union{Nothing, Vector{Float64}}
1719
aero_force::MVec3
1820
aero_moments::MVec3
1921
force_coefficients::MVec3
@@ -24,7 +26,7 @@ mutable struct VSMSolution
2426
end
2527

2628
function VSMSolution()
27-
VSMSolution(zeros(MVec3), zeros(MVec3), zeros(MVec3), zeros(MVec3), zeros(3), zeros(3), FAILURE)
29+
VSMSolution(nothing, zeros(MVec3), zeros(MVec3), zeros(MVec3), zeros(MVec3), zeros(3), zeros(3), FAILURE)
2830
end
2931

3032
"""
@@ -79,7 +81,7 @@ sol::VSMSolution = VSMSolution(): The result of calling [solve!](@ref)
7981
end
8082

8183
"""
82-
solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=nothing;
84+
solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=solver.sol.gamma_distribution;
8385
log=false, reference_point=zeros(MVec3), moment_frac=0.1)
8486
8587
Main solving routine for the aerodynamic model. Reference point is in the kite body (KB) frame.
@@ -99,15 +101,20 @@ a dictionary.
99101
# Returns
100102
The solution of type [VSMSolution](@ref)
101103
"""
102-
function solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=nothing;
104+
function solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=solver.sol.gamma_distribution;
103105
log=false, reference_point=zeros(MVec3), moment_frac=0.1)
104106

105107
# calculate intermediate result
106-
converged,
108+
(converged,
107109
body_aero, gamma_new, reference_point, density, aerodynamic_model_type, core_radius_fraction,
108110
mu, alpha_array, v_a_array, chord_array, x_airf_array, y_airf_array, z_airf_array,
109111
va_array, va_norm_array, va_unit_array, panels,
110-
is_only_f_and_gamma_output = solve_base(solver, body_aero, gamma_distribution; log, reference_point)
112+
is_only_f_and_gamma_output) = solve_base(solver, body_aero, gamma_distribution; log, reference_point)
113+
if !isnothing(solver.sol.gamma_distribution)
114+
solver.sol.gamma_distribution .= gamma_new
115+
else
116+
solver.sol.gamma_distribution = gamma_new
117+
end
111118

112119
# Initialize arrays
113120
n_panels = length(panels)

0 commit comments

Comments
 (0)