-
Hello everyone, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @Delilay, can you share a code example, that is failing and is as small as possible? Thank you very much! Best |
Beta Was this translation helpful? Give feedback.
-
I did it for multiple customers but her it is one small code just for 2 customers. from tespy.components.basics.cycle_closer import CycleCloser
from tespy.networks import Network
from tespy.components import (
Pipe, Pump, Valve, SimpleHeatExchanger, Merge, Splitter
)
from tespy.connections import Connection
nw = Network()
nw.set_attr(T_unit='C', p_unit='bar', m_unit='kg / s', h_unit='kJ / kg')
# central heating plant
hs = SimpleHeatExchanger('chaufferie')
cc = CycleCloser('cycle closer1')
cc2 = CycleCloser('cycle closer2')
pu = Pump('feed pump')
# consumer
cons1 = SimpleHeatExchanger('stade')
cons2 = SimpleHeatExchanger('ancienne école')
val1 = Valve('control valve1')
val2 = Valve('control valve2')
# pipes for the stadium
pipe_feed1 = Pipe('feed pipe1')
pipe_feed2 = Pipe('feed pipe2')
pipe_return1 = Pipe('return pipe1')
pipe_return2 = Pipe('return pipe2')
# pipes pour l'école
fp2 = Pipe('feed pipe ecole')
rp2 = Pipe('return pipe ecole')
me1 = Merge('merge1', num_in=2)
sp1 = Splitter('splitter1', num_out=2)
# connections stade
c0 = Connection(cc, "out1", hs, "in1", label="0")
c1 = Connection(hs, "out1", pu, "in1", label="1")
c2 = Connection(pu, "out1", pipe_feed1, "in1", label="2")
c3 = Connection(pipe_feed1, "out1", sp1, "in1", label="3")
c4 = Connection(sp1, "out1", pipe_feed2, "in1", label="4")
c5 = Connection(pipe_feed2, "out1", val1, "in1", label="5")
c8 = Connection(val1, "out1", cons1, "in1", label="8")
c9 = Connection(cons1, "out1", pipe_return2, "in1", label="9")
c12 = Connection(pipe_return2, "out1", me1, "in1", label="12")
c13 = Connection(me1, "out1", pipe_return1, "in1", label="13")
c14 = Connection(pipe_return1, "out1", cc, "in1", label="14")
#connections ancienne école
c00 = Connection(sp1, "out2", fp2, "in1", label="00")
c01 = Connection(fp2, "out1", val2, "in1", label="01")
c02 = Connection(val2, "out1", cons2, "in1", label="02")
c03 = Connection(cons2, "out1", rp2, "in1", label="03")
c04 = Connection(rp2, "out1", me1, "in2", label="04")
nw.add_conns(c0, c1, c2, c3, c4, c5, c8, c9, c12, c13, c14)
nw.add_conns(c00, c01, c02, c03, c04)
hs.set_attr(pr=1)
pu.set_attr(eta_s=0.75)
# Consumer 1 (stade)
cons1.set_attr(Q=-17e4, pr=1)
pipe_return1.set_attr(Q=-182, pr=0.98)
pipe_feed2.set_attr(Q=-250, pr=0.98)
c1.set_attr(T=82, p=10, fluid={'INCOMP::Water': 1})
c2.set_attr(p=15)
#c8.set_attr(p=15)
c5.set_attr(T=62)
# Consumer 2 (ancienne école)
cons2.set_attr(Q=-14e4, pr=1)
fp2.set_attr(Q=-50, pr=0.98)
rp2.set_attr(Q=-150, pr=0.98)
c01.set_attr(T=82, p=14.47)
c00.set_attr(p=15)
c04.set_attr(p=10)
c0.set_attr(T=62)
# Résolution du réseau
nw.solve(mode="design")
nw.print_results() |
Beta Was this translation helpful? Give feedback.
Hi, this is a little bit difficult to guess without seeing the actual problem. You need to understand, what are all the variables that have to be determined in your model, what variables are determined by the implicit constraints of your components (e.g. mass flow equality for 1to1 components like pipes or pressure equality for all connections of splitters and mergers) and what variables are determined by component settings and what variables are determined by connections specifications.
My workflow suggestion for you is: