예제 #1
0
    def setup(self):
        nn = self.options['num_nodes']
        flight_phase = self.options['flight_phase']

        # any control variables other than throttle and braking need to be defined here
        controls = self.add_subsystem('controls', IndepVarComp(), promotes_outputs=['*'])
        controls.add_output('proprpm',val=np.ones((nn,))*2000, units='rpm')

        # assume TO happens on battery backup
        if flight_phase in ['climb', 'cruise','descent']:
            controls.add_output('hybridization',val=0.0)
        else:
            controls.add_output('hybridization',val=1.0)

        hybrid_factor = self.add_subsystem('hybrid_factor', LinearInterpolator(num_nodes=nn),
                                           promotes_inputs=[('start_val', 'hybridization'),
                                                            ('end_val', 'hybridization')])

        propulsion_promotes_outputs = ['fuel_flow','thrust']
        propulsion_promotes_inputs = ["fltcond|*", "ac|propulsion|*", "throttle", "propulsor_active",
                                      "ac|weights*", 'duration']

        self.add_subsystem('propmodel',
                           TwinSeriesHybridElectricPropulsionSystem(num_nodes=nn),
                           promotes_inputs=propulsion_promotes_inputs,
                           promotes_outputs=propulsion_promotes_outputs)
        self.connect('proprpm', ['propmodel.prop1.rpm', 'propmodel.prop2.rpm'])
        self.connect('hybrid_factor.vec', 'propmodel.hybrid_split.power_split_fraction')

        # use a different drag coefficient for takeoff versus cruise
        if flight_phase not in ['v0v1', 'v1v0', 'v1vr', 'rotate']:
            cd0_source = 'ac|aero|polar|CD0_cruise'
        else:
            cd0_source = 'ac|aero|polar|CD0_TO'
        self.add_subsystem('drag', PolarDrag(num_nodes=nn),
                           promotes_inputs=['fltcond|CL', 'ac|geom|*', ('CD0', cd0_source),
                                            'fltcond|q', ('e', 'ac|aero|polar|e')],
                           promotes_outputs=['drag'])

        self.add_subsystem('OEW',TwinSeriesHybridEmptyWeight(),
                           promotes_inputs=[('P_TO','ac|propulsion|engine|rating'),'*'],
                           promotes_outputs=['OEW'])
        self.connect('propmodel.propellers_weight', 'W_propeller')
        self.connect('propmodel.eng1.component_weight', 'W_engine')
        self.connect('propmodel.gen1.component_weight', 'W_generator')
        self.connect('propmodel.motors_weight', 'W_motors')
        intfuel = self.add_subsystem('intfuel', Integrator(num_nodes=nn, method='simpson', diff_units='s',
                                                              time_setup='duration'), promotes_inputs=['*'], promotes_outputs=['*'])
        intfuel.add_integrand('fuel_used', rate_name='fuel_flow', val=1.0, units='kg')
        self.add_subsystem('weight', AddSubtractComp(output_name='weight',
                                                     input_names=['ac|weights|MTOW', 'fuel_used'],
                                                     units='kg', vec_size=[1, nn],
                                                     scaling_factors=[1, -1]),
                           promotes_inputs=['*'],
                           promotes_outputs=['weight'])
예제 #2
0
    def setup(self):
        nn = self.options['num_nodes']
        nn_ones = np.ones((nn, ))
        spec_heat = self.options['specific_heat']

        iv = self.add_subsystem('control', om.IndepVarComp())
        iv.add_output('bypass_start', val=1.0)
        iv.add_output('bypass_end', val=1.0)

        li = self.add_subsystem('li',
                                LinearInterpolator(num_nodes=nn, units=None),
                                promotes_outputs=[('vec', 'bypass')])
        self.connect('control.bypass_start', 'li.start_val')
        self.connect('control.bypass_end', 'li.end_val')
        self.add_subsystem('weightpower',
                           HeatPumpWeight(),
                           promotes_inputs=['power_rating', 'specific_power'],
                           promotes_outputs=['component_weight'])

        self.add_subsystem('hot_side',
                           PerfectHeatTransferComp(num_nodes=nn,
                                                   specific_heat=spec_heat),
                           promotes_inputs=[('T_in', 'T_in_hot'),
                                            'mdot_coolant'])
        self.add_subsystem('cold_side',
                           PerfectHeatTransferComp(num_nodes=nn,
                                                   specific_heat=spec_heat),
                           promotes_inputs=[('T_in', 'T_in_cold'),
                                            'mdot_coolant'])
        self.add_subsystem('copmatch',
                           COPExplicit(num_nodes=nn),
                           promotes_inputs=['eff_factor'],
                           promotes_outputs=['COP'])
        self.connect('hot_side.T_out', 'copmatch.T_h')
        self.connect('cold_side.T_out', 'copmatch.T_c')
        self.add_subsystem('heat_pump',
                           COPHeatPump(num_nodes=nn),
                           promotes_inputs=['power_rating', 'COP'])
        self.connect('heat_pump.q_in_1', 'cold_side.q')
        self.connect('heat_pump.q_in_2', 'hot_side.q')
        # Set the default set points and T_in defaults for continuity
        self.set_input_defaults('T_in_hot', val=400. * nn_ones, units='K')
        self.set_input_defaults('T_in_cold', val=400. * nn_ones, units='K')

        self.add_subsystem(
            'bypass_comp',
            LinearSelector(num_nodes=nn),
            promotes_inputs=['T_in_cold', 'T_in_hot', 'power_rating'],
            promotes_outputs=['T_out_cold', 'T_out_hot', 'elec_load'])
        self.connect('hot_side.T_out', 'bypass_comp.T_out_refrig_hot')
        self.connect('cold_side.T_out', 'bypass_comp.T_out_refrig_cold')
        self.connect('bypass', 'bypass_comp.bypass')
예제 #3
0
    def setup(self):
        nn = self.options['num_nodes']
        flight_phase = self.options['flight_phase']

        # any control variables other than throttle and braking need to be defined here
        controls = self.add_subsystem('controls',
                                      IndepVarComp(),
                                      promotes_outputs=['*'])
        controls.add_output('prop1rpm',
                            val=np.ones((nn, )) * 2000,
                            units='rpm')

        propulsion_promotes_outputs = ['thrust']
        propulsion_promotes_inputs = [
            "fltcond|*", "ac|propulsion|*", "throttle", "ac|weights|*",
            "duration"
        ]

        self.add_subsystem(
            'propmodel',
            AllElectricSinglePropulsionSystemWithThermal_Compressible(
                num_nodes=nn),
            promotes_inputs=propulsion_promotes_inputs,
            promotes_outputs=propulsion_promotes_outputs)
        self.connect('prop1rpm', 'propmodel.prop1.rpm')

        # use a different drag coefficient for takeoff versus cruise
        if flight_phase not in ['v0v1', 'v1v0', 'v1vr', 'rotate']:
            cd0_source = 'ac|aero|polar|CD0_cruise'
        else:
            cd0_source = 'ac|aero|polar|CD0_TO'
        self.add_subsystem('drag',
                           PolarDrag(num_nodes=nn),
                           promotes_inputs=[
                               'fltcond|CL', 'ac|geom|*', ('CD0', cd0_source),
                               'fltcond|q', ('e', 'ac|aero|polar|e')
                           ],
                           promotes_outputs=['drag'])
        self.add_subsystem('weight',
                           LinearInterpolator(num_nodes=nn, units='kg'),
                           promotes_inputs=[('start_val', 'ac|weights|MTOW'),
                                            ('end_val', 'ac|weights|MTOW')],
                           promotes_outputs=[('vec', 'weight')])
