Exemple #1
0
    def setup(self):
        self.Tamb = 20
        self.pamb = 1
        fluids = ['Air']

        # turbine part
        self.nw = Network(fluids=fluids)
        self.nw.set_attr(p_unit='bar', T_unit='C', h_unit='kJ / kg')

        # components
        so = Source('inlet')
        cp = Compressor('compressor')
        si = Sink('outlet')

        # fuel exergy bus
        self.exergy_fuel = Bus('fuel exergy')
        self.exergy_fuel.add_comps({'comp': cp, 'char': 0.9, 'base': 'bus'})
        # product exergy bus
        self.exergy_prod = Bus('product exergy')
        self.exergy_prod.add_comps({'comp': si}, {'comp': so, 'base': 'bus'})

        # create connections
        c1 = Connection(so, 'out1', cp, 'in1', '1')
        c2 = Connection(cp, 'out1', si, 'in1', '2')
        self.nw.add_conns(c1, c2)

        # component parameters
        cp.set_attr(eta_s=0.85, pr=5)

        # connection parameters
        c1.set_attr(m=2, T=self.Tamb, p=self.pamb, fluid={'Air': 1})

        # solve network
        self.nw.solve('design')
    def setup_CombustionChamberStoich_model(self):
        """Set up the model using the stoichimetric combustion chamber."""
        # %% network setup
        fluid_list = ['myAir', 'myFuel', 'myFuel_fg']
        self.nw2 = 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 = CombustionChamberStoich('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.nw2.add_conns(amb_cp, cp_cc, sf_cc, cc_gt, gt_fg)

        # %% component parameters
        cc.set_attr(fuel={
            'CH4': 0.96,
            'CO2': 0.04
        },
                    air={
                        'Ar': 0.0129,
                        'N2': 0.7553,
                        'CO2': 0.0004,
                        'O2': 0.2314
                    },
                    fuel_alias='myFuel',
                    air_alias='myAir',
                    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={
                            'myAir': 1,
                            'myFuel': 0,
                            'myFuel_fg': 0
                        })
        sf_cc.set_attr(T=20, fluid={'myAir': 0, 'myFuel': 1, 'myFuel_fg': 0})
        gt_fg.set_attr(p=1)

        # %% solving
        self.nw2.solve(mode='design')
Exemple #3
0
    def setup(self):
        """Set up simple refrigerator."""
        self.Tamb = 20
        self.pamb = 1
        fluids = ['R134a']
        self.nw = Network(fluids=fluids)
        self.nw.set_attr(p_unit='bar', T_unit='C', h_unit='kJ / kg')

        # create components
        va = Valve('expansion valve')
        cp = Compressor('compressor')
        cond = HeatExchangerSimple('condenser')
        eva = HeatExchangerSimple('evaporator')
        cc = CycleCloser('cycle closer')

        # create busses
        # power output bus
        self.power = Bus('power input')
        self.power.add_comps({'comp': cp, 'char': 1, 'base': 'bus'})
        # cooling bus
        self.cool = Bus('heat from fridge')
        self.cool.add_comps({'comp': eva})
        # heat input bus
        self.heat = Bus('heat to ambient')
        self.heat.add_comps({'comp': cond})
        self.nw.add_busses(self.power, self.cool, self.heat)

        # create connections
        cc_cp = Connection(cc, 'out1', cp, 'in1', label='from eva')
        cp_cond = Connection(cp, 'out1', cond, 'in1', label='to cond')
        cond_va = Connection(cond, 'out1', va, 'in1', label='from cond')
        va_eva = Connection(va, 'out1', eva, 'in1', label='to eva')
        eva_cc = Connection(eva, 'out1', cc, 'in1')
        self.nw.add_conns(cc_cp, cp_cond, cond_va, va_eva, eva_cc)

        # component parameters
        cp.set_attr(eta_s=0.9)
        cond.set_attr(pr=0.97)
        eva.set_attr(pr=0.96)

        # connection parameters
        cc_cp.set_attr(m=1, x=1, T=-25, fluid={'R134a': 1})
        cond_va.set_attr(x=0, T=self.Tamb + 1)

        # solve network
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
Exemple #4
0
    def setup(self):
        """Set up air compressor."""
        self.Tamb = 20
        self.pamb = 1
        fluids = ['Air']

        # compressor part
        self.nw = Network(fluids=fluids)
        self.nw.set_attr(p_unit='bar', T_unit='C', h_unit='kJ / kg')

        # components
        amb = Source('air intake')
        cp = Compressor('compressor')
        cooler = HeatExchangerSimple('cooling')
        cas = Sink('compressed air storage')

        # power input bus
        self.power_in = Bus('power input')
        self.power_in.add_comps({'comp': cp, 'char': 1, 'base': 'bus'})
        # compressed air bus (not sure about this!)
        self.cas_in = Bus('massflow into storage')
        self.cas_in.add_comps({'comp': cas}, {'comp': amb, 'base': 'bus'})
        self.nw.add_busses(self.power_in, self.cas_in)

        # create connections
        amb_cp = Connection(amb, 'out1', cp, 'in1')
        cp_cool = Connection(cp, 'out1', cooler, 'in1')
        cool_cas = Connection(cooler, 'out1', cas, 'in1')
        self.nw.add_conns(amb_cp, cp_cool, cool_cas)

        # component parameters
        cp.set_attr(eta_s=1)
        cooler.set_attr(pr=1)

        # connection parameters
        amb_cp.set_attr(m=2, T=self.Tamb, p=self.pamb, fluid={'Air': 1})
        cool_cas.set_attr(T=self.Tamb, p=10)

        # solve network
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
Exemple #5
0
def run_simple_heat_pump_model():
    nw = Network(['NH3'], T_unit='C', p_unit='bar', h_unit='kJ / kg')
    nw.set_attr(iterinfo=False)
    cp = Compressor('compressor')
    cc = CycleCloser('cycle_closer')
    cd = HeatExchangerSimple('condenser')
    va = Valve('expansion valve')
    ev = HeatExchangerSimple('evaporator')

    cc_cd = Connection(cc, 'out1', cd, 'in1')
    cd_va = Connection(cd, 'out1', va, 'in1')
    va_ev = Connection(va, 'out1', ev, 'in1')
    ev_cp = Connection(ev, 'out1', cp, 'in1')
    cp_cc = Connection(cp, 'out1', cc, 'in1')

    nw.add_conns(cc_cd, cd_va, va_ev, ev_cp, cp_cc)

    cd.set_attr(pr=0.95, Q=-1e6)
    ev.set_attr(pr=0.9)
    cp.set_attr(eta_s=0.9)

    cc_cd.set_attr(fluid={'NH3': 1})
    cd_va.set_attr(Td_bp=-5, T=85)
    ev_cp.set_attr(Td_bp=5, T=15)
    nw.solve('design')

    result_dict = {}
    result_dict.update({
        cp.label: cp.get_plotting_data()[1]
        for cp in nw.comps.index if cp.get_plotting_data() is not None
    })

    return result_dict
Exemple #6
0
def test_compressor_missing_char_parameter():
    """Compressor with invalid parameter for eta_s_char function."""
    nw = Network(['CH4'])
    so = Source('source')
    si = Sink('sink')
    instance = Compressor('compressor')
    c1 = Connection(so, 'out1', instance, 'in1')
    c2 = Connection(instance, 'out1', si, 'in1')
    nw.add_conns(c1, c2)
    instance.set_attr(eta_s_char={
        'func': CharLine([0, 1], [1, 2]), 'is_set': True, 'param': None})
    nw.solve('design', init_only=True)
    with raises(ValueError):
        instance.eta_s_char_func()
Exemple #7
0
    def test_Network_reader_deleted_chars(self):
        """Test import of network with missing characteristics."""
        self.setup_Network_tests()
        comp = Compressor('compressor')
        a = Connection(self.source, 'out1', comp, 'in1')
        b = Connection(comp, 'out1', self.sink, 'in1')
        self.nw.add_conns(a, b)
        self.nw.solve('design', init_only=True)
        self.nw.save('tmp')

        # # remove char_line and char_map folders
        os.unlink('tmp/components/char_line.csv')
        os.unlink('tmp/components/char_map.csv')

        # import network with missing files
        imported_nwk = load_network('tmp')
        imported_nwk.solve('design', init_only=True)
        msg = ('If the network import was successful the network check '
               'should have been successful, too, but it is not.')
        assert imported_nwk.checked, msg
        shutil.rmtree('./tmp', ignore_errors=True)
    def setup(self):
        """
        Full model validation of SEGS model in TESPy vs. EBSILON.

        Find original models at https://github.com/fwitte/SEGS_exergy.
        """
        # specification of ambient state
        self.pamb = 1.013
        self.Tamb = 25

        # setting up network
        self.nw = Network(fluids=['water', 'INCOMP::TVP1', 'air'])
        self.nw.set_attr(T_unit='C',
                         p_unit='bar',
                         h_unit='kJ / kg',
                         m_unit='kg / s',
                         s_unit="kJ / kgK")

        # components definition
        air_in = Source('Ambient air source', fkt_group='CW')
        air_out = Sink('Ambient air sink', fkt_group='CW')

        closer_pt = CycleCloser('Cycle closer pt', fkt_group='SF')
        pt = ParabolicTrough('Parabolic trough', fkt_group='SF')
        ptpump = Pump('HTF pump', fkt_group='SF')

        closer = CycleCloser('Cycle closer power cycle', fkt_group='SG')

        eco = HeatExchanger('Economizer', fkt_group='SG')
        eva = HeatExchanger('Evaporator', fkt_group='SG')
        sup = HeatExchanger('Superheater', fkt_group='SG')
        drum = Drum('Drum', fkt_group='SG')

        reh = HeatExchanger('Reheater', fkt_group='RH')

        hpt1 = Turbine('HP turbine 1', fkt_group='HPT')
        hpt2 = Turbine('HP turbine 2', fkt_group='HPT')
        lpt1 = Turbine('LP turbine 1', fkt_group='LPT')
        lpt2 = Turbine('LP turbine 2', fkt_group='LPT')
        lpt3 = Turbine('LP turbine 3', fkt_group='LPT')
        lpt4 = Turbine('LP turbine 4', fkt_group='LPT')
        lpt5 = Turbine('LP turbine 5', fkt_group='LPT')

        cond = Condenser('Condenser', fkt_group='CW')
        condpump = Pump('Condenser pump', fkt_group='CW')
        fwt = Merge('Feedwater tank', num_in=3, fkt_group='LPP')
        fwp = Pump('Feedwater pump', fkt_group='FWP')
        cwp = Pump('Cooling water pump', fkt_group='CW')
        closer_cw = CycleCloser('Cycle closer cw', fkt_group='CW')
        ct = HeatExchanger('Cooling tower', fkt_group='CW')
        fan = Compressor('Cooling tower fan', fkt_group='CW')

        sp1 = Splitter('Splitter 1', fkt_group='HPT')
        sp2 = Splitter('Splitter 2', fkt_group='HPT')
        sp3 = Splitter('Splitter 3', fkt_group='LPT')
        sp4 = Splitter('Splitter 4', fkt_group='LPT')
        sp5 = Splitter('Splitter 5', fkt_group='LPT')
        sp6 = Splitter('Splitter 6', fkt_group='LPT')
        sp7 = Splitter('Splitter 7', fkt_group='SF')

        m1 = Merge('Merge 1', fkt_group='CW')
        m2 = Merge('Merge 2', fkt_group='HPP')
        m3 = Merge('Merge 3', fkt_group='LPP')
        m4 = Merge('Merge 4', fkt_group='LPP')
        m5 = Merge('Merge 5', fkt_group='SF')

        v1 = Valve('Valve 1', fkt_group='HPP')
        v2 = Valve('Valve 2', fkt_group='HPP')
        v3 = Valve('Valve 3', fkt_group='LPP')
        v4 = Valve('Valve 4', fkt_group='LPP')
        v5 = Valve('Valve 5', fkt_group='LPP')

        hppre1 = Condenser('High pressure preheater 1', fkt_group='HPP')
        hppre2 = Condenser('High pressure preheater 2', fkt_group='HPP')
        hppre1_sub = HeatExchanger('High pressure preheater 1 subcooling',
                                   fkt_group='HPP')
        hppre2_sub = HeatExchanger('High pressure preheater 2 subcooling',
                                   fkt_group='HPP')

        lppre1 = Condenser('Low pressure preheater 1', fkt_group='LPP')
        lppre2 = Condenser('Low pressure preheater 2', fkt_group='LPP')
        lppre3 = Condenser('Low pressure preheater 3', fkt_group='LPP')
        lppre1_sub = HeatExchanger('Low pressure preheater 1 subcooling',
                                   fkt_group='LPP')
        lppre2_sub = HeatExchanger('Low pressure preheater 2 subcooling',
                                   fkt_group='LPP')
        lppre3_sub = HeatExchanger('Low pressure preheater 3 subcooling',
                                   fkt_group='LPP')

        # connections definition
        # power cycle
        c1 = Connection(sup, 'out2', closer, 'in1', label='1')
        c2 = Connection(closer, 'out1', hpt1, 'in1', label='2')
        c3 = Connection(hpt1, 'out1', sp1, 'in1', label='3')
        c4 = Connection(sp1, 'out1', hpt2, 'in1', label='4')
        c5 = Connection(hpt2, 'out1', sp2, 'in1', label='5')
        c6 = Connection(sp2, 'out1', reh, 'in2', label='6')
        c7 = Connection(reh, 'out2', lpt1, 'in1', label='7')
        c8 = Connection(lpt1, 'out1', sp3, 'in1', label='8')
        c9 = Connection(sp3, 'out1', lpt2, 'in1', label='9')
        c10 = Connection(lpt2, 'out1', sp4, 'in1', label='10')
        c11 = Connection(sp4, 'out1', lpt3, 'in1', label='11')
        c12 = Connection(lpt3, 'out1', sp5, 'in1', label='12')
        c13 = Connection(sp5, 'out1', lpt4, 'in1', label='13')
        c14 = Connection(lpt4, 'out1', sp6, 'in1', label='14')
        c15 = Connection(sp6, 'out1', lpt5, 'in1', label='15')
        c16 = Connection(lpt5, 'out1', m1, 'in1', label='16')
        c17 = Connection(m1, 'out1', cond, 'in1', label='17')
        c18 = Connection(cond, 'out1', condpump, 'in1', label='18')
        c19 = Connection(condpump, 'out1', lppre1, 'in2', label='19')
        # c19 = Connection(condpump, 'out1', lppre1_sub, 'in2', label='19')
        # c20 = Connection(lppre1_sub, 'out2', lppre1, 'in2', label='20')
        c21 = Connection(lppre1, 'out2', lppre2, 'in2', label='21')
        # c21 = Connection(lppre1, 'out2', lppre2_sub, 'in2', label='21')
        # c22 = Connection(lppre2_sub, 'out2', lppre2, 'in2', label='22')
        c23 = Connection(lppre2, 'out2', lppre3, 'in2', label='23')
        # c23 = Connection(lppre2, 'out2', lppre3_sub, 'in2', label='23')
        # c24 = Connection(lppre3_sub, 'out2', lppre3, 'in2', label='24')
        c25 = Connection(lppre3, 'out2', fwt, 'in1', label='25')
        c26 = Connection(fwt, 'out1', fwp, 'in1', label='26')
        c27 = Connection(fwp, 'out1', hppre1, 'in2', label='27')
        c29 = Connection(hppre1, 'out2', hppre2, 'in2', label='29')
        c31 = Connection(hppre2, 'out2', eco, 'in2', label='31')

        c36 = Connection(sp1, 'out2', hppre2, 'in1', label='36')
        c37 = Connection(hppre2, 'out1', v1, 'in1', label='37')
        c39 = Connection(v1, 'out1', m2, 'in2', label='39')
        c40 = Connection(sp2, 'out2', m2, 'in1', label='40')
        c41 = Connection(m2, 'out1', hppre1, 'in1', label='41')
        c42 = Connection(hppre1, 'out1', v2, 'in1', label='42')
        c44 = Connection(v2, 'out1', fwt, 'in2', label='44')
        c45 = Connection(sp3, 'out2', fwt, 'in3', label='45')
        c46 = Connection(sp4, 'out2', lppre3, 'in1', label='46')
        c47 = Connection(lppre3, 'out1', v3, 'in1', label='47')
        # c47 = Connection(lppre3, 'out1', lppre3_sub, 'in1', label='47')
        # c48 = Connection(lppre3_sub, 'out1', v3, 'in1', label='48')
        c49 = Connection(v3, 'out1', m3, 'in1', label='49')
        c50 = Connection(sp5, 'out2', m3, 'in2', label='50')
        c51 = Connection(m3, 'out1', lppre2, 'in1', label='51')
        c52 = Connection(lppre2, 'out1', v4, 'in1', label='52')
        # c52 = Connection(lppre2, 'out1', lppre2_sub, 'in1', label='52')
        # c53 = Connection(lppre2_sub, 'out1', v4, 'in1', label='53')
        c54 = Connection(v4, 'out1', m4, 'in2', label='54')
        c55 = Connection(sp6, 'out2', m4, 'in1', label='55')
        c56 = Connection(m4, 'out1', lppre1, 'in1', label='56')
        c57 = Connection(lppre1, 'out1', v5, 'in1', label='57')
        # c57 = Connection(lppre1, 'out1', lppre1_sub, 'in1', label='57')
        # c58 = Connection(lppre1_sub, 'out1', v5, 'in1', label='58')
        c59 = Connection(v5, 'out1', m1, 'in2', label='59')

        # components from subsystem
        c32 = Connection(eco, 'out2', drum, 'in1', label='32')
        c33 = Connection(drum, 'out1', eva, 'in2', label='33')
        c34 = Connection(eva, 'out2', drum, 'in2', label='34')
        c35 = Connection(drum, 'out2', sup, 'in2', label='35')
        c73 = Connection(sup, 'out1', eva, 'in1', label='73')
        c74 = Connection(eva, 'out1', eco, 'in1', label='74')

        # cooling water
        c60 = Connection(cond, 'out2', closer_cw, 'in1', label='60')
        c61 = Connection(closer_cw, 'out1', ct, 'in1', label='61')
        c62 = Connection(ct, 'out1', cwp, 'in1', label='62')
        c63 = Connection(cwp, 'out1', cond, 'in2', label='63')

        # cooling tower
        c64 = Connection(air_in, 'out1', fan, 'in1', label='64')
        c65 = Connection(fan, 'out1', ct, 'in2', label='65')
        c66 = Connection(ct, 'out2', air_out, 'in1', label='66')

        # parabolic trough cycle
        c70 = Connection(pt, 'out1', closer_pt, 'in1', label='67')
        c71 = Connection(closer_pt, 'out1', sp7, 'in1', label='71')
        c72 = Connection(sp7, 'out1', sup, 'in1', label='72')
        c75 = Connection(eco, 'out1', m5, 'in1', label='75')
        c76 = Connection(sp7, 'out2', reh, 'in1', label='76')
        c77 = Connection(reh, 'out1', m5, 'in2', label='77')
        c78 = Connection(m5, 'out1', ptpump, 'in1', label='78')
        c79 = Connection(ptpump, 'out1', pt, 'in1', label='79')

        # add connections to network
        self.nw.add_conns(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12,
                          c13, c14, c15, c16, c17, c18, c19, c21, c23, c25,
                          c26, c27, c29, c31, c32, c33, c34, c35, c36, c37,
                          c39, c40, c41, c42, c44, c45, c46, c47, c49, c50,
                          c51, c52, c54, c55, c56, c57, c59, c60, c61, c62,
                          c63, c64, c65, c66, c70, c71, c72, c73, c74, c75,
                          c76, c77, c78, c79)

        # power bus
        power = Bus('total output power')
        power.add_comps({
            'comp': hpt1,
            'char': 0.97,
            'base': 'component'
        }, {
            'comp': hpt2,
            'char': 0.97,
            'base': 'component'
        }, {
            'comp': lpt1,
            'char': 0.97,
            'base': 'component'
        }, {
            'comp': lpt2,
            'char': 0.97,
            'base': 'component'
        }, {
            'comp': lpt3,
            'char': 0.97,
            'base': 'component'
        }, {
            'comp': lpt4,
            'char': 0.97,
            'base': 'component'
        }, {
            'comp': lpt5,
            'char': 0.97,
            'base': 'component'
        }, {
            'comp': fwp,
            'char': 0.95,
            'base': 'bus'
        }, {
            'comp': condpump,
            'char': 0.95,
            'base': 'bus'
        }, {
            'comp': ptpump,
            'char': 0.95,
            'base': 'bus'
        }, {
            'comp': cwp,
            'char': 0.95,
            'base': 'bus'
        }, {
            'comp': fan,
            'char': 0.95,
            'base': 'bus'
        })

        heat_input_bus = Bus('heat input')
        heat_input_bus.add_comps({'comp': pt, 'base': 'bus'})

        exergy_loss_bus = Bus('exergy loss')
        exergy_loss_bus.add_comps({
            'comp': air_in,
            'base': 'bus'
        }, {'comp': air_out})

        self.nw.add_busses(power, heat_input_bus, exergy_loss_bus)

        # component parameters
        pt.set_attr(doc=0.95,
                    aoi=0,
                    Tamb=25,
                    A='var',
                    eta_opt=0.73,
                    c_1=0.00496,
                    c_2=0.000691,
                    E=1000,
                    iam_1=1,
                    iam_2=1)

        ptpump.set_attr(eta_s=0.6)

        eco.set_attr()
        eva.set_attr(ttd_l=5)
        sup.set_attr()

        hpt1.set_attr(eta_s=0.8376)
        hpt2.set_attr(eta_s=0.8463)
        lpt1.set_attr(eta_s=0.8623)
        lpt2.set_attr(eta_s=0.917)
        lpt3.set_attr(eta_s=0.9352)
        lpt4.set_attr(eta_s=0.88)
        lpt5.set_attr(eta_s=0.6445)

        cond.set_attr(pr1=1, pr2=0.9, ttd_u=5)
        condpump.set_attr(eta_s=0.7)
        fwp.set_attr(eta_s=0.7)
        cwp.set_attr(eta_s=0.7)
        ct.set_attr(pr1=0.95)
        fan.set_attr(eta_s=0.6)

        lppre1.set_attr(pr1=1, ttd_u=5)
        lppre2.set_attr(pr1=1, ttd_u=5)
        lppre3.set_attr(pr1=1, ttd_u=5)
        hppre1.set_attr(pr1=1, ttd_u=5)
        hppre2.set_attr(pr1=1, ttd_u=5)

        lppre1_sub.set_attr(pr1=1, pr2=1, ttd_l=10)
        lppre2_sub.set_attr(pr1=1, pr2=1, ttd_l=10)
        lppre3_sub.set_attr(pr1=1, pr2=1, ttd_l=10)
        hppre1_sub.set_attr(pr1=1, pr2=1, ttd_l=10)
        hppre2_sub.set_attr(pr1=1, pr2=1, ttd_l=10)

        # connection parameters
        # parabolic trough cycle
        c70.set_attr(fluid={'TVP1': 1, 'water': 0, 'air': 0}, T=390, p=23.304)
        c76.set_attr(m=Ref(c70, 0.1284, 0))
        c73.set_attr(p=22.753)
        c74.set_attr(p=21.167)
        c78.set_attr(p=20.34)
        c79.set_attr(p=41.024)

        # cooling water
        c62.set_attr(fluid={
            'TVP1': 0,
            'water': 1,
            'air': 0
        },
                     T=30,
                     p=self.pamb)
        # cooling tower
        c64.set_attr(fluid={
            'water': 0,
            'TVP1': 0,
            'air': 1
        },
                     p=self.pamb,
                     T=self.Tamb)
        c65.set_attr(p=self.pamb + 0.0005)
        c66.set_attr(p=self.pamb, T=30)
        # power cycle
        c32.set_attr(Td_bp=-2)
        c34.set_attr(x=0.5)
        c1.set_attr(fluid={'water': 1, 'TVP1': 0, 'air': 0}, p=100, T=371)

        # steam generator pressure values
        c31.set_attr(p=103.56)
        c35.set_attr(p=103.42)

        # turbine pressure values
        c3.set_attr(p=33.61, m=38.969)
        c5.set_attr(p=18.58)
        c7.set_attr(p=17.1, T=371)
        c8.set_attr(p=7.98)
        c10.set_attr(p=2.73)
        c12.set_attr(p=0.96)
        c14.set_attr(p=0.29)

        # preheater pressure values
        c19.set_attr(p=14.755, state='l')
        c21.set_attr(p=9.9975, state='l')
        c23.set_attr(p=8.7012, state='l')
        c25.set_attr(state='l')

        c27.set_attr(p=125)
        c29.set_attr(p=112)

        # condensation
        c16.set_attr(p=0.08)

        # feedwater tank
        c26.set_attr(x=0)

        # a stable solution is generated for parts of the network
        self.nw.solve(mode='design')

        self.nw.del_conns(c19, c21, c23, c27, c29, c37, c42, c47, c52, c57)

        c19 = Connection(condpump, 'out1', lppre1_sub, 'in2', label='19')
        c20 = Connection(lppre1_sub, 'out2', lppre1, 'in2', label='20')
        c21 = Connection(lppre1, 'out2', lppre2_sub, 'in2', label='21')
        c22 = Connection(lppre2_sub, 'out2', lppre2, 'in2', label='22')
        c23 = Connection(lppre2, 'out2', lppre3_sub, 'in2', label='23')
        c24 = Connection(lppre3_sub, 'out2', lppre3, 'in2', label='24')

        c27 = Connection(fwp, 'out1', hppre1_sub, 'in2', label='27')
        c28 = Connection(hppre1_sub, 'out2', hppre1, 'in2', label='28')
        c29 = Connection(hppre1, 'out2', hppre2_sub, 'in2', label='29')
        c30 = Connection(hppre2_sub, 'out2', hppre2, 'in2', label='30')

        c37 = Connection(hppre2, 'out1', hppre2_sub, 'in1', label='37')
        c38 = Connection(hppre2_sub, 'out1', v1, 'in1', label='38')
        c42 = Connection(hppre1, 'out1', hppre1_sub, 'in1', label='42')
        c43 = Connection(hppre1_sub, 'out1', v2, 'in1', label='43')

        c47 = Connection(lppre3, 'out1', lppre3_sub, 'in1', label='47')
        c48 = Connection(lppre3_sub, 'out1', v3, 'in1', label='48')
        c52 = Connection(lppre2, 'out1', lppre2_sub, 'in1', label='52')
        c53 = Connection(lppre2_sub, 'out1', v4, 'in1', label='53')
        c57 = Connection(lppre1, 'out1', lppre1_sub, 'in1', label='57')
        c58 = Connection(lppre1_sub, 'out1', v5, 'in1', label='58')

        self.nw.add_conns(c19, c20, c21, c22, c23, c24, c27, c28, c29, c30,
                          c37, c38, c42, c43, c47, c48, c52, c53, c57, c58)

        # specification of missing parameters
        c19.set_attr(p=14.755)
        c21.set_attr(p=9.9975, state='l')
        c23.set_attr(p=8.7012, state='l')
        c27.set_attr(p=125)
        c29.set_attr(p=112)

        # solve final state
        self.nw.solve(mode='design')
Exemple #9
0
nw = Network(fluids=['water', 'R410A'],
             T_unit='C',
             p_unit='bar',
             h_unit='kJ / kg',
             m_unit='kg / s')

# %% components

cc = CycleCloser('cycle closer')

# heat pump system
cd = Condenser('condenser')
va = Valve('valve')
ev = HeatExchanger('evaporator')
cp = Compressor('compressor')

# geothermal heat collector
gh_in = Source('ground heat feed flow')
gh_out = Sink('ground heat return flow')
ghp = Pump('ground heat loop pump')

# heating system
hs_feed = Sink('heating system feed flow')
hs_ret = Source('heating system return flow')
hsp = Pump('heating system pump')

# %% connections

# heat pump system
cc_cd = Connection(cc, 'out1', cd, 'in1')
Exemple #10
0
sto_ff = Sink('storage feed')

# consumer system
cd = Condenser('condenser')

# evaporator system

valve = Valve('valve')
dr = Drum('drum')
ev = HeatExchanger('evaporator')
su = HeatExchanger('superheater')
pump_ev = Pump('evaporator reciculation pump')

# compressor-system

cp = Compressor('compressor 1')

# %% connections

# heating system interface

sys_IF = Connection(sys_rf, 'out1', cd, 'in2')
IF_sys = Connection(cd, 'out2', sys_ff, 'in1')

nw.add_conns(sys_IF, IF_sys)

# condenser, expansion valve

c_in_cd = Connection(close_cycle, 'out1', cd, 'in1')
cd_valve = Connection(cd, 'out1', valve, 'in1')
Exemple #11
0
    def setup(self):
        # %% network setup
        self.nw = Network(fluids=['water', 'NH3'],
                          T_unit='C',
                          p_unit='bar',
                          h_unit='kJ / kg',
                          m_unit='kg / s')

        # %% components
        # sources & sinks
        cc_coolant = CycleCloser('coolant cycle closer')
        cc_consumer = CycleCloser('consumer cycle closer')
        amb_in = Source('source ambient')
        amb_out = Sink('sink ambient')
        ic_in = Source('source intercool')
        ic_out = Sink('sink intercool')

        # consumer system
        cd = HeatExchanger('condenser')
        rp = Pump('recirculation pump')
        cons = HeatExchangerSimple('consumer')

        # evaporator system
        va = Valve('valve')
        dr = Drum('drum')
        ev = HeatExchanger('evaporator')
        su = HeatExchanger('superheater')
        pu = Pump('pump evaporator')

        # compressor-system
        cp1 = Compressor('compressor 1')
        cp2 = Compressor('compressor 2')
        he = HeatExchanger('intercooler')

        # busses
        self.power = Bus('total compressor power')
        self.power.add_comps({
            'comp': cp1,
            'base': 'bus'
        }, {
            'comp': cp2,
            'base': 'bus'
        })
        self.heat = Bus('total delivered heat')
        self.heat.add_comps({'comp': cd, 'char': -1})
        self.nw.add_busses(self.power, self.heat)

        # %% connections
        # consumer system
        c_in_cd = Connection(cc_coolant, 'out1', cd, 'in1')

        cb_rp = Connection(cc_consumer, 'out1', rp, 'in1')
        rp_cd = Connection(rp, 'out1', cd, 'in2')
        self.cd_cons = Connection(cd, 'out2', cons, 'in1')
        cons_cf = Connection(cons, 'out1', cc_consumer, 'in1')

        self.nw.add_conns(c_in_cd, cb_rp, rp_cd, self.cd_cons, cons_cf)

        # connection condenser - evaporator system
        cd_va = Connection(cd, 'out1', va, 'in1')

        self.nw.add_conns(cd_va)

        # evaporator system
        va_dr = Connection(va, 'out1', dr, 'in1')
        dr_pu = Connection(dr, 'out1', pu, 'in1')
        pu_ev = Connection(pu, 'out1', ev, 'in2')
        ev_dr = Connection(ev, 'out2', dr, 'in2')
        dr_su = Connection(dr, 'out2', su, 'in2')

        self.nw.add_conns(va_dr, dr_pu, pu_ev, ev_dr, dr_su)

        self.amb_in_su = Connection(amb_in, 'out1', su, 'in1')
        su_ev = Connection(su, 'out1', ev, 'in1')
        ev_amb_out = Connection(ev, 'out1', amb_out, 'in1')

        self.nw.add_conns(self.amb_in_su, su_ev, ev_amb_out)

        # connection evaporator system - compressor system
        su_cp1 = Connection(su, 'out2', cp1, 'in1')

        self.nw.add_conns(su_cp1)

        # compressor-system
        cp1_he = Connection(cp1, 'out1', he, 'in1')
        he_cp2 = Connection(he, 'out1', cp2, 'in1')
        cp2_c_out = Connection(cp2, 'out1', cc_coolant, 'in1')

        ic_in_he = Connection(ic_in, 'out1', he, 'in2')
        he_ic_out = Connection(he, 'out2', ic_out, 'in1')

        self.nw.add_conns(cp1_he, he_cp2, ic_in_he, he_ic_out, cp2_c_out)

        # %% component parametrization
        # condenser system
        x = np.array([
            0, 0.0625, 0.125, 0.1875, 0.25, 0.3125, 0.375, 0.4375, 0.5, 0.5625,
            0.6375, 0.7125, 0.7875, 0.9, 0.9875, 1, 1.0625, 1.125, 1.175,
            1.2125, 1.2375, 1.25
        ])
        y = np.array([
            0.0076, 0.1390, 0.2731, 0.4003, 0.5185, 0.6263, 0.7224, 0.8056,
            0.8754, 0.9312, 0.9729, 1.0006, 1.0203, 1.0158, 1.0051, 1.0000,
            0.9746, 0.9289, 0.8832, 0.8376, 0.7843, 0.7614
        ])
        rp.set_attr(eta_s=0.8,
                    design=['eta_s'],
                    offdesign=['eta_s_char'],
                    eta_s_char={
                        'char_func': CharLine(x, y),
                        'param': 'm'
                    })
        cons.set_attr(pr=1, design=['pr'], offdesign=['zeta'])

        # evaporator system
        x = np.linspace(0, 2.5, 26)
        y = np.array([
            0.000, 0.164, 0.283, 0.389, 0.488, 0.581, 0.670, 0.756, 0.840,
            0.921, 1.000, 1.078, 1.154, 1.228, 1.302, 1.374, 1.446, 1.516,
            1.585, 1.654, 1.722, 1.789, 1.855, 1.921, 1.986, 2.051
        ])
        kA_char1 = {'char_func': CharLine(x, y), 'param': 'm'}

        x = np.array([
            0.0100, 0.0400, 0.0700, 0.1100, 0.1500, 0.2000, 0.2500, 0.3000,
            0.3500, 0.4000, 0.4500, 0.5000, 0.5500, 0.6000, 0.6500, 0.7000,
            0.7500, 0.8000, 0.8500, 0.9000, 0.9500, 1.0000, 1.5000, 2.0000
        ])

        y = np.array([
            0.0185, 0.0751, 0.1336, 0.2147, 0.2997, 0.4118, 0.5310, 0.6582,
            0.7942, 0.9400, 0.9883, 0.9913, 0.9936, 0.9953, 0.9966, 0.9975,
            0.9983, 0.9988, 0.9992, 0.9996, 0.9998, 1.0000, 1.0008, 1.0014
        ])
        kA_char2 = {'char_func': CharLine(x, y), 'param': 'm'}
        ev.set_attr(pr1=1,
                    pr2=.999,
                    ttd_l=5,
                    design=['ttd_l'],
                    offdesign=['kA_char'],
                    kA_char1=kA_char1,
                    kA_char2=kA_char2)

        # no kA modification for hot side!
        x = np.array([0, 1])
        y = np.array([1, 1])
        kA_char1 = {'char_func': CharLine(x, y), 'param': 'm'}

        # characteristic line for superheater kA
        x = np.array(
            [0, 0.045, 0.136, 0.244, 0.43, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2])
        y = np.array(
            [0, 0.037, 0.112, 0.207, 0.5, 0.8, 0.85, 0.9, 0.95, 1, 1.04, 1.07])
        kA_char2 = {'char_func': CharLine(x, y), 'param': 'm'}
        su.set_attr(kA_char1=kA_char1,
                    kA_char2=kA_char2,
                    offdesign=['zeta1', 'zeta2', 'kA_char'])

        x = np.array([
            0, 0.0625, 0.125, 0.1875, 0.25, 0.3125, 0.375, 0.4375, 0.5, 0.5625,
            0.6375, 0.7125, 0.7875, 0.9, 0.9875, 1, 1.0625, 1.125, 1.175,
            1.2125, 1.2375, 1.25
        ])
        y = np.array([
            0.0076, 0.1390, 0.2731, 0.4003, 0.5185, 0.6263, 0.7224, 0.8056,
            0.8754, 0.9312, 0.9729, 1.0006, 1.0203, 1.0158, 1.0051, 1.0000,
            0.9746, 0.9289, 0.8832, 0.8376, 0.7843, 0.7614
        ])
        pu.set_attr(eta_s=0.8,
                    design=['eta_s'],
                    offdesign=['eta_s_char'],
                    eta_s_char={
                        'char_func': CharLine(x, y),
                        'param': 'm'
                    })

        # compressor system
        x = np.array([0, 0.4, 1, 1.2])
        y = np.array([0.5, 0.9, 1, 1.1])

        cp1.set_attr(eta_s=0.8,
                     design=['eta_s'],
                     offdesign=['eta_s_char'],
                     eta_s_char={
                         'char_func': CharLine(x, y),
                         'param': 'm'
                     })
        cp2.set_attr(eta_s=0.8,
                     design=['eta_s'],
                     offdesign=['eta_s_char'],
                     eta_s_char={
                         'char_func': CharLine(x, y),
                         'param': 'm'
                     })

        # characteristic line for intercooler kA
        x = np.linspace(0, 2.5, 26)
        y = np.array([
            0.0000, 0.2455, 0.3747, 0.4798, 0.5718, 0.6552, 0.7323, 0.8045,
            0.8727, 0.9378, 1.0000, 1.0599, 1.1176, 1.1736, 1.2278, 1.2806,
            1.3320, 1.3822, 1.4313, 1.4792, 1.5263, 1.5724, 1.6176, 1.6621,
            1.7058, 1.7488
        ])
        kA_char1 = {'char_func': CharLine(x, y), 'param': 'm'}

        x = np.linspace(0, 2.5, 26)
        y = np.array([
            0.000, 0.164, 0.283, 0.389, 0.488, 0.581, 0.670, 0.756, 0.840,
            0.921, 1.000, 1.078, 1.154, 1.228, 1.302, 1.374, 1.446, 1.516,
            1.585, 1.654, 1.722, 1.789, 1.855, 1.921, 1.986, 2.051
        ])
        kA_char2 = {'char_func': CharLine(x, y), 'param': 'm'}

        he.set_attr(kA_char1=kA_char1,
                    kA_char2=kA_char2,
                    offdesign=['zeta1', 'zeta2', 'kA_char'])

        # characteristic line for condenser kA
        x = np.linspace(0, 2.5, 26)
        y = np.array([
            0.0000, 0.2455, 0.3747, 0.4798, 0.5718, 0.6552, 0.7323, 0.8045,
            0.8727, 0.9378, 1.0000, 1.0599, 1.1176, 1.1736, 1.2278, 1.2806,
            1.3320, 1.3822, 1.4313, 1.4792, 1.5263, 1.5724, 1.6176, 1.6621,
            1.7058, 1.7488
        ])
        kA_char1 = {'char_func': CharLine(x, y), 'param': 'm'}

        x = np.linspace(0, 2.5, 26)
        y = np.array([
            0.000, 0.164, 0.283, 0.389, 0.488, 0.581, 0.670, 0.756, 0.840,
            0.921, 1.000, 1.078, 1.154, 1.228, 1.302, 1.374, 1.446, 1.516,
            1.585, 1.654, 1.722, 1.789, 1.855, 1.921, 1.986, 2.051
        ])
        kA_char2 = {'char_func': CharLine(x, y), 'param': 'm'}

        cd.set_attr(kA_char1=kA_char1,
                    kA_char2=kA_char2,
                    pr2=0.9998,
                    design=['pr2'],
                    offdesign=['zeta2', 'kA_char'])

        # %% connection parametrization
        # condenser system
        c_in_cd.set_attr(fluid={'water': 0, 'NH3': 1}, p=60)
        rp_cd.set_attr(T=60, fluid={'water': 1, 'NH3': 0}, p=10)
        self.cd_cons.set_attr(T=105)
        cd_va.set_attr(p=Ref(c_in_cd, 1, -0.01), Td_bp=-5, design=['Td_bp'])

        # evaporator system cold side
        pu_ev.set_attr(m=Ref(va_dr, 10, 0), p0=5)
        dr_su.set_attr(p0=5, T=5)
        su_cp1.set_attr(p=Ref(dr_su, 1, -0.05), Td_bp=5, design=['Td_bp', 'p'])

        # evaporator system hot side
        self.amb_in_su.set_attr(m=20, T=12, p=1, fluid={'water': 1, 'NH3': 0})
        su_ev.set_attr(p=Ref(self.amb_in_su, 1, -0.001), design=['p'])
        ev_amb_out.set_attr()

        # compressor-system
        cp1_he.set_attr(p=15)
        he_cp2.set_attr(T=40, p=Ref(cp1_he, 1, -0.01), design=['T', 'p'])
        ic_in_he.set_attr(p=1, T=20, m=5, fluid={'water': 1, 'NH3': 0})
        he_ic_out.set_attr(p=Ref(ic_in_he, 1, -0.002), design=['p'])
Exemple #12
0
    def __init__(self, working_fluid):
        """Set up model."""
        self.working_fluid = working_fluid
        fluids = ['water', self.working_fluid, 'air']
        self.nw = Network(fluids=fluids)
        self.nw.set_attr(p_unit='bar', T_unit='C', h_unit='kJ / kg')

        # geo parameters

        self.geo_mass_flow = 200
        geo_steam_share = 0.1
        self.T_brine_in = 140

        # ambient parameters

        self.T_amb = 5
        self.p_amb = 0.6

        # main components

        geo_steam = Source('geosteam source')
        geo_brine = Source('geobrine source')
        geo_reinjection = Sink('re-injection')

        air_in = Source('air source')
        air_out = Sink('air sink')
        air_fan = Compressor('air fan')
        air_cond = Condenser('condenser')

        orc_cc = CycleCloser('orc cycle closer')

        evap_splitter = Splitter('splitter evaporation')
        evap_merge = Merge('merge evaporation')
        evap_steam = Condenser('geosteam evaporator')
        evap_brine = HeatExchanger('geobrine evaporator')
        dr = Drum('drum')
        geo_merge = Merge('merge brine')

        pre = HeatExchanger('preheater')
        feed_working_fluid_pump = Pump('feed pump')

        tur = Turbine('turbine')

        ihe = HeatExchanger('internal heat exchanger')

        # busses
        net_power = Bus('net power output')
        net_power.add_comps(
            {'comp': tur, 'char': 0.97},
            {'comp': feed_working_fluid_pump, 'char': 0.97, 'base': 'bus'},
            {'comp': air_fan, 'char': 0.97, 'base': 'bus'}
        )

        ORC_power_bus = Bus('cycle gross power output')
        ORC_power_bus.add_comps(
            {'comp': tur}, {'comp': feed_working_fluid_pump}
        )

        geothermal_bus = Bus('thermal input')
        geothermal_bus.add_comps(
            {'comp': pre, 'char': -1}, {'comp': evap_brine, 'char': -1},
            {'comp': evap_steam, 'char': -1}
        )

        self.nw.add_busses(net_power, ORC_power_bus, geothermal_bus)

        # turbine to condenser
        c1 = Connection(orc_cc, 'out1', tur, 'in1', label='1')
        c2 = Connection(tur, 'out1', ihe, 'in1', label='2')
        c3 = Connection(ihe, 'out1', air_cond, 'in1', label='3')
        self.nw.add_conns(c1, c2, c3)

        # condenser to steam generator
        c4 = Connection(air_cond, 'out1', feed_working_fluid_pump, 'in1', label='4')
        c5 = Connection(feed_working_fluid_pump, 'out1', ihe, 'in2', label='5')
        self.nw.add_conns(c4, c5)

        # steam generator
        c6 = Connection(ihe, 'out2', pre, 'in2', label='6')
        c7 = Connection(pre, 'out2', dr, 'in1', label='7')
        c8 = Connection(dr, 'out1', evap_splitter, 'in1', label='8')
        c9 = Connection(evap_splitter, 'out2', evap_steam, 'in2', label='9')
        c10 = Connection(evap_steam, 'out2', evap_merge, 'in2', label='10')
        c11 = Connection(evap_splitter, 'out1', evap_brine, 'in2', label='11')
        c12 = Connection(evap_brine, 'out2', evap_merge, 'in1', label='12')
        c13 = Connection(evap_merge, 'out1', dr, 'in2', label='13')
        c0 = Connection(dr, 'out2', orc_cc, 'in1', label='0')
        self.nw.add_conns(c6, c7, c8, c11, c9, c12, c10, c13, c0)

        # condenser cold side
        c20 = Connection(air_in, 'out1', air_fan, 'in1', label='20')
        c21 = Connection(air_fan, 'out1', air_cond, 'in2', label='21')
        c22 = Connection(air_cond, 'out2', air_out, 'in1', label='22')
        self.nw.add_conns(c20, c21, c22)

        # geo source
        c30 = Connection(geo_steam, 'out1', evap_steam, 'in1', label='30')
        c31 = Connection(evap_steam, 'out1',  geo_merge, 'in1', label='31')
        c32 = Connection(geo_brine, 'out1', geo_merge, 'in2', label='32')
        c33 = Connection(geo_merge, 'out1', evap_brine, 'in1', label='33')
        self.nw.add_conns(c30, c31, c32, c33)

        c34 = Connection(evap_brine, 'out1', pre, 'in1', label='34')
        c35 = Connection(pre, 'out1', geo_reinjection, 'in1', label='35')
        self.nw.add_conns(c34, c35)

        # generate a set of stable starting values of every working fluid
        # fluid settings
        c6.set_attr(fluid={self.working_fluid: 1.0, 'air': 0.0, 'water': 0.0})
        c20.set_attr(fluid={self.working_fluid: 0.0, 'air': 1.0, 'water': 0.0})
        c30.set_attr(fluid={self.working_fluid: 0.0, 'air': 0.0, 'water': 1.0})
        c32.set_attr(fluid={self.working_fluid: 0.0, 'air': 0.0, 'water': 1.0})

        # connection parameters
        p0 = PSI('P', 'T', self.T_brine_in + 273.15, 'Q', 1, self.working_fluid)
        c1.set_attr(p0=p0 / 1e5)
        ws_stable_h0 = (
            PSI('H', 'T', self.T_amb + 273.15, 'Q', 1, self.working_fluid) +
            0.5 * (
                PSI('H', 'T', self.T_brine_in + 273.15, 'Q', 1, self.working_fluid) -
                PSI('H', 'T', self.T_amb + 273.15, 'Q', 1, self.working_fluid)
            )
        ) / 1e3
        c2.set_attr(h=ws_stable_h0)
        p0 = PSI('P', 'T', self.T_amb + 273.15, 'Q', 1, self.working_fluid)
        c3.set_attr(Td_bp=5, design=['Td_bp'], p0=p0 / 1e5)
        c5.set_attr(h=Ref(c4, 1, 1))

        # steam generator
        c30.set_attr(
            m=self.geo_mass_flow * geo_steam_share,
            T=self.T_brine_in, x=1, p0=5)
        c32.set_attr(
            m=self.geo_mass_flow * (1 - geo_steam_share),
            T=self.T_brine_in, x=0)

        c13.set_attr()
        c12.set_attr(x=0.5)
        c10.set_attr(x=0.5, design=['x'])
        c34.set_attr(h=Ref(c33, 1, -50))

        c7.set_attr(Td_bp=-2)

        # main condenser
        c20.set_attr(p=self.p_amb, T=self.T_amb)
        c22.set_attr(T=self.T_amb + 15, p=self.p_amb)

        # component parameters
        # condensing
        ihe.set_attr(pr1=0.98, pr2=0.98)
        air_cond.set_attr(pr1=1, pr2=0.995, ttd_u=10)
        air_fan.set_attr(eta_s=0.6)

        # steam generator
        evap_brine.set_attr(pr1=0.98, ttd_l=8)
        pre.set_attr(pr1=0.98, pr2=0.98)

        self.nw.set_attr(iterinfo=False)
        self.nw.solve('design')
        self.nw.save('stable_' + self.working_fluid)

        # specify actual parameters
        tur.set_attr(eta_s=0.9)
        feed_working_fluid_pump.set_attr(eta_s=0.75)
        c2.set_attr(h=None)
        c5.set_attr(h=None)
        c34.set_attr(h=None, T=Ref(c33, 1, -10))

        self.nw.solve('design')
        c22.set_attr(T=None)
        c3.set_attr(Td_bp=None)

        self.ude_IHE_size = UserDefinedEquation(
            label='ihe deshuperheat ratio',
            func=desuperheat, deriv=desuperheat_deriv,
            latex={
                'equation':
                    r'0 = h_3 - h_2 - x_\mathrm{IHE} \cdot \left(h_3 -'
                    r'h\left(p_2, T_5 + \Delta T_\mathrm{t,u,min} \right)'
                    r'\right)'},
            conns=[
                self.nw.get_conn('2'),
                self.nw.get_conn('3'),
                self.nw.get_conn('5')],
            params={'distance': 0.0, 'ttd_min': 2}
        )
        if self.nw.lin_dep or self.nw.res[-1] > 1e-3:
            msg = 'No stable solution found.'
            raise TESPyNetworkError(msg)
        print(
            'Generated stable starting values for working fluid ' +
            self.working_fluid + '.')
Exemple #13
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])

        # %% components
        amb = Source('ambient')
        sf = Source('fuel')
        cc = CombustionChamber('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 = CharLine(x=x, y=y)
        self.motor_comp_based = CharLine(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 = CharLine(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 #14
0
    def test_Compressor(self):
        """Test component properties of compressors."""
        instance = Compressor('compressor')
        self.setup_network(instance)

        # compress NH3, other fluids in network are for turbine, pump, ...
        fl = {'N2': 1, 'O2': 0, 'Ar': 0, 'DowQ': 0, 'NH3': 0}
        self.c1.set_attr(fluid=fl, v=1, p=1, T=5)
        self.c2.set_attr(p=6)
        instance.set_attr(eta_s=0.8)
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
        self.nw.save('tmp')

        # test isentropic efficiency value
        eta_s_d = ((isentropic(self.c1.get_flow(), self.c2.get_flow()) -
                    self.c1.h.val_SI) / (self.c2.h.val_SI - self.c1.h.val_SI))
        msg = ('Value of isentropic efficiency must be ' + str(eta_s_d) +
               ', is ' + str(instance.eta_s.val) + '.')
        assert 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')
        convergence_check(self.nw.lin_dep)

        # test calculated value
        eta_s = ((isentropic(self.c1.get_flow(), self.c2.get_flow()) -
                  self.c1.h.val_SI) / (self.c2.h.val_SI - self.c1.h.val_SI))
        msg = ('Value of isentropic efficiency must be ' + str(eta_s) +
               ', is ' + str(instance.eta_s.val) + '.')
        assert round(eta_s, 3) == round(instance.eta_s.val, 3), msg

        # remove pressure at outlet, use characteristic map for pressure
        # rise calculation
        self.c2.set_attr(p=np.nan)
        instance.set_attr(char_map_pr={
            'char_func':
            ldc('compressor', 'char_map_pr', 'DEFAULT', CharMap),
            'is_set':
            True
        },
                          char_map_eta_s={
                              'char_func':
                              ldc('compressor', 'char_map_eta_s', 'DEFAULT',
                                  CharMap),
                              'is_set':
                              True
                          },
                          eta_s=np.nan,
                          igva=0)

        # offdesign test, efficiency value should be at design value
        self.nw.solve('offdesign', design_path='tmp')
        convergence_check(self.nw.lin_dep)
        msg = ('Value of isentropic efficiency (' + str(instance.eta_s.val) +
               ') must be identical to design case (' + str(eta_s) + ').')
        assert round(eta_s_d, 2) == round(instance.eta_s.val, 2), msg

        # move to highest available speedline, mass flow below lowest value
        # at that line
        self.c1.set_attr(v=np.nan, m=self.c1.m.val * 0.8, T=-30)
        self.nw.solve('offdesign', design_path='tmp')
        convergence_check(self.nw.lin_dep)

        # should be value
        eta_s = eta_s_d * instance.char_map_eta_s.char_func.z[6, 0]
        msg = ('Value of isentropic efficiency (' + str(instance.eta_s.val) +
               ') must be at (' + str(round(eta_s, 4)) + ').')
        assert round(eta_s, 4) == round(instance.eta_s.val, 4), msg

        # going below lowest available speedline, above highest mass flow at
        # that line
        self.c1.set_attr(T=175)
        self.nw.solve('offdesign', design_path='tmp', init_path='tmp')
        convergence_check(self.nw.lin_dep)
        # should be value
        eta_s = eta_s_d * instance.char_map_eta_s.char_func.z[0, 9]
        msg = ('Value of isentropic efficiency (' + str(instance.eta_s.val) +
               ') must be at (' + str(round(eta_s, 4)) + ').')
        assert round(eta_s, 4) == round(instance.eta_s.val, 4), msg

        # back to design properties, test eta_s_char
        self.c2.set_attr(p=6)
        self.c1.set_attr(v=1, T=5, m=np.nan)

        # test parameter specification for eta_s_char with unset char map
        instance.set_attr(
            eta_s_char={
                'char_func': ldc('compressor', 'eta_s_char', 'DEFAULT',
                                 CharLine),
                'is_set': True,
                'param': 'm'
            })
        instance.char_map_eta_s.is_set = False
        instance.char_map_pr.is_set = False
        self.nw.solve('offdesign', design_path='tmp')
        convergence_check(self.nw.lin_dep)
        msg = ('Value of isentropic efficiency must be ' + str(eta_s_d) +
               ', is ' + str(instance.eta_s.val) + '.')
        assert round(eta_s_d, 3) == round(instance.eta_s.val, 3), msg

        # move up in volumetric flow
        self.c1.set_attr(v=1.5)
        self.nw.solve('offdesign', design_path='tmp')
        convergence_check(self.nw.lin_dep)
        eta_s = round(
            eta_s_d * instance.eta_s_char.char_func.evaluate(
                self.c1.m.val_SI / self.c1.m.design), 3)
        msg = ('Value of isentropic efficiency must be ' + str(eta_s) +
               ', is ' + str(round(instance.eta_s.val, 3)) + '.')
        assert eta_s == round(instance.eta_s.val, 3), msg

        # test parameter specification for pr
        instance.eta_s_char.set_attr(param='pr')
        self.c1.set_attr(v=1)
        self.c2.set_attr(p=6)
        self.nw.solve('offdesign', design_path='tmp')
        convergence_check(self.nw.lin_dep)
        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.char_func.evaluate(expr),
                      3)
        msg = ('Value of isentropic efficiency must be ' + str(eta_s) +
               ', is ' + str(round(instance.eta_s.val, 3)) + '.')
        assert eta_s == round(instance.eta_s.val, 3), msg
        shutil.rmtree('./tmp', ignore_errors=True)
Exemple #15
0
Q_N = -189e6

# %% network
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 = CombustionChamber('combustion')
g_turb = Turbine('gas turbine')

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

# waste heat recovery
suph = HeatExchanger('superheater')
evap = HeatExchanger('evaporator')
drum = Drum('drum')
eco = HeatExchanger('economizer')
ch = Sink('chimney')

# steam turbine part
Exemple #16
0
             p_unit='bar',
             h_unit='kJ / kg',
             m_unit='kg / s')

# %% components

# sources & sinks
cc = CycleCloser('coolant cycle closer')
cc_cons = CycleCloser('consumer cycle closer')
amb = Source('ambient air')
amb_out1 = Sink('sink ambient 1')
amb_out2 = Sink('sink ambient 2')

# ambient air system
sp = Splitter('splitter')
fan = Compressor('fan')

# consumer system

cd = Condenser('condenser')
dhp = Pump('district heating pump')
cons = HeatExchangerSimple('consumer')

# evaporator system

ves = Valve('valve')
dr = Drum('drum')
ev = HeatExchanger('evaporator')
su = HeatExchanger('superheater')
erp = Pump('evaporator reciculation pump')
Exemple #17
0
                              CombustionChamber, Pump, HeatExchanger, Drum,
                              CycleCloser)
from tespy.connections import Connection, Bus, Ref
from tespy.tools import document_model

from tespy.tools import CharLine
import numpy as np

# %% network
fluid_list = ['Ar', 'N2', 'O2', 'CO2', 'CH4', 'H2O']

nw = Network(fluids=fluid_list, p_unit='bar', T_unit='C', h_unit='kJ / kg')

# %% components
# gas turbine part
comp = Compressor('compressor')
c_c = CombustionChamber('combustion')
g_turb = Turbine('gas turbine')

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

# waste heat recovery
suph = HeatExchanger('superheater')
evap = HeatExchanger('evaporator')
dr = Drum('drum')
eco = HeatExchanger('economizer')
dh_whr = HeatExchanger('waste heat recovery')
ch = Sink('chimney')

# steam turbine part
Exemple #18
0
cd = Condenser('condenser')
rp = Pump('recirculation pump')
cons = HeatExchangerSimple('consumer')

# evaporator system

va = Valve('valve')
dr = Drum('drum')
ev = HeatExchanger('evaporator')
su = HeatExchanger('superheater')
pu = Pump('pump evaporator')

# compressor-system

cp1 = Compressor('compressor 1')
cp2 = Compressor('compressor 2')
he = HeatExchanger('intercooler')

# %% connections

# consumer system

c_in_cd = Connection(cool_closer, 'out1', cd, 'in1')
close_rp = Connection(cons_closer, 'out1', rp, 'in1')
rp_cd = Connection(rp, 'out1', cd, 'in2')
cd_cons = Connection(cd, 'out2', cons, 'in1')
cons_close = Connection(cons, 'out1', cons_closer, 'in1')

nw.add_conns(c_in_cd, close_rp, rp_cd, cd_cons, cons_close)