Skip to content

Commit f166b27

Browse files
authored
fix tests (#104)
1 parent 9a00194 commit f166b27

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

src/body_aerodynamics.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ Structure to hold calculated panel properties.
168168
- `control_points`::Vector{MVec3}
169169
- `bound_points_1`::Vector{MVec3}
170170
- `bound_points_2`::Vector{MVec3}
171-
- `x_airf`::Vector{MVec3}: Vector of unit vectors perpendicular to chord line
172-
- `y_airf`::Vector{MVec3}: Vector of unit vectors parallel to chord line
173-
- `z_airf`::Vector{MVec3}: Vector of unit vectors in spanwise direction
171+
- `x_airf`::Vector{MVec3}: Vector of unit vectors tangential to chord line
172+
- `y_airf`::Vector{MVec3}: Vector of unit vectors in spanwise direction
173+
- `z_airf`::Vector{MVec3}: Vector of unit vectors pointing up (cross of x_airf and y_airf)
174174
"""
175175
struct PanelProperties
176176
aero_centers::Vector{MVec3}

src/solver.jl

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ function solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=
132132
body_aero,
133133
gamma_new,
134134
core_radius_fraction,
135+
z_airf_array,
135136
x_airf_array,
136-
y_airf_array,
137137
va_array,
138138
va_norm_array,
139139
va_unit_array
@@ -166,22 +166,19 @@ function solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=
166166

167167
for (i, panel) in enumerate(panels) # 30625 bytes
168168

169+
### Lift and Drag ###
169170
# Panel geometry
170-
z_airf_span = panel.z_airf
171-
y_airf_chord = panel.y_airf
172-
x_airf_normal = panel.x_airf
173-
# panel_moment_point = 0.5(panel.LE_point_1 + panel.LE_point_2) .+ y_airf_chord .* moment_frac
174171
panel_area = panel.chord * panel.width
175172
area_all_panels += panel_area
176173

177174
# Calculate induced velocity direction
178175
alpha_corrected_i = alpha_corrected[i]
179-
induced_va_airfoil = cos(alpha_corrected_i) * y_airf_chord +
180-
sin(alpha_corrected_i) * x_airf_normal
176+
induced_va_airfoil = cos(alpha_corrected_i) * panel.x_airf +
177+
sin(alpha_corrected_i) * panel.z_airf
181178
dir_induced_va_airfoil = induced_va_airfoil / norm(induced_va_airfoil)
182179

183180
# Calculate lift and drag directions
184-
dir_lift_induced_va = cross(dir_induced_va_airfoil, z_airf_span)
181+
dir_lift_induced_va = cross(dir_induced_va_airfoil, panel.y_airf)
185182
dir_lift_induced_va = dir_lift_induced_va / norm(dir_lift_induced_va)
186183
dir_drag_induced_va = cross(spanwise_direction, dir_lift_induced_va)
187184
dir_drag_induced_va = dir_drag_induced_va / norm(dir_drag_induced_va)
@@ -194,15 +191,15 @@ function solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=
194191
# Calculate forces in prescribed wing frame
195192
dir_lift_prescribed_va = cross(va, spanwise_direction)
196193
dir_lift_prescribed_va = dir_lift_prescribed_va / norm(dir_lift_prescribed_va)
197-
194+
198195
# Calculate force components
199196
lift_prescribed_va = dot(lift_induced_va, dir_lift_prescribed_va) +
200-
dot(drag_induced_va, dir_lift_prescribed_va)
197+
dot(drag_induced_va, dir_lift_prescribed_va)
201198
drag_prescribed_va = dot(lift_induced_va, va_unit) +
202-
dot(drag_induced_va, va_unit)
199+
dot(drag_induced_va, va_unit)
203200
side_prescribed_va = dot(lift_induced_va, spanwise_direction) +
204-
dot(drag_induced_va, spanwise_direction)
205-
201+
dot(drag_induced_va, spanwise_direction)
202+
206203
# Body frame forces
207204
f_body_3D[:,i] .= ftotal_induced_va .* panel.width
208205

@@ -216,8 +213,8 @@ function solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=
216213
panel_ac_body = panel.aero_center # 3D [x, y, z]
217214
# (2) Convert local (2D) pitching moment to a 3D vector in body coords.
218215
# Use the axis around which the moment is defined,
219-
# which is the z-axis pointing "spanwise"
220-
moment_axis_body = panel.z_airf
216+
# which is the y-axis pointing "spanwise"
217+
moment_axis_body = panel.y_airf
221218
M_local_3D = moment[i] * moment_axis_body * panel.width
222219
# Vector from panel AC to the chosen reference point:
223220
r_vector = panel_ac_body - reference_point # e.g. CG, wing root, etc.
@@ -228,7 +225,7 @@ function solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=
228225

229226
# Calculate the moment distribution (moment on each panel)
230227
arm = (moment_frac - 0.25) * panel.chord
231-
moment_distribution[i] = dot(ftotal_induced_va, x_airf_normal) * arm
228+
moment_distribution[i] = dot(ftotal_induced_va, panel.z_airf) * arm
232229
end
233230

234231
# Calculate wing geometry properties

0 commit comments

Comments
 (0)