Ejemplo n.º 1
0
    def setUp(self):
        self.prob = Problem()

        des_vars = self.prob.model.add_subsystem('des_vars',
                                                 IndepVarComp(),
                                                 promotes=['*'])
        des_vars.add_output('Wp', 322.60579101811692, units='lbm/s')
        des_vars.add_output('Np', 172.11870165984794, units='rpm')
        des_vars.add_output('alphaMap', 1.0)
        des_vars.add_output('s_Np', 1.721074624)
        des_vars.add_output('s_PR', 0.147473296)
        des_vars.add_output('s_Wp', 2.152309293)
        des_vars.add_output('s_eff', 0.9950409659)
        self.prob.model.add_subsystem('map',
                                      TurbineMap(map_data=LPT2269,
                                                 design=False),
                                      promotes=['*'])

        self.prob.setup(check=False)
Ejemplo n.º 2
0
    def setUp(self):
        print('\n')
        self.prob = Problem()

        self.prob.model.add_subsystem('map',
                                      TurbineMap(map_data=LPT2269,
                                                 design=True),
                                      promotes=['*'])

        self.prob.model.set_input_defaults('PR', 5.0)
        self.prob.model.set_input_defaults('alphaMap', 1.0)
        self.prob.model.set_input_defaults('Wp',
                                           322.60579101811692,
                                           units='lbm/s')
        self.prob.model.set_input_defaults('Np',
                                           172.11870165984794,
                                           units='rpm')

        self.prob.setup(check=False)
Ejemplo n.º 3
0
    def setUp(self):
        self.prob = Problem()

        self.prob.model.add_subsystem('map',
                                      TurbineMap(map_data=LPT2269,
                                                 design=False),
                                      promotes=['*'])

        self.prob.model.set_input_defaults('s_Wp', 2.152309293)
        self.prob.model.set_input_defaults('s_eff', 0.9950409659)
        self.prob.model.set_input_defaults('s_Np', 1.721074624)
        self.prob.model.set_input_defaults('s_PR', 0.147473296)
        self.prob.model.set_input_defaults('Wp',
                                           322.60579101811692,
                                           units='lbm/s')
        self.prob.model.set_input_defaults('Np',
                                           172.11870165984794,
                                           units='rpm')
        self.prob.model.set_input_defaults('alphaMap', 1.0)

        self.prob.setup(check=False)
