def setup(self): shape = self.options['shape'] # comp = GeometryComp() self.add_subsystem('geometry_comp', comp, promotes = ['*']) comp = PowerCombinationComp( shape = shape, out_name = 'wing_chord', coeff = 1., powers_dict=dict( wing_area = 1., wing_span = -1., ) ) self.add_subsystem('wing_chord_comp',comp, promotes = ['*']) comp = PowerCombinationComp( shape = shape, out_name = 'tail_chord', coeff = 1., powers_dict=dict( tail_area = 1., tail_span = -1., ) ) self.add_subsystem('tail_chord_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] # mode = self.options['mode'] # comp = IndepVarComp() # comp.add_input('area', val = 0.05) # comp.add_output('AR', val = 10) # self.add_subsystem('inputs_comp', comp, promotes=['*']) # b = sqrt(AR * S) comp = PowerCombinationComp(shape=shape, out_name='wing_span', powers_dict=dict( AR=0.5, area=0.5, )) self.add_subsystem('wing_span_comp', comp, promotes=['*']) # c = b / AR oas_shape = (9, ) comp = PowerCombinationComp(shape=shape, out_name='wing_chord', powers_dict=dict( AR=-1., wing_span=1., )) self.add_subsystem('wing_chord_comp', comp, promotes=['*']) comp = ScalarExpansionComp( shape=oas_shape, out_name='oas_wing_chord', in_name='wing_chord', ) self.add_subsystem('oas_wing_chord_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] module = self.options['options_dictionary'] comp = IndepVarComp() comp.add_output('throttle', shape=shape) comp.add_output('ref_3km_density', val=0.909122, shape=shape) comp.add_output('sealevel_density', val=1.225, shape=shape) self.add_subsystem('inputs_comp', comp, promotes=['*']) # comp = PowerCombinationComp( # shape=shape, # out_name='available_thrust', # coeff=0.369, # powers_dict=dict( # sealevel_thrust=1., # mach_number=-0.305, # density=1., # ref_3km_density=-1., # ), # ) # self.add_subsystem('available_thrust_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='available_thrust', powers_dict=dict( mach_number=0., sealevel_thrust=1., density=1., sealevel_density=-1., ), ) self.add_subsystem('available_thrust_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='thrust', powers_dict=dict( throttle=1., available_thrust=1., ), ) self.add_subsystem('thrust_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='mass_flow_rate', coeff=module['thrust_specific_fuel_consumption'], powers_dict=dict( thrust=1., ), ) self.add_subsystem('mass_flow_rate_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] #computations below: R = 287.058 gamma = 1.4 comp = PowerCombinationComp( # shape=shape, coeff=1 / np.sqrt(gamma * R), out_name='M_inf', powers_dict=dict( speed=1., temperature=-0.5, )) self.add_subsystem('mach_comp', comp, promotes=['*']) #### Thrust Compcomp = Zerospeed_Thrust() sealv_dens = 1.225 comp = PowerCombinationComp(shape=shape, coeff=1 / sealv_dens, out_name='zerospeed_thrust', powers_dict=dict( T_max=1., density=1., )) self.add_subsystem('zerospeed_thrust_comp', comp, promotes=['*']) # comp=Specific_Fuel_Consum() # self.add_subsystem('specific_fuel_consum_comp', comp, promotes=['*']) comp = Thrust_Ratio() self.add_subsystem('thrust_ratio_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='avaliable_thrust', powers_dict=dict( thrust_ratio=1., zerospeed_thrust=1., ), ) self.add_subsystem('avaliable_thrust', comp, promotes=['*']) comp = Thottled_Thrust() self.add_subsystem('thottled_thrust_comp', comp, promotes=['*']) mass_flow_rate_coeffecient = 0.61 comp = PowerCombinationComp( shape=shape, out_name='mass_flow_rate', coeff=mass_flow_rate_coeffecient, powers_dict=dict(thottled_thrust=1., ), ) self.add_subsystem('mass_flow_comp', comp, promotes=['*'])
def setup(self): num_times = self.options['num_times'] vec_name = self.options['vec_name'] norm_name = self.options['norm_name'] unit_vec_name = self.options['unit_vec_name'] comp = PowerCombinationComp( shape=(3, num_times), out_name='tmp_{}_2'.format(vec_name), powers_dict={vec_name: 2.}, ) self.add_subsystem('tmp_{}_2_comp'.format(vec_name), comp, promotes=['*']) comp = ArrayContractionComp( shape=(3, num_times), contract_indices=[0], out_name='tmp_{}_2'.format(norm_name), in_name='tmp_{}_2'.format(vec_name), ) self.add_subsystem('tmp_{}_2_comp'.format(norm_name), comp, promotes=['*']) comp = PowerCombinationComp( shape=(num_times, ), out_name=norm_name, powers_dict={'tmp_{}_2'.format(norm_name): 0.5}, ) self.add_subsystem('{}_comp'.format(norm_name), comp, promotes=['*']) comp = ArrayExpansionComp( shape=(3, num_times), expand_indices=[0], out_name='tmp_{}_expanded'.format(norm_name), in_name=norm_name, ) self.add_subsystem('tmp_{}_expanded_comp'.format(norm_name), comp, promotes=['*']) comp = PowerCombinationComp(shape=(3, num_times), out_name=unit_vec_name, powers_dict={ vec_name: 1., 'tmp_{}_expanded'.format(norm_name): -1., }) self.add_subsystem('{}_comp'.format(unit_vec_name), comp, promotes=['*'])
def setup(self): shape = self.options['shape'] size = int(np.prod(shape)) group = Group() comp = PowerCombinationComp( shape=shape, out_name='altitude_km', coeff=1.e-3, powers_dict=dict(altitude=1., ), ) self.add_subsystem('altitude_km_comp', comp, promotes=['*']) comp = TemperatureComp(shape=shape) self.add_subsystem('temperature_comp', comp, promotes=['*']) comp = PressureComp(shape=shape) self.add_subsystem('pressure_comp', comp, promotes=['*']) comp = DensityComp(shape=shape) self.add_subsystem('density_comp', comp, promotes=['*']) comp = SonicSpeedComp(shape=shape) self.add_subsystem('sonic_speed_comp', comp, promotes=['*']) comp = ViscosityComp(shape=shape) self.add_subsystem('viscosity_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='mach_number', powers_dict=dict( speed=1., sonic_speed=-1., ), ) self.add_subsystem('mach_number_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='dynamic_pressure', coeff=0.5, powers_dict=dict( density=1., speed=2., ), ) self.add_subsystem('dynamic_pressure_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] comp = IndepVarComp() comp.add_output('C_L') comp.add_output('L_t', val=0.2) comp.add_output('area') self.add_subsystem('inputs_comp', comp, promotes=['*']) # L = CL^1 0.5 rho^1 V^2 S^1 comp = PowerCombinationComp(shape=shape, out_name='L_w', coeff=0.5, powers_dict=dict( C_L=1., density=1., speed=2., area=1., )) self.add_subsystem('wing_lift_comp', comp, promotes=['*']) # L = 1. x L_w + 1. x L_t comp = LinearCombinationComp(shape=shape, out_name='L', constant=0., coeffs_dict=dict( L_w=1., L_t=1., )) self.add_subsystem('total_lift_comp', comp, promotes=['*'])
def setup(self): num_times = self.options['num_times'] in1_name = self.options['in1_name'] in2_name = self.options['in2_name'] out_name = self.options['out_name'] shape = (3, num_times) comp = PowerCombinationComp( shape=shape, out_name='tmp_{}_multiplied'.format(out_name), powers_dict={ in1_name: 1., in2_name: 2., }, ) self.add_subsystem('tmp_{}_multiplied_comp'.format(out_name), comp, promotes=['*']) comp = ArrayContractionComp( shape=shape, contract_indices=[0], out_name='tmp_{}_summed'.format(out_name), in_name='tmp_{}_multiplied'.format(out_name), ) self.add_subsystem('{}_summed_comp'.format(out_name), comp, promotes=['*']) comp = ArrayExpansionComp( shape=shape, expand_indices=[0], in_name='tmp_{}_summed'.format(out_name), out_name=out_name, ) self.add_subsystem('{}_comp'.format(out_name), comp, promotes=['*'])
def setup(self): shape = self.options['shape'] comp = ExecComp('thrust_torque_hover = thrust * wing_span', shape=shape) self.add_subsystem('thrust_torque_hover_comp', comp, promotes=['*']) comp = ExecComp('drag_torque_hover = drag * radius * 1.5', shape=shape) self.add_subsystem('drag_torque_hover_comp', comp, promotes=['*']) comp = LinearCombinationComp( shape=shape, in_names=['thrust_torque_hover', 'drag_torque_hover'], out_name='vertical_torque', coeffs=[1., -1.]) self.add_subsystem('vertical_torque_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='vertical_shaft_power', coeff=1., powers_dict=dict( vertical_torque=1., hover_wing_angular_speed=1., )) self.add_subsystem('vertical_shaft_power_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] part = self.options['part'] lift_coeff_zero_alpha = part['lift_coeff_zero_alpha'] lift_curve_slope_2D = part['lift_curve_slope_2D'] dynamic_pressure_ratio = part['dynamic_pressure_ratio'] downwash_slope = part['downwash_slope'] wing_exposed_ratio = part['wing_exposed_ratio'] fuselage_diameter_span = part['fuselage_diameter_span'] comp = LiftCurveSlopeDenominatorComp( shape=shape, lift_curve_slope_2D=lift_curve_slope_2D, wing_exposed_ratio=wing_exposed_ratio, fuselage_diameter_span=fuselage_diameter_span, ) self.add_subsystem('lift_curve_slope_denominator_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='lift_curve_slope', coeff=2 * np.pi * wing_exposed_ratio * 1.07 * (1. + fuselage_diameter_span)**2., powers_dict=dict( aspect_ratio=1., lift_curve_slope_denominator=-1., ), ) self.add_subsystem('lift_curve_slope_comp', comp, promotes=['*']) comp = LinearCombinationComp( shape=shape, out_name='lift_curve_slope_modified', coeffs_dict=dict(lift_curve_slope=(1 - downwash_slope) * dynamic_pressure_ratio, )) self.add_subsystem('lift_curve_slope_modified_comp', comp, promotes=['*']) comp = LinearPowerCombinationComp( shape=shape, out_name='lift_coeff', constant=dynamic_pressure_ratio * lift_coeff_zero_alpha, terms_list=[ (dynamic_pressure_ratio * (1 - downwash_slope), dict( lift_curve_slope=1., alpha=1., )), (dynamic_pressure_ratio, dict( lift_curve_slope=1., incidence_angle=1., )), ], ) self.add_subsystem('lift_coeff_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] # find = self.options['find'] comp = PowerCombinationComp( shape=shape, out_name='altitude_km', coeff=1.e-3, powers_dict=dict(altitude=1., ), ) self.add_subsystem('altitude_km_comp', comp, promotes=['*']) comp = TemperatureComp(shape=shape) self.add_subsystem('temperature_comp', comp, promotes=['*']) comp = PressureComp(shape=shape) self.add_subsystem('pressure_comp', comp, promotes=['*']) comp = DensityComp(shape=shape) self.add_subsystem('density_comp', comp, promotes=['*']) comp = SonicSpeedComp(shape=shape) self.add_subsystem('sonic_speed_comp', comp, promotes=['*']) # comp = ViscosityComp(shape=shape) # self.add_subsystem('viscosity_comp', comp, promotes=['*']) # if find == 'angle': # comp = PowerCombinationComp( # shape=shape, # out_name='speed', # powers_dict=dict( # mach_number=1., # sonic_speed=1., # ), # ) # self.add_subsystem('speed_comp', comp, promotes=['*']) # comp = PowerCombinationComp( # shape=shape, # out_name='dynamic_pressure', # coeff=0.5, # powers_dict=dict( # density=1., # speed=2., # ), # ) # self.add_subsystem('dynamic_pressure_comp', comp, promotes=['*']) # else: # pass # need to edit mach number comp in atmosphere to find speed given sonic speed and mach number (input) # then connect this output speed to the dynamic_pressure_comp speed input
def setup(self): shape = self.options['shape'] comp = PowerCombinationComp( shape=shape, out_name='aspect_ratio', powers_dict=dict( wing_span=1., mean_chord=-1., ), ) self.add_subsystem('aspect_ratio', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] module = self.options['options_dictionary'] comp = IndepVarComp() comp.add_output('throttle', shape=shape) comp.add_output('sealevel_density', val=1.225, shape=shape) self.add_subsystem('inputs_comp', comp, promotes=['*']) comp = LinearPowerCombinationComp( shape=shape, out_name='available_power', terms_list=[ (1.132, dict( density=1., sealevel_density=-1., sealevel_power=1., )), (-0.132, dict(sealevel_power=1., )), ], ) self.add_subsystem('available_power_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='power', powers_dict=dict( throttle=1., available_power=1., ), ) self.add_subsystem('power_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='mass_flow_rate', coeff=module['brake_specific_fuel_consumption'], powers_dict=dict(power=1., ), ) self.add_subsystem('mass_flow_rate_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] # comp = IndepVarComp() # comp.add_output('hover_wing_angular_speed') # # if design variable, add as output in IVC # self.add_subsystem('inputs_comp', comp, promotes = ['*']) # make connections in run_group (aero_geom_group to this one for wing_span) # r = b/2/(cos(sweep)) comp = ExecComp('radius = wing_span/2/(cos(sweep*pi/180))', shape=shape) self.add_subsystem('radius_comp', comp, promotes=['*']) # ExecComp defines the equation and calculates given the equation/inputs # Need to connect sweep/wingspan to this Group and then can compute the # hover velocity below # V = 2pi*RPM/60*.75*radius or V = 2pi*RPM/60*.75* b/2/(cos(sweep)) # V = omega * r comp = PowerCombinationComp(shape=shape, coeff=.75, out_name='hover_drag_velocity', powers_dict=dict( hover_wing_angular_speed=1., radius=1., )) self.add_subsystem('hover_drag_velocity_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, coeff=.5, out_name='hover_torque_velocity', powers_dict=dict( hover_wing_angular_speed=1., wing_span=1., )) self.add_subsystem('hover_torque_velocity_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] ## Need CDv CD0 CL0 CLa #comp = PressureComp() #self.add_subsystem('pressure_comp', comp, promotes=['*']) #comp = TemperatureComp() #self.add_subsystem('temperature_comp', comp, promotes=['*']) #comp = DensityComp() #self.add_subsystem('density_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, coeff=1/2, out_name='drag', powers_dict=dict( speed=2., density=1, drag_coeff = 1., ) ) self.add_subsystem('drag_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='Lift', powers_dict=dict( drag = 1., lift_to_drag_ratio = 1 ) ) self.add_subsystem('lift_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] # comp = IndepVarComp() # comp.add_output('C_D') # comp.add_output('C_L') # comp.add_output('speed') # comp.add_output('density') # comp.add_output('area') # self.add_subsystem('inputs_comp', comp, promotes=['*']) # # D = 0.5 * rho * v^2 * C_D * S # comp = PowerCombinationComp( # shape=shape, # out_name='cruise_drag', # coeff=0.5, # powers_dict=dict( # area=1., # C_D=1, # speed=2., # density=1. # ) # ) # self.add_subsystem('cruise_drag_comp', comp, promotes=['*']) # # L = 0.5 * rho * v^2 * C_L * S # comp = PowerCombinationComp( # shape=shape, # out_name='cruise_lift', # coeff=0.5, # powers_dict=dict( # area=1., # C_L=1, # speed=2., # density=1. # ) # ) # self.add_subsystem('cruise_lift_comp', comp, promotes=['*']) # L_D = C_L/C_D comp = PowerCombinationComp(shape=shape, out_name='L_D', powers_dict=dict(C_L=1, C_D=-1.)) self.add_subsystem('L_D_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] comp = IndepVarComp() comp.add_output('motor_efficiency') comp.add_output('voltage') self.add_subsystem('inputs_comp', comp, promotes = ['*']) comp = PowerCombinationComp( shape = shape, out_name = 'propeller_shaft_power', coeff = 1., powers_dict = dict( motor_efficiency = 1., voltage = 1., current = 1., ) ) self.add_subsystem('propeller_shaft_power_comp', comp)
def setup(self): shape = self.options['shape'] g = self.options['g'] EMD = self.options['EMD'] W0 = self.options['W0'] Wb = self.options['Wb'] # comp = IndepVarComp() # comp.add_output('efficiency') # Propellor Efficiency # comp.add_output('LD') # Lift to Drag Ratio # self.add_subsystem('inputs_comp', comp, promotes=['*']) # # self.add_subsystem('inputs_comp', comp) comp = PowerCombinationComp(shape=shape, out_name='range', coeff=EMD / g * Wb / W0, powers_dict=dict( efficiency=1., L_D=1., )) self.add_subsystem('range_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] module = self.options['options_dictionary'] comp = IndepVarComp() comp.add_output('mass', shape=shape) comp.add_output('normalized_torque', shape=shape) comp.add_output('angular_speed', shape=shape) for var_name in [ 'magnetic_flux_density', 'line_current_density', 'number_of_poles_per_phase', 'hysteresis_coeff', 'copper_resistivity', 'eta_slot', 'eta_fill', ]: comp.add_output(var_name, val=module[var_name], shape=shape) self.add_subsystem('inputs_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='supply_frequency', coeff=(60 / (2 * np.pi)) * (1 / 120), powers_dict=dict( number_of_poles_per_phase=1., angular_speed=1., ), ) self.add_subsystem('supply_frequency_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='continuous_torque', coeff=module['torque_mass_coeff'], powers_dict=dict(mass=module['torque_mass_power'], ), ) self.add_subsystem('continuous_torque_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='continuous_power', coeff=module['specific_power'], powers_dict=dict(mass=1., ), ) self.add_subsystem('continuous_power_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='flux_weakening_torque', powers_dict=dict( continuous_power=1., angular_speed=-1., ), ) self.add_subsystem('flux_weakening_torque_comp', comp, promotes=['*']) comp = ElementwiseMinComp( shape=shape, out_name='available_torque', in_names=['continuous_torque', 'flux_weakening_torque'], rho=1.e-1, ) self.add_subsystem('available_torque_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='torque', powers_dict=dict( normalized_torque=1., available_torque=1., ), ) self.add_subsystem('torque_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='shaft_power', powers_dict=dict( torque=1., angular_speed=1., ), ) self.add_subsystem('shaft_power_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='mass_stator', coeff=0.53, powers_dict=dict(mass=1.), ) self.add_subsystem('mass_stator_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='mass_rotor', coeff=0.47, powers_dict=dict(mass=1.), ) self.add_subsystem('mass_rotor_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='outer_diameter', coeff=96.9, powers_dict=dict(mass=0.344, ), ) self.add_subsystem('outer_diameter_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='motor_length', coeff=0.35, powers_dict=dict(outer_diameter=1., ), ) self.add_subsystem('motor_length_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='stator_diameter', coeff=0.5, powers_dict=dict(outer_diameter=1., ), ) self.add_subsystem('stator_diameter_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='shaft_diameter', coeff=0.085, powers_dict=dict(outer_diameter=1., ), ) self.add_subsystem('shaft_diameter_comp', comp, promotes=['*']) comp = LinearCombinationComp( shape=shape, out_name='stator_thickness', coeffs_dict=dict(stator_diameter=.5, shaft_diameter=-.5), ) self.add_subsystem('stator_thickness_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='eddy_loss', coeff=1.1 * (1 / 50)**1.5, powers_dict=dict( supply_frequency=1.5, mass_stator=1., magnetic_flux_density=2., ), ) self.add_subsystem('eddy_loss_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='hysteresis_loss', powers_dict=dict(supply_frequency=1., mass_rotor=1., magnetic_flux_density=2., hysteresis_coeff=1.), ) self.add_subsystem('hysteresis_loss_comp', comp, promotes=['*']) comp = LinearCombinationComp( shape=shape, out_name='iron_loss', coeffs_dict=dict(hysteresis_loss=1., eddy_loss=1.), ) self.add_subsystem('iron_loss_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='heat_loss_nominal', coeff=0.5, powers_dict=dict(shaft_diameter=1., motor_length=1., copper_resistivity=1., line_current_density=2., eta_slot=-1., eta_fill=-1., stator_thickness=-1.), ) self.add_subsystem('heat_loss_nominal_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='heat_loss', powers_dict=dict(heat_loss_nominal=1., normalized_torque=2.), ) self.add_subsystem('heat_loss_comp', comp, promotes=['*']) comp = LinearCombinationComp( shape=shape, out_name='input_power', coeffs_dict=dict(shaft_power=1., iron_loss=1., heat_loss=1.), ) self.add_subsystem('input_power_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='motor_efficiency', coeff=100, powers_dict=dict( shaft_power=1., input_power=-1., ), ) self.add_subsystem('motor_efficiency_comp', comp, promotes=['*'])
def setup(self): num_times = self.options['num_times'] num_cp = self.options['num_cp'] step_size = self.options['step_size'] cubesat = self.options['cubesat'] mtx = self.options['mtx'] shape = (3, num_times) thrust_unit_vec = np.outer( np.array([1., 0., 0.]), np.ones(num_times), ) comp = IndepVarComp() comp.add_output('thrust_unit_vec_b_3xn', val=thrust_unit_vec) comp.add_output('thrust_scalar_mN_cp', val=1.e-3 * np.ones(num_cp)) comp.add_output('initial_propellant_mass', 0.17) comp.add_design_var('thrust_scalar_mN_cp', lower=0., upper=20000) self.add_subsystem('inputs_comp', comp, promotes=['*']) comp = MtxVecComp( num_times=num_times, mtx_name='rot_mtx_i_b_3x3xn', vec_name='thrust_unit_vec_b_3xn', out_name='thrust_unit_vec_3xn', ) self.add_subsystem('thrust_unit_vec_3xn_comp', comp, promotes=['*']) comp = LinearCombinationComp( shape=(num_cp, ), out_name='thrust_scalar_cp', coeffs_dict=dict(thrust_scalar_mN_cp=1.e-3), ) self.add_subsystem('thrust_scalar_cp_comp', comp, promotes=['*']) comp = BsplineComp( num_pt=num_times, num_cp=num_cp, jac=mtx, in_name='thrust_scalar_cp', out_name='thrust_scalar', ) self.add_subsystem('thrust_scalar_comp', comp, promotes=['*']) comp = ArrayExpansionComp( shape=shape, expand_indices=[0], in_name='thrust_scalar', out_name='thrust_scalar_3xn', ) self.add_subsystem('thrust_scalar_3xn_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='thrust_3xn', powers_dict=dict( thrust_unit_vec_3xn=1., thrust_scalar_3xn=1., ), ) self.add_subsystem('thrust_3xn_comp', comp, promotes=['*']) comp = LinearCombinationComp( shape=(num_times, ), out_name='mass_flow_rate', coeffs_dict=dict(thrust_scalar=-1. / (cubesat['acceleration_due_to_gravity'] * cubesat['specific_impulse']))) self.add_subsystem('mass_flow_rate_comp', comp, promotes=['*']) comp = PropellantMassRK4Comp( num_times=num_times, step_size=step_size, ) self.add_subsystem('propellant_mass_rk4_comp', comp, promotes=['*']) comp = ExecComp( 'total_propellant_used=propellant_mass[0] - propellant_mass[-1]', propellant_mass=np.empty(num_times), ) self.add_subsystem('total_propellant_used_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] module = self.options['options_dictionary'] blade_solidity = module['blade_solidity'] integrated_design_lift_coeff = module['integrated_design_lift_coeff'] comp = IndepVarComp() comp.add_output('radius_scalar') self.add_subsystem('inputs_comp', comp, promotes=['*']) comp = ScalarExpansionComp( shape=shape, out_name='radius', in_name='radius_scalar', ) self.add_subsystem('radius_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='diameter', coeff=2., powers_dict=dict(radius=1., )) self.add_subsystem('diameter_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='rotational_speed', coeff=1. / 2. / np.pi, powers_dict=dict(angular_speed=1., )) self.add_subsystem('rotational_speed_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='power_coeff', powers_dict=dict( shaft_power=1., density=-1., rotational_speed=-3., diameter=-5., )) self.add_subsystem('power_coeff_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='tip_speed', powers_dict=dict( radius=1., angular_speed=1., )) self.add_subsystem('tip_speed_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='tip_mach', powers_dict=dict( tip_speed=1., sonic_speed=-1., )) self.add_subsystem('tip_mach_comp', comp, promotes=['*']) comp = FlowAngleComp(shape=shape) self.add_subsystem('flow_angle_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='advance_ratio', coeff=np.pi, powers_dict=dict( speed=1., tip_speed=-1., )) self.add_subsystem('advance_ratio_comp', comp, promotes=['*']) comp = GlauertFactorComp(shape=shape) self.add_subsystem('glauert_factor_comp', comp, promotes=['*']) comp = BladeDragCoeffComp( shape=shape, integrated_design_lift_coeff=integrated_design_lift_coeff) self.add_subsystem('blade_drag_coeff_comp', comp, promotes=['*']) comp = Eta1Comp(shape=shape, blade_solidity=blade_solidity) self.add_subsystem('eta1_comp', comp, promotes=['*']) comp = Eta2Comp(shape=shape) self.add_subsystem('eta2_comp', comp, promotes=['*']) comp = Eta3Comp(shape=shape, blade_solidity=blade_solidity) self.add_subsystem('eta3_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='efficiency', powers_dict=dict( eta1=1., eta2=1., eta3=1., )) self.add_subsystem('efficiency_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='thrust_coeff', powers_dict=dict( efficiency=1., power_coeff=1., advance_ratio=-1., )) self.add_subsystem('thrust_coeff_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='thrust', powers_dict=dict( thrust_coeff=1., density=1., rotational_speed=2., diameter=4., )) self.add_subsystem('thrust_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='blade_loading_coeff', coeff=1. / blade_solidity, powers_dict=dict(thrust_coeff=1., )) self.add_subsystem('blade_loading_coeff_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='figure_of_merit', coeff=1. / np.sqrt(2 * np.pi), powers_dict=dict( thrust=1.5, density=-0.5, radius=-1., shaft_power=-1., )) self.add_subsystem('figure_of_merit_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='area', coeff=np.pi, powers_dict=dict(radius=2., )) self.add_subsystem('area_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='disk_loading_lb_ft2', coeff=units('lbf/ft^2', 'N/m^2'), powers_dict=dict( thrust=1., area=-1., )) self.add_subsystem('disk_loading_lb_ft2_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] part = self.options['part'] comp = IndepVarComp() comp.add_output('sweep_30', val=30. * np.pi / 180., shape=shape) self.add_subsystem('sweep_30_comp', comp, promotes=['*']) comp = ElementwiseMinComp( shape=shape, out_name='sweep_capped_30', in_names=['sweep', 'sweep_30'], rho=50., ) self.add_subsystem('sweep_capped_30_comp', comp, promotes=['*']) comp = LinearPowerCombinationComp( shape=shape, out_name='oswald_efficiency_unswept', constant=1.14, terms_list=[ (-1.78 * 0.045, dict(aspect_ratio=0.68, )), ], ) self.add_subsystem('oswald_efficiency_unswept_comp', comp, promotes=['*']) comp = LinearPowerCombinationComp( shape=shape, out_name='oswald_efficiency_swept', constant=-3.1, terms_list=[ (4.61, dict(cos_sweep=0.15, )), (-4.61 * 0.045, dict( aspect_ratio=0.68, cos_sweep=0.15, )), ], ) self.add_subsystem('oswald_efficiency_swept_comp', comp, promotes=['*']) comp = LinearPowerCombinationComp( shape=shape, out_name='oswald_efficiency', terms_list=[ (1., dict(oswald_efficiency_unswept=1., )), (-1. / (30. * np.pi / 180.), dict( oswald_efficiency_unswept=1., sweep_capped_30=1., )), (1. / (30. * np.pi / 180.), dict( oswald_efficiency_swept=1., sweep_capped_30=1., )), ], ) self.add_subsystem('oswald_efficiency_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='induced_drag_coeff', coeff=1. / np.pi, powers_dict=dict( lift_coeff=2., oswald_efficiency=-1., aspect_ratio=-1., ), ) self.add_subsystem('induced_drag_coeff_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] aircraft = self.options['aircraft'] part = self.options['part'] skin_friction_roughness = part['skin_friction_roughness'] laminar_pctg = part['laminar_pctg'] comp = PowerCombinationComp( shape=shape, out_name='Re', powers_dict=dict( density=1., speed=1., characteristic_length=1., dynamic_viscosity=-1., ), ) self.add_subsystem('Re_comp', comp, promotes=['*']) if aircraft['regime'] == 'subsonic': comp = PowerCombinationComp( shape=shape, out_name='Re_cutoff', coeff=38.21 * skin_friction_roughness**-1.053, powers_dict=dict(characteristic_length=1.053, ), ) self.add_subsystem('Re_cutoff_comp', comp, promotes=['*']) elif aircraft['regime'] in ['transonic', 'supersonic']: comp = PowerCombinationComp( shape=shape, out_name='Re_cutoff', coeff=44.62 * skin_friction_roughness**-1.053, powers_dict=dict( characteristic_length=1.053, mach_number=1.16, ), ) self.add_subsystem('Re_cutoff_comp', comp, promotes=['*']) else: raise Exception() comp = ElementwiseMinComp( shape=shape, out_name='Re_turbulent_min', in_names=['Re', 'Re_cutoff'], rho=1e-3, ) self.add_subsystem('Re_turbulent_min_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='skin_friction_coeff_laminar', coeff=1.328, powers_dict=dict(Re=-0.5, ), ) self.add_subsystem('skin_friction_coeff_laminar_comp', comp, promotes=['*']) def func(Re, M): Cf = 0.455 / (np.log(Re) / np.log(10))**2.58 / (1 + 0.144 * M**2)**0.65 return Cf def deriv(Re, M): dCf_dRe = -2.58 * 0.455 / ( np.log(Re) / np.log(10))**3.58 * 1 / Re / np.log(10) / ( 1 + 0.144 * M**2)**0.65 dCf_dM = 0.455 / (np.log(Re) / np.log(10))**2.58 * -0.65 / ( 1 + 0.144 * M**2)**1.65 * 2 * 0.144 * M return (dCf_dRe, dCf_dM) comp = GeneralOperationComp( shape=shape, out_name='skin_friction_coeff_turbulent', in_names=['Re_turbulent_min', 'mach_number'], func=func, deriv=deriv, ) self.add_subsystem('skin_friction_coeff_turbulent_comp', comp, promotes=['*']) comp = LinearCombinationComp( shape=shape, out_name='skin_friction_coeff', coeffs_dict=dict( skin_friction_coeff_laminar=laminar_pctg / 100., skin_friction_coeff_turbulent=1 - laminar_pctg / 100., ), ) self.add_subsystem('skin_friction_coeff_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] comp = PressureComp() self.add_subsystem('pressure_comp', comp, promotes=['*']) comp = TemperatureComp() self.add_subsystem('temperature_comp', comp, promotes=['*']) comp = DensityComp() self.add_subsystem('density_comp', comp, promotes=['*']) R = 287.058 gamma = 1.4 comp = PowerCombinationComp( # shape=shape, coeff=1 / np.sqrt(gamma * R), out_name='M_inf', powers_dict=dict( velocity_ms=1., temperature=-0.5, )) self.add_subsystem('mach_comp', comp, promotes=['*']) ## Need CDv CD0 CL0 CLa comp = LinearPowerCombinationComp( shape=shape, out_name='CL', terms_list=[ (1., dict( alpha=1., CLa=1., )), (1., dict(CL0=1., )), ], ) self.add_subsystem('CL_comp', comp, promotes=['*']) comp = WaveDragCoeffComp() self.add_subsystem('CDw_comp', comp, promotes=['*']) e = 0.7 comp = PowerCombinationComp(shape=shape, coeff=1 / (np.pi * e), out_name='CDi', powers_dict=dict( CL=2., aspect_ratio=-1, )) self.add_subsystem('CDi_comp', comp, promotes=['*']) comp = LinearCombinationComp( shape=shape, in_names=['CDi', 'CDv', 'CDw', 'CD0'], out_name='CD', coeffs=[1., 1., 1., 1.], ) self.add_subsystem('CD_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, coeff=1 / 2, out_name='drag', powers_dict=dict( velocity_ms=2., density=1, CD=1., )) self.add_subsystem('drag_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='LD', #lift over drag powers_dict=dict( CL=1., CD=-1., )) self.add_subsystem('lift_over_drag_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='Lift', powers_dict=dict(drag=1., LD=1)) self.add_subsystem('lift_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] comp = PowerCombinationComp( shape=shape, out_name='altitude_km', coeff=1.e-3, powers_dict=dict(altitude=1., ), ) self.add_subsystem('altitude_km_comp', comp, promotes=['*']) comp = TemperatureComp(shape=shape) self.add_subsystem('temperature_comp', comp, promotes=['*']) comp = PressureComp(shape=shape) self.add_subsystem('pressure_comp', comp, promotes=['*']) comp = DensityComp(shape=shape) self.add_subsystem('density_comp', comp, promotes=['*']) comp = SonicSpeedComp(shape=shape) self.add_subsystem('sonic_speed_comp', comp, promotes=['*']) comp = ViscosityComp(shape=shape) self.add_subsystem('viscosity_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='re', powers_dict=dict( dynamic_viscosity=-1, characteristic_length=1, v=1, ), ) self.add_subsystem('reynolds_number_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='Mach_number', powers_dict=dict( v=1., sonic_speed=-1., ), ) self.add_subsystem('Mach_number_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='rho', powers_dict=dict(density=1., ), ) self.add_subsystem('rho_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='dynamic_pressure', coeff=0.5, powers_dict=dict( rho=1., v=2., ), ) self.add_subsystem('dynamic_pressure_comp', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] # module = self.options['options_dictionary'] # comp = PercentBlownComp() self.add_subsystem('percent_blown_comp', comp, promotes=['*']) comp = AxialIntComp() self.add_subsystem('axial_int_comp', comp, promotes=['*']) comp = AverageAxialIntComp() self.add_subsystem('average_axial_int_comp', comp, promotes=['*']) comp = CLWingComp() self.add_subsystem('cl_wing_comp', comp, promotes=['*']) comp = CLTailComp() self.add_subsystem('cl_tail_comp', comp, promotes=['*']) comp = CDiWingComp() self.add_subsystem('cdi_wing_comp', comp, promotes=['*']) comp = CDiTailComp() self.add_subsystem('cdi_tail_comp', comp, promotes=['*']) # comp = ExecComp('wing_lift = wing_CL*q*wing_area') # self.add_subsystem('wing_lift_comp', comp, promotes= ['*']) comp = PowerCombinationComp(shape=shape, out_name='wing_lift', coeff=0.5, powers_dict=dict( wing_CL=1., density=1., v_inf=2., wing_area=1., )) self.add_subsystem('wing_lift_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='tail_lift', coeff=0.5, powers_dict=dict( tail_CL=1., density=1., v_inf=2., tail_area=1., )) self.add_subsystem('tail_lift_comp', comp, promotes=['*']) comp = LinearCombinationComp(shape=shape, out_name='total_lift', constant=0., coeffs_dict=dict( wing_lift=1., tail_lift=1., )) self.add_subsystem('total_lift_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='wing_Re', coeff=1., powers_dict=dict( density=1., v_inf=1., wing_chord=1., dynamic_viscosity=-1., )) self.add_subsystem('wing_Re_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='tail_Re', coeff=1., powers_dict=dict( density=1., v_inf=1., tail_chord=1., dynamic_viscosity=-1., )) self.add_subsystem('tail_Re_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='fuselage_Re', coeff=1., powers_dict=dict( density=1., v_inf=1., fuselage_length=1., dynamic_viscosity=-1., )) self.add_subsystem('fuselage_Re_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='vertical_tail_Re', coeff=1., powers_dict=dict( density=1., v_inf=1., vertical_tail_mac=1., dynamic_viscosity=-1., )) self.add_subsystem('vertical_tail_Re_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='mach_number', coeff=1., powers_dict=dict(v_inf=1., sonic_speed=-1.)) self.add_subsystem('mach_number_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='wing_skin_friction', coeff=1.328, powers_dict=dict(wing_Re=-0.5, )) self.add_subsystem('wing_skin_friction_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='tail_skin_friction', coeff=1.328, powers_dict=dict(tail_Re=-0.5, )) self.add_subsystem('tail_skin_friction_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='fuselage_skin_friction', coeff=1.328, powers_dict=dict(fuselage_Re=-0.5, )) self.add_subsystem('fuselage_skin_friction_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='vertical_tail_skin_friction', coeff=1.328, powers_dict=dict(vertical_tail_Re=-0.5, )) self.add_subsystem('vertical_tail_skin_friction_comp', comp, promotes=['*']) comp = LinearPowerCombinationComp( shape=shape, out_name='wing_form_factor_1', terms_list=[ (100, dict(wing_tc=4., )), (2, dict( wing_tc=1., wing_chord=-1., )), ], constant=1., ) self.add_subsystem('wing_form_factor_1_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='form_factor_mach_component', coeff=1.34, powers_dict=dict(mach_number=0.18)) self.add_subsystem('form_factor_mach_component_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='wing_form_factor', coeff=1., powers_dict=dict( wing_form_factor_1=1., form_factor_mach_component=1., )) self.add_subsystem('wing_form_factor_comp', comp, promotes=['*']) comp = LinearPowerCombinationComp( shape=shape, out_name='tail_form_factor_1', terms_list=[ (100, dict(tail_tc=4., )), (2, dict( tail_tc=1., tail_chord=-1., )), ], constant=1., ) self.add_subsystem('tail_form_factor_1_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='tail_form_factor', coeff=1., powers_dict=dict( tail_form_factor_1=1., form_factor_mach_component=1., )) self.add_subsystem('tail_form_factor_comp', comp, promotes=['*']) comp = LinearPowerCombinationComp( shape=shape, out_name='vertical_tail_form_factor_1', terms_list=[ (100, dict(tail_tc=4., )), (2, dict( vertical_tail_tc=1., vertical_tail_mac=-1., )), ], constant=1., ) self.add_subsystem('vertical_tail_form_factor_1_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='vertical_tail_form_factor', coeff=1., powers_dict=dict( vertical_tail_form_factor_1=1., form_factor_mach_component=1., )) self.add_subsystem('vertical_tail_form_factor_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='wing_wetted_area', coeff=2.3, powers_dict=dict(wing_area=1., )) self.add_subsystem('wing_wetted_area_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='tail_wetted_area', coeff=2.3, powers_dict=dict(tail_area=1., )) self.add_subsystem('tail_wetted_area_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='vertical_tail_wetted_area', coeff=2.3, powers_dict=dict(vertical_tail_area=1., )) self.add_subsystem('vertical_tail_wetted_area_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='parasite_drag_wing', coeff=1.1, powers_dict=dict( wing_skin_friction=1., wing_form_factor=1., wing_wetted_area=1., wing_area=-1., )) self.add_subsystem('parasite_drag_wing_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='parasite_drag_tail', coeff=1.1, powers_dict=dict( tail_skin_friction=1., tail_form_factor=1., tail_wetted_area=1., wing_area=-1., )) self.add_subsystem('parasite_drag_tail_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='parasite_drag_fuselage', coeff=1.1, powers_dict=dict( fuselage_skin_friction=1., fuselage_form_factor=1., fuselage_wetted_area=1., wing_area=-1., )) self.add_subsystem('parasite_drag_fuselage_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='parasite_drag_vertical_tail', coeff=1.1, powers_dict=dict( vertical_tail_skin_friction=1., vertical_tail_form_factor=1., vertical_tail_wetted_area=1., wing_area=-1., )) self.add_subsystem('parasite_drag_vertical_tail_comp', comp, promotes=['*']) comp = LinearCombinationComp(shape=shape, out_name='parasite_CD0', constant=0., coeffs_dict=dict( parasite_drag_wing=1., parasite_drag_tail=1., parasite_drag_fuselage=1., parasite_drag_vertical_tail=1., )) self.add_subsystem('parasite_drag_comp', comp, promotes=['*']) comp = LinearCombinationComp(shape=shape, out_name='total_CD', constant=0., coeffs_dict=dict( parasite_CD0=1., wing_CDi=1., tail_CDi=1., )) self.add_subsystem('total_CD_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='total_drag', coeff=0.5, powers_dict=dict( total_CD=1., density=1., v_inf=2., wing_area=1., )) self.add_subsystem('total_drag_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='lift_drag_ratio', coeff=1., powers_dict=dict( total_lift=1., total_drag=-1., )) self.add_subsystem('lift_drag_ratio', comp, promotes=['*'])
def setup(self): shape = self.options['shape'] comp = PowerCombinationComp( shape = shape, out_name = 'total_avail_energy', coeff = 3600., powers_dict=dict( battery_mass = 1., batter_energy_density = 1., ) ) self.add_subsystem('total_avail_energy_comp', comp, promotes = ['*']) comp = PowerCombinationComp( shape = shape, out_name = 'total_avail_energy_kWh', coeff = 3600/(1000*3600), powers_dict=dict( battery_mass = 1., batter_energy_density = 1., ) ) self.add_subsystem('total_avail_energy_kWh_comp', comp, promotes = ['*']) comp = LinearPowerCombinationComp( shape = shape, out_name = 'cruise_average_prop_efficiency', terms_list=[ (1/6, dict( cruise_tail_right_eff = 1., )), (1/6, dict( cruise_tail_left_eff = 1., )), (1/6, dict( cruise_wing_right_outer_eff = 1., )), (1/6, dict( cruise_wing_right_inner_eff = 1., )), (1/6, dict( cruise_wing_left_outer_eff = 1., )), (1/6, dict( cruise_wing_left_inner_eff = 1., )), ], constant = 0., ) self.add_subsystem('cruise_average_prop_efficiency_comp', comp, promotes = ['*']) comp = LinearPowerCombinationComp( shape = shape, out_name = 'hover_average_prop_efficiency', terms_list=[ (1/6, dict( hover_tail_right_eff = 1., )), (1/6, dict( hover_tail_left_eff = 1., )), (1/6, dict( hover_wing_right_outer_eff = 1., )), (1/6, dict( hover_wing_right_inner_eff = 1., )), (1/6, dict( hover_wing_left_outer_eff = 1., )), (1/6, dict( hover_wing_left_inner_eff = 1., )), ], constant = 0., ) self.add_subsystem('hover_average_prop_efficiency_comp', comp, promotes = ['*']) comp = LinearPowerCombinationComp( shape = shape, out_name = 'cruise_total_power', terms_list=[ (1, dict( cruise_tail_right_power = 1., )), (1, dict( cruise_tail_left_power = 1., )), (1, dict( cruise_wing_right_outer_power = 1., )), (1, dict( cruise_wing_right_inner_power = 1., )), (1, dict( cruise_wing_left_outer_power = 1., )), (1, dict( cruise_wing_left_inner_power = 1., )), ], constant = 0., ) self.add_subsystem('cruise_total_power_comp', comp, promotes = ['*']) comp = LinearPowerCombinationComp( shape = shape, out_name = 'hover_total_power', terms_list=[ (1, dict( hover_tail_right_power = 1., )), (1, dict( hover_tail_left_power = 1., )), (1, dict( hover_wing_right_outer_power = 1., )), (1, dict( hover_wing_right_inner_power = 1., )), (1, dict( hover_wing_left_outer_power = 1., )), (1, dict( hover_wing_left_inner_power = 1., )), ], constant = 0., ) self.add_subsystem('hover_total_power_comp', comp, promotes = ['*']) comp = PowerCombinationComp( shape = shape, out_name = 'cruise_time', coeff = 1., powers_dict = dict( distance = 1., v_inf = -1., ) ) self.add_subsystem('cruise_time', comp, promotes = ['*']) comp = PowerCombinationComp( shape = shape, out_name = 'cruise_energy_expenditure_kWh', coeff = 1/3600000, powers_dict=dict( cruise_time = 1., cruise_total_power = 1., ) ) self.add_subsystem('cruise_energy_expenditure_comp', comp, promotes = ['*']) comp = LinearCombinationComp( shape = shape, out_name = 'total_flight_time', constant = 0., coeffs_dict=dict( cruise_time = 1., t_tol = 1., ) ) self.add_subsystem('total_flight_time_comp', comp, promotes = ['*']) comp = PowerCombinationComp( shape = shape, out_name = 'trips_per_flight_hour', coeff = 3600., powers_dict=dict( total_flight_time = -1., ) ) self.add_subsystem('trips_per_flight_hour', comp, promotes= ['*']) comp = PowerCombinationComp( shape = shape, out_name = 'hover_energy_expenditure_kWh', coeff = 1/1000, powers_dict=dict( t_tol = 1., hover_total_power = 1., ) ) self.add_subsystem('hover_energy_expenditure_comp', comp, promotes = ['*']) comp = LinearCombinationComp( shape = shape, out_name = 'energy_expenditure_per_trip_kWh', constant = 0., coeffs_dict=dict( hover_energy_expenditure_kWh = 1., cruise_energy_expenditure_kWh = 1., ) ) self.add_subsystem('energy_expenditure_per_trip_comp',comp, promotes = ['*']) comp = LinearCombinationComp( shape = shape, out_name = 'energy_remaining', constant = 0., coeffs_dict=dict( total_avail_energy =1., cruise_energy_expenditure_kWh = -1., hover_energy_expenditure_kWh = -1., ) ) self.add_subsystem('energy_remaining_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape = shape, out_name = 'trips_per_charge', coeff = 1/(3600*1000), powers_dict=dict( total_avail_energy = 1., energy_expenditure_per_trip_kWh = -1., ) ) self.add_subsystem('trips_per_charge_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape = shape, out_name = 'aircraft_range', coeff = 1, powers_dict = dict( distance = 1., trips_per_charge = 1., ) ) self.add_subsystem('aircraft_range_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape = shape, out_name = 'design_range_energy_expenditure', coeff = 1., powers_dict=dict( distance = 1., GrossWeight = 1., cruise_average_prop_efficiency = -1., lift_drag_ratio = -1., ) ) self.add_subsystem('design_range_energy_expenditure_comp', comp, promotes = ['*']) comp = LinearCombinationComp( shape = shape, out_name = 'energy_remaining_1', constant = 0., coeffs_dict=dict( total_avail_energy =1., design_range_energy_expenditure = -1., ) ) self.add_subsystem('energy_remaining_1_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape = shape, out_name = 'Electric_Range_Equation', coeff = 1., powers_dict=dict( cruise_average_prop_efficiency = 1., batter_energy_density = 1., lift_drag_ratio = 1., battery_mass = 1., GrossWeight = -1., ) ) self.add_subsystem('Electric_Range_Equation_comp', comp, promotes = ['*'])
comp.add_design_var('alpha', lower=0.) model.add_subsystem('inputs_comp', comp, promotes=['*']) comp = CLComp() model.add_subsystem('cl_comp', comp, promotes=['*']) e = 0.7 if 1: comp = CDiComp(e=e) model.add_subsystem('cdi_comp', comp, promotes=['*']) else: from lsdo_utils.api import PowerCombinationComp comp = PowerCombinationComp(shape=(1, ), out_name='CDi', coeff=1. / np.pi / e, powers_dict=dict( CL=2., AR=-1., )) model.add_subsystem('cdi_comp', comp, promotes=['*']) comp = ExecComp('CD = CD0 + CDi') model.add_subsystem('cd_comp', comp, promotes=['*']) comp = ExecComp('LD = CL/CD') comp.add_objective('LD', scaler=-1.) model.add_subsystem('ld_comp', comp, promotes=['*']) prob.model = model prob.driver = ScipyOptimizeDriver()
def setup(self): num_times = self.options['num_times'] num_cp = self.options['num_cp'] cubesat = self.options['cubesat'] mtx = self.options['mtx'] comp = IndepVarComp() # comp.add_output('roll_cp', val=2. * np.pi * np.random.rand(num_cp)) # comp.add_output('pitch_cp', val=2. * np.pi * np.random.rand(num_cp)) comp.add_output('roll_cp', val=np.ones(num_cp)) comp.add_output('pitch_cp', val=np.ones(num_cp)) comp.add_design_var('roll_cp') comp.add_design_var('pitch_cp') self.add_subsystem('inputs_comp', comp, promotes=['*']) for var_name in ['roll', 'pitch']: comp = BsplineComp( num_pt=num_times, num_cp=num_cp, jac=mtx, in_name='{}_cp'.format(var_name), out_name=var_name, ) self.add_subsystem('{}_comp'.format(var_name), comp, promotes=['*']) comp = RotMtxBIComp(num_times=num_times) self.add_subsystem('rot_mtx_b_i_3x3xn_comp', comp, promotes=['*']) comp = ArrayReorderComp( in_shape=(3, 3, num_times), out_shape=(3, 3, num_times), in_subscripts='ijn', out_subscripts='jin', in_name='rot_mtx_b_i_3x3xn', out_name='rot_mtx_i_b_3x3xn', ) self.add_subsystem('rot_mtx_i_b_3x3xn_comp', comp, promotes=['*']) # for var_name in [ 'times', 'roll', 'pitch', ]: comp = FiniteDifferenceComp( num_times=num_times, in_name=var_name, out_name='d{}'.format(var_name), ) self.add_subsystem('d{}_comp'.format(var_name), comp, promotes=['*']) rad_deg = np.pi / 180. for var_name in [ 'roll', 'pitch', ]: comp = PowerCombinationComp(shape=(num_times, ), out_name='{}_rate'.format(var_name), powers_dict={ 'd{}'.format(var_name): 1., 'dtimes': -1., }) comp.add_constraint('{}_rate'.format(var_name), lower=-10. * rad_deg, upper=10. * rad_deg, linear=True) self.add_subsystem('{}_rate_comp'.format(var_name), comp, promotes=['*'])
def setup(self): shape = self.options['shape'] aircraft = self.options['aircraft'] geometry = self.options['geometry'] options_dictionary = self.options['options_dictionary'] comp = IndepVarComp() comp.add_output('dummy_var') self.add_subsystem('inputs_comp', comp, promotes=['*']) for part in geometry.children: name = part['name'] group = Group() # Passthrough for area if isinstance(part, LiftingSurfaceGeometry): comp = LinearCombinationComp( shape=shape, out_name='_area', coeffs_dict=dict( area=1., ), ) group.add_subsystem('area_comp', comp, promotes=['*']) else: comp = IndepVarComp() comp.add_output('_area', shape=shape) group.add_subsystem('area_comp', comp, promotes=['*']) # Cosine of sweep - useful for many calculations that follow if isinstance(part, LiftingSurfaceGeometry): def func(sweep): return np.cos(sweep) def deriv(sweep): return (-np.sin(sweep)) comp = GeneralOperationComp( shape=shape, out_name='cos_sweep', in_names=['sweep'], func=func, deriv=deriv, ) group.add_subsystem('cos_sweep_comp', comp, promotes=['*']) # Lift coefficient if isinstance(part, LiftingSurfaceGeometry): lift_group = LiftGroup( shape=shape, part=part, ) group.add_subsystem('lift_group', lift_group, promotes=['*']) elif isinstance(part, PartGeometry): comp = LinearCombinationComp( shape=shape, out_name='dummy_comp_var', coeffs_dict=dict( ref_area=1., alpha=1., wetted_area=1., characteristic_length=1., ), ) group.add_subsystem('dummy_comp', comp, promotes=['*']) comp = IndepVarComp() comp.add_output('lift_coeff', val=0., shape=shape) group.add_subsystem('lift_coeff_comp', comp, promotes=['*']) else: comp = LinearCombinationComp( shape=shape, out_name='dummy_comp_var', coeffs_dict=dict( alpha=1., ), ) group.add_subsystem('dummy_comp', comp, promotes=['*']) comp = IndepVarComp() comp.add_output('lift_coeff', val=0., shape=shape) group.add_subsystem('lift_coeff_comp', comp, promotes=['*']) # Induced drag coefficient if isinstance(part, LiftingSurfaceGeometry): induced_drag_group = InducedDragGroup( shape=shape, part=part, ) group.add_subsystem('induced_drag_group', induced_drag_group, promotes=['*']) else: comp = IndepVarComp() comp.add_output('induced_drag_coeff', val=0., shape=shape) group.add_subsystem('induced_drag_coeff_comp', comp, promotes=['*']) # Skin friction coefficient skin_friction_group = SkinFrictionGroup( shape=shape, aircraft=aircraft, part=part, ) group.add_subsystem('skin_friction_group', skin_friction_group, promotes=['*']) # Parasite drag coefficient---form factor if isinstance(part, LiftingSurfaceGeometry): thickness_chord = part['thickness_chord'] max_thickness_location = part['max_thickness_location'] comp = PowerCombinationComp( shape=shape, out_name='form_factor', coeff=1.34 * (1 + 0.6 / max_thickness_location * thickness_chord + 100. * thickness_chord ** 4), powers_dict=dict( mach_number=0.18, cos_sweep=0.28, ), ) group.add_subsystem('form_factor_comp', comp, promotes=['*']) elif isinstance(part, BodyGeometry): fuselage_aspect_ratio = part['fuselage_aspect_ratio'] comp = IndepVarComp() comp.add_output('form_factor', val=1 + 60. / fuselage_aspect_ratio ** 3. + fuselage_aspect_ratio / 400., shape=shape) group.add_subsystem('form_factor_comp', comp, promotes=['*']) # Parasite drag coefficient---interference factor comp = IndepVarComp() comp.add_output('interference_factor', val=part['interference_factor'], shape=shape) group.add_subsystem('interference_factor_comp', comp, promotes=['*']) # Parasite drag coefficient if isinstance(part, (LiftingSurfaceGeometry, BodyGeometry)): comp = PowerCombinationComp( shape=shape, out_name='parasite_drag_coeff', powers_dict=dict( skin_friction_coeff=1., form_factor=1., interference_factor=1., wetted_area=1., ref_area=-1., ), ) group.add_subsystem('parasite_drag_coeff_comp', comp, promotes=['*']) elif isinstance(part, PartGeometry): comp = IndepVarComp() comp.add_output('parasite_drag_coeff', val=part['parasite_drag_coeff'], shape=shape) group.add_subsystem('parasite_drag_coeff_comp', comp, promotes=['*']) else: comp = IndepVarComp() comp.add_output('parasite_drag_coeff', val=0., shape=shape) group.add_subsystem('parasite_drag_coeff_comp', comp, promotes=['*']) # Wave drag coefficient if isinstance(part, LiftingSurfaceGeometry): airfoil_technology_factor = part['airfoil_technology_factor'] thickness_chord = part['thickness_chord'] comp = LinearPowerCombinationComp( shape=shape, out_name='critical_mach_number', constant=-(0.1 / 80.) ** (1. / 3.), terms_list=[ (airfoil_technology_factor, dict( cos_sweep=-1., )), (-thickness_chord, dict( cos_sweep=-2., )), (-0.1, dict( cos_sweep=-3., lift_coeff=1., )), ], ) group.add_subsystem('critical_mach_number_comp', comp, promotes=['*']) comp = WaveDragCoeffComp(shape=shape) group.add_subsystem('wave_drag_coeff_comp', comp, promotes=['*']) else: comp = IndepVarComp() comp.add_output('wave_drag_coeff', val=0., shape=shape) group.add_subsystem('wave_drag_coeff_comp', comp, promotes=['*']) self.add_subsystem('{}_group'.format(name), group, promotes=[ 'density', 'speed', 'ref_area', 'dynamic_viscosity', 'alpha', 'mach_number', ]) # names = [] lift_coeff_names = [] lift_coeff_connects = [] area_names = [] area_connects = [] for part in geometry.children: name = part['name'] lift_coeff_name = '{}_group_lift_coeff'.format(name) src_lift_coeff_name = '{}_group.lift_coeff'.format(name) area_name = '{}_group_area'.format(name) src_area_name = '{}_group._area'.format(name) lift_coeff_names.append(lift_coeff_name) lift_coeff_connects.append((src_lift_coeff_name, lift_coeff_name)) area_names.append(area_name) area_connects.append((src_area_name, area_name)) names.append(name) comp = LinearPowerCombinationComp( shape=shape, out_name='lift_coeff', terms_list=[ (1., { lift_coeff_name: 1., area_name: 1., 'ref_area': -1., }) for lift_coeff_name, area_name in zip(lift_coeff_names, area_names) ], ) self.add_subsystem('lift_coeff_comp', comp, promotes=['*']) comp = LinearPowerCombinationComp( shape=shape, out_name='drag_coeff', terms_list=[ (1., { '{}_group_induced_drag_coeff'.format(name): 1., area_name: 1., 'ref_area': -1., }) for name, area_name in zip(names, area_names) ] + [ (1., { '{}_group_parasite_drag_coeff'.format(name): 1., # area_name: 0., # 'ref_area': 0., }) for name, area_name in zip(names, area_names) ] + [ (1., { '{}_group_wave_drag_coeff'.format(name): 1., area_name: 1., 'ref_area': -1., }) for name, area_name in zip(names, area_names) ], ) self.add_subsystem('drag_coeff_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='lift_to_drag_ratio', powers_dict=dict( lift_coeff=1., drag_coeff=-1., ), ) self.add_subsystem('lift_to_drag_ratio_comp', comp, promotes=['*']) for src, tgt in lift_coeff_connects: self.connect(src, tgt) for src, tgt in area_connects: self.connect(src, tgt) for name in names: self.connect( '{}_group.induced_drag_coeff'.format(name), '{}_group_induced_drag_coeff'.format(name), ) self.connect( '{}_group.parasite_drag_coeff'.format(name), '{}_group_parasite_drag_coeff'.format(name), ) self.connect( '{}_group.wave_drag_coeff'.format(name), '{}_group_wave_drag_coeff'.format(name), )