diff --git a/.gitignore b/.gitignore index ae204086..35a21b6a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ results/TUDELFT_V3_LEI_KITE/polars/$C_L$ vs $C_D$.pdf *.bin results/TUDELFT_V3_LEI_KITE/polars/tutorial_testing_stall_model_n_panels_54_distribution_split_provided.pdf docs/build/ +results/TUDELFT_V3_LEI_KITE/polars/tutorial_testing_stall_model_n_panels_54_distribution_SPLIT_PROVIDED.pdf diff --git a/docs/make.jl b/docs/make.jl index 7811cb9b..0b8a042a 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -18,6 +18,7 @@ makedocs(; pages=[ "Home" => "index.md", "How it works" => "explanation.md", + "Examples" => "examples.md", "Exported Functions" => "functions.md", "Exported Types" => "types.md", "Private Functions" => "private_functions.md", diff --git a/docs/src/Polars.png b/docs/src/Polars.png new file mode 100644 index 00000000..51769191 Binary files /dev/null and b/docs/src/Polars.png differ diff --git a/docs/src/RectangularWing.png b/docs/src/RectangularWing.png new file mode 100644 index 00000000..aaf6d436 Binary files /dev/null and b/docs/src/RectangularWing.png differ diff --git a/docs/src/SpanwiseDistributions.png b/docs/src/SpanwiseDistributions.png new file mode 100644 index 00000000..3ad2d290 Binary files /dev/null and b/docs/src/SpanwiseDistributions.png differ diff --git a/docs/src/examples.md b/docs/src/examples.md new file mode 100644 index 00000000..94b4ae77 --- /dev/null +++ b/docs/src/examples.md @@ -0,0 +1,150 @@ +```@meta +CurrentModule = VortexStepMethod +``` + +## Wing Aerodynamics Analysis using Vortex-Step Method (VSM) and Lift Line Theory (LLT) +This example demonstrates the process of setting up and analyzing a wing's aerodynamics using VSM and LLT. We'll cover the following steps: +1. Importing necessary libraries. +2. Define the wing parameters +3. Create wing geometry with linear panel distribution and add the wing sections +4. Initializing the wing aerodynamics and set the inflow conditions. +5. Plotting the geometry +6. Initialize solvers for both LLT and VSM methods +7. Running an simulation with both methods +8. Plotting distributions +9. Plotting polars + +First, install Julia and launch the Julia REPL as explained in the section [Installation](@ref). Then, copy and paste to the Julia prompt: + +#### Step 1: Importing the necessary libraries: +```julia +using LinearAlgebra +using ControlPlots +using VortexStepMethod +``` + +#### Step 2: Define wing parameters +```julia +n_panels = 20 # Number of panels +span = 20.0 # Wing span [m] +chord = 1.0 # Chord length [m] +v_a = 20.0 # Magnitude of inflow velocity [m/s] +density = 1.225 # Air density [kg/m³] +alpha_deg = 30.0 # Angle of attack [degrees] +alpha = deg2rad(alpha_deg) +``` + +#### Step 3: Create wing geometry with linear panel distribution +```julia +wing = Wing(n_panels, spanwise_panel_distribution=LINEAR) +``` + +##### Add wing sections - defining only tip sections with inviscid airfoil model +```julia +add_section!(wing, + [0.0, span/2, 0.0], # Left tip LE + [chord, span/2, 0.0], # Left tip TE + INVISCID) +add_section!(wing, + [0.0, -span/2, 0.0], # Right tip LE + [chord, -span/2, 0.0], # Right tip TE + INVISCID) +``` + +#### Step 4: Initialize aerodynamics +``` +wa = BodyAerodynamics([wing]) +``` +We need to pass here an array of wing objects, because a body can have multiple wings. + +###### Set inflow conditions +```julia +vel_app = [cos(alpha), 0.0, sin(alpha)] .* v_a +set_va!(wa, vel_app, [0, 0, 0.1]) +``` +#### Step 5: Plot the geometry +```julia +plot_geometry( + wa, + "Rectangular_wing_geometry"; + data_type=".pdf", + save_path=".", + is_save=false, + is_show=true, +) +``` +You should see a plot like this: + +![Rectangular Wing](RectangularWing.png) + +#### Step 6: Initialize solvers for both LLT and VSM methods +```julia +llt_solver = Solver(aerodynamic_model_type=LLT) +vsm_solver = Solver(aerodynamic_model_type=VSM) +``` + +#### Step 7: Solve using both methods +``` +results_llt = solve(llt_solver, wa) +results_vsm = solve(vsm_solver, wa) +``` + +##### Print results comparison +```julia +println("\nLifting Line Theory Results:") +println("CL = $(round(results_llt["cl"], digits=4))") +println("CD = $(round(results_llt["cd"], digits=4))") +println("\nVortex Step Method Results:") +println("CL = $(round(results_vsm["cl"], digits=4))") +println("CD = $(round(results_vsm["cd"], digits=4))") +println("Projected area = $(round(results_vsm["projected_area"], digits=4)) m²") +``` + +#### Step 8: Plot spanwise distributions +```julia +y_coordinates = [panel.aero_center[2] for panel in wa.panels] + +plot_distribution( + [y_coordinates, y_coordinates], + [results_vsm, results_llt], + ["VSM", "LLT"], + title="Spanwise Distributions" +) +``` +You should see a plot like this: + +![Spanwise Distributions](SpanwiseDistributions.png) + +#### Step 9: Plot polar curves +```julia +angle_range = range(0, 20, 20) +plot_polars( + [llt_solver, vsm_solver], + [wa, wa], + ["LLT", "VSM"]; + angle_range, + angle_type="angle_of_attack", + v_a, + title="Rectangular Wing Polars" +) +``` +You should see a plot like this: + +![Polars](Polars.png) + +## More examples +You can execute more examples by typing: +```julia +include("examples/menu.jl") +``` +You should see the following menu: +``` +Choose function to execute or `q` to quit: + > rectangular_wing = include("rectangular_wing.jl") + ram_air_kite = include("ram_air_kite.jl") + stall_model = include("stall_model.jl") + bench = include("bench.jl") + cleanup = include("cleanup.jl") + quit +``` +You can select one of the examples using the `` and `` keys. Press `` to run the selected example. \ No newline at end of file