Esempio n. 1
0
    def setup(self):

        thermo_data = self.options['thermo_data']
        n_stages = self.options['n_stages']
        n_rows = 2 * n_stages

        if self.options['owns_x_factor']:
            indeps = self.add_subsystem('indeps', om.IndepVarComp(), promotes=['*'])
            indeps.add_output('x_factor', val=1.0)

        primary_thermo = species_data.Thermo(thermo_data, init_reacts=self.options['primary_elements'])

        in_flow = FlowIn(fl_name='Fl_turb_I', num_prods=primary_thermo.num_prod, num_elements=primary_thermo.num_element)
        self.add_subsystem('turb_in_flow', in_flow, promotes_inputs=['Fl_turb_I:tot:*', 'Fl_turb_I:stat:*'])

        in_flow = FlowIn(fl_name='Fl_turb_O', num_prods=primary_thermo.num_prod, num_elements=primary_thermo.num_element)
        self.add_subsystem('turb_out_flow', in_flow, promotes_inputs=['Fl_turb_O:tot:*', 'Fl_turb_O:stat:*'])

        cool_thermo = species_data.Thermo(thermo_data, init_reacts=self.options['cool_elements'])
        in_flow = FlowIn(fl_name='Fl_cool', num_prods=cool_thermo.num_prod, num_elements=cool_thermo.num_element)
        self.add_subsystem('cool_in_flow', in_flow, promotes_inputs=['Fl_cool:tot:*', 'Fl_cool:stat:*'])


        # these are the inputs to the component
        p_inputs_all = ['x_factor', ('Pt_in', 'Fl_turb_I:tot:P'), ('Pt_out', 'Fl_turb_O:tot:P'),
                        ('Tt_cool','Fl_cool:tot:T'), ('ht_cool','Fl_cool:tot:h'), ('n_cool','Fl_cool:tot:n'), 'turb_pwr']

        p_row_inputs = [('W_primary',  'Fl_turb_I:stat:W'),
                        ('Tt_primary', 'Fl_turb_I:tot:T'),
                        ('ht_primary', 'Fl_turb_I:tot:h'),
                        ('n_primary',  'Fl_turb_I:tot:n')]
        self.add_subsystem('row_0', Row(n_stages=n_stages, i_row=0,
                                        T_safety=self.options['T_safety'], T_metal=self.options['T_metal'],
                                        thermo_data=thermo_data),
                           promotes_inputs=p_inputs_all+p_row_inputs)

        for i in range(1,n_rows):

            prev_row = 'row_{}'.format(i-1)
            curr_row = 'row_{}'.format(i)
            self.add_subsystem('row_{}'.format(i),
                               Row(n_stages=n_stages, i_row=i,
                                   T_safety=self.options['T_safety'], T_metal=self.options['T_metal'],
                                   thermo_data=thermo_data),
                               promotes_inputs=p_inputs_all)

            self.connect('{}.W_out'.format(prev_row), '{}.W_primary'.format(curr_row))
            self.connect('{}.Fl_O:tot:T'.format(prev_row), '{}.Tt_primary'.format(curr_row))
            self.connect('{}.Fl_O:tot:h'.format(prev_row), '{}.ht_primary'.format(curr_row))
            self.connect('{}.Fl_O:tot:n'.format(prev_row), '{}.n_primary'.format(curr_row))
Esempio n. 2
0
    def setup(self):
        thermo_data = self.options['thermo_data']
        elements = self.options['elements']
        statics = self.options['statics']
        design = self.options['design']
        bleeds = self.options['bleed_names']

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

        # Create inlet flowstation
        flow_in = FlowIn(fl_name='Fl_I', num_prods=num_prod)
        self.add_subsystem('flow_in',
                           flow_in,
                           promotes=['Fl_I:tot:*', 'Fl_I:stat:*'])

        # Bleed flow calculations
        blds = BleedCalcs(bleed_names=bleeds)
        bld_port_globs = ['{}:*'.format(bn) for bn in bleeds]
        self.add_subsystem('bld_calcs',
                           blds,
                           promotes_inputs=[('W_in', 'Fl_I:stat:W'),
                                            '*:frac_W'],
                           promotes_outputs=['W_out'] + bld_port_globs)

        bleed_names = []
        for BN in bleeds:

            bleed_names.append(BN + '_flow')
            bleed_flow = SetTotal(thermo_data=thermo_data,
                                  mode='T',
                                  init_reacts=elements,
                                  fl_name=BN + ":tot")
            self.add_subsystem(BN + '_flow',
                               bleed_flow,
                               promotes_inputs=[('init_prod_amounts',
                                                 'Fl_I:tot:n'),
                                                ('T', 'Fl_I:tot:T'),
                                                ('P', 'Fl_I:tot:P')],
                               promotes_outputs=['{}:tot:*'.format(BN)])

        # Total Calc
        real_flow = SetTotal(thermo_data=thermo_data,
                             mode='T',
                             init_reacts=elements,
                             fl_name="Fl_O:tot")
        prom_in = [('init_prod_amounts', 'Fl_I:tot:n'), ('T', 'Fl_I:tot:T'),
                   ('P', 'Fl_I:tot:P')]
        self.add_subsystem('real_flow',
                           real_flow,
                           promotes_inputs=prom_in,
                           promotes_outputs=['Fl_O:*'])

        if statics:
            if design:
                #   Calculate static properties
                out_stat = SetStatic(mode="MN",
                                     thermo_data=thermo_data,
                                     init_reacts=elements,
                                     fl_name="Fl_O:stat")
                prom_in = [('init_prod_amounts', 'Fl_I:tot:n'), 'MN']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)

                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')
                self.connect('W_out', 'out_stat.W')

            else:
                # Calculate static properties
                out_stat = SetStatic(mode="area",
                                     thermo_data=thermo_data,
                                     init_reacts=elements,
                                     fl_name="Fl_O:stat")
                prom_in = [('init_prod_amounts', 'Fl_I:tot:n'), 'area']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)

                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')
                self.connect('W_out', 'out_stat.W')
        else:
            self.add_subsystem('W_passthru',
                               PassThrough('W_out',
                                           'Fl_O:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])

        self.add_subsystem('FAR_passthru',
                           PassThrough('Fl_I:FAR', 'Fl_O:FAR', 0.0),
                           promotes=['*'])
Esempio n. 3
0
    def setup(self):

        thermo_method = self.options['thermo_method']
        design = self.options['design']
        thermo_data = self.options['thermo_data']

        flow1_elements = self.options['Fl_I1_elements']
        in_flow = FlowIn(fl_name='Fl_I1')
        self.add_subsystem('in_flow1', in_flow, promotes=['Fl_I1:*'])

        flow2_elements = self.options['Fl_I2_elements']
        in_flow = FlowIn(fl_name='Fl_I2')
        self.add_subsystem('in_flow2', in_flow, promotes=['Fl_I2:*'])

        if design:
            # internal flow station to compute the area that is needed to match the static pressures
            if self.options['designed_stream'] == 1:
                Fl1_stat = Thermo(mode='static_Ps',
                                  fl_name="Fl_I1_calc:stat",
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'elements': flow1_elements,
                                      'spec': thermo_data
                                  })
                self.add_subsystem('Fl_I1_stat_calc',
                                   Fl1_stat,
                                   promotes_inputs=[('composition',
                                                     'Fl_I1:tot:composition'),
                                                    ('S', 'Fl_I1:tot:S'),
                                                    ('ht', 'Fl_I1:tot:h'),
                                                    ('W', 'Fl_I1:stat:W'),
                                                    ('Ps', 'Fl_I2:stat:P')],
                                   promotes_outputs=['Fl_I1_calc:stat*'])

                self.add_subsystem('area_calc',
                                   AreaSum(),
                                   promotes_inputs=['Fl_I2:stat:area'],
                                   promotes_outputs=[('area_sum', 'area')])
                self.connect('Fl_I1_calc:stat:area',
                             'area_calc.Fl_I1:stat:area')

            else:
                Fl2_stat = Thermo(mode='static_Ps',
                                  fl_name="Fl_I2_calc:stat",
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'elements': flow2_elements,
                                      'spec': thermo_data
                                  })
                self.add_subsystem('Fl_I2_stat_calc',
                                   Fl2_stat,
                                   promotes_inputs=[('composition',
                                                     'Fl_I2:tot:composition'),
                                                    ('S', 'Fl_I2:tot:S'),
                                                    ('ht', 'Fl_I2:tot:h'),
                                                    ('W', 'Fl_I2:stat:W'),
                                                    ('Ps', 'Fl_I1:stat:P')],
                                   promotes_outputs=['Fl_I2_calc:stat:*'])

                self.add_subsystem('area_calc',
                                   AreaSum(),
                                   promotes_inputs=['Fl_I1:stat:area'],
                                   promotes_outputs=[('area_sum', 'area')])
                self.connect('Fl_I2_calc:stat:area',
                             'area_calc.Fl_I2:stat:area')

        else:
            if self.options['designed_stream'] == 1:
                Fl1_stat = Thermo(mode='static_A',
                                  fl_name="Fl_I1_calc:stat",
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'elements': flow1_elements,
                                      'spec': thermo_data
                                  })
                self.add_subsystem('Fl_I1_stat_calc',
                                   Fl1_stat,
                                   promotes_inputs=[
                                       ('composition',
                                        'Fl_I1:tot:composition'),
                                       ('S', 'Fl_I1:tot:S'),
                                       ('ht', 'Fl_I1:tot:h'),
                                       ('W', 'Fl_I1:stat:W'),
                                       ('guess:Pt', 'Fl_I1:tot:P'),
                                       ('guess:gamt', 'Fl_I1:tot:gamma')
                                   ],
                                   promotes_outputs=['Fl_I1_calc:stat*'])

            else:
                Fl2_stat = Thermo(mode='static_A',
                                  fl_name="Fl_I2_calc:stat",
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'elements': flow2_elements,
                                      'spec': thermo_data
                                  })
                self.add_subsystem('Fl_I2_stat_calc',
                                   Fl2_stat,
                                   promotes_inputs=[
                                       ('composition',
                                        'Fl_I2:tot:composition'),
                                       ('S', 'Fl_I2:tot:S'),
                                       ('ht', 'Fl_I2:tot:h'),
                                       ('W', 'Fl_I2:stat:W'),
                                       ('guess:Pt', 'Fl_I2:tot:P'),
                                       ('guess:gamt', 'Fl_I2:tot:gamma')
                                   ],
                                   promotes_outputs=['Fl_I2_calc:stat*'])

        self.add_subsystem('extraction_ratio',
                           om.ExecComp('ER=Pt1/Pt2',
                                       Pt1={'units': 'Pa'},
                                       Pt2={'units': 'Pa'}),
                           promotes_inputs=[('Pt1', 'Fl_I1:tot:P'),
                                            ('Pt2', 'Fl_I2:tot:P')],
                           promotes_outputs=['ER'])

        self.add_subsystem('mix_flow',
                           ThermoAdd(mix_thermo_data=thermo_data,
                                     mix_mode='flow',
                                     mix_names='mix',
                                     inflow_elements=flow1_elements,
                                     mix_elements=flow2_elements),
                           promotes_inputs=[('Fl_I:stat:W', 'Fl_I1:stat:W'),
                                            ('Fl_I:tot:composition',
                                             'Fl_I1:tot:composition'),
                                            ('Fl_I:tot:h', 'Fl_I1:tot:h'),
                                            ('mix:W', 'Fl_I2:stat:W'),
                                            ('mix:composition',
                                             'Fl_I2:tot:composition'),
                                            ('mix:h', 'Fl_I2:tot:h')])

        if self.options['designed_stream'] == 1:
            self.add_subsystem('impulse_mix',
                               MixImpulse(),
                               promotes_inputs=[
                                   ('Fl_I1:stat:W', 'Fl_I1_calc:stat:W'),
                                   ('Fl_I1:stat:P', 'Fl_I1_calc:stat:P'),
                                   ('Fl_I1:stat:V', 'Fl_I1_calc:stat:V'),
                                   ('Fl_I1:stat:area', 'Fl_I1_calc:stat:area'),
                                   'Fl_I2:stat:W', 'Fl_I2:stat:P',
                                   'Fl_I2:stat:V', 'Fl_I2:stat:area'
                               ])
        else:
            self.add_subsystem('impulse_mix',
                               MixImpulse(),
                               promotes_inputs=[
                                   'Fl_I1:stat:W', 'Fl_I1:stat:P',
                                   'Fl_I1:stat:V', 'Fl_I1:stat:area',
                                   ('Fl_I2:stat:W', 'Fl_I2_calc:stat:W'),
                                   ('Fl_I2:stat:P', 'Fl_I2_calc:stat:P'),
                                   ('Fl_I2:stat:V', 'Fl_I2_calc:stat:V'),
                                   ('Fl_I2:stat:area', 'Fl_I2_calc:stat:area')
                               ])

        # group to converge for the impulse balance
        conv = self.add_subsystem('impulse_converge',
                                  om.Group(),
                                  promotes=['*'])

        if self.options['internal_solver']:
            newton = conv.nonlinear_solver = om.NewtonSolver()
            newton.options['maxiter'] = 30
            newton.options['atol'] = 1e-2
            newton.options['solve_subsystems'] = True
            newton.options['max_sub_solves'] = 20
            newton.options['reraise_child_analysiserror'] = False
            newton.linesearch = om.BoundsEnforceLS()
            newton.linesearch.options['bound_enforcement'] = 'scalar'
            newton.linesearch.options['iprint'] = -1
            conv.linear_solver = om.DirectSolver(assemble_jac=True)

        out_tot = Thermo(mode='total_hP',
                         fl_name='Fl_O:tot',
                         method=thermo_method,
                         thermo_kwargs={
                             'elements': self.options['Fl_I1_elements'],
                             'spec': thermo_data
                         })
        conv.add_subsystem('out_tot', out_tot, promotes_outputs=['Fl_O:tot:*'])
        self.connect('mix_flow.composition_out', 'out_tot.composition')
        self.connect('mix_flow.mass_avg_h', 'out_tot.h')
        # note: gets Pt from the balance comp

        out_stat = Thermo(mode='static_A',
                          fl_name='Fl_O:stat',
                          method=thermo_method,
                          thermo_kwargs={
                              'elements': self.options['Fl_I1_elements'],
                              'spec': thermo_data
                          })
        conv.add_subsystem('out_stat',
                           out_stat,
                           promotes_outputs=['Fl_O:stat:*'],
                           promotes_inputs=[
                               'area',
                           ])
        self.connect('mix_flow.composition_out', 'out_stat.composition')
        self.connect('mix_flow.Wout', 'out_stat.W')
        conv.connect('Fl_O:tot:S', 'out_stat.S')
        self.connect('mix_flow.mass_avg_h', 'out_stat.ht')
        conv.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
        conv.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')

        conv.add_subsystem('imp_out', Impulse())
        conv.connect('Fl_O:stat:P', 'imp_out.P')
        conv.connect('Fl_O:stat:area', 'imp_out.area')
        conv.connect('Fl_O:stat:V', 'imp_out.V')
        conv.connect('Fl_O:stat:W', 'imp_out.W')

        balance = conv.add_subsystem('balance', om.BalanceComp())
        balance.add_balance('P_tot',
                            val=100,
                            units='psi',
                            eq_units='N',
                            lower=1e-3,
                            upper=10000)
        conv.connect('balance.P_tot', 'out_tot.P')
        conv.connect('imp_out.impulse', 'balance.lhs:P_tot')
        self.connect(
            'impulse_mix.impulse_mix', 'balance.rhs:P_tot'
        )  #note that this connection comes from outside the convergence group
