Skip to content

Commit

Permalink
Merge branch 'fix/drum-equations' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Dec 2, 2023
2 parents b254960 + 3d3ea8e commit 4ae3832
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/tespy/components/nodes/drum.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def outlets():
return ['out1', 'out2']

def get_mandatory_constraints(self):
num_mass_eq = 1
if self.inl[1].m == self.outl[0].m:
num_mass_eq = 0
return {
Expand Down Expand Up @@ -217,6 +218,7 @@ def mass_flow_func(self):
if self.inl[1].m == self.outl[0].m:
return self.inl[0].m.val_SI - self.outl[1].m.val_SI
else:
res = 0
for i in self.inl:
res += i.m.val_SI
for o in self.outl:
Expand Down
52 changes: 52 additions & 0 deletions tests/test_components/test_drum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# -*- coding: utf-8

"""Module for testing components of type merge.
This file is part of project TESPy (github.com/oemof/tespy). It's copyrighted
by the contributors recorded in the version control history of the file,
available from its original location
tests/test_components/test_merge.py
SPDX-License-Identifier: MIT
"""
from pytest import approx
from pytest import fixture

from tespy.components import Drum
from tespy.components import SimpleHeatExchanger
from tespy.components import Sink
from tespy.components import Source
from tespy.components import Splitter
from tespy.connections import Connection
from tespy.networks import Network


@fixture()
def drum_network_setup():
nw = Network(T_unit="C", p_unit="bar")
dr = Drum("drum")
so = Source("liquid")
si = Sink("vapor")
c1 = Connection(so, "out1", dr, "in1", label="1")
c2 = Connection(dr, "out2", si, "in1", label="2")
nw.add_conns(c1, c2)
c1.set_attr(fluid={"R290": 1}, m=10, Td_bp=-10, T=50)
yield nw


def test_drum_with_blowdown(drum_network_setup):
nw = drum_network_setup
sp = Splitter("blowdown splitter")
si = Sink("blowdown sink")
eva = SimpleHeatExchanger("evaporator")
dr = nw.get_comp("drum")
c3 = Connection(dr, "out1", sp, "in1", label="3")
c4 = Connection(sp, "out1", si, "in1", label="4")
c5 = Connection(sp, "out2", eva, "in1", label="5")
c6 = Connection(eva, "out1", dr, "in2", label="6")

c6.set_attr(x=0.7, m=15)

nw.add_conns(c3, c4, c5, c6)

nw.solve("design")

assert 0.72728 == approx(c4.m.val_SI)

0 comments on commit 4ae3832

Please sign in to comment.