def create_new_structure_obj(init_obj, x, fat_dict=None): ''' Returns a new calculation object to be used in optimization :param init_obj: :return: ''' x_old = [ init_obj.get_s(), init_obj.get_plate_thk(), init_obj.get_web_h(), init_obj.get_web_thk(), init_obj.get_fl_w(), init_obj.get_fl_thk(), init_obj.get_span(), init_obj.get_lg() ] sigma_y1_new = stress_scaling(init_obj.get_sigma_y1(), init_obj.get_plate_thk(), x[1]) sigma_y2_new = stress_scaling(init_obj.get_sigma_y2(), init_obj.get_plate_thk(), x[1]) tau_xy_new = stress_scaling(init_obj.get_tau_xy(), init_obj.get_plate_thk(), x[1]) sigma_x_new = stress_scaling_area(init_obj.get_sigma_x(), sum(get_field_tot_area(x_old)), sum(get_field_tot_area(x))) try: stf_type = x[8] except IndexError: stf_type = init_obj.get_stiffener_type() main_dict = { 'mat_yield': [init_obj.get_fy(), 'Pa'], 'span': [init_obj.get_span(), 'm'], 'spacing': [x[0], 'm'], 'plate_thk': [x[1], 'm'], 'stf_web_height': [x[2], 'm'], 'stf_web_thk': [x[3], 'm'], 'stf_flange_width': [x[4], 'm'], 'stf_flange_thk': [x[5], 'm'], 'structure_type': [init_obj.get_structure_type(), ''], 'stf_type': [stf_type, ''], 'sigma_y1': [sigma_y1_new, 'MPa'], 'sigma_y2': [sigma_y2_new, 'MPa'], 'sigma_x': [sigma_x_new, 'MPa'], 'tau_xy': [tau_xy_new, 'MPa'], 'plate_kpp': [init_obj.get_kpp(), ''], 'stf_kps': [init_obj.get_kps(), ''], 'stf_km1': [init_obj.get_km1(), ''], 'stf_km2': [init_obj.get_km2(), ''], 'stf_km3': [init_obj.get_km3(), ''] } if fat_dict == None: return calc.Structure(main_dict)
def opt_input(): obj_dict = ex.obj_dict fat_obj = ex.get_fatigue_object() fp = ex.get_fatigue_pressures() fat_press = ((fp['p_ext']['loaded'],fp['p_ext']['ballast'],fp['p_ext']['part']), (fp['p_int']['loaded'],fp['p_int']['ballast'],fp['p_int']['part'])) x0 = [obj_dict['spacing'][0], obj_dict['plate_thk'][0], obj_dict['stf_web_height'][0], obj_dict['stf_web_thk'][0], obj_dict['stf_flange_width'][0], obj_dict['stf_flange_thk'][0], obj_dict['span'][0], 10] obj = calc.Structure(obj_dict) lat_press = 271.124 upper_bounds = np.array([0.6, 0.01, 0.3, 0.01, 0.1, 0.01, 3.5, 10]) lower_bounds = np.array([0.8, 0.02, 0.5, 0.02, 0.22, 0.03, 3.5, 10]) deltas = np.array([0.05, 0.005, 0.05, 0.005, 0.05, 0.005]) return obj, upper_bounds, lower_bounds, lat_press, deltas, fat_obj, fat_press, x0
def get_structure_object(line=None): if line in ('line12', 'line13', 'line11', 'line4'): return calc_structure.Structure(obj_dict_fr) else: return calc_structure.Structure(obj_dict)
def structure_cls(): return calc.Structure(ex.obj_dict), calc.Structure(ex.obj_dict2), calc.Structure(ex.obj_dict_L)
if __name__ == '__main__': obj_dict = test.obj_dict fat_obj = test.get_fatigue_object() fp = test.get_fatigue_pressures() fat_press = ((fp['p_ext']['loaded'], fp['p_ext']['ballast'], fp['p_ext']['part']), (fp['p_int']['loaded'], fp['p_int']['ballast'], fp['p_int']['part'])) x0 = [ obj_dict['spacing'][0], obj_dict['plate_thk'][0], obj_dict['stf_web_height'][0], obj_dict['stf_web_thk'][0], obj_dict['stf_flange_width'][0], obj_dict['stf_flange_thk'][0], obj_dict['span'][0], 10 ] obj = calc.Structure(obj_dict) lat_press = 271.124 calc_object = calc.CalcScantlings(obj_dict) upper_bounds = np.array([0.6, 0.01, 0.3, 0.01, 0.05, 0.01, 3.5, 10]) lower_bounds = np.array([0.8, 0.025, 0.5, 0.022, 0.25, 0.03, 3.5, 10]) deltas = np.array([0.02, 0.002, 0.01, 0.002, 0.02, 0.002]) geo_opt_obj = test.get_geo_opt_object() geo_opt_press = test.get_geo_opt_presure() print('Initial x is:', x0) print( 'Initial constraint ok? ', True if any_constraints_all(x0, obj, lat_press, calc_weight(x0), fat_dict=fat_obj.get_fatigue_properties(),