How to use the tespy.con.connection function in tespy

To help you get started, we’ve selected a few tespy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oemof / tespy / tests / component_tests.py View on Github external
def setup_network_21(self, instance):
        """
        Set up network for components with two inlets and one outlet.
        """
        c1 = con.connection(self.source, 'out1', instance, 'in1')
        c2 = con.connection(cmp.source('fuel'), 'out1', instance, 'in2')
        c3 = con.connection(instance, 'out1', self.sink, 'in1')
        self.nw.add_conns(c1, c2, c3)
        return c1, c2, c3
github oemof / tespy / tests / component_tests.py View on Github external
def setup_network_11(self, instance):
        """
        Set up network for components with one inlet and one outlet.
        """
        c1 = con.connection(self.source, 'out1', instance, 'in1')
        c2 = con.connection(instance, 'out1', self.sink, 'in1')
        self.nw.add_conns(c1, c2)
        return c1, c2
github oemof / tespy / tests / component_tests.py View on Github external
def test_heat_ex(self):
        """
        Test component properties of heat exchanger.
        """
        tesin = cmp.sink('TES in')
        tesout = cmp.source('TES out')
        hsin = cmp.sink('HS in')
        hsout = cmp.source('HS out')
        he = cmp.heat_exchanger('heat exchanger')
        tes_he = con.connection(tesout, 'out1', he, 'in2')
        he_tes = con.connection(he, 'out2', tesin, 'in1')
        hs_he = con.connection(hsout, 'out1', he, 'in1')
        he_hs = con.connection(he, 'out1', hsin, 'in1')
        self.nw.add_conns(tes_he, he_tes, hs_he, he_hs)
        # design specification
        he.set_attr(pr1=0.98, pr2=0.98, ttd_u=5, design=['pr1', 'pr2', 'ttd_u'], offdesign=['zeta1', 'zeta2', 'kA'])
        hs_he.set_attr(T=120, p=3, fluid={'N2': 0, 'O2': 0, 'Ar': 0, 'INCOMP::DowQ': 0, 'H2O': 1, 'NH3': 0, 'CO2': 0, 'CH4': 0})
        he_hs.set_attr(T=70)
        tes_he.set_attr(T=40, p=5, fluid={'N2': 0, 'O2': 0, 'Ar': 1, 'INCOMP::DowQ': 0, 'H2O': 0, 'NH3': 0, 'CO2': 0, 'CH4': 0})
        b = con.bus('heat transfer', P=-80e3)
        b.add_comps({'c': he})
        self.nw.add_busses(b)
        self.nw.solve('design')
        # check heat flow
        Q = hs_he.m.val_SI * (he_hs.h.val_SI - hs_he.h.val_SI)
        self.nw.save('tmp')
github oemof / tespy / tests / component_tests.py View on Github external
def setup_network_11(self, instance):
        """
        Set up network for components with one inlet and one outlet.
        """
        c1 = con.connection(self.source, 'out1', instance, 'in1')
        c2 = con.connection(instance, 'out1', self.sink, 'in1')
        self.nw.add_conns(c1, c2)
        return c1, c2
github oemof / tespy / examples / chp.py View on Github external
# preheater and condenser
ext_cond = con.connection(preheater, 'out1', vessel, 'in1')
cond_ws = con.connection(vessel, 'out1', merge, 'in2')
turb_ws = con.connection(turbine_lp, 'out1', merge, 'in1')
ws = con.connection(merge, 'out1', condenser, 'in1')
nw.add_conns(ext_cond, cond_ws, turb_ws, ws)

# feed water
cond = con.connection(condenser, 'out1', pump, 'in1')
fw_c = con.connection(pump, 'out1', preheater, 'in2')
fw_w = con.connection(preheater, 'out2', steam_generator, 'in1')
fs_out = con.connection(steam_generator, 'out1', sink, 'in1')
nw.add_conns(cond, fw_c, fw_w, fs_out)

# cooling water
cw_in = con.connection(source_cw, 'out1', condenser, 'in2')
cw_out = con.connection(condenser, 'out2', sink_cw, 'in1')
nw.add_conns(cw_in, cw_out)

# %% busses

# power bus
power_bus = con.bus('power')
power_bus.add_comps([turbine_hp, -1], [turbine_lp, -1], [pump, -1])

