Exemple #1
0
def test_turbine_missing_char_parameter():
    """Turbine with invalid parameter for eta_s_char function."""
    nw = network(['CH4'])
    so = basics.source('source')
    si = basics.sink('sink')
    instance = turbomachinery.turbine('turbine')
    c1 = connection(so, 'out1', instance, 'in1')
    c2 = connection(instance, 'out1', si, 'in1')
    nw.add_conns(c1, c2)
    instance.set_attr(eta_s_char=dc_cc(
        func=char_line([0, 1], [1, 2]), is_set=True, param=None))
    nw.solve('design', init_only=True)
    with raises(ValueError):
        instance.eta_s_char_func()
Exemple #2
0
    def setup_combustion_chamber_model(self):
        """Set up the model using the combustion chamber."""
        # %% network setup
        fluid_list = ['Ar', 'N2', 'O2', 'CO2', 'CH4', 'H2O']
        self.nw1 = network(
            fluids=fluid_list, p_unit='bar', T_unit='C',
            p_range=[0.5, 20], T_range=[10, 2000])

        # %% components
        amb = source('ambient')
        sf = source('fuel')
        cc = combustion_chamber('combustion')
        cp = compressor('compressor')
        gt = turbine('turbine')
        fg = sink('flue gas outlet')

        # %% connections
        amb_cp = connection(amb, 'out1', cp, 'in1')
        cp_cc = connection(cp, 'out1', cc, 'in1')
        sf_cc = connection(sf, 'out1', cc, 'in2')
        cc_gt = connection(cc, 'out1', gt, 'in1', label='flue gas after cc')
        gt_fg = connection(gt, 'out1', fg, 'in1', label='flue gas after gt')

        self.nw1.add_conns(amb_cp, cp_cc, sf_cc, cc_gt, gt_fg)

        # %% component parameters
        cc.set_attr(lamb=3)
        cp.set_attr(eta_s=0.9, pr=15)
        gt.set_attr(eta_s=0.9)

        # %% connection parameters
        amb_cp.set_attr(
            T=20, p=1, m=100,
            fluid={'Ar': 0.0129, 'N2': 0.7553, 'H2O': 0, 'CH4': 0,
                   'CO2': 0.0004, 'O2': 0.2314})
        sf_cc.set_attr(
            T=20, fluid={'CO2': 0.04, 'Ar': 0, 'N2': 0,
                         'O2': 0, 'H2O': 0, 'CH4': 0.96})
        gt_fg.set_attr(p=1)

        # %% solving
        mode = 'design'
        self.nw1.solve(mode=mode)
