예제 #1
0
    def setup(self):

        mode = self.options['mode']

        thermo_data = self.options['thermo_data']
        init_reacts = self.options['init_reacts']
        fl_name = self.options['fl_name']

        thermo = species_data.Thermo(thermo_data, init_reacts)

        statics = SetTotal(mode='S',
                           fl_name=fl_name,
                           thermo_data=thermo_data,
                           init_reacts=init_reacts,
                           for_statics=mode)

        # have to promote things differently depending on which mode we are
        if mode == 'Ps':
            self.add_subsystem('statics', statics,
                               promotes_inputs=[('P', 'Ps'), 'S', 'ht', 'W', 'init_prod_amounts'],
                               promotes_outputs=['MN', 'V', 'Vsonic', 'area',
                                                 'T', 'h', 'gamma', 'Cp', 'Cv', 'rho', 'n', 'n_moles'])
        elif mode == 'MN':
            self.add_subsystem('statics', statics,
                               promotes_inputs=['MN', 'S', 'ht', 'W', 'guess:*', 'init_prod_amounts'],
                               promotes_outputs=['V', 'Vsonic', 'area',
                                                 'Ps', 'T', 'h', 'gamma', 'Cp', 'Cv', 'rho', 'n', 'n_moles'])

        else:
            self.add_subsystem('statics', statics,
                               promotes_inputs=['area', 'S', 'ht', 'W', 'guess:*', 'init_prod_amounts'],
                               promotes_outputs=['V', 'Vsonic', 'MN',
                                                 'Ps', 'T', 'h', 'gamma', 'Cp', 'Cv', 'rho', 'n', 'n_moles'])

        p_inputs = ('T', 'P', 'h', 'S', 'gamma', 'Cp', 'Cv', 'rho', 'n', 'n_moles')
        p_outputs = tuple(['{0}:{1}'.format(fl_name, in_name) for in_name in p_inputs])
        # need to redefine this so that P gets promoted as P. Needed the first definition for the list comprehension
        p_inputs = ('T', ('P', 'Ps'), 'h', 'S', 'gamma', 'Cp', 'Cv', 'rho', 'n', 'n_moles')

        self.add_subsystem('flow', EngUnitProps(thermo=thermo, fl_name=fl_name),
                           promotes_inputs=p_inputs,
                           promotes_outputs=p_outputs)

        p_inputs = ('area', 'W', 'V', 'Vsonic', 'MN')
        p_outputs = tuple(['{0}:{1}'.format(fl_name, in_name) for in_name in p_inputs])
        eng_units_statics = EngUnitStaticProps(thermo, fl_name)
        self.add_subsystem('flow_static', eng_units_statics,
                           promotes_inputs=p_inputs,
                           promotes_outputs=p_outputs)
예제 #2
0
    def setup(self):
        #, thermo_data, mode='T', fl_name='flow', init_reacts=AIR_MIX):

        thermo_data = self.options['thermo_data']
        init_reacts = self.options['init_reacts']
        fl_name = self.options['fl_name']
        mode = self.options['mode']
        for_statics = self.options['for_statics']

        thermo = Thermo(thermo_data, init_reacts)

        # chem_eq calculations
        in_vars = ('init_prod_amounts', 'P')
        out_vars = ('n', 'n_moles', 'b0')
        if mode == 'T':
            in_vars += ('T', )
        elif mode == 'h':
            in_vars += ('h',)
            out_vars += ('T', )
        elif mode == 'S':
            in_vars += ('S', )
            out_vars += ('T', )

        self.ceq = self.add_subsystem('chem_eq', ChemEq(thermo=thermo, mode=mode),
                           promotes_inputs=in_vars,
                           promotes_outputs=out_vars,
                           )

        out_vars = ('gamma', 'Cp', 'Cv', 'rho', 'R')
        if mode == 'h':
            out_vars += ('S',)
        elif mode == 'S':
            out_vars += ('h',)
        else:
            out_vars += ('S', 'h')

        self.add_subsystem('props', Properties(thermo=thermo),
                           promotes_inputs=('T', 'P', 'n', 'n_moles', 'b0'),
                           promotes_outputs=out_vars)

        if for_statics:  # created after props to keep the execution order
            if for_statics == 'MN':
                self.add_subsystem('ps_resid', PsResid(mode=for_statics),
                                   promotes_inputs=['ht', 'n_moles', 'gamma', 'W',
                                                    'rho', 'MN', 'guess:*', ('Ts', 'T'), ('hs', 'h')],
                                   promotes_outputs=['V', 'Vsonic', 'area', 'Ps'])

                self.connect('Ps', 'P')  # create the cyclic data connection for the static solve
            elif for_statics == 'area':
                self.add_subsystem('ps_resid', PsResid(mode=for_statics),
                                   promotes_inputs=['ht', 'n_moles', 'gamma', 'W',
                                                    'rho', 'area', 'guess:*', ('Ts', 'T'), ('hs', 'h')],
                                   promotes_outputs=['V', 'Vsonic', 'MN', 'Ps'])

                self.connect('Ps', 'P') # create the cyclic data connection for the static solve
            else:
                self.add_subsystem('ps_calc', PsCalc(thermo=thermo),
                                   promotes_inputs=['P', 'gamma', 'n_moles', 'ht', 'W', 'rho',
                                                    ('Ts', 'T'), ('hs', 'h')],
                                   promotes_outputs=['MN', 'V', 'Vsonic', 'area']
                                   )

        else:
            self.add_subsystem('flow', EngUnitProps(thermo=thermo, fl_name=fl_name),
                               promotes_inputs=('T', 'P', 'h', 'S', 'gamma', 'Cp', 'Cv', 'rho', 'n', 'n_moles', 'R'),
                               promotes_outputs=('{}:*'.format(fl_name),))