*ARCHIVED* development moved to aircraft-studio.
Reformat print_coord and save_coord data presentation
Changed files
creator.py
@@ -65,28 +65,35 @@
65
65
66
66
def print_coord(self, round):
67
67
"""
68
Removed:
Print all the object's coordinates to the terminal.
68
Added:
Print all the component's coordinates to the terminal.
69
69
70
70
This function's output is piped to the 'save_coord' function below.
71
71
"""
72
Removed:
print('Chord length', self.chord, sep='\n')
73
Removed:
print('Semi-span')
74
Removed:
print('x_u the upper x-coordinates')
75
Removed:
print(np.around(self.x_u, round))
76
Removed:
print('y_u the upper y-coordinates')
77
Removed:
print(np.around(self.y_u, round))
78
Removed:
print('x_l the lower x-coordinates')
79
Removed:
print(np.around(self.x_l, round))
80
Removed:
print('y_l the lower y-coordinates')
81
Removed:
print(np.around(self.y_l, round))
72
Added:
print('============================')
73
Added:
print('Component:', type(self).__name__)
74
Added:
print('Chord length:', self.chord)
75
Added:
print('Semi-span:', self.semi_span)
76
Added:
print('============================')
77
Added:
print('x_u the upper x-coordinates:',
78
Added:
np.around(self.x_u, round),
79
Added:
sep='\n')
80
Added:
print('y_u the upper y-coordinates:',
81
Added:
np.around(self.y_u, round),
82
Added:
sep='\n')
83
Added:
print('x_l the lower x-coordinates:',
84
Added:
np.around(self.x_l, round),
85
Added:
sep='\n')
86
Added:
print('y_l the lower y-coordinates:',
87
Added:
np.around(self.y_l, round),
88
Added:
sep='\n')
89
Added:
print('\n')
82
90
return None
83
91
84
92
def save_coord(self, save_dir_path):
85
93
"""
86
94
Save all the object's coordinates (must be full path).
87
95
"""
88
Removed:
object_name = str(self.__name__)
89
Removed:
file_name = 'airfoil_%s' % airfoil_number
96
Added:
file_name = str(type(self).__name__)
90
97
full_path = os.path.join(save_dir_path, file_name + '.txt')
91
98
file = open(full_path, 'w')
92
99
sys.stdout = file
main.py
@@ -23,22 +23,35 @@
23
23
SEMI_SPAN = 200
24
24
25
25
POP_SIZE = 1
26
Removed:
SAVE_PATH = 'C:/Users/blend/Desktop/python/airfoils'
26
Added:
SAVE_PATH = 'C:/Users/blend/github/UCLA_MAE_154B/save'
27
27
28
28
29
29
def main():
30
30
# Create coordinate system specific to airfoil dimensions.
31
31
creator.Coordinates(CHORD_LENGTH, SEMI_SPAN)
32
Removed:
for airfoil_number in range(1, POP_SIZE + 1):
33
Removed:
foo = creator.Airfoil()
34
Removed:
foo.naca(2412)
35
Removed:
# foo.print_coord(4)
36
Removed:
foo.spar = creator.Spar()
37
Removed:
foo.spar.add_spar(foo.coordinates, 'aluminium', 0.15)
38
Removed:
foo.spar.print_coord(4)
39
Removed:
creator.plot(foo, foo.spar)
40
Removed:
foo.save_values(SAVE_PATH)
41
32
33
Added:
# Interate through all wings in population.
34
Added:
for _ in range(1, POP_SIZE + 1):
35
Added:
# Create airfoil instance
36
Added:
af = creator.Airfoil()
37
Added:
# Define NACA airfoil coordinates
38
Added:
af.naca(2412)
39
Added:
# Print coordinates of af to terminal
40
Added:
af.print_coord(4)
41
Added:
# Create spar instance
42
Added:
af.spar = creator.Spar()
43
Added:
# Define the spar coordinates
44
Added:
af.spar.add_spar(af.coordinates, 'aluminium', 0.15)
45
Added:
# Print coordinates of af.spar to terminal
46
Added:
af.spar.print_coord(4)
47
Added:
# Plot components with matplotlib
48
Added:
creator.plot(af, af.spar)
49
Added:
50
Added:
# Save component coordinates
51
Added:
af.save_coord(SAVE_PATH)
52
Added:
af.spar.save_coord(SAVE_PATH)
53
Added:
54
Added:
# Print final execution time
42
55
print("--- %s seconds ---" % (time.time() - start_time))
43
56
44
57