def pre_setup(self): self.options.update(dict( powers_dict=dict( TOP=1., takeoff_density=1., sealevel_density=-1., CL_takeoff=1., power_to_weight=1., ), out_name='takeoff_wing_loading', coeff=units('N/m^2', 'lbf/ft^2') / 745.7 * units('N', 'lbf'), ))
def post_initialize(self): self.empty_weight_fraction_parameters = dict( ga_single=(2.36, -0.18), ga_twin=(1.51, -0.10), transport=(1.02, -0.06), )[self['aircraft_type']] if self['empty_weight_fraction_variable_sweep']: self.empty_weight_fraction_k_vs = 1.04 else: self.empty_weight_fraction_k_vs = 1. self['battery_energy_density'] = self[ 'battery_energy_density_Wh_kg'] * units('J/kg', 'Wh/kg') if self['aircraft_type'] in ['transport']: self['approach_distance'] = 1000. * units('m', 'ft') elif self['aircraft_type'] in ['ga_single', 'ga_twin']: self['approach_distance'] = 600. * units('m', 'ft') self['wing_loading'] = self['wing_loading_lbf_ft2'] * units( 'N/m^2', 'lbf/ft^2') self['ref_wing_loading'] = self['ref_wing_loading_lbf_ft2'] * units( 'N/m^2', 'lbf/ft^2') self['landing_distance'] = self['landing_distance_ft'] * units( 'm', 'ft')
def post_initialize(self): self.options.update( dict( powers_dict=dict( TOP=1., takeoff_density=1., sealevel_density=-1., CL_takeoff=1., thrust_to_weight=1., ), out_name='takeoff_wing_loading', coeff=units('N/m^2', 'lbf/ft^2'), ))
def pre_setup(self): self.options.update( dict( out_name='landing_wing_loading', terms_list=[ (1. / 80 * units('ft', 'm') * units('N/m^2', 'lbf/ft^2'), dict( landing_distance=1., takeoff_density=1., sealevel_density=-1., CL_max=1., )), (-1. / 80 * units('ft', 'm') * units('N/m^2', 'lbf/ft^2'), dict( approach_distance=1., takeoff_density=1., sealevel_density=-1., CL_max=1., )), ], constant=0., ))
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=['*'])
import numpy as np from lsdo_utils.api import units, constants from openmdao.api import ImplicitComponent eps = 1.e-10 lb_N = units('lb', 'kg') / constants.g N_lb = 1. / lb_N class GrossWeightComp(ImplicitComponent): """ This component solves for the gross weight of the aircraft selected by solving a non-linear equation. The options that are required for this component are given in 'aircraft.py', and are defined based on the type of aircraft selected. The values for: 'a', 'c' and 'k_vs' are taken from the Raymer Empty Weight Fraction Regression. Other options are 'shape', 'num_iter' (maximum number of iterations), and 'weight_max' (limit on gross weight). """ def initialize(self): self.options.declare('shape', types=tuple) self.options.declare('a', types=float) self.options.declare('c', types=float) self.options.declare('k_vs', types=float) self.options.declare('weight_max', default=1.e8, types=float) self.options.declare('num_iter', default=100, types=int) def setup(self): shape = self.options['shape'] self.add_input('fixed_weight', shape=shape)
def pre_setup(self): self['brake_specific_fuel_consumption'] = self[ 'brake_specific_fuel_consumption_lb_hph'] / constants.W_hp * units( 'kg/W/s', 'lb/W/hr')
# - You want to evaluate your design at 3 different payloads and two different ranges. # You would set the shape to a (2, 3), and you would define the values of payload and range as so: # payload_weight = np.array([[4 * 230 * N_lb, 5 * 230 * N_lb, 6 * 230 * N_lb ],[4 * 230 * N_lb, 5 * 230 * N_lb, 6 * 230 * N_lb ]]) # range_km = np.array([[100., 100, 100] , [200, 200 , 200]]) # The other variables you can just remain as a single value, because the program will automatically make them into a (2, 3) matrix. num_sweep_points = 0 shape = (1 + num_sweep_points,) # energy_source_type specifies whether you're using an electric or fuel-burning aircraft. Different equations apply # based on which type you choose. #energy_source_type = 'electric' energy_source_type = 'fuel_burning' # Constants, and units are imported from lsdo_utils. Allows for the use of gravity, as well as converting between SI and Imperial units. lb_N = units('lb', 'kg') / constants.g N_lb = 1. / lb_N # Depending on whether the aircraft is fuel-burning or electric, you need to change the values under the corresponding 'if' statement. if energy_source_type == 'electric': payload_weight = 410 * 230 * units('N', 'lbf') crew_weight = 1 * 230 * units('N', 'lbf') range_km = 6492. lift_to_drag_ratio = 17.5 cruise_speed = 256. thrust_source_type = 'propeller' landing_distance_ft = 8000. ref_wing_loading_lbf_ft2 = 25. ref_thrust_to_weight = 0.3 aircraft_type = 'ga_twin' elif energy_source_type == 'fuel_burning':
def pre_setup(self): self['thrust_specific_fuel_consumption'] = self[ 'thrust_specific_fuel_consumption_lb_lbfh'] * units( 'kg/N/s', 'lb/lbf/hr')
def pre_setup(self): self['specific_energy'] = self['specific_energy_Wh_kg'] * units('J/kg', 'Wh/kg') self['specific_power'] = self['specific_power_W_kg'] self['reserve'] = self['reserve_pct'] / 100.
def pre_setup(self): self['specific_power'] = self['specific_power_kW_kg'] * units( 'W/kg', 'kW/kg')
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=['*'])