# heating bus
heat_bus = con.bus('heat')
heat_bus.add_comps([condenser, -1])

nw.add_busses(power_bus, heat_bus)

# %% parametrization of components
github oemof / tespy / examples / simple_clausius_rankine.py View on Github external
steam_generator = cmp.heat_exchanger_simple('steam generator')
source = cmp.source('cycle opener')
sink = cmp.sink('cycle closer')

# cooling water
source_cw = cmp.source('cooling water inlet')
sink_cw = cmp.sink('cooling water outlet')

# %% connections

# main cycle
fs_in = con.connection(source, 'out1', turbine, 'in1')
ws = con.connection(turbine, 'out1', condenser, 'in1')
cond = con.connection(condenser, 'out1', pump, 'in1')
fw = con.connection(pump, 'out1', steam_generator, 'in1')
fs_out = con.connection(steam_generator, 'out1', sink, 'in1')
nw.add_conns(fs_in, ws, cond, fw, fs_out)

# cooling water
cw_in = con.connection(source_cw, 'out1', condenser, 'in2')
cw_out = con.connection(condenser, 'out2', sink_cw, 'in1')
nw.add_conns(cw_in, cw_out)

# %% busses

power = con.bus('total output power')
power.add_comps([turbine, 1], [pump, 1])
nw.add_busses(power)

# %% parametrization of components

turbine.set_attr(eta_s=0.9)
github oemof / tespy / examples / simple_clausius_rankine.py View on Github external
# cooling water
source_cw = cmp.source('cooling water inlet')
sink_cw = cmp.sink('cooling water outlet')

# %% connections

# main cycle
fs_in = con.connection(source, 'out1', turbine, 'in1')
ws = con.connection(turbine, 'out1', condenser, 'in1')
cond = con.connection(condenser, 'out1', pump, 'in1')
fw = con.connection(pump, 'out1', steam_generator, 'in1')
fs_out = con.connection(steam_generator, 'out1', sink, 'in1')
nw.add_conns(fs_in, ws, cond, fw, fs_out)

# cooling water
cw_in = con.connection(source_cw, 'out1', condenser, 'in2')
cw_out = con.connection(condenser, 'out2', sink_cw, 'in1')
nw.add_conns(cw_in, cw_out)

# %% busses

power = con.bus('total output power')
power.add_comps([turbine, 1], [pump, 1])
nw.add_busses(power)

# %% parametrization of components

turbine.set_attr(eta_s=0.9)
condenser.set_attr(pr1=0.98, pr2=0.98, ttd_u=5)
pump.set_attr(eta_s=0.8)
steam_generator.set_attr(pr=0.95, mode='man')
github oemof / tespy / docs / build / html / _downloads / CHP.py View on Github external
fs_in=con.connection(source,'out1',vessel_turb,'in1',p=100,T=550)
fs=con.connection(vessel_turb,'out1',turbine_hp,'in1',p=100,m=47,fluid={'water':1})
ext=con.connection(turbine_hp,'out1',split,'in1',p=10)
ext_pre=con.connection(split,'out1',preheater,'in1')
ext_turb=con.connection(split,'out2',turbine_lp,'in1',h0=2800000)

# preheater and condenser
ext_cond=con.connection(preheater,'out1',vessel,'in1',h0=600000)
cond_ws=con.connection(vessel,'out1',merge,'in2')
turb_ws=con.connection(turbine_lp,'out1',merge,'in1')
ws=con.connection(merge,'out1',condenser,'in1')

# feed water
cond=con.connection(condenser,'out1',pump,'in1')
fw_c=con.connection(pump,'out1',preheater,'in2',h0=330000)
fw_w=con.connection(preheater,'out2',steam_generator,'in1')
out=con.connection(steam_generator,'out1',sink,'in1',p=con.ref(fs_in,1,0),h=con.ref(fs_in,1,0))

# cooling water
cw_in=con.connection(source_cw,'out1',condenser,'in2',T=60,p=10,fluid={'water':1})
cw_out=con.connection(condenser,'out2',sink_cw,'in1',T=110)

# %% network

fluids=['water']

nw=nwk.network(fluids=fluids,p='bar',T='C')
nw.add_conns(fs_in,fs,ext,ext_pre,ext_turb,ext_cond,cond_ws,turb_ws,ws,cond,fw_c,fw_w,cw_in,cw_out,out)

# %% busses

# power bus