Ejemplo n.º 4
0
    def setup(self):

        thermo_data = self.options['thermo_data']
        elements = self.options['elements']
        bleed_elements = self.options['bleed_elements']
        map_data = self.options['map_data']
        designFlag = self.options['design']
        bleeds = self.options['bleed_names']
        statics = self.options['statics']
        interp_method = self.options['map_interp_method']
        map_extrap = self.options['map_extrap']

        gas_thermo = species_data.Thermo(thermo_data, init_reacts=elements)
        self.gas_prods = gas_thermo.products
        self.num_prod = len(self.gas_prods)

        bld_thermo = species_data.Thermo(thermo_data,
                                         init_reacts=bleed_elements)
        self.bld_prods = bld_thermo.products
        self.num_bld_prod = len(self.bld_prods)

        # Create inlet flow station
        in_flow = FlowIn(fl_name='Fl_I', num_prods=self.num_prod)
        self.add_subsystem('in_flow', in_flow, promotes_inputs=['Fl_I:*'])

        self.add_subsystem('corrinputs',
                           CorrectedInputsCalc(),
                           promotes_inputs=[
                               'Nmech', ('W_in', 'Fl_I:stat:W'),
                               ('Pt', 'Fl_I:tot:P'), ('Tt', 'Fl_I:tot:T')
                           ],
                           promotes_outputs=['Np', 'Wp'])

        turb_map = TurbineMap(map_data=map_data,
                              design=designFlag,
                              interp_method=interp_method,
                              extrap=map_extrap)
        if designFlag:
            self.add_subsystem(
                'map',
                turb_map,
                promotes_inputs=['Np', 'Wp', 'PR', 'eff'],
                promotes_outputs=['s_PR', 's_Wp', 's_eff', 's_Np'])
        else:
            self.add_subsystem(
                'map',
                turb_map,
                promotes_inputs=['Np', 'Wp', 's_PR', 's_Wp', 's_eff', 's_Np'],
                promotes_outputs=['PR', 'eff'])

        # Calculate pressure drop across turbine
        self.add_subsystem('press_drop',
                           PressureDrop(),
                           promotes_inputs=['PR', ('Pt_in', 'Fl_I:tot:P')])

        # Calculate ideal flow station properties
        self.add_subsystem('ideal_flow',
                           SetTotal(thermo_data=thermo_data,
                                    mode='S',
                                    init_reacts=elements),
                           promotes_inputs=[('S', 'Fl_I:tot:S'),
                                            ('init_prod_amounts', 'Fl_I:tot:n')
                                            ])
        self.connect("press_drop.Pt_out", "ideal_flow.P")

        # # Calculate enthalpy drop across turbine
        # self.add_subsystem("enth_drop", EnthalpyDrop(), promotes=['eff'])
        # self.connect("Fl_I:tot:h", "enth_drop.ht_in")
        # self.connect("ideal_flow.h", "enth_drop.ht_out_ideal")

        for BN in bleeds:
            bld_flow = FlowIn(fl_name=BN, num_prods=self.num_bld_prod)
            self.add_subsystem(BN,
                               bld_flow,
                               promotes_inputs=['{}:*'.format(BN)])

        # Calculate bleed parameters
        blds = Bleeds(bleed_names=bleeds, main_flow_elements=elements)
        self.add_subsystem('blds',
                           blds,
                           promotes_inputs=[('W_in', 'Fl_I:stat:W'),
                                            ('Pt_in', 'Fl_I:tot:P'),
                                            ('n_in', 'Fl_I:tot:n')] +
                           ['{}:frac_P'.format(BN) for BN in bleeds] +
                           [('{}:W'.format(BN), '{}:stat:W'.format(BN))
                            for BN in bleeds] +
                           [('{}:n'.format(BN), '{}:tot:n'.format(BN))
                            for BN in bleeds],
                           promotes_outputs=['W_out'])
        self.connect('press_drop.Pt_out', 'blds.Pt_out')

        bleed_names2 = []
        for BN in bleeds:
            # self.connect(BN+':stat:W','blds.{}:W'.format(BN))
            # self.connect(BN+':tot:n','blds.{}:n'.format(BN))
            # self.connect(BN+':stat:W','blds.%s:'%BN)

            # Determine bleed inflow properties
            bleed_names2.append(BN + '_inflow')
            self.add_subsystem(BN + '_inflow',
                               SetTotal(thermo_data=thermo_data,
                                        mode='h',
                                        init_reacts=bleed_elements),
                               promotes_inputs=[('init_prod_amounts',
                                                 BN + ":tot:n"),
                                                ('h', BN + ':tot:h')])
            self.connect('blds.' + BN + ':Pt', BN + "_inflow.P")

            # Ideally expand bleeds to exit pressure
            bleed_names2.append(BN + '_ideal')
            self.add_subsystem(BN + '_ideal',
                               SetTotal(thermo_data=thermo_data,
                                        mode='S',
                                        init_reacts=bleed_elements),
                               promotes_inputs=[('init_prod_amounts',
                                                 BN + ":tot:n")])
            self.connect(BN + "_inflow.flow:S", BN + "_ideal.S")
            self.connect("press_drop.Pt_out", BN + "_ideal.P")

        # Calculate shaft power and exit enthalpy with cooling flows production
        self.add_subsystem('pwr_turb',
                           EnthalpyAndPower(bleed_names=bleeds),
                           promotes_inputs=[
                               'Nmech', 'eff', 'W_out',
                               ('W_in', 'Fl_I:stat:W'), ('ht_in', 'Fl_I:tot:h')
                           ] + [(BN + ':W', BN + ':stat:W') for BN in bleeds] +
                           [(BN + ':ht', BN + ':tot:h') for BN in bleeds] +
                           [(BN + ':ht_ideal', BN + '_ideal.h')
                            for BN in bleeds],
                           promotes_outputs=['power', 'trq', 'ht_out_b4bld'])
        self.connect('ideal_flow.h', 'pwr_turb.ht_out_ideal')

        # Calculate real flow station properties before bleed air is added
        real_flow_b4bld = SetTotal(thermo_data=thermo_data,
                                   mode='h',
                                   init_reacts=elements,
                                   fl_name="Fl_O_b4bld:tot")
        self.add_subsystem('real_flow_b4bld',
                           real_flow_b4bld,
                           promotes_inputs=[('init_prod_amounts', 'Fl_I:tot:n')
                                            ])
        self.connect('ht_out_b4bld', 'real_flow_b4bld.h')
        self.connect('press_drop.Pt_out', 'real_flow_b4bld.P')

        # Calculate Polytropic efficiency
        self.add_subsystem('eff_poly_calc',
                           eff_poly_calc(),
                           promotes_inputs=[
                               'PR', ('S_in', 'Fl_I:tot:S'),
                               ('Rt', 'Fl_I:tot:R')
                           ],
                           promotes_outputs=['eff_poly'])
        self.connect('real_flow_b4bld.Fl_O_b4bld:tot:S', 'eff_poly_calc.S_out')

        # Calculate real flow station properties
        real_flow = SetTotal(thermo_data=thermo_data,
                             mode='h',
                             init_reacts=elements,
                             fl_name="Fl_O:tot")
        self.add_subsystem('real_flow',
                           real_flow,
                           promotes_outputs=['Fl_O:tot:*'])
        self.connect("pwr_turb.ht_out", "real_flow.h")
        self.connect("press_drop.Pt_out", "real_flow.P")
        self.connect("blds.n_out", "real_flow.init_prod_amounts")

        self.add_subsystem('FAR_passthru',
                           PassThrough('Fl_I:FAR', 'Fl_O:FAR', 0.0),
                           promotes=['*'])

        # Calculate static properties
        if statics:
            if designFlag:
                #   SetStaticMN
                out_stat = SetStatic(mode='MN',
                                     thermo_data=thermo_data,
                                     init_reacts=elements,
                                     fl_name="Fl_O:stat")
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=['MN'],
                                   promotes_outputs=['Fl_O:stat:*'])
                self.connect('blds.n_out', 'out_stat.init_prod_amounts')
                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('W_out', 'out_stat.W')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')

            else:
                #   SetStaticArea
                out_stat = SetStatic(mode='area',
                                     thermo_data=thermo_data,
                                     init_reacts=elements,
                                     fl_name="Fl_O:stat")
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=['area'],
                                   promotes_outputs=['Fl_O:stat:*'])
                self.connect('blds.n_out', 'out_stat.init_prod_amounts')
                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('W_out', 'out_stat.W')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')

            self.set_order(
                ['in_flow', 'corrinputs', 'map', 'press_drop', 'ideal_flow'] +
                bleeds + ['blds'] + bleed_names2 + [
                    'pwr_turb', 'real_flow_b4bld', 'eff_poly_calc',
                    'real_flow', 'FAR_passthru', 'out_stat'
                ])

        else:
            self.add_subsystem('W_passthru',
                               PassThrough('W_out',
                                           'Fl_O:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])
            self.set_order(
                ['in_flow', 'corrinputs', 'map', 'press_drop', 'ideal_flow'] +
                bleeds + ['blds'] + bleed_names2 + [
                    'pwr_turb', 'real_flow_b4bld', 'eff_poly_calc',
                    'real_flow', 'FAR_passthru', 'W_passthru'
                ])
Ejemplo n.º 5
0
    def setup(self):

        thermo_method = self.options['thermo_method']
        thermo_data = self.options['thermo_data']
        elements = self.options['elements']
        bleed_elements = self.options['bleed_elements']
        map_data = self.options['map_data']
        designFlag = self.options['design']
        bleeds = self.options['bleed_names']
        statics = self.options['statics']
        interp_method = self.options['map_interp_method']
        map_extrap = self.options['map_extrap']

        num_element = len(elements)
        num_bld_element = len(bleed_elements)

        # Create inlet flow station
        in_flow = FlowIn(fl_name='Fl_I')
        self.add_subsystem('in_flow', in_flow, promotes_inputs=['Fl_I:*'])

        self.add_subsystem('corrinputs',
                           CorrectedInputsCalc(),
                           promotes_inputs=[
                               'Nmech', ('W_in', 'Fl_I:stat:W'),
                               ('Pt', 'Fl_I:tot:P'), ('Tt', 'Fl_I:tot:T')
                           ],
                           promotes_outputs=['Np', 'Wp'])

        turb_map = TurbineMap(map_data=map_data,
                              design=designFlag,
                              interp_method=interp_method,
                              extrap=map_extrap)
        if designFlag:
            self.add_subsystem(
                'map',
                turb_map,
                promotes_inputs=['Np', 'Wp', 'PR', 'eff'],
                promotes_outputs=['s_PR', 's_Wp', 's_eff', 's_Np'])
        else:
            self.add_subsystem(
                'map',
                turb_map,
                promotes_inputs=['Np', 'Wp', 's_PR', 's_Wp', 's_eff', 's_Np'],
                promotes_outputs=['PR', 'eff'])

        # Calculate pressure drop across turbine
        self.add_subsystem('press_drop',
                           PressureDrop(),
                           promotes_inputs=['PR', ('Pt_in', 'Fl_I:tot:P')])

        # Calculate ideal flow station properties
        ideal_flow = Thermo(mode='total_SP',
                            method=thermo_method,
                            thermo_kwargs={
                                'elements': elements,
                                'spec': thermo_data
                            })
        self.add_subsystem('ideal_flow',
                           ideal_flow,
                           promotes_inputs=[('S', 'Fl_I:tot:S'),
                                            ('composition',
                                             'Fl_I:tot:composition')])
        self.connect("press_drop.Pt_out", "ideal_flow.P")

        # # Calculate enthalpy drop across turbine
        # self.add_subsystem("enth_drop", EnthalpyDrop(), promotes=['eff'])
        # self.connect("Fl_I:tot:h", "enth_drop.ht_in")
        # self.connect("ideal_flow.h", "enth_drop.ht_out_ideal")

        for BN in bleeds:
            bld_flow = FlowIn(fl_name=BN)
            self.add_subsystem(BN, bld_flow, promotes_inputs=[f'{BN}:*'])

        # # Calculate bleed parameters
        blds = BleedPressure(bleed_names=bleeds)
        self.add_subsystem('blds',
                           blds,
                           promotes_inputs=[
                               ('Pt_in', 'Fl_I:tot:P'),
                           ] + [f'{BN}:frac_P' for BN in bleeds])
        self.connect('press_drop.Pt_out', 'blds.Pt_out')

        bleed_element_list = [bleed_elements for name in bleeds]
        bld_mix = ThermoAdd(mix_thermo_data=thermo_data,
                            inflow_elements=elements,
                            mix_elements=bleed_element_list,
                            mix_names=bleeds,
                            mix_mode='flow')
        self.add_subsystem(
            'bld_mix',
            bld_mix,
            promotes_inputs=['Fl_I:stat:W', 'Fl_I:tot:composition'] +
            [(f'{BN}:W', f'{BN}:stat:W') for BN in bleeds] +
            [(f'{BN}:composition', f'{BN}:tot:composition') for BN in bleeds],
            promotes_outputs=[('Wout', 'W_out')])

        bleed_names2 = []
        for BN in bleeds:
            # Determine bleed inflow properties
            bleed_names2.append(BN + '_inflow')
            inflow = Thermo(mode='total_hP',
                            method=thermo_method,
                            thermo_kwargs={
                                'elements': bleed_elements,
                                'spec': thermo_data
                            })
            self.add_subsystem(BN + '_inflow',
                               inflow,
                               promotes_inputs=[('composition',
                                                 BN + ":tot:composition"),
                                                ('h', BN + ':tot:h')])
            self.connect(f'blds.{BN}:Pt', f'{BN}_inflow.P')

            # Ideally expand bleeds to exit pressure
            bleed_names2.append(f'{BN}_ideal')
            ideal = Thermo(mode='total_SP',
                           method=thermo_method,
                           thermo_kwargs={
                               'elements': bleed_elements,
                               'spec': thermo_data
                           })
            self.add_subsystem(f'{BN}_ideal',
                               ideal,
                               promotes_inputs=[('composition',
                                                 BN + ":tot:composition")])
            self.connect(f"{BN}_inflow.flow:S", f"{BN}_ideal.S")
            self.connect("press_drop.Pt_out", f"{BN}_ideal.P")

        # Calculate shaft power and exit enthalpy with cooling flows production
        self.add_subsystem('pwr_turb',
                           EnthalpyAndPower(bleed_names=bleeds),
                           promotes_inputs=[
                               'Nmech', 'eff', 'W_out',
                               ('W_in', 'Fl_I:stat:W'), ('ht_in', 'Fl_I:tot:h')
                           ] + [(BN + ':W', BN + ':stat:W') for BN in bleeds] +
                           [(BN + ':ht', BN + ':tot:h') for BN in bleeds] +
                           [(BN + ':ht_ideal', BN + '_ideal.h')
                            for BN in bleeds],
                           promotes_outputs=['power', 'trq', 'ht_out_b4bld'])
        self.connect('ideal_flow.h', 'pwr_turb.ht_out_ideal')

        # Calculate real flow station properties before bleed air is added
        real_flow_b4bld = Thermo(mode='total_hP',
                                 fl_name="Fl_O_b4bld:tot",
                                 method=thermo_method,
                                 thermo_kwargs={
                                     'elements': elements,
                                     'spec': thermo_data
                                 })
        self.add_subsystem('real_flow_b4bld',
                           real_flow_b4bld,
                           promotes_inputs=[('composition',
                                             'Fl_I:tot:composition')])
        self.connect('ht_out_b4bld', 'real_flow_b4bld.h')
        self.connect('press_drop.Pt_out', 'real_flow_b4bld.P')

        # Calculate Polytropic efficiency
        self.add_subsystem('eff_poly_calc',
                           eff_poly_calc(),
                           promotes_inputs=[
                               'PR', ('S_in', 'Fl_I:tot:S'),
                               ('Rt', 'Fl_I:tot:R')
                           ],
                           promotes_outputs=['eff_poly'])
        self.connect('real_flow_b4bld.Fl_O_b4bld:tot:S', 'eff_poly_calc.S_out')

        # Calculate real flow station properties
        real_flow = Thermo(mode='total_hP',
                           fl_name="Fl_O:tot",
                           method=thermo_method,
                           thermo_kwargs={
                               'elements': elements,
                               'spec': thermo_data
                           })
        self.add_subsystem('real_flow',
                           real_flow,
                           promotes_outputs=['Fl_O:tot:*'])
        self.connect("pwr_turb.ht_out", "real_flow.h")
        self.connect("press_drop.Pt_out", "real_flow.P")
        self.connect("bld_mix.composition_out", "real_flow.composition")

        # Calculate static properties
        if statics:
            if designFlag:
                #   SetStaticMN
                out_stat = Thermo(mode='static_MN',
                                  fl_name="Fl_O:stat",
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'elements': elements,
                                      'spec': thermo_data
                                  })
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=['MN'],
                                   promotes_outputs=['Fl_O:stat:*'])
                self.connect('bld_mix.composition_out', 'out_stat.composition')
                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('W_out', 'out_stat.W')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')

            else:
                #   SetStaticArea
                out_stat = Thermo(mode='static_A',
                                  fl_name="Fl_O:stat",
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'elements': elements,
                                      'spec': thermo_data
                                  })
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=['area'],
                                   promotes_outputs=['Fl_O:stat:*'])
                self.connect('bld_mix.composition_out', 'out_stat.composition')
                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('W_out', 'out_stat.W')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')

            self.set_order(
                ['in_flow', 'corrinputs', 'map', 'press_drop', 'ideal_flow'] +
                bleeds + ['bld_mix', 'blds'] + bleed_names2 + [
                    'pwr_turb', 'real_flow_b4bld', 'eff_poly_calc',
                    'real_flow', 'out_stat'
                ])

        else:
            self.add_subsystem('W_passthru',
                               PassThrough('W_out',
                                           'Fl_O:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])
            self.set_order(
                ['in_flow', 'corrinputs', 'map', 'press_drop', 'ideal_flow'] +
                bleeds + ['bld_mix', 'blds'] + bleed_names2 + [
                    'pwr_turb', 'real_flow_b4bld', 'eff_poly_calc',
                    'real_flow', 'W_passthru'
                ])

        self.set_input_defaults('eff', val=0.99, units=None)