Esempio n. 1
0
    def test_set_total_sp(self):
        p = self.p
        p.model.add_subsystem('ceq', ChemEq(thermo=self.thermo, mode="S"), promotes=["*"])
        p.model.set_input_defaults('S', 1.58645, units='cal/(g*degK)')
        p.setup(check=False)
        p.run_model()

        check_val = np.array([3.23319258e-04, 1.00000000e-10, 1.10131241e-05, 1.00000000e-10,
                            1.00000000e-10, 1.00000000e-10, 1.00000000e-10, 2.69578866e-02,
                            1.00000000e-10, 7.23199382e-03])

        tol = 6e-4
        assert_near_equal(p['n'], check_val, tol)
Esempio n. 2
0
    def test_set_total_sp(self):
        p = self.p
        p.model.add_subsystem('ceq',
                              ChemEq(thermo=self.thermo, mode="S"),
                              promotes=["*"])
        p.model.set_input_defaults('S', 1.58645, units='cal/(g*degK)')
        p.setup(check=False)
        p.run_model()

        tol = 6e-4
        assert_near_equal(p['n'],
                          [8.15344263e-06, 2.27139552e-02, 4.07672148e-06],
                          tol)
Esempio n. 3
0
    def test_set_total_tp(self):
        p = self.p
        p.model.add_subsystem('ceq', ChemEq(thermo=self.thermo, mode="T"), promotes=["*"])
        p.model.set_input_defaults('T', 1500., units='degK')
        p.setup(check=False)
        p.run_model()

        check_val = np.array([3.23319258e-04, 1.16619251e-10, 1.10131075e-05, 1.00000000e-10,
                            4.19205954e-05, 2.27520440e-07, 1.00000000e-10, 2.69368126e-02,
                            6.33239011e-08, 7.21077455e-03])

        tol = 6e-4

        assert_near_equal(p['n'], check_val, tol)
Esempio n. 4
0
    def test_set_total_sp(self):
        p = self.p
        p.model.add_subsystem('entropy',
                              IndepVarComp('S', 1.58645, units='cal/(g*degK)'),
                              promotes=['*'])
        p.model.add_subsystem('ceq',
                              ChemEq(thermo=self.thermo, mode="S"),
                              promotes=["*"])
        p.setup(check=False)
        p.run_model()

        tol = 6e-4
        assert_rel_error(self, p['n'],
                         [8.15344263e-06, 2.27139552e-02, 4.07672148e-06], tol)
Esempio n. 5
0
    def test_set_total_tp(self):
        p = self.p
        p.model.add_subsystem('temp',
                              IndepVarComp('T', 1500., units='degK'),
                              promotes=['*'])
        p.model.add_subsystem('ceq',
                              ChemEq(thermo=self.thermo, mode="T"),
                              promotes=["*"])
        p.setup(check=False)
        p.run_model()

        tol = 6e-4

        assert_rel_error(self, p['n'],
                         [8.15344263e-06, 2.27139552e-02, 4.07672148e-06], tol)
Esempio n. 6
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),))