How to use tespy - 10 common examples

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 test_cogeneration_unit(self):
        """
        Test component properties of cogeneration unit.
        """
        amb = cmp.source('ambient')
        sf = cmp.source('fuel')
        fg = cmp.sink('flue gas outlet')
        cw_in1 = cmp.source('cooling water inlet1')
        cw_in2 = cmp.source('cooling water inlet2')
        cw_out1 = cmp.sink('cooling water outlet1')
        cw_out2 = cmp.sink('cooling water outlet2')
        chp = cmp.cogeneration_unit('cogeneration unit', fuel='CH4')
        amb_comb = con.connection(amb, 'out1', chp, 'in3')
        sf_comb = con.connection(sf, 'out1', chp, 'in4')
        comb_fg = con.connection(chp, 'out3', fg, 'in1')
        self.nw.add_conns(sf_comb, amb_comb, comb_fg)
        cw1_chp1 = con.connection(cw_in1, 'out1', chp, 'in1')
        cw2_chp2 = con.connection(cw_in2, 'out1', chp, 'in2')
        self.nw.add_conns(cw1_chp1, cw2_chp2)
        chp1_cw = con.connection(chp, 'out1', cw_out1, 'in1')
        chp2_cw = con.connection(chp, 'out2', cw_out2, 'in1')
        self.nw.add_conns(chp1_cw, chp2_cw)

        air = {'N2': 0.7556, 'O2': 0.2315, 'Ar': 0.0129, 'INCOMP::DowQ': 0, 'H2O': 0, 'NH3': 0, 'CO2': 0, 'CH4': 0}
github oemof / tespy / tests / component_tests.py View on Github external
def test_cogeneration_unit(self):
        """
        Test component properties of cogeneration unit.
        """
        amb = cmp.source('ambient')
        sf = cmp.source('fuel')
        fg = cmp.sink('flue gas outlet')
        cw_in1 = cmp.source('cooling water inlet1')
        cw_in2 = cmp.source('cooling water inlet2')
        cw_out1 = cmp.sink('cooling water outlet1')
        cw_out2 = cmp.sink('cooling water outlet2')
        chp = cmp.cogeneration_unit('cogeneration unit', fuel='CH4')
        amb_comb = con.connection(amb, 'out1', chp, 'in3')
        sf_comb = con.connection(sf, 'out1', chp, 'in4')
        comb_fg = con.connection(chp, 'out3', fg, 'in1')
        self.nw.add_conns(sf_comb, amb_comb, comb_fg)
        cw1_chp1 = con.connection(cw_in1, 'out1', chp, 'in1')
        cw2_chp2 = con.connection(cw_in2, 'out1', chp, 'in2')
        self.nw.add_conns(cw1_chp1, cw2_chp2)
        chp1_cw = con.connection(chp, 'out1', cw_out1, 'in1')
        chp2_cw = con.connection(chp, 'out2', cw_out2, 'in1')
        self.nw.add_conns(chp1_cw, chp2_cw)

        air = {'N2': 0.7556, 'O2': 0.2315, 'Ar': 0.0129, 'INCOMP::DowQ': 0, 'H2O': 0, 'NH3': 0, 'CO2': 0, 'CH4': 0}
        fuel = {'N2': 0, 'O2': 0, 'Ar': 0, 'INCOMP::DowQ': 0, 'H2O': 0, 'NH3': 0, 'CO2': 0.04, 'CH4': 0.96}
        water1 = {'N2': 0, 'O2': 0, 'Ar': 0, 'INCOMP::DowQ': 0, 'H2O': 1, 'NH3': 0, 'CO2': 0, 'CH4': 0}
        water2 = {'N2': 0, 'O2': 0, 'Ar': 0, 'INCOMP::DowQ': 0, 'H2O': 1, 'NH3': 0, 'CO2': 0, 'CH4': 0}
github oemof / tespy / tests / test_models / test_heat_pump_model.py View on Github external
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', c_out, '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])
github oemof / tespy / tests / test_components / test_heat_exchangers.py View on Github external
def setup_heat_exchanger_network(self, instance):

        self.inl2 = source('inlet 2')
        self.outl2 = sink('outlet 2')

        self.c1 = connection(self.inl1, 'out1', instance, 'in1')
        self.c2 = connection(instance, 'out1', self.outl1, 'in1')
        self.c3 = connection(self.inl2, 'out1', instance, 'in2')
        self.c4 = connection(instance, 'out2', self.outl2, 'in1')

        self.nw.add_conns(self.c1, self.c2, self.c3, self.c4)
