forked from modelica/ModelicaStandardLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IF97_Utilities.mo
8741 lines (8365 loc) · 363 KB
/
IF97_Utilities.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 Modelica.Media.Water;
package IF97_Utilities
"Low level and utility computation for high accuracy water properties according to the IAPWS/IF97 standard"
extends Modelica.Icons.UtilitiesPackage;
package BaseIF97
"Modelica Physical Property Model: the new industrial formulation IAPWS-IF97"
extends Modelica.Icons.Package;
record IterationData "Constants for iterations internal to some functions"
extends Modelica.Icons.Record;
constant Integer IMAX=50
"Maximum number of iterations for inverse functions";
constant Real DELP=1.0e-6 "Maximum iteration error in pressure, Pa";
constant Real DELS=1.0e-8
"Maximum iteration error in specific entropy, J/{kg.K}";
constant Real DELH=1.0e-8
"Maximum iteration error in specific enthalpy, J/kg";
constant Real DELD=1.0e-8 "Maximum iteration error in density, kg/m^3";
end IterationData;
//===================================================================
// Constant declarations
//===================================================================
record data "Constant IF97 data and region limits"
extends Modelica.Icons.Record;
constant SI.SpecificHeatCapacity RH2O=461.526
"Specific gas constant of water vapour";
constant SI.MolarMass MH2O=0.01801528 "Molar weight of water";
constant SI.Temperature TSTAR1=1386.0
"Normalization temperature for region 1 IF97";
constant SI.Pressure PSTAR1=16.53e6
"Normalization pressure for region 1 IF97";
constant SI.Temperature TSTAR2=540.0
"Normalization temperature for region 2 IF97";
constant SI.Pressure PSTAR2=1.0e6
"Normalization pressure for region 2 IF97";
constant SI.Temperature TSTAR5=1000.0
"Normalization temperature for region 5 IF97";
constant SI.Pressure PSTAR5=1.0e6
"Normalization pressure for region 5 IF97";
constant SI.SpecificEnthalpy HSTAR1=2.5e6
"Normalization specific enthalpy for region 1 IF97";
constant Real IPSTAR=1.0e-6
"Normalization pressure for inverse function in region 2 IF97";
constant Real IHSTAR=5.0e-7
"Normalization specific enthalpy for inverse function in region 2 IF97";
constant SI.Temperature TLIMIT1=623.15
"Temperature limit between regions 1 and 3";
constant SI.Temperature TLIMIT2=1073.15
"Temperature limit between regions 2 and 5";
constant SI.Temperature TLIMIT5=2273.15 "Upper temperature limit of 5";
constant SI.Pressure PLIMIT1=100.0e6
"Upper pressure limit for regions 1, 2 and 3";
constant SI.Pressure PLIMIT4A=16.5292e6
"Pressure limit between regions 1 and 2, important for two-phase (region 4)";
constant SI.Pressure PLIMIT5=10.0e6
"Upper limit of valid pressure in region 5";
constant SI.Pressure PCRIT=22064000.0 "The critical pressure";
constant SI.Temperature TCRIT=647.096 "The critical temperature";
constant SI.Density DCRIT=322.0 "The critical density";
constant SI.SpecificEntropy SCRIT=4412.02148223476
"The calculated specific entropy at the critical point";
constant SI.SpecificEnthalpy HCRIT=2087546.84511715
"The calculated specific enthalpy at the critical point";
constant Real[5] n=array(
0.34805185628969e3,
-0.11671859879975e1,
0.10192970039326e-2,
0.57254459862746e3,
0.13918839778870e2)
"Polynomial coefficients for boundary between regions 2 and 3";
annotation (Documentation(info="<html>
<h4>Record description</h4>
<p>Constants needed in the international steam properties IF97.
SCRIT and HCRIT are calculated from Helmholtz function for region 3.</p>
<h4>Version Info and Revision history</h4>
<ul>
<li>
First implemented: <em>July, 2000</em>
by Hubertus Tummescheit
</li>
</ul>
<address>
Author: Hubertus Tummescheit,<br>
Modelon AB<br>
Ideon Science Park<br>
SE-22370 Lund, Sweden<br>
email: hubertus@modelon.se
</address>
<ul>
<li>Initial version: July 2000</li>
<li>Documentation added: December 2002</li>
</ul>
</html>"));
end data;
function getTstar "Get normalization temperature for region 1, 2 or 5"
extends Modelica.Icons.Function;
input Integer region "IF 97 region";
output SI.Temperature Tstar "Normalization temperature";
algorithm
if region == 1 then
Tstar := data.TSTAR1;
elseif region == 2 then
Tstar := data.TSTAR2;
else
Tstar := data.TSTAR5;
end if;
end getTstar;
function getpstar "Get normalization pressure for region 1, 2 or 5"
extends Modelica.Icons.Function;
input Integer region "IF 97 region";
output SI.Pressure pstar "Normalization pressure";
algorithm
if region == 1 then
pstar := data.PSTAR1;
elseif region == 2 then
pstar := data.PSTAR2;
else
pstar := data.PSTAR5;
end if;
end getpstar;
record critical "Critical point data"
extends Modelica.Icons.Record;
constant SI.Pressure PCRIT=22064000.0 "The critical pressure";
constant SI.Temperature TCRIT=647.096 "The critical temperature";
constant SI.Density DCRIT=322.0 "The critical density";
constant SI.SpecificEnthalpy HCRIT=2087546.84511715
"The calculated specific enthalpy at the critical point";
constant SI.SpecificEntropy SCRIT=4412.02148223476
"The calculated specific entropy at the critical point";
annotation (Documentation(info="<html>
<h4>Record description</h4>
<p>
Critical point data for IF97 steam properties. SCRIT and HCRIT are calculated from Helmholtz function for region 3.
</p>
<h4>Version Info and Revision history</h4>
<ul>
<li>
First implemented: <em>July, 2000</em>
by Hubertus Tummescheit
</li>
</ul>
<address>
Author: Hubertus Tummescheit,<br>
Modelon AB<br>
Ideon Science Park<br>
SE-22370 Lund, Sweden<br>
email: hubertus@modelon.se
</address>
<ul>
<li>Initial version: July 2000</li>
<li>Documentation added: December 2002</li>
</ul>
</html>"));
end critical;
record triple "Triple point data"
extends Modelica.Icons.Record;
constant SI.Temperature Ttriple=273.16 "The triple point temperature";
constant SI.Pressure ptriple=611.657 "The triple point pressure";
constant SI.Density dltriple=999.792520031617642
"The triple point liquid density";
constant SI.Density dvtriple=0.485457572477861372e-2
"The triple point vapour density";
annotation (Documentation(info="<html>
<h4>Record description</h4>
<p>Vapour/liquid/ice triple point data for IF97 steam properties.</p>
<h4>Version Info and Revision history</h4>
<ul>
<li>
First implemented: <em>July, 2000</em>
by Hubertus Tummescheit
</li>
</ul>
<address>
Author: Hubertus Tummescheit,<br>
Modelon AB<br>
Ideon Science Park<br>
SE-22370 Lund, Sweden<br>
email: hubertus@modelon.se
</address>
<ul>
<li>Initial version: July 2000</li>
<li>Documentation added: December 2002</li>
</ul>
</html>"));
end triple;
package Regions
"Functions to find the current region for given pairs of input variables"
extends Modelica.Icons.FunctionsPackage;
//===================================================================
// "Public" functions
//===================================================================
function boundary23ofT
"Boundary function for region boundary between regions 2 and 3 (input temperature)"
extends Modelica.Icons.Function;
input SI.Temperature t "Temperature (K)";
output SI.Pressure p "Pressure";
protected
constant Real[5] n=data.n;
algorithm
p := 1.0e6*(n[1] + t*(n[2] + t*n[3]));
end boundary23ofT;
function boundary23ofp
"Boundary function for region boundary between regions 2 and 3 (input pressure)"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.Temperature t "Temperature (K)";
protected
constant Real[5] n=data.n;
Real pi "Dimensionless pressure";
algorithm
pi := p/1.0e6;
assert(p > triple.ptriple,
"IF97 medium function boundary23ofp called with too low pressure\n"
+ "p = " + String(p) + " Pa <= " + String(triple.ptriple) +
" Pa (triple point pressure)");
t := n[4] + ((pi - n[5])/n[3])^0.5;
end boundary23ofp;
function hlowerofp5
"Explicit lower specific enthalpy limit of region 5 as function of pressure"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEnthalpy h "Specific enthalpy";
protected
Real pi "Dimensionless pressure";
algorithm
pi := p/data.PSTAR5;
assert(p > triple.ptriple,
"IF97 medium function hlowerofp5 called with too low pressure\n" +
"p = " + String(p) + " Pa <= " + String(triple.ptriple) +
" Pa (triple point pressure)");
h := 461526.*(9.01505286876203 + pi*(-0.00979043490246092 + (-0.0000203245575263501
+ 3.36540214679088e-7*pi)*pi));
end hlowerofp5;
function hupperofp5
"Explicit upper specific enthalpy limit of region 5 as function of pressure"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEnthalpy h "Specific enthalpy";
protected
Real pi "Dimensionless pressure";
algorithm
pi := p/data.PSTAR5;
assert(p > triple.ptriple,
"IF97 medium function hupperofp5 called with too low pressure\n" +
"p = " + String(p) + " Pa <= " + String(triple.ptriple) +
" Pa (triple point pressure)");
h := 461526.*(15.9838891400332 + pi*(-0.000489898813722568 + (-5.01510211858761e-8
+ 7.5006972718273e-8*pi)*pi));
end hupperofp5;
function slowerofp5
"Explicit lower specific entropy limit of region 5 as function of pressure"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEntropy s "Specific entropy";
protected
Real pi "Dimensionless pressure";
algorithm
pi := p/data.PSTAR5;
assert(p > triple.ptriple,
"IF97 medium function slowerofp5 called with too low pressure\n" +
"p = " + String(p) + " Pa <= " + String(triple.ptriple) +
" Pa (triple point pressure)");
s := 461.526*(18.4296209980112 + pi*(-0.00730911805860036 + (-0.0000168348072093888
+ 2.09066899426354e-7*pi)*pi) - Modelica.Math.log(pi));
end slowerofp5;
function supperofp5
"Explicit upper specific entropy limit of region 5 as function of pressure"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEntropy s "Specific entropy";
protected
Real pi "Dimensionless pressure";
algorithm
pi := p/data.PSTAR5;
assert(p > triple.ptriple,
"IF97 medium function supperofp5 called with too low pressure\n" +
"p = " + String(p) + " Pa <= " + String(triple.ptriple) +
" Pa (triple point pressure)");
s := 461.526*(22.7281531474243 + pi*(-0.000656650220627603 + (-1.96109739782049e-8
+ 2.19979537113031e-8*pi)*pi) - Modelica.Math.log(pi));
end supperofp5;
function hlowerofp1
"Explicit lower specific enthalpy limit of region 1 as function of pressure"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEnthalpy h "Specific enthalpy";
protected
Real pi1 "Dimensionless pressure";
Real[3] o "Vector of auxiliary variables";
algorithm
pi1 := 7.1 - p/data.PSTAR1;
assert(p > triple.ptriple,
"IF97 medium function hlowerofp1 called with too low pressure\n" +
"p = " + String(p) + " Pa <= " + String(triple.ptriple) +
" Pa (triple point pressure)");
o[1] := pi1*pi1;
o[2] := o[1]*o[1];
o[3] := o[2]*o[2];
h := 639675.036*(0.173379420894777 + pi1*(-0.022914084306349 + pi1*(-0.00017146768241932
+ pi1*(-4.18695814670391e-6 + pi1*(-2.41630417490008e-7 + pi1*(
1.73545618580828e-11 + o[1]*pi1*(8.43755552264362e-14 + o[2]*o[3]*pi1
*(5.35429206228374e-35 + o[1]*(-8.12140581014818e-38 + o[1]*o[2]*(-1.43870236842915e-44
+ pi1*(1.73894459122923e-45 + (-7.06381628462585e-47 +
9.64504638626269e-49*pi1)*pi1)))))))))));
end hlowerofp1;
function hupperofp1
"Explicit upper specific enthalpy limit of region 1 as function of pressure (meets region 4 saturation pressure curve at 623.15 K)"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEnthalpy h "Specific enthalpy";
protected
Real pi1 "Dimensionless pressure";
Real[3] o "Vector of auxiliary variables";
algorithm
pi1 := 7.1 - p/data.PSTAR1;
assert(p > triple.ptriple,
"IF97 medium function hupperofp1 called with too low pressure\n" +
"p = " + String(p) + " Pa <= " + String(triple.ptriple) +
" Pa (triple point pressure)");
o[1] := pi1*pi1;
o[2] := o[1]*o[1];
o[3] := o[2]*o[2];
h := 639675.036*(2.42896927729349 + pi1*(-0.00141131225285294 + pi1*(
0.00143759406818289 + pi1*(0.000125338925082983 + pi1*(
0.0000123617764767172 + pi1*(3.17834967400818e-6 + o[1]*pi1*(
1.46754947271665e-8 + o[2]*o[3]*pi1*(1.86779322717506e-17 + o[1]*(-4.18568363667416e-19
+ o[1]*o[2]*(-9.19148577641497e-22 + pi1*(4.27026404402408e-22 + (-6.66749357417962e-23
+ 3.49930466305574e-24*pi1)*pi1)))))))))));
end hupperofp1;
function slowerofp1
"Explicit lower specific entropy limit of region 1 as function of pressure"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEntropy s "Specific entropy";
protected
Real pi1 "Dimensionless pressure";
Real[3] o "Vector of auxiliary variables";
algorithm
pi1 := 7.1 - p/data.PSTAR1;
assert(p > triple.ptriple,
"IF97 medium function slowerofp1 called with too low pressure\n" +
"p = " + String(p) + " Pa <= " + String(triple.ptriple) +
" Pa (triple point pressure)");
o[1] := pi1*pi1;
o[2] := o[1]*o[1];
o[3] := o[2]*o[2];
s := 461.526*(-0.0268080988194267 + pi1*(0.00834795890110168 + pi1*(-0.000486470924668433
+ pi1*(-0.0000154902045012264 + pi1*(-1.07631751351358e-6 + pi1*(
9.64159058957115e-11 + o[1]*pi1*(4.81921078863103e-13 + o[2]*o[3]*pi1
*(2.7879623870968e-34 + o[1]*(-4.22182957646226e-37 + o[1]*o[2]*(-7.44601427465175e-44
+ pi1*(8.99540001407168e-45 + (-3.65230274480299e-46 +
4.98464639687285e-48*pi1)*pi1)))))))))));
end slowerofp1;
function supperofp1
"Explicit upper specific entropy limit of region 1 as function of pressure (meets region 4 saturation pressure curve at 623.15 K)"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEntropy s "Specific entropy";
protected
Real pi1 "Dimensionless pressure";
Real[3] o "Vector of auxiliary variables";
algorithm
pi1 := 7.1 - p/data.PSTAR1;
assert(p > triple.ptriple,
"IF97 medium function supperofp1 called with too low pressure\n" +
"p = " + String(p) + " Pa <= " + String(triple.ptriple) +
" Pa (triple point pressure)");
o[1] := pi1*pi1;
o[2] := o[1]*o[1];
o[3] := o[2]*o[2];
s := 461.526*(7.28316418503422 + pi1*(0.070602197808399 + pi1*(
0.0039229343647356 + pi1*(0.000313009170788845 + pi1*(
0.0000303619398631619 + pi1*(7.46739440045781e-6 + o[1]*pi1*(
3.40562176858676e-8 + o[2]*o[3]*pi1*(4.21886233340801e-17 + o[1]*(-9.44504571473549e-19
+ o[1]*o[2]*(-2.06859611434475e-21 + pi1*(9.60758422254987e-22 + (-1.49967810652241e-22
+ 7.86863124555783e-24*pi1)*pi1)))))))))));
end supperofp1;
function hlowerofp2
"Explicit lower specific enthalpy limit of region 2 as function of pressure (meets region 4 saturation pressure curve at 623.15 K)"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEnthalpy h "Specific enthalpy";
protected
Real pi "Dimensionless pressure";
Real q1 "Auxiliary variable";
Real q2 "Auxiliary variable";
Real[18] o "Vector of auxiliary variables";
algorithm
pi := p/data.PSTAR2;
assert(p > triple.ptriple,
"IF97 medium function hlowerofp2 called with too low pressure\n" +
"p = " + String(p) + " Pa <= " + String(triple.ptriple) +
" Pa (triple point pressure)");
q1 := 572.54459862746 + 31.3220101646784*(-13.91883977887 + pi)^0.5;
q2 := -0.5 + 540./q1;
o[1] := q1*q1;
o[2] := o[1]*o[1];
o[3] := o[2]*o[2];
o[4] := pi*pi;
o[5] := o[4]*o[4];
o[6] := q2*q2;
o[7] := o[6]*o[6];
o[8] := o[6]*o[7];
o[9] := o[5]*o[5];
o[10] := o[7]*o[7];
o[11] := o[9]*o[9];
o[12] := o[10]*o[10];
o[13] := o[12]*o[12];
o[14] := o[7]*q2;
o[15] := o[6]*q2;
o[16] := o[10]*o[6];
o[17] := o[13]*o[6];
o[18] := o[13]*o[6]*q2;
h := (4.63697573303507e9 + 3.74686560065793*o[2] + 3.57966647812489e-6*
o[1]*o[2] + 2.81881548488163e-13*o[3] - 7.64652332452145e7*q1 -
0.00450789338787835*o[2]*q1 - 1.55131504410292e-9*o[1]*o[2]*q1 + o[1]
*(2.51383707870341e6 - 4.78198198764471e6*o[10]*o[11]*o[12]*o[13]*o[4]
+ 49.9651389369988*o[11]*o[12]*o[13]*o[4]*o[5]*o[7] + o[15]*o[4]*(
1.03746636552761e-13 - 0.00349547959376899*o[16] -
2.55074501962569e-7*o[8])*o[9] + (-242662.235426958*o[10]*o[12] -
3.46022402653609*o[16])*o[4]*o[5]*pi + o[4]*(0.109336249381227 -
2248.08924686956*o[14] - 354742.725841972*o[17] - 24.1331193696374*o[
6])*pi - 3.09081828396912e-19*o[11]*o[12]*o[5]*o[7]*pi -
1.24107527851371e-8*o[11]*o[13]*o[4]*o[5]*o[6]*o[7]*pi +
3.99891272904219*o[5]*o[8]*pi + 0.0641817365250892*o[10]*o[7]*o[9]*pi
+ pi*(-4444.87643334512 - 75253.6156722047*o[14] - 43051.9020511789*
o[6] - 22926.6247146068*q2) + o[4]*(-8.23252840892034 -
3927.0508365636*o[15] - 239.325789467604*o[18] - 76407.3727417716*o[8]
- 94.4508644545118*q2) + 0.360567666582363*o[5]*(-0.0161221195808321
+ q2)*(0.0338039844460968 + q2) + o[11]*(-0.000584580992538624*o[10]
*o[12]*o[7] + 1.33248030241755e6*o[12]*o[13]*q2) + o[9]*(-7.38502736990986e7
*o[18] + 0.0000224425477627799*o[6]*o[7]*q2) + o[4]*o[5]*(-2.08438767026518e8
*o[17] - 0.0000124971648677697*o[6] - 8442.30378348203*o[10]*o[6]*o[7]
*q2) + o[11]*o[9]*(4.73594929247646e-22*o[10]*o[12]*q2 -
13.6411358215175*o[10]*o[12]*o[13]*q2 + 5.52427169406836e-10*o[13]*o[
6]*o[7]*q2) + o[11]*o[5]*(2.67174673301715e-6*o[17] +
4.44545133805865e-18*o[12]*o[6]*q2 - 50.2465185106411*o[10]*o[13]*o[6]
*o[7]*q2)))/o[1];
end hlowerofp2;
function hupperofp2
"Explicit upper specific enthalpy limit of region 2 as function of pressure"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEnthalpy h "Specific enthalpy";
protected
Real pi "Dimensionless pressure";
Real[2] o "Vector of auxiliary variables";
algorithm
pi := p/data.PSTAR2;
assert(p > triple.ptriple,
"IF97 medium function hupperofp2 called with too low pressure\n" +
"p = " + String(p) + " Pa <= " + String(triple.ptriple) +
" Pa (triple point pressure)");
o[1] := pi*pi;
o[2] := o[1]*o[1]*o[1];
h := 4.16066337647071e6 + pi*(-4518.48617188327 + pi*(-8.53409968320258
+ pi*(0.109090430596056 + pi*(-0.000172486052272327 + pi*(
4.2261295097284e-15 + pi*(-1.27295130636232e-10 + pi*(-3.79407294691742e-25
+ pi*(7.56960433802525e-23 + pi*(7.16825117265975e-32 + pi*(
3.37267475986401e-21 + (-7.5656940729795e-74 + o[1]*(-8.00969737237617e-134
+ (1.6746290980312e-65 + pi*(-3.71600586812966e-69 + pi*(
8.06630589170884e-129 + (-1.76117969553159e-103 +
1.88543121025106e-84*pi)*pi)))*o[1]))*o[2]))))))))));
end hupperofp2;
function slowerofp2
"Explicit lower specific entropy limit of region 2 as function of pressure (meets region 4 saturation pressure curve at 623.15 K)"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEntropy s "Specific entropy";
protected
Real pi "Dimensionless pressure";
Real q1 "Auxiliary variable";
Real q2 "Auxiliary variable";
Real[40] o "Vector of auxiliary variables";
algorithm
pi := p/data.PSTAR2;
assert(p > triple.ptriple,
"IF97 medium function slowerofp2 called with too low pressure\n" +
"p = " + String(p) + " Pa <= " + String(triple.ptriple) +
" Pa (triple point pressure)");
q1 := 572.54459862746 + 31.3220101646784*(-13.91883977887 + pi)^0.5;
q2 := -0.5 + 540.0/q1;
o[1] := pi*pi;
o[2] := o[1]*pi;
o[3] := o[1]*o[1];
o[4] := o[1]*o[3]*pi;
o[5] := q1*q1;
o[6] := o[5]*q1;
o[7] := 1/o[5];
o[8] := 1/q1;
o[9] := o[5]*o[5];
o[10] := o[9]*q1;
o[11] := q2*q2;
o[12] := o[11]*q2;
o[13] := o[1]*o[3];
o[14] := o[11]*o[11];
o[15] := o[3]*o[3];
o[16] := o[1]*o[15];
o[17] := o[11]*o[14];
o[18] := o[11]*o[14]*q2;
o[19] := o[3]*pi;
o[20] := o[14]*o[14];
o[21] := o[11]*o[20];
o[22] := o[15]*pi;
o[23] := o[14]*o[20]*q2;
o[24] := o[20]*o[20];
o[25] := o[15]*o[15];
o[26] := o[25]*o[3];
o[27] := o[14]*o[24];
o[28] := o[25]*o[3]*pi;
o[29] := o[20]*o[24]*q2;
o[30] := o[15]*o[25];
o[31] := o[24]*o[24];
o[32] := o[11]*o[31]*q2;
o[33] := o[14]*o[31];
o[34] := o[1]*o[25]*o[3]*pi;
o[35] := o[11]*o[14]*o[31]*q2;
o[36] := o[1]*o[25]*o[3];
o[37] := o[1]*o[25];
o[38] := o[20]*o[24]*o[31]*q2;
o[39] := o[14]*q2;
o[40] := o[11]*o[31];
s := 461.526*(9.692768600217 + 1.22151969114703e-16*o[10] +
0.00018948987516315*o[1]*o[11] + 1.6714766451061e-11*o[12]*o[13] +
0.0039392777243355*o[1]*o[14] - 1.0406965210174e-19*o[14]*o[16] +
0.043797295650573*o[1]*o[18] - 2.2922076337661e-6*o[18]*o[19] -
2.0481737692309e-8*o[2] + 0.00003227767723857*o[12]*o[2] +
0.0015033924542148*o[17]*o[2] - 1.1256211360459e-11*o[15]*o[20] +
1.0018179379511e-9*o[11]*o[14]*o[16]*o[20] + 1.0234747095929e-13*o[16]
*o[21] - 1.9809712802088e-8*o[22]*o[23] + 0.0021171472321355*o[13]*o[
24] - 8.9185845355421e-25*o[26]*o[27] - 1.2790717852285e-8*o[11]*o[3]
- 4.8225372718507e-7*o[12]*o[3] - 7.3087610595061e-29*o[11]*o[20]*o[
24]*o[30] - 0.10693031879409*o[11]*o[24]*o[25]*o[31] +
4.2002467698208e-6*o[24]*o[26]*o[31] - 5.5414715350778e-17*o[20]*o[30]
*o[31] + 9.436970724121e-7*o[11]*o[20]*o[24]*o[30]*o[31] +
23.895741934104*o[13]*o[32] + 0.040668253562649*o[2]*o[32] -
3.0629316876232e-13*o[26]*o[32] + 0.000026674547914087*o[1]*o[33] +
8.2311340897998*o[15]*o[33] + 1.2768608934681e-15*o[34]*o[35] +
0.33662250574171*o[37]*o[38] + 5.905956432427e-18*o[4] +
0.038946842435739*o[29]*o[4] - 4.88368302964335e-6*o[5] -
3.34901734177133e6/o[6] + 2.58538448402683e-9*o[6] + 82839.5726841115
*o[7] - 5446.7940672972*o[8] - 8.40318337484194e-13*o[9] +
0.0017731742473213*pi + 0.045996013696365*o[11]*pi +
0.057581259083432*o[12]*pi + 0.05032527872793*o[17]*pi + o[8]*pi*(
9.63082563787332 - 0.008917431146179*q1) + 0.00811842799898148*q1 +
0.000033032641670203*o[1]*q2 - 4.3870667284435e-7*o[2]*q2 +
8.0882908646985e-11*o[14]*o[20]*o[24]*o[25]*q2 + 5.9056029685639e-26*
o[14]*o[24]*o[28]*q2 + 7.8847309559367e-10*o[3]*q2 -
3.7826947613457e-6*o[14]*o[24]*o[31]*o[36]*q2 + 1.2621808899101e-6*o[
11]*o[20]*o[4]*q2 + 540.*o[8]*(10.08665568018 - 0.000033032641670203*
o[1] - 6.2245802776607e-15*o[10] - 0.015757110897342*o[1]*o[12] -
5.0144299353183e-11*o[11]*o[13] + 4.1627860840696e-19*o[12]*o[16] -
0.306581069554011*o[1]*o[17] + 9.0049690883672e-11*o[15]*o[18] +
0.0000160454534363627*o[17]*o[19] + 4.3870667284435e-7*o[2] -
0.00009683303171571*o[11]*o[2] + 2.57526266427144e-7*o[14]*o[20]*o[22]
- 1.40254511313154e-8*o[16]*o[23] - 2.34560435076256e-9*o[14]*o[20]*
o[24]*o[25] - 1.24017662339842e-24*o[27]*o[28] - 7.8847309559367e-10*
o[3] + 1.44676118155521e-6*o[11]*o[3] + 1.90027787547159e-27*o[29]*o[
30] - 0.000960283724907132*o[1]*o[32] - 296.320827232793*o[15]*o[32]
- 4.97975748452559e-14*o[11]*o[14]*o[31]*o[34] +
2.21658861403112e-15*o[30]*o[35] + 0.000200482822351322*o[14]*o[24]*o[
31]*o[36] - 19.1874828272775*o[20]*o[24]*o[31]*o[37] -
0.0000547344301999018*o[30]*o[38] - 0.0090203547252888*o[2]*o[39] -
0.0000138839897890111*o[21]*o[4] - 0.973671060893475*o[20]*o[24]*o[4]
- 836.35096769364*o[13]*o[40] - 1.42338887469272*o[2]*o[40] +
1.07202609066812e-11*o[26]*o[40] + 0.0000150341259240398*o[5] -
1.8087714924605e-8*o[6] + 18605.6518987296*o[7] - 306.813232163376*o[
8] + 1.43632471334824e-11*o[9] + 1.13103675106207e-18*o[5]*o[9] -
0.017834862292358*pi - 0.172743777250296*o[11]*pi - 0.30195167236758*
o[39]*pi + o[8]*pi*(-49.6756947920742 + 0.045996013696365*q1) -
0.0003789797503263*o[1]*q2 - 0.033874355714168*o[11]*o[13]*o[14]*o[20]
*q2 - 1.0234747095929e-12*o[16]*o[20]*q2 + 1.78371690710842e-23*o[11]
*o[24]*o[26]*q2 + 2.558143570457e-8*o[3]*q2 + 5.3465159397045*o[24]*o[
25]*o[31]*q2 - 0.000201611844951398*o[11]*o[14]*o[20]*o[26]*o[31]*q2)
- Modelica.Math.log(pi));
end slowerofp2;
function supperofp2
"Explicit upper specific entropy limit of region 2 as function of pressure"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEntropy s "Specific entropy";
protected
Real pi "Dimensionless pressure";
Real[2] o "Vector of auxiliary variables";
algorithm
pi := p/data.PSTAR2;
assert(p > triple.ptriple,
"IF97 medium function supperofp2 called with too low pressure\n" +
"p = " + String(p) + " Pa <= " + String(triple.ptriple) +
" Pa (triple point pressure)");
o[1] := pi*pi;
o[2] := o[1]*o[1]*o[1];
s := 8505.73409708683 - 461.526*Modelica.Math.log(pi) + pi*(-3.36563543302584
+ pi*(-0.00790283552165338 + pi*(0.0000915558349202221 + pi*(-1.59634706513e-7
+ pi*(3.93449217595397e-18 + pi*(-1.18367426347994e-13 + pi*(
2.72575244843195e-15 + pi*(7.04803892603536e-26 + pi*(
6.67637687381772e-35 + pi*(3.1377970315132e-24 + (-7.04844558482265e-77
+ o[1]*(-7.46289531275314e-137 + (1.55998511254305e-68 + pi*(-3.46166288915497e-72
+ pi*(7.51557618628583e-132 + (-1.64086406733212e-106 +
1.75648443097063e-87*pi)*pi)))*o[1]))*o[2]*o[2]))))))))));
end supperofp2;
function d1n "Density in region 1 as function of p and T"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
input SI.Temperature T "Temperature (K)";
output SI.Density d "Density";
protected
Real pi "Dimensionless pressure";
Real pi1 "Dimensionless pressure";
Real tau "Dimensionless temperature";
Real tau1 "Dimensionless temperature";
Real gpi "Dimensionless Gibbs-derivative w.r.t. pi";
Real[11] o "Auxiliary variables";
algorithm
pi := p/data.PSTAR1;
tau := data.TSTAR1/T;
pi1 := 7.1 - pi;
tau1 := tau - 1.222;
o[1] := tau1*tau1;
o[2] := o[1]*o[1];
o[3] := o[2]*o[2];
o[4] := o[1]*o[2];
o[5] := o[1]*tau1;
o[6] := o[2]*tau1;
o[7] := pi1*pi1;
o[8] := o[7]*o[7];
o[9] := o[8]*o[8];
o[10] := o[3]*o[3];
o[11] := o[10]*o[10];
gpi := pi1*(pi1*((0.000095038934535162 + o[2]*(8.4812393955936e-6 +
2.55615384360309e-9*o[4]))/o[2] + pi1*((8.9701127632e-6 + (
2.60684891582404e-6 + 5.7366919751696e-13*o[2]*o[3])*o[5])/o[6] + pi1
*(2.02584984300585e-6/o[3] + o[7]*pi1*(o[8]*o[9]*pi1*(o[7]*(o[7]*o[8]
*(-7.63737668221055e-22/(o[1]*o[11]*o[2]) + pi1*(pi1*(-5.65070932023524e-23
/(o[11]*o[3]) + (2.99318679335866e-24*pi1)/(o[11]*o[3]*tau1)) +
3.5842867920213e-22/(o[1]*o[11]*o[2]*tau1))) - 3.33001080055983e-19/(
o[1]*o[10]*o[2]*o[3]*tau1)) + 1.44400475720615e-17/(o[10]*o[2]*o[3]*
tau1)) + (1.01874413933128e-8 + 1.39398969845072e-9*o[6])/(o[1]*o[3]*
tau1))))) + (0.00094368642146534 + o[5]*(0.00060003561586052 + (-0.000095322787813974
+ o[1]*(8.8283690661692e-6 + 1.45389992595188e-15*o[1]*o[2]*o[3]))*
tau1))/o[5]) + (-0.00028319080123804 + o[1]*(0.00060706301565874 + o[
4]*(0.018990068218419 + tau1*(0.032529748770505 + (0.021841717175414
+ 0.00005283835796993*o[1])*tau1))))/(o[3]*tau1);
d := p/(data.RH2O*T*pi*gpi);
end d1n;
function d2n "Density in region 2 as function of p and T"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
input SI.Temperature T "Temperature (K)";
output SI.Density d "Density";
protected
Real pi "Dimensionless pressure";
Real tau "Dimensionless temperature";
Real tau2 "Dimensionless temperature";
Real gpi "Dimensionless Gibbs-derivative w.r.t. pi";
Real[12] o "Auxiliary variables";
algorithm
pi := p/data.PSTAR2;
tau := data.TSTAR2/T;
tau2 := tau - 0.5;
o[1] := tau2*tau2;
o[2] := o[1]*tau2;
o[3] := o[1]*o[1];
o[4] := o[3]*o[3];
o[5] := o[4]*o[4];
o[6] := o[3]*o[4]*o[5]*tau2;
o[7] := o[3]*o[4]*tau2;
o[8] := o[1]*o[3]*o[4];
o[9] := pi*pi;
o[10] := o[9]*o[9];
o[11] := o[3]*o[5]*tau2;
o[12] := o[5]*o[5];
gpi := (1. + pi*(-0.0017731742473213 + tau2*(-0.017834862292358 + tau2*
(-0.045996013696365 + (-0.057581259083432 - 0.05032527872793*o[2])*
tau2)) + pi*(tau2*(-0.000066065283340406 + (-0.0003789797503263 + o[1]
*(-0.007878555448671 + o[2]*(-0.087594591301146 -
0.000053349095828174*o[6])))*tau2) + pi*(6.1445213076927e-8 + (
1.31612001853305e-6 + o[1]*(-0.00009683303171571 + o[2]*(-0.0045101773626444
- 0.122004760687947*o[6])))*tau2 + pi*(tau2*(-3.15389238237468e-9 +
(5.116287140914e-8 + 1.92901490874028e-6*tau2)*tau2) + pi*(
0.0000114610381688305*o[1]*o[3]*tau2 + pi*(o[2]*(-1.00288598706366e-10
+ o[7]*(-0.012702883392813 - 143.374451604624*o[1]*o[5]*tau2)) + pi*
(-4.1341695026989e-17 + o[1]*o[4]*(-8.8352662293707e-6 -
0.272627897050173*o[8])*tau2 + pi*(o[4]*(9.0049690883672e-11 -
65.8490727183984*o[3]*o[4]*o[5]) + pi*(1.78287415218792e-7*o[7] + pi*
(o[3]*(1.0406965210174e-18 + o[1]*(-1.0234747095929e-12 -
1.0018179379511e-8*o[3])*o[3]) + o[10]*o[9]*((-1.29412653835176e-9 +
1.71088510070544*o[11])*o[6] + o[9]*(-6.05920510335078*o[12]*o[4]*o[5]
*tau2 + o[9]*(o[3]*o[5]*(1.78371690710842e-23 + o[1]*o[3]*o[4]*(
6.1258633752464e-12 - 0.000084004935396416*o[7])*tau2) + pi*(-1.24017662339842e-24
*o[11] + pi*(0.0000832192847496054*o[12]*o[3]*o[5]*tau2 + pi*(o[1]*o[
4]*o[5]*(1.75410265428146e-27 + (1.32995316841867e-15 -
0.0000226487297378904*o[1]*o[5])*o[8])*pi - 2.93678005497663e-14*o[1]
*o[12]*o[3]*tau2)))))))))))))))))/pi;
d := p/(data.RH2O*T*pi*gpi);
end d2n;
function dhot1ofp "Density at upper temperature limit of region 1"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.Density d "Density";
protected
Real pi "Dimensionless pressure";
Real pi1 "Dimensionless pressure";
Real[4] o "Auxiliary variables";
algorithm
pi := p/data.PSTAR1;
pi1 := 7.1 - pi;
o[1] := pi1*pi1;
o[2] := o[1]*o[1];
o[3] := o[2]*o[2];
o[4] := o[3]*o[3];
d := 57.4756752485113/(0.0737412153522555 + 0.000102697173772229*o[1]
+ 1.99080616601101e-6*o[2] + 1.35549330686006e-17*o[2]*o[4] -
3.11228834832975e-19*o[1]*o[2]*o[4] - 7.02987180039442e-22*o[2]*o[3]*
o[4] - 5.17859076694812e-23*o[1]*o[2]*o[3]*o[4] + 0.00145092247736023
*pi1 + 0.0000114683182476084*o[1]*pi1 + 1.13217858826367e-8*o[1]*o[2]
*pi1 + 3.29199117056433e-22*o[2]*o[3]*o[4]*pi1 + 2.73712834080283e-24
*o[1]*o[2]*o[3]*o[4]*pi1);
end dhot1ofp;
function dupper1ofT "Density at upper pressure limit of region 1"
extends Modelica.Icons.Function;
input SI.Temperature T "Temperature (K)";
output SI.Density d "Density";
protected
Real tau "Dimensionless temperature";
Real[4] o "Auxiliary variables";
algorithm
tau := 1386.0/T;
o[1] := tau*tau;
o[2] := o[1]*o[1];
o[3] := o[2]*o[2];
o[4] := o[3]*o[3];
d := 57.4756752485113/(2.24144616859917 + 40.9288231166229*o[1] +
106.47246463213*o[2] + 88.4481480270751*o[1]*o[2] + 31.3207272417546*
o[3] + 5.47811738891798*o[1]*o[3] + 0.515626225030717*o[2]*o[3] +
0.0274905057899089*o[1]*o[2]*o[3] + 0.000853742979250503*o[4] +
0.0000155932210492199*o[1]*o[4] + 1.6621051480279e-7*o[2]*o[4] +
1.00606771839976e-9*o[1]*o[2]*o[4] + 3.27598951831994e-12*o[3]*o[4]
+ 5.20162317530099e-15*o[1]*o[3]*o[4] + 3.33501889800275e-18*o[2]*o[
3]*o[4] + 5.50656040141221e-22*o[1]*o[2]*o[3]*o[4] - 13.5354267762204
*tau - 78.3629702507642*o[1]*tau - 109.374479648652*o[2]*tau -
57.9035658513312*o[1]*o[2]*tau - 14.215347150565*o[3]*tau -
1.80906759985501*o[1]*o[3]*tau - 0.127542214693871*o[2]*o[3]*tau -
0.0051779458313163*o[1]*o[2]*o[3]*tau - 0.000123304142684848*o[4]*tau
- 1.72405791469972e-6*o[1]*o[4]*tau - 1.39155695911655e-8*o[2]*o[4]*
tau - 6.23333356847138e-11*o[1]*o[2]*o[4]*tau - 1.44056015732082e-13*
o[3]*o[4]*tau - 1.50201626932938e-16*o[1]*o[3]*o[4]*tau -
5.34588682252967e-20*o[2]*o[3]*o[4]*tau - 2.73712834080283e-24*o[1]*o[
2]*o[3]*o[4]*tau);
end dupper1ofT;
function hl_p_R4b
"Explicit approximation of liquid specific enthalpy on the boundary between regions 4 and 3"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEnthalpy h "Specific enthalpy";
protected
Real x "Auxiliary variable";
algorithm
// documentation of accuracy in notebook ~hubertus/props/IAPWS/R3Approx.nb
// boundary between region IVa and III
x := Modelica.Math.acos(p/data.PCRIT);
h := (1 + x*(-0.4945586958175176 + x*(1.346800016564904 + x*(-3.889388153209752
+ x*(6.679385472887931 + x*(-6.75820241066552 + x*(3.558919744656498
+ (-0.7179818554978939 - 0.0001152032945617821*x)*x)))))))*data.HCRIT;
end hl_p_R4b;
function hv_p_R4b
"Explicit approximation of vapour specific enthalpy on the boundary between regions 4 and 3"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEnthalpy h "Specific enthalpy";
protected
Real x "Auxiliary variable";
algorithm
// boundary between region IVa and III
x := Modelica.Math.acos(p/data.PCRIT);
h := (1 + x*(0.4880153718655694 + x*(0.2079670746250689 + x*(-6.084122698421623
+ x*(25.08887602293532 + x*(-48.38215180269516 + x*(
45.66489164833212 + (-16.98555442961553 + 0.0006616936460057691*x)*x)))))))
*data.HCRIT;
end hv_p_R4b;
function sl_p_R4b
"Explicit approximation of liquid specific entropy on the boundary between regions 4 and 3"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEntropy s "Specific entropy";
protected
Real x "Auxiliary variable";
algorithm
// boundary between region IVa and III
x := Modelica.Math.acos(p/data.PCRIT);
s := (1 + x*(-0.36160692245648063 + x*(0.9962778630486647 + x*(-2.8595548144171103
+ x*(4.906301159555333 + x*(-4.974092309614206 + x*(
2.6249651699204457 + (-0.5319954375299023 - 0.00008064497431880644*x)
*x)))))))*data.SCRIT;
end sl_p_R4b;
function sv_p_R4b
"Explicit approximation of vapour specific entropy on the boundary between regions 4 and 3"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEntropy s "Specific entropy";
protected
Real x "Auxiliary variable";
algorithm
// documentation of accuracy in notebook ~hubertus/props/IAPWS/R3Approx.nb
// boundary between region IVa and III
x := Modelica.Math.acos(p/data.PCRIT);
s := (1 + x*(0.35682641826674344 + x*(0.1642457027815487 + x*(-4.425350377422446
+ x*(18.324477859983133 + x*(-35.338631625948665 + x*(
33.36181025816282 + (-12.408711490585757 + 0.0004810049834109226*x)*x)))))))
*data.SCRIT;
end sv_p_R4b;
function rhol_p_R4b
"Explicit approximation of liquid density on the boundary between regions 4 and 3"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.Density dl "Liquid density";
protected
Real x "Auxiliary variable";
algorithm
if (p < data.PCRIT) then
x := Modelica.Math.acos(p/data.PCRIT);
dl := (1 + x*(1.903224079094824 + x*(-2.5314861802401123 + x*(-8.191449323843552
+ x*(94.34196116778385 + x*(-369.3676833623383 + x*(
796.6627910598293 + x*(-994.5385383600702 + x*(673.2581177021598 +
(-191.43077336405156 + 0.00052536560808895*x)*x)))))))))*data.DCRIT;
else
dl := data.DCRIT;
end if;
end rhol_p_R4b;
function rhov_p_R4b
"Explicit approximation of vapour density on the boundary between regions 4 and 2"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.Density dv "Vapour density";
protected
Real x "Auxiliary variable";
algorithm
if (p < data.PCRIT) then
x := Modelica.Math.acos(p/data.PCRIT);
dv := (1 + x*(-1.8463850803362596 + x*(-1.1447872718878493 + x*(
59.18702203076563 + x*(-403.5391431811611 + x*(1437.2007245332388
+ x*(-3015.853540307519 + x*(3740.5790348670057 + x*(-2537.375817253895
+ (725.8761975803782 - 0.0011151111658332337*x)*x)))))))))*data.DCRIT;
else
dv := data.DCRIT;
end if;
end rhov_p_R4b;
function boilingcurve_p "Properties on the boiling curve"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output Common.IF97PhaseBoundaryProperties bpro "Property record";
protected
Common.GibbsDerivs g "Dimensionless Gibbs function and derivatives";
Common.HelmholtzDerivs f
"Dimensionless Helmholtz function and derivatives";
SI.Pressure plim=min(p, data.PCRIT - 1e-7)
"Pressure limited to critical pressure - epsilon";
algorithm
bpro.R_s := data.RH2O;
bpro.T := Basic.tsat(plim);
bpro.dpT := Basic.dptofT(bpro.T);
bpro.region3boundary := bpro.T > data.TLIMIT1;
if not bpro.region3boundary then
g := Basic.g1(p, bpro.T);
bpro.d := p/(bpro.R_s*bpro.T*g.pi*g.gpi);
bpro.h := if p > plim then data.HCRIT else bpro.R_s*bpro.T*g.tau*g.gtau;
bpro.s := g.R_s*(g.tau*g.gtau - g.g);
bpro.cp := -bpro.R_s*g.tau*g.tau*g.gtautau;
bpro.vt := bpro.R_s/p*(g.pi*g.gpi - g.tau*g.pi*g.gtaupi);
bpro.vp := bpro.R_s*bpro.T/(p*p)*g.pi*g.pi*g.gpipi;
bpro.pt := -p/bpro.T*(g.gpi - g.tau*g.gtaupi)/(g.gpipi*g.pi);
bpro.pd := -bpro.R_s*bpro.T*g.gpi*g.gpi/(g.gpipi);
else
bpro.d := rhol_p_R4b(plim);
f := Basic.f3(bpro.d, bpro.T);
bpro.h := hl_p_R4b(plim);
// bpro.R_s*bpro.T*(f.tau*f.ftau + f.delta*f.fdelta);
bpro.s := f.R_s*(f.tau*f.ftau - f.f);
bpro.cv := bpro.R_s*(-f.tau*f.tau*f.ftautau);
bpro.pt := bpro.R_s*bpro.d*f.delta*(f.fdelta - f.tau*f.fdeltatau);
bpro.pd := bpro.R_s*bpro.T*f.delta*(2.0*f.fdelta + f.delta*f.fdeltadelta);
end if;
end boilingcurve_p;
function dewcurve_p "Properties on the dew curve"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output Common.IF97PhaseBoundaryProperties bpro "Property record";
protected
Common.GibbsDerivs g "Dimensionless Gibbs function and derivatives";
Common.HelmholtzDerivs f
"Dimensionless Helmholtz function and derivatives";
SI.Pressure plim=min(p, data.PCRIT - 1e-7)
"Pressure limited to critical pressure - epsilon";
algorithm
bpro.R_s := data.RH2O;
bpro.T := Basic.tsat(plim);
bpro.dpT := Basic.dptofT(bpro.T);
bpro.region3boundary := bpro.T > data.TLIMIT1;
if not bpro.region3boundary then
g := Basic.g2(p, bpro.T);
bpro.d := p/(bpro.R_s*bpro.T*g.pi*g.gpi);
bpro.h := if p > plim then data.HCRIT else bpro.R_s*bpro.T*g.tau*g.gtau;
bpro.s := g.R_s*(g.tau*g.gtau - g.g);
bpro.cp := -bpro.R_s*g.tau*g.tau*g.gtautau;
bpro.vt := bpro.R_s/p*(g.pi*g.gpi - g.tau*g.pi*g.gtaupi);
bpro.vp := bpro.R_s*bpro.T/(p*p)*g.pi*g.pi*g.gpipi;
bpro.pt := -p/bpro.T*(g.gpi - g.tau*g.gtaupi)/(g.gpipi*g.pi);
bpro.pd := -bpro.R_s*bpro.T*g.gpi*g.gpi/(g.gpipi);
else
bpro.d := rhov_p_R4b(plim);
f := Basic.f3(bpro.d, bpro.T);
bpro.h := hv_p_R4b(plim);
// bpro.R_s*bpro.T*(f.tau*f.ftau + f.delta*f.fdelta);
bpro.s := f.R_s*(f.tau*f.ftau - f.f);
bpro.cv := bpro.R_s*(-f.tau*f.tau*f.ftautau);
bpro.pt := bpro.R_s*bpro.d*f.delta*(f.fdelta - f.tau*f.fdeltatau);
bpro.pd := bpro.R_s*bpro.T*f.delta*(2.0*f.fdelta + f.delta*f.fdeltadelta);
end if;
end dewcurve_p;
function hvl_p
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
input Common.IF97PhaseBoundaryProperties bpro "Property record";
output SI.SpecificEnthalpy h "Specific enthalpy";
algorithm
h := bpro.h;
annotation (
derivative(noDerivative=bpro) = hvl_p_der,
Inline=false,
LateInline=true);
end hvl_p;
function hl_p
"Liquid specific enthalpy on the boundary between regions 4 and 3 or 1"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
output SI.SpecificEnthalpy h "Specific enthalpy";
algorithm
h := hvl_p(p, boilingcurve_p(p));
annotation (Inline=true);
end hl_p;
function hv_p
"Vapour specific enthalpy on the boundary between regions 4 and 3 or 2"