/
Thermal.mo
3319 lines (3123 loc) · 142 KB
/
Thermal.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
within ThermoPower;
package Thermal "Thermal models of heat transfer"
extends Modelica.Icons.Package;
connector HT = Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a
"Thermal port for lumped parameter heat transfer";
connector DHTNodes "Distributed Heat Terminal"
parameter Integer N(min=1) = 2 "Number of nodes";
SI.Temperature T[N] "Temperature at the nodes";
flow SI.HeatFlux phi[N] "Heat flux at the nodes";
annotation (
Diagram(coordinateSystem(preserveAspectRatio=false)),
Icon(graphics={Rectangle(
extent={{-100,100},{100,-100}},
lineColor={255,127,0},
fillColor={255,127,0},
fillPattern=FillPattern.Solid)}));
end DHTNodes;
connector DHTVolumes "Distributed Heat Terminal"
parameter Integer N "Number of volumes";
SI.Temperature T[N] "Temperature at the volumes";
flow SI.Power Q[N] "Heat flow at the volumes";
annotation (
Diagram(coordinateSystem(preserveAspectRatio=false)),
Icon(graphics={Rectangle(
extent={{-100,100},{100,-100}},
lineColor={255,127,0},
fillColor={255,127,0},
fillPattern=FillPattern.Solid)}));
end DHTVolumes;
model HThtc_HT "HThtc to HT adaptor"
HT HT_port annotation (Placement(transformation(extent={{100,-20},{140,20}},
rotation=0)));
HThtc_in HThtc_port annotation (Placement(transformation(extent={{-140,-20},
{-100,20}}, rotation=0)));
equation
HT_port.T = HThtc_port.T;
HT_port.Q_flow = HThtc_port.Q_flow;
annotation (Diagram(graphics), Icon(graphics={
Text(
extent={{-86,-4},{32,96}},
lineColor={0,0,0},
lineThickness=1,
textString="HThtc"),
Text(
extent={{-10,-92},{96,-20}},
lineColor={0,0,0},
textString="HT"),
Rectangle(extent={{-100,100},{100,-100}}, lineColor={255,0,0}),
Line(points={{100,100},{-100,-100}}, color={255,0,0})}));
end HThtc_HT;
model HT_DHTNodes "HT to DHT adaptor"
parameter Integer N=1 "Number of nodes on DHT side";
parameter SI.Area exchangeSurface "Area of heat transfer surface";
HT HT_port annotation (Placement(transformation(extent={{-140,-20},{-100,20}},
rotation=0), iconTransformation(extent={{-140,-20},{-100,20}})));
DHT DHT_port(N=N) annotation (Placement(transformation(extent={{100,-40},{
120,40}}, rotation=0)));
equation
for i in 1:N loop
DHT_port.T[i] = HT_port.T "Uniform temperature distribution on DHT side";
end for;
if N == 1 then
// Uniform flow distribution
DHT_port.phi[1]*exchangeSurface + HT_port.Q_flow = 0 "Energy balance";
else
// Piecewise linear flow distribution
sum(DHT_port.phi[1:N - 1] + DHT_port.phi[2:N])/2*exchangeSurface/(N - 1)
+ HT_port.Q_flow = 0 "Energy balance";
end if;
annotation (Icon(graphics={
Polygon(
points={{-100,100},{-100,-100},{100,100},{-100,100}},
lineColor={185,0,0},
fillColor={185,0,0},
fillPattern=FillPattern.Solid),
Polygon(
points={{100,100},{100,-100},{-100,-100},{100,100}},
lineColor={255,128,0},
fillColor={255,128,0},
fillPattern=FillPattern.Solid),
Text(
extent={{-74,10},{24,88}},
lineColor={255,255,255},
lineThickness=1,
textString="HT"),
Text(
extent={{-16,-84},{82,-6}},
lineColor={255,255,255},
lineThickness=1,
textString="DHT"),
Rectangle(
extent={{-100,100},{100,-100}},
lineColor={0,0,0},
pattern=LinePattern.None)}), Diagram(graphics));
end HT_DHTNodes;
model HT_DHTVolumes "HT to DHT adaptor"
parameter Integer N=1 "Number of volumes on the connectors";
HT HT_port annotation (Placement(transformation(extent={{-140,-20},{-100,20}},
rotation=0), iconTransformation(extent={{-140,-20},{-100,20}})));
DHTVolumes DHT_port(N=N) annotation (Placement(transformation(extent={{100,-40},{
120,40}}, rotation=0)));
equation
for i in 1:N loop
DHT_port.T[i] = HT_port.T "Uniform temperature distribution on DHT side";
end for;
sum(DHT_port.Q) + HT_port.Q_flow = 0 "Energy balance";
annotation (Icon(graphics={
Polygon(
points={{-100,100},{-100,-100},{100,100},{-100,100}},
lineColor={185,0,0},
fillColor={185,0,0},
fillPattern=FillPattern.Solid),
Polygon(
points={{100,100},{100,-100},{-100,-100},{100,100}},
lineColor={255,128,0},
fillColor={255,128,0},
fillPattern=FillPattern.Solid),
Text(
extent={{-74,10},{24,88}},
lineColor={255,255,255},
lineThickness=1,
textString="HT"),
Text(
extent={{-16,-84},{82,-6}},
lineColor={255,255,255},
lineThickness=1,
textString="DHT"),
Rectangle(
extent={{-100,100},{100,-100}},
lineColor={0,0,0},
pattern=LinePattern.None)}), Diagram(graphics));
end HT_DHTVolumes;
model TempSource1DFV
"Uniform Distributed Temperature Source for Finite Volume models"
extends Icons.HeatFlow;
parameter Integer Nw = 1 "Number of volumes on the wall port";
Thermal.DHTVolumes wall(final N=Nw) annotation (Placement(transformation(
extent={{-40,-40},{40,-20}}, rotation=0)));
Modelica.Blocks.Interfaces.RealInput temperature "Temperature [K]" annotation (Placement(
transformation(
origin={0,40},
extent={{-20,-20},{20,20}},
rotation=270)));
equation
for i in 1:Nw loop
wall.T[i] = temperature;
end for;
annotation (
Diagram(graphics),
Icon(graphics={Text(
extent={{-100,-46},{100,-70}},
lineColor={191,95,0},
textString="%name")}),
Documentation(info="<HTML>
<p>Model of an ideal 1D uniform temperature source (finite volume). The actual temperature is provided by the <tt>temperature</tt> signal connector.
</HTML>", revisions="<html>
<ul>
<li><i>3 May 2013</i>
by <a href=\"mailto:stefanoboni@hotmail.com\">Stefano Boni</a>:<br>
First release.</li>
</ul>
</html>
"));
end TempSource1DFV;
model TempSource1DlinFV
"Linearly Distributed Temperature Source for Finite Volume models"
extends Icons.HeatFlow;
parameter Integer Nw = 1 "Number of volumes on the wall port";
Thermal.DHTVolumes wall(final N=Nw) annotation (Placement(transformation(
extent={{-40,-40},{40,-20}}, rotation=0)));
Modelica.Blocks.Interfaces.RealInput temperature_1 annotation (
Placement(transformation(
origin={-40,30},
extent={{-20,-20},{20,20}},
rotation=270)));
Modelica.Blocks.Interfaces.RealInput temperature_Nw annotation (
Placement(transformation(
origin={40,28},
extent={{-20,-20},{20,20}},
rotation=270)));
equation
wall.T = Functions.linspaceExt(
temperature_1,
temperature_Nw,
Nw);
annotation (
Documentation(info="<HTML>
<p>Model of an ideal 1D temperature source with a linear distribution. The values of the temperature at the two ends of the source are provided by the <tt>temperature_node1</tt> and <tt>temperature_nodeN</tt> signal connectors.
</HTML>", revisions="<html>
<ul>
<li><i>10 Jan 2004</i>
by <a href=\"mailto:francesco.schiavo@polimi.it\">Francesco Schiavo</a>:<br>
First release.</li>
</ul>
</html>
"), Icon(graphics={Text(
extent={{-100,-46},{100,-72}},
lineColor={191,95,0},
textString="%name")}));
end TempSource1DlinFV;
model TempSource1DFEM "Distributed Temperature Source for FEM models"
extends Icons.HeatFlow;
parameter Integer N=2 "Number of nodes";
Thermal.DHTNodes wall(N=N) annotation (Placement(transformation(
extent={{-40,-40},{40,-20}}, rotation=0)));
Modelica.Blocks.Interfaces.RealInput temperature annotation (Placement(
transformation(
origin={0,40},
extent={{-20,-20},{20,20}},
rotation=270)));
equation
for i in 1:N loop
wall.T[i] = temperature;
end for;
annotation (
Diagram(graphics),
Icon(graphics={Text(
extent={{-100,-46},{100,-70}},
lineColor={191,95,0},
textString="%name")}),
Documentation(info="<HTML>
<p>Model of an ideal 1D uniform temperature source. The actual temperature is provided by the <tt>temperature</tt> signal connector.
</HTML>", revisions="<html>
<ul>
<li><i>1 Oct 2003</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
First release.</li>
</ul>
</html>
"));
end TempSource1DFEM;
model TempSource1DlinFEM
"Linearly Distributed Temperature Source for FEM models"
extends Icons.HeatFlow;
parameter Integer N=2 "Number of nodes";
Thermal.DHTNodes wall(N=N) annotation (Placement(transformation(
extent={{-40,-40},{40,-20}}, rotation=0)));
Modelica.Blocks.Interfaces.RealInput temperature_node1 annotation (
Placement(transformation(
origin={-40,30},
extent={{-20,-20},{20,20}},
rotation=270)));
Modelica.Blocks.Interfaces.RealInput temperature_nodeN annotation (
Placement(transformation(
origin={40,28},
extent={{-20,-20},{20,20}},
rotation=270)));
equation
wall.T = linspace(
temperature_node1,
temperature_nodeN,
N);
annotation (
Documentation(info="<HTML>
<p>Model of an ideal 1D temperature source with a linear distribution. The values of the temperature at the two ends of the source are provided by the <tt>temperature_node1</tt> and <tt>temperature_nodeN</tt> signal connectors.
</HTML>", revisions="<html>
<ul>
<li><i>10 Jan 2004</i>
by <a href=\"mailto:francesco.schiavo@polimi.it\">Francesco Schiavo</a>:<br>
First release.</li>
</ul>
</html>
"), Icon(graphics={Text(
extent={{-100,-46},{100,-72}},
lineColor={191,95,0},
textString="%name")}));
end TempSource1DlinFEM;
model HeatSource1DFV "Distributed Heat Flow Source for Finite Volume models"
extends Icons.HeatFlow;
parameter Integer Nw = 1 "Number of volumes on the wall port";
Thermal.DHTVolumes wall(final N=Nw) annotation (Placement(transformation(
extent={{-40,-40},{40,-20}}, rotation=0)));
Modelica.Blocks.Interfaces.RealInput power annotation (Placement(
transformation(
origin={0,40},
extent={{-20,-20},{20,20}},
rotation=270)));
equation
for i in 1:Nw loop
wall.Q[i] = -power/Nw;
end for;
annotation (
Diagram(graphics),
Icon(graphics={Text(
extent={{-100,-44},{100,-68}},
lineColor={191,95,0},
textString="%name")}),
Documentation(info="<HTML>
<p>Model of an ideal tubular heat flow source, with uniform heat flux. The actual heating power is provided by the <tt>power</tt> signal connector.
</HTML>", revisions="<html>
<ul>
<li><i>1 Oct 2003</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
First release.</li>
</ul>
</html>
"));
end HeatSource1DFV;
model HeatSource1DNonUniformFV
"Distributed Heat Flow Source for Finite Volume models with non-uniformly distributed flow"
extends Icons.HeatFlow;
parameter Integer Nw = 1 "Number of volumes on the wall port";
Thermal.DHTVolumes wall(final N=Nw) annotation (Placement(transformation(
extent={{-40,-40},{40,-20}}, rotation=0)));
Modelica.Blocks.Interfaces.RealInput power[Nw] annotation (Placement(
transformation(
origin={0,40},
extent={{-20,-20},{20,20}},
rotation=270)));
equation
wall.Q = -power;
annotation (
Diagram(graphics),
Icon(graphics={Text(
extent={{-100,-44},{100,-68}},
lineColor={191,95,0},
textString="%name")}),
Documentation(info="<HTML>
<p>Model of an ideal tubular heat flow source, with uniform heat flux. The actual heating power is provided by the <tt>power</tt> signal connector.
</HTML>", revisions="<html>
<ul>
<li><i>1 Oct 2003</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
First release.</li>
</ul>
</html>
"));
end HeatSource1DNonUniformFV;
model HeatSource1DFEM "Distributed Heat Flow Source for FEM models"
extends Icons.HeatFlow;
parameter Integer N=2 "Number of nodes";
parameter Integer Nt=1 "Number of tubes";
parameter SI.Length L "Source length";
parameter SI.Length omega "Source perimeter (single tube)";
Thermal.DHTNodes wall(N=N) annotation (Placement(transformation(
extent={{-40,-40},{40,-20}}, rotation=0)));
Modelica.Blocks.Interfaces.RealInput power annotation (Placement(
transformation(
origin={0,40},
extent={{-20,-20},{20,20}},
rotation=270)));
equation
for i in 1:N loop
wall.phi[i] = -power/(omega*L*Nt);
end for;
annotation (
Diagram(graphics),
Icon(graphics={Text(
extent={{-100,-44},{100,-68}},
lineColor={191,95,0},
textString="%name")}),
Documentation(info="<HTML>
<p>Model of an ideal tubular heat flow source, with uniform heat flux. The actual heating power is provided by the <tt>power</tt> signal connector.
</HTML>", revisions="<html>
<ul>
<li><i>1 Oct 2003</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
First release.</li>
</ul>
</html>
"));
end HeatSource1DFEM;
model MetalTubeFV "Cylindrical metal tube model with Nw finite volumes"
extends Icons.MetalWall;
parameter Integer Nw = 1 "Number of volumes on the wall ports";
parameter Integer Nt = 1 "Number of tubes in parallel";
parameter SI.Length L "Tube length";
parameter SI.Length rint "Internal radius (single tube)";
parameter SI.Length rext "External radius (single tube)";
parameter Real rhomcm "Metal heat capacity per unit volume [J/m^3.K]";
parameter SI.ThermalConductivity lambda "Thermal conductivity";
parameter Boolean WallRes=true "Wall thermal resistance accounted for";
parameter SI.Temperature Tstartbar=300 "Avarage temperature"
annotation (Dialog(tab="Initialisation"));
parameter SI.Temperature Tstart1=Tstartbar
"Temperature start value - first volume"
annotation (Dialog(tab="Initialisation"));
parameter SI.Temperature TstartN=Tstartbar
"Temperature start value - last volume"
annotation (Dialog(tab="Initialisation"));
parameter SI.Temperature Tvolstart[Nw]=
Functions.linspaceExt(Tstart1, TstartN, Nw)
annotation (Dialog(tab="Initialisation"));
parameter Choices.Init.Options initOpt=system.initOpt
"Initialisation option"
annotation (Dialog(tab="Initialisation"));
constant Real pi=Modelica.Constants.pi;
final parameter SI.Area Am = (rext^2 - rint^2)*pi
"Area of the metal tube cross-section";
final parameter SI.HeatCapacity Cm = Nt*L*Am*rhomcm "Total heat capacity";
outer ThermoPower.System system "System wide properties";
SI.Temperature Tvol[Nw](start=Tvolstart) "Volume temperatures";
ThermoPower.Thermal.DHTVolumes int(final N=Nw, T(start=Tvolstart))
"Internal surface"
annotation (Placement(transformation(extent={{-40,20},{40,40}}, rotation=0)));
ThermoPower.Thermal.DHTVolumes ext(final N=Nw, T(start=Tvolstart))
"External surface"
annotation (Placement(transformation(extent={{-40,-42},{40,-20}}, rotation=0)));
equation
assert(rext > rint, "External radius must be greater than internal radius");
(L/Nw*Nt)*rhomcm*Am*der(Tvol) = int.Q + ext.Q "Energy balance";
if WallRes then
// Thermal resistance of the tube walls accounted for
int.Q = (lambda*(2*pi*L/Nw)*(int.T - Tvol))/(log((rint + rext)/(2*rint)))*Nt
"Heat conduction through the internal half-thickness";
ext.Q = (lambda*(2*pi*L/Nw)*(ext.T - Tvol))/(log((2*rext)/(rint + rext)))*Nt
"Heat conduction through the external half-thickness";
else
// No temperature gradients across the thickness
ext.T = Tvol;
int.T = Tvol;
end if;
initial equation
if initOpt == Choices.Init.Options.noInit then
// do nothing
elseif initOpt == Choices.Init.Options.fixedState then
Tvol = Tvolstart;
elseif initOpt == Choices.Init.Options.steadyState then
der(Tvol) = zeros(Nw);
elseif initOpt == Choices.Init.Options.steadyStateNoT then
// do nothing
else
assert(false, "Unsupported initialisation option");
end if;
annotation (
Icon(graphics={
Text(
extent={{-100,60},{-40,20}},
lineColor={0,0,0},
fillColor={128,128,128},
fillPattern=FillPattern.Forward,
textString="Int"),
Text(
extent={{-100,-20},{-40,-60}},
lineColor={0,0,0},
fillColor={128,128,128},
fillPattern=FillPattern.Forward,
textString="Ext"),
Text(
extent={{-138,-60},{142,-100}},
lineColor={191,95,0},
textString="%name")}),
Documentation(info="<HTML>
<p>This is the model of a cylindrical tube of solid material.
<p>The heat capacity (which is lumped at the center of the tube thickness) is accounted for, as well as the thermal resistance due to the finite heat conduction coefficient. Longitudinal heat conduction is neglected.
<p><b>Modelling options</b></p>
<p>The following options are available:
<ul>
<li><tt>WallRes = false</tt>: the thermal resistance of the tube wall is neglected.
<li><tt>WallRes = true</tt>: the thermal resistance of the tube wall is accounted for.
</ul>
</HTML>", revisions="<html>
<ul>
<li><i>30 May 2005</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
Initialisation support added.</li>
<li><i>1 Oct 2003</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
First release.</li>
</ul>
</html>
"), Diagram(graphics));
end MetalTubeFV;
model MetalTubeFEM "Cylindrical metal tube - 1 radial node and N axial nodes"
extends Icons.MetalWall;
parameter Integer N(min=1) = 2 "Number of nodes";
parameter SI.Length L "Tube length";
parameter SI.Length rint "Internal radius (single tube)";
parameter SI.Length rext "External radius (single tube)";
parameter Real rhomcm "Metal heat capacity per unit volume [J/m^3.K]";
parameter SI.ThermalConductivity lambda "Thermal conductivity";
parameter Boolean WallRes=true "Wall conduction resistance accounted for";
parameter SI.Temperature Tstartbar=300 "Avarage temperature"
annotation (Dialog(tab="Initialisation"));
parameter SI.Temperature Tstart1=Tstartbar
"Temperature start value - first node"
annotation (Dialog(tab="Initialisation"));
parameter SI.Temperature TstartN=Tstartbar
"Temperature start value - last node"
annotation (Dialog(tab="Initialisation"));
parameter SI.Temperature Tstart[N]=Functions.linspaceExt(
Tstart1,
TstartN,
N) "Start value of temperature vector (initialized by default)"
annotation (Dialog(tab="Initialisation"));
parameter Choices.Init.Options initOpt = system.initOpt
"Initialisation option" annotation (Dialog(tab="Initialisation"));
constant Real pi=Modelica.Constants.pi;
outer ThermoPower.System system "System wide properties";
SI.Temperature T[N](start=Tstart) "Node temperatures";
SI.Area Am "Area of the metal tube cross-section";
DHT int(N=N, T(start=Tstart)) "Internal surface" annotation (Placement(
transformation(extent={{-40,20},{40,40}}, rotation=0)));
DHT ext(N=N, T(start=Tstart)) "External surface" annotation (Placement(
transformation(extent={{-40,-42},{40,-20}}, rotation=0)));
equation
assert(rext > rint, "External radius must be greater than internal radius");
Am = (rext^2 - rint^2)*pi "Area of the metal cross section";
rhomcm*Am*der(T) = rint*2*pi*int.phi + rext*2*pi*ext.phi "Energy balance";
if WallRes then
int.phi = lambda/(rint*log((rint + rext)/(2*rint)))*(int.T - T)
"Heat conduction through the internal half-thickness";
ext.phi = lambda/(rext*log((2*rext)/(rint + rext)))*(ext.T - T)
"Heat conduction through the external half-thickness";
else
// No temperature gradients across the thickness
int.T = T;
ext.T = T;
end if;
initial equation
if initOpt == Choices.Init.Options.noInit then
// do nothing
elseif initOpt == Choices.Init.Options.fixedState then
T = Tstart;
elseif initOpt == Choices.Init.Options.steadyState then
der(T) = zeros(N);
elseif initOpt == Choices.Init.Options.steadyStateNoT then
// do nothing
else
assert(false, "Unsupported initialisation option");
end if;
annotation (
Icon(graphics={
Text(
extent={{-100,60},{-40,20}},
lineColor={0,0,0},
fillColor={128,128,128},
fillPattern=FillPattern.Forward,
textString="Int"),
Text(
extent={{-100,-20},{-40,-60}},
lineColor={0,0,0},
fillColor={128,128,128},
fillPattern=FillPattern.Forward,
textString="Ext"),
Text(
extent={{-138,-60},{142,-100}},
lineColor={191,95,0},
textString="%name")}),
Documentation(info="<HTML>
<p>This is the model of a cylindrical tube of solid material.
<p>The heat capacity (which is lumped at the center of the tube thickness) is accounted for, as well as the thermal resistance due to the finite heat conduction coefficient. Longitudinal heat conduction is neglected.
<p><b>Modelling options</b></p>
<p>The following options are available:
<ul>
<li><tt>WallRes = false</tt>: the thermal resistance of the tube wall is neglected.
<li><tt>WallRes = true</tt>: the thermal resistance of the tube wall is accounted for.
</ul>
</HTML>", revisions="<html>
<ul>
<li><i>30 May 2005</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
Initialisation support added.</li>
<li><i>1 Oct 2003</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
First release.</li>
</ul>
</html>
"), Diagram(graphics));
end MetalTubeFEM;
model MetalWallFV "Generic metal wall model with Nw finite volumes"
extends ThermoPower.Icons.MetalWall;
parameter Integer Nw = 1 "Number of volumes on the wall ports";
parameter SI.Mass M "Mass";
parameter SI.SpecificHeatCapacity cm "Specific heat capacity of metal";
parameter SI.HeatCapacity Cm = M*cm "Heat capacity of the wall";
parameter Boolean WallRes=false "Wall thermal resistance accounted for";
parameter SI.ThermalConductance UA_ext = 0
"Equivalent thermal conductance of outer half-wall"
annotation(Dialog(enable = WallRes));
parameter SI.ThermalConductance UA_int = UA_ext
"Equivalent thermal conductance of inner half-wall"
annotation(Dialog(enable = WallRes));
parameter SI.Temperature Tstartbar=300 "Average temperature"
annotation (Dialog(tab="Initialisation"));
parameter SI.Temperature Tstart1=Tstartbar
"Temperature start value - first volume"
annotation (Dialog(tab="Initialisation"));
parameter SI.Temperature TstartN=Tstartbar
"Temperature start value - last volume"
annotation (Dialog(tab="Initialisation"));
parameter SI.Temperature Tvolstart[Nw]=
Functions.linspaceExt(Tstart1, TstartN, Nw)
annotation (Dialog(tab="Initialisation"));
parameter ThermoPower.Choices.Init.Options initOpt = system.initOpt
"Initialisation option" annotation (Dialog(tab="Initialisation"));
constant Real pi=Modelica.Constants.pi;
outer ThermoPower.System system "System wide properties";
Units.AbsoluteTemperature Tvol[Nw](start=Tvolstart) "Volume temperatures";
ThermoPower.Thermal.DHTVolumes int(final N=Nw, T(start=Tvolstart))
"Internal surface"
annotation (Placement(transformation(extent={{-40,20},{40,40}}, rotation=0)));
ThermoPower.Thermal.DHTVolumes ext(final N=Nw, T(start=Tvolstart))
"External surface"
annotation (Placement(transformation(extent={{-40,-42},{40,-20}}, rotation=0)));
equation
(Cm/Nw)*der(Tvol) = int.Q + ext.Q "Energy balance";
if WallRes then
assert(UA_int > 0 and UA_ext > 0, "Assign positive values to UA_int, UA_ext");
ext.Q = (ext.T-Tvol)*UA_ext/Nw;
int.Q = (int.T-Tvol)*UA_int/Nw;
else
// No temperature gradients across the thickness
ext.T = Tvol;
int.T = Tvol;
end if;
initial equation
if initOpt == ThermoPower.Choices.Init.Options.noInit then
// do nothing
elseif initOpt == Choices.Init.Options.fixedState then
Tvol = Tvolstart;
elseif initOpt == ThermoPower.Choices.Init.Options.steadyState then
der(Tvol) = zeros(Nw);
elseif initOpt == ThermoPower.Choices.Init.Options.steadyStateNoT then
// do nothing
else
assert(false, "Unsupported initialisation option");
end if;
annotation (
Icon(graphics={
Text(
extent={{-100,60},{-40,20}},
lineColor={0,0,0},
fillColor={128,128,128},
fillPattern=FillPattern.Forward,
textString="Int"),
Text(
extent={{-100,-20},{-40,-60}},
lineColor={0,0,0},
fillColor={128,128,128},
fillPattern=FillPattern.Forward,
textString="Ext"),
Text(
extent={{-138,-60},{142,-100}},
lineColor={191,95,0},
textString="%name")}),
Documentation(info="<html>
<p>Finite volumes 1D model of a generic wall for 1D heat exchangers.</p>
<p>The heat capacity of the wall is accounted for, and lumped half-way between the inner and outer surfaces.</p>
<p>The thermal resistance of the wall is optionally accounted for by setting WallRes = true; in that case, the total heat conductance of the outer and inner half-layers of the wall must then be set. For a flat (or approximately flat) wall with surface S, thickness d and conductivity lambda, both parameters are equal to 2*S*lambda/d.</p>
<h4>Modelling options</h4>
<p>The following options are available: </p>
<ul>
<li><code>WallRes = false</code>: the thermal resistance of the wall is neglected. </li>
<li><code>WallRes = true</code>: the thermal resistance of the wall is accounted for. </li>
</ul>
</html>", revisions="<html>
<ul>
<li>11 Jul 2014 by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>Added support for wall resistance.</li>
<li><i>30 May 2005</i> by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>Initialisation support added.</li>
<li><i>1 Oct 2003</i> by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>First release. </li>
</ul>
</html>"),
Diagram(graphics));
end MetalWallFV;
model MetalWallFEM "Generic metal wall - 1 radial node and N axial nodes"
extends ThermoPower.Icons.MetalWall;
parameter Integer N(min=1) = 2 "Number of nodes";
parameter SI.Mass M "Mass";
parameter SI.Area Sint "Internal surface";
parameter SI.Area Sext "External surface";
parameter SI.SpecificHeatCapacity cm "Specific heat capacity of metal";
parameter SI.HeatCapacity Cm = M*cm "Heat capacity of the wall";
parameter SI.Temperature Tstartbar=300 "Avarage temperature"
annotation (Dialog(tab="Initialisation"));
parameter SI.Temperature Tstart1=Tstartbar
"Temperature start value - first node"
annotation (Dialog(tab="Initialisation"));
parameter SI.Temperature TstartN=Tstartbar
"Temperature start value - last node"
annotation (Dialog(tab="Initialisation"));
parameter SI.Temperature Tstart[N]=Functions.linspaceExt(
Tstart1,
TstartN,
N) "Start value of temperature vector (initialized by default)"
annotation (Dialog(tab="Initialisation"));
parameter ThermoPower.Choices.Init.Options initOpt = system.initOpt
"Initialisation option" annotation (Dialog(tab="Initialisation"));
constant Real pi=Modelica.Constants.pi;
outer ThermoPower.System system "System wide properties";
Units.AbsoluteTemperature T[N](start=Tstart) "Node temperatures";
ThermoPower.Thermal.DHT int(N=N, T(start=Tstart)) "Internal surface"
annotation (Placement(transformation(extent={{-40,20},{40,40}}, rotation=
0)));
ThermoPower.Thermal.DHT ext(N=N, T(start=Tstart)) "External surface"
annotation (Placement(transformation(extent={{-40,-42},{40,-20}},
rotation=0)));
equation
Cm*der(T) = Sint*int.phi + Sext*ext.phi "Energy balance";
// No temperature gradients across the thickness
int.T = T;
ext.T = T;
initial equation
if initOpt == ThermoPower.Choices.Init.Options.noInit then
// do nothing
elseif initOpt == Choices.Init.Options.fixedState then
T = Tstart;
elseif initOpt == ThermoPower.Choices.Init.Options.steadyState then
der(T) = zeros(N);
elseif initOpt == ThermoPower.Choices.Init.Options.steadyStateNoT then
// do nothing
else
assert(false, "Unsupported initialisation option");
end if;
annotation (
Icon(graphics={
Text(
extent={{-100,60},{-40,20}},
lineColor={0,0,0},
fillColor={128,128,128},
fillPattern=FillPattern.Forward,
textString="Int"),
Text(
extent={{-100,-20},{-40,-60}},
lineColor={0,0,0},
fillColor={128,128,128},
fillPattern=FillPattern.Forward,
textString="Ext"),
Text(
extent={{-138,-60},{142,-100}},
lineColor={191,95,0},
textString="%name")}),
Documentation(info="<HTML>
<p>This is the model of a cylindrical tube of solid material.
<p>The heat capacity (which is lumped at the center of the tube thickness) is accounted for, as well as the thermal resistance due to the finite heat conduction coefficient. Longitudinal heat conduction is neglected.
<p><b>Modelling options</b></p>
<p>The following options are available:
<ul>
<li><tt>WallRes = false</tt>: the thermal resistance of the tube wall is neglected.
<li><tt>WallRes = true</tt>: the thermal resistance of the tube wall is accounted for.
</ul>
</HTML>", revisions="<html>
<ul>
<li><i>30 May 2005</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
Initialisation support added.</li>
<li><i>1 Oct 2003</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
First release.</li>
</ul>
</html>
"), Diagram(graphics));
end MetalWallFEM;
model HeatExchangerTopologyFV
"Connects two DHTVolumes ports according to a selected heat exchanger topology"
extends Icons.HeatFlow;
parameter Integer Nw "Number of volumes";
replaceable model HeatExchangerTopology =
HeatExchangerTopologies.CoCurrentFlow
constrainedby ThermoPower.Thermal.BaseClasses.HeatExchangerTopologyData
annotation(choicesAllMatching=true);
HeatExchangerTopology HET(final Nw = Nw);
Thermal.DHTVolumes side1(final N=Nw) annotation (Placement(transformation(extent={{-40,20},
{40,40}}, rotation=0)));
Thermal.DHTVolumes side2(final N=Nw) annotation (Placement(transformation(extent={{-40,-42},
{40,-20}}, rotation=0)));
equation
for j in 1:Nw loop
side2.T[HET.correspondingVolumes[j]] = side1.T[j];
side2.Q[HET.correspondingVolumes[j]] + side1.Q[j] = 0;
end for;
annotation (
Diagram(graphics),
Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}),
graphics));
end HeatExchangerTopologyFV;
model CounterCurrentFV
"Connects two DHTVolume ports according to a counter-current flow configuration"
extends ThermoPower.Thermal.HeatExchangerTopologyFV(
redeclare model HeatExchangerTopology =
HeatExchangerTopologies.CounterCurrentFlow);
annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
{100,100}}),
graphics={
Polygon(
points={{-74,2},{-48,8},{-74,16},{-56,8},{-74,2}},
lineColor={0,0,0},
fillColor={0,0,0},
fillPattern=FillPattern.Solid),
Polygon(
points={{74,-16},{60,-10},{74,-2},{52,-10},{74,-16}},
lineColor={0,0,0},
fillColor={0,0,0},
fillPattern=FillPattern.Solid)}),
Documentation(info="<HTML>
<p>This component can be used to model counter-current heat transfer. The temperature and flux vectors on one side are swapped with respect to the other side. This means that the temperature of node <tt>j</tt> on side 1 is equal to the temperature of note <tt>N-j+1</tt> on side 2; heat fluxes behave correspondingly.
<p>
The swapping is performed if the counterCurrent parameter is true (default value).
</HTML>", revisions="<html>
<ul>
<li><i>25 Aug 2005</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
<tt>counterCurrent</tt> parameter added.</li>
<li><i>1 Oct 2003</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
First release.</li>
</ul>
</html>
"));
end CounterCurrentFV;
model CounterCurrentFEM
"Counter-current heat transfer adaptor for 1D FEM heat exchangers"
extends Icons.HeatFlow;
parameter Integer N=2 "Number of Nodes";
parameter Boolean counterCurrent=true
"Swap temperature and flux vector order";
Thermal.DHTNodes side1(N=N) annotation (Placement(transformation(extent={{-40,20},
{40,40}}, rotation=0)));
Thermal.DHTNodes side2(N=N) annotation (Placement(transformation(extent={{-40,-42},
{40,-20}}, rotation=0)));
equation
// Swap temperature and flux vector order
if counterCurrent then
side1.phi = -side2.phi[N:-1:1];
side1.T = side2.T[N:-1:1];
else
side1.phi = -side2.phi;
side1.T = side2.T;
end if;
annotation (Icon(graphics={
Polygon(
points={{-74,2},{-48,8},{-74,16},{-56,8},{-74,2}},
lineColor={0,0,0},
fillColor={0,0,0},
fillPattern=FillPattern.Solid),
Polygon(
points={{74,-16},{60,-10},{74,-2},{52,-10},{74,-16}},
lineColor={0,0,0},
fillColor={0,0,0},
fillPattern=FillPattern.Solid)}),
Documentation(info="<HTML>
<p>This component can be used to model counter-current heat transfer. The temperature and flux vectors on one side are swapped with respect to the other side. This means that the temperature of node <tt>j</tt> on side 1 is equal to the temperature of note <tt>N-j+1</tt> on side 2; heat fluxes behave correspondingly.
<p>
The swapping is performed if the counterCurrent parameter is true (default value).
</HTML>", revisions="<html>
<ul>
<li><i>25 Aug 2005</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
<tt>counterCurrent</tt> parameter added.</li>
<li><i>1 Oct 2003</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
First release.</li>
</ul>
</html>
"));
end CounterCurrentFEM;
model ConvHTFV "1D Constant thermal conductance"
extends Icons.HeatFlow;
parameter Integer Nv=2 "Number of finite volumes";
parameter SI.ThermalConductance G "Overall thermal conductance";
DHTVolumes side1(final N=Nv) annotation (Placement(transformation(extent={{-40,20},{40,40}},
rotation=0)));
DHTVolumes side2(final N=Nv) annotation (Placement(transformation(extent={{-40,-42},{40,-20}},
rotation=0)));
equation
side1.Q = G*(side1.T - side2.T) "Convective heat transfer";
side1.Q + side2.Q = zeros(Nv) "Static energy balance";
annotation (Icon(graphics={Text(
extent={{-100,-44},{100,-68}},
lineColor={191,95,0},
textString="%name")}), Documentation(info="<HTML>
<p>Model of a uniformly distributed finite-volume constant thermal conductance between two 1D objects.
<p>Volume <tt>j</tt> on side 1 interacts with volume <tt>j</tt> on side 2.
</HTML>", revisions="<html>
<li><i>23 Oct 2018</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
First release.</li>
</ul>
</html>"));
end ConvHTFV;
model FoulingFV "1D FV thermal resistance due to fouling"
extends ConvHTFV(final G = A/R);
parameter Units.SpecificThermalResistance R "Fouling factor";
parameter SI.Area A "Total surface";
end FoulingFV;
model ConvHTLumped "Lumped parameter convective heat transfer"
extends Icons.HeatFlow;
parameter SI.ThermalConductance G "Constant thermal conductance";
HT side1 annotation (Placement(transformation(extent={{-40,20},{40,40}},
rotation=0)));
HT side2 annotation (Placement(transformation(extent={{-40,-20},{40,-42}},
rotation=0)));
equation
side1.Q_flow = G*(side1.T - side2.T) "Convective heat transfer";
side1.Q_flow = -side2.Q_flow "Energy balance";
annotation (Icon(graphics={Text(
extent={{-98,-76},{102,-100}},
lineColor={191,95,0},
textString="%name")}), Documentation(info="<HTML>
<p>Model of a simple convective heat transfer mechanism between two lumped parameter objects, with a constant heat transfer coefficient.
</HTML>", revisions="<html>
<li><i>28 Dic 2005</i>
by <a href=\"mailto:francesco.casella@polimi.it\">Francesco Casella</a>:<br>
First release.</li>
</ul>
</html>"));
end ConvHTLumped;
package HeatTransferFV "Heat transfer models for FV components"
model IdealHeatTransfer
"Delta T across the boundary layer is zero (infinite h.t.c.)"
extends BaseClasses.DistributedHeatTransferFV(final useAverageTemperature=false);
equation
assert(Nw == Nf - 1, "Number of volumes Nw on wall side should be equal to number of volumes fluid side Nf - 1");
for j in 1:Nw loop
wall.T[j] = T[j+1] "Ideal infinite heat transfer";
end for;
end IdealHeatTransfer;
model ConstantHeatTransferCoefficient "Constant heat transfer coefficient"
extends BaseClasses.DistributedHeatTransferFV;
parameter SI.CoefficientOfHeatTransfer gamma
"Constant heat transfer coefficient";
parameter Boolean adaptiveAverageTemperature = true
"Adapt the average temperature at low flow rates";
parameter Modelica.SIunits.PerUnit sigma = 0.1
"Fraction of nominal flow rate below which the heat transfer is computed on outlet volume temperatures";
SI.PerUnit w_wnom "Ratio between actual and nominal flow rate";
Medium.Temperature Tvol[Nw] "Fluid temperature in the volumes";
equation
assert(Nw == Nf - 1, "The number of volumes Nw on wall side should be equal to number of volumes fluid side Nf - 1");
w_wnom = abs(w[1])/wnom;
for j in 1:Nw loop
Tvol[j] =
if not useAverageTemperature then T[j+1]
else if not adaptiveAverageTemperature then (T[j] + T[j + 1])/2
else (T[j]+T[j+1])/2 + (T[j+1]-T[j])/2*exp(-w_wnom/sigma);
Qw[j] = (Tw[j] - Tvol[j])*omega*l*kc*gamma*Nt;
end for;
annotation (
Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{
100,100}}),
graphics),
Icon(graphics={Text(extent={{-100,-52},{100,-80}}, textString="%name")}),
Documentation(info="<html>
<p>This component assumes a uniform and connstant heat transfer coefficient gamma.</p>
<p>If useAverageTemperature=false, the outlet fluid temperature of each volume is used to compute the heat transfer, otherwise the average temperature between inlet and outlet is used.</p>
<p>In the latter case, the temperature distribution is accurately predicted if N > NTU. However, non-physical temperature distributions and numerical problems can arise at low flows, when NTU increases. If adaptiveAverageTemperature=true, then the outlet temperature is used instead of the average one when w/wnom_ht < sigma. This leads to physically realistic temperature distributions and better numerical properties at low or zero flows.</p>
</html>"));
end ConstantHeatTransferCoefficient;
model ConstantHeatTransferCoefficientTwoGrids
"Constant heat transfer coefficient - different grids for fluid and wall side"
extends BaseClasses.DistributedHeatTransferFV(
final useAverageTemperature = true,
Qvol=Qv);
parameter SI.CoefficientOfHeatTransfer gamma
"Constant heat transfer coefficient";
final parameter Integer Nv = Nf - 1
"Number of volumes on the fluid side";
final parameter SI.Length lw = L/Nw "Length of volumes on the wall side";
final parameter SI.Length lv = L/Nv
"Length of volumes on the fluid side";
Medium.Temperature Tv[Nf-1] "Fluid temperature in the volumes";
SI.Power Qv[Nf-1] "Heat flows entering the volumes";
final parameter SI.PerUnit Hv[min(Nw,Nv),Nv] = getH(Nw,Nv)
"Sums heat flows on fluid side onto coarser grid"
annotation(Evaluate = true);
final parameter SI.PerUnit Hw[min(Nw,Nv),Nw] = getH(Nv,Nw)
"Sums heat flows on wall side onto coarser grid"
annotation(Evaluate = true);
final parameter SI.PerUnit G[max(Nw,Nv),min(Nw,Nv)] = transpose(getH(min(Nw,Nv),max(Nw,Nv)))
"Maps temperatures on coarser grid onto finer grid"
annotation(Evaluate = true);