From 04e871de7e318fec404975176800ccebf9e5e741 Mon Sep 17 00:00:00 2001 From: Marius Peter Date: Thu, 4 Jul 2019 10:42:01 -0700 Subject: docstrings --- creator.py | 25 +++++++------------------ evaluator.py | 2 -- example_airfoil.py | 18 ++---------------- generator.py | 1 - 4 files changed, 9 insertions(+), 37 deletions(-) diff --git a/creator.py b/creator.py index 15425bc..810df09 100644 --- a/creator.py +++ b/creator.py @@ -35,8 +35,7 @@ import matplotlib.pyplot as plt class Airfoil: - """ - This class represents a single NACA airfoil. + """This class represents a single NACA airfoil. Please note: the coordinates are saved as two lists for the x- and z-coordinates. The coordinates start at @@ -65,7 +64,6 @@ 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: @@ -78,8 +76,8 @@ class Airfoil: return type(self).__name__ def add_naca(self, naca_num): - """ - This function generates geometry for a NACA number passed as argument. + """Generate surface geometry for a NACA airfoil. + The nested functions perform the required steps to generate geometry, and can be called to solve the geometry y-coordinate for any 'x' input. Equation coefficients were retrieved from Wikipedia.org. @@ -113,7 +111,7 @@ class Airfoil: return (z_c * self.chord) def get_thickness(x): - """Returns thickness from 1 'x' along the airfoil chord.""" + """Return thickness from 1 'x' along the airfoil chord.""" x = 0 if x < 0 else x z_t = 5 * t * self.chord * ( + 0.2969 * (x / self.chord) ** 0.5 @@ -169,9 +167,7 @@ class Airfoil: self.mass = mass def info_print(self, round): - # TODO: implement this info getting method! """Print all the component's coordinates to the terminal.""" - name = ' CREATOR DATA FOR {} '.format(str(self).upper()) num_of_dashes = len(name) print(num_of_dashes * '-') @@ -186,10 +182,7 @@ class Airfoil: return None def info_save(self, save_path, number): - """ - Save all the object's coordinates (must be full path). - """ - + """Save all the object's coordinates (must be full path).""" file_name = '{}_{}.txt'.format(str(self).lower(), number) full_path = os.path.join(save_path, file_name) try: @@ -217,8 +210,7 @@ class Spar(Airfoil): self.z_end = [] def add_coord(self, airfoil, x_loc_percent): - """ - Add a single spar at the % chord location given to function. + """Add a single spar at the % chord location given to function. Parameters: airfoil: gives the spar access to airfoil's coordinates. @@ -278,8 +270,7 @@ class Stringer(Airfoil): def add_coord(self, airfoil, stringer_u_1, stringer_u_2, stringer_l_1, stringer_l_2): - """ - Add equally distributed stringers to four airfoil locations + """Add equally distributed stringers to four airfoil locations (upper nose, lower nose, upper surface, lower surface). Parameters: @@ -362,9 +353,7 @@ class Stringer(Airfoil): def plot_geom(airfoil, view: False): """This function plots the airfoil's + sub-components' geometry.""" - fig, ax = plt.subplots() - # ax.axis('off') # Plot chord x = [0, airfoil.chord] diff --git a/evaluator.py b/evaluator.py index d41716c..ad1f873 100644 --- a/evaluator.py +++ b/evaluator.py @@ -73,7 +73,6 @@ class Evaluator: def info_save(self, save_path, number): """Save all the object's coordinates (must be full path).""" - file_name = 'airfoil_{}_eval.txt'.format(number) full_path = os.path.join(save_path, file_name) try: @@ -199,7 +198,6 @@ class Evaluator: def analysis(self, V_x, V_z): """Perform all analysis calculations and store in class instance.""" - self.drag = self.get_drag(10) self.lift_rectangular = self.get_lift_rectangular(13.7) self.lift_elliptical = self.get_lift_elliptical(15) diff --git a/example_airfoil.py b/example_airfoil.py index 1055116..cf279d5 100644 --- a/example_airfoil.py +++ b/example_airfoil.py @@ -1,18 +1,5 @@ -# This file is part of Marius Peter's airfoil analysis package (this program). -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -""" +"""This example illustrates the usage of creator, evaluator and generator. + Create an airfoil; Evaluate an airfoil; Generate a population of airfoils & optimize. @@ -21,7 +8,6 @@ Generate a population of airfoils & optimize. import creator # Create geometry import evaluator # Evaluate geometry import generator # Iteratevely evaluate instances of geometry and optimize -import numpy as np import time start_time = time.time() diff --git a/generator.py b/generator.py index eb0ef65..6a2865d 100644 --- a/generator.py +++ b/generator.py @@ -22,7 +22,6 @@ import creator def default_airfoil(): """Generate the default airfoil.""" - airfoil = creator.Airfoil.from_dimensions(100, 200) airfoil.add_naca(2412) airfoil.add_mass(10) -- cgit v1.2.3