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'] 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'] 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=['*'])
# prob.model.add_subsystem('lift_comp', comp, promotes=['*']) # comp = thrustComp() # prob.model.add_subsystem('thrust_comp', comp, promotes=['*']) # Computes E = L/D for use in the breguet range component comp = ExecComp('LD = CL/CD') prob.model.add_subsystem('ld_comp', comp, promotes=['*']) # comp = ExecComp('TOD = thrust - drag ') # prob.model.add_subsystem('TOD', comp, promotes=['*']) comp = LinearPowerCombinationComp( shape=shape, out_name='LOW', terms_list=[ (1.0, dict(L=1., )), (-9.81, dict(emptyTotal=1, )), ], ) prob.model.add_subsystem('LOW', comp, promotes=['*']) prob.model.connect('aero_point_0.CL', 'CL') prob.model.connect('aero_point_0.CD', 'CD') prob.model.connect('aero_point_0.wing_perf.L', 'L') prob.model.connect('dihedral', 'wing.mesh.dihedral.dihedral') # prob.model.connect('chord', 'wing.mesh.scale_x.chord'[0]) # Import the Scipy Optimizer and set the driver of the problem to use # it, which defaults to an SLSQP optimization method # # recorder = om.SqliteRecorder("aero.db")
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 = ['*'])
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), )
def setup(self): shape = self.options['shape'] # module = self.options['options_dictionary'] # comp = LinearCombinationComp(shape=shape, out_name='vertical_hover_equilibrium', constant=0., coeffs_dict=dict( hover_total_thrust=1., GrossWeight=-1., )) self.add_subsystem('vertical_hover_equilibrium_comp', comp, promotes=['*']) comp = LinearCombinationComp(shape=shape, out_name='vertical_cruise_equilibrium', constant=0., coeffs_dict=dict( total_lift=1., GrossWeight=-1., )) self.add_subsystem('vertical_cruise_equilibrium_comp', comp, promotes=['*']) comp = LinearCombinationComp(shape=shape, out_name='horizontal_cruise_equilibrium', constant=0., coeffs_dict=dict( cruise_total_thrust=1., total_drag=-1., )) self.add_subsystem('horizontal_cruise_equilibrium_comp', comp, promotes=['*']) comp = LinearPowerCombinationComp( shape=shape, out_name='cruise_rolling_moment_equilibrium', terms_list=[ (0.2, dict( cruise_wing_right_inner_thrust=1., wing_span=1., )), (0.5, dict( cruise_wing_right_outer_thrust=1., wing_span=1., )), (0.5, dict( cruise_tail_right_thrust=1., tail_span=1., )), (-0.2, dict( cruise_wing_left_inner_thrust=1., wing_span=1., )), (-0.5, dict( cruise_wing_left_outer_thrust=1., wing_span=1., )), (-0.5, dict( cruise_tail_left_thrust=1., tail_span=1., )), ], constant=0., ) self.add_subsystem('cruise_rolling_moment_equilibrium_comp', comp, promotes=['*']) comp = LinearCombinationComp(shape=shape, out_name='wing_lift_moment_arm', constant=0., coeffs_dict=dict( xcg=1., nose_wing_c4=-1., )) self.add_subsystem('wing_lift_moment_arm_comp', comp, promotes=['*']) comp = LinearCombinationComp(shape=shape, out_name='tail_lift_moment_arm', constant=0., coeffs_dict=dict( nose_tail_c4=1., xcg=-1., )) self.add_subsystem('tail_lift_moment_arm_comp', comp, promotes=['*']) comp = LinearPowerCombinationComp( shape=shape, out_name='pitching_moment_equilibrium', terms_list=[ (1, dict( wing_lift_moment_arm=1., wing_lift=1., )), (-1, dict( tail_lift_moment_arm=1., tail_lift=1., )), ], constant=0., ) self.add_subsystem('pitching_moment_equilibrium_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=['*'])
comp = ExecComp('LD = CL/CD') prob.model.add_subsystem('ld_comp', comp, promotes=['*']) comp = ExecComp( 'tot_weight = (fuelburn + emptyTotal*4.45/9.81 + 42760) * 9.81') prob.model.add_subsystem('total_weight_calculation', comp, promotes=['*']) # comp = ExecComp('1 - L / tot_weight') # prob.model.add_subsystem('total_weight_comp', comp, promotes=['*']) comp = LinearPowerCombinationComp( shape=shape, out_name='LOW', terms_list=[ (-1, dict( L=1, tot_weight=-1, )), ], constant=1, ) prob.model.add_subsystem('LOW', comp, promotes=['*']) comp = LinearCombinationComp( shape=shape, out_name='TOD', coeffs_dict=dict( thrust=1e3, D=-1, ), )
def setup(self): shape = self.options['shape'] aircraft = self.options['aircraft'] comp = IndepVarComp() comp.add_output('CL_max', val=aircraft['CL_max'], shape=shape) comp.add_output('CL_takeoff', val=aircraft['CL_takeoff'], shape=shape) comp.add_output('climb_gradient', val=aircraft['climb_gradient'], shape=shape) comp.add_output('turn_load_factor', val=aircraft['turn_load_factor'], shape=shape) comp.add_output('TOP', val=aircraft['TOP'], shape=shape) comp.add_output('takeoff_density', val=aircraft['takeoff_density'], shape=shape) comp.add_output('sealevel_density', val=1.225, shape=shape) comp.add_output('stall_speed', val=aircraft['stall_speed'], shape=shape) comp.add_output('climb_speed', val=aircraft['climb_speed'], shape=shape) comp.add_output('turn_speed', val=aircraft['turn_speed'], shape=shape) comp.add_output('landing_distance', val=aircraft['landing_distance'], shape=shape) comp.add_output('approach_distance', val=aircraft['approach_distance'], shape=shape) comp.add_output('wing_loading', val=aircraft['wing_loading'], shape=shape) comp.add_output('thrust_to_weight', val=aircraft['thrust_to_weight'], shape=shape) comp.add_output('ref_wing_loading', val=aircraft['ref_wing_loading'], shape=shape) comp.add_output('ref_thrust_to_weight', val=aircraft['ref_thrust_to_weight'], shape=shape) comp.add_design_var('wing_loading', indices=[0], lower=0.) comp.add_design_var('thrust_to_weight', indices=[0], lower=0.) self.add_subsystem('inputs_comp', comp, promotes=['*']) # comp = PowerCombinationComp( shape=shape, out_name='wing_loading_lbf_ft2', powers_dict=dict(wing_loading=1., ), coeff=units('lbf/ft^2', 'N/m^2'), ) self.add_subsystem('wing_loading_lbf_ft2_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='ref_power_to_weight', powers_dict=dict( ref_thrust_to_weight=1., cruise_speed=1., propulsive_efficiency=-1., ), ) self.add_subsystem('ref_power_to_weight_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='power_to_weight', powers_dict=dict( thrust_to_weight=1., cruise_speed=1., propulsive_efficiency=-1., ), ) self.add_subsystem('power_to_weight_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='wing_area', powers_dict=dict( gross_weight=1., wing_loading=-1., ), ) self.add_subsystem('wing_area_comp', comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='max_thrust', powers_dict=dict( gross_weight=1., thrust_to_weight=1., ), ) self.add_subsystem('max_thrust_comp', comp, promotes=['*']) # comp = StallWingLoadingComp(shape=shape) self.add_subsystem('stall_wing_loading_comp', comp, promotes=['*']) comp = ClimbThrustToWeightComp(shape=shape) self.add_subsystem('climb_thrust_to_weight_comp', comp, promotes=['*']) comp = TurnThrustToWeightComp(shape=shape) self.add_subsystem('turn_thrust_to_weight_comp', comp, promotes=['*']) if aircraft['thrust_source_type'] == 'jet': TakeoffWingLoadingComp = JetTakeoffWingLoadingComp elif aircraft['thrust_source_type'] == 'propeller': TakeoffWingLoadingComp = PropellerTakeoffWingLoadingComp else: raise Exception() comp = TakeoffWingLoadingComp(shape=shape) self.add_subsystem('takeoff_wing_loading_comp', comp, promotes=['*']) comp = LandingWingLoadingComp(shape=shape) self.add_subsystem('landing_wing_loading_comp', comp, promotes=['*']) # for con_name in [ 'stall', 'takeoff', 'landing', ]: comp = LinearCombinationComp( shape=shape, out_name='{}_wing_loading_constraint'.format(con_name), coeffs_dict={ 'wing_loading': 1., '{}_wing_loading'.format(con_name): -1., }, ) comp.add_constraint('{}_wing_loading_constraint'.format(con_name), indices=[0], upper=0.) self.add_subsystem( '{}_wing_loading_constraint_comp'.format(con_name), comp, promotes=['*']) for con_name in [ 'climb', 'turn', ]: comp = LinearCombinationComp( shape=shape, out_name='{}_thrust_to_weight_constraint'.format(con_name), coeffs_dict={ 'thrust_to_weight': -1., '{}_thrust_to_weight'.format(con_name): 1., }, ) comp.add_constraint( '{}_thrust_to_weight_constraint'.format(con_name), indices=[0], upper=0.) self.add_subsystem( '{}_thrust_to_weight_constraint_comp'.format(con_name), comp, promotes=['*']) comp = PowerCombinationComp( shape=shape, out_name='{}_power_to_weight'.format(con_name), powers_dict={ '{}_thrust_to_weight'.format(con_name): 1., 'cruise_speed': 1., 'propulsive_efficiency': -1., }, ) self.add_subsystem('{}_power_to_weight_comp'.format(con_name), comp, promotes=['*']) a = 0.5 comp = LinearPowerCombinationComp( shape=shape, out_name='sizing_performance_objective', terms_list=[ (1 - a, dict( thrust_to_weight=1., ref_thrust_to_weight=-1., )), (-a, dict( wing_loading=1., ref_wing_loading=-1., )), ], ) self.add_subsystem( 'sizing_performance_objective_comp'.format(con_name), 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 = 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( trip_length=1., v_inf=-1., )) self.add_subsystem('cruise_time', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='cruise_energy_expenditure', coeff=1., powers_dict=dict( cruise_time=1., cruise_total_power=1., )) self.add_subsystem('cruise_energy_expenditure_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='hover_energy_expenditure', powers_dict=dict( hover_time=1., hover_total_power=1., )) self.add_subsystem('hover_energy_expenditure_comp', comp, promotes=['*']) comp = LinearCombinationComp(shape=shape, out_name='energy_expenditure_per_trip', constant=0., coeffs_dict=dict( hover_energy_expenditure=1., cruise_energy_expenditure=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=-1., hover_energy_expenditure=-1., )) self.add_subsystem('energy_remaining_comp', comp, promotes=['*']) comp = PowerCombinationComp(shape=shape, out_name='tips_per_charge', powers_dict=dict( total_avail_energy=1., energy_expenditure_per_trip=-1., )) self.add_subsystem('trips_per_charge', comp, promotes=['*'])