def setup(self): nn = self.options['num_nodes'] eta_b = self.options['efficiency'] e_b = self.options['specific_energy'] p_b = self.options['specific_power'] cost_inc = self.options['cost_inc'] cost_base = self.options['cost_base'] defaults = [['SOC_initial', 'batt_SOC_initial', 1, None]] self.add_subsystem('defaults', DVLabel(defaults), promotes_inputs=["*"], promotes_outputs=["*"]) self.add_subsystem('batt_base',SimpleBattery(num_nodes=nn, efficiency=eta_b, specific_energy=e_b, specific_power=p_b, cost_inc=cost_inc, cost_base=cost_base), promotes_outputs=['*'],promotes_inputs=['*']) # change in SOC over time is (- elec_load) / max_energy self.add_subsystem('divider',ElementMultiplyDivideComp(output_name='dSOCdt',input_names=['elec_load','max_energy'],vec_size=[nn,1],scaling_factor=-1,divide=[False,True],input_units=['W','kJ']), promotes_inputs=['*'],promotes_outputs=['*']) nn_simpson = int((nn-1)/2) self.add_subsystem('intload',Integrator(num_intervals=nn_simpson, method='simpson', quantity_units=None, diff_units='s', time_setup='duration'), promotes_inputs=[('q_initial','batt_SOC_initial'),'duration',('dqdt','dSOCdt')], promotes_outputs=[('q','SOC'),('q_final','SOC_final')])
def setup(self): #define design variables that are independent of flight condition or control states dvlist = [['ac|propulsion|engine|rating', 'eng1_rating', 260.0, 'kW'], ['dv_prop1_diameter', 'prop1_diameter', 2.5, 'm'], ['dv_motor1_rating', 'motor1_rating', 240.0, 'kW'], ['dv_gen1_rating', 'gen1_rating', 250.0, 'kW'], ['dv_batt1_weight', 'batt1_weight', 2000, 'kg']] self.add_subsystem('dvs', DVLabel(dvlist), promotes_inputs=["*"], promotes_outputs=["*"]) nn = self.options['num_nodes'] #introduce model components self.add_subsystem('motor1', SimpleMotor(efficiency=0.97, num_nodes=nn), promotes_inputs=["throttle"]) self.add_subsystem('hybrid_split', PowerSplit(rule='fraction', num_nodes=nn)) self.add_subsystem('gen1', SimpleGenerator(efficiency=0.97, num_nodes=nn)) self.add_subsystem('eng1', SimpleTurboshaft(num_nodes=nn), promotes_outputs=["fuel_flow"]) self.add_subsystem('batt1', SimpleBattery(num_nodes=nn)) self.add_subsystem('prop1', SimplePropeller(num_nodes=nn), promotes_inputs=["fltcond_*"], promotes_outputs=["thrust"]) #connect design variables to model component inputs self.connect('eng1_rating', 'eng1.shaft_power_rating') self.connect('prop1_diameter', 'prop1.diameter') self.connect('motor1_rating', 'motor1.elec_power_rating') self.connect('motor1_rating', 'prop1.power_rating') self.connect('gen1_rating', 'gen1.elec_power_rating') self.connect('batt1_weight', 'batt1.battery_weight') #connect components to each other self.connect('motor1.shaft_power_out', 'prop1.shaft_power_in') self.connect('eng1.shaft_power_out', 'gen1.shaft_power_in') self.connect('motor1.elec_load', 'hybrid_split.power_in') self.connect('hybrid_split.power_out_A', 'batt1.elec_load')
def setUp(self): self.p = Problem(model=Group()) ivc = IndepVarComp() ivc.add_output(name='a_to_be_renamed', units='m/s') ivc.add_output(name='b_to_be_renamed', units='kg') dvlabel = DVLabel([['a_to_be_renamed','a',1,'m/s'], ['b_to_be_renamed','b',1,'lbm']]) self.p.model.add_subsystem(name='ivc', subsys=ivc, promotes_outputs=['*']) self.p.model.add_subsystem(name='dvlabel', subsys=dvlabel, promotes_inputs=['*'], promotes_outputs=['*']) self.p.setup() self.p['a_to_be_renamed'] = np.random.rand(1) self.p['b_to_be_renamed'] = np.random.rand(1) self.p.run_model()
def setUp(self): self.nn = 3 self.p = Problem(model=Group()) ivc = IndepVarComp() ivc.add_output(name='a_to_be_renamed', shape=(self.nn,)) ivc.add_output(name='b_to_be_renamed', shape=(self.nn,)) dvlabel = DVLabel([['a_to_be_renamed','a',np.ones(self.nn),None], ['b_to_be_renamed','b',np.ones(self.nn),None]]) self.p.model.add_subsystem(name='ivc', subsys=ivc, promotes_outputs=['*']) self.p.model.add_subsystem(name='dvlabel', subsys=dvlabel, promotes_inputs=['*'], promotes_outputs=['*']) self.p.setup() self.p['a_to_be_renamed'] = np.random.rand(self.nn,) self.p['b_to_be_renamed'] = np.random.rand(self.nn,) self.p.run_model()
def setup(self): nn = self.options['num_nodes'] # rename incoming design variables dvlist = [['ac|propulsion|engine|rating', 'eng1_rating', 850, 'hp'], [ 'ac|propulsion|propeller|diameter', 'prop1_diameter', 2.3, 'm' ]] self.add_subsystem('dvs', DVLabel(dvlist), promotes_inputs=["*"], promotes_outputs=["*"]) # introduce model components self.add_subsystem('eng1', SimpleTurboshaft(num_nodes=nn, weight_inc=0.14 / 1000, weight_base=104), promotes_inputs=["throttle"], promotes_outputs=["fuel_flow"]) self.add_subsystem('prop1', SimplePropeller(num_nodes=nn, num_blades=4, design_J=2.2, design_cp=0.55), promotes_inputs=["fltcond|*"], promotes_outputs=["thrust"]) # connect design variables to model component inputs self.connect('eng1_rating', 'eng1.shaft_power_rating') self.connect('eng1_rating', 'prop1.power_rating') self.connect('prop1_diameter', 'prop1.diameter') # connect components to each other self.connect('eng1.shaft_power_out', 'prop1.shaft_power_in')
def setup(self): nn = self.options['num_nodes'] #define design variables that are independent of flight condition or control states dvlist = [ ['ac|propulsion|engine|rating', 'eng_rating', 260.0, 'kW'], ['ac|propulsion|propeller|diameter', 'prop_diameter', 2.5, 'm'], ['ac|propulsion|motor|rating', 'motor_rating', 240.0, 'kW'], ['ac|propulsion|generator|rating', 'gen_rating', 250.0, 'kW'], ['ac|weights|W_battery', 'batt_weight', 2000, 'kg'], [ 'ac|propulsion|thermal|hx|mdot_coolant', 'mdot_coolant', 0.1 * np.ones((nn, )), 'kg/s' ], [ 'ac|propulsion|thermal|hx|coolant_mass', 'coolant_mass', 10., 'kg' ], [ 'ac|propulsion|thermal|hx|channel_width', 'channel_width', 1., 'mm' ], [ 'ac|propulsion|thermal|hx|channel_height', 'channel_height', 20., 'mm' ], [ 'ac|propulsion|thermal|hx|channel_length', 'channel_length', 0.2, 'm' ], ['ac|propulsion|thermal|hx|n_parallel', 'n_parallel', 50, None], # ['ac|propulsion|thermal|duct|area_nozzle','area_nozzle',58.*np.ones((nn,)),'inch**2'], [ 'ac|propulsion|battery|specific_energy', 'specific_energy', 300, 'W*h/kg' ] ] self.add_subsystem('dvs', DVLabel(dvlist), promotes_inputs=["*"], promotes_outputs=["*"]) #introduce model components self.add_subsystem('motor1', SimpleMotor(efficiency=0.97, num_nodes=nn), promotes_inputs=['throttle']) self.add_subsystem('prop1', SimplePropeller(num_nodes=nn), promotes_inputs=["fltcond|*"]) self.connect('motor1.shaft_power_out', 'prop1.shaft_power_in') #propulsion models expect a high-level 'throttle' parameter and a 'propulsor_active' flag to set individual throttles failedengine = ElementMultiplyDivideComp() failedengine.add_equation('motor2throttle', input_names=['throttle', 'propulsor_active'], vec_size=nn) self.add_subsystem('failedmotor', failedengine, promotes_inputs=['throttle', 'propulsor_active']) self.add_subsystem('motor2', SimpleMotor(efficiency=0.97, num_nodes=nn)) self.add_subsystem('prop2', SimplePropeller(num_nodes=nn), promotes_inputs=["fltcond|*"]) self.connect('motor2.shaft_power_out', 'prop2.shaft_power_in') self.connect('failedmotor.motor2throttle', 'motor2.throttle') addpower = AddSubtractComp( output_name='motors_elec_load', input_names=['motor1_elec_load', 'motor2_elec_load'], units='kW', vec_size=nn) addpower.add_equation(output_name='thrust', input_names=['prop1_thrust', 'prop2_thrust'], units='N', vec_size=nn) self.add_subsystem('add_power', subsys=addpower, promotes_outputs=['*']) self.connect('motor1.elec_load', 'add_power.motor1_elec_load') self.connect('motor2.elec_load', 'add_power.motor2_elec_load') self.connect('prop1.thrust', 'add_power.prop1_thrust') self.connect('prop2.thrust', 'add_power.prop2_thrust') self.add_subsystem('hybrid_split', PowerSplit(rule='fraction', num_nodes=nn)) self.connect('motors_elec_load', 'hybrid_split.power_in') self.add_subsystem('eng1', SimpleTurboshaft(num_nodes=nn, weight_inc=0.14 / 1000, weight_base=104), promotes_outputs=["fuel_flow"]) self.add_subsystem('gen1', SimpleGenerator(efficiency=0.97, num_nodes=nn)) self.connect('eng1.shaft_power_out', 'gen1.shaft_power_in') self.add_subsystem('batt1', SOCBattery(num_nodes=nn, efficiency=0.97), promotes_inputs=["duration", 'specific_energy']) self.connect('hybrid_split.power_out_A', 'batt1.elec_load') # TODO set val= right number of nn self.add_subsystem( 'eng_throttle_set', BalanceComp(name='eng_throttle', val=np.ones((nn, )) * 0.5, units=None, eq_units='kW', rhs_name='gen_power_required', lhs_name='gen_power_available')) #need to use the optimizer to drive hybrid_split.power_out_B to the same value as gen1.elec_power_out self.connect('hybrid_split.power_out_B', 'eng_throttle_set.gen_power_required') self.connect('gen1.elec_power_out', 'eng_throttle_set.gen_power_available') self.connect('eng_throttle_set.eng_throttle', 'eng1.throttle') adder = AddSubtractComp(output_name='motors_weight', input_names=['motor1_weight', 'motor2_weight'], units='kg') adder.add_equation(output_name='propellers_weight', input_names=['prop1_weight', 'prop2_weight'], units='kg') adder.add_equation(output_name='motors_heat', input_names=['motor1_heat', 'motor2_heat'], vec_size=nn, units='W') self.add_subsystem('adder', subsys=adder, promotes_inputs=['*'], promotes_outputs=['*']) relabel = [[ 'hybrid_split_A_in', 'battery_load', np.ones(nn) * 260.0, 'kW' ]] self.add_subsystem('relabel', DVLabel(relabel), promotes_outputs=["battery_load"]) self.connect('hybrid_split.power_out_A', 'relabel.hybrid_split_A_in') self.connect('motor1.component_weight', 'motor1_weight') self.connect('motor2.component_weight', 'motor2_weight') self.connect('prop1.component_weight', 'prop1_weight') self.connect('prop2.component_weight', 'prop2_weight') self.connect('motor1.heat_out', 'motor1_heat') self.connect('motor2.heat_out', 'motor2_heat') #connect design variables to model component inputs self.connect('eng_rating', 'eng1.shaft_power_rating') self.connect('prop_diameter', ['prop1.diameter', 'prop2.diameter']) self.connect('motor_rating', ['motor1.elec_power_rating', 'motor2.elec_power_rating']) self.connect('motor_rating', ['prop1.power_rating', 'prop2.power_rating']) self.connect('gen_rating', 'gen1.elec_power_rating') self.connect('batt_weight', 'batt1.battery_weight') iv = self.add_subsystem('iv', IndepVarComp(), promotes_outputs=['*']) iv.add_output('rho_coolant', val=997 * np.ones((nn, )), units='kg/m**3') lc_promotes = ['duration', 'channel_*', 'n_parallel'] self.add_subsystem('batteryheatsink', LiquidCooledComp(num_nodes=nn, quasi_steady=False), promotes_inputs=lc_promotes) self.connect('batt1.heat_out', 'batteryheatsink.q_in') self.connect('batt_weight', 'batteryheatsink.mass') self.add_subsystem('motorheatsink', LiquidCooledComp(num_nodes=nn, quasi_steady=False), promotes_inputs=lc_promotes) self.connect('motors_heat', 'motorheatsink.q_in') self.connect('motors_weight', 'motorheatsink.mass') self.add_subsystem('duct', ExplicitIncompressibleDuct(num_nodes=nn), promotes_inputs=['fltcond|*']) iv.add_output('ac|propulsion|thermal|duct|area_nozzle', val=58. * np.ones((nn, )), units='inch**2') self.connect('ac|propulsion|thermal|duct|area_nozzle', 'duct.area_nozzle') self.add_subsystem('hx', HXGroup(num_nodes=nn), promotes_inputs=[ 'ac|*', ('T_in_cold', 'fltcond|T'), ('rho_cold', 'fltcond|rho') ]) self.connect('duct.mdot', 'hx.mdot_cold') self.connect('hx.delta_p_cold', 'duct.delta_p_hex') self.connect('motorheatsink.T_out', 'hx.T_in_hot') self.connect('rho_coolant', 'hx.rho_hot') self.add_subsystem( 'reservoir', CoolantReservoir(num_nodes=nn), promotes_inputs=['duration', ('mass', 'coolant_mass')]) self.connect('hx.T_out_hot', 'reservoir.T_in') self.connect('reservoir.T_out', 'batteryheatsink.T_in') self.connect('batteryheatsink.T_out', 'motorheatsink.T_in') self.connect('mdot_coolant', [ 'batteryheatsink.mdot_coolant', 'motorheatsink.mdot_coolant', 'hx.mdot_hot', 'reservoir.mdot_coolant' ])
def setup(self): n_int_per_seg = self.options['n_int_per_seg'] track_battery = self.options['track_battery'] track_fuel = self.options['track_fuel'] nn = (n_int_per_seg * 2 + 1) nn_tot = 3 * nn + 2 #===Some of the generic components take "weight" as an input. Need to re-label Takeoff Weight (TOW) as just weight dvlist = [['ac|weights|MTOW', 'weight', 2000.0, 'kg'], ['mission|takeoff|v1', 'v1', 40, 'm/s'], ['mission|takeoff|vr', 'vr', 45, 'm/s'], ['ac|aero|polar|CD0_TO', 'CD0', 0.005, None], ['ac|aero|polar|e', 'e', 0.95, None], [ 'fltcond|takeoff|q', 'fltcond|q', 100 * np.ones(nn_tot), 'Pa' ]] self.add_subsystem('dvs', DVLabel(dvlist), promotes_inputs=["*"], promotes_outputs=["*"]) #===We assume the takeoff starts at 1 m/s to avoid singularities at v=0 const = self.add_subsystem('const', IndepVarComp()) const.add_output('v0', val=1, units='m/s') const.add_output('reaction_time', val=2, units='s') #===Lift and Drag Calculations feed the EOMs for the takeoff roll=== self.add_subsystem( 'CL', TakeoffCLs(n_int_per_seg=n_int_per_seg), promotes_inputs=["ac|geom|*", "fltcond|*", "weight"], ) self.add_subsystem( 'drag', PolarDrag(num_nodes=nn_tot), promotes_inputs=['ac|geom|*', 'fltcond|q', 'CD0', 'e'], promotes_outputs=['drag']) self.add_subsystem('lift', Lift(num_nodes=nn_tot), promotes_inputs=['ac|geom|*', 'fltcond|q'], promotes_outputs=['lift']) self.connect('CL.CL_takeoff', 'drag.fltcond|CL') self.connect('CL.CL_takeoff', 'lift.fltcond|CL') #==The takeoff distance integrator numerically integrates the quantity (speed / acceleration) with respect to speed to obtain distance. Obtain this quantity: self.add_subsystem( 'accel', TakeoffAccels(n_int_per_seg=n_int_per_seg), promotes_inputs=['lift', 'drag', 'takeoff|thrust', 'weight'], promotes_outputs=['_inverse_accel']) self.add_subsystem( 'mult', ElementMultiplyDivideComp( output_name='_rate_to_integrate', input_names=['_inverse_accel', 'fltcond|takeoff|Utrue'], vec_size=nn_tot, input_units=['s**2/m', 'm/s']), promotes_inputs=['*'], promotes_outputs=['_*']) if track_fuel: self.add_subsystem( 'fuelflowmult', ElementMultiplyDivideComp( output_name='_fuel_flow_rate_to_integrate', input_names=['_inverse_accel', 'takeoff|fuel_flow'], vec_size=nn_tot, input_units=['s**2/m', 'kg/s']), promotes_inputs=['*'], promotes_outputs=['_*']) if track_battery: self.add_subsystem( 'batterymult', ElementMultiplyDivideComp( output_name='_battery_rate_to_integrate', input_names=['_inverse_accel', 'takeoff|battery_load'], vec_size=nn_tot, input_units=['s**2/m', 'J / s']), promotes_inputs=['*'], promotes_outputs=['*']) #==The following boilerplate splits the input flight conditions, thrusts, and fuel flows into the takeoff segments for further analysis inputs_to_split = [ '_rate_to_integrate', 'fltcond|takeoff|Utrue', 'takeoff|thrust', 'drag', 'lift' ] units = ['s', 'm/s', 'N', 'N', 'N'] if track_battery: inputs_to_split.append('_battery_rate_to_integrate') units.append('J*s/m') if track_fuel: inputs_to_split.append('_fuel_flow_rate_to_integrate') units.append('kg*s/m') segments_to_split_into = ['v0v1', 'v1vr', 'v1v0', 'vtrans', 'v2'] nn_each_segment = [nn, nn, nn, 1, 1] split_inst = VectorSplitComp() for kth, input_name in enumerate(inputs_to_split): output_names_list = [] for segment in segments_to_split_into: output_names_list.append(input_name + '_' + segment) split_inst.add_relation(output_names=output_names_list, input_name=input_name, vec_sizes=nn_each_segment, units=units[kth]) splitter = self.add_subsystem('splitter', subsys=split_inst, promotes_inputs=["*"], promotes_outputs=["*"]) #==Now integrate the three continuous segments: 0 to v1, v1 to rotation with reduced power if applicable, and hard braking self.add_subsystem( 'v0v1_dist', IntegrateQuantity(num_intervals=n_int_per_seg, quantity_units='m', diff_units='m/s', force_signs=True)) self.add_subsystem( 'v1vr_dist', IntegrateQuantity(num_intervals=n_int_per_seg, quantity_units='m', diff_units='m/s', force_signs=True)) self.add_subsystem( 'v1v0_dist', IntegrateQuantity(num_intervals=n_int_per_seg, quantity_units='m', diff_units='m/s', force_signs=True)) self.connect('_rate_to_integrate_v0v1', 'v0v1_dist.rate') self.connect('_rate_to_integrate_v1vr', 'v1vr_dist.rate') self.connect('_rate_to_integrate_v1v0', 'v1v0_dist.rate') self.connect('const.v0', 'v0v1_dist.lower_limit') self.connect('v1', 'v0v1_dist.upper_limit') self.connect('v1', 'v1v0_dist.lower_limit') self.connect('const.v0', 'v1v0_dist.upper_limit') self.connect('v1', 'v1vr_dist.lower_limit') self.connect('vr', 'v1vr_dist.upper_limit') if track_fuel: self.add_subsystem( 'v0v1_fuel', IntegrateQuantity(num_intervals=n_int_per_seg, quantity_units='kg', diff_units='m/s', force_signs=True)) self.add_subsystem( 'v1vr_fuel', IntegrateQuantity(num_intervals=n_int_per_seg, quantity_units='kg', diff_units='m/s', force_signs=True)) self.connect('_fuel_flow_rate_to_integrate_v0v1', 'v0v1_fuel.rate') self.connect('_fuel_flow_rate_to_integrate_v1vr', 'v1vr_fuel.rate') self.connect('const.v0', 'v0v1_fuel.lower_limit') self.connect('v1', ['v0v1_fuel.upper_limit', 'v1vr_fuel.lower_limit']) self.connect('vr', 'v1vr_fuel.upper_limit') if track_battery: self.add_subsystem( 'v0v1_battery', IntegrateQuantity(num_intervals=n_int_per_seg, quantity_units='J', diff_units='m/s', force_signs=True)) self.add_subsystem( 'v1vr_battery', IntegrateQuantity(num_intervals=n_int_per_seg, quantity_units='J', diff_units='m/s', force_signs=True)) self.connect('_battery_rate_to_integrate_v0v1', 'v0v1_battery.rate') self.connect('_battery_rate_to_integrate_v1vr', 'v1vr_battery.rate') self.connect('const.v0', 'v0v1_battery.lower_limit') self.connect( 'v1', ['v0v1_battery.upper_limit', 'v1vr_battery.lower_limit']) self.connect('vr', 'v1vr_battery.upper_limit') #==Next compute the transition and climb phase to the specified clearance height. First, need the steady climb-out angle at v2 speed self.add_subsystem( 'gamma', TakeoffV2ClimbAngle(), promotes_inputs=["drag_v2", "takeoff|thrust_v2", "weight"], promotes_outputs=["takeoff|climb|gamma"]) self.add_subsystem('transition', TakeoffTransition(), promotes_inputs=[ "fltcond|takeoff|Utrue_vtrans", "takeoff|climb|gamma" ], promotes_outputs=["h_transition", "s_transition"]) self.add_subsystem( 'climb', TakeoffClimb(), promotes_inputs=["takeoff|climb|gamma", "h_transition"], promotes_outputs=["s_climb"]) self.add_subsystem('reaction', ElementMultiplyDivideComp( output_name='s_reaction', input_names=['v1', 'reaction_time'], vec_size=1, input_units=['m/s', 's']), promotes_inputs=['v1']) self.connect('const.reaction_time', 'reaction.reaction_time') self.add_subsystem('total_to_distance_continue', AddSubtractComp(output_name='takeoff|distance', input_names=[ 's_v0v1', 's_v1vr', 's_reaction', 's_transition', 's_climb' ], vec_size=1, units='m'), promotes_outputs=["*"]) self.add_subsystem('total_to_distance_abort', AddSubtractComp( output_name='takeoff|distance_abort', input_names=['s_v0v1', 's_v1v0', 's_reaction'], vec_size=1, units='m'), promotes_outputs=["*"]) self.connect('reaction.s_reaction', 'total_to_distance_continue.s_reaction') self.connect('reaction.s_reaction', 'total_to_distance_abort.s_reaction') self.connect('v0v1_dist.delta_quantity', [ 'total_to_distance_continue.s_v0v1', 'total_to_distance_abort.s_v0v1' ]) self.connect('v1vr_dist.delta_quantity', 'total_to_distance_continue.s_v1vr') self.connect('s_transition', 'total_to_distance_continue.s_transition') self.connect('s_climb', 'total_to_distance_continue.s_climb') self.connect('v1v0_dist.delta_quantity', 'total_to_distance_abort.s_v1v0') if track_battery: self.add_subsystem( 'total_battery', AddSubtractComp(output_name='takeoff|total_battery_energy', input_names=['battery_v0v1', 'battery_v1vr'], units='J'), promotes_outputs=["*"]) self.connect('v0v1_battery.delta_quantity', 'total_battery.battery_v0v1') self.connect('v1vr_battery.delta_quantity', 'total_battery.battery_v1vr') if track_fuel: self.add_subsystem('total_fuel', AddSubtractComp( output_name='takeoff|total_fuel', input_names=['fuel_v0v1', 'fuel_v1vr'], units='kg', scaling_factors=[-1, -1]), promotes_outputs=["*"]) self.connect('v0v1_fuel.delta_quantity', 'total_fuel.fuel_v0v1') self.connect('v1vr_fuel.delta_quantity', 'total_fuel.fuel_v1vr') self.add_subsystem( 'climb_weight', AddSubtractComp(output_name='weight_after_takeoff', input_names=['weight', 'takeoff|total_fuel'], units='kg', scaling_factors=[1, -1]), promotes_inputs=["*"], promotes_outputs=["*"])
def setup(self): #define design variables that are independent of flight condition or control states dvlist = [ ['ac|propulsion|engine|rating', 'eng_rating', 750, 'hp'], ['ac|propulsion|propeller|diameter', 'prop_diameter', 2.28, 'm'], ] self.add_subsystem('dvs', DVLabel(dvlist), promotes_inputs=["*"], promotes_outputs=["*"]) nn = self.options['num_nodes'] #introduce model components self.add_subsystem('eng1', SimpleTurboshaft(num_nodes=nn, weight_inc=0.14 / 1000, weight_base=104), promotes_inputs=['throttle']) self.add_subsystem('prop1', SimplePropeller(num_nodes=nn, num_blades=4, design_J=2.2, design_cp=0.55), promotes_inputs=["fltcond|*"]) self.add_subsystem( 'eng2', SimpleTurboshaft(num_nodes=nn, weight_inc=0.14 / 1000, weight_base=104)) self.add_subsystem('prop2', SimplePropeller(num_nodes=nn, num_blades=4, design_J=2.2, design_cp=0.55), promotes_inputs=["fltcond|*"]) #connect design variables to model component inputs self.connect('eng_rating', 'eng1.shaft_power_rating') self.connect('eng_rating', 'eng2.shaft_power_rating') self.connect('eng_rating', 'prop1.power_rating') self.connect('eng_rating', 'prop2.power_rating') self.connect('prop_diameter', 'prop1.diameter') self.connect('prop_diameter', 'prop2.diameter') #propulsion models expect a high-level 'throttle' parameter and a 'propulsor_active' flag to set individual throttles failedengine = ElementMultiplyDivideComp() failedengine.add_equation('eng2throttle', input_names=['throttle', 'propulsor_active'], vec_size=nn) self.add_subsystem('failedengine', failedengine, promotes_inputs=['throttle', 'propulsor_active']) self.connect('failedengine.eng2throttle', 'eng2.throttle') #connect components to each other self.connect('eng1.shaft_power_out', 'prop1.shaft_power_in') self.connect('eng2.shaft_power_out', 'prop2.shaft_power_in') #add up the weights, thrusts and fuel flows add1 = AddSubtractComp( output_name='fuel_flow', input_names=['eng1_fuel_flow', 'eng2_fuel_flow'], vec_size=nn, units='kg/s') add1.add_equation(output_name='thrust', input_names=['prop1_thrust', 'prop2_thrust'], vec_size=nn, units='N') add1.add_equation(output_name='engines_weight', input_names=['eng1_weight', 'eng2_weight'], units='kg') add1.add_equation(output_name='propellers_weight', input_names=['prop1_weight', 'prop2_weight'], units='kg') self.add_subsystem('adder', subsys=add1, promotes_inputs=["*"], promotes_outputs=["*"]) self.connect('prop1.thrust', 'prop1_thrust') self.connect('prop2.thrust', 'prop2_thrust') self.connect('eng1.fuel_flow', 'eng1_fuel_flow') self.connect('eng2.fuel_flow', 'eng2_fuel_flow') self.connect('prop1.component_weight', 'prop1_weight') self.connect('prop2.component_weight', 'prop2_weight') self.connect('eng1.component_weight', 'eng1_weight') self.connect('eng2.component_weight', 'eng2_weight')
def setup(self): #define design variables that are independent of flight condition or control states dvlist = [ ['ac|propulsion|engine|rating', 'eng_rating', 260.0, 'kW'], ['ac|propulsion|propeller|diameter', 'prop_diameter', 2.5, 'm'], ['ac|propulsion|motor|rating', 'motor_rating', 240.0, 'kW'], ['ac|propulsion|generator|rating', 'gen_rating', 250.0, 'kW'], ['ac|weights|W_battery', 'batt_weight', 2000, 'kg'] ] self.add_subsystem('dvs', DVLabel(dvlist), promotes_inputs=["*"], promotes_outputs=["*"]) nn = self.options['num_nodes'] e_b = self.options['specific_energy'] #introduce model components self.add_subsystem('motor1', SimpleMotor(efficiency=0.97, num_nodes=nn)) self.add_subsystem('prop1', SimplePropeller(num_nodes=nn), promotes_inputs=["fltcond|*"]) self.connect('motor1.shaft_power_out', 'prop1.shaft_power_in') self.add_subsystem('motor2', SimpleMotor(efficiency=0.97, num_nodes=nn)) self.add_subsystem('prop2', SimplePropeller(num_nodes=nn), promotes_inputs=["fltcond|*"]) self.connect('motor2.shaft_power_out', 'prop2.shaft_power_in') addpower = AddSubtractComp( output_name='motors_elec_load', input_names=['motor1_elec_load', 'motor2_elec_load'], units='kW', vec_size=nn) addpower.add_equation(output_name='thrust', input_names=['prop1_thrust', 'prop2_thrust'], units='N', vec_size=nn) self.add_subsystem('add_power', subsys=addpower, promotes_outputs=['*']) self.connect('motor1.elec_load', 'add_power.motor1_elec_load') self.connect('motor2.elec_load', 'add_power.motor2_elec_load') self.connect('prop1.thrust', 'add_power.prop1_thrust') self.connect('prop2.thrust', 'add_power.prop2_thrust') self.add_subsystem('hybrid_split', PowerSplit(rule='fraction', num_nodes=nn)) self.connect('motors_elec_load', 'hybrid_split.power_in') self.add_subsystem('eng1', SimpleTurboshaft(num_nodes=nn, weight_inc=0.14 / 1000, weight_base=104), promotes_outputs=["fuel_flow"]) self.add_subsystem('gen1', SimpleGenerator(efficiency=0.97, num_nodes=nn)) self.connect('eng1.shaft_power_out', 'gen1.shaft_power_in') self.add_subsystem('batt1', SimpleBattery(num_nodes=nn, specific_energy=e_b)) self.connect('hybrid_split.power_out_A', 'batt1.elec_load') self.add_subsystem( 'eng_gen_resid', AddSubtractComp( output_name='eng_gen_residual', input_names=['gen_power_available', 'gen_power_required'], vec_size=nn, units='kW', scaling_factors=[1, -1])) #need to use the optimizer to drive hybrid_split.power_out_B to the same value as gen1.elec_power_out self.connect('hybrid_split.power_out_B', 'eng_gen_resid.gen_power_required') self.connect('gen1.elec_power_out', 'eng_gen_resid.gen_power_available') addweights = AddSubtractComp( output_name='motors_weight', input_names=['motor1_weight', 'motor2_weight'], units='kg') addweights.add_equation(output_name='propellers_weight', input_names=['prop1_weight', 'prop2_weight'], units='kg') self.add_subsystem('add_weights', subsys=addweights, promotes_inputs=['*'], promotes_outputs=['*']) relabel = [[ 'hybrid_split_A_in', 'battery_load', np.ones(nn) * 260.0, 'kW' ]] self.add_subsystem('relabel', DVLabel(relabel), promotes_outputs=["battery_load"]) self.connect('hybrid_split.power_out_A', 'relabel.hybrid_split_A_in') self.connect('motor1.component_weight', 'motor1_weight') self.connect('motor2.component_weight', 'motor2_weight') self.connect('prop1.component_weight', 'prop1_weight') self.connect('prop2.component_weight', 'prop2_weight') #connect design variables to model component inputs self.connect('eng_rating', 'eng1.shaft_power_rating') self.connect('prop_diameter', ['prop1.diameter', 'prop2.diameter']) self.connect('motor_rating', ['motor1.elec_power_rating', 'motor2.elec_power_rating']) self.connect('motor_rating', ['prop1.power_rating', 'prop2.power_rating']) self.connect('gen_rating', 'gen1.elec_power_rating') self.connect('batt_weight', 'batt1.battery_weight')
def setup(self): nn = self.options['num_nodes'] e_b = self.options['specific_energy'] # define design variables that are independent of flight condition or control states dvlist = [ ['ac|propulsion|engine|rating', 'eng_rating', 260.0, 'kW'], ['ac|propulsion|propeller|diameter', 'prop_diameter', 2.5, 'm'], ['ac|propulsion|motor|rating', 'motor_rating', 240.0, 'kW'], ['ac|propulsion|generator|rating', 'gen_rating', 250.0, 'kW'], ['ac|weights|W_battery', 'batt_weight', 2000, 'kg'] ] self.add_subsystem('dvs', DVLabel(dvlist), promotes_inputs=["*"], promotes_outputs=["*"]) # introduce model components self.add_subsystem('motor1', SimpleMotor(efficiency=0.97, num_nodes=nn)) self.add_subsystem('prop1', SimplePropeller(num_nodes=nn), promotes_inputs=["fltcond|*"], promotes_outputs=['thrust']) self.connect('motor1.shaft_power_out', 'prop1.shaft_power_in') self.add_subsystem('hybrid_split', PowerSplit(rule='fraction', num_nodes=nn)) self.connect('motor1.elec_load', 'hybrid_split.power_in') self.add_subsystem('eng1', SimpleTurboshaft(num_nodes=nn, weight_inc=0.14 / 1000, weight_base=104), promotes_outputs=["fuel_flow"]) self.add_subsystem('gen1', SimpleGenerator(efficiency=0.97, num_nodes=nn)) self.connect('eng1.shaft_power_out', 'gen1.shaft_power_in') self.add_subsystem('batt1', SimpleBattery(num_nodes=nn, specific_energy=e_b)) self.connect('hybrid_split.power_out_A', 'batt1.elec_load') # need to use the optimizer to drive hybrid_split.power_out_B to the # same value as gen1.elec_power_out. # create a residual equation for power in vs power out from the generator self.add_subsystem( 'eng_gen_resid', AddSubtractComp( output_name='eng_gen_residual', input_names=['gen_power_available', 'gen_power_required'], vec_size=nn, units='kW', scaling_factors=[1, -1])) self.connect('hybrid_split.power_out_B', 'eng_gen_resid.gen_power_required') self.connect('gen1.elec_power_out', 'eng_gen_resid.gen_power_available') # add the weights of all the motors and props # (forward-compatibility for twin series hybrid layout) addweights = AddSubtractComp(output_name='motors_weight', input_names=['motor1_weight'], units='kg') addweights.add_equation(output_name='propellers_weight', input_names=['prop1_weight'], units='kg') self.add_subsystem('add_weights', subsys=addweights, promotes_inputs=['*'], promotes_outputs=['*']) self.connect('motor1.component_weight', 'motor1_weight') self.connect('prop1.component_weight', 'prop1_weight') #connect design variables to model component inputs self.connect('eng_rating', 'eng1.shaft_power_rating') self.connect('prop_diameter', ['prop1.diameter']) self.connect('motor_rating', ['motor1.elec_power_rating']) self.connect('motor_rating', ['prop1.power_rating']) self.connect('gen_rating', 'gen1.elec_power_rating') self.connect('batt_weight', 'batt1.battery_weight')
def setup(self): nn = self.options['num_nodes'] e_b = self.options['specific_energy'] # rename incoming design variables dvlist = [['ac|propulsion|motor|rating', 'motor1_rating', 850, 'hp'], [ 'ac|propulsion|propeller|diameter', 'prop1_diameter', 2.3, 'm' ], ['ac|weights|W_battery', 'battery1_weight', 300, 'kg']] self.add_subsystem('dvs', DVLabel(dvlist), promotes_inputs=["*"], promotes_outputs=["*"]) # introduce model components self.add_subsystem('motor1', SimpleMotor(num_nodes=nn, weight_inc=1 / 5000, weight_base=0, efficiency=0.97), promotes_inputs=["throttle"]) self.add_subsystem('prop1', SimplePropeller(num_nodes=nn, num_blades=4, design_J=2.2, design_cp=0.55), promotes_inputs=["fltcond|*"], promotes_outputs=["thrust"]) self.add_subsystem('batt1', SOCBattery(num_nodes=nn, specific_energy=e_b, efficiency=0.97), promotes_inputs=["duration"]) # connect design variables to model component inputs self.connect('motor1_rating', 'motor1.elec_power_rating') self.connect('motor1_rating', 'prop1.power_rating') self.connect('prop1_diameter', 'prop1.diameter') self.connect('battery1_weight', 'batt1.battery_weight') # connect components to each other self.connect('motor1.shaft_power_out', 'prop1.shaft_power_in') self.connect('motor1.elec_load', 'batt1.elec_load') iv = self.add_subsystem('iv', IndepVarComp(), promotes_outputs=['*']) iv.add_output('mdot_coolant', val=0.1 * np.ones((nn, )), units='kg/s') iv.add_output('rho_coolant', val=997 * np.ones((nn, )), units='kg/m**3') iv.add_output('coolant_mass', val=10., units='kg') iv.add_output('channel_width', val=1, units='mm') iv.add_output('channel_height', val=20, units='mm') iv.add_output('channel_length', val=0.2, units='m') iv.add_output('n_parallel', val=50) lc_promotes = ['duration', 'channel_*', 'n_parallel'] self.add_subsystem('motorheatsink', LiquidCooledComp(num_nodes=nn, quasi_steady=False), promotes_inputs=lc_promotes) self.connect('motor1.heat_out', 'motorheatsink.q_in') self.connect('motor1.component_weight', 'motorheatsink.mass') self.add_subsystem('duct', ImplicitCompressibleDuct(num_nodes=nn), promotes_inputs=[('p_inf', 'fltcond|p'), ('T_inf', 'fltcond|T'), ('Utrue', 'fltcond|Utrue')]) self.connect('motorheatsink.T_out', 'duct.T_in_hot') self.connect('rho_coolant', 'duct.rho_hot') self.add_subsystem( 'reservoir', CoolantReservoir(num_nodes=nn), promotes_inputs=['duration', ('mass', 'coolant_mass')]) self.connect('duct.T_out_hot', 'reservoir.T_in') self.connect('reservoir.T_out', 'motorheatsink.T_in') self.connect('mdot_coolant', [ 'motorheatsink.mdot_coolant', 'duct.mdot_hot', 'reservoir.mdot_coolant' ])
def setup(self): nn = self.options['num_nodes'] #define design variables that are independent of flight condition or control states dvlist = [ ['ac|propulsion|engine|rating', 'eng_rating', 260.0, 'kW'], ['ac|propulsion|propeller|diameter', 'prop_diameter', 2.5, 'm'], ['ac|propulsion|motor|rating', 'motor_rating', 240.0, 'kW'], ['ac|propulsion|generator|rating', 'gen_rating', 250.0, 'kW'], ['ac|weights|W_battery', 'batt_weight', 2000, 'kg'], [ 'ac|propulsion|thermal|hx|mdot_coolant', 'mdot_coolant', 0.1 * np.ones((nn, )), 'kg/s' ], [ 'ac|propulsion|thermal|hx|coolant_mass', 'coolant_mass', 10., 'kg' ], [ 'ac|propulsion|thermal|hx|channel_width', 'channel_width', 1., 'mm' ], [ 'ac|propulsion|thermal|hx|channel_height', 'channel_height', 20., 'mm' ], [ 'ac|propulsion|thermal|hx|channel_length', 'channel_length', 0.2, 'm' ], ['ac|propulsion|thermal|hx|n_parallel', 'n_parallel', 50, None], # ['ac|propulsion|thermal|duct|area_nozzle','area_nozzle',58.*np.ones((nn,)),'inch**2'], [ 'ac|propulsion|battery|specific_energy', 'specific_energy', 300, 'W*h/kg' ] ] self.add_subsystem('dvs', DVLabel(dvlist), promotes_inputs=["*"], promotes_outputs=["*"]) #introduce model components self.add_subsystem('motor1', SimpleMotor(efficiency=0.97, num_nodes=nn), promotes_inputs=['throttle']) self.add_subsystem('prop1', SimplePropeller(num_nodes=nn), promotes_inputs=["fltcond|*"]) self.connect('motor1.shaft_power_out', 'prop1.shaft_power_in') #propulsion models expect a high-level 'throttle' parameter and a 'propulsor_active' flag to set individual throttles failedengine = ElementMultiplyDivideComp() failedengine.add_equation('motor2throttle', input_names=['throttle', 'propulsor_active'], vec_size=nn) self.add_subsystem('failedmotor', failedengine, promotes_inputs=['throttle', 'propulsor_active']) self.add_subsystem('motor2', SimpleMotor(efficiency=0.97, num_nodes=nn)) self.add_subsystem('prop2', SimplePropeller(num_nodes=nn), promotes_inputs=["fltcond|*"]) self.connect('motor2.shaft_power_out', 'prop2.shaft_power_in') self.connect('failedmotor.motor2throttle', 'motor2.throttle') addpower = AddSubtractComp(output_name='total_elec_load', input_names=[ 'motor1_elec_load', 'motor2_elec_load', 'refrig_elec_load' ], units='kW', vec_size=nn) addpower.add_equation(output_name='thrust', input_names=['prop1_thrust', 'prop2_thrust'], units='N', vec_size=nn) self.add_subsystem('add_power', subsys=addpower, promotes_outputs=['*']) self.connect('motor1.elec_load', 'add_power.motor1_elec_load') self.connect('motor2.elec_load', 'add_power.motor2_elec_load') self.connect('prop1.thrust', 'add_power.prop1_thrust') self.connect('prop2.thrust', 'add_power.prop2_thrust') self.add_subsystem('hybrid_split', PowerSplit(rule='fraction', num_nodes=nn)) self.connect('total_elec_load', 'hybrid_split.power_in') self.add_subsystem('eng1', SimpleTurboshaft(num_nodes=nn, weight_inc=0.14 / 1000, weight_base=104), promotes_outputs=["fuel_flow"]) self.add_subsystem('gen1', SimpleGenerator(efficiency=0.97, num_nodes=nn)) self.connect('eng1.shaft_power_out', 'gen1.shaft_power_in') self.add_subsystem('batt1', SOCBattery(num_nodes=nn, efficiency=0.97), promotes_inputs=["duration", 'specific_energy']) self.connect('hybrid_split.power_out_A', 'batt1.elec_load') # TODO set val= right number of nn self.add_subsystem( 'eng_throttle_set', BalanceComp(name='eng_throttle', val=np.ones((nn, )) * 0.5, units=None, eq_units='kW', rhs_name='gen_power_required', lhs_name='gen_power_available')) #need to use the optimizer to drive hybrid_split.power_out_B to the same value as gen1.elec_power_out self.connect('hybrid_split.power_out_B', 'eng_throttle_set.gen_power_required') self.connect('gen1.elec_power_out', 'eng_throttle_set.gen_power_available') self.connect('eng_throttle_set.eng_throttle', 'eng1.throttle') adder = AddSubtractComp(output_name='motors_weight', input_names=['motor1_weight', 'motor2_weight'], units='kg') adder.add_equation(output_name='propellers_weight', input_names=['prop1_weight', 'prop2_weight'], units='kg') adder.add_equation(output_name='motors_heat', input_names=['motor1_heat', 'motor2_heat'], vec_size=nn, units='W') self.add_subsystem('adder', subsys=adder, promotes_inputs=['*'], promotes_outputs=['*']) relabel = [[ 'hybrid_split_A_in', 'battery_load', np.ones(nn) * 260.0, 'kW' ]] self.add_subsystem('relabel', DVLabel(relabel), promotes_outputs=["battery_load"]) self.connect('hybrid_split.power_out_A', 'relabel.hybrid_split_A_in') self.connect('motor1.component_weight', 'motor1_weight') self.connect('motor2.component_weight', 'motor2_weight') self.connect('prop1.component_weight', 'prop1_weight') self.connect('prop2.component_weight', 'prop2_weight') self.connect('motor1.heat_out', 'motor1_heat') self.connect('motor2.heat_out', 'motor2_heat') #connect design variables to model component inputs self.connect('eng_rating', 'eng1.shaft_power_rating') self.connect('prop_diameter', ['prop1.diameter', 'prop2.diameter']) self.connect('motor_rating', ['motor1.elec_power_rating', 'motor2.elec_power_rating']) self.connect('motor_rating', ['prop1.power_rating', 'prop2.power_rating']) self.connect('gen_rating', 'gen1.elec_power_rating') self.connect('batt_weight', 'batt1.battery_weight') iv = self.add_subsystem('iv', IndepVarComp(), promotes_outputs=['*']) rho_coolant = 997. # kg/m^3 iv.add_output('rho_coolant', val=rho_coolant * np.ones((nn, )), units='kg/m**3') lc_promotes = ['duration', 'channel_*', 'n_parallel'] # Add the refrigerators electrical load to the splitter with the two motors # so it pulls power from both the battery and turboshaft at the hybridization ratio self.add_subsystem( 'refrig', HeatPumpWithIntegratedCoolantLoop( num_nodes=nn, hot_side_balance_param_units='inch**2', hot_side_balance_param_lower=1e-10, hot_side_balance_param_upper=1e3)) self.connect('refrig.Wdot', 'add_power.refrig_elec_load') iv.add_output('refrig_eff_factor', val=0.4, shape=None, units=None) iv.add_output('refrig_T_h_set', val=450., shape=(nn, ), units='K') iv.add_output('refrig_T_c_set', val=280., shape=(nn, ), units='K') iv.add_output('bypass_refrig', val=np.zeros((nn, )), shape=(nn, ), units=None) self.connect('refrig_eff_factor', 'refrig.eff_factor') self.connect('refrig_T_h_set', 'refrig.T_h_set') self.connect('refrig_T_c_set', 'refrig.T_c_set') self.connect('bypass_refrig', 'refrig.bypass_heat_pump') # Coolant loop on electrical component side (cooling side of refrigerator) # ,---> battery ---> motor ---, # | | # '---- refrig cold side <----' self.add_subsystem('batteryheatsink', LiquidCooledComp(num_nodes=nn, quasi_steady=False), promotes_inputs=lc_promotes) self.connect('batt1.heat_out', 'batteryheatsink.q_in') self.connect('batt_weight', 'batteryheatsink.mass') self.connect('refrig.T_out_cold', 'batteryheatsink.T_in') self.add_subsystem('motorheatsink', LiquidCooledComp(num_nodes=nn, quasi_steady=False), promotes_inputs=lc_promotes) self.connect('motors_heat', 'motorheatsink.q_in') self.connect('motors_weight', 'motorheatsink.mass') self.connect('motorheatsink.T_out', 'refrig.T_in_cold') self.connect('batteryheatsink.T_out', 'motorheatsink.T_in') self.connect('mdot_coolant', [ 'batteryheatsink.mdot_coolant', 'motorheatsink.mdot_coolant', 'refrig.mdot_coolant_cold' ]) # Coolant loop on hot side of refrigerator to reject heat # ,----> refrigerator hot side -----, # | | # '----- heat exchanger/duct <------' self.add_subsystem('duct', ExplicitIncompressibleDuct(num_nodes=nn), promotes_inputs=['fltcond|*']) self.add_subsystem('hx', HXGroup(num_nodes=nn), promotes_inputs=[ 'ac|*', ('rho_cold', 'fltcond|rho'), ('T_in_cold', 'fltcond|T') ]) self.connect('duct.mdot', 'hx.mdot_cold') self.connect('hx.delta_p_cold', 'duct.delta_p_hex') self.connect('rho_coolant', 'hx.rho_hot') self.connect('refrig.T_out_hot', 'hx.T_in_hot') self.connect('hx.T_out_hot', 'refrig.T_in_hot') # Modulate the duct inlet area to maintain the desired temperature on the hot side of the refrig self.connect('refrig.hot_side_balance_param', 'duct.area_nozzle') self.connect('mdot_coolant', ['refrig.mdot_coolant_hot', 'hx.mdot_hot'])
def setup(self): nn = self.options['num_nodes'] #define design variables that are independent of flight condition or control states dvlist = [ ['ac|propulsion|engine|rating', 'eng_rating', 260.0, 'kW'], ['ac|propulsion|propeller|diameter', 'prop_diameter', 2.5, 'm'], ['ac|propulsion|motor|rating', 'motor_rating', 240.0, 'kW'], ['ac|propulsion|generator|rating', 'gen_rating', 250.0, 'kW'], ['ac|weights|W_battery', 'batt_weight', 2000, 'kg'], [ 'ac|propulsion|battery|specific_energy', 'specific_energy', 300, 'W*h/kg' ] ] self.add_subsystem('dvs', DVLabel(dvlist), promotes_inputs=["*"], promotes_outputs=["*"]) #introduce model components self.add_subsystem('motor1', SimpleMotor(efficiency=0.97, num_nodes=nn), promotes_inputs=['throttle']) self.add_subsystem('prop1', SimplePropeller(num_nodes=nn), promotes_inputs=["fltcond|*"]) self.connect('motor1.shaft_power_out', 'prop1.shaft_power_in') #propulsion models expect a high-level 'throttle' parameter and a 'propulsor_active' flag to set individual throttles failedengine = ElementMultiplyDivideComp() failedengine.add_equation('motor2throttle', input_names=['throttle', 'propulsor_active'], vec_size=nn) self.add_subsystem('failedmotor', failedengine, promotes_inputs=['throttle', 'propulsor_active']) self.add_subsystem('motor2', SimpleMotor(efficiency=0.97, num_nodes=nn)) self.add_subsystem('prop2', SimplePropeller(num_nodes=nn), promotes_inputs=["fltcond|*"]) self.connect('motor2.shaft_power_out', 'prop2.shaft_power_in') self.connect('failedmotor.motor2throttle', 'motor2.throttle') addpower = AddSubtractComp( output_name='motors_elec_load', input_names=['motor1_elec_load', 'motor2_elec_load'], units='kW', vec_size=nn) addpower.add_equation(output_name='thrust', input_names=['prop1_thrust', 'prop2_thrust'], units='N', vec_size=nn) self.add_subsystem('add_power', subsys=addpower, promotes_outputs=['*']) self.connect('motor1.elec_load', 'add_power.motor1_elec_load') self.connect('motor2.elec_load', 'add_power.motor2_elec_load') self.connect('prop1.thrust', 'add_power.prop1_thrust') self.connect('prop2.thrust', 'add_power.prop2_thrust') self.add_subsystem('hybrid_split', PowerSplit(rule='fraction', num_nodes=nn)) self.connect('motors_elec_load', 'hybrid_split.power_in') self.add_subsystem('eng1', SimpleTurboshaft(num_nodes=nn, weight_inc=0.14 / 1000, weight_base=104), promotes_outputs=["fuel_flow"]) self.add_subsystem('gen1', SimpleGenerator(efficiency=0.97, num_nodes=nn)) self.connect('eng1.shaft_power_out', 'gen1.shaft_power_in') self.add_subsystem('batt1', SOCBattery(num_nodes=nn, efficiency=0.97), promotes_inputs=["duration", "specific_energy"]) self.connect('hybrid_split.power_out_A', 'batt1.elec_load') # TODO set val= right number of nn self.add_subsystem( 'eng_throttle_set', BalanceComp(name='eng_throttle', val=np.ones((nn, )) * 0.5, units=None, eq_units='kW', rhs_name='gen_power_required', lhs_name='gen_power_available')) #need to use the optimizer to drive hybrid_split.power_out_B to the same value as gen1.elec_power_out self.connect('hybrid_split.power_out_B', 'eng_throttle_set.gen_power_required') self.connect('gen1.elec_power_out', 'eng_throttle_set.gen_power_available') self.connect('eng_throttle_set.eng_throttle', 'eng1.throttle') addweights = AddSubtractComp( output_name='motors_weight', input_names=['motor1_weight', 'motor2_weight'], units='kg') addweights.add_equation(output_name='propellers_weight', input_names=['prop1_weight', 'prop2_weight'], units='kg') self.add_subsystem('add_weights', subsys=addweights, promotes_inputs=['*'], promotes_outputs=['*']) relabel = [[ 'hybrid_split_A_in', 'battery_load', np.ones(nn) * 260.0, 'kW' ]] self.add_subsystem('relabel', DVLabel(relabel), promotes_outputs=["battery_load"]) self.connect('hybrid_split.power_out_A', 'relabel.hybrid_split_A_in') self.connect('motor1.component_weight', 'motor1_weight') self.connect('motor2.component_weight', 'motor2_weight') self.connect('prop1.component_weight', 'prop1_weight') self.connect('prop2.component_weight', 'prop2_weight') #connect design variables to model component inputs self.connect('eng_rating', 'eng1.shaft_power_rating') self.connect('prop_diameter', ['prop1.diameter', 'prop2.diameter']) self.connect('motor_rating', ['motor1.elec_power_rating', 'motor2.elec_power_rating']) self.connect('motor_rating', ['prop1.power_rating', 'prop2.power_rating']) self.connect('gen_rating', 'gen1.elec_power_rating') self.connect('batt_weight', 'batt1.battery_weight')