View raw

1 """ 2 This example illustrates the usage of creator, evaluator and generator. 3 4 All the steps of airfoil creation & evaluation are detailed here; 5 furthermore, the generator.py module contains certain presets 6 (default airfoils). 7 8 Create an airfoil; 9 Evaluate an airfoil; 10 Generate a population of airfoils & optimize. 11 """ 12 13 import aircraftstudio as acs 14 import resources.materials as mt 15 16 import time 17 start_time = time.time() 18 19 # Thicknesses 20 SPAR_THICKNESS = 0.4 21 SKIN_THICKNESS = 0.1 22 23 # Component masses (lbs) 24 AIRFOIL_MASS = 10 25 SPAR_MASS = 10 26 STRINGER_MASS = 5 27 28 # Area (sqin) 29 SPAR_CAP_AREA = 0.3 30 STRINGER_AREA = 0.1 31 32 SAVE_PATH = '/home/blendux/Projects/Aircraft_Studio/save' 33 34 # eval = evaluator.Evaluator("eval") 35 36 # ac = creator.base.Aircraft(eval, "ac") 37 # af = creator.wing.Airfoil(ac, 'af') 38 # af.add_naca(2412) 39 # spar1 = creator.wing.Spar(af, 'spar1') 40 # spar2 = creator.wing.Spar(af, 'spar2', 0.57) 41 # # spar2 = creator.wing.Spar(af, 'spar2', 0.7) 42 # stringer = creator.wing.Stringer(af, 'stringer', 5, 6, 5, 4) 43 # stringer.info_save(SAVE_PATH) 44 45 # ac2 = creator.base.Aircraft(eval, "ac2") 46 # af2 = creator.wing.Airfoil(ac2, 'af2') 47 # af2.add_naca(3412) 48 # af2.info_save() 49 # spar3 = creator.wing.Spar(af2, 'spar3', 0.23) 50 # spar4 = creator.wing.Spar(af2, 'spar4', 0.67) 51 # stringer2 = creator.wing.Stringer(af2, 'stringer2') 52 # stringer2.info_save(SAVE_PATH) 53 54 population = acs.generator.Population(10000) 55 acs.evaluator.analyze_all(population) # 123s with multiprocessing :-( 56 57 def foo(size): 58 for _ in range(size): 59 print(acs.evaluator.analyze(acs.creator.base.Aircraft.from_random())) 60 return None 61 62 foo(10000) # 106s 63 64 # Final execution time 65 final_time = time.time() - start_time 66 print(f"--- {round(final_time, 4)}s seconds ---") 67