summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--creator.py33
-rw-r--r--main.py33
2 files changed, 43 insertions, 23 deletions
diff --git a/creator.py b/creator.py
index 645ed9b..d5ff3ec 100644
--- a/creator.py
+++ b/creator.py
@@ -65,28 +65,35 @@ class Coordinates:
def print_coord(self, round):
"""
- Print all the object's coordinates to the terminal.
+ Print all the component's coordinates to the terminal.
This function's output is piped to the 'save_coord' function below.
"""
- print('Chord length', self.chord, sep='\n')
- print('Semi-span')
- print('x_u the upper x-coordinates')
- print(np.around(self.x_u, round))
- print('y_u the upper y-coordinates')
- print(np.around(self.y_u, round))
- print('x_l the lower x-coordinates')
- print(np.around(self.x_l, round))
- print('y_l the lower y-coordinates')
- print(np.around(self.y_l, round))
+ print('============================')
+ print('Component:', type(self).__name__)
+ print('Chord length:', self.chord)
+ print('Semi-span:', self.semi_span)
+ print('============================')
+ print('x_u the upper x-coordinates:',
+ np.around(self.x_u, round),
+ sep='\n')
+ print('y_u the upper y-coordinates:',
+ np.around(self.y_u, round),
+ sep='\n')
+ print('x_l the lower x-coordinates:',
+ np.around(self.x_l, round),
+ sep='\n')
+ print('y_l the lower y-coordinates:',
+ np.around(self.y_l, round),
+ sep='\n')
+ print('\n')
return None
def save_coord(self, save_dir_path):
"""
Save all the object's coordinates (must be full path).
"""
- object_name = str(self.__name__)
- file_name = 'airfoil_%s' % airfoil_number
+ file_name = str(type(self).__name__)
full_path = os.path.join(save_dir_path, file_name + '.txt')
file = open(full_path, 'w')
sys.stdout = file
diff --git a/main.py b/main.py
index 4107054..a6e75a3 100644
--- a/main.py
+++ b/main.py
@@ -23,22 +23,35 @@ CHORD_LENGTH = 40
SEMI_SPAN = 200
POP_SIZE = 1
-SAVE_PATH = 'C:/Users/blend/Desktop/python/airfoils'
+SAVE_PATH = 'C:/Users/blend/github/UCLA_MAE_154B/save'
def main():
# Create coordinate system specific to airfoil dimensions.
creator.Coordinates(CHORD_LENGTH, SEMI_SPAN)
- for airfoil_number in range(1, POP_SIZE + 1):
- foo = creator.Airfoil()
- foo.naca(2412)
- # foo.print_coord(4)
- foo.spar = creator.Spar()
- foo.spar.add_spar(foo.coordinates, 'aluminium', 0.15)
- foo.spar.print_coord(4)
- creator.plot(foo, foo.spar)
- foo.save_values(SAVE_PATH)
+ # Interate through all wings in population.
+ for _ in range(1, POP_SIZE + 1):
+ # Create airfoil instance
+ af = creator.Airfoil()
+ # Define NACA airfoil coordinates
+ af.naca(2412)
+ # Print coordinates of af to terminal
+ af.print_coord(4)
+ # Create spar instance
+ af.spar = creator.Spar()
+ # Define the spar coordinates
+ af.spar.add_spar(af.coordinates, 'aluminium', 0.15)
+ # Print coordinates of af.spar to terminal
+ af.spar.print_coord(4)
+ # Plot components with matplotlib
+ creator.plot(af, af.spar)
+
+ # Save component coordinates
+ af.save_coord(SAVE_PATH)
+ af.spar.save_coord(SAVE_PATH)
+
+ # Print final execution time
print("--- %s seconds ---" % (time.time() - start_time))
Copyright 2019--2024 Marius PETER