@@ -109,7 +109,10 @@ function init!(body_aero::BodyAerodynamics;
109109
110110 idx = 1
111111 for wing in body_aero. wings
112- @time panel_props = init! (wing; aero_center_location, control_point_location)
112+ println (" init wing" )
113+ @time init! (wing; aero_center_location, control_point_location)
114+ # @assert false
115+ panel_props = wing. panel_props
113116
114117 # Create panels
115118 @time for i in 1 : wing. n_panels
@@ -122,19 +125,18 @@ function init!(body_aero::BodyAerodynamics;
122125 body_aero. panels[idx],
123126 wing. refined_sections[i],
124127 wing. refined_sections[i+ 1 ],
125- panel_props. aero_centers[i],
126- panel_props. control_points[i],
127- panel_props. bound_points_1[i],
128- panel_props. bound_points_2[i],
129- panel_props. x_airf[i],
130- panel_props. y_airf[i],
131- panel_props. z_airf[i],
128+ panel_props. aero_centers[i, : ],
129+ panel_props. control_points[i, : ],
130+ panel_props. bound_points_1[i, : ],
131+ panel_props. bound_points_2[i, : ],
132+ panel_props. x_airf[i, : ],
133+ panel_props. y_airf[i, : ],
134+ panel_props. z_airf[i, : ],
132135 delta;
133136 remove_nan= wing. remove_nan
134137 )
135138 idx += 1
136139 end
137- @assert false
138140 end
139141
140142 # Initialize rest of the struct
@@ -161,116 +163,6 @@ function Base.setproperty!(obj::BodyAerodynamics, sym::Symbol, val)
161163 end
162164end
163165
164- """
165- PanelProperties
166-
167- Structure to hold calculated panel properties.
168-
169- # Fields
170- - `aero_centers`::Matrix{Float64}
171- - `control_points`::Matrix{Float64}
172- - `bound_points_1`::Matrix{Float64}
173- - `bound_points_2`::Matrix{Float64}
174- - `x_airf`::Matrix{Float64}: Vector of unit vectors tangential to chord line
175- - `y_airf`::Matrix{Float64}: Vector of unit vectors in spanwise direction
176- - `z_airf`::Matrix{Float64}: Vector of unit vectors pointing up (cross of x_airf and y_airf)
177- """
178- @with_kw mutable struct PanelProperties{P}
179- aero_centers:: Matrix{Float64} = zeros (P, 3 )
180- control_points:: Matrix{Float64} = zeros (P, 3 )
181- bound_points_1:: Matrix{Float64} = zeros (P, 3 )
182- bound_points_2:: Matrix{Float64} = zeros (P, 3 )
183- x_airf:: Matrix{Float64} = zeros (P, 3 )
184- y_airf:: Matrix{Float64} = zeros (P, 3 )
185- z_airf:: Matrix{Float64} = zeros (P, 3 )
186- coords:: Matrix{Float64} = zeros (2 (P+ 1 ), 3 )
187- end
188-
189- """
190- update_panel_properties!(section_list::Vector{Section}, n_panels::Int,
191- aero_center_loc::Float64, control_point_loc::Float64)
192-
193- Calculate geometric properties for each panel.
194-
195- # Arguments
196- - section_list::Vector{Section}: List of [Section](@ref)s
197- - `n_panels`::Int: Number of [Panel](@ref)s
198- - `aero_center_loc`::Float64: Location of the aerodynamic center
199- - `control_point_loc`::Float64: Location of the control point
200-
201- # Returns:
202- [PanelProperties](@ref) containing vectors for each property
203- """
204- function update_panel_properties! (panel_props:: PanelProperties , section_list:: Vector{Section} , n_panels:: Int ,
205- aero_center_loc:: Float64 , control_point_loc:: Float64 )
206- coords = panel_props. coords
207- aero_centers = panel_props. aero_centers
208- control_points = panel_props. control_points
209- bound_points_1 = panel_props. bound_points_1
210- bound_points_2 = panel_props. bound_points_2
211- x_airf = panel_props. x_airf
212- y_airf = panel_props. y_airf
213- z_airf = panel_props. z_airf
214- @debug " Shape of coordinates: $(size (coords)) "
215-
216- for i in 1 : n_panels
217- coords[2 i- 1 , :] .= section_list[i]. LE_point
218- coords[2 i, :] .= section_list[i]. TE_point
219- coords[2 i+ 1 , :] .= section_list[i+ 1 ]. LE_point
220- coords[2 i+ 2 , :] .= section_list[i+ 1 ]. TE_point
221- end
222-
223- @debug " Coordinates: $coords "
224-
225- for i in 1 : n_panels
226- # Define panel points
227- section = Dict (
228- " p1" => coords[2 i- 1 , :], # LE_1
229- " p2" => coords[2 i+ 1 , :], # LE_2
230- " p3" => coords[2 i+ 2 , :], # TE_2
231- " p4" => coords[2 i, :] # TE_1
232- )
233-
234- # Calculate control point position
235- di = norm (coords[2 i- 1 , :] * 0.75 + coords[2 i, :] * 0.25 -
236- (coords[2 i+ 1 , :] * 0.75 + coords[2 i+ 2 , :] * 0.25 ))
237-
238- ncp = if i == 1
239- diplus = norm (coords[2 i+ 1 , :] * 0.75 + coords[2 i+ 2 , :] * 0.25 -
240- (coords[2 i+ 3 , :] * 0.75 + coords[2 i+ 4 , :] * 0.25 ))
241- di / (di + diplus)
242- elseif i == n_panels
243- dimin = norm (coords[2 i- 3 , :] * 0.75 + coords[2 i- 2 , :] * 0.25 -
244- (coords[2 i- 1 , :] * 0.75 + coords[2 i, :] * 0.25 ))
245- dimin / (dimin + di)
246- else
247- dimin = norm (coords[2 i- 3 , :] * 0.75 + coords[2 i- 2 , :] * 0.25 -
248- (coords[2 i- 1 , :] * 0.75 + coords[2 i, :] * 0.25 ))
249- diplus = norm (coords[2 i+ 1 , :] * 0.75 + coords[2 i+ 2 , :] * 0.25 -
250- (coords[2 i+ 3 , :] * 0.75 + coords[2 i+ 4 , :] * 0.25 ))
251- 0.25 * (dimin / (dimin + di) + di / (di + diplus) + 1 )
252- end
253-
254- ncp = 1 - ncp
255-
256- # Calculate points
257- @. aero_centers[i, :] = (section[" p2" ] * (1 - ncp) + section[" p1" ] * ncp) * 0.75 +
258- (section[" p3" ] * (1 - ncp) + section[" p4" ] * ncp) * 0.25
259-
260- @. control_points[i, :] = (section[" p2" ] * (1 - ncp) + section[" p1" ] * ncp) * 0.25 +
261- (section[" p3" ] * (1 - ncp) + section[" p4" ] * ncp) * 0.75
262-
263- @. bound_points_1[i, :] = section[" p1" ] * 0.75 + section[" p4" ] * 0.25
264- bound_points_2[i, :] = section[" p2" ] * 0.75 + section[" p3" ] * 0.25
265-
266- # Calculate reference frame vectors
267- @. z_airf[i, :] = normalize (cross (control_points[i, :] - aero_centers[i, :], section[" p1" ] - section[" p2" ]))
268- @. x_airf[i, :] = normalize (control_points[i, :] - aero_centers[i, :])
269- @. y_airf[i, :] = normalize (bound_points_1[i, :] - bound_points_2[i, :])
270- end
271- return nothing
272- end
273-
274166"""
275167 calculate_AIC_matrices!(body_aero::BodyAerodynamics, model::Model,
276168 core_radius_fraction::Float64,
0 commit comments