|
| 1 | +# -*- coding: utf-8 |
| 2 | + |
| 3 | +"""Module for testing components of type merge. |
| 4 | +This file is part of project TESPy (github.com/oemof/tespy). It's copyrighted |
| 5 | +by the contributors recorded in the version control history of the file, |
| 6 | +available from its original location |
| 7 | +tests/test_components/test_merge.py |
| 8 | +SPDX-License-Identifier: MIT |
| 9 | +""" |
| 10 | +from pytest import approx |
| 11 | +from pytest import fixture |
| 12 | + |
| 13 | +from tespy.components import Drum |
| 14 | +from tespy.components import SimpleHeatExchanger |
| 15 | +from tespy.components import Sink |
| 16 | +from tespy.components import Source |
| 17 | +from tespy.components import Splitter |
| 18 | +from tespy.connections import Connection |
| 19 | +from tespy.networks import Network |
| 20 | + |
| 21 | + |
| 22 | +@fixture() |
| 23 | +def drum_network_setup(): |
| 24 | + nw = Network(T_unit="C", p_unit="bar") |
| 25 | + dr = Drum("drum") |
| 26 | + so = Source("liquid") |
| 27 | + si = Sink("vapor") |
| 28 | + c1 = Connection(so, "out1", dr, "in1", label="1") |
| 29 | + c2 = Connection(dr, "out2", si, "in1", label="2") |
| 30 | + nw.add_conns(c1, c2) |
| 31 | + c1.set_attr(fluid={"R290": 1}, m=10, Td_bp=-10, T=50) |
| 32 | + yield nw |
| 33 | + |
| 34 | + |
| 35 | +def test_drum_with_blowdown(drum_network_setup): |
| 36 | + nw = drum_network_setup |
| 37 | + sp = Splitter("blowdown splitter") |
| 38 | + si = Sink("blowdown sink") |
| 39 | + eva = SimpleHeatExchanger("evaporator") |
| 40 | + dr = nw.get_comp("drum") |
| 41 | + c3 = Connection(dr, "out1", sp, "in1", label="3") |
| 42 | + c4 = Connection(sp, "out1", si, "in1", label="4") |
| 43 | + c5 = Connection(sp, "out2", eva, "in1", label="5") |
| 44 | + c6 = Connection(eva, "out1", dr, "in2", label="6") |
| 45 | + |
| 46 | + c6.set_attr(x=0.7, m=15) |
| 47 | + |
| 48 | + nw.add_conns(c3, c4, c5, c6) |
| 49 | + |
| 50 | + nw.solve("design") |
| 51 | + |
| 52 | + assert 0.72728 == approx(c4.m.val_SI) |
0 commit comments