예제 #4
0
    def setup(self):
        nn = self.options['num_nodes']
        flight_phase = self.options['flight_phase']

        #=============AERODYNAMICS======================
        # use a different drag coefficient for takeoff versus cruise
        if flight_phase not in ['v0v1', 'v1v0', 'v1vr', 'rotate']:
            cd0_source = 'ac|aero|polar|CD0_cruise'
        else:
            cd0_source = 'ac|aero|polar|CD0_TO'

        self.add_subsystem('airframe_drag',
                           PolarDrag(num_nodes=nn),
                           promotes_inputs=[
                               'fltcond|CL', 'ac|geom|*', ('CD0', cd0_source),
                               'fltcond|q', ('e', 'ac|aero|polar|e')
                           ])
        self.promote_add(sources=[
            'airframe_drag.drag', 'variable_duct.force.F_net',
            'motor_duct.force.F_net'
        ],
                         prom_name='drag',
                         factors=[1.0, -2.0, -2.0],
                         vec_size=nn,
                         units='N')

        #=============PROPULSION=======================
        # Hybrid propulsion motor (model one side only)
        self.add_subsystem('hybrid_throttle',
                           LinearInterpolator(num_nodes=nn, units=None),
                           promotes_inputs=[
                               ('start_val', 'hybrid_throttle_start'),
                               ('end_val', 'hybrid_throttle_end')
                           ])

        self.add_subsystem('hybrid_motor',
                           SimpleMotor(num_nodes=nn, efficiency=0.95),
                           promotes_inputs=[('elec_power_rating',
                                             'ac|propulsion|motor|rating')])
        self.connect('hybrid_motor.shaft_power_out', 'engine.hybrid_power')
        self.connect('hybrid_throttle.vec', 'hybrid_motor.throttle')
        # Add a surrogate model for the engine. Inputs are Mach, Alt, Throttle, Hybrid power
        self.add_subsystem('engine',
                           N3Hybrid(num_nodes=nn, plot=False),
                           promotes_inputs=["fltcond|*", "throttle"])

        # double the thrust and fuel flow of the engine and integrate fuel flow
        self.promote_mult('engine.thrust',
                          prom_name='thrust',
                          factor=2.0,
                          vec_size=nn,
                          units='kN')
        self.promote_mult('engine.fuel_flow',
                          prom_name='fuel_flow',
                          factor=2.0,
                          vec_size=nn,
                          units='kg/s',
                          tags=[
                              'integrate', 'state_name:fuel_used',
                              'state_units:kg', 'state_val:1.0',
                              'state_promotes:True'
                          ])
        # Hybrid propulsion battery
        self.add_subsystem('battery',
                           SOCBattery(num_nodes=nn,
                                      efficiency=0.95,
                                      specific_energy=400),
                           promotes_inputs=[('battery_weight',
                                             'ac|propulsion|battery|weight')])
        self.promote_add(sources=[
            'hybrid_motor.elec_load', 'refrig.elec_load',
            'motorfaultprot.elec_load', 'battery_coolant_pump.elec_load',
            'motor_coolant_pump.elec_load'
        ],
                         prom_name='elec_load',
                         factors=[1.0, 1.0, 1.0, 1.0, 1.0],
                         vec_size=nn,
                         val=1.0,
                         units='kW')
        self.connect('elec_load', 'battery.elec_load')

        #=============THERMAL======================
        thermal_params = self.add_subsystem('thermal_params',
                                            om.IndepVarComp(),
                                            promotes_outputs=['*'])
        # properties
        thermal_params.add_output('rho_coolant',
                                  val=1020 * np.ones((nn, )),
                                  units='kg/m**3')
        # controls
        thermal_params.add_output('mdot_coolant_battery',
                                  val=4.8 * np.ones((nn, )),
                                  units='kg/s')
        thermal_params.add_output('mdot_coolant_motor',
                                  val=1.2 * np.ones((nn, )),
                                  units='kg/s')
        # fault protection needs separate cooler because it needs 40C inflow temp at 3gpm
        thermal_params.add_output('mdot_coolant_fault_prot',
                                  val=0.19 * np.ones((nn, )),
                                  units='kg/s')

        thermal_params.add_output('bypass_heat_pump', val=np.ones((nn, )))
        thermal_params.add_output('variable_duct_nozzle_area_start',
                                  val=20,
                                  units='inch**2')
        thermal_params.add_output('variable_duct_nozzle_area_end',
                                  val=20,
                                  units='inch**2')
        thermal_params.add_output('heat_pump_specific_power',
                                  val=200.,
                                  units='W/kg')
        thermal_params.add_output('heat_pump_eff_factor', val=0.4, units=None)

        self.add_subsystem('li_battery',
                           LinearInterpolator(num_nodes=nn, units='inch**2'),
                           promotes_outputs=[('vec',
                                              'variable_duct_nozzle_area')])
        self.connect('variable_duct_nozzle_area_start', 'li_battery.start_val')
        self.connect('variable_duct_nozzle_area_end', 'li_battery.end_val')
        self.add_subsystem(
            'li_motor',
            LinearInterpolator(num_nodes=nn, units='inch**2'),
            promotes_inputs=[
                ('start_val', 'ac|propulsion|thermal|hx_motor|nozzle_area'),
                ('end_val', 'ac|propulsion|thermal|hx_motor|nozzle_area')
            ],
            promotes_outputs=[('vec', 'motor_duct_area_nozzle_in')])

        hx_design_vars = [
            'ac|propulsion|thermal|hx|n_wide_cold',
            'ac|propulsion|thermal|hx|n_long_cold',
            'ac|propulsion|thermal|hx|n_tall'
        ]

        #===========MOTOR LOOP=======================

        self.add_subsystem('motorheatsink',
                           LiquidCooledMotor(num_nodes=nn,
                                             case_cooling_coefficient=2100.,
                                             quasi_steady=False),
                           promotes_inputs=[('power_rating',
                                             'ac|propulsion|motor|rating')])
        self.connect('hybrid_motor.heat_out', 'motorheatsink.q_in')
        self.connect('hybrid_motor.component_weight',
                     'motorheatsink.motor_weight')

        self.add_subsystem('motorfaultprot',
                           MotorFaultProtection(num_nodes=nn))
        self.connect('hybrid_motor.elec_load', 'motorfaultprot.motor_power')

        self.add_subsystem('hx_motor',
                           HXGroup(num_nodes=nn),
                           promotes_inputs=[(a, a.replace('hx', 'hx_motor'))
                                            for a in hx_design_vars])
        self.connect('rho_coolant', 'hx_motor.rho_hot')
        fault_prot_promotes = [
            ('ac|propulsion|thermal|hx|n_wide_cold',
             'ac|propulsion|thermal|hx_motor|n_wide_cold'),
            ('ac|propulsion|thermal|hx|n_long_cold',
             'ac|propulsion|thermal|hx_fault_prot|n_long_cold'),
            ('ac|propulsion|thermal|hx|n_tall',
             'ac|propulsion|thermal|hx_motor|n_tall')
        ]
        self.add_subsystem('hx_fault_prot',
                           HXGroup(num_nodes=nn),
                           promotes_inputs=fault_prot_promotes)
        self.connect('rho_coolant', [
            'hx_fault_prot.rho_hot', 'motor_hose.rho_coolant',
            'motor_coolant_pump.rho_coolant'
        ])

        self.add_subsystem('motor_duct',
                           ImplicitCompressibleDuct_ExternalHX(num_nodes=nn,
                                                               cfg=0.90),
                           promotes_inputs=[('p_inf', 'fltcond|p'),
                                            ('T_inf', 'fltcond|T'),
                                            ('Utrue', 'fltcond|Utrue'),
                                            ('area_nozzle_in',
                                             'motor_duct_area_nozzle_in')])

        self.add_subsystem('motor_hose',
                           SimpleHose(num_nodes=nn),
                           promotes_inputs=[
                               ('hose_length',
                                'ac|geom|thermal|hx_to_motor_length'),
                               ('hose_diameter',
                                'ac|geom|thermal|hx_to_motor_diameter')
                           ])
        self.add_subsystem(
            'motor_coolant_pump',
            SimplePump(num_nodes=nn),
            promotes_inputs=[
                ('power_rating',
                 'ac|propulsion|thermal|hx_motor|pump_power_rating')
            ])
        self.promote_add(
            sources=['motor_hose.delta_p', 'hx_motor.delta_p_hot'],
            prom_name='pressure_drop_motor_loop',
            factors=[1.0, -1.0],
            vec_size=nn,
            units='Pa')
        self.connect('pressure_drop_motor_loop', 'motor_coolant_pump.delta_p')

        # in to HXGroup:
        self.connect('motor_duct.sta2.T', 'hx_fault_prot.T_in_cold')
        self.connect('hx_fault_prot.T_out_cold', 'hx_motor.T_in_cold')

        self.connect('motor_duct.sta2.rho',
                     ['hx_motor.rho_cold', 'hx_fault_prot.rho_cold'])
        self.connect('motor_duct.mdot',
                     ['hx_motor.mdot_cold', 'hx_fault_prot.mdot_cold'])
        self.connect('motorheatsink.T_out', 'hx_motor.T_in_hot')
        self.connect('motorfaultprot.T_out', 'hx_fault_prot.T_in_hot')
        self.connect('mdot_coolant_motor', [
            'motorheatsink.mdot_coolant', 'hx_motor.mdot_hot',
            'motor_hose.mdot_coolant', 'motor_coolant_pump.mdot_coolant'
        ])
        self.connect('mdot_coolant_fault_prot',
                     ['motorfaultprot.mdot_coolant', 'hx_fault_prot.mdot_hot'])

        #out from HXGroup
        self.connect('hx_motor.frontal_area',
                     ['motor_duct.area_2', 'motor_duct.area_3'])
        self.connect('hx_motor.delta_p_cold',
                     'motorfaultprot.delta_p_motor_hx')
        self.connect('hx_fault_prot.delta_p_cold',
                     'motorfaultprot.delta_p_fault_prot_hx')
        self.connect('motorfaultprot.delta_p_stack', 'motor_duct.sta3.delta_p')

        self.connect('hx_motor.heat_transfer',
                     'motorfaultprot.heat_transfer_motor_hx')
        self.connect('hx_fault_prot.heat_transfer',
                     'motorfaultprot.heat_transfer_fault_prot_hx')
        self.connect('motorfaultprot.heat_transfer', 'motor_duct.sta3.heat_in')

        self.connect('hx_motor.T_out_hot', 'motorheatsink.T_in')
        self.connect('hx_fault_prot.T_out_hot', 'motorfaultprot.T_in')

        #=========BATTERY LOOP=====================
        self.add_subsystem('batteryheatsink',
                           LiquidCooledBattery(num_nodes=nn,
                                               quasi_steady=False),
                           promotes_inputs=[('battery_weight',
                                             'ac|propulsion|battery|weight')])
        self.connect('battery.heat_out', 'batteryheatsink.q_in')

        # self.connect('mdot_coolant_battery', ['batteryheatsink.mdot_coolant', 'hx_battery.mdot_hot', 'battery_hose.mdot_coolant', 'battery_coolant_pump.mdot_coolant'])
        self.connect('mdot_coolant_battery', [
            'batteryheatsink.mdot_coolant', 'refrig.mdot_coolant',
            'hx_battery.mdot_hot', 'battery_hose.mdot_coolant',
            'battery_coolant_pump.mdot_coolant'
        ])

        self.connect('batteryheatsink.T_out', 'refrig.T_in_cold')
        self.connect('refrig.T_out_cold', 'batteryheatsink.T_in')

        self.add_subsystem('hx_battery',
                           HXGroup(num_nodes=nn),
                           promotes_inputs=hx_design_vars)
        self.connect('rho_coolant', [
            'hx_battery.rho_hot', 'battery_hose.rho_coolant',
            'battery_coolant_pump.rho_coolant'
        ])

        # Hot side balance param will be set to the cooling duct nozzle area
        self.add_subsystem('refrig',
                           HeatPumpWithIntegratedCoolantLoop(num_nodes=nn),
                           promotes_inputs=[
                               ('power_rating',
                                'ac|propulsion|thermal|heatpump|power_rating')
                           ])
        self.connect('heat_pump_eff_factor', 'refrig.eff_factor')
        self.connect('heat_pump_specific_power', 'refrig.specific_power')

        self.add_subsystem('variable_duct',
                           ImplicitCompressibleDuct_ExternalHX(num_nodes=nn,
                                                               cfg=0.95),
                           promotes_inputs=[('p_inf', 'fltcond|p'),
                                            ('T_inf', 'fltcond|T'),
                                            ('Utrue', 'fltcond|Utrue')])
        self.connect('variable_duct_nozzle_area',
                     'variable_duct.area_nozzle_in')

        self.add_subsystem('battery_hose',
                           SimpleHose(num_nodes=nn),
                           promotes_inputs=[
                               ('hose_length',
                                'ac|geom|thermal|hx_to_battery_length'),
                               ('hose_diameter',
                                'ac|geom|thermal|hx_to_battery_diameter')
                           ])
        self.add_subsystem('battery_coolant_pump',
                           SimplePump(num_nodes=nn),
                           promotes_inputs=[
                               ('power_rating',
                                'ac|propulsion|thermal|hx|pump_power_rating')
                           ])
        self.promote_add(
            sources=['battery_hose.delta_p', 'hx_battery.delta_p_hot'],
            prom_name='pressure_drop_battery_loop',
            factors=[1.0, -1.0],
            vec_size=nn,
            units='Pa')
        self.connect('pressure_drop_battery_loop',
                     'battery_coolant_pump.delta_p')

        # in to HXGroup:
        self.connect('variable_duct.sta2.T', 'hx_battery.T_in_cold')
        self.connect('variable_duct.sta2.rho', 'hx_battery.rho_cold')
        self.connect('variable_duct.mdot', 'hx_battery.mdot_cold')

        #out from HXGroup
        self.connect('hx_battery.frontal_area',
                     ['variable_duct.area_2', 'variable_duct.area_3'])
        self.connect('hx_battery.delta_p_cold', 'variable_duct.sta3.delta_p')
        self.connect('hx_battery.heat_transfer', 'variable_duct.sta3.heat_in')
        self.connect('hx_battery.T_out_hot', 'refrig.T_in_hot')
        self.connect('refrig.T_out_hot', 'hx_battery.T_in_hot')

        # self.connect('hx_battery.T_out_hot', 'batteryheatsink.T_in')
        # self.connect('batteryheatsink.T_out', 'hx_battery.T_in_hot')

        #=============WEIGHTS======================

        # generally the weights module will be custom to each airplane

        # Motor, Battery, TMS, N+3 weight delta
        self.promote_add(sources=[
            'refrig.component_weight', 'hx_motor.component_weight',
            'hx_battery.component_weight', 'battery_hose.component_weight',
            'battery_coolant_pump.component_weight',
            'motor_hose.component_weight',
            'motor_coolant_pump.component_weight',
            'hx_fault_prot.component_weight', 'hybrid_motor.component_weight'
        ],
                         promoted_sources=['ac|weights|OEW'],
                         prom_name='OEW',
                         factors=[
                             2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 1.0
                         ],
                         vec_size=1,
                         units='kg')

        self.add_subsystem('weight',
                           oc.AddSubtractComp(output_name='weight',
                                              input_names=[
                                                  'ac|design_mission|TOW',
                                                  'fuel_used'
                                              ],
                                              units='kg',
                                              vec_size=[1, nn],
                                              scaling_factors=[1, -1]),
                           promotes_inputs=['*'],
                           promotes_outputs=['weight'])

        self.promote_add(sources=[],
                         promoted_sources=[
                             'ac|design_mission|TOW', 'OEW', 'fuel_used_final',
                             'ac|propulsion|battery|weight'
                         ],
                         prom_name='margin',
                         factors=[1.0, -1.0, -1.0, -2.0],
                         vec_size=1,
                         units='kg')
