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')
Exemple #2
0
    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'
        ])
Exemple #4
0
    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')
Exemple #7
0
    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')