From 5c1c6665fba2cd76b75f05c7c9c621461b7518ef Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Thu, 1 May 2025 12:27:50 +0200 Subject: aircraft-studio, redux. --- .ocamlformat | 2 + aircraft_studio.opam | 31 + bin/dune | 4 + bin/main.ml | 36 + bin/static/airfoil-2412.svg | 6982 ++++++++++++++++++++++++++++++++++++++++++ bin/static/airfoil-2812.svg | 6982 ++++++++++++++++++++++++++++++++++++++++++ bin/static/airfoil-4412.svg | 6982 ++++++++++++++++++++++++++++++++++++++++++ bin/static/airfoil-8412.svg | 6982 ++++++++++++++++++++++++++++++++++++++++++ bin/static/airfoil-9412.svg | 6982 ++++++++++++++++++++++++++++++++++++++++++ bin/static/airfoil.svg | 6982 ++++++++++++++++++++++++++++++++++++++++++ dune-project | 26 + lib/naca/dune | 5 + lib/naca/naca.mli.bkp | 6 + lib/naca/naca4.ml | 143 + lib/naca/naca5.ml | 18 + lib/naca/naca5.mli | 6 + test/dune | 2 + test/test_aircraft_studio.ml | 0 18 files changed, 42171 insertions(+) create mode 100644 .ocamlformat create mode 100644 aircraft_studio.opam create mode 100644 bin/dune create mode 100644 bin/main.ml create mode 100644 bin/static/airfoil-2412.svg create mode 100644 bin/static/airfoil-2812.svg create mode 100644 bin/static/airfoil-4412.svg create mode 100644 bin/static/airfoil-8412.svg create mode 100644 bin/static/airfoil-9412.svg create mode 100644 bin/static/airfoil.svg create mode 100644 dune-project create mode 100644 lib/naca/dune create mode 100644 lib/naca/naca.mli.bkp create mode 100644 lib/naca/naca4.ml create mode 100644 lib/naca/naca5.ml create mode 100644 lib/naca/naca5.mli create mode 100644 test/dune create mode 100644 test/test_aircraft_studio.ml diff --git a/.ocamlformat b/.ocamlformat new file mode 100644 index 0000000..d2136f0 --- /dev/null +++ b/.ocamlformat @@ -0,0 +1,2 @@ +profile = default +version = 0.26.2 \ No newline at end of file diff --git a/aircraft_studio.opam b/aircraft_studio.opam new file mode 100644 index 0000000..f5439b4 --- /dev/null +++ b/aircraft_studio.opam @@ -0,0 +1,31 @@ +# This file is generated by dune, edit dune-project instead +opam-version: "2.0" +synopsis: "A short synopsis" +description: "A longer description" +maintainer: ["Marius Peter"] +authors: ["Marius Peter"] +license: "LICENSE" +tags: ["topics" "to describe" "your" "project"] +homepage: "https://github.com/username/reponame" +doc: "https://url/to/documentation" +bug-reports: "https://github.com/username/reponame/issues" +depends: [ + "ocaml" + "dune" {>= "3.15"} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/username/reponame.git" diff --git a/bin/dune b/bin/dune new file mode 100644 index 0000000..f0a6781 --- /dev/null +++ b/bin/dune @@ -0,0 +1,4 @@ +(executable + (name main) + (public_name aircraft_studio) + (libraries aircraft_studio.naca plplot dream)) diff --git a/bin/main.ml b/bin/main.ml new file mode 100644 index 0000000..0767aa7 --- /dev/null +++ b/bin/main.ml @@ -0,0 +1,36 @@ +(* Main function to plot the coordinates *) + +let airfoil_plot naca_num = + (* let filename = Printf.sprintf "static/airfoil-%s.svg" naca_num in *) + let open Naca in + (* Initialize plplot *) + Plplot.plsdev "xwin"; + (* Plplot.plsfnam filename; *) + Plplot.plinit (); + Plplot.plenv (-0.2) 1.2 (-0.3) 0.3 1 0; + + (* Set the labels *) + let x_label = "relative x" in + let y_label = "y_t" in + let title = + Printf.sprintf "NACA %s Airfoil Thickness Distribution" naca_num + in + Plplot.pllab x_label y_label title; + Naca4.plot_airfoil naca_num ~amt:10 (); + + (* End the plot *) + Plplot.plend () + (* filename *) + +(* let main_page naca_num = *) +(* let file = airfoil_plot naca_num in *) +(* "Hello world!" ^ Printf.sprintf "" file *) + +let () = + airfoil_plot "4412" + (* Dream.run @@ Dream.logger *) + (* @@ Dream.router *) + (* [ *) + (* Dream.get "/" (fun _ -> Dream.html @@ main_page "9412"); *) + (* Dream.get "/static/**" (Dream.static "static"); *) + (* ] *) diff --git a/bin/static/airfoil-2412.svg b/bin/static/airfoil-2412.svg new file mode 100644 index 0000000..4ba5187 --- /dev/null +++ b/bin/static/airfoil-2412.svg @@ -0,0 +1,6982 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -0.2 + + + 0.0 + + + 0.2 + + + 0.4 + + + 0.6 + + + 0.8 + + + 1.0 + + + 1.2 + + + -0.2 + + + 0.0 + + + 0.2 + + + NACA 2412 Airfoil Thickness Distribution + + + relative x + + + y_t + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/static/airfoil-2812.svg b/bin/static/airfoil-2812.svg new file mode 100644 index 0000000..2593144 --- /dev/null +++ b/bin/static/airfoil-2812.svg @@ -0,0 +1,6982 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -0.2 + + + 0.0 + + + 0.2 + + + 0.4 + + + 0.6 + + + 0.8 + + + 1.0 + + + 1.2 + + + -0.2 + + + 0.0 + + + 0.2 + + + NACA 2812 Airfoil Thickness Distribution + + + relative x + + + y_t + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/static/airfoil-4412.svg b/bin/static/airfoil-4412.svg new file mode 100644 index 0000000..170f7e9 --- /dev/null +++ b/bin/static/airfoil-4412.svg @@ -0,0 +1,6982 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -0.2 + + + 0.0 + + + 0.2 + + + 0.4 + + + 0.6 + + + 0.8 + + + 1.0 + + + 1.2 + + + -0.2 + + + 0.0 + + + 0.2 + + + NACA 4412 Airfoil Thickness Distribution + + + relative x + + + y_t + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/static/airfoil-8412.svg b/bin/static/airfoil-8412.svg new file mode 100644 index 0000000..19078bd --- /dev/null +++ b/bin/static/airfoil-8412.svg @@ -0,0 +1,6982 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -0.2 + + + 0.0 + + + 0.2 + + + 0.4 + + + 0.6 + + + 0.8 + + + 1.0 + + + 1.2 + + + -0.2 + + + 0.0 + + + 0.2 + + + NACA 8412 Airfoil Thickness Distribution + + + relative x + + + y_t + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/static/airfoil-9412.svg b/bin/static/airfoil-9412.svg new file mode 100644 index 0000000..37ef6d3 --- /dev/null +++ b/bin/static/airfoil-9412.svg @@ -0,0 +1,6982 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -0.2 + + + 0.0 + + + 0.2 + + + 0.4 + + + 0.6 + + + 0.8 + + + 1.0 + + + 1.2 + + + -0.2 + + + 0.0 + + + 0.2 + + + NACA 9412 Airfoil Thickness Distribution + + + relative x + + + y_t + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/static/airfoil.svg b/bin/static/airfoil.svg new file mode 100644 index 0000000..170f7e9 --- /dev/null +++ b/bin/static/airfoil.svg @@ -0,0 +1,6982 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -0.2 + + + 0.0 + + + 0.2 + + + 0.4 + + + 0.6 + + + 0.8 + + + 1.0 + + + 1.2 + + + -0.2 + + + 0.0 + + + 0.2 + + + NACA 4412 Airfoil Thickness Distribution + + + relative x + + + y_t + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dune-project b/dune-project new file mode 100644 index 0000000..4e9e59a --- /dev/null +++ b/dune-project @@ -0,0 +1,26 @@ +(lang dune 3.15) + +(name aircraft_studio) + +(generate_opam_files true) + +(source + (github username/reponame)) + +(authors "Marius Peter") + +(maintainers "Marius Peter") + +(license LICENSE) + +(documentation https://url/to/documentation) + +(package + (name aircraft_studio) + (synopsis "A short synopsis") + (description "A longer description") + (depends ocaml dune) + (tags + (topics "to describe" your project))) + +; See the complete stanza docs at https://dune.readthedocs.io/en/stable/dune-files.html#dune-project diff --git a/lib/naca/dune b/lib/naca/dune new file mode 100644 index 0000000..18fe976 --- /dev/null +++ b/lib/naca/dune @@ -0,0 +1,5 @@ +(library + (name naca) + (modules naca4) + (public_name aircraft_studio.naca) + (libraries plplot)) diff --git a/lib/naca/naca.mli.bkp b/lib/naca/naca.mli.bkp new file mode 100644 index 0000000..7027549 --- /dev/null +++ b/lib/naca/naca.mli.bkp @@ -0,0 +1,6 @@ +(* -*- mode: tuareg; -*- *) + +(** Interface for NACA 4-digit airfoil generation *) + +val generate_coordinates : string -> float -> (float * float) list +(** Generates coordinates for a 4-digit NACA airfoil given its number and chord length. *) diff --git a/lib/naca/naca4.ml b/lib/naca/naca4.ml new file mode 100644 index 0000000..d65e581 --- /dev/null +++ b/lib/naca/naca4.ml @@ -0,0 +1,143 @@ +(* -*- mode: tuareg; -*- *) + +type naca4_num = string +type naca4_params = { m : float; p : float; t : float } +type coord = Coordinate of { x : float; y : float } +type naca4_coords = { c : coord array; u : coord array; l : coord array } +type naca4_arfoil = { naca_num : naca4_num; coords : naca4_coords } + +let get_params naca_num = + if String.length naca_num <> 4 then + raise (Invalid_argument "NACA number must be a 4-digit string"); + (* Maximum camber *) + let m = String.sub naca_num 0 1 |> float_of_string |> ( *. ) 0.01 in + (* Location of maximum camber *) + let p = String.sub naca_num 1 1 |> float_of_string |> ( *. ) 0.10 in + (* Maximum thickness *) + let t = String.sub naca_num 2 2 |> float_of_string |> ( *. ) 0.01 in + { m; p; t } + +let y_t t x = + 5. *. t + *. ((0.2969 *. sqrt x) + -. (0.1260 *. x) + -. (0.3516 *. (x ** 2.)) + +. (0.2843 *. (x ** 3.)) + -. (0.1015 *. (x ** 4.))) + +let array_of_amt amt = + Array.init (amt + 1) (fun x -> float_of_int x /. float_of_int amt) + +let densified_array_of_amt amt = + let pct = 0.25 in + let dense_amt = int_of_float (pct *. float_of_int amt) in + let factor = 5. in + let dense_array = + Array.init + (int_of_float (pct *. amt *. factor)) + (fun x -> float_of_int x /. (10. *. factor)) + in + let sparse_array = + let pct = 1. -. pct in + Array.init + (int_of_float (pct *. (amt))) + (fun x -> (float_of_int x +. (pct *. factor)) /. factor) + in + Array.append dense_array sparse_array + +(* Symmetrical airfoil *) +module Symmetrical = struct + let center_coord x = Coordinate { x; y = 0. } + + let upper_coord t x = + let y = y_t x t in + Coordinate { x; y } + + let lower_coord t x = + let y = -.y_t x t in + Coordinate { x; y } + + let get_coords t xs = + { + c = Array.map center_coord xs; + u = Array.map (upper_coord t) xs; + l = Array.map (lower_coord t) xs; + } +end + +(* Cambered airfoil *) +module Cambered = struct + let y_c m p x = + if 0. <= x && x <= p then m /. (p ** 2.) *. ((2. *. p *. x) -. (x ** 2.)) + else if p <= x && x <= 1. then + m /. ((1. -. p) ** 2.) *. (1. -. (2. *. p) +. (2. *. p *. x) -. (x ** 2.)) + else failwith "x value out of bounds" + + let theta m p x = + let dy_c_over_dx = + if 0. <= x && x <= p then 2. *. m /. (p ** 2.) *. (p -. x) + else if p <= x && x <= 1. then 2. *. m /. ((1. -. p) ** 2.) *. (p -. x) + else failwith "x value out of bounds" + in + atan dy_c_over_dx + + let camber_coord m p x = + let y = y_c m p x in + Coordinate { x; y } + + let upper_coord m p t x = + let y_t = y_t t x in + let y_c = y_c m p x in + let theta = theta m p x in + let x = x -. (y_t *. sin theta) in + let y = y_c +. (y_t *. cos theta) in + Coordinate { x; y } + + let lower_coord m p t x = + let y_t = y_t t x in + let y_c = y_c m p x in + let theta = theta m p x in + let x = x +. (y_t *. sin theta) in + let y = y_c -. (y_t *. cos theta) in + Coordinate { x; y } + + let get_coords m p t xs = + { + c = Array.map (camber_coord m p) xs; + u = Array.map (upper_coord m p t) xs; + l = Array.map (lower_coord m p t) xs; + } +end + +let get_coords naca_num ?(amt = 100) () = + let { m; p; t } = get_params naca_num in + let x_coords = densified_array_of_amt amt in + let airfoil_is_symmetrical = m = 0. && p = 0. in + if airfoil_is_symmetrical then Symmetrical.get_coords t x_coords + else Cambered.get_coords m p t x_coords + +let extract_coords coords = + let get_x (Coordinate c) = c.x in + let get_y (Coordinate c) = c.y in + let xs = Array.map get_x coords in + let ys = Array.map get_y coords in + (xs, ys) + +let plot_curve coords = + let get_x (Coordinate c) = c.x in + let get_y (Coordinate c) = c.y in + let xs = Array.map get_x coords in + let ys = Array.map get_y coords in + (xs, ys) + +let plot_airfoil naca_num ?(amt = 100) () = + let naca_coords = get_coords naca_num ~amt () in + let xs, ys = extract_coords naca_coords.c in + Plplot.plcol0 1; + Plplot.plpoin xs ys 1; + let xs, ys = extract_coords naca_coords.u in + Plplot.plcol0 6; + Plplot.plline xs ys; + let xs, ys = extract_coords naca_coords.l in + Plplot.plcol0 6; + Plplot.plline xs ys diff --git a/lib/naca/naca5.ml b/lib/naca/naca5.ml new file mode 100644 index 0000000..865f3ec --- /dev/null +++ b/lib/naca/naca5.ml @@ -0,0 +1,18 @@ +(* -*- mode: tuareg; -*- *) + +type naca5 = { l : float; p : float; s : int; t : float } + +(** Implementation for NACA 5-digit airfoil generation *) + +let generate_coordinates (naca_num : string) = + (* Logic for generating 5-digit NACA airfoil coordinates *) + naca_num + +(* type naca4 = { m : float; p : float; t : float } *) + +let parse_naca5 (naca_num : string) = + let l = String.sub naca_num 0 1 |> float_of_string |> ( *. ) 0.15 in + let p = String.sub naca_num 1 1 |> float_of_string |> ( *. ) 0.05 in + let s = String.sub naca_num 2 2 |> int_of_string in + let t = String.sub naca_num 2 2 |> float_of_string |> ( *. ) 0.01 in + { l; p; s; t } diff --git a/lib/naca/naca5.mli b/lib/naca/naca5.mli new file mode 100644 index 0000000..07377d8 --- /dev/null +++ b/lib/naca/naca5.mli @@ -0,0 +1,6 @@ +(* -*- mode: tuareg; -*- *) + +(** Interface for NACA 5-digit airfoil generation *) + +val generate_coordinates : int -> float -> (float * float) list +(** Generates coordinates for a 5-digit NACA airfoil given its number and chord length. *) diff --git a/test/dune b/test/dune new file mode 100644 index 0000000..571186f --- /dev/null +++ b/test/dune @@ -0,0 +1,2 @@ +(test + (name test_aircraft_studio)) diff --git a/test/test_aircraft_studio.ml b/test/test_aircraft_studio.ml new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3