[Python] Design & build airplanes from your specifications.
final Evaluator implementation
Changed files
creator/base.py
@@ -20,7 +20,10 @@
20
20
self.propulsion = None
21
21
self.wing = None
22
22
23
Added:
def __str__(self):
24
Added:
return self.name
23
25
26
Added:
24
27
class Component:
25
28
"""Basic component providing coordinates, tools and a component tree."""
26
29
def __init__(self, parent, name):
@@ -38,11 +41,11 @@
38
41
print(num_of_dashes * '-')
39
42
print(name)
40
43
for k, v in self.__dict__.items():
41
Removed:
if type(v) != list:
44
Added:
if type(v) is not np.ndarray:
42
45
print(f'{k}:\n', v)
43
46
print(num_of_dashes * '-')
44
47
for k, v in self.__dict__.items():
45
Removed:
if type(v) == list:
48
Added:
if type(v) is np.ndarray:
46
49
print(f'{k}:\n', np.around(v, round))
47
50
return None
48
51
@@ -54,14 +57,16 @@
54
57
try:
55
58
with open(full_path, 'w') as f:
56
59
for k, v in self.__dict__.items():
57
Removed:
if type(v) != list:
58
Removed:
f.write(f'{k}:\n')
60
Added:
if type(v) is not np.ndarray:
61
Added:
f.write(f'{k}=\n')
59
62
f.write(str(v))
63
Added:
f.write("\n")
60
64
# print(num_of_dashes * '-')
61
65
for k, v in self.__dict__.items():
62
Removed:
if type(v) == list:
63
Removed:
f.write(f'{k}:\n')
66
Added:
if type(v) is np.ndarray:
67
Added:
f.write(f'{k}=\n')
64
68
f.write(str(v))
69
Added:
f.write("\n")
65
70
logging.debug(f'Successfully wrote to file {full_path}')
66
71
except IOError:
67
72
print(f'Unable to write {file_name} to specified directory.\n',
creator/wing.py
@@ -55,7 +55,7 @@
55
55
def __str__(self):
56
56
return self.name
57
57
58
Removed:
def add_naca(self, naca_num):
58
Added:
def add_naca(self, naca_num=2412):
59
59
"""Generate surface geometry for a NACA airfoil.
60
60
61
61
The nested functions perform the required steps to generate geometry,
example_airfoil.py
@@ -18,9 +18,6 @@
18
18
import time
19
19
start_time = time.time()
20
20
21
Removed:
# Airfoil dimensions (in)
22
Removed:
NACA_NUM = 2412
23
Removed:
24
21
# Thicknesses
25
22
SPAR_THICKNESS = 0.4
26
23
SKIN_THICKNESS = 0.1
@@ -46,7 +43,7 @@
46
43
47
44
ac = creator.base.Aircraft(eval, "ac")
48
45
af = creator.wing.Airfoil(ac, 'af')
49
Removed:
af.add_naca(NACA_NUM)
46
Added:
af.add_naca(2412)
50
47
# af.info_print(2)
51
48
af.info_save()
52
49
spar1 = creator.wing.Spar(af, 'spar1')
@@ -59,10 +56,14 @@
59
56
ac2 = creator.base.Aircraft(eval, "ac2")
60
57
af2 = creator.wing.Airfoil(ac2, 'af2')
61
58
af2.add_naca(3412)
59
Added:
af2.info_save()
62
60
spar3 = creator.wing.Spar(af2, 'spar3', 0.23)
63
61
spar4 = creator.wing.Spar(af2, 'spar4', 0.67)
62
Added:
spar3.info_save()
63
Added:
spar4.info_save()
64
64
65
65
for aircraft in eval.aircrafts:
66
Added:
print(aircraft)
66
67
print(aircraft.wing)
67
68
for spar in aircraft.wing.spars:
68
69
print(spar.material["name"])