Exemple #3
0
    def test_turbine(self):
        """Test component properties of turbines."""
        instance = turbine('turbine')
        self.setup_network(instance)
        fl = {
            'N2': 0.7556,
            'O2': 0.2315,
            'Ar': 0.0129,
            'INCOMP::DowQ': 0,
            'NH3': 0
        }
        self.c1.set_attr(fluid=fl, m=15, p=10)
        self.c2.set_attr(p=1, T=20)
        instance.set_attr(eta_s=0.85)
        self.nw.solve('design')
        self.nw.save('tmp')

        # design value of isentropic efficiency
        eta_s_d = ((self.c2.h.val_SI - self.c1.h.val_SI) /
                   (instance.h_os('') - self.c1.h.val_SI))
        msg = ('Value of isentropic efficiency must be ' +
               str(round(eta_s_d, 3)) + ', is ' + str(instance.eta_s.val) +
               '.')
        eq_(round(eta_s_d, 3), round(instance.eta_s.val, 3), msg)

        # trigger invalid value for isentropic efficiency
        instance.set_attr(eta_s=1.1)
        self.nw.solve('design')
        eta_s = round((self.c2.h.val_SI - self.c1.h.val_SI) /
                      (instance.h_os('') - self.c1.h.val_SI), 3)
        msg = ('Value of isentropic efficiency must be ' + str(eta_s) +
               ', is ' + str(instance.eta_s.val) + '.')
        eq_(eta_s, round(instance.eta_s.val, 3), msg)

        # unset isentropic efficiency and inlet pressure,
        # use characteristcs and cone law instead, parameters have to be in
        # design state
        self.c1.set_attr(p=np.nan)
        instance.cone.is_set = True
        instance.eta_s_char.is_set = True
        instance.eta_s.is_set = False
        self.nw.solve('offdesign', design_path='tmp')
        # check efficiency
        msg = ('Value of isentropic efficiency (' + str(instance.eta_s.val) +
               ') must be identical to design case (' + str(eta_s_d) + ').')
        eq_(round(eta_s_d, 2), round(instance.eta_s.val, 2), msg)
        # check pressure
        msg = ('Value of inlet pressure (' + str(round(self.c1.p.val_SI)) +
               ') must be identical to design case (' +
               str(round(self.c1.p.design)) + ').')
        eq_(round(self.c1.p.design), round(self.c1.p.val_SI), msg)

        # lowering mass flow, inlet pressure must sink according to cone law
        self.c1.set_attr(m=self.c1.m.val * 0.8)
        self.nw.solve('offdesign', design_path='tmp')
        msg = ('Value of pressure ratio (' + str(instance.pr.val) +
               ') must be at (' + str(0.128) + ').')
        eq_(0.128, round(instance.pr.val, 3), msg)

        # testing more parameters for eta_s_char
        # test parameter specification v
        self.c1.set_attr(m=10)
        instance.eta_s_char.param = 'v'
        self.nw.solve('offdesign', design_path='tmp')
        expr = self.c1.v.val_SI / self.c1.v.design
        eta_s = round(eta_s_d * instance.eta_s_char.func.evaluate(expr), 3)
        msg = ('Value of isentropic efficiency (' +
               str(round(instance.eta_s.val, 3)) + ') must be (' + str(eta_s) +
               ').')
        eq_(eta_s, round(instance.eta_s.val, 3), msg)

        # test parameter specification pr
        instance.eta_s_char.param = 'pr'
        self.nw.solve('offdesign', design_path='tmp')
        expr = (self.c2.p.val_SI * self.c1.p.design /
                (self.c2.p.design * self.c1.p.val_SI))
        eta_s = round(eta_s_d * instance.eta_s_char.func.evaluate(expr), 3)
        msg = ('Value of isentropic efficiency (' +
               str(round(instance.eta_s.val, 3)) + ') must be (' + str(eta_s) +
               ').')
        eq_(eta_s, round(instance.eta_s.val, 3), msg)

        # test parameter specification dh_s
        instance.eta_s_char.param = 'dh_s'
        self.nw.solve('offdesign', design_path='tmp')
        expr = (instance.h_os('') - self.c1.h.val_SI) / instance.dh_s_ref
        eta_s = round(eta_s_d * instance.eta_s_char.func.evaluate(expr), 3)
        msg = ('Value of isentropic efficiency (' +
               str(round(instance.eta_s.val, 3)) + ') must be (' + str(eta_s) +
               ').')
        eq_(eta_s, round(instance.eta_s.val, 3), msg)
        shutil.rmtree('./tmp', ignore_errors=True)
