|
| 1 | +using Revise |
| 2 | +using LinearAlgebra |
| 3 | +using ControlPlots |
| 4 | +using VortexStepMethod |
| 5 | + |
| 6 | +# Step 1: Define wing parameters |
| 7 | +n_panels = 20 # Number of panels |
| 8 | +span = 20.0 # Wing span [m] |
| 9 | +chord = 1.0 # Chord length [m] |
| 10 | +v_a = 20.0 # Magnitude of inflow velocity [m/s] |
| 11 | +density = 1.225 # Air density [kg/m³] |
| 12 | +alpha_deg = 30.0 # Angle of attack [degrees] |
| 13 | +alpha = deg2rad(alpha_deg) |
| 14 | + |
| 15 | +# Step 2: Create wing geometry with linear panel distribution |
| 16 | +wing = Wing(n_panels, spanwise_panel_distribution="linear") |
| 17 | + |
| 18 | +# Add wing sections - defining only tip sections with inviscid airfoil model |
| 19 | +add_section!(wing, |
| 20 | + [0.0, span/2, 0.0], # Left tip LE |
| 21 | + [chord, span/2, 0.0], # Left tip TE |
| 22 | + "inviscid") |
| 23 | +add_section!(wing, |
| 24 | + [0.0, -span/2, 0.0], # Right tip LE |
| 25 | + [chord, -span/2, 0.0], # Right tip TE |
| 26 | + "inviscid") |
| 27 | + |
| 28 | +# Step 3: Initialize aerodynamics |
| 29 | +wa = WingAerodynamics([wing]) |
| 30 | + |
| 31 | +# Set inflow conditions |
| 32 | +vel_app = [cos(alpha), 0.0, sin(alpha)] .* v_a |
| 33 | +set_va!(wa, (vel_app, 0.0)) # Second parameter is yaw rate |
| 34 | + |
| 35 | +# Step 4: Initialize solvers for both LLT and VSM methods |
| 36 | +vsm_solver = Solver(aerodynamic_model_type="VSM") |
| 37 | + |
| 38 | +# Benchmark setup |
| 39 | +velocity_induced = zeros(3) |
| 40 | +tempvel = zeros(3) |
| 41 | +panel = wa.panels[1] |
| 42 | +ep = [0.25, 9.5, 0.0] |
| 43 | +evaluation_point_on_bound = true |
| 44 | +va_norm = 20.0 |
| 45 | +va_unit = [0.8660254037844387, 0.0, 0.4999999999999999] |
| 46 | +core_radius_fraction = 1.0e-20 |
| 47 | +gamma = 1.0 |
| 48 | + |
| 49 | +# Create work vectors tuple |
| 50 | +work_vectors = ntuple(_ -> zeros(3), 10) |
| 51 | + |
| 52 | +using BenchmarkTools |
| 53 | +@btime VortexStepMethod.calculate_velocity_induced_single_ring_semiinfinite!( |
| 54 | + $velocity_induced, |
| 55 | + $tempvel, |
| 56 | + $panel.filaments, |
| 57 | + $ep, |
| 58 | + $evaluation_point_on_bound, |
| 59 | + $va_norm, |
| 60 | + $va_unit, |
| 61 | + $gamma, |
| 62 | + $core_radius_fraction, |
| 63 | + $work_vectors |
| 64 | +) |
| 65 | + |
| 66 | +U_2D = zeros(3) |
| 67 | + |
| 68 | +@btime VortexStepMethod.calculate_velocity_induced_bound_2D!( |
| 69 | + $U_2D, |
| 70 | + $panel, |
| 71 | + $ep, |
| 72 | + $work_vectors |
| 73 | +) |
| 74 | + |
| 75 | +nothing |
0 commit comments