From 4d37eb4790f438905acc30e6565e4acb6a94a276 Mon Sep 17 00:00:00 2001 From: Prashanth <61168530+askprash@users.noreply.github.com> Date: Wed, 7 Feb 2024 06:41:37 -0500 Subject: [PATCH] Minor output fixes and output testing (#14) --- Project.toml | 1 + src/IO/outputs.jl | 4 --- test/aero.txt | 27 +++++++++++++++++ test/geom.txt | 44 +++++++++++++++++++++++++++ test/runtests.jl | 3 ++ test/unit_test_heat_exchanger.jl | 3 -- test/unit_test_outputs.jl | 32 ++++++++++++++++++++ test/weights.txt | 52 ++++++++++++++++++++++++++++++++ 8 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 test/aero.txt create mode 100644 test/geom.txt create mode 100644 test/unit_test_outputs.jl create mode 100644 test/weights.txt diff --git a/Project.toml b/Project.toml index 5ca03e7d..9add654d 100644 --- a/Project.toml +++ b/Project.toml @@ -7,6 +7,7 @@ version = "1.0.0-DEV" BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94" +DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" NLopt = "76087f3c-5699-56af-9a33-bf431cd00edd" diff --git a/src/IO/outputs.jl b/src/IO/outputs.jl index 0ebf1fb2..b9815eb8 100644 --- a/src/IO/outputs.jl +++ b/src/IO/outputs.jl @@ -1473,7 +1473,6 @@ function high_res_airplane_plot(ac; ax = nothing, label_fs = 16, save_name = not ax.plot( [xi.+lnace/2, xi.+1.0] , -1.0 .* [yi, yi], color = "k", lw = 2, zorder = wingz-2) - # Plot NP and CG range ax.scatter(parg[igxNP], 0.0, color = "k", marker="o", zorder = 21, label = "NP") ax.text(parg[igxNP], -1.0, "NP", fontsize=label_fs-2.0, ha="center", va="center", zorder = 21) @@ -1498,7 +1497,6 @@ function high_res_airplane_plot(ac; ax = nothing, label_fs = 16, save_name = not # ax.plot([parg[igxftank]-l/2, parg[igxftank]+l/2],[0.0, 0.0], zorder = 21) - # Annotations ax.text(0, 16, @sprintf("PFEI = %5.3f J/Nm\nM\$_{cruise}\$ = %.2f\nWMTO = %.1f tonnes\nSpan = %5.1f m\nco = %5.1f m\n\$ \\Lambda \$ = %.1f\$^\\circ\$\nRfuse = %5.1f m\nL/D = %3.2f", parm[imPFEI], para[iaMach, ipcruise1],parg[igWMTO]/9.81/1000, parg[igb], parg[igco], parg[igsweep], parg[igRfuse], para[iaCL, ipcruise1]/para[iaCD, ipcruise1]), @@ -1559,8 +1557,6 @@ function high_res_airplane_plot(ac; ax = nothing, label_fs = 16, save_name = not # Scale bar - - return ax end diff --git a/test/aero.txt b/test/aero.txt new file mode 100644 index 00000000..4bf44ef1 --- /dev/null +++ b/test/aero.txt @@ -0,0 +1,27 @@ +Aerodynamics: + -------------- +Ref.Area= 139.48268 m² +L/D = 17.60833 +CL = 0.57000 +CD = 0.03237 +CDfuse = 0.00681 +CDi = 0.01116 +CDwing = 0.00820 +CDhtail = 0.00259 +CDvtail = 0.00175 +CDnace = 0.00186 +CDBLIf = -0.00000 +CDBLIw = -0.00000 + +Drag Areas = CD × Sref: +CL × Sref = 79.50513 m² +CD × Sref = 4.51520 m² +CDfuse × Sref = 0.95001 m² +CDi × Sref = 1.55662 m² +CDwing × Sref = 1.14362 m² +CDhtail× Sref = 0.36162 m² +CDvtail× Sref = 0.24445 m² +CDnace × Sref = 0.25888 m² +CDBLIf × Sref = -0.00000 m² +CDBLIw × Sref = -0.00000 m² + diff --git a/test/geom.txt b/test/geom.txt new file mode 100644 index 00000000..28a503e4 --- /dev/null +++ b/test/geom.txt @@ -0,0 +1,44 @@ +Fuselage Layout: + -------------- +xnose = 0.0 m ( 0.0 ft) +xend = 37.8 m ( 124.0 ft) +xwing = 18.8 m ( 61.7 ft) +xhtail = 36.2 m ( 118.9 ft) +xvtail = 35.1 m ( 115.0 ft) +xblend1 = 6.1 m ( 20.0 ft) +xblend2 = 29.6 m ( 97.0 ft) +xshell1 = 5.2 m ( 17.0 ft) +xshell2 = 31.1 m ( 102.0 ft) +xhbend = 31.0 m ( 101.7 ft) +xvbend = 31.2 m ( 102.3 ft) +xwbox = 16.0 m ( 52.6 ft) +xhbox = 34.9 m ( 114.5 ft) +xvbox = 33.5 m ( 110.0 ft) +xtshaft = 0.0 m ( 0.0 ft) +xgen = 0.0 m ( 0.0 ft) +xcat = 0.0 m ( 0.0 ft) +xftank = 0.0 m ( 0.0 ft) + +Rfuse = 2.0 m ( 6.4 ft) + +Stability: + -------------- +xNP = 19.9 m ( 65.3 ft) +xCGfwd = 17.6 m ( 57.8 ft) +xCGaft = 19.6 m ( 64.4 ft) +xSMfwd = 0.5416 +xSMaft = 0.0637 + +Wing Layout: + -------------- +AR = 10.100 +sweep = 26.000 +lambdas = 0.700 +lambdat = 0.250 +co = 6.2 m ( 20.4 ft) +cs = 4.4 m ( 14.3 ft) +ct = 1.6 m ( 5.1 ft) +bo = 3.6 m ( 11.8 ft) +bs = 10.7 m ( 35.1 ft) +b = 37.5 m ( 123.1 ft) +S = 139.5 m²( 1501.4 ft²) diff --git a/test/runtests.jl b/test/runtests.jl index e7fdcc1c..73a26bbc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,5 +4,8 @@ using Test @testset verbose=true "TASOPT" begin include("unit_test_structures.jl") include("unit_test_aero.jl") + include("unit_test_heat_exchanger.jl") include("regression_test_wsize.jl") + include("unit_test_outputs.jl") + end \ No newline at end of file diff --git a/test/unit_test_heat_exchanger.jl b/test/unit_test_heat_exchanger.jl index 9b4aa305..19a65fa8 100644 --- a/test/unit_test_heat_exchanger.jl +++ b/test/unit_test_heat_exchanger.jl @@ -5,9 +5,6 @@ # exchanger in air. It assumes that air in flowing through the exchanger # and heat is absorbed by a coolant fluid. -using TASOPT -using Test - #--------------------------------- # Test functions individually #--------------------------------- diff --git a/test/unit_test_outputs.jl b/test/unit_test_outputs.jl new file mode 100644 index 00000000..6a7ce589 --- /dev/null +++ b/test/unit_test_outputs.jl @@ -0,0 +1,32 @@ + +@testset "outputs" verbose=true begin + + ac = load_default_model() + size_aircraft!(ac; printiter=false); + + @testset "output summaries" begin + f = open(io->TASOPT.weight_buildup(ac,io=io), "temp.txt", "w") + @test read("weights.txt", String) == read("temp.txt", String) + rm("temp.txt") + + f = open(io->TASOPT.aero(ac,io=io), "temp.txt", "w") + @test read("aero.txt", String) == read("temp.txt", String) + rm("temp.txt") + + f = open(io->TASOPT.geometry(ac,io=io), "temp.txt", "w") + @test read("geom.txt", String) == read("temp.txt", String) + rm("temp.txt") + end + + @testset "output plots" begin + + TASOPT.stickfig(ac) + @test 1 == 1 + TASOPT.high_res_airplane_plot(ac) + @test 2 == 2 + TASOPT.plot_details(ac) + @test 3 == 3 + + end + +end \ No newline at end of file diff --git a/test/weights.txt b/test/weights.txt new file mode 100644 index 00000000..dfd9b91c --- /dev/null +++ b/test/weights.txt @@ -0,0 +1,52 @@ +Weight build-up: + -------------- +Wempty + 466014.1 N (104764.1 lb) +Wpay + 172146.2 N ( 38700.0 lb) +Wfuel + 233069.6 N ( 52396.1 lb) +-------------------- +WMTO = 871229.9 N (195860.3 lb) + +Wfuse + 195735.6 N ( 44003.1 lb) +Wwing + 128764.2 N ( 28947.3 lb) +Wvtail + 9899.4 N ( 2225.5 lb) +Whtail + 14759.3 N ( 3318.0 lb) +Wtesys + 0.0 N ( 0.0 lb) +Wftank + 0.0 N ( 0.0 lb) +Wadd + 56629.9 N ( 12730.9 lb) +-------------------- +Wempty = 405788.5 N ( 91224.9 lb) + +Wcap + 74931.7 N ( 16845.3 lb) +Wweb + 3583.1 N ( 805.5 lb) +Wflap + 15703.0 N ( 3530.2 lb) +Wslat + 7851.5 N ( 1765.1 lb) +Waile + 3140.6 N ( 706.0 lb) +Wlete + 7851.5 N ( 1765.1 lb) +Wribs + 11777.2 N ( 2647.6 lb) +Wspoi + 1570.3 N ( 353.0 lb) +Wwatt + 2355.4 N ( 529.5 lb) +-------------------- +Wwing = 128764.2 N ( 28947.3 lb) + +Wtshaft + 0.0 N ( 0.0 lb) × 2 +Wcat + 0.0 N ( 0.0 lb) × 2 +Waftfan + 0.0 N ( 0.0 lb) × 2 +WaftGB + 0.0 N ( 0.0 lb) × 2 +Wgen + 0.0 N ( 0.0 lb) × 4 +Wrect + 0.0 N ( 0.0 lb) × 4 +Wcables + 0.0 N ( 0.0 lb) ---- +Winv + 0.0 N ( 0.0 lb) × 6 +Wmot + 0.0 N ( 0.0 lb) × 6 +Wfan + 0.0 N ( 0.0 lb) × 6 +WfanGB + 0.0 N ( 0.0 lb) × 6 +Wtms + 0.0 N ( 0.0 lb) ---- +-------------------- +Wtesys = 0.0 N ( 0.0 lb) + +Wftnkins = 0.0 N ( 0.0 lb) +Wftank = 0.0 N ( 0.0 lb) + +lftank = 0.0 m ( 0.0 ft) +Rftank = 0.0 m ( 0.0 ft) +ηtank = 100.0 % +