oemof / tespy

Thermal Engineering Systems in Python (TESPy). This package provides a powerful simulation toolkit for thermal engineering plants such as power plants, district heating systems or heat pumps.
https://tespy.readthedocs.io
MIT License
256 stars 80 forks source link

How can i define the parameters? #496

Closed Songyihu closed 3 months ago

Songyihu commented 3 months ago

Dear Francesco Witte: Thank you for open-sourcing your great work! I'm trying to solve some engineering problems in thermodynamics with TESPy, but I'm having some problems with it. The number of parameters is fixed when I create a network, but I don't know which parameters to set. The code below is an example of what I'm simulating, I'm sorry it has some Chinese set up in it, but that shouldn't matter. The network needs 250 parameters, but I've provided 259. How do I reasonably set the correct parameters for a beginner? I would be very appreciate if you could give me some advice.

`from tespy.components import Sink, Source, HeatExchanger from tespy.connections import Connection from tespy.networks import Network from tespy.components import Drum, HeatExchanger, Sink, Source, Pump, Desuperheater, Splitter, Merge, DropletSeparator

nw = Network(fluids=['water', 'air']) nw.set_attr(p_unit='bar', T_unit='C', h_unit='kJ / kg',m_unit="kg / s", iterinfo=True)

w_source = Source('水源') g_source = Source('热烟气') s_sourceH = Source('高压缸蒸汽输入')

s_sink1 = Sink('蒸汽输出1') s_sink2 = Sink('蒸汽输出2') s_sink3 = Sink('蒸汽输出3') g_sink = Sink('烟气输出')

smqL2 = HeatExchanger('低压省煤器2') smqL2.set_attr(pr1=0.9967, pr2=0.8926, ttd_u=6.6) smqI = HeatExchanger('中压省煤器') smqI.set_attr(pr1=0.9968, pr2=0.9536, ttd_u=10.7) smqH1 = HeatExchanger('高压省煤器1') smqH1.set_attr(pr1=0.9968, pr2=0.984, ttd_u=9.9) smqH2 = HeatExchanger('高压省煤器2') smqH2.set_attr(pr1=0.9968, pr2=0.977, ttd_u=13.5) zfqL = HeatExchanger('蒸发器1') zfqL.set_attr(pr1=0.996, ttd_u=48.4) zfqI = HeatExchanger('蒸发器2') zfqI.set_attr(pr1=0.9977, ttd_u=40.2) zfqH = HeatExchanger('蒸发器3') zfqH.set_attr(pr1=0.9935, ttd_u=149.4) zrq1 = HeatExchanger('再热器1') zrq1.set_attr(pr1=0.9979, pr2=0.9846, ttd_u=35.6) zrq2 = HeatExchanger('再热器2') zrq2.set_attr(pr1=0.999, pr2=0.9736, ttd_u=30.1)

grqL1 = Desuperheater('低压过热器1') grqL1.set_attr(pr1=0.999, pr2=0.9937, ttd_u=8.0) grqL2 = Desuperheater('低压过热器2') grqL2.set_attr(pr1=0.999, pr2=0.9667, ttd_u=8.8) grqI = Desuperheater('中压过热器') grqI.set_attr(pr1=0.999, pr2=0.983, ttd_u=8.9) grqH1 = Desuperheater('高压过热器1') grqH1.set_attr(pr1=0.998, pr2=0.9816, ttd_u=61.3) grqH2 = Desuperheater('高压过热器2') grqH2.set_attr(pr1=0.999, pr2=0.97, ttd_u=49.0)

drumL = Drum('低压汽包') drumI = Drum('中压汽包') drumH = Drum('高压汽包')

merge1 = Merge('汇合点1', num_in=2) merge3 = Merge('汇合点3', num_in=2) merge4 = Merge('汇合点4', num_in=2)

split1 = Splitter('分流点1', num_out=2) split2 = Splitter('分流点2', num_out=2) splitDrum = Splitter('汽包分离器',num_out=2) splitL = Splitter('分流点低压气包', num_out=2)

pumpI = Pump('中压水泵') pumpH = Pump('高压水泵') pumpI.set_attr(pr=7.97, eta_s=0.85) pumpH.set_attr(pr=22.31, eta_s=0.85)

g2 = Connection(w_source, 'out1', smqL2, 'in2') g3 = Connection(smqL2, 'out2', drumL, 'in1')
g4 = Connection(drumL, 'out1', splitDrum, 'in1') g5 = Connection(splitDrum, 'out1', zfqL, 'in2')
g6 = Connection(splitDrum, 'out2', splitL, 'in1')
g7 = Connection(zfqL, 'out2', drumL, 'in2') g8 = Connection(drumL, 'out2', grqL1, 'in2')

r14 = Connection(grqL1, 'out2', grqL2, 'in2') r15 = Connection(grqL2, 'out2', s_sink3, 'in1')

g9 = Connection(splitL, 'out1', pumpH, 'in1')
g10 = Connection(splitL, 'out2', pumpI, 'in1')

g11 = Connection(pumpH, 'out1', smqH1, 'in2')
g12 = Connection(smqH1, 'out2', smqH2, 'in2')
g13 = Connection(smqH2, 'out2', drumH, 'in1') r1 = Connection(drumH, 'out1', zfqH, 'in2')
r2 = Connection(zfqH, 'out2', drumH, 'in2') r3 = Connection(drumH, 'out2', grqH1, 'in2') r4 = Connection(grqH1, 'out2', grqH2, 'in2') r5 = Connection(grqH2, 'out2', s_sink1, 'in1')

g14 = Connection(pumpI, 'out1', smqI, 'in2') g15 = Connection(smqI, 'out2', drumI, 'in1') r6 = Connection(drumI, 'out1', zfqI, 'in2')
r7 = Connection(zfqI, 'out2', drumI, 'in2') r8 = Connection(drumI, 'out2', grqI, 'in2')
r9 = Connection(s_sourceH, 'out1', merge1, 'in1')
r10 = Connection(grqI, 'out2', merge1, 'in2') r11 = Connection(merge1, 'out1', zrq1, 'in2')
r12 = Connection(zrq1, 'out2', zrq2, 'in2')
r13 = Connection(zrq2, 'out2', s_sink2, 'in1')

b1 = Connection(g_source, 'out1', zrq2, 'in1') b2 = Connection(zrq2, 'out1', grqH2, 'in1')
b3 = Connection(grqH2, 'out1', zrq1, 'in1')
b4 = Connection(zrq1, 'out1', grqH1, 'in1')
b5 = Connection(grqH1, 'out1', zfqH, 'in1') b6 = Connection(zfqH, 'out1', smqH2, 'in1')
b7 = Connection(smqH2, 'out1', split2, 'in1') b8 = Connection(split2, 'out1', grqI, 'in1')
b9 = Connection(split2, 'out2', merge4, 'in1') b10 = Connection(grqI, 'out1', merge4, 'in2') b11 = Connection(merge4, 'out1', zfqI, 'in1') b12 = Connection(zfqI, 'out1', grqL2, 'in1') b13 = Connection(grqL2, 'out1', split1, 'in1') b14 = Connection(split1, 'out1', smqH1, 'in1') b15 = Connection(split1, 'out2', smqI, 'in1') b16 = Connection(smqH1, 'out1', merge3, 'in1') b17 = Connection(smqI, 'out1', merge3, 'in2') b18 = Connection(merge3, 'out1', grqL1, 'in1') b19 = Connection(grqL1, 'out1', zfqL, 'in1') b20 = Connection(zfqL, 'out1', smqL2, 'in1') b21 = Connection(smqL2, 'out1', g_sink, 'in1')

nw.add_conns(g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21)

g2.set_attr(fluid={'water': 1, 'air':0}, T=84.2, p=15.89, m=101.69) b1.set_attr(fluid={'water': 0, 'air':1}, p=1.0445, T=202.9, m=622.69) r9.set_attr(fluid={'water': 1, 'air':0}, T=397.7, p=37.9, m=73.6422)

g5.set_attr(m=13.42462) g9.set_attr(m=76.814) b9.set_attr(m=278.584) b11.set_attr(fluid={'air':1})

b14.set_attr(m=546.5758)

nw.solve("design") nw.print_results()`

Songyihu commented 3 months ago

Please forget my question above, I just want to know, in a network, is there a clear specification for the way to set parameters? Thanks a lot if you could give me some advice.

tub-hofmann commented 3 months ago

Your network is huge. As a beginner, you should start with a smaller network and build it up step by step. Then parameter setting and solver stability debugging is much easier. For a gas turbine, I did a step-by-step creation, you can find here: https://github.com/tub-hofmann/tespy-gt

fwitte commented 3 months ago

Please forget my question above, I just want to know, in a network, is there a clear specification for the way to set parameters? Thanks a lot if you could give me some advice.

I am not sure what you want to say with this to be honest. The specifications are fully the designers choice... You have to make sure, that all mass flows, pressure values and enthalpy values can be determined from the combination of your specifications.