Exemple #4
0
    def setup(self):
        """Set up the model."""
        # %% network setup
        fluid_list = ['Ar', 'N2', 'O2', 'CO2', 'CH4', 'H2O']
        self.nw = network(fluids=fluid_list,
                          p_unit='bar',
                          T_unit='C',
                          p_range=[0.5, 20],
                          T_range=[10, 2000])

        # %% components
        amb = source('ambient')
        sf = source('fuel')
        cc = combustion_chamber('combustion')
        cp = compressor('compressor')
        gt = turbine('turbine')
        fg = sink('flue gas outlet')

        # %% connections
        amb_cp = connection(amb, 'out1', cp, 'in1', label='ambient air flow')
        cp_cc = connection(cp, 'out1', cc, 'in1')
        sf_cc = connection(sf, 'out1', cc, 'in2')
        cc_gt = connection(cc, 'out1', gt, 'in1')
        gt_fg = connection(gt, 'out1', fg, 'in1')

        self.nw.add_conns(amb_cp, cp_cc, sf_cc, cc_gt, gt_fg)

        # %% component parameters
        cc.set_attr(lamb=3)
        cp.set_attr(eta_s=0.9, pr=15)
        gt.set_attr(eta_s=0.9)

        # %% connection parameters
        amb_cp.set_attr(T=20,
                        p=1,
                        m=100,
                        fluid={
                            'Ar': 0.0129,
                            'N2': 0.7553,
                            'H2O': 0,
                            'CH4': 0,
                            'CO2': 0.0004,
                            'O2': 0.2314
                        })
        sf_cc.set_attr(T=20,
                       fluid={
                           'CO2': 0.04,
                           'Ar': 0,
                           'N2': 0,
                           'O2': 0,
                           'H2O': 0,
                           'CH4': 0.96
                       })
        gt_fg.set_attr(p=1)

        # motor efficiency
        x = np.array([
            0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55,
            0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.05, 1.1, 1.15,
            1.2, 10
        ])
        y = np.array([
            0.01, 0.3148, 0.5346, 0.6843, 0.7835, 0.8477, 0.8885, 0.9145,
            0.9318, 0.9443, 0.9546, 0.9638, 0.9724, 0.9806, 0.9878, 0.9938,
            0.9982, 0.999, 0.9995, 0.9999, 1, 0.9977, 0.9947, 0.9909, 0.9853,
            0.9644
        ]) * 0.975
        self.motor_bus_based = char_line(x=x, y=y)
        self.motor_comp_based = char_line(x=x, y=1 / y)

        # generator efficiency
        x = np.array([
            0.100, 0.345, 0.359, 0.383, 0.410, 0.432, 0.451, 0.504, 0.541,
            0.600, 0.684, 0.805, 1.000, 1.700, 10
        ])
        y = np.array([
            0.976, 0.989, 0.990, 0.991, 0.992, 0.993, 0.994, 0.995, 0.996,
            0.997, 0.998, 0.999, 1.000, 0.999, 0.99
        ]) * 0.975
        self.generator = char_line(x=x, y=y)

        power_bus_total = bus('total power output')
        power_bus_total.add_comps(
            {
                'comp': cp,
                'char': self.motor_bus_based,
                'base': 'bus'
            }, {
                'comp': gt,
                'char': self.generator
            })

        thermal_input = bus('thermal input')
        thermal_input.add_comps({'comp': cc})

        compressor_power_comp = bus('compressor power input')
        compressor_power_comp.add_comps({
            'comp': cp,
            'char': self.motor_comp_based
        })

        compressor_power_bus = bus('compressor power input bus based')
        compressor_power_bus.add_comps({
            'comp': cp,
            'char': self.motor_bus_based,
            'base': 'bus'
        })

        self.nw.add_busses(power_bus_total, thermal_input,
                           compressor_power_comp, compressor_power_bus)

        # %% solving
        self.nw.solve('design')
        self.nw.save('tmp')
Exemple #5
0
fluid_list = ['Ar', 'N2', 'O2', 'CO2', 'CH4', 'H2O']

nw = network(fluids=fluid_list,
             p_unit='bar',
             T_unit='C',
             h_unit='kJ / kg',
             p_range=[1, 100],
             T_range=[10, 1500],
             h_range=[10, 4000])

# %% components
# gas turbine part
comp = compressor('compressor')
comp_fuel = compressor('fuel compressor')
c_c = combustion_chamber('combustion')
g_turb = turbine('gas turbine')

CH4 = source('fuel source')
air = source('ambient air')

# waste heat recovery
suph = heat_exchanger('superheater')
evap = heat_exchanger('evaporator')
drum = drum('drum')
eco = heat_exchanger('economizer')
ch = sink('chimney')

# steam turbine part
turb_hp = turbine('steam turbine high pressure')
cond_dh = condenser('district heating condenser')
mp_split = splitter('mp split')