Esempio n. 4
0
    def setup(self):

        map_data = self.options['map_data']
        interp_method = self.options['map_interp_method']
        map_extrap = self.options['map_extrap']
        # self.linear_solver = ScipyGMRES()
        # self.linear_solver.options['atol'] = 2e-8
        # self.linear_solver.options['maxiter'] = 100
        # self.linear_solver.options['restart'] = 100

        # self.nonlinear_solver = Newton()
        # self.nonlinear_solver.options['utol'] = 1e-9

        thermo_method = self.options['thermo_method']
        design = self.options['design']
        bleeds = self.options['bleed_names']
        thermo_data = self.options['thermo_data']
        statics = self.options['statics']

        composition = self.Fl_I_data['Fl_I']

        # Create inlet flow station
        flow_in = FlowIn(fl_name='Fl_I')
        self.add_subsystem('flow_in', flow_in, 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=('Nc', 'Wc'))

        map_calcs = CompressorMap(map_data=self.options['map_data'],
                                  design=design,
                                  interp_method=interp_method,
                                  extrap=map_extrap)
        self.add_subsystem('map',
                           map_calcs,
                           promotes=[
                               's_Nc', 's_eff', 's_Wc', 's_PR', 'Nc', 'Wc',
                               'PR', 'eff', 'SMN', 'SMW'
                           ])

        # Calculate pressure rise across compressor
        self.add_subsystem('press_rise',
                           PressureRise(),
                           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={
                                'composition': composition,
                                '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_rise.Pt_out", "ideal_flow.P")

        # Calculate enthalpy rise across compressor
        self.add_subsystem("enth_rise",
                           EnthalpyRise(),
                           promotes_inputs=['eff', ('inlet_ht', 'Fl_I:tot:h')])
        self.connect("ideal_flow.h", "enth_rise.ideal_ht")

        # Calculate real flow station properties
        real_flow = Thermo(mode='total_hP',
                           fl_name='Fl_O:tot',
                           method=thermo_method,
                           thermo_kwargs={
                               'composition': composition,
                               'spec': thermo_data
                           })
        self.add_subsystem('real_flow',
                           real_flow,
                           promotes_inputs=[('composition',
                                             'Fl_I:tot:composition')],
                           promotes_outputs=['Fl_O:tot:*'])
        self.connect("enth_rise.ht_out", "real_flow.h")
        self.connect("press_rise.Pt_out", "real_flow.P")
        #clculate Polytropic Efficiency
        self.add_subsystem(
            'eff_poly_calc',
            eff_poly_calc(),
            promotes_inputs=[
                ('PR', 'PR'),
                ('S_in', 'Fl_I:tot:S'),
                ('S_out', 'Fl_O:tot:S'),
                # ('Cp','Fl_I:tot:Cp'),
                # ('Cv','Fl_I:tot:Cv'),
                ('Rt', 'Fl_I:tot:R')
            ],
            promotes_outputs=['eff_poly'])

        # Calculate shaft power consumption
        blds_pwr = BleedsAndPower(bleed_names=bleeds)
        bld_inputs = ['frac_W', 'frac_P', 'frac_work']
        bld_in_vars = [
            '{0}:{1}'.format(bn, in_name)
            for bn, in_name in itertools.product(bleeds, bld_inputs)
        ]
        bld_out_globs = ['{}:*'.format(bn) for bn in bleeds]

        self.add_subsystem('blds_pwr',
                           blds_pwr,
                           promotes_inputs=[
                               'Nmech',
                               ('W_in', 'Fl_I:stat:W'),
                               ('ht_in', 'Fl_I:tot:h'),
                               ('Pt_in', 'Fl_I:tot:P'),
                               ('Pt_out', 'Fl_O:tot:P'),
                           ] + bld_in_vars,
                           promotes_outputs=['power', 'trq', 'W_out'] +
                           bld_out_globs)
        self.connect('enth_rise.ht_out', 'blds_pwr.ht_out')

        bleed_names = []
        for BN in bleeds:

            bleed_names.append(f'{BN}_flow')
            bleed_flow = Thermo(mode='total_hP',
                                fl_name=BN + ":tot",
                                method=thermo_method,
                                thermo_kwargs={
                                    'composition': composition,
                                    'spec': thermo_data
                                })
            self.add_subsystem(BN + '_flow',
                               bleed_flow,
                               promotes_inputs=[('composition',
                                                 'Fl_I:tot:composition')],
                               promotes_outputs=[f'{BN}:tot:*'])
            self.connect(BN + ':ht', BN + "_flow.h")
            self.connect(BN + ':Pt', BN + "_flow.P")

        if statics:
            if design:
                #   Calculate static properties
                out_stat = Thermo(mode='static_MN',
                                  fl_name='Fl_O:stat',
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'composition': composition,
                                      'spec': thermo_data
                                  })
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=[
                                       'MN',
                                       ('composition', 'Fl_I:tot:composition')
                                   ],
                                   promotes_outputs=['Fl_O:stat:*'])
                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:  # Calculate static properties
                out_stat = Thermo(mode='static_A',
                                  fl_name='Fl_O:stat',
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'composition': composition,
                                      'spec': thermo_data
                                  })
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=[
                                       'area',
                                       ('composition', 'Fl_I:tot:composition')
                                   ],
                                   promotes_outputs=['Fl_O:stat:*'])

                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([
                'flow_in',
                'corrinputs',
                'map',
                'press_rise',
                'ideal_flow',
                'enth_rise',
                'real_flow',
                'eff_poly_calc',
                'blds_pwr',
            ] + bleed_names + ['out_stat'])

        else:
            self.add_subsystem('W_passthru',
                               PassThrough('W_out',
                                           'Fl_O:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])
            self.set_order([
                'flow_in', 'corrinputs', 'map', 'press_rise', 'ideal_flow',
                'enth_rise', 'real_flow', 'eff_poly_calc', 'blds_pwr'
            ] + bleed_names + ['W_passthru'])

        # define the group level defaults
        self.set_input_defaults('Fl_I:FAR', val=0., units=None)
        self.set_input_defaults('PR', val=2., units=None)
        self.set_input_defaults('eff', val=0.99, units=None)

        # if not design:
        #     self.set_input_defaults('area', val=1, units='inch**2')

        super().setup()
Esempio n. 5
0
    def setup(self):

        thermo_data = self.options['thermo_data']
        elements = self.options['elements']
        statics = self.options['statics']
        design = self.options['design']

        num_prod = species_data.Thermo(thermo_data,
                                       init_reacts=elements).num_prod

        # Create inlet flowstation
        flow_in = FlowIn(fl_name='Fl_I', num_prods=num_prod)
        self.add_subsystem('flow_in', flow_in, promotes_inputs=('Fl_I:*', ))

        # Split the flows
        self.add_subsystem('split_calc',
                           BPRcalc(),
                           promotes_inputs=('BPR', ('W_in', 'Fl_I:stat:W')))

        # Set Fl_out1 totals based on T, P
        real_flow1 = SetTotal(thermo_data=thermo_data,
                              mode='T',
                              init_reacts=elements,
                              fl_name="Fl_O1:tot")
        self.add_subsystem('real_flow1',
                           real_flow1,
                           promotes_inputs=(('init_prod_amounts',
                                             'Fl_I:tot:n'), ('P',
                                                             'Fl_I:tot:P'),
                                            ('T', 'Fl_I:tot:T')),
                           promotes_outputs=('Fl_O1:tot:*', ))

        # Set Fl_out2 totals based on T, P
        real_flow2 = SetTotal(thermo_data=thermo_data,
                              mode='T',
                              init_reacts=elements,
                              fl_name="Fl_O2:tot")
        self.add_subsystem('real_flow2',
                           real_flow2,
                           promotes_inputs=(('init_prod_amounts',
                                             'Fl_I:tot:n'), ('P',
                                                             'Fl_I:tot:P'),
                                            ('T', 'Fl_I:tot:T')),
                           promotes_outputs=('Fl_O2:tot:*', ))

        if statics:
            if design:
                #   Calculate static properties
                out1_stat = SetStatic(mode="MN",
                                      thermo_data=thermo_data,
                                      init_reacts=elements,
                                      fl_name="Fl_O1:stat")
                prom_in = [('init_prod_amounts', 'Fl_I:tot:n'), ('MN', 'MN1')]
                prom_out = ['Fl_O1:stat:*']
                self.add_subsystem('out1_stat',
                                   out1_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)
                self.connect('Fl_O1:tot:S', 'out1_stat.S')
                self.connect('Fl_O1:tot:h', 'out1_stat.ht')
                self.connect('Fl_O1:tot:P', 'out1_stat.guess:Pt')
                self.connect('Fl_O1:tot:gamma', 'out1_stat.guess:gamt')
                self.connect('split_calc.W1', 'out1_stat.W')

                out2_stat = SetStatic(mode="MN",
                                      thermo_data=thermo_data,
                                      init_reacts=elements,
                                      fl_name="Fl_O2:stat")
                prom_in = [('init_prod_amounts', 'Fl_I:tot:n'), ('MN', 'MN2')]
                prom_out = ['Fl_O2:stat:*']
                self.add_subsystem('out2_stat',
                                   out2_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)
                self.connect('Fl_O2:tot:S', 'out2_stat.S')
                self.connect('Fl_O2:tot:h', 'out2_stat.ht')
                self.connect('Fl_O2:tot:P', 'out2_stat.guess:Pt')
                self.connect('Fl_O2:tot:gamma', 'out2_stat.guess:gamt')
                self.connect('split_calc.W2', 'out2_stat.W')

            else:
                # Calculate static properties
                out1_stat = SetStatic(mode="area",
                                      thermo_data=thermo_data,
                                      init_reacts=elements,
                                      fl_name="Fl_O1:stat")
                prom_in = [('init_prod_amounts', 'Fl_I:tot:n'),
                           ('area', 'area1')]
                prom_out = ['Fl_O1:stat:*']
                self.add_subsystem('out1_stat',
                                   out1_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)
                self.connect('Fl_O1:tot:S', 'out1_stat.S')
                self.connect('Fl_O1:tot:h', 'out1_stat.ht')
                self.connect('Fl_O1:tot:P', 'out1_stat.guess:Pt')
                self.connect('Fl_O1:tot:gamma', 'out1_stat.guess:gamt')
                self.connect('split_calc.W1', 'out1_stat.W')

                out2_stat = SetStatic(mode="area",
                                      thermo_data=thermo_data,
                                      init_reacts=elements,
                                      fl_name="Fl_O2:stat")
                prom_in = [('init_prod_amounts', 'Fl_I:tot:n'),
                           ('area', 'area2')]
                prom_out = ['Fl_O2:stat:*']
                self.add_subsystem('out2_stat',
                                   out2_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)
                self.connect('Fl_O2:tot:S', 'out2_stat.S')
                self.connect('Fl_O2:tot:h', 'out2_stat.ht')
                self.connect('Fl_O2:tot:P', 'out2_stat.guess:Pt')
                self.connect('Fl_O2:tot:gamma', 'out2_stat.guess:gamt')
                self.connect('split_calc.W2', 'out2_stat.W')

        else:
            self.add_subsystem('W1_passthru',
                               PassThrough('split_calc_W1',
                                           'Fl_O1:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])
            self.add_subsystem('W2_passthru',
                               PassThrough('split_calc_W2',
                                           'Fl_O2:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])
            self.connect('split_calc.W1', 'split_calc_W1')
            self.connect('split_calc.W2', 'split_calc_W2')
Esempio n. 6
0
    def setup(self):
        thermo_data = self.options['thermo_data']
        elements = self.options['elements']
        nozzType = self.options['nozzType']
        lossCoef = self.options['lossCoef']

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

        num_prod = len(self.gas_prods)

        self.add_subsystem('mach_choked', IndepVarComp(
            'MN',
            1.000,
        ))

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

        # PR_bal = self.add_subsystem('PR_bal', BalanceComp())
        # PR_bal.add_balance('PR', units=None, eq_units='lbf/inch**2', lower=1.001)
        # self.connect('PR_bal.PR', 'PR')
        # self.connect('Ps_exhaust', 'PR_bal.lhs:PR')
        # self.connect('Ps_calc', 'PR_bal.rhs:PR')

        self.add_subsystem('PR_bal',
                           PR_bal(),
                           promotes_inputs=['*'],
                           promotes_outputs=['*'])

        # Calculate pressure at the throat
        prom_in = [('Pt_in', 'Fl_I:tot:P'), 'PR', 'dPqP']
        self.add_subsystem('press_calcs',
                           PressureCalcs(),
                           promotes_inputs=prom_in,
                           promotes_outputs=['Ps_calc'])

        # Calculate throat total flow properties
        throat_total = SetTotal(thermo_data=thermo_data,
                                mode="h",
                                init_reacts=elements,
                                fl_name="Fl_O:tot")
        prom_in = [('h', 'Fl_I:tot:h'), ('init_prod_amounts', 'Fl_I:tot:n')]
        self.add_subsystem('throat_total',
                           throat_total,
                           promotes_inputs=prom_in,
                           promotes_outputs=['Fl_O:*'])
        self.connect('press_calcs.Pt_th', 'throat_total.P')

        # Calculate static properties for sonic flow
        prom_in = [('ht', 'Fl_I:tot:h'), ('W', 'Fl_I:stat:W'),
                   ('init_prod_amounts', 'Fl_I:tot:n')]
        self.add_subsystem('staticMN',
                           SetStatic(mode="MN",
                                     thermo_data=thermo_data,
                                     init_reacts=elements),
                           promotes_inputs=prom_in)
        self.connect('throat_total.S', 'staticMN.S')
        self.connect('mach_choked.MN', 'staticMN.MN')
        self.connect('press_calcs.Pt_th', 'staticMN.guess:Pt')
        self.connect('throat_total.gamma', 'staticMN.guess:gamt')
        # self.connect('Fl_I.flow:flow_products','staticMN.init_prod_amounts')

        # Calculate static properties based on exit static pressure
        prom_in = [('ht', 'Fl_I:tot:h'), ('W', 'Fl_I:stat:W'),
                   ('Ps', 'Ps_calc'), ('init_prod_amounts', 'Fl_I:tot:n')]
        self.add_subsystem('staticPs',
                           SetStatic(mode="Ps",
                                     thermo_data=thermo_data,
                                     init_reacts=elements),
                           promotes_inputs=prom_in)
        self.connect('throat_total.S', 'staticPs.S')
        # self.connect('press_calcs.Ps_calc', 'staticPs.Ps')
        # self.connect('Fl_I.flow:flow_products','staticPs.init_prod_amounts')

        # Calculate ideal exit flow properties
        prom_in = [('ht', 'Fl_I:tot:h'), ('S', 'Fl_I:tot:S'),
                   ('W', 'Fl_I:stat:W'), ('Ps', 'Ps_calc'),
                   ('init_prod_amounts', 'Fl_I:tot:n')]
        self.add_subsystem('ideal_flow',
                           SetStatic(mode="Ps",
                                     thermo_data=thermo_data,
                                     init_reacts=elements),
                           promotes_inputs=prom_in)
        # self.connect('press_calcs.Ps_calc', 'ideal_flow.Ps')
        # self.connect('Fl_I.flow:flow_products','ideal_flow.init_prod_amounts')

        # Determine throat and exit flow properties based on nozzle type and exit static pressure
        mux = Mux(nozzType=nozzType, fl_out_name='Fl_O')
        prom_in = [('Ps:W', 'Fl_I:stat:W'), ('MN:W', 'Fl_I:stat:W'),
                   ('Ps:P', 'Ps_calc'), 'Ps_calc']
        self.add_subsystem('mux',
                           mux,
                           promotes_inputs=prom_in,
                           promotes_outputs=['*:stat:*'])
        self.connect('throat_total.S', 'mux.S')
        self.connect('staticPs.h', 'mux.Ps:h')
        self.connect('staticPs.T', 'mux.Ps:T')
        self.connect('staticPs.rho', 'mux.Ps:rho')
        self.connect('staticPs.gamma', 'mux.Ps:gamma')
        self.connect('staticPs.Cp', 'mux.Ps:Cp')
        self.connect('staticPs.Cv', 'mux.Ps:Cv')
        self.connect('staticPs.V', 'mux.Ps:V')
        self.connect('staticPs.Vsonic', 'mux.Ps:Vsonic')
        self.connect('staticPs.MN', 'mux.Ps:MN')
        self.connect('staticPs.area', 'mux.Ps:area')

        self.connect('staticMN.h', 'mux.MN:h')
        self.connect('staticMN.T', 'mux.MN:T')
        self.connect('staticMN.Ps', 'mux.MN:P')
        self.connect('staticMN.rho', 'mux.MN:rho')
        self.connect('staticMN.gamma', 'mux.MN:gamma')
        self.connect('staticMN.Cp', 'mux.MN:Cp')
        self.connect('staticMN.Cv', 'mux.MN:Cv')
        self.connect('staticMN.V', 'mux.MN:V')
        self.connect('staticMN.Vsonic', 'mux.MN:Vsonic')
        self.connect('mach_choked.MN', 'mux.MN:MN')
        self.connect('staticMN.area', 'mux.MN:area')

        # Calculate nozzle performance paramters based on
        perf_calcs = PerformanceCalcs(lossCoef=lossCoef)
        if lossCoef == "Cv":
            other_inputs = ['Cv', 'Ps_calc']
        else:
            other_inputs = ['Cfg', 'Ps_calc']
        prom_in = [('W_in', 'Fl_I:stat:W')] + other_inputs
        self.add_subsystem('perf_calcs',
                           perf_calcs,
                           promotes_inputs=prom_in,
                           promotes_outputs=['Fg'])
        self.connect('ideal_flow.V', 'perf_calcs.V_ideal')
        # self.connect('ideal_flow.area', 'perf_calcs.A_ideal')

        if lossCoef == 'Cv':
            self.connect('Fl_O:stat:V', 'perf_calcs.V_actual')
            self.connect('Fl_O:stat:area', 'perf_calcs.A_actual')
            self.connect('Fl_O:stat:P', 'perf_calcs.Ps_actual')

        if self.options['internal_solver']:
            newton = self.nonlinear_solver = NewtonSolver()
            newton.options['atol'] = 1e-10
            newton.options['rtol'] = 1e-10
            newton.options['maxiter'] = 20
            newton.options['iprint'] = 2
            newton.options['solve_subsystems'] = True
            newton.linesearch = BoundsEnforceLS()
            newton.linesearch.options['bound_enforcement'] = 'scalar'

            newton.linesearch.options['iprint'] = -1
            self.linear_solver = DirectSolver(assemble_jac=True)
Esempio n. 7
0
    def setup(self):

        thermo_method = self.options['thermo_method']
        thermo_data = self.options['thermo_data']
        statics = self.options['statics']
        design = self.options['design']

        composition = self.Fl_I_data['Fl_I']

        # Create inlet flowstation
        flow_in = FlowIn(fl_name='Fl_I')
        self.add_subsystem('flow_in', flow_in, promotes_inputs=('Fl_I:*', ))

        # Split the flows
        self.add_subsystem('split_calc',
                           BPRcalc(),
                           promotes_inputs=('BPR', ('W_in', 'Fl_I:stat:W')))

        # Set Fl_out1 totals based on T, P
        real_flow1 = Thermo(mode='total_TP',
                            fl_name='Fl_O1:tot',
                            method=thermo_method,
                            thermo_kwargs={
                                'composition': composition,
                                'spec': thermo_data
                            })
        self.add_subsystem('real_flow1',
                           real_flow1,
                           promotes_inputs=(('composition',
                                             'Fl_I:tot:composition'),
                                            ('P', 'Fl_I:tot:P'),
                                            ('T', 'Fl_I:tot:T')),
                           promotes_outputs=('Fl_O1:tot:*', ))

        # Set Fl_out2 totals based on T, P
        real_flow2 = Thermo(mode='total_TP',
                            fl_name='Fl_O2:tot',
                            method=thermo_method,
                            thermo_kwargs={
                                'composition': composition,
                                'spec': thermo_data
                            })
        self.add_subsystem('real_flow2',
                           real_flow2,
                           promotes_inputs=(('composition',
                                             'Fl_I:tot:composition'),
                                            ('P', 'Fl_I:tot:P'),
                                            ('T', 'Fl_I:tot:T')),
                           promotes_outputs=('Fl_O2:tot:*', ))

        if statics:
            if design:
                #   Calculate static properties
                out1_stat = Thermo(mode='static_MN',
                                   fl_name='Fl_O1:stat',
                                   method=thermo_method,
                                   thermo_kwargs={
                                       'composition': composition,
                                       'spec': thermo_data
                                   })
                prom_in = [('composition', 'Fl_I:tot:composition'),
                           ('MN', 'MN1')]
                prom_out = ['Fl_O1:stat:*']
                self.add_subsystem('out1_stat',
                                   out1_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)
                self.connect('Fl_O1:tot:S', 'out1_stat.S')
                self.connect('Fl_O1:tot:h', 'out1_stat.ht')
                self.connect('Fl_O1:tot:P', 'out1_stat.guess:Pt')
                self.connect('Fl_O1:tot:gamma', 'out1_stat.guess:gamt')
                self.connect('split_calc.W1', 'out1_stat.W')

                out2_stat = Thermo(mode='static_MN',
                                   fl_name='Fl_O2:stat',
                                   method=thermo_method,
                                   thermo_kwargs={
                                       'composition': composition,
                                       'spec': thermo_data
                                   })
                prom_in = [('composition', 'Fl_I:tot:composition'),
                           ('MN', 'MN2')]
                prom_out = ['Fl_O2:stat:*']
                self.add_subsystem('out2_stat',
                                   out2_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)
                self.connect('Fl_O2:tot:S', 'out2_stat.S')
                self.connect('Fl_O2:tot:h', 'out2_stat.ht')
                self.connect('Fl_O2:tot:P', 'out2_stat.guess:Pt')
                self.connect('Fl_O2:tot:gamma', 'out2_stat.guess:gamt')
                self.connect('split_calc.W2', 'out2_stat.W')

            else:
                # Calculate static properties
                out1_stat = Thermo(mode='static_A',
                                   fl_name='Fl_O1:stat',
                                   method=thermo_method,
                                   thermo_kwargs={
                                       'composition': composition,
                                       'spec': thermo_data
                                   })
                prom_in = [('composition', 'Fl_I:tot:composition'),
                           ('area', 'area1')]
                prom_out = ['Fl_O1:stat:*']
                self.add_subsystem('out1_stat',
                                   out1_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)
                self.connect('Fl_O1:tot:S', 'out1_stat.S')
                self.connect('Fl_O1:tot:h', 'out1_stat.ht')
                self.connect('Fl_O1:tot:P', 'out1_stat.guess:Pt')
                self.connect('Fl_O1:tot:gamma', 'out1_stat.guess:gamt')
                self.connect('split_calc.W1', 'out1_stat.W')

                out2_stat = Thermo(mode='static_A',
                                   fl_name='Fl_O2:stat',
                                   method=thermo_method,
                                   thermo_kwargs={
                                       'composition': composition,
                                       'spec': thermo_data
                                   })
                prom_in = [('composition', 'Fl_I:tot:composition'),
                           ('area', 'area2')]
                prom_out = ['Fl_O2:stat:*']
                self.add_subsystem('out2_stat',
                                   out2_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)
                self.connect('Fl_O2:tot:S', 'out2_stat.S')
                self.connect('Fl_O2:tot:h', 'out2_stat.ht')
                self.connect('Fl_O2:tot:P', 'out2_stat.guess:Pt')
                self.connect('Fl_O2:tot:gamma', 'out2_stat.guess:gamt')
                self.connect('split_calc.W2', 'out2_stat.W')

        else:
            self.add_subsystem('W1_passthru',
                               PassThrough('split_calc_W1',
                                           'Fl_O1:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])
            self.add_subsystem('W2_passthru',
                               PassThrough('split_calc_W2',
                                           'Fl_O2:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])
            self.connect('split_calc.W1', 'split_calc_W1')
            self.connect('split_calc.W2', 'split_calc_W2')

        super().setup()
Esempio n. 8
0
    def setup(self):
        thermo_data = self.options['thermo_data']
        inflow_elements = self.options['inflow_elements']
        air_fuel_elements = self.options['air_fuel_elements']
        design = self.options['design']
        statics = self.options['statics']
        fuel_type = self.options['fuel_type']

        air_fuel_thermo = Thermo(thermo_data, init_reacts=air_fuel_elements)
        self.air_fuel_prods = air_fuel_thermo.products

        air_thermo = Thermo(thermo_data, init_reacts=inflow_elements)
        self.air_prods = air_thermo.products

        self.num_air_fuel_prod = len(self.air_fuel_prods)
        self.num_air_prod = len(self.air_prods)

        # Create combustor flow station
        in_flow = FlowIn(fl_name='Fl_I', num_prods=self.num_air_prod)
        self.add_subsystem('in_flow',
                           in_flow,
                           promotes=['Fl_I:tot:*', 'Fl_I:stat:*'])

        # Perform combustor engineering calculations
        self.add_subsystem('mix_fuel',
                           MixFuel(thermo_data=thermo_data,
                                   inflow_elements=inflow_elements,
                                   fuel_type=fuel_type),
                           promotes=[
                               'Fl_I:stat:W', 'Fl_I:FAR', 'Fl_I:tot:n',
                               'Fl_I:tot:h', 'Wfuel', 'Wout'
                           ])

        # Pressure loss
        prom_in = [('Pt_in', 'Fl_I:tot:P'), 'dPqP']
        self.add_subsystem('p_loss', PressureLoss(), promotes_inputs=prom_in)

        # Calculate vitiated flow station properties
        vit_flow = SetTotal(thermo_data=thermo_data,
                            mode='h',
                            init_reacts=air_fuel_elements,
                            fl_name="Fl_O:tot")
        self.add_subsystem('vitiated_flow',
                           vit_flow,
                           promotes_outputs=['Fl_O:*'])
        self.connect("mix_fuel.mass_avg_h", "vitiated_flow.h")
        self.connect("mix_fuel.init_prod_amounts",
                     "vitiated_flow.init_prod_amounts")
        self.connect("p_loss.Pt_out", "vitiated_flow.P")

        if statics:
            if design:
                # Calculate static properties.
                out_stat = SetStatic(mode="MN",
                                     thermo_data=thermo_data,
                                     init_reacts=air_fuel_elements,
                                     fl_name="Fl_O:stat")
                prom_in = ['MN']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)

                self.connect("mix_fuel.init_prod_amounts",
                             "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('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')
                self.connect('Wout', 'out_stat.W')

            else:
                # Calculate static properties.
                out_stat = SetStatic(mode="area",
                                     thermo_data=thermo_data,
                                     init_reacts=air_fuel_elements,
                                     fl_name="Fl_O:stat")
                prom_in = ['area']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)
                self.connect("mix_fuel.init_prod_amounts",
                             "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('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')
                self.connect('Wout', 'out_stat.W')

        else:
            self.add_subsystem('W_passthru',
                               PassThrough('Wout',
                                           'Fl_O:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])

        self.add_subsystem('FAR_pass_thru',
                           PassThrough('Fl_I:FAR', 'Fl_O:FAR', 0.0),
                           promotes=['*'])
Esempio n. 9
0
    def setup(self):

        thermo_data = self.options['thermo_data']
        n_stages = self.options['n_stages']
        n_rows = 2 * n_stages

        if self.options['owns_x_factor']:
            indeps = self.add_subsystem('indeps',
                                        om.IndepVarComp(),
                                        promotes=['*'])
            indeps.add_output('x_factor', val=1.0)

        in_flow = FlowIn(fl_name='Fl_turb_I')
        self.add_subsystem(
            'turb_in_flow',
            in_flow,
            promotes_inputs=['Fl_turb_I:tot:*', 'Fl_turb_I:stat:*'])

        in_flow = FlowIn(fl_name='Fl_turb_O')
        self.add_subsystem(
            'turb_out_flow',
            in_flow,
            promotes_inputs=['Fl_turb_O:tot:*', 'Fl_turb_O:stat:*'])

        in_flow = FlowIn(fl_name='Fl_cool')
        self.add_subsystem('cool_in_flow',
                           in_flow,
                           promotes_inputs=['Fl_cool:tot:*', 'Fl_cool:stat:*'])

        # these are the inputs to the component
        p_inputs_all = [
            'x_factor', ('Pt_in', 'Fl_turb_I:tot:P'),
            ('Pt_out', 'Fl_turb_O:tot:P'), ('Tt_cool', 'Fl_cool:tot:T'),
            ('ht_cool', 'Fl_cool:tot:h'),
            ('cool:composition', 'Fl_cool:tot:composition'), 'turb_pwr'
        ]

        p_row_inputs = [('W_primary', 'Fl_turb_I:stat:W'),
                        ('Tt_primary', 'Fl_turb_I:tot:T'),
                        ('ht_primary', 'Fl_turb_I:tot:h'),
                        ('composition_primary', 'Fl_turb_I:tot:composition')]
        self.add_subsystem(
            'row_0',
            Row(n_stages=n_stages,
                i_row=0,
                T_safety=self.options['T_safety'],
                T_metal=self.options['T_metal'],
                thermo_data=thermo_data,
                thermo_method=self.options['thermo_method'],
                main_flow_composition=self.Fl_I_data['Fl_turb_I'],
                bld_flow_composition=self.Fl_I_data['Fl_cool'],
                mix_flow_composition=self.Fl_I_data['Fl_turb_O']),
            promotes_inputs=p_inputs_all + p_row_inputs)

        for i in range(1, n_rows):

            prev_row = 'row_{}'.format(i - 1)
            curr_row = 'row_{}'.format(i)
            self.add_subsystem(
                'row_{}'.format(i),
                Row(n_stages=n_stages,
                    i_row=i,
                    T_safety=self.options['T_safety'],
                    T_metal=self.options['T_metal'],
                    thermo_data=thermo_data,
                    thermo_method=self.options['thermo_method'],
                    main_flow_composition=self.Fl_I_data['Fl_turb_I'],
                    bld_flow_composition=self.Fl_I_data['Fl_cool'],
                    mix_flow_composition=self.Fl_I_data['Fl_turb_O']),
                promotes_inputs=p_inputs_all)

            self.connect('{}.W_out'.format(prev_row),
                         '{}.W_primary'.format(curr_row))
            self.connect('{}.Fl_O:tot:T'.format(prev_row),
                         '{}.Tt_primary'.format(curr_row))
            self.connect('{}.Fl_O:tot:h'.format(prev_row),
                         '{}.ht_primary'.format(curr_row))
            self.connect('{}.Fl_O:tot:composition'.format(prev_row),
                         '{}.composition_primary'.format(curr_row))

        super().setup()
Esempio n. 10
0
    def setup(self):
        thermo_data = self.options['thermo_data']
        elements = self.options['elements']
        statics = self.options['statics']
        design = self.options['design']
        bleeds = self.options['bleed_names']

        num_element = len(elements)

        # Create inlet flowstation
        flow_in = FlowIn(fl_name='Fl_I')
        self.add_subsystem('flow_in',
                           flow_in,
                           promotes=['Fl_I:tot:*', 'Fl_I:stat:*'])

        # Bleed flow calculations
        blds = BleedCalcs(bleed_names=bleeds)
        bld_port_globs = ['{}:*'.format(bn) for bn in bleeds]
        self.add_subsystem('bld_calcs',
                           blds,
                           promotes_inputs=[('W_in', 'Fl_I:stat:W'),
                                            '*:frac_W'],
                           promotes_outputs=['W_out'] + bld_port_globs)

        bleed_names = []
        for BN in bleeds:

            bleed_names.append(BN + '_flow')
            bleed_flow = Thermo(mode='total_TP',
                                fl_name=BN + ":tot",
                                method='CEA',
                                thermo_kwargs={
                                    'elements': elements,
                                    'spec': thermo_data
                                })
            self.add_subsystem(BN + '_flow',
                               bleed_flow,
                               promotes_inputs=[('composition',
                                                 'Fl_I:tot:composition'),
                                                ('T', 'Fl_I:tot:T'),
                                                ('P', 'Fl_I:tot:P')],
                               promotes_outputs=['{}:tot:*'.format(BN)])

        # Total Calc
        real_flow = Thermo(mode='total_TP',
                           fl_name="Fl_O:tot",
                           method='CEA',
                           thermo_kwargs={
                               'elements': elements,
                               'spec': thermo_data
                           })
        prom_in = [('composition', 'Fl_I:tot:composition'),
                   ('T', 'Fl_I:tot:T'), ('P', 'Fl_I:tot:P')]
        self.add_subsystem('real_flow',
                           real_flow,
                           promotes_inputs=prom_in,
                           promotes_outputs=['Fl_O:*'])

        if statics:
            if design:
                #   Calculate static properties
                out_stat = Thermo(mode='static_MN',
                                  fl_name="Fl_O:stat",
                                  method='CEA',
                                  thermo_kwargs={
                                      'elements': elements,
                                      'spec': thermo_data
                                  })
                prom_in = [('composition', 'Fl_I:tot:composition'), 'MN']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)

                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')
                self.connect('W_out', 'out_stat.W')

            else:
                # Calculate static properties
                out_stat = Thermo(mode='static_A',
                                  fl_name="Fl_O:stat",
                                  method='CEA',
                                  thermo_kwargs={
                                      'elements': elements,
                                      'spec': thermo_data
                                  })
                prom_in = [('composition', 'Fl_I:tot:composition'), 'area']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)

                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')
                self.connect('W_out', 'out_stat.W')
        else:
            self.add_subsystem('W_passthru',
                               PassThrough('W_out',
                                           'Fl_O:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])
Esempio n. 11
0
    def setup(self):
        thermo_method = self.options['thermo_method']
        thermo_data = self.options['thermo_data']

        inflow_composition = self.Fl_I_data['Fl_I']
        air_fuel_composition = self.Fl_O_data['Fl_O']
        design = self.options['design']
        statics = self.options['statics']

        # Create combustor flow station
        in_flow = FlowIn(fl_name='Fl_I')
        self.add_subsystem('in_flow',
                           in_flow,
                           promotes=['Fl_I:tot:*', 'Fl_I:stat:*'])

        self.add_subsystem('mix_fuel',
                           self.thermo_add_comp,
                           promotes=[
                               'Fl_I:stat:W', ('mix:ratio', 'Fl_I:FAR'),
                               'Fl_I:tot:composition', 'Fl_I:tot:h',
                               ('mix:W', 'Wfuel'), 'Wout'
                           ])

        # Pressure loss
        prom_in = [('Pt_in', 'Fl_I:tot:P'), 'dPqP']
        self.add_subsystem('p_loss', PressureLoss(), promotes_inputs=prom_in)

        # Calculate vitiated flow station properties
        vit_flow = Thermo(mode='total_hP',
                          fl_name='Fl_O:tot',
                          method=thermo_method,
                          thermo_kwargs={
                              'composition': air_fuel_composition,
                              'spec': thermo_data
                          })
        self.add_subsystem('vitiated_flow',
                           vit_flow,
                           promotes_outputs=['Fl_O:*'])
        self.connect("mix_fuel.mass_avg_h", "vitiated_flow.h")
        self.connect("mix_fuel.composition_out", "vitiated_flow.composition")
        self.connect("p_loss.Pt_out", "vitiated_flow.P")

        if statics:
            if design:
                # Calculate static properties.

                out_stat = Thermo(mode='static_MN',
                                  fl_name='Fl_O:stat',
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'composition': air_fuel_composition,
                                      'spec': thermo_data
                                  })
                prom_in = ['MN']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)

                self.connect("mix_fuel.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('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')
                self.connect('Wout', 'out_stat.W')

            else:
                # Calculate static properties.
                out_stat = Thermo(mode='static_A',
                                  fl_name='Fl_O:stat',
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'composition': air_fuel_composition,
                                      'spec': thermo_data
                                  })
                prom_in = ['area']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)
                self.connect("mix_fuel.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('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')
                self.connect('Wout', 'out_stat.W')

        else:
            self.add_subsystem('W_passthru',
                               PassThrough('Wout',
                                           'Fl_O:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])

        super().setup()
Esempio n. 12
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)
Esempio n. 13
0
    def setup(self):
        thermo_data = self.options['thermo_data']
        elements = self.options['elements']
        statics = self.options['statics']
        design = self.options['design']
        expMN = self.options['expMN']

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

        # Create inlet flowstation
        flow_in = FlowIn(fl_name='Fl_I', num_prods=num_prod)
        self.add_subsystem('flow_in',
                           flow_in,
                           promotes=['Fl_I:tot:*', 'Fl_I:stat:*'])

        if expMN > 1e-10:  # Calcluate pressure losses as function of Mach number
            if design:
                self.add_subsystem(
                    'dPqP_MN',
                    MachPressureLossMap(design=design, expMN=expMN),
                    promotes_inputs=['dPqP', ('MN_in', 'Fl_I:stat:MN')],
                    promotes_outputs=['s_dPqP'])
            else:
                self.add_subsystem(
                    'dPqP_MN',
                    MachPressureLossMap(design=design, expMN=expMN),
                    promotes_inputs=['s_dPqP', ('MN_in', 'Fl_I:stat:MN')],
                    promotes_outputs=['dPqP'])

        #Pressure Loss Component
        prom_in = [('Pt_in', 'Fl_I:tot:P'), 'dPqP']
        self.add_subsystem('p_loss', PressureLoss(), promotes_inputs=prom_in)

        # Energy Calc Component
        prom_in = [('W_in', 'Fl_I:stat:W'), ('ht_in', 'Fl_I:tot:h'), 'Q_dot']
        self.add_subsystem('q_calc', qCalc(), promotes_inputs=prom_in)

        # Total Calc
        real_flow = SetTotal(thermo_data=thermo_data,
                             mode='h',
                             init_reacts=elements,
                             fl_name="Fl_O:tot")
        prom_in = [('init_prod_amounts', 'Fl_I:tot:n')]
        self.add_subsystem('real_flow',
                           real_flow,
                           promotes_inputs=prom_in,
                           promotes_outputs=['Fl_O:*'])
        self.connect("q_calc.ht_out", "real_flow.h")
        self.connect("p_loss.Pt_out", "real_flow.P")

        if statics:
            if design:
                #   Calculate static properties
                out_stat = SetStatic(mode="MN",
                                     thermo_data=thermo_data,
                                     init_reacts=elements,
                                     fl_name="Fl_O:stat")
                prom_in = [('init_prod_amounts', 'Fl_I:tot:n'),
                           ('W', 'Fl_I:stat:W'), 'MN']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)

                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')

            else:
                # Calculate static properties
                out_stat = SetStatic(mode="area",
                                     thermo_data=thermo_data,
                                     init_reacts=elements,
                                     fl_name="Fl_O:stat")
                prom_in = [('init_prod_amounts', 'Fl_I:tot:n'),
                           ('W', 'Fl_I:stat:W'), 'area']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)

                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')
        else:
            self.add_subsystem('W_passthru',
                               PassThrough('Fl_I:stat:W',
                                           'Fl_O:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])

        self.add_subsystem('FAR_passthru',
                           PassThrough('Fl_I:FAR', 'Fl_O:FAR', 0.0),
                           promotes=['*'])
Esempio n. 14
0
    def setup(self):
        thermo_method = self.options['thermo_method']
        thermo_data = self.options['thermo_data']
        if self.options['inflow_thermo_data'] is not None:
            # Set the inflow thermodynamic data package if it is different from the outflow one
            inflow_thermo_data = self.options['inflow_thermo_data']

        else:
            # Set the inflow thermodynamic data package if it is the same as the outflow one
            inflow_thermo_data = thermo_data

        inflow_elements = self.options['inflow_elements']
        air_fuel_elements = self.options['air_fuel_elements']
        design = self.options['design']
        statics = self.options['statics']
        fuel_type = self.options['fuel_type']

        num_air_element = len(inflow_elements)

        # Create combustor flow station
        in_flow = FlowIn(fl_name='Fl_I')
        self.add_subsystem('in_flow',
                           in_flow,
                           promotes=['Fl_I:tot:*', 'Fl_I:stat:*'])

        # Perform combustor engineering calculations
        self.add_subsystem('mix_fuel',
                           ThermoAdd(inflow_thermo_data=inflow_thermo_data,
                                     mix_thermo_data=thermo_data,
                                     inflow_elements=inflow_elements,
                                     mix_elements=fuel_type),
                           promotes=[
                               'Fl_I:stat:W', ('mix:ratio', 'Fl_I:FAR'),
                               'Fl_I:tot:composition', 'Fl_I:tot:h',
                               ('mix:W', 'Wfuel'), 'Wout'
                           ])

        # Pressure loss
        prom_in = [('Pt_in', 'Fl_I:tot:P'), 'dPqP']
        self.add_subsystem('p_loss', PressureLoss(), promotes_inputs=prom_in)

        # Calculate vitiated flow station properties
        vit_flow = Thermo(mode='total_hP',
                          fl_name='Fl_O:tot',
                          method=thermo_method,
                          thermo_kwargs={
                              'elements': air_fuel_elements,
                              'spec': thermo_data
                          })
        self.add_subsystem('vitiated_flow',
                           vit_flow,
                           promotes_outputs=['Fl_O:*'])
        self.connect("mix_fuel.mass_avg_h", "vitiated_flow.h")
        self.connect("mix_fuel.composition_out", "vitiated_flow.composition")
        self.connect("p_loss.Pt_out", "vitiated_flow.P")

        if statics:
            if design:
                # Calculate static properties.

                out_stat = Thermo(mode='static_MN',
                                  fl_name='Fl_O:stat',
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'elements': air_fuel_elements,
                                      'spec': thermo_data
                                  })
                prom_in = ['MN']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)

                self.connect("mix_fuel.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('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')
                self.connect('Wout', 'out_stat.W')

            else:
                # Calculate static properties.
                out_stat = Thermo(mode='static_A',
                                  fl_name='Fl_O:stat',
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'elements': air_fuel_elements,
                                      'spec': thermo_data
                                  })
                prom_in = ['area']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)
                self.connect("mix_fuel.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('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')
                self.connect('Wout', 'out_stat.W')

        else:
            self.add_subsystem('W_passthru',
                               PassThrough('Wout',
                                           'Fl_O:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])
Esempio n. 15
0
    def setup(self):
        #(self, mapclass=NCP01map(), design=True, thermo_data=species_data.janaf, elements=AIR_MIX, bleeds=[],statics=True):

        map_data = self.options['map_data']
        interp_method = self.options['map_interp_method']
        map_extrap = self.options['map_extrap']
        # self.linear_solver = ScipyGMRES()
        # self.linear_solver.options['atol'] = 2e-8
        # self.linear_solver.options['maxiter'] = 100
        # self.linear_solver.options['restart'] = 100

        # self.nonlinear_solver = Newton()
        # self.nonlinear_solver.options['utol'] = 1e-9

        design = self.options['design']
        bleeds = self.options['bleed_names']
        thermo_data = self.options['thermo_data']
        elements = self.options['elements']
        statics = self.options['statics']

        thermo = species_data.Thermo(thermo_data, init_reacts=elements)
        num_prod = thermo.num_prod

        # Create inlet flow station
        flow_in = FlowIn(fl_name='Fl_I', num_prods=num_prod)
        self.add_subsystem('flow_in', flow_in, 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=('Nc', 'Wc'))

        map_calcs = CompressorMap(map_data=self.options['map_data'],
                                  design=design,
                                  interp_method=interp_method,
                                  extrap=map_extrap)
        self.add_subsystem('map',
                           map_calcs,
                           promotes=[
                               's_Nc', 's_eff', 's_Wc', 's_PR', 'Nc', 'Wc',
                               'PR', 'eff', 'SMN', 'SMW'
                           ])

        # Calculate pressure rise across compressor
        self.add_subsystem('press_rise',
                           PressureRise(),
                           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_rise.Pt_out", "ideal_flow.P")

        # Calculate enthalpy rise across compressor
        self.add_subsystem("enth_rise",
                           EnthalpyRise(),
                           promotes_inputs=['eff', ('inlet_ht', 'Fl_I:tot:h')])
        self.connect("ideal_flow.h", "enth_rise.ideal_ht")

        # 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_inputs=[('init_prod_amounts', 'Fl_I:tot:n')
                                            ],
                           promotes_outputs=['Fl_O:tot:*'])
        self.connect("enth_rise.ht_out", "real_flow.h")
        self.connect("press_rise.Pt_out", "real_flow.P")
        #clculate Polytropic Efficiency
        self.add_subsystem(
            'eff_poly_calc',
            eff_poly_calc(),
            promotes_inputs=[
                ('PR', 'PR'),
                ('S_in', 'Fl_I:tot:S'),
                ('S_out', 'Fl_O:tot:S'),
                # ('Cp','Fl_I:tot:Cp'),
                # ('Cv','Fl_I:tot:Cv'),
                ('Rt', 'Fl_I:tot:R')
            ],
            promotes_outputs=['eff_poly'])

        # Calculate shaft power consumption
        blds_pwr = BleedsAndPower(bleed_names=bleeds)
        bld_inputs = ['frac_W', 'frac_P', 'frac_work']
        bld_in_vars = [
            '{0}:{1}'.format(bn, in_name)
            for bn, in_name in itertools.product(bleeds, bld_inputs)
        ]
        bld_out_globs = ['{}:*'.format(bn) for bn in bleeds]

        self.add_subsystem('blds_pwr',
                           blds_pwr,
                           promotes_inputs=[
                               'Nmech',
                               ('W_in', 'Fl_I:stat:W'),
                               ('ht_in', 'Fl_I:tot:h'),
                               ('Pt_in', 'Fl_I:tot:P'),
                               ('Pt_out', 'Fl_O:tot:P'),
                           ] + bld_in_vars,
                           promotes_outputs=['power', 'trq', 'W_out'] +
                           bld_out_globs)
        self.connect('enth_rise.ht_out', 'blds_pwr.ht_out')

        bleed_names = []
        for BN in bleeds:

            bleed_names.append(BN + '_flow')
            bleed_flow = SetTotal(thermo_data=thermo_data,
                                  mode='h',
                                  init_reacts=elements,
                                  fl_name=BN + ":tot")
            self.add_subsystem(BN + '_flow',
                               bleed_flow,
                               promotes_inputs=[('init_prod_amounts',
                                                 'Fl_I:tot:n')],
                               promotes_outputs=['{}:tot:*'.format(BN)])
            self.connect(BN + ':ht', BN + "_flow.h")
            self.connect(BN + ':Pt', BN + "_flow.P")

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

        if statics:
            if design:
                #   Calculate static properties
                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',
                                       ('init_prod_amounts', 'Fl_I:tot:n')
                                   ],
                                   promotes_outputs=['Fl_O:stat:*'])
                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:  # Calculate static properties
                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',
                                       ('init_prod_amounts', 'Fl_I:tot:n')
                                   ],
                                   promotes_outputs=['Fl_O:stat:*'])

                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([
                'flow_in', 'corrinputs', 'map', 'press_rise', 'ideal_flow',
                'enth_rise', 'real_flow', 'eff_poly_calc', 'blds_pwr',
                'FAR_passthru'
            ] + bleed_names + ['out_stat'])

        else:
            self.add_subsystem('W_passthru',
                               PassThrough('W_out',
                                           'Fl_O:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])
            self.set_order([
                'flow_in', 'corrinputs', 'map', 'press_rise', 'ideal_flow',
                'enth_rise', 'real_flow', 'eff_poly_calc', 'blds_pwr',
                'FAR_passthru'
            ] + bleed_names + ['W_passthru'])
Esempio n. 16
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'
                ])
Esempio n. 17
0
    def setup(self):
        thermo_method = self.options['thermo_method']
        thermo_data = self.options['thermo_data']
        elements = self.options['elements']
        statics = self.options['statics']
        design = self.options['design']

        num_element = len(elements)

        # Create inlet flow station
        flow_in = FlowIn(fl_name='Fl_I')
        self.add_subsystem('flow_in',
                           flow_in,
                           promotes=['Fl_I:tot:*', 'Fl_I:stat:*'])

        # Perform inlet engineering calculations
        self.add_subsystem('calcs_inlet',
                           Calcs(),
                           promotes_inputs=[
                               'ram_recovery', ('Pt_in', 'Fl_I:tot:P'),
                               ('V_in', 'Fl_I:stat:V'), ('W_in', 'Fl_I:stat:W')
                           ],
                           promotes_outputs=['F_ram'])

        # Calculate real flow station properties
        real_flow = Thermo(mode='total_TP',
                           fl_name='Fl_O:tot',
                           method=thermo_method,
                           thermo_kwargs={
                               'elements': elements,
                               'spec': thermo_data
                           })
        self.add_subsystem('real_flow',
                           real_flow,
                           promotes_inputs=[('T', 'Fl_I:tot:T'),
                                            ('composition',
                                             'Fl_I:tot:composition')],
                           promotes_outputs=['Fl_O:*'])

        self.connect("calcs_inlet.Pt_out", "real_flow.P")

        if statics:
            if design:
                #   Calculate static properties

                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=[
                                       ('composition', 'Fl_I:tot:composition'),
                                       ('W', 'Fl_I:stat:W'), 'MN'
                                   ],
                                   promotes_outputs=['Fl_O:stat:*'])

                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')

            else:
                # Calculate static properties
                out_stat = Thermo(mode='static_A',
                                  fl_name='Fl_O:stat',
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'elements': elements,
                                      'spec': thermo_data
                                  })
                prom_in = [('composition', 'Fl_I:tot:composition'),
                           ('W', 'Fl_I:stat:W'), 'area']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)

                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')

        else:
            self.add_subsystem('W_passthru',
                               PassThrough('Fl_I:stat:W',
                                           'Fl_O:stat:W',
                                           0.0,
                                           units="lbm/s"),
                               promotes=['*'])
Esempio n. 18
0
    def setup(self):
        thermo_data = self.options['thermo_data']
        elements = self.options['elements']
        statics = self.options['statics']
        design = self.options['design']

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

        # Create inlet flow station
        flow_in = FlowIn(fl_name='Fl_I', num_prods=num_prod)
        self.add_subsystem('flow_in',
                           flow_in,
                           promotes=['Fl_I:tot:*', 'Fl_I:stat:*'])

        # Perform inlet engineering calculations
        self.add_subsystem('calcs_inlet',
                           Calcs(),
                           promotes_inputs=[
                               'ram_recovery', ('Pt_in', 'Fl_I:tot:P'),
                               ('V_in', 'Fl_I:stat:V'), ('W_in', 'Fl_I:stat:W')
                           ],
                           promotes_outputs=['F_ram'])

        # Calculate real flow station properties
        real_flow = SetTotal(thermo_data=thermo_data,
                             mode="T",
                             init_reacts=elements,
                             fl_name="Fl_O:tot")

        self.add_subsystem('real_flow',
                           real_flow,
                           promotes_inputs=[('T', 'Fl_I:tot:T'),
                                            ('init_prod_amounts', 'Fl_I:tot:n')
                                            ],
                           promotes_outputs=['Fl_O:*'])
        self.connect("calcs_inlet.Pt_out", "real_flow.P")

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

        if statics:
            if design:
                #   Calculate static properties
                self.add_subsystem('out_stat',
                                   SetStatic(mode="MN",
                                             thermo_data=thermo_data,
                                             init_reacts=elements,
                                             fl_name="Fl_O:stat"),
                                   promotes_inputs=[
                                       ('init_prod_amounts', 'Fl_I:tot:n'),
                                       ('W', 'Fl_I:stat:W'), 'MN'
                                   ],
                                   promotes_outputs=['Fl_O:stat:*'])

                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')

            else:
                # Calculate static properties
                out_stat = SetStatic(mode="area",
                                     thermo_data=thermo_data,
                                     init_reacts=elements,
                                     fl_name="Fl_O:stat")
                prom_in = [('init_prod_amounts', 'Fl_I:tot:n'),
                           ('W', 'Fl_I:stat:W'), 'area']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)

                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')

        else:
            self.add_subsystem('W_passthru',
                               PassThrough('Fl_I:stat:W',
                                           'Fl_O:stat:W',
                                           0.0,
                                           units="lbm/s"),
                               promotes=['*'])
Esempio n. 19
0
    def setup(self):

        design = self.options['design']
        thermo_data = self.options['thermo_data']

        flow1_elements = self.options['Fl_I1_elements']
        flow1_thermo = Thermo(thermo_data, init_reacts=flow1_elements)
        n_flow1_prods = len(flow1_thermo.products)
        in_flow = FlowIn(fl_name='Fl_I1', num_prods=n_flow1_prods)
        self.add_subsystem('in_flow1', in_flow, promotes=['Fl_I1:*'])

        flow2_elements = self.options['Fl_I2_elements']
        flow2_thermo = Thermo(thermo_data, init_reacts=flow2_elements)
        n_flow2_prods = len(flow2_thermo.products)
        in_flow = FlowIn(fl_name='Fl_I2', num_prods=n_flow2_prods)
        self.add_subsystem('in_flow2', in_flow, promotes=['Fl_I2:*'])


        if design:
            # internal flow station to compute the area that is needed to match the static pressures
            if self.options['designed_stream'] == 1:
                Fl1_stat = SetStatic(mode="Ps", thermo_data=thermo_data,
                                    init_reacts=flow1_elements,
                                    fl_name="Fl_I1_calc:stat")
                self.add_subsystem('Fl_I1_stat_calc', Fl1_stat,
                                   promotes_inputs=[('init_prod_amounts', 'Fl_I1:stat:n'), ('S', 'Fl_I1:tot:S'),
                                                    ('ht', 'Fl_I1:tot:h'), ('W', 'Fl_I1:stat:W'), ('Ps', 'Fl_I2:stat:P')],
                                   promotes_outputs=['Fl_I1_calc:stat*'])

                self.add_subsystem('area_calc', AreaSum(), promotes_inputs=['Fl_I2:stat:area'],
                                   promotes_outputs=[('area_sum', 'area')])
                self.connect('Fl_I1_calc:stat:area', 'area_calc.Fl_I1:stat:area')
            else:
                Fl2_stat = SetStatic(mode="Ps", thermo_data=thermo_data,
                                    init_reacts=flow2_elements,
                                    fl_name="Fl_I2_calc:stat")
                self.add_subsystem('Fl_I2_stat_calc', Fl2_stat,
                                   promotes_inputs=[('init_prod_amounts', 'Fl_I2:tot:n'), ('S', 'Fl_I2:tot:S'),
                                                    ('ht', 'Fl_I2:tot:h'), ('W', 'Fl_I2:stat:W'), ('Ps', 'Fl_I1:stat:P')],
                                   promotes_outputs=['Fl_I2_calc:stat:*'])

                self.add_subsystem('area_calc', AreaSum(), promotes_inputs=['Fl_I1:stat:area'],
                                   promotes_outputs=[('area_sum', 'area')])
                self.connect('Fl_I2_calc:stat:area', 'area_calc.Fl_I2:stat:area')

        else:
            if self.options['designed_stream'] == 1:
                Fl1_stat = SetStatic(mode="area", thermo_data=thermo_data,
                                        init_reacts=flow1_elements,
                                        fl_name="Fl_I1_calc:stat")
                self.add_subsystem('Fl_I1_stat_calc', Fl1_stat,
                                    promotes_inputs=[('init_prod_amounts', 'Fl_I1:tot:n'), ('S', 'Fl_I1:tot:S'),
                                                     ('ht', 'Fl_I1:tot:h'), ('W', 'Fl_I1:stat:W'),
                                                     ('guess:Pt', 'Fl_I1:tot:P'), ('guess:gamt', 'Fl_I1:tot:gamma')],
                                    promotes_outputs=['Fl_I1_calc:stat*'])
            else:
                Fl2_stat = SetStatic(mode="area", thermo_data=thermo_data,
                                        init_reacts=flow2_elements,
                                        fl_name="Fl_I2_calc:stat")
                self.add_subsystem('Fl_I2_stat_calc', Fl2_stat,
                                    promotes_inputs=[('init_prod_amounts', 'Fl_I2:tot:n'), ('S', 'Fl_I2:tot:S'),
                                                     ('ht', 'Fl_I2:tot:h'), ('W', 'Fl_I2:stat:W'),
                                                     ('guess:Pt', 'Fl_I2:tot:P'), ('guess:gamt', 'Fl_I2:tot:gamma')],
                                    promotes_outputs=['Fl_I2_calc:stat*'])

        self.add_subsystem('extraction_ratio', om.ExecComp('ER=Pt1/Pt2', Pt1={'units':'Pa'}, Pt2={'units':'Pa'}),
                            promotes_inputs=[('Pt1', 'Fl_I1:tot:P'), ('Pt2', 'Fl_I2:tot:P')],
                            promotes_outputs=['ER'])

        mix_flow = MixFlow(thermo_data=thermo_data,
                   Fl_I1_elements=self.options['Fl_I1_elements'],
                   Fl_I2_elements=self.options['Fl_I2_elements'])
        if self.options['designed_stream'] == 1:
            self.add_subsystem('mix_flow', mix_flow,
                               promotes_inputs=['Fl_I1:tot:h', 'Fl_I1:tot:n', ('Fl_I1:stat:W','Fl_I1_calc:stat:W'), ('Fl_I1:stat:P','Fl_I1_calc:stat:P'),
                                                ('Fl_I1:stat:V','Fl_I1_calc:stat:V'), ('Fl_I1:stat:area','Fl_I1_calc:stat:area'),
                                                'Fl_I2:tot:h', 'Fl_I2:tot:n', 'Fl_I2:stat:W', 'Fl_I2:stat:P', 'Fl_I2:stat:V', 'Fl_I2:stat:area'])
        else:
            self.add_subsystem('mix_flow', mix_flow,
                               promotes_inputs=['Fl_I1:tot:h', 'Fl_I1:tot:n', 'Fl_I1:stat:W', 'Fl_I1:stat:P', 'Fl_I1:stat:V', 'Fl_I1:stat:area',
                                                'Fl_I2:tot:h', 'Fl_I2:tot:n', ('Fl_I2:stat:W','Fl_I2_calc:stat:W'), ('Fl_I2:stat:P','Fl_I2_calc:stat:P'),
                                                ('Fl_I2:stat:V','Fl_I2_calc:stat:V'), ('Fl_I2:stat:area','Fl_I2_calc:stat:area')])


        # group to converge for the impulse balance
        conv = self.add_subsystem('impulse_converge', om.Group(), promotes=['*'])

        if self.options['internal_solver']:
            newton = conv.nonlinear_solver = om.NewtonSolver()
            newton.options['maxiter'] = 30
            newton.options['atol'] = 1e-2
            newton.options['solve_subsystems'] = True
            newton.options['max_sub_solves'] = 20
            newton.options['reraise_child_analysiserror'] = False
            newton.linesearch = om.BoundsEnforceLS()
            newton.linesearch.options['bound_enforcement'] = 'scalar'
            newton.linesearch.options['iprint'] = -1
            conv.linear_solver = om.DirectSolver(assemble_jac=True)

        out_tot = SetTotal(thermo_data=thermo_data, mode='h', init_reacts=self.options['Fl_I1_elements'],
                        fl_name="Fl_O:tot")
        conv.add_subsystem('out_tot', out_tot, promotes_outputs=['Fl_O:tot:*'])
        self.connect('mix_flow.n_mix', 'out_tot.init_prod_amounts')
        self.connect('mix_flow.ht_mix', 'out_tot.h')
        # note: gets Pt from the balance comp

        out_stat = SetStatic(mode="area", thermo_data=thermo_data,
                             init_reacts=self.options['Fl_I1_elements'],
                             fl_name="Fl_O:stat")
        conv.add_subsystem('out_stat', out_stat, promotes_outputs=['Fl_O:stat:*'], promotes_inputs=['area', ])
        self.connect('mix_flow.n_mix', 'out_stat.init_prod_amounts')
        self.connect('mix_flow.W_mix','out_stat.W')
        conv.connect('Fl_O:tot:S', 'out_stat.S')
        self.connect('mix_flow.ht_mix', 'out_stat.ht')
        conv.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
        conv.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')

        conv.add_subsystem('imp_out', Impulse())
        conv.connect('Fl_O:stat:P', 'imp_out.P')
        conv.connect('Fl_O:stat:area', 'imp_out.area')
        conv.connect('Fl_O:stat:V', 'imp_out.V')
        conv.connect('Fl_O:stat:W', 'imp_out.W')

        balance = conv.add_subsystem('balance', om.BalanceComp())
        balance.add_balance('P_tot', val=100, units='psi', eq_units='N', lower=1e-3, upper=10000)
        conv.connect('balance.P_tot', 'out_tot.P')
        conv.connect('imp_out.impulse', 'balance.lhs:P_tot')
        self.connect('mix_flow.impulse_mix', 'balance.rhs:P_tot') #note that this connection comes from outside the convergence group
Esempio n. 20
0
    def setup(self):
        thermo_method = self.options['thermo_method']
        thermo_data = self.options['thermo_data']
        elements = self.options['elements']
        statics = self.options['statics']
        design = self.options['design']
        expMN = self.options['expMN']

        num_element = len(elements)

        # Create inlet flowstation
        flow_in = FlowIn(fl_name='Fl_I')
        self.add_subsystem('flow_in',
                           flow_in,
                           promotes=['Fl_I:tot:*', 'Fl_I:stat:*'])

        if expMN > 1e-10:  # Calcluate pressure losses as function of Mach number
            if design:
                self.add_subsystem(
                    'dPqP_MN',
                    MachPressureLossMap(design=design, expMN=expMN),
                    promotes_inputs=['dPqP', ('MN_in', 'Fl_I:stat:MN')],
                    promotes_outputs=['s_dPqP'])
            else:
                self.add_subsystem(
                    'dPqP_MN',
                    MachPressureLossMap(design=design, expMN=expMN),
                    promotes_inputs=['s_dPqP', ('MN_in', 'Fl_I:stat:MN')],
                    promotes_outputs=['dPqP'])

        #Pressure Loss Component
        prom_in = [('Pt_in', 'Fl_I:tot:P'), 'dPqP']
        self.add_subsystem('p_loss', PressureLoss(), promotes_inputs=prom_in)

        # Energy Calc Component
        prom_in = [('W_in', 'Fl_I:stat:W'), ('ht_in', 'Fl_I:tot:h'), 'Q_dot']
        self.add_subsystem('q_calc', qCalc(), promotes_inputs=prom_in)

        # Total Calc
        real_flow = Thermo(mode='total_hP',
                           fl_name='Fl_O:tot',
                           method=thermo_method,
                           thermo_kwargs={
                               'elements': elements,
                               'spec': thermo_data
                           })
        prom_in = [('composition', 'Fl_I:tot:composition')]
        self.add_subsystem('real_flow',
                           real_flow,
                           promotes_inputs=prom_in,
                           promotes_outputs=['Fl_O:*'])
        self.connect("q_calc.ht_out", "real_flow.h")
        self.connect("p_loss.Pt_out", "real_flow.P")

        if statics:
            if design:
                #   Calculate static properties
                out_stat = Thermo(mode='static_MN',
                                  fl_name='Fl_O:stat',
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'elements': elements,
                                      'spec': thermo_data
                                  })
                prom_in = [('composition', 'Fl_I:tot:composition'),
                           ('W', 'Fl_I:stat:W'), 'MN']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)

                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')

            else:
                # Calculate static properties
                out_stat = Thermo(mode='static_A',
                                  fl_name='Fl_O:stat',
                                  method=thermo_method,
                                  thermo_kwargs={
                                      'elements': elements,
                                      'spec': thermo_data
                                  })
                prom_in = [('composition', 'Fl_I:tot:composition'),
                           ('W', 'Fl_I:stat:W'), 'area']
                prom_out = ['Fl_O:stat:*']
                self.add_subsystem('out_stat',
                                   out_stat,
                                   promotes_inputs=prom_in,
                                   promotes_outputs=prom_out)

                self.connect('Fl_O:tot:S', 'out_stat.S')
                self.connect('Fl_O:tot:h', 'out_stat.ht')
                self.connect('Fl_O:tot:P', 'out_stat.guess:Pt')
                self.connect('Fl_O:tot:gamma', 'out_stat.guess:gamt')
        else:
            self.add_subsystem('W_passthru',
                               PassThrough('Fl_I:stat:W',
                                           'Fl_O:stat:W',
                                           1.0,
                                           units="lbm/s"),
                               promotes=['*'])