github oemof / tespy / tests / test_networks / test_network.py View on Github external
self.sc2.set_attr(pr=0.95, lkf_lin=3.5, lkf_quad=0.011, A=700, E=800,
                          Tamb=20, eta_opt=0.92, design=['pr'],
                          offdesign=['zeta'])

        fl = {'H2O': 1}
        inlet = connection(so, 'out1', sp, 'in1', T=50, p=3, fluid=fl)
        outlet = connection(me, 'out1', si, 'in1', p=3)

        self.sp_p1 = connection(sp, 'out1', self.pump1, 'in1')
        self.p1_sc1 = connection(self.pump1, 'out1', self.sc1, 'in1')
        self.sc1_v1 = connection(self.sc1, 'out1', v1, 'in1', p=3.1, T=90)
        v1_me = connection(v1, 'out1', me, 'in1')

        self.sp_p2 = connection(sp, 'out2', self.pump2, 'in1')
        self.p2_sc2 = connection(self.pump2, 'out1', self.sc2, 'in1')
        self.sc2_v2 = connection(self.sc2, 'out1', v2, 'in1', p=3.1, m=0.1)
        v2_me = connection(v2, 'out1', me, 'in2')

        self.nw.add_conns(inlet, outlet, self.sp_p1, self.p1_sc1, self.sc1_v1,
                          v1_me, self.sp_p2, self.p2_sc2, self.sc2_v2, v2_me)
github oemof / tespy / tests / test_components / test_turbomachinery.py View on Github external
def setup_network(self, instance):
        self.nw = network(['INCOMP::DowQ', 'NH3', 'N2', 'O2', 'Ar'],
                          T_unit='C', p_unit='bar', v_unit='m3 / s')
        self.source = source('source')
        self.sink = sink('sink')
        self.c1 = connection(self.source, 'out1', instance, 'in1')
        self.c2 = connection(instance, 'out1', self.sink, 'in1')
        self.nw.add_conns(self.c1, self.c2)
github oemof / tespy / tests / error_tests.py View on Github external
Set up network for electrolyzer tests.
        """
        self.instance = reactors.water_electrolyzer('electrolyzer')

        fw = basics.source('feed water')
        cw_in = basics.source('cooling water')
        o2 = basics.sink('oxygen sink')
        h2 = basics.sink('hydrogen sink')
        cw_out = basics.sink('cooling water sink')

        cw_el = connection(cw_in, 'out1', self.instance, 'in1')
        el_cw = connection(self.instance, 'out1', cw_out, 'in1')

        self.nw.add_conns(cw_el, el_cw)

        fw_el = connection(fw, 'out1', self.instance, 'in2')
        el_o2 = connection(self.instance, 'out2', o2, 'in1')
        el_h2 = connection(self.instance, 'out3', h2, 'in1')

        self.nw.add_conns(fw_el, el_o2, el_h2)
github oemof / tespy / tests / error_tests.py View on Github external
self.instance = reactors.water_electrolyzer('electrolyzer')

        fw = basics.source('feed water')
        cw_in = basics.source('cooling water')
        o2 = basics.sink('oxygen sink')
        h2 = basics.sink('hydrogen sink')
        cw_out = basics.sink('cooling water sink')

        cw_el = connection(cw_in, 'out1', self.instance, 'in1')
        el_cw = connection(self.instance, 'out1', cw_out, 'in1')

        self.nw.add_conns(cw_el, el_cw)

        fw_el = connection(fw, 'out1', self.instance, 'in2')
        el_o2 = connection(self.instance, 'out2', o2, 'in1')
        el_h2 = connection(self.instance, 'out3', h2, 'in1')

        self.nw.add_conns(fw_el, el_o2, el_h2)
github oemof / tespy / tests / test_models / test_gas_turbine_models.py View on Github external
# %% 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 = combustion_chamber_stoich('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
github oemof / tespy / tests / test_components / test_heat_exchangers.py View on Github external
def setup_heat_exchanger_network(self, instance):

        self.inl2 = source('inlet 2')
        self.outl2 = sink('outlet 2')

        self.c1 = connection(self.inl1, 'out1', instance, 'in1')
        self.c2 = connection(instance, 'out1', self.outl1, 'in1')
        self.c3 = connection(self.inl2, 'out1', instance, 'in2')
        self.c4 = connection(instance, 'out2', self.outl2, 'in1')

        self.nw.add_conns(self.c1, self.c2, self.c3, self.c4)