コード例 #1
0
ファイル: compressor.py プロジェクト: friedenhe/pyCycle
    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'])
コード例 #2
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=['*'])
コード例 #3
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')
コード例 #4
0
ファイル: bleed_out.py プロジェクト: friedenhe/pyCycle
    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=['*'])
コード例 #5
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=['*'])
コード例 #6
0
ファイル: compressor.py プロジェクト: lamkina/pyCycle
    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()
コード例 #7
0
ファイル: combustor.py プロジェクト: smyng91/pyCycle
    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=['*'])
コード例 #8
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'
                ])
コード例 #9
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=['*'])
コード例 #10
0
ファイル: combustor.py プロジェクト: lamkina/pyCycle
    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()
コード例 #11
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)
コード例 #12
0
ファイル: duct.py プロジェクト: will214/pyCycle
    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=['*'])
コード例 #13
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=['*'])
コード例 #14
0
ファイル: splitter.py プロジェクト: lamkina/pyCycle
    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()
コード例 #15
0
ファイル: duct.py プロジェクト: eshendricks/pyCycle
    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=['*'])