summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--creator.py18
-rw-r--r--main.py9
2 files changed, 16 insertions, 11 deletions
diff --git a/creator.py b/creator.py
index aa8001f..a2626d0 100644
--- a/creator.py
+++ b/creator.py
@@ -92,12 +92,16 @@ class Coordinates:
file_name = '{}_{}.txt'.format(self, number)
full_path = os.path.join(save_dir_path, file_name)
- # sys.stdout = open(full_path, 'w')
- # self.print_coord(2)
- with open(full_path, 'w') as sys.stdout:
- self.print_coord(2)
- # Following line required to reset value of sys.stdout
- sys.stdout = sys.__stdout__
+ try:
+ with open(full_path, 'w') as sys.stdout:
+ self.print_coord(2)
+ # This line required to reset behavior of sys.stdout
+ sys.stdout = sys.__stdout__
+ print('Successfully wrote to file {}'.format(full_path))
+ except:
+ print('Unable to write {} to specified directory.\n'
+ .format(file_name),
+ 'Was the full path passed to the function?')
# It is cleaner to use this context guard to ensure file is closed
return None
@@ -385,7 +389,7 @@ def plot(airfoil, spar, stringer):
x = (spar.x_u[_], spar.x_l[_])
y = (spar.y_u[_], spar.y_l[_])
plt.plot(x, y, '.-', color='b')
- plt.legend()
+ # plt.legend()
except:
print('Did not plot spars. Were they added?')
diff --git a/main.py b/main.py
index 9278eeb..b842e9e 100644
--- a/main.py
+++ b/main.py
@@ -34,28 +34,29 @@ def main():
# Interate through all wings in population.
for _ in range(1, POP_SIZE + 1):
+
# Create airfoil instance
af = creator.Airfoil()
# Define NACA airfoil coordinates
af.add_naca(2412)
- af.print_coord(2)
+ # af.print_coord(2)
# Create spar instance
af.spar = creator.Spar()
# Define the spar coordinates, stored in single spar object
af.spar.add(af.coord, 0.15)
af.spar.add(af.coord, 0.55)
- af.spar.print_coord(2)
+ # af.spar.print_coord(2)
# Create stringer instance
af.stringer = creator.Stringer()
# Define the stringer coordinates from their amount
af.stringer.add(af.coord, af.spar.coord, 4, 7, 5, 6)
# Print coordinates of af.stringer to terminal
- af.stringer.print_coord(2)
+ # af.stringer.print_coord(2)
# Plot components with matplotlib
- creator.plot(af, af.spar, af.stringer)
+ # creator.plot(af, af.spar, af.stringer)
# Save component coordinates
af.save_coord(SAVE_PATH, _)
Copyright 2019--2024 Marius PETER