Replies: 2 comments 4 replies
-
# %%
#import des bibliothèques
from tespy.components.basics.cycle_closer import CycleCloser
from tespy.networks import Network
from tespy.components import (
CycleCloser, Pipe, Pump, Valve, SimpleHeatExchanger,Splitter,Merge
)
from tespy.connections import Connection
# fluid is therminol 66 : Coolprop fluid = "T66"
Fluid='INCOMP::T66'
# https://tespy.readthedocs.io/en/main/
# %%
# table de tuyauterie
DN_Acier={
21.7:0.1295,
27.3:0.1564,
36:0.1589,
41.9:0.181,
53.9:0.2013,
69.7:0.2325,
82.5:0.2418,
107.1:0.2543,
132.5:0.288,
160.3:0.3369,
210.1:0.3686,
263:0.3637,
312.7:0.4126,
344.4:0.4009,
393.8:0.4222,
444.4:0.4242,
495.4:0.4149,
595.8:0.5002,
695.2:0.5665,
795.4:0.6372,
}
# Trouver la clé strictement supérieure
def find_DN( D):
for key in sorted(DN_Acier.keys()):
if key >= D*1000:
return key/1000, DN_Acier[key]*1000
return None, None # Si aucune clé ne correspond
# %%
# définitions du réseau
nw = Network()
nw.set_attr(
T_unit='C',
p_unit='bar',
h_unit='kJ / kg',
v_unit='m3 / h',
vol_unit='m3 / kg'
)
# central heating plant
Chaudiere = SimpleHeatExchanger('Biomasse')
cc = CycleCloser('cycle closer',printout=False)
Pompe = Pump('Pompe')
# consumer
cons=[]
val=[]
for i in range(5):
cons.append(SimpleHeatExchanger('consumer_' + str(i+1))) # Append to the list
val.append(Valve('control_valve_' + str(i+1)))
# pipes
pipe=[]
for i in range(10):
pipe.append(Pipe('Pipe_'+str(i)))
# Split & merge
sp0 = Splitter("splitter 1", num_out=2)
sp1 = Splitter("splitter 2", num_out=2)
sp2 = Splitter("splitter 3", num_out=2)
sp3 = Splitter("splitter 4", num_out=2)
me1 = Merge("merge 1", num_in=2)
me2 = Merge("merge 2", num_in=2)
me3 = Merge("merge 3", num_in=2)
me4 = Merge("merge 4", num_in=2)
# connections
c=[None]*35
#aller et consumers
c[0] = Connection(cc, "out1", Chaudiere, "in1", label="entrée chaudière")
c[1] = Connection(Chaudiere, "out1", Pompe, "in1", label="sortie chaudière")
c[2] = Connection(Pompe, "out1", pipe[0], "in1", label="sortie pompe")
c[3] = Connection(pipe[0], "out1", sp0, "in1", label="Feeder")
c[4] = Connection(sp0 , "out1", val[0] , "in1", label="4")
c[5] = Connection(val[0], "out1", cons[0], "in1", label="entrée ech0")
c[6] = Connection(cons[0] , "out1", pipe[5] , "in1", label="sortie ech0")
c[7] = Connection(sp0 , "out2", pipe[1] , "in1", label="7")
c[8] = Connection(pipe[1] , "out1", sp1 , "in1", label="8")
c[9] = Connection(sp1 , "out1", val[1] , "in1", label="9")
c[10] = Connection(val[1] , "out1", cons[1] , "in1", label="entrée ech1")
c[11] = Connection(cons[1] , "out1", me1 , "in1", label="sortie ech1")
c[12] = Connection(sp1 , "out2", pipe[2] , "in1", label="12")
c[13] = Connection(pipe[2] , "out1", sp2 , "in1", label="13")
c[14] = Connection(sp2 , "out1", val[2] , "in1", label="14")
c[15] = Connection(val[2] , "out1", cons[2] , "in1", label="entrée ech2")
c[16] = Connection(cons[2], "out1", me2 , "in1", label="sortie ech2")
c[17] = Connection(sp2 , "out2", pipe[3] , "in1", label="17")
c[18] = Connection(pipe[3] , "out1", sp3 , "in1", label="18")
c[19] = Connection(sp3 , "out1", val[3] , "in1", label="19")
c[20] = Connection(val[3], "out1", cons[3] , "in1", label="entrée ech3")
c[21] = Connection(cons[3] , "out1", me3 , "in1", label="sortie ech3")
c[22] = Connection(sp3 , "out2", pipe[4] , "in1", label="22")
c[23] = Connection(pipe[4] , "out1",val[4] , "in1", label="23")
c[24] = Connection(val[4] , "out1", cons[4] , "in1", label="entrée ech4")
c[25] = Connection( cons[4], "out1", me4 , "in1", label="sortie ech4")
#retour
c[26] = Connection(pipe[5] , "out1", me1 , "in2", label="26")
c[27] = Connection(me1 , "out1", pipe[6] , "in1", label="27")
c[28] = Connection(pipe[6] , "out1", me2 , "in2", label="28")
c[29] = Connection(me2 , "out1", pipe[7] , "in1", label="29")
c[30] = Connection(pipe[7] , "out1", me3 , "in2", label="30")
c[31] = Connection(me3 , "out1", pipe[8] , "in1", label="31")
c[32] = Connection(pipe[8] , "out1", me4 , "in2", label="32")
c[33] = Connection(me4, "out1", pipe[9] , "in1", label="33")
c[34] = Connection(pipe[9] , "out1", cc , "in1", label="34")
for i in range(35):
nw.add_conns(c[i])
# %%
# Initialisation pour premier calcul
# Tuyauteries
for i in range(10):
pipe[i].set_attr(
pr=0.9,
Q=-100, # deperdition estimées
Tamb=15,
ks = 0.00045, #rugosité
D = 'var' # cherche diametre
)
pipe[0].set_attr(L=100)
pipe[1].set_attr(L=50)
pipe[2].set_attr(L=50)
pipe[3].set_attr(L=160)
pipe[4].set_attr(L=80)
pipe[5].set_attr(L=50)
pipe[6].set_attr(L=50)
pipe[7].set_attr(L=160)
pipe[8].set_attr(L=80)
pipe[9].set_attr(L=250)
# chaudière
Chaudiere.set_attr(
# Tamb=800,
pr=1,
Q='var',
Tamb = 12,
)
# pompe
Pompe.set_attr(
eta_s=0.75,
)
# consommateurs
for i in range(5):
cons[i].set_attr(
pr = 0.93,
Tamb=200,
)
val[i].set_attr(pr='var')
cons[0].set_attr(Q=-1.9e6) # Jod
cons[1].set_attr(Q=-1.8e6) # Castor
cons[2].set_attr(Q=-3e6) # Noris
cons[3].set_attr(Q=-2.5e6) # Astérix
cons[4].set_attr(Q=-1.8e6) # Pollux
# fluide, pression et températures
c[0].set_attr( fluid={Fluid : 0},p=3) # entrée chaudière
c[1].set_attr(T=330) # sortie chaudière
c[2].set_attr(p=8)
# températures de sorties
for i in (6,11,16,21,25): # sorties échangeurs
c[i].set_attr(T=230)
#calcul
nw.solve(mode="design")
nw.print_results()
# %%
# Définition des DN normalisés / Calcul des Pertes de charge et de température
# calcul du dP pompe Réel nécessaire
for i in range(10):
dn, ka = find_DN(pipe[i].D.val)
pipe[i].set_attr(
D = dn, # Diametre normalisé
kA=ka, # perte de chaleur correspondante
pr='var',
Q='var',
)
# consommateurs
for i in range(5):
cons[i].set_attr(
# Q = -6e6,
pr = 0.98,
Tamb=200,
)
val[i].set_attr(pr='var')
# Suppression de la valeur de sortie de la pompe
c[2].set_attr(p=None)
# vanne de la sortie la plus défavorisée trés ouverte
val[4].set_attr(
pr=0.99,
)
#d éfinition de la valeur cherchée de la pompe
Pompe.set_attr(
eta_s= 0.75,
pr='var'
)
#calcul
nw.solve(mode="design",max_iter=100)
nw.print_results()
# %%
nw.save('Results_omya')
# %% [markdown]
# until here everything had worked fine.....
# %%
# Calcul avec echangeur 0 arrété
# définition de la valeur cherchée de la pompe
c[2].set_attr(p=None)
# vanne forcée pour permettre calcul
val[4].set_attr(
pr=.8,
)
# fermeture de l'echangeur 0
cons[0].set_attr(
Q = 'var',
)
# fermeture de l'echangeur 0
val[0].set_attr(
pr=0,
)
# nw.solve(mode="design",max_iter=100)
nw.solve(mode="offdesign",design_path='Results_omya',max_iter=100)
nw.print_results() |
Beta Was this translation helpful? Give feedback.
3 replies
-
I've changed the last part of my code by # Calcul avec echangeur 0 arrété
# définition de la valeur cherchée de la pompe
c[2].set_attr(p=None)
# vanne forcée pour permettre calcul
val[4].set_attr(
pr=.8,
)
# fermeture de l'echangeur 0
cons[0].set_attr(
Q = 'var',
)
# fermeture de l'echangeur 0
c[6].set_attr(m=0.001)
# nw.solve(mode="design",max_iter=100)
nw.solve(mode="offdesign",design_path='Results_omya',max_iter=100)
nw.print_results() And it gives me this
I hope this could help you. It seems to me that it would be easier to configure a network if we could force a valve to be closed. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm new to TESPy and currently working on my first work-related project.
As you can probably tell, English isn't my first language—sorry about that!
I'm designing a heat network, as shown in the attached schematic:
I've created the network and performed an initial design to calculate the flows and diameters.
Then, I adjusted the diameters to match standard values (I might open another thread on this topic).
After redesigning the system, I got everything working
I'm pretty happy with the results so far!
Now, I would like to simulate what happens when the power demand changes in the consumer heat exchangers. Specifically, I'm trying to figure out how to:
I couldn’t find a clear solution for this in the documentation.
Either the number of parameters isn’t correct, or the solver fails with a "math error."
Any help or guidance would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions