Exemplo n.º 1
0
    def setup_pipeline_network(self, fluid_list):
        """Setup a pipeline network."""
        self.nw = Network(fluids=fluid_list)
        self.nw.set_attr(p_unit='bar', T_unit='C', iterinfo=False)

        # %% components

        # main components
        pu = Pump('pump')
        pi = Pipe('pipeline')
        es = HeatExchangerSimple('energy balance closing')

        closer = CycleCloser('cycle closer')

        pu_pi = Connection(pu, 'out1', pi, 'in1')
        pi_es = Connection(pi, 'out1', es, 'in1')
        es_closer = Connection(es, 'out1', closer, 'in1')
        closer_pu = Connection(closer, 'out1', pu, 'in1')
        self.nw.add_conns(pu_pi, pi_es, es_closer, closer_pu)

        # %% parametrization of components

        pu.set_attr(eta_s=0.7)
        pi.set_attr(pr=0.95, L=100, ks=1e-5, D='var', Q=0)
        es.set_attr(pr=1)

        # %% parametrization of connections

        pu_pi.set_attr(p=20, T=100, m=10, fluid={self.nw.fluids[0]: 1})

        # %% solving
        self.nw.solve('design')
Exemplo n.º 2
0
    def setup_clausius_rankine(self, fluid_list):
        """Setup a Clausius-Rankine cycle."""
        self.nw = Network(fluids=fluid_list)
        self.nw.set_attr(p_unit='bar', T_unit='C', iterinfo=True)

        # %% components

        # main components
        turb = Turbine('turbine')
        con = Condenser('condenser')
        pu = Pump('pump')
        steam_generator = HeatExchangerSimple('steam generator')
        closer = CycleCloser('cycle closer')

        # cooling water
        so_cw = Source('cooling water inlet')
        si_cw = Sink('cooling water outlet')

        # %% connections

        # main cycle
        fs_in = Connection(closer, 'out1', turb, 'in1', label='livesteam')
        ws = Connection(turb, 'out1', con, 'in1', label='wastesteam')
        cond = Connection(con, 'out1', pu, 'in1', label='condensate')
        fw = Connection(pu, 'out1', steam_generator, 'in1', label='feedwater')
        fs_out = Connection(steam_generator, 'out1', closer, 'in1')
        self.nw.add_conns(fs_in, ws, cond, fw, fs_out)

        # cooling water
        cw_in = Connection(so_cw, 'out1', con, 'in2')
        cw_out = Connection(con, 'out2', si_cw, 'in1')
        self.nw.add_conns(cw_in, cw_out)

        # %% parametrization of components

        turb.set_attr(eta_s=0.9)
        con.set_attr(pr1=1, pr2=0.99, ttd_u=5)
        steam_generator.set_attr(pr=0.9)

        # %% parametrization of connections

        fs_in.set_attr(p=100, T=500, m=100, fluid={self.nw.fluids[0]: 1})
        fw.set_attr(h=200e3)
        cw_in.set_attr(T=20, p=5, fluid={self.nw.fluids[0]: 1})
        cw_out.set_attr(T=30)

        # %% solving
        self.nw.solve('design')
        pu.set_attr(eta_s=0.7)
        fw.set_attr(h=None)
        self.nw.solve('design')
Exemplo n.º 3
0
    def setup(self):
        """Set up air compressed air turbine."""
        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
        cas = Source('compressed air storage')
        reheater = HeatExchangerSimple('reheating')
        turb = Turbine('turbine')
        amb = Sink('air outlet')

        # power ouput bus
        self.power_out = Bus('power output')
        self.power_out.add_comps({'comp': turb, 'char': 1})
        # compressed air bus
        self.cas_out = Bus('exergy in')
        self.cas_out.add_comps({
            'comp': cas,
            'base': 'bus'
        }, {
            'comp': reheater,
            'base': 'bus'
        })
        # exergy loss bus
        self.ex_loss = Bus('exergy loss')
        self.ex_loss.add_comps({'comp': amb, 'base': 'component'})
        self.nw.add_busses(self.power_out, self.cas_out)

        # create connections
        cas_reheater = Connection(cas, 'out1', reheater, 'in1')
        reheater_turb = Connection(reheater, 'out1', turb, 'in1')
        turb_amb = Connection(turb, 'out1', amb, 'in1', label='outlet')
        self.nw.add_conns(cas_reheater, reheater_turb, turb_amb)

        # component parameters
        turb.set_attr(eta_s=1)
        reheater.set_attr(pr=1)

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

        # solve network
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
Exemplo n.º 4
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
Exemplo n.º 5
0
    def setup(self):
        """Set up clausis rankine cycle with turbine driven feed water pump."""
        self.Tamb = 20
        self.pamb = 1
        fluids = ['water']
        self.nw = Network(fluids=fluids)
        self.nw.set_attr(p_unit='bar', T_unit='C', h_unit='kJ / kg')

        # create components
        splitter1 = Splitter('splitter 1')
        merge1 = Merge('merge 1')
        turb = Turbine('turbine')
        fwp_turb = Turbine('feed water pump turbine')
        condenser = HeatExchangerSimple('condenser')
        fwp = Pump('pump')
        steam_generator = HeatExchangerSimple('steam generator')
        cycle_close = CycleCloser('cycle closer')

        # create busses
        # power output bus
        self.power = Bus('power_output')
        self.power.add_comps({'comp': turb, 'char': 1})
        # turbine driven feed water pump internal bus
        self.fwp_power = Bus('feed water pump power', P=0)
        self.fwp_power.add_comps(
            {'comp': fwp_turb, 'char': 1},
            {'comp': fwp, 'char': 1, 'base': 'bus'})
        # heat input bus
        self.heat = Bus('heat_input')
        self.heat.add_comps({'comp': steam_generator, 'base': 'bus'})
        self.nw.add_busses(self.power, self.fwp_power, self.heat)

        # create connections
        fs_in = Connection(cycle_close, 'out1', splitter1, 'in1', label='fs')
        fs_fwpt = Connection(splitter1, 'out1', fwp_turb, 'in1')
        fs_t = Connection(splitter1, 'out2', turb, 'in1')
        fwpt_ws = Connection(fwp_turb, 'out1', merge1, 'in1')
        t_ws = Connection(turb, 'out1', merge1, 'in2')
        ws = Connection(merge1, 'out1', condenser, 'in1')
        cond = Connection(condenser, 'out1', fwp, 'in1', label='cond')
        fw = Connection(fwp, 'out1', steam_generator, 'in1', label='fw')
        fs_out = Connection(steam_generator, 'out1', cycle_close, 'in1')
        self.nw.add_conns(fs_in, fs_fwpt, fs_t, fwpt_ws, t_ws, ws, cond, fw,
                          fs_out)

        # component parameters
        turb.set_attr(eta_s=1)
        fwp_turb.set_attr(eta_s=1)
        condenser.set_attr(pr=1)
        fwp.set_attr(eta_s=1)
        steam_generator.set_attr(pr=1)

        # connection parameters
        fs_in.set_attr(m=10, p=120, T=600, fluid={'water': 1})
        cond.set_attr(T=self.Tamb, x=0)

        # solve network
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
Exemplo n.º 6
0
    def create_comps(self):

        for i in range(self.num_consumer - 1):
            j = str(i)
            self.comps['splitter_' + j] = Splitter(self.label + '_splitter_' +
                                                   j)
            self.comps['merge_' + j] = Merge(self.label + '_merge_' + j)
            self.comps['consumer_' + j] = HeatExchangerSimple(self.label +
                                                              '_consumer_' + j)
            self.comps['valve_' + j] = Valve(self.label + '_valve_' + j)
            self.comps['feed_' + j] = Pipe(self.label + '_pipe feed_' + j)
            self.comps['return_' + j] = Pipe(self.label + '_pipe return_' + j)

        j = str(i + 1)
        self.comps['consumer_' + j] = HeatExchangerSimple(self.label +
                                                          '_consumer_' + j)
def consumers(end_pipes):
    cons = {}

    for index, row in end_pipes.iterrows():
        cons_name = "consumer" + str(int(row["USER_ID"]))

        cons[int(row['USER_ID'])] = HeatExchangerSimple(cons_name)
        cons[int(row["USER_ID"])].set_attr(Q=-row["Power"])
    return cons
Exemplo n.º 8
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)
Exemplo n.º 9
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)
Exemplo n.º 10
0
# 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')

# compressor-system

cp1 = Compressor('compressor 1')
cp2 = Compressor('compressor 2')
ic = HeatExchanger('intercooler')
    def __init__(self):
        self.nw = Network(fluids=['BICUBIC::water'],
                          p_unit='bar',
                          T_unit='C',
                          h_unit='kJ / kg',
                          iterinfo=False)
        # components
        # main cycle
        eco = HeatExchangerSimple('economizer')
        eva = HeatExchangerSimple('evaporator')
        sup = HeatExchangerSimple('superheater')
        cc = CycleCloser('cycle closer')
        hpt = Turbine('high pressure turbine')
        sp1 = Splitter('splitter 1', num_out=2)
        mpt = Turbine('mid pressure turbine')
        sp2 = Splitter('splitter 2', num_out=2)
        lpt = Turbine('low pressure turbine')
        con = Condenser('condenser')
        pu1 = Pump('feed water pump')
        fwh1 = Condenser('feed water preheater 1')
        fwh2 = Condenser('feed water preheater 2')
        dsh = Desuperheater('desuperheater')
        me2 = Merge('merge2', num_in=2)
        pu2 = Pump('feed water pump 2')
        pu3 = Pump('feed water pump 3')
        me = Merge('merge', num_in=2)

        # cooling water
        cwi = Source('cooling water source')
        cwo = Sink('cooling water sink')

        # connections
        # main cycle
        cc_hpt = Connection(cc, 'out1', hpt, 'in1', label='feed steam')
        hpt_sp1 = Connection(hpt, 'out1', sp1, 'in1', label='extraction1')
        sp1_mpt = Connection(sp1, 'out1', mpt, 'in1', state='g')
        mpt_sp2 = Connection(mpt, 'out1', sp2, 'in1', label='extraction2')
        sp2_lpt = Connection(sp2, 'out1', lpt, 'in1')
        lpt_con = Connection(lpt, 'out1', con, 'in1')
        con_pu1 = Connection(con, 'out1', pu1, 'in1')
        pu1_fwh1 = Connection(pu1, 'out1', fwh1, 'in2')
        fwh1_me = Connection(fwh1, 'out2', me, 'in1', state='l')
        me_fwh2 = Connection(me, 'out1', fwh2, 'in2', state='l')
        fwh2_dsh = Connection(fwh2, 'out2', dsh, 'in2', state='l')
        dsh_me2 = Connection(dsh, 'out2', me2, 'in1')
        me2_eco = Connection(me2, 'out1', eco, 'in1', state='l')
        eco_eva = Connection(eco, 'out1', eva, 'in1')
        eva_sup = Connection(eva, 'out1', sup, 'in1')
        sup_cc = Connection(sup, 'out1', cc, 'in1')

        self.nw.add_conns(cc_hpt, hpt_sp1, sp1_mpt, mpt_sp2, sp2_lpt, lpt_con,
                          con_pu1, pu1_fwh1, fwh1_me, me_fwh2, fwh2_dsh,
                          dsh_me2, me2_eco, eco_eva, eva_sup, sup_cc)

        # cooling water
        cwi_con = Connection(cwi, 'out1', con, 'in2')
        con_cwo = Connection(con, 'out2', cwo, 'in1')

        self.nw.add_conns(cwi_con, con_cwo)

        # preheating
        sp1_dsh = Connection(sp1, 'out2', dsh, 'in1')
        dsh_fwh2 = Connection(dsh, 'out1', fwh2, 'in1')
        fwh2_pu2 = Connection(fwh2, 'out1', pu2, 'in1')
        pu2_me2 = Connection(pu2, 'out1', me2, 'in2')

        sp2_fwh1 = Connection(sp2, 'out2', fwh1, 'in1')
        fwh1_pu3 = Connection(fwh1, 'out1', pu3, 'in1')
        pu3_me = Connection(pu3, 'out1', me, 'in2')

        self.nw.add_conns(sp1_dsh, dsh_fwh2, fwh2_pu2, pu2_me2, sp2_fwh1,
                          fwh1_pu3, pu3_me)

        # busses
        # power bus
        self.power = Bus('power')
        self.power.add_comps({
            'comp': hpt,
            'char': -1
        }, {
            'comp': mpt,
            'char': -1
        }, {
            'comp': lpt,
            'char': -1
        }, {
            'comp': pu1,
            'char': -1
        }, {
            'comp': pu2,
            'char': -1
        }, {
            'comp': pu3,
            'char': -1
        })

        # heating bus
        self.heat = Bus('heat')
        self.heat.add_comps({
            'comp': eco,
            'char': 1
        }, {
            'comp': eva,
            'char': 1
        }, {
            'comp': sup,
            'char': 1
        })

        self.nw.add_busses(self.power, self.heat)

        # parametrization
        # components
        hpt.set_attr(eta_s=0.9)
        mpt.set_attr(eta_s=0.9)
        lpt.set_attr(eta_s=0.9)

        pu1.set_attr(eta_s=0.8)
        pu2.set_attr(eta_s=0.8)
        pu3.set_attr(eta_s=0.8)

        eco.set_attr(pr=0.99)
        eva.set_attr(pr=0.99)
        sup.set_attr(pr=0.99)

        con.set_attr(pr1=1, pr2=0.99, ttd_u=5)
        fwh1.set_attr(pr1=1, pr2=0.99, ttd_u=5)
        fwh2.set_attr(pr1=1, pr2=0.99, ttd_u=5)
        dsh.set_attr(pr1=0.99, pr2=0.99)

        # connections
        eco_eva.set_attr(x=0)
        eva_sup.set_attr(x=1)

        cc_hpt.set_attr(m=200, T=650, p=100, fluid={'water': 1})
        hpt_sp1.set_attr(p=20)
        mpt_sp2.set_attr(p=3)
        lpt_con.set_attr(p=0.05)

        cwi_con.set_attr(T=20, p=10, fluid={'water': 1})

        # test run
        self.nw.solve('design')
        document_model(self.nw)
Exemplo n.º 12
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'])
Exemplo n.º 13
0
    def test_HeatExhangerSimple(self):
        """Test component properties of simple heat exchanger."""
        instance = HeatExchangerSimple('heat exchanger')
        self.setup_HeatExchangerSimple_network(instance)
        fl = {'Ar': 0, 'H2O': 1, 'S800': 0}
        self.c1.set_attr(fluid=fl, m=1, p=10, T=100)
        # trigger heat exchanger parameter groups
        instance.set_attr(hydro_group='HW', L=100, ks=100, pr=0.99, Tamb=20)

        # test grouped parameter settings with missing parameters
        instance.hydro_group.is_set = True
        instance.kA_group.is_set = True
        instance.kA_char_group.is_set = True
        self.nw.solve('design', init_only=True)
        msg = ('Hydro group must no be set, if one parameter is missing!')
        assert instance.hydro_group.is_set is False, msg
        msg = ('kA group must no be set, if one parameter is missing!')
        assert instance.kA_group.is_set is False, msg
        msg = ('kA char group must no be set, if one parameter is missing!')
        assert instance.kA_char_group.is_set is False, msg

        # test diameter calculation from specified dimensions (as pipe)
        # with Hazen-Williams method
        instance.set_attr(hydro_group='HW', D='var', L=100,
                          ks=100, pr=0.99, Tamb=20)
        b = Bus('heat', P=-1e5)
        b.add_comps({'comp': instance})
        self.nw.add_busses(b)
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
        pr = round(self.c2.p.val_SI / self.c1.p.val_SI, 3)
        msg = ('Value of pressure ratio must be ' + str(pr) + ', is ' +
               str(instance.pr.val) + '.')
        assert pr == round(instance.pr.val, 3), msg

        # make zeta system variable and use previously calculated diameter
        # to calculate zeta. The value for zeta must not change
        zeta = round(instance.zeta.val, 0)
        instance.set_attr(D=instance.D.val, zeta='var', pr=np.nan)
        instance.D.is_var = False
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
        msg = ('Value of zeta must be ' + str(zeta) + ', is ' +
               str(round(instance.zeta.val, 0)) + '.')
        assert zeta == round(instance.zeta.val, 0), msg

        # same test with pressure ratio as sytem variable
        pr = round(instance.pr.val, 3)
        instance.set_attr(zeta=np.nan, pr='var')
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
        msg = ('Value of pressure ratio must be ' + str(pr) +
               ', is ' + str(round(instance.pr.val, 3)) + '.')
        assert pr == round(instance.pr.val, 3), msg

        # test heat transfer coefficient as variable of the system (ambient
        # temperature required)
        instance.set_attr(kA='var', pr=np.nan)
        b.set_attr(P=-5e4)
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)

        # due to heat output being half of reference (for Tamb) kA should be
        # somewhere near to that (actual value is 677)
        msg = ('Value of heat transfer coefficient must be 677, is ' +
               str(instance.kA.val) + '.')
        assert 677 == round(instance.kA.val, 0), msg

        # test heat transfer as variable of the system
        instance.set_attr(Q='var', kA=np.nan)
        Q = -5e4
        b.set_attr(P=Q)
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
        msg = ('Value of heat transfer must be ' + str(Q) +
               ', is ' + str(instance.Q.val) + '.')
        assert Q == round(instance.Q.val, 0), msg
Exemplo n.º 14
0
# %% network

fluids = ['water']

nw = Network(fluids=fluids)
nw.set_attr(
    p_unit='bar', T_unit='C', h_unit='kJ / kg',
    p_range=[0.01, 150], h_range=[10, 5000])

# %% components

# main components
turb = Turbine('turbine')
con = Condenser('condenser')
pu = Pump('pump')
steam_generator = HeatExchangerSimple('steam generator')
closer = CycleCloser('cycle closer')

# cooling water
so_cw = Source('cooling water inlet')
si_cw = Sink('cooling water outlet')

# %% connections

# main cycle
fs_in = Connection(closer, 'out1', turb, 'in1')
ws = Connection(turb, 'out1', con, 'in1')
cond = Connection(con, 'out1', pu, 'in1')
fw = Connection(pu, 'out1', steam_generator, 'in1')
fs_out = Connection(steam_generator, 'out1', closer, 'in1')
nw.add_conns(fs_in, ws, cond, fw, fs_out)
Exemplo n.º 15
0
nw = Network(fluids=fluid_list,
             p_unit='bar',
             T_unit='C',
             h_unit='kJ / kg',
             v_unit='l / s',
             iterinfo=False)

T_dh_in = 50
T_dh_out = 124  # might change due to 4GDH

# %% components

st = Turbine('steam Turbine')
con = Condenser('Condenser')
pu = Pump('feed water Pump')
sg1 = HeatExchangerSimple('steam generator: feed water heater')
sg2 = HeatExchangerSimple('steam generator: evaporater')
sg3 = HeatExchangerSimple('steam generator: superheater')
cc = CycleCloser('cycle closer')

dh_Source = Source('district heating Source')
dh_Sink = Sink('district heating Sink')

# %% Connection

# steam part
cc_st = Connection(cc, 'out1', st, 'in1')
st_con = Connection(st, 'out1', con, 'in1')
con_pu = Connection(con, 'out1', pu, 'in1')
pu_sg1 = Connection(pu, 'out1', sg1, 'in1')
sg1_sg2 = Connection(sg1, 'out1', sg2, 'in1')
Exemplo n.º 16
0
# sinks & sources
amb = Source('ambient')
sf = Source('fuel')
chbp = Sink('chimney bypass')
ch = Sink('chimney')

cw = Source('cooling water')
pump = Pump('cooling water pump')

cw_split = Splitter('cooling water splitter')
cw_merge = Merge('cooling water merge')
fg_split = Splitter('flue gas splitter')

fgc = HeatExchanger('flue gas cooler')

cons = HeatExchangerSimple('consumer')
cw_out = Sink('cooling water sink')

# combustion engine
ice = CombustionEngine(label='internal combustion engine')

# %% connections

amb_comb = Connection(amb, 'out1', ice, 'in3')
sf_comb = Connection(sf, 'out1', ice, 'in4')
comb_fg = Connection(ice, 'out3', fg_split, 'in1')

fg_fgc = Connection(fg_split, 'out1', fgc, 'in1')
fg_chbp = Connection(fg_split, 'out2', chbp, 'in1')

fgc_ch = Connection(fgc, 'out1', ch, 'in1')