예제 #5
0
    def setup(self):
        n_int_per_seg = self.options['n_int_per_seg']
        nn_tot_to = (2 * n_int_per_seg + 1) * 3 + 2  #v0v1,v1vr,v1v0, vtr, v2
        nn_tot_m = (2 * n_int_per_seg + 1) * 3
        nn_tot = nn_tot_to + nn_tot_m
        nn = (2 * n_int_per_seg + 1)

        constant_hybridization = self.options['constant_hybridization']
        specific_energy = self.options['specific_energy']

        #Define input variables
        dv_comp = self.add_subsystem('dv_comp',
                                     DictIndepVarComp(acdata),
                                     promotes_outputs=["*"])
        #eventually replace the following aerodynamic parameters with an analysis module (maybe OpenAeroStruct)
        dv_comp.add_output_from_dict('ac|aero|CLmax_flaps30')
        dv_comp.add_output_from_dict('ac|aero|polar|e')
        dv_comp.add_output_from_dict('ac|aero|polar|CD0_TO')
        dv_comp.add_output_from_dict('ac|aero|polar|CD0_cruise')

        dv_comp.add_output_from_dict('ac|geom|wing|S_ref')
        dv_comp.add_output_from_dict('ac|geom|wing|AR')
        dv_comp.add_output_from_dict('ac|geom|wing|c4sweep')
        dv_comp.add_output_from_dict('ac|geom|wing|taper')
        dv_comp.add_output_from_dict('ac|geom|wing|toverc')
        dv_comp.add_output_from_dict('ac|geom|hstab|S_ref')
        dv_comp.add_output_from_dict('ac|geom|hstab|c4_to_wing_c4')
        dv_comp.add_output_from_dict('ac|geom|vstab|S_ref')
        dv_comp.add_output_from_dict('ac|geom|fuselage|S_wet')
        dv_comp.add_output_from_dict('ac|geom|fuselage|width')
        dv_comp.add_output_from_dict('ac|geom|fuselage|length')
        dv_comp.add_output_from_dict('ac|geom|fuselage|height')
        dv_comp.add_output_from_dict('ac|geom|nosegear|length')
        dv_comp.add_output_from_dict('ac|geom|maingear|length')

        dv_comp.add_output_from_dict('ac|weights|MTOW')
        dv_comp.add_output_from_dict('ac|weights|W_fuel_max')
        dv_comp.add_output_from_dict('ac|weights|MLW')
        dv_comp.add_output_from_dict('ac|weights|W_battery')

        dv_comp.add_output_from_dict('ac|propulsion|engine|rating')
        dv_comp.add_output_from_dict('ac|propulsion|propeller|diameter')
        dv_comp.add_output_from_dict('ac|propulsion|generator|rating')
        dv_comp.add_output_from_dict('ac|propulsion|motor|rating')

        dv_comp.add_output_from_dict('ac|num_passengers_max')
        dv_comp.add_output_from_dict('ac|q_cruise')
        dv_comp.add_output_from_dict('ac|num_engines')

        mission_data_comp = self.add_subsystem('mission_data_comp',
                                               DictIndepVarComp(missiondata),
                                               promotes_outputs=["*"])
        mission_data_comp.add_output_from_dict('mission|takeoff|h')
        mission_data_comp.add_output_from_dict('mission|climb|vs')
        mission_data_comp.add_output_from_dict('mission|climb|Ueas')
        mission_data_comp.add_output_from_dict('mission|cruise|h')
        mission_data_comp.add_output_from_dict('mission|cruise|Ueas')
        mission_data_comp.add_output_from_dict('mission|descent|vs')
        mission_data_comp.add_output_from_dict('mission|descent|Ueas')
        mission_data_comp.add_output_from_dict('mission|range')
        mission_data_comp.add_output_from_dict('mission|payload')

        #== Compute the stall speed (necessary for takeoff analysis - leave this alone)
        vstall = self.add_subsystem('vstall', StallSpeed())
        self.connect('ac|weights|MTOW', 'vstall.weight')
        self.connect('ac|geom|wing|S_ref', 'vstall.ac|geom|wing|S_ref')
        self.connect('ac|aero|CLmax_flaps30', 'vstall.CLmax')

        # ==Calculate flight conditions for the takeoff and mission segments here (leave this alone)
        mission_conditions = self.add_subsystem(
            'mission_conditions',
            MissionFlightConditions(n_int_per_seg=n_int_per_seg),
            promotes_inputs=["mission|*"],
            promotes_outputs=["mission|*", "fltcond|mission|*"])

        takeoff_conditions = self.add_subsystem(
            'takeoff_conditions',
            TakeoffFlightConditions(n_int_per_seg=n_int_per_seg),
            promotes_inputs=["mission|takeoff|*"],
            promotes_outputs=["fltcond|takeoff|*", "mission|takeoff|*"])
        self.connect('vstall.Vstall_eas', 'takeoff_conditions.Vstall_eas')

        fltcondcombiner = VectorConcatenateComp(
            output_name='fltcond|h',
            input_names=['fltcond|takeoff|h', 'fltcond|mission|h'],
            units='m',
            vec_sizes=[nn_tot_to, nn_tot_m])
        fltcondcombiner.add_relation(
            output_name='fltcond|Ueas',
            input_names=['fltcond|takeoff|Ueas', 'fltcond|mission|Ueas'],
            units='m/s',
            vec_sizes=[nn_tot_to, nn_tot_m])
        self.add_subsystem(
            'fltcondcombiner',
            subsys=fltcondcombiner,
            promotes_inputs=["fltcond|takeoff|*", "fltcond|mission|*"],
            promotes_outputs=["fltcond|Ueas", "fltcond|h"])

        #==Calculate atmospheric properties and true airspeeds for all mission segments
        atmos = self.add_subsystem(
            'atmos',
            ComputeAtmosphericProperties(num_nodes=nn_tot),
            promotes_inputs=["fltcond|h", "fltcond|Ueas"],
            promotes_outputs=["fltcond|rho", "fltcond|Utrue", "fltcond|q"])

        #==Define control settings for the propulsion system.
        # Recall that all flight points including takeoff roll are calculated all at once
        # The structure of the takeoff vector should be:
        #[ nn points (takeoff at full power, v0 to v1),
        #  nn points (takeoff at engine-out power (if applicable), v1 to vr),
        #  nn points (hard braking at zero power or even reverse, vr to v0),
        # !CAUTION! 1 point (transition at OEI power (if applicable), v_trans)
        # !CAUTION! 1 point (v2 climb at OEI power (if app), v2)
        # ]
        # The mission throttle vector should be set implicitly using the optimizer (driving T = D + sin(gamma)mg residual to 0)

        controls = self.add_subsystem('controls', IndepVarComp())
        #set the prop to 1900 rpm for all time
        controls.add_output('prop1|rpm',
                            val=np.ones(nn_tot) * 1900,
                            units='rpm')
        controls.add_output('prop2|rpm',
                            val=np.ones(nn_tot) * 1900,
                            units='rpm')

        motor1_TO_throttle_vec = np.concatenate(
            [np.ones(nn),
             np.ones(nn) * 1.0,
             np.zeros(nn),
             np.ones(2) * 1.0]) * 1.1
        motor2_TO_throttle_vec = np.concatenate(
            [np.ones(nn),
             np.zeros(nn) * 0.0,
             np.zeros(nn),
             np.zeros(2) * 0.0]) * 1.1
        controls.add_output('motor1|throttle|takeoff',
                            val=motor1_TO_throttle_vec)
        controls.add_output('motor2|throttle|takeoff',
                            val=motor2_TO_throttle_vec)

        controls.add_output('hybrid_split|takeoff', val=1)
        self.add_subsystem('hybrid_TO',
                           LinearInterpolator(num_nodes=nn_tot_to))
        self.connect('controls.hybrid_split|takeoff',
                     ['hybrid_TO.start_val', 'hybrid_TO.end_val'])

        hybrid_climb = self.add_subsystem('hybrid_climb',
                                          LinearInterpolator(num_nodes=nn))
        hybrid_cruise = self.add_subsystem('hybrid_cruise',
                                           LinearInterpolator(num_nodes=nn))
        hybrid_desc = self.add_subsystem('hybrid_desc',
                                         LinearInterpolator(num_nodes=nn))

        if constant_hybridization:
            controls.add_output('hybrid_split|percentage', val=0.5)
            self.connect('controls.hybrid_split|percentage',
                         'hybrid_climb.start_val')
            self.connect('controls.hybrid_split|percentage',
                         'hybrid_climb.end_val')
            self.connect('controls.hybrid_split|percentage',
                         'hybrid_cruise.start_val')
            self.connect('controls.hybrid_split|percentage',
                         'hybrid_cruise.end_val')
            self.connect('controls.hybrid_split|percentage',
                         'hybrid_desc.start_val')
            self.connect('controls.hybrid_split|percentage',
                         'hybrid_desc.end_val')
        else:
            controls.add_output('hybrid_split|climb_0', val=0.5)
            controls.add_output('hybrid_split|climb_f', val=0.5)
            controls.add_output('hybrid_split|cruise_0', val=0.5)
            controls.add_output('hybrid_split|cruise_f', val=0.5)
            controls.add_output('hybrid_split|desc_0', val=0.5)
            controls.add_output('hybrid_split|desc_f', val=0.5)
            self.connect('controls.hybrid_split|climb_0',
                         'hybrid_climb.start_val')
            self.connect('controls.hybrid_split|climb_f',
                         'hybrid_climb.end_val')
            self.connect('controls.hybrid_split|cruise_0',
                         'hybrid_cruise.start_val')
            self.connect('controls.hybrid_split|cruise_f',
                         'hybrid_cruise.end_val')
            self.connect('controls.hybrid_split|desc_0',
                         'hybrid_desc.start_val')
            self.connect('controls.hybrid_split|desc_f', 'hybrid_desc.end_val')

        hybrid_combiner = self.add_subsystem(
            'hybrid_combiner',
            VectorConcatenateComp(
                output_name='hybrid_split|mission',
                input_names=['hybrid_climb', 'hybrid_cruise', 'hybrid_desc'],
                vec_sizes=[nn, nn, nn]))
        self.connect('hybrid_climb.vec', 'hybrid_combiner.hybrid_climb')
        self.connect('hybrid_cruise.vec', 'hybrid_combiner.hybrid_cruise')
        self.connect('hybrid_desc.vec', 'hybrid_combiner.hybrid_desc')
        #combine the various controls together into one vector
        throttle_combiner = VectorConcatenateComp(
            output_name='motor1|throttle',
            input_names=['motor1|throttle|takeoff', 'motor1|throttle|mission'],
            vec_sizes=[nn_tot_to, nn_tot_m])
        throttle_combiner.add_relation(
            output_name='motor2|throttle',
            input_names=['motor2|throttle|takeoff', 'motor2|throttle|mission'],
            vec_sizes=[nn_tot_to, nn_tot_m])
        throttle_combiner.add_relation(
            output_name='hybrid_split',
            input_names=['hybrid_split|takeoff', 'hybrid_split|mission'],
            vec_sizes=[nn_tot_to, nn_tot_m])
        self.add_subsystem('throttle_combiner',
                           subsys=throttle_combiner,
                           promotes_outputs=["motor*|throttle"])
        self.connect('controls.motor1|throttle|takeoff',
                     'throttle_combiner.motor1|throttle|takeoff')
        self.connect('controls.motor2|throttle|takeoff',
                     'throttle_combiner.motor2|throttle|takeoff')
        self.connect('hybrid_TO.vec', 'throttle_combiner.hybrid_split|takeoff')
        self.connect('hybrid_combiner.hybrid_split|mission',
                     'throttle_combiner.hybrid_split|mission')
        #==Calculate engine thrusts and fuel flows. You will need to override this module to vary number of engines, prop architecture, etc
        # Your propulsion model must promote up a single variable called "thrust" and a single variable called "fuel_flow". You may need to sum these at a lower level in the prop model group
        # You will probably need to add more control parameters if you use multiple engines. You may also need to add implicit solver states if, e.g. turbogenerator power setting depends on motor power setting

        prop = self.add_subsystem(
            'propmodel',
            TwinSeriesHybridElectricPropulsionSystem(
                num_nodes=nn_tot, specific_energy=specific_energy),
            promotes_inputs=["fltcond|*", "ac|propulsion|*", "ac|weights|*"],
            promotes_outputs=["fuel_flow", "thrust"])
        #connect control settings to the various states in the propulsion model
        self.connect('controls.prop1|rpm', 'propmodel.prop1.rpm')
        self.connect('controls.prop2|rpm', 'propmodel.prop2.rpm')
        self.connect('motor1|throttle', 'propmodel.motor1.throttle')
        self.connect('motor2|throttle', 'propmodel.motor2.throttle')
        self.connect('throttle_combiner.hybrid_split',
                     'propmodel.hybrid_split.power_split_fraction')

        #now we have flight conditions and propulsion outputs for all flight conditions. Split into our individual analysis phases
        #== Leave this alone==#
        splitter_inst = VectorSplitComp()

        inputs_to_split = [
            'fltcond|q', 'fltcond|Utrue', 'fuel_flow', 'thrust', 'battery_load'
        ]
        segments_to_split_into = ['takeoff', 'mission']
        units = ['N * m**-2', 'm/s', 'kg/s', 'N', 'kW']
        nn_each_segment = [nn_tot_to, nn_tot_m]

        for kth, input_name in enumerate(inputs_to_split):
            output_names_list = []
            for segment in segments_to_split_into:
                inpnamesplit = input_name.split('|')
                inpnamesplit.insert(-1, segment)
                output_names_list.append('|'.join(inpnamesplit))
            splitter_inst.add_relation(output_names=output_names_list,
                                       input_name=input_name,
                                       vec_sizes=nn_each_segment,
                                       units=units[kth])

        self.add_subsystem('splitter',
                           subsys=splitter_inst,
                           promotes_inputs=["*"],
                           promotes_outputs=["*"])
        self.connect('propmodel.hybrid_split.power_out_A', 'battery_load')

        #==This next module calculates balanced field length, if applicable. Your optimizer or solver MUST implicitly drive the abort distance and oei takeoff distances to the same value by varying v1

        takeoff = self.add_subsystem(
            'takeoff',
            TakeoffTotalDistance(n_int_per_seg=n_int_per_seg,
                                 track_fuel=True,
                                 track_battery=True),
            promotes_inputs=[
                'ac|aero*', 'ac|weights|MTOW', 'ac|geom|*',
                'fltcond|takeoff|*', 'takeoff|battery_load', 'takeoff|thrust',
                'takeoff|fuel_flow', 'mission|takeoff|v*'
            ])

        #==This module computes fuel consumption during the entire mission
        mission = self.add_subsystem(
            'mission',
            MissionNoReserves(n_int_per_seg=n_int_per_seg, track_battery=True),
            promotes_inputs=[
                "ac|aero|*", "ac|geom|*", "fltcond|mission|*",
                "mission|thrust", "mission|fuel_flow", 'mission|battery_load',
                "mission|*"
            ])
        #remember that you will need to set the mission throttle implicitly using the optimizer/solver. This was done above when we mashed the control vectors all together.
        self.connect('takeoff.weight_after_takeoff', 'mission|weight_initial')

        #==This module is an empirical weight tool specific to a single-engine turboprop airplane. You will need to modify or replace it.
        self.add_subsystem('OEW',
                           TwinSeriesHybridEmptyWeight(),
                           promotes_inputs=["*"])
        self.connect('ac|propulsion|engine|rating', 'P_TO')
        #Don't forget to couple the propulsion system to the weights module like so:
        self.connect('propmodel.propellers_weight', 'W_propeller')
        self.connect('propmodel.eng1.component_weight', 'W_engine')
        self.connect('propmodel.gen1.component_weight', 'W_generator')
        self.connect('propmodel.motors_weight', 'W_motors')

        #==Finally, we need to compute certain quantities to ensure the airplane is feasible. Compute whether enough fuel volume exists, and whether the airplane burned more fuel than it can carry
        missionmargins = self.add_subsystem(
            'missionmargins',
            ComputeDesignMissionResidualsBattery(include_takeoff=True),
            promotes_inputs=[
                'ac|weights|MTOW', 'ac|weights|W_battery', "mission|*",
                "ac|weights|W_fuel_max"
            ],
            promotes_outputs=['fuel_burn', 'battery_energy_used'])
        self.connect('OEW.OEW', 'missionmargins.OEW')
        self.connect('mission.mission|total_fuel', 'mission|total_fuel')
        self.connect('mission.mission|total_battery_energy',
                     'mission|total_battery_energy')
        self.connect('takeoff.takeoff|total_fuel',
                     'missionmargins.takeoff|total_fuel')
        self.connect('takeoff.takeoff|total_battery_energy',
                     'missionmargins.takeoff|total_battery_energy')
        self.connect('propmodel.batt1.max_energy',
                     'missionmargins.battery_max_energy')

        #==Calculate the difference between the one-engine-out abort distance and one-engine-out takeoff distance with obstacle clearance
        bflmargins = self.add_subsystem('bflmargins',
                                        ComputeBalancedFieldLengthResidual(),
                                        promotes_inputs=['mission|takeoff|v*'])
        self.connect('takeoff.takeoff|distance', 'bflmargins.takeoff|distance')
        self.connect('takeoff.takeoff|distance_abort',
                     'bflmargins.takeoff|distance_abort')

        implicit_solve = self.add_subsystem(
            'implicit_solve', SolveImplicitStates(n_int_per_seg=n_int_per_seg))
        self.connect('mission.thrust_resid.thrust_residual',
                     'implicit_solve.thrust_residual')
        self.connect('bflmargins.BFL_combined', 'implicit_solve.BFL_residual')
        self.connect('propmodel.eng_gen_resid.eng_gen_residual',
                     'implicit_solve.eng_gen_residual')

        self.connect('implicit_solve.mission|takeoff|v1', 'mission|takeoff|v1')
        self.connect('implicit_solve.eng_throttle', 'propmodel.eng1.throttle')
        self.connect('implicit_solve.motor_throttle', [
            'throttle_combiner.motor1|throttle|mission',
            'throttle_combiner.motor2|throttle|mission'
        ])

        components_list = ['eng1', 'motor1', 'motor2', 'gen1']
        opcost = self.add_subsystem(
            'operating_cost',
            OperatingCost(n_components=len(components_list), n_batteries=1))
        self.connect('propmodel.batt1.component_cost',
                     'operating_cost.battery_1_NR_cost')
        self.connect('battery_energy_used',
                     'operating_cost.battery_1_energy_used')

        self.connect('OEW.OEW', 'operating_cost.OEW')
        self.connect('fuel_burn', 'operating_cost.fuel_burn')
        for i, component in enumerate(components_list):
            self.connect('propmodel.' + component + '.component_weight',
                         'operating_cost.component_' + str(i + 1) + '_weight')
            self.connect('propmodel.' + component + '.component_cost',
                         'operating_cost.component_' + str(i + 1) + '_NR_cost')

        dummy_range = self.add_subsystem(
            'dummypayload',
            DummyPayload(),
            promotes_outputs=['payload_objective'])
        self.connect('mission|payload', 'dummypayload.payload_DV')
        dummy_obj = self.add_subsystem(
            'dummyobj',
            AugmentedFBObjective(),
            promotes_inputs=['ac|weights|MTOW', 'fuel_burn'],
            promotes_outputs=['mixed_objective'])
예제 #6
0
    def setup(self):
        n_int_per_seg = self.options['n_int_per_seg']
        mission_segments = ['climb', 'cruise', 'descent']
        nn, nn_tot_to, nn_tot_m, nn_tot = compute_num_nodes(
            n_int_per_seg, mission_segments)

        constant_hybridization = self.options['constant_hybridization']
        specific_energy = self.options['specific_energy']

        #Define input variables
        dv_comp = self.add_subsystem('dv_comp',
                                     DictIndepVarComp(acdata),
                                     promotes_outputs=["*"])
        #eventually replace the following aerodynamic parameters with an analysis module (maybe OpenAeroStruct)
        dv_comp.add_output_from_dict('ac|aero|CLmax_flaps30')
        dv_comp.add_output_from_dict('ac|aero|polar|e')
        dv_comp.add_output_from_dict('ac|aero|polar|CD0_TO')
        dv_comp.add_output_from_dict('ac|aero|polar|CD0_cruise')

        dv_comp.add_output_from_dict('ac|geom|wing|S_ref')
        dv_comp.add_output_from_dict('ac|geom|wing|AR')
        dv_comp.add_output_from_dict('ac|geom|wing|c4sweep')
        dv_comp.add_output_from_dict('ac|geom|wing|taper')
        dv_comp.add_output_from_dict('ac|geom|wing|toverc')
        dv_comp.add_output_from_dict('ac|geom|hstab|S_ref')
        dv_comp.add_output_from_dict('ac|geom|hstab|c4_to_wing_c4')
        dv_comp.add_output_from_dict('ac|geom|vstab|S_ref')
        dv_comp.add_output_from_dict('ac|geom|fuselage|S_wet')
        dv_comp.add_output_from_dict('ac|geom|fuselage|width')
        dv_comp.add_output_from_dict('ac|geom|fuselage|length')
        dv_comp.add_output_from_dict('ac|geom|fuselage|height')
        dv_comp.add_output_from_dict('ac|geom|nosegear|length')
        dv_comp.add_output_from_dict('ac|geom|maingear|length')

        dv_comp.add_output_from_dict('ac|weights|MTOW')
        dv_comp.add_output_from_dict('ac|weights|W_fuel_max')
        dv_comp.add_output_from_dict('ac|weights|MLW')
        dv_comp.add_output_from_dict('ac|weights|W_battery')

        dv_comp.add_output_from_dict('ac|propulsion|engine|rating')
        dv_comp.add_output_from_dict('ac|propulsion|propeller|diameter')
        dv_comp.add_output_from_dict('ac|propulsion|generator|rating')
        dv_comp.add_output_from_dict('ac|propulsion|motor|rating')

        dv_comp.add_output_from_dict('ac|num_passengers_max')
        dv_comp.add_output_from_dict('ac|q_cruise')
        dv_comp.add_output_from_dict('ac|num_engines')

        mission_data_comp = self.add_subsystem('mission_data_comp',
                                               DictIndepVarComp(missiondata),
                                               promotes_outputs=["*"])
        mission_data_comp.add_output_from_dict('takeoff|h')
        mission_data_comp.add_output_from_dict('climb|h0')
        mission_data_comp.add_output_from_dict('climb|time')
        mission_data_comp.add_output_from_dict('climb|Ueas')
        mission_data_comp.add_output_from_dict('cruise|h0')
        mission_data_comp.add_output_from_dict('cruise|Ueas')
        mission_data_comp.add_output_from_dict('descent|h0')
        mission_data_comp.add_output_from_dict('descent|hf')
        mission_data_comp.add_output_from_dict('descent|time')
        mission_data_comp.add_output_from_dict('descent|Ueas')
        mission_data_comp.add_output_from_dict('design_range')
        mission_data_comp.add_output_from_dict('payload')

        #==Define control settings for the propulsion system.
        # Recall that all flight points including takeoff roll are calculated all at once
        # The structure of the takeoff vector should be:
        #[ nn points (takeoff at full power, v0 to v1),
        #  nn points (takeoff at engine-out power (if applicable), v1 to vr),
        #  nn points (hard braking at zero power or even reverse, vr to v0),
        # !CAUTION! 1 point (transition at OEI power (if applicable), v_trans)
        # !CAUTION! 1 point (v2 climb at OEI power (if app), v2)
        # ]
        # The mission throttle vector should be set implicitly using the optimizer (driving T = D + sin(gamma)mg residual to 0)

        controls = self.add_subsystem('controls', IndepVarComp())
        #set the prop to 1900 rpm for all time
        controls.add_output('prop|rpm|takeoff',
                            val=np.ones(nn_tot_to) * 1900,
                            units='rpm')
        controls.add_output('prop|rpm|mission',
                            val=np.ones(nn_tot_m) * 1900,
                            units='rpm')

        motor1_TO_throttle_vec = np.concatenate(
            [np.ones(nn),
             np.ones(nn) * 1.0,
             np.zeros(nn),
             np.ones(2) * 1.0]) * 1.1
        motor2_TO_throttle_vec = np.concatenate(
            [np.ones(nn),
             np.zeros(nn) * 0.0,
             np.zeros(nn),
             np.zeros(2) * 0.0]) * 1.1
        controls.add_output('motor1|throttle|takeoff',
                            val=motor1_TO_throttle_vec)
        controls.add_output('motor2|throttle|takeoff',
                            val=motor2_TO_throttle_vec)

        controls.add_output('hybrid_split|takeoff', val=1)
        controls.add_output('eng1|throttle|takeoff', val=np.zeros(nn_tot_to))
        self.add_subsystem('hybrid_TO',
                           LinearInterpolator(num_nodes=nn_tot_to))
        self.connect('controls.hybrid_split|takeoff',
                     ['hybrid_TO.start_val', 'hybrid_TO.end_val'])

        if constant_hybridization:
            controls.add_output('hybrid_split|percentage', val=0.5)
        hybrid_comps = []
        for segment_name in mission_segments:
            hybrid_comps.append('hybrid_' + segment_name)
            self.add_subsystem('hybrid_' + segment_name,
                               LinearInterpolator(num_nodes=nn))
            if constant_hybridization:
                self.connect('controls.hybrid_split|percentage',
                             'hybrid_' + segment_name + '.start_val')
                self.connect('controls.hybrid_split|percentage',
                             'hybrid_' + segment_name + '.end_val')
            else:
                controls.add_output('hybrid_split|' + segment_name + '_0',
                                    val=0.5)
                controls.add_output('hybrid_split|' + segment_name + '_f',
                                    val=0.5)
                self.connect('hybrid_split|' + segment_name + '_0',
                             'hybrid_' + segment_name + '.start_val')
                self.connect('hybrid_split|' + segment_name + '_f',
                             'hybrid_' + segment_name + '.end_val')
        hybrid_combiner = self.add_subsystem(
            'hybrid_combiner',
            VectorConcatenateComp(output_name='hybrid_split|mission',
                                  input_names=hybrid_comps,
                                  vec_sizes=[nn, nn, nn]))
        for segment_name in mission_segments:
            self.connect('hybrid_' + segment_name + '.vec',
                         'hybrid_combiner.hybrid_' + segment_name)

        #==Calculate engine thrusts and fuel flows. You will need to override this module to vary number of engines, prop architecture, etc
        # Your propulsion model must promote up a single variable called "thrust" and a single variable called "fuel_flow". You may need to sum these at a lower level in the prop model group
        # You will probably need to add more control parameters if you use multiple engines. You may also need to add implicit solver states if, e.g. turbogenerator power setting depends on motor power setting

        #connect control settings to the various states in the propulsion model

        #now we have flight conditions and propulsion outputs for all flight conditions. Split into our individual analysis phases

        #==This next module calculates balanced field length, if applicable. Your optimizer or solver MUST implicitly drive the abort distance and oei takeoff distances to the same value by varying v1

        self.add_subsystem(
            'takeoff',
            BalancedFieldLengthTakeoff(
                n_int_per_seg=n_int_per_seg,
                track_fuel=True,
                track_battery=True,
                propulsion_system=TwinSeriesHybridElectricPropulsionSystem(
                    num_nodes=nn_tot_to, specific_energy=specific_energy)),
            promotes_inputs=[
                'ac|aero*', 'ac|geom|*', 'ac|propulsion|*', 'ac|weights|*',
                'takeoff|h'
            ])

        self.connect(
            'controls.prop|rpm|takeoff',
            ['takeoff.propmodel.prop1.rpm', 'takeoff.propmodel.prop2.rpm'])
        self.connect('controls.motor1|throttle|takeoff',
                     'takeoff.propmodel.motor1.throttle')
        self.connect('controls.motor2|throttle|takeoff',
                     'takeoff.propmodel.motor2.throttle')
        self.connect('hybrid_TO.vec',
                     'takeoff.propmodel.hybrid_split.power_split_fraction')
        self.connect('controls.eng1|throttle|takeoff',
                     'takeoff.propmodel.eng1.throttle')

        #==This module computes fuel consumption during the entire mission
        mission_promote_inputs = [
            "ac|aero|*", "ac|geom|*", 'ac|propulsion|*', 'ac|weights|*', 'OEW',
            '*|Ueas', '*|h0', '*|hf', '*|time', 'design_range', 'payload'
        ]
        self.add_subsystem(
            'design_mission',
            MissionAnalysis(
                n_int_per_seg=n_int_per_seg,
                track_battery=True,
                propulsion_system=TwinSeriesHybridElectricPropulsionSystem(
                    num_nodes=nn_tot_m, specific_energy=specific_energy)),
            promotes_inputs=mission_promote_inputs)
        self.connect('design_mission.throttle', [
            'design_mission.propmodel.motor1.throttle',
            'design_mission.propmodel.motor2.throttle'
        ])
        self.connect('takeoff.weight_after_takeoff',
                     'design_mission.weight_initial')
        self.connect(
            'hybrid_combiner.hybrid_split|mission',
            'design_mission.propmodel.hybrid_split.power_split_fraction')
        self.connect('controls.prop|rpm|mission', [
            'design_mission.propmodel.prop1.rpm',
            'design_mission.propmodel.prop2.rpm'
        ])

        #==This module is an empirical weight tool specific to a single-engine turboprop airplane. You will need to modify or replace it.
        self.add_subsystem('OEW',
                           TwinSeriesHybridEmptyWeight(),
                           promotes_inputs=["*"],
                           promotes_outputs=['OEW'])
        self.connect('ac|propulsion|engine|rating', 'P_TO')
        self.connect('design_mission.propmodel.propellers_weight',
                     'W_propeller')
        self.connect('design_mission.propmodel.eng1.component_weight',
                     'W_engine')
        self.connect('design_mission.propmodel.gen1.component_weight',
                     'W_generator')
        self.connect('design_mission.propmodel.motors_weight', 'W_motors')

        #==Finally, we need to compute certain quantities to ensure the airplane is feasible. Compute whether enough fuel volume exists, and whether the airplane burned more fuel than it can carry
        self.connect('takeoff.total_fuel',
                     'design_mission.residuals.takeoff|total_fuel')
        self.connect('takeoff.total_battery_energy',
                     'design_mission.residuals.takeoff|total_battery_energy')
        self.connect('design_mission.propmodel.batt1.max_energy',
                     'design_mission.residuals.battery_max_energy')

        #==Calculate the difference between the one-engine-out abort distance and one-engine-out takeoff distance with obstacle clearance
        self.add_subsystem('implicit_solve',
                           SolveImplicitStates(n_int_per_seg=n_int_per_seg))
        self.connect('design_mission.propmodel.eng_gen_resid.eng_gen_residual',
                     'implicit_solve.eng_gen_residual')
        self.connect('implicit_solve.eng_throttle',
                     'design_mission.propmodel.eng1.throttle')

        components_list = ['eng1', 'motor1', 'motor2', 'gen1']
        opcost = self.add_subsystem(
            'operating_cost',
            OperatingCost(n_components=len(components_list), n_batteries=1))
        self.connect('design_mission.propmodel.batt1.component_cost',
                     'operating_cost.battery_1_NR_cost')
        self.connect('design_mission.battery_energy_used',
                     'operating_cost.battery_1_energy_used')

        self.connect('OEW', 'operating_cost.OEW')
        self.connect('design_mission.fuel_burn', 'operating_cost.fuel_burn')
        for i, component in enumerate(components_list):
            self.connect(
                'design_mission.propmodel.' + component + '.component_weight',
                'operating_cost.component_' + str(i + 1) + '_weight')
            self.connect(
                'design_mission.propmodel.' + component + '.component_cost',
                'operating_cost.component_' + str(i + 1) + '_NR_cost')

        dummy_range = self.add_subsystem(
            'dummypayload',
            DummyPayload(),
            promotes_outputs=['payload_objective'])
        self.connect('payload', 'dummypayload.payload_DV')
        dummy_obj = self.add_subsystem('dummyobj',
                                       AugmentedFBObjective(),
                                       promotes_inputs=['ac|weights|MTOW'],
                                       promotes_outputs=['mixed_objective'])
        self.connect('design_mission.fuel_burn', 'dummyobj.fuel_burn')