summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Peter <blendoit@gmail.com>2019-07-04 10:26:55 -0700
committerMarius Peter <blendoit@gmail.com>2019-07-04 10:26:55 -0700
commit7d0859d55a984a0c42111a620b3bb1ed7982c38e (patch)
treeab0218e93333e87b78294e8b134d2110ad2147c5
parent0e6e5f026ed443e40af2d20d37e90f6e16a0e722 (diff)
remove sqrt operator from creator
-rw-r--r--creator.py8
-rw-r--r--example_airfoil.py125
-rw-r--r--gui.py6
3 files changed, 63 insertions, 76 deletions
diff --git a/creator.py b/creator.py
index 22449bd..15425bc 100644
--- a/creator.py
+++ b/creator.py
@@ -29,7 +29,7 @@ Functions:
import sys
import os.path
import numpy as np
-from math import sin, cos, atan, sqrt
+from math import sin, cos, atan
import bisect as bi
import matplotlib.pyplot as plt
@@ -64,6 +64,8 @@ class Airfoil:
@classmethod
def from_dimensions(cls, chord, semi_span):
+ """Create airfoil from its chord and semi-span."""
+
if chord > 20:
cls.chord = chord
else:
@@ -114,8 +116,8 @@ class Airfoil:
"""Returns thickness from 1 'x' along the airfoil chord."""
x = 0 if x < 0 else x
z_t = 5 * t * self.chord * (
- + 0.2969 * sqrt(x / self.chord)
- - 0.1260 * (x / self.chord)
+ + 0.2969 * (x / self.chord) ** 0.5
+ - 0.1260 * (x / self.chord) ** 1
- 0.3516 * (x / self.chord) ** 2
+ 0.2843 * (x / self.chord) ** 3
- 0.1015 * (x / self.chord) ** 4)
diff --git a/example_airfoil.py b/example_airfoil.py
index 966dcc8..1055116 100644
--- a/example_airfoil.py
+++ b/example_airfoil.py
@@ -12,7 +12,11 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-
+"""
+Create an airfoil;
+Evaluate an airfoil;
+Generate a population of airfoils & optimize.
+"""
import creator # Create geometry
import evaluator # Evaluate geometry
@@ -50,69 +54,56 @@ NOSE_BOTTOM_STRINGERS = 5
POP_SIZE = 1
SAVE_PATH = 'C:/Users/blend/github/UCLA_MAE_154B/save'
-
-def main():
- """
- Create an airfoil;
- Evaluate an airfoil;
- Generate a population of airfoils & optimize.
- """
-
- # Create airfoil instance
- af = creator.Airfoil.from_dimensions(CHORD_LENGTH, SEMI_SPAN)
- # Define NACA airfoil coordinates and mass
- af.add_naca(NACA_NUM)
- af.add_mass(AIRFOIL_MASS)
- # af.info_print(2)
- af.info_save(SAVE_PATH, 'foo_name')
-
- # Create spar instance
- af.spar = creator.Spar()
- # Define the spar coordinates and mass, stored in single spar object
- af.spar.add_coord(af, 0.23)
- af.spar.add_coord(af, 0.57)
- # Automatically adds spar caps for each spar defined previously
- af.spar.add_spar_caps(SPAR_CAP_AREA)
- af.spar.add_mass(SPAR_MASS)
- af.spar.add_webs(SPAR_THICKNESS)
- # af.spar.info_print(2)
- af.spar.info_save(SAVE_PATH, 'foo_name')
-
- # Create stringer instance
- af.stringer = creator.Stringer()
- # Compute the stringer coordinates from their quantity in each zone
- af.stringer.add_coord(af,
- NOSE_TOP_STRINGERS,
- TOP_STRINGERS,
- NOSE_BOTTOM_STRINGERS,
- BOTTOM_STRINGERS)
- af.stringer.add_area(STRINGER_AREA)
- af.stringer.add_mass(STRINGER_MASS)
- af.stringer.add_webs(SKIN_THICKNESS)
- # af.stringer.info_print(2)
- af.stringer.info_save(SAVE_PATH, 'foo_name')
-
- # Plot components with matplotlib
- creator.plot_geom(af, True)
-
- # Evaluator object contains airfoil analysis results.
- eval = evaluator.Evaluator(af)
- # The analysis is performed in the evaluator.py module.
- eval.analysis(1, 1)
- # eval.info_print(2)
- eval.info_save(SAVE_PATH, 'foo_name')
- # evaluator.plot_geom(eval)
- # evaluator.plot_lift(eval)
-
- pop = generator.Population(10)
-
- # print(help(creator))
- # print(help(evaluator))
- # print(help(generator))
-
- # Print final execution time
- print("--- %s seconds ---" % (time.time() - start_time))
-
-
-if __name__ == '__main__':
- main()
+# Create airfoil instance
+af = creator.Airfoil.from_dimensions(CHORD_LENGTH, SEMI_SPAN)
+af.add_naca(NACA_NUM)
+af.add_mass(AIRFOIL_MASS)
+# af.info_print(2)
+af.info_save(SAVE_PATH, 'foo_name')
+
+# Create spar instance
+af.spar = creator.Spar()
+# Define the spar coordinates and mass, stored in single spar object
+af.spar.add_coord(af, 0.23)
+af.spar.add_coord(af, 0.57)
+# Automatically adds spar caps for each spar defined previously
+af.spar.add_spar_caps(SPAR_CAP_AREA)
+af.spar.add_mass(SPAR_MASS)
+af.spar.add_webs(SPAR_THICKNESS)
+# af.spar.info_print(2)
+af.spar.info_save(SAVE_PATH, 'foo_name')
+
+# Create stringer instance
+af.stringer = creator.Stringer()
+# Compute the stringer coordinates from their quantity in each zone
+af.stringer.add_coord(af,
+ NOSE_TOP_STRINGERS,
+ TOP_STRINGERS,
+ NOSE_BOTTOM_STRINGERS,
+ BOTTOM_STRINGERS)
+af.stringer.add_area(STRINGER_AREA)
+af.stringer.add_mass(STRINGER_MASS)
+af.stringer.add_webs(SKIN_THICKNESS)
+# af.stringer.info_print(2)
+af.stringer.info_save(SAVE_PATH, 'foo_name')
+
+# Plot components with matplotlib
+creator.plot_geom(af, True)
+
+# Evaluator object contains airfoil analysis results.
+eval = evaluator.Evaluator(af)
+# The analysis is performed in the evaluator.py module.
+eval.analysis(1, 1)
+# eval.info_print(2)
+eval.info_save(SAVE_PATH, 'foo_name')
+# evaluator.plot_geom(eval)
+# evaluator.plot_lift(eval)
+
+pop = generator.Population(10)
+
+# print(help(creator))
+# print(help(evaluator))
+# print(help(generator))
+
+# Print final execution time
+print("--- %s seconds ---" % (time.time() - start_time))
diff --git a/gui.py b/gui.py
index 483cc0c..cd036b1 100644
--- a/gui.py
+++ b/gui.py
@@ -23,8 +23,6 @@ from matplotlib.backends.backend_tkagg import (
FigureCanvasTkAgg, NavigationToolbar2Tk)
-# def main():
-
def new_field(parent, name):
"""Add a new user input field."""
@@ -85,7 +83,3 @@ frame_2.pack(side=tk.LEFT)
# plot.get_tk_widget().pack()
root.mainloop()
-
-
-# if __name__ == '__main__':
-# main()
Copyright 2019--2024 Marius PETER