View raw

1 """This example illustrates the usage of creator, evaluator and generator. 2 3 All the steps of airfoil creation & evaluation are detailed here; 4 however, the generator.py module contains certain presets (default airfoils). 5 6 Create an airfoil; 7 Evaluate an airfoil; 8 Generate a population of airfoils & optimize. 9 """ 10 11 from tools import creator, evaluator, generator 12 13 import time 14 start_time = time.time() 15 16 # Airfoil dimensions (in) 17 NACA_NUM = 2412 18 CHORD_LENGTH = 68 19 SEMI_SPAN = 150 20 21 # Thicknesses 22 SPAR_THICKNESS = 0.4 23 SKIN_THICKNESS = 0.1 24 25 # Component masses (lbs) 26 AIRFOIL_MASS = 10 27 SPAR_MASS = 10 28 STRINGER_MASS = 5 29 30 # Area (sqin) 31 SPAR_CAP_AREA = 0.3 32 STRINGER_AREA = 0.1 33 34 # Amount of stringers 35 TOP_STRINGERS = 6 36 BOTTOM_STRINGERS = 4 37 NOSE_TOP_STRINGERS = 3 38 NOSE_BOTTOM_STRINGERS = 5 39 40 SAVE_PATH = '/home/blendux/github/UCLA_MAE_154B/save/' 41 42 # Create airfoil instance 43 af = creator.Airfoil.from_dimensions(CHORD_LENGTH, SEMI_SPAN) 44 af.add_naca(NACA_NUM) 45 af.add_mass(AIRFOIL_MASS) 46 af.info_print(2) 47 af.info_save(SAVE_PATH, 'foo_name') 48 49 # Create spar instance 50 af.spar = creator.Spar() 51 # All spar coordinates are stored in single Spar object 52 af.spar.add_coord(af, 0.23) 53 af.spar.add_coord(af, 0.57) 54 # Automatically adds spar caps for each spar previously defined 55 af.spar.add_spar_caps(SPAR_CAP_AREA) 56 af.spar.add_mass(SPAR_MASS) 57 af.spar.add_webs(SPAR_THICKNESS) 58 af.spar.info_print(2) 59 af.spar.info_save(SAVE_PATH, 'foo_name') 60 61 # Create stringer instance 62 af.stringer = creator.Stringer() 63 # Compute the stringer coordinates from their quantity in each zone 64 af.stringer.add_coord(af, NOSE_TOP_STRINGERS, TOP_STRINGERS, 65 NOSE_BOTTOM_STRINGERS, BOTTOM_STRINGERS) 66 af.stringer.add_area(STRINGER_AREA) 67 af.stringer.add_mass(STRINGER_MASS) 68 af.stringer.add_webs(SKIN_THICKNESS) 69 af.stringer.info_print(2) 70 af.stringer.info_save(SAVE_PATH, 'foo_name') 71 72 # Plot components with matplotlib 73 creator.plot_geom(af, True) 74 75 # Evaluator object contains airfoil analysis results. 76 eval = evaluator.Evaluator(af) 77 # The analysis is performed in the evaluator.py module. 78 eval.analysis(1, 1) 79 eval.info_print(2) 80 eval.info_save(SAVE_PATH, 'foo_name') 81 # evaluator.plot_geom(eval) 82 evaluator.plot_lift(eval) 83 84 pop = generator.Population(10) 85 86 # print(help(creator)) 87 # print(help(evaluator)) 88 # print(help(generator)) 89 90 # Print final execution time 91 print("--- %s seconds ---" % (time.time() - start_time)) 92