forked from modelica/ModelicaStandardLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReferenceAir.mo
2152 lines (1973 loc) · 81.9 KB
/
ReferenceAir.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.Air;
package ReferenceAir
"ReferenceAir: Detailed dry air model with a large operating range (130 ... 2000 K, 0 ... 2000 MPa) based on Helmholtz equations of state"
extends Modelica.Icons.VariantsPackage;
constant Modelica.Media.Interfaces.Types.TwoPhase.FluidConstants
airConstants(
chemicalFormula="N2+O2+Ar",
structureFormula="N2+O2+Ar",
casRegistryNumber="1",
iupacName="air",
molarMass=0.02896546,
criticalTemperature=132.5306,
criticalPressure=3.786e6,
criticalMolarVolume=0.02896546/342.68,
triplePointTemperature=63.05 "From N2",
triplePointPressure=0.1253e5 "From N2",
normalBoilingPoint=78.903,
meltingPoint=0,
acentricFactor=0.0335,
dipoleMoment=0.0,
hasCriticalData=true,
hasFundamentalEquation=true,
hasAccurateViscosityData=true,
hasAcentricFactor=true);
protected
type MolarHeatCapacity = SI.MolarHeatCapacity (
min=0,
max=3.e5,
nominal=3.e1,
start=3.e1)
"Type for molar heat capacity with medium specific attributes";
type MolarDensity = Real (
final quantity="MolarDensity",
final unit="mol/m3",
min=0);
type IsothermalExpansionCoefficient = Real (
min=0,
max=1e8,
unit="1");
public
package Air_ph
"ReferenceAir.Air_ph: Detailed dry air model (130 ... 2000 K) explicit in p and h"
extends Modelica.Icons.MaterialProperty;
extends Modelica.Media.Air.ReferenceAir.Air_Base(
ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.ph,
final ph_explicit=true,
final dT_explicit=false,
final pT_explicit=false);
annotation (Documentation(info="<html>
<h4>Usage</h4>
<p>
The package Air_ph can be used as any other medium model (see <a href=\"modelica://Modelica.Media.UsersGuide\">User's Guide of Media Library</a> for further information).
</p>
</html>"));
end Air_ph;
package Air_pT
"ReferenceAir.Air_pT: Detailed dry air model (130 ... 2000 K) explicit in p and T"
extends Modelica.Icons.MaterialProperty;
extends Modelica.Media.Air.ReferenceAir.Air_Base(
ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.pT,
final ph_explicit=false,
final dT_explicit=false,
final pT_explicit=true);
annotation (Documentation(info="<html>
<h4>Usage</h4>
<p>
The package Air_pT can be used as any other medium model (see <a href=\"modelica://Modelica.Media.UsersGuide\">User's Guide of Media Library</a> for further information).
</p>
</html>"));
end Air_pT;
public
package Air_dT
"ReferenceAir.Air_dT: Detailed dry air model (130 ... 2000 K) explicit in d and T"
extends Modelica.Icons.MaterialProperty;
extends Modelica.Media.Air.ReferenceAir.Air_Base(
ThermoStates=Modelica.Media.Interfaces.Choices.IndependentVariables.dTX,
final ph_explicit=false,
final dT_explicit=true,
final pT_explicit=false);
annotation (Documentation(info="<html>
<h4>Usage</h4>
<p>
The package Air_dT can be used as any other medium model (see <a href=\"modelica://Modelica.Media.UsersGuide\">User's Guide of Media Library</a> for further information).
</p>
</html>"));
end Air_dT;
public
partial package Air_Base
"Properties of dry air calculated using the equation of state by Lemmon et. al."
extends Modelica.Media.Interfaces.PartialPureSubstance(
mediumName="Air",
substanceNames={"air"},
singleState=false,
SpecificEnthalpy(start=1.0e5, nominal=5.0e5),
Density(start=1.0, nominal=1.2),
AbsolutePressure(
start=1e5,
nominal=1e5,
min=1.0,
max=2000e6),
Temperature(
start=273.15,
nominal=293.15,
min=130,
max=2000));
constant Boolean ph_explicit
"True if explicit in pressure and specific enthalpy";
constant Boolean dT_explicit
"True if explicit in density and temperature";
constant Boolean pT_explicit
"True if explicit in pressure and temperature";
redeclare record extends ThermodynamicState "Thermodynamic state"
SpecificEnthalpy h "Specific enthalpy";
Density d "Density";
Temperature T "Temperature";
AbsolutePressure p "Pressure";
end ThermodynamicState;
redeclare model extends BaseProperties(
h(stateSelect=if ph_explicit and preferredMediumStates then StateSelect.prefer
else StateSelect.default),
d(stateSelect=if dT_explicit and preferredMediumStates then StateSelect.prefer
else StateSelect.default),
T(stateSelect=if (pT_explicit or dT_explicit) and preferredMediumStates
then StateSelect.prefer else StateSelect.default),
p(stateSelect=if (pT_explicit or ph_explicit) and preferredMediumStates
then StateSelect.prefer else StateSelect.default))
"Base properties of air"
equation
MM = Air_Utilities.Basic.Constants.MM;
if dT_explicit then
p = pressure_dT(d, T);
h = specificEnthalpy_dT(d, T);
elseif ph_explicit then
d = density_ph(p, h);
T = temperature_ph(p, h);
else
h = specificEnthalpy_pT(p, T);
d = density_pT(p, T);
end if;
u = h - p/d;
R_s = Air_Utilities.Basic.Constants.R_s;
h = state.h;
p = state.p;
T = state.T;
d = state.d;
end BaseProperties;
redeclare function density_ph
"Computes density as a function of pressure and specific enthalpy"
extends Modelica.Icons.Function;
input AbsolutePressure p "Pressure";
input SpecificEnthalpy h "Specific enthalpy";
output Density d "Density";
algorithm
d := Air_Utilities.rho_ph(p, h);
annotation (Inline=true);
end density_ph;
redeclare function temperature_ph
"Computes temperature as a function of pressure and specific enthalpy"
extends Modelica.Icons.Function;
input AbsolutePressure p "Pressure";
input SpecificEnthalpy h "Specific enthalpy";
output Temperature T "Temperature";
algorithm
T := Air_Utilities.T_ph(p, h);
annotation (Inline=true);
end temperature_ph;
redeclare function temperature_ps
"Compute temperature from pressure and specific enthalpy"
extends Modelica.Icons.Function;
input AbsolutePressure p "Pressure";
input SpecificEntropy s "Specific entropy";
output Temperature T "Temperature";
algorithm
T := Air_Utilities.T_ps(p, s);
annotation (Inline=true);
end temperature_ps;
redeclare function density_ps
"Computes density as a function of pressure and specific enthalpy"
extends Modelica.Icons.Function;
input AbsolutePressure p "Pressure";
input SpecificEntropy s "Specific entropy";
output Density d "Density";
algorithm
d := Air_Utilities.rho_ps(p, s);
annotation (Inline=true);
end density_ps;
redeclare function pressure_dT
"Computes pressure as a function of density and temperature"
extends Modelica.Icons.Function;
input Density d "Density";
input Temperature T "Temperature";
output AbsolutePressure p "Pressure";
algorithm
p := Air_Utilities.p_dT(d, T);
annotation (Inline=true);
end pressure_dT;
redeclare function specificEnthalpy_dT
"Computes specific enthalpy as a function of density and temperature"
extends Modelica.Icons.Function;
input Density d "Density";
input Temperature T "Temperature";
output SpecificEnthalpy h "Specific enthalpy";
algorithm
h := Air_Utilities.h_dT(d, T);
annotation (Inline=true);
end specificEnthalpy_dT;
redeclare function specificEnthalpy_pT
"Computes specific enthalpy as a function of pressure and temperature"
extends Modelica.Icons.Function;
input AbsolutePressure p "Pressure";
input Temperature T "Temperature";
output SpecificEnthalpy h "Specific enthalpy";
algorithm
h := Air_Utilities.h_pT(p, T);
annotation (Inline=true);
end specificEnthalpy_pT;
redeclare function specificEnthalpy_ps
"Computes specific enthalpy as a function of pressure and temperature"
extends Modelica.Icons.Function;
input AbsolutePressure p "Pressure";
input SpecificEntropy s "Specific entropy";
output SpecificEnthalpy h "Specific enthalpy";
algorithm
h := Air_Utilities.h_ps(p, s);
annotation (Inline=true);
end specificEnthalpy_ps;
redeclare function density_pT
"Computes density as a function of pressure and temperature"
extends Modelica.Icons.Function;
input AbsolutePressure p "Pressure";
input Temperature T "Temperature";
output Density d "Density";
algorithm
d := Air_Utilities.rho_pT(p, T);
annotation (Inline=true);
end density_pT;
redeclare function extends dynamicViscosity
"Return dynamic viscosity as a function of the thermodynamic state record"
algorithm
eta := Air_Utilities.Transport.eta_dT(state.d, state.T);
annotation (Inline=true);
end dynamicViscosity;
redeclare function extends thermalConductivity
"Thermal conductivity of air"
algorithm
lambda := Air_Utilities.Transport.lambda_dT(state.d, state.T);
annotation (Inline=true);
end thermalConductivity;
redeclare function extends pressure "Return pressure of ideal gas"
algorithm
p := state.p;
annotation (Inline=true);
end pressure;
redeclare function extends temperature "Return temperature of ideal gas"
algorithm
T := state.T;
annotation (Inline=true);
end temperature;
redeclare function extends density "Return density of ideal gas"
algorithm
d := state.d;
annotation (Inline=true);
end density;
redeclare function extends specificEnthalpy "Return specific enthalpy"
algorithm
h := state.h;
annotation (Inline=true);
end specificEnthalpy;
redeclare function extends specificInternalEnergy
"Return specific internal energy"
algorithm
u := state.h - state.p/state.d;
annotation (Inline=true);
end specificInternalEnergy;
redeclare function extends specificGibbsEnergy
"Return specific Gibbs energy"
algorithm
g := state.h - state.T*specificEntropy(state);
annotation (Inline=true);
end specificGibbsEnergy;
redeclare function extends specificHelmholtzEnergy
"Return specific Helmholtz energy"
algorithm
f := state.h - state.p/state.d - state.T*specificEntropy(state);
annotation (Inline=true);
end specificHelmholtzEnergy;
redeclare function extends specificEntropy "Specific entropy of air"
algorithm
if dT_explicit then
s := Air_Utilities.s_dT(state.d, state.T);
elseif pT_explicit then
s := Air_Utilities.s_pT(state.p, state.T);
else
s := Air_Utilities.s_ph(state.p, state.h);
end if;
end specificEntropy;
redeclare function extends specificHeatCapacityCp
"Specific heat capacity at constant pressure of air"
algorithm
if dT_explicit then
cp := Air_Utilities.cp_dT(state.d, state.T);
elseif pT_explicit then
cp := Air_Utilities.cp_pT(state.p, state.T);
else
cp := Air_Utilities.cp_ph(state.p, state.h);
end if;
end specificHeatCapacityCp;
redeclare function extends specificHeatCapacityCv
"Specific heat capacity at constant volume of air"
algorithm
if dT_explicit then
cv := Air_Utilities.cv_dT(state.d, state.T);
elseif pT_explicit then
cv := Air_Utilities.cv_pT(state.p, state.T);
else
cv := Air_Utilities.cv_ph(state.p, state.h);
end if;
end specificHeatCapacityCv;
redeclare function extends isentropicExponent
"Return isentropic exponent"
algorithm
if dT_explicit then
gamma := Air_Utilities.isentropicExponent_dT(state.d, state.T);
elseif pT_explicit then
gamma := Air_Utilities.isentropicExponent_pT(state.p, state.T);
else
gamma := Air_Utilities.isentropicExponent_ph(state.p, state.h);
end if;
end isentropicExponent;
redeclare function extends isothermalCompressibility
"Isothermal compressibility of air"
algorithm
if dT_explicit then
kappa := Air_Utilities.kappa_dT(state.d, state.T);
elseif pT_explicit then
kappa := Air_Utilities.kappa_pT(state.p, state.T);
else
kappa := Air_Utilities.kappa_ph(state.p, state.h);
end if;
end isothermalCompressibility;
redeclare function extends isobaricExpansionCoefficient
"Isobaric expansion coefficient of air"
algorithm
if dT_explicit then
beta := Air_Utilities.beta_dT(state.d, state.T);
elseif pT_explicit then
beta := Air_Utilities.beta_pT(state.p, state.T);
else
beta := Air_Utilities.beta_ph(state.p, state.h);
end if;
end isobaricExpansionCoefficient;
redeclare function extends velocityOfSound
"Return velocity of sound as a function of the thermodynamic state record"
algorithm
if dT_explicit then
a := Air_Utilities.velocityOfSound_dT(state.d, state.T);
elseif pT_explicit then
a := Air_Utilities.velocityOfSound_pT(state.p, state.T);
else
a := Air_Utilities.velocityOfSound_ph(state.p, state.h);
end if;
end velocityOfSound;
redeclare function extends density_derh_p
"Density derivative by specific enthalpy"
algorithm
ddhp := Air_Utilities.ddhp(state.p, state.h);
annotation (Inline=true);
end density_derh_p;
redeclare function extends density_derp_h
"Density derivative by pressure"
algorithm
ddph := Air_Utilities.ddph(state.p, state.h);
annotation (Inline=true);
end density_derp_h;
// redeclare function extends density_derT_p
// "Density derivative by temperature"
// algorithm
// ddTp := IF97_Utilities.ddTp(state.p, state.h, state.phase);
// end density_derT_p;
//
// redeclare function extends density_derp_T
// "Density derivative by pressure"
// algorithm
// ddpT := IF97_Utilities.ddpT(state.p, state.h, state.phase);
// end density_derp_T;
redeclare function extends setState_dTX
"Return thermodynamic state of air as function of d and T"
algorithm
state := ThermodynamicState(
d=d,
T=T,
h=specificEnthalpy_dT(d, T),
p=pressure_dT(d, T));
annotation (Inline=true);
end setState_dTX;
redeclare function extends setState_phX
"Return thermodynamic state of air as function of p and h"
algorithm
state := ThermodynamicState(
d=density_ph(p, h),
T=temperature_ph(p, h),
h=h,
p=p);
annotation (Inline=true);
end setState_phX;
redeclare function extends setState_psX
"Return thermodynamic state of air as function of p and s"
algorithm
state := ThermodynamicState(
d=density_ps(p, s),
T=temperature_ps(p, s),
h=specificEnthalpy_ps(p, s),
p=p);
annotation (Inline=true);
end setState_psX;
redeclare function extends setState_pTX
"Return thermodynamic state of air as function of p and T"
algorithm
state := ThermodynamicState(
d=density_pT(p, T),
T=T,
h=specificEnthalpy_pT(p, T),
p=p);
annotation (Inline=true);
end setState_pTX;
redeclare function extends setSmoothState
"Return thermodynamic state so that it smoothly approximates: if x > 0 then state_a else state_b"
import Modelica.Media.Common.smoothStep;
algorithm
state := ThermodynamicState(
p=smoothStep(
x,
state_a.p,
state_b.p,
x_small),
h=smoothStep(
x,
state_a.h,
state_b.h,
x_small),
d=density_ph(smoothStep(
x,
state_a.p,
state_b.p,
x_small), smoothStep(
x,
state_a.h,
state_b.h,
x_small)),
T=temperature_ph(smoothStep(
x,
state_a.p,
state_b.p,
x_small), smoothStep(
x,
state_a.h,
state_b.h,
x_small)));
annotation (Inline=true);
end setSmoothState;
redeclare function extends isentropicEnthalpy
algorithm
h_is := specificEnthalpy_psX(
p_downstream,
specificEntropy(refState),
reference_X);
annotation (Inline=true);
end isentropicEnthalpy;
redeclare function extends molarMass "Return the molar mass of the medium"
algorithm
MM := Modelica.Media.Air.ReferenceAir.airConstants.molarMass;
annotation (Inline=true);
end molarMass;
annotation (Documentation(info="<html>
<p>
This model calculates medium properties
for air in the <strong>liquid</strong>, <strong>gas</strong> and <strong>two phase</strong> regions.
Three variable pairs can be the independent variables of the model:
</p>
<ol>
<li>Pressure <strong>p</strong> and specific enthalpy <strong>h</strong> are the most natural choice for general applications. This is the recommended choice for most general purpose applications.</li>
<li>Pressure <strong>p</strong> and temperature <strong>T</strong> are the most natural choice for applications where air is always in the same phase (liquid or gas).</li>
<li>Density <strong>d</strong> and temperature <strong>T</strong> are explicit variables of the Helmholtz function in the near-critical region and can be the best choice for applications with super-critical or near-critical states.</li>
</ol>
<p>
The following quantities are always computed:
</p>
<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">
<tr><td><strong>Variable</strong></td>
<td><strong>Unit</strong></td>
<td><strong>Description</strong></td></tr>
<tr><td>T</td>
<td>K</td>
<td>temperature</td></tr>
<tr><td>u</td>
<td>J/kg</td>
<td>specific internal energy</td></tr>
<tr><td>d</td>
<td>kg/m^3</td>
<td>density</td></tr>
<tr><td>p</td>
<td>Pa</td>
<td>pressure</td></tr>
<tr><td>h</td>
<td>J/kg</td>
<td>specific enthalpy</td></tr>
</table>
<p>
In some cases additional medium properties are needed.
A component that needs these optional properties has to call
one of the functions listed in
<a href=\"modelica://Modelica.Media.UsersGuide.MediumUsage.OptionalProperties\">
Modelica.Media.UsersGuide.MediumUsage.OptionalProperties</a> and in
<a href=\"modelica://Modelica.Media.UsersGuide.MediumUsage.TwoPhase\">
Modelica.Media.UsersGuide.MediumUsage.TwoPhase</a>.
</p>
<p>Many further properties can be computed. Using the well-known Bridgman's Tables, all first partial derivatives of the standard thermodynamic variables can be computed easily.</p>
</html>"));
end Air_Base;
package Air_Utilities
"Low level and utility computation for high accuracy dry air properties"
extends Modelica.Icons.UtilitiesPackage;
record iter = Inverses.accuracy;
package Basic "Fundamental equation of state"
extends Modelica.Icons.BasesPackage;
constant Modelica.Media.Common.FundamentalConstants Constants(
final R_bar=8.31451,
final R_s=287.117,
final MM=28.9586E-003,
final rhored=10447.7,
final Tred=132.6312,
final pred=3785020,
h_off=1589557.62320524,
s_off=6610.41237132543);
function Helmholtz "Helmholtz equation of state"
extends Modelica.Icons.Function;
input SI.Density d "Density";
input SI.Temperature T "Temperature (K)";
output Modelica.Media.Common.HelmholtzDerivs f
"Dimensionless Helmholtz function and derivatives w.r.t. delta and tau";
protected
final constant Real[13] N_0={0.605719400E-007,-0.210274769E-004,-0.158860716E-003,
-0.13841928076E002,0.17275266575E002,-0.195363420E-003,
0.2490888032E001,0.791309509,0.212236768,0.197938904,
0.2536365E002,0.1690741E002,0.8731279E002};
final constant Real[19] N={0.118160747229,0.713116392079,-0.161824192067E001,
0.714140178971E-001,-0.865421396646E-001,0.134211176704,
0.112626704218E-001,-0.420533228842E-001,0.349008431982E-001,
0.164957183186E-003,-0.101365037912,-0.173813690970,-0.472103183731E-001,
-0.122523554253E-001,-0.146629609713,-0.316055879821E-001,
0.233594806142E-003,0.148287891978E-001,-0.938782884667E-002};
final constant Integer[19] i={1,1,1,2,3,3,4,4,4,6,1,3,5,6,1,3,11,1,3};
final constant Real[19] j={0,0.33,1.01,0,0,0.15,0,0.2,0.35,1.35,1.6,
0.8,0.95,1.25,3.6,6,3.25,3.5,15};
final constant Integer[19] l={0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,3,3};
algorithm
f.d := d;
f.T := T;
f.R_s := ReferenceAir.Air_Utilities.Basic.Constants.R_s;
//Reduced density
f.delta := d/(ReferenceAir.Air_Utilities.Basic.Constants.MM*
ReferenceAir.Air_Utilities.Basic.Constants.rhored);
//Reciprocal reduced temperature
f.tau := ReferenceAir.Air_Utilities.Basic.Constants.Tred/T;
//Dimensionless Helmholtz equation
f.f := 0;
//Ideal-gas part
for k in 1:5 loop
f.f := f.f + N_0[k]*f.tau^(k - 4);
end for;
f.f := f.f + log(f.delta) + N_0[6]*f.tau*sqrt(f.tau) + N_0[7]*log(f.tau)
+ N_0[8]*log(1 - exp(-N_0[11]*f.tau)) + N_0[9]*log(1 - exp(-N_0[12]
*f.tau)) + N_0[10]*log(2/3 + exp(N_0[13]*f.tau));
//Residual part
for k in 1:10 loop
f.f := f.f + N[k]*f.delta^i[k]*f.tau^j[k];
end for;
for k in 11:19 loop
f.f := f.f + N[k]*f.delta^i[k]*f.tau^j[k]*exp(-f.delta^l[k]);
end for;
//First derivative of f w.r.t. delta
f.fdelta := 0;
//Ideal-gas part
f.fdelta := 1/f.delta;
//Residual part
for k in 1:10 loop
f.fdelta := f.fdelta + i[k]*N[k]*f.delta^(i[k] - 1)*f.tau^j[k];
end for;
for k in 11:19 loop
f.fdelta := f.fdelta + N[k]*f.delta^(i[k] - 1)*f.tau^j[k]*exp(-f.delta
^l[k])*(i[k] - l[k]*f.delta^l[k]);
end for;
//Second derivative of f w.r.t. delta
f.fdeltadelta := 0;
//Ideal-gas part
f.fdeltadelta := -1/f.delta^2;
//Residual part
for k in 1:10 loop
f.fdeltadelta := f.fdeltadelta + i[k]*(i[k] - 1)*N[k]*f.delta^(i[k]
- 2)*f.tau^j[k];
end for;
for k in 11:19 loop
f.fdeltadelta := f.fdeltadelta + N[k]*f.delta^(i[k] - 2)*f.tau^j[k]
*exp(-f.delta^l[k])*((i[k] - l[k]*f.delta^l[k])*(i[k] - 1 - l[k]*
f.delta^l[k]) - l[k]^2*f.delta^l[k]);
end for;
//First derivative of f w.r.t. tau
f.ftau := 0;
//Ideal-gas part
for k in 1:5 loop
f.ftau := f.ftau + (k - 4)*N_0[k]*f.tau^(k - 5);
end for;
f.ftau := f.ftau + 1.5*N_0[6]*sqrt(f.tau) + N_0[7]/f.tau + N_0[8]*N_0
[11]/(exp(N_0[11]*f.tau) - 1) + N_0[9]*N_0[12]/(exp(N_0[12]*f.tau)
- 1) + N_0[10]*N_0[13]/(2/3*exp(-N_0[13]*f.tau) + 1);
//Residual part
for k in 1:10 loop
f.ftau := f.ftau + j[k]*N[k]*f.delta^i[k]*f.tau^(j[k] - 1);
end for;
for k in 11:19 loop
f.ftau := f.ftau + j[k]*N[k]*f.delta^i[k]*f.tau^(j[k] - 1)*exp(-f.delta
^l[k]);
end for;
//Second derivative of f w.r.t. tau
f.ftautau := 0;
//Ideal-gas part
for k in 1:3 loop
f.ftautau := f.ftautau + (k - 4)*(k - 5)*N_0[k]*f.tau^(k - 6);
end for;
f.ftautau := f.ftautau + 0.75*N_0[6]/sqrt(f.tau) - N_0[7]/f.tau^2 -
N_0[8]*N_0[11]^2*exp(N_0[11]*f.tau)/(exp(N_0[11]*f.tau) - 1)^2 -
N_0[9]*N_0[12]^2*exp(N_0[12]*f.tau)/(exp(N_0[12]*f.tau) - 1)^2 + 2/
3*N_0[10]*N_0[13]^2*exp(-N_0[13]*f.tau)/(2/3*exp(-N_0[13]*f.tau) +
1)^2;
//Residual part
for k in 1:10 loop
f.ftautau := f.ftautau + j[k]*(j[k] - 1)*N[k]*f.delta^i[k]*f.tau^(j[
k] - 2);
end for;
for k in 11:19 loop
f.ftautau := f.ftautau + j[k]*(j[k] - 1)*N[k]*f.delta^i[k]*f.tau^(j[
k] - 2)*exp(-f.delta^l[k]);
end for;
//Mixed derivative of f w.r.t. delta and tau
f.fdeltatau := 0;
//Residual part (Ideal-gas part is zero)
for k in 1:10 loop
f.fdeltatau := f.fdeltatau + i[k]*j[k]*N[k]*f.delta^(i[k] - 1)*f.tau
^(j[k] - 1);
end for;
for k in 11:19 loop
f.fdeltatau := f.fdeltatau + j[k]*N[k]*f.delta^(i[k] - 1)*f.tau^(j[
k] - 1)*exp(-f.delta^l[k])*(i[k] - l[k]*f.delta^l[k]);
end for;
end Helmholtz;
end Basic;
package Inverses "Inverse function"
extends Modelica.Icons.BasesPackage;
record accuracy "Accuracy of the iterations"
extends Modelica.Icons.Record;
constant Real delp=1E-001 "Accuracy of p";
constant Real delh=1E-009 "Accuracy of h";
constant Real dels=1E-006 "Accuracy of s";
end accuracy;
function dofpT "Compute d for given p and T"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
input SI.Temperature T "Temperature (K)";
input SI.Pressure delp "Iteration converged if (p-pre(p) < delp)";
output SI.Density d "Density";
protected
Integer i=0 "Loop counter";
Real dp "Pressure difference";
SI.Density deld "Density step";
Modelica.Media.Common.HelmholtzDerivs f
"Dimensionless Helmholtz function and derivatives w.r.t. delta and tau";
Modelica.Media.Common.NewtonDerivatives_pT nDerivs
"Derivatives needed in Newton iteration";
Boolean found=false "Flag for iteration success";
algorithm
d := p/(ReferenceAir.Air_Utilities.Basic.Constants.R_s*T);
while ((i < 100) and not found) loop
f := Basic.Helmholtz(d, T);
nDerivs := Modelica.Media.Common.Helmholtz_pT(f);
dp := nDerivs.p - p;
if (abs(dp) <= delp) then
found := true;
end if;
deld := dp/nDerivs.pd;
d := d - deld;
i := i + 1;
end while;
end dofpT;
function dTofph "Return d and T as a function of p and h"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
input SI.SpecificEnthalpy h "Specific enthalpy";
input SI.Pressure delp "Iteration accuracy";
input SI.SpecificEnthalpy delh "Iteration accuracy";
output SI.Density d "Density";
output SI.Temperature T "Temperature (K)";
protected
SI.Temperature Tguess "Initial temperature";
SI.Density dguess "Initial density";
Integer i "Iteration counter";
Real dh "Newton-error in h-direction";
Real dp "Newton-error in p-direction";
Real det "Determinant of directional derivatives";
Real deld "Newton-step in d-direction";
Real delt "Newton-step in T-direction";
Modelica.Media.Common.HelmholtzDerivs f
"Dimensionless Helmholtz function and derivatives w.r.t. delta and tau";
Modelica.Media.Common.NewtonDerivatives_ph nDerivs
"Derivatives needed in Newton iteration";
Boolean found=false "Flag for iteration success";
algorithm
// Stefan Wischhusen: better guess for high temperatures:
T := h/1000 + 273.15;
d := p/(ReferenceAir.Air_Utilities.Basic.Constants.R_s*T);
i := 0;
while ((i < 100) and not found) loop
f := Basic.Helmholtz(d, T);
nDerivs := Modelica.Media.Common.Helmholtz_ph(f);
dh := nDerivs.h - ReferenceAir.Air_Utilities.Basic.Constants.h_off
- h;
dp := nDerivs.p - p;
if ((abs(dh) <= delh) and (abs(dp) <= delp)) then
found := true;
end if;
det := nDerivs.ht*nDerivs.pd - nDerivs.pt*nDerivs.hd;
delt := (nDerivs.pd*dh - nDerivs.hd*dp)/det;
deld := (nDerivs.ht*dp - nDerivs.pt*dh)/det;
T := T - delt;
d := d - deld;
i := i + 1;
end while;
end dTofph;
function dTofps "Return d and T as a function of p and s"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
input SI.SpecificEntropy s "Specific entropy";
input SI.Pressure delp "Iteration accuracy";
input SI.SpecificEntropy dels "Iteration accuracy";
output SI.Density d "Density";
output SI.Temperature T "Temperature (K)";
protected
SI.Temperature Tguess "Initial temperature";
SI.Density dguess "Initial density";
Integer i "Iteration counter";
Real ds "Newton-error in s-direction";
Real dp "Newton-error in p-direction";
Real det "Determinant of directional derivatives";
Real deld "Newton-step in d-direction";
Real delt "Newton-step in T-direction";
Modelica.Media.Common.HelmholtzDerivs f
"Dimensionless Helmholtz function and derivatives w.r.t. delta and tau";
Modelica.Media.Common.NewtonDerivatives_ps nDerivs
"Derivatives needed in Newton iteration";
Boolean found=false "Flag for iteration success";
algorithm
T := 273.15;
d := p/(ReferenceAir.Air_Utilities.Basic.Constants.R_s*T);
i := 0;
while ((i < 100) and not found) loop
f := Basic.Helmholtz(d, T);
nDerivs := Modelica.Media.Common.Helmholtz_ps(f);
ds := nDerivs.s - ReferenceAir.Air_Utilities.Basic.Constants.s_off
- s;
dp := nDerivs.p - p;
if ((abs(ds) <= dels) and (abs(dp) <= delp)) then
found := true;
end if;
det := nDerivs.st*nDerivs.pd - nDerivs.pt*nDerivs.sd;
delt := (nDerivs.pd*ds - nDerivs.sd*dp)/det;
deld := (nDerivs.st*dp - nDerivs.pt*ds)/det;
T := T - delt;
d := d - deld;
i := i + 1;
end while;
end dTofps;
end Inverses;
package Transport "Transport properties for air"
extends Modelica.Icons.BasesPackage;
function eta_dT "Return dynamic viscosity as a function of d and T"
extends Modelica.Icons.Function;
input SI.Density d "Density";
input SI.Temperature T "Temperature";
output SI.DynamicViscosity eta "Dynamic viscosity";
protected
Real delta=d/(ReferenceAir.Air_Utilities.Basic.Constants.MM*
ReferenceAir.Air_Utilities.Basic.Constants.rhored)
"Reduced density";
Real tau=ReferenceAir.Air_Utilities.Basic.Constants.Tred/T
"Reciprocal reduced temperature";
Real Omega "Collision integral";
SI.DynamicViscosity eta_0=0 "Dilute gas viscosity";
SI.DynamicViscosity eta_r=0 "Residual fluid viscosity";
final constant Real[5] b={0.431,-0.4623,0.08406,0.005341,-0.00331};
final constant Real[5] Nvis={10.72,1.122,0.002019,-8.876,-0.02916};
final constant Real[5] tvis={0.2,0.05,2.4,0.6,3.6};
final constant Integer[5] dvis={1,4,9,1,8};
final constant Integer[5] lvis={0,0,0,1,1};
final constant Integer[5] gammavis={0,0,0,1,1};
algorithm
Omega := exp(
Modelica.Math.Polynomials.evaluate(
{b[5],b[4],b[3],b[2],b[1]}, log(T/103.3)));
eta_0 := 0.0266958*sqrt(1000*ReferenceAir.Air_Utilities.Basic.Constants.MM
*T)/(0.36^2*Omega);
for i in 1:5 loop
eta_r := eta_r + (Nvis[i]*(tau^tvis[i])*(delta^dvis[i])*exp(-
gammavis[i]*(delta^lvis[i])));
end for;
eta := (eta_0 + eta_r)*1E-006;
end eta_dT;
function lambda_dT
"Return thermal conductivity as a function of d and T"
extends Modelica.Icons.Function;
input SI.Density d "Density";
input SI.Temperature T "Temperature";
output SI.ThermalConductivity lambda "Thermal conductivity";
protected
Modelica.Media.Common.HelmholtzDerivs f
"Dimensionless Helmholtz function and derivatives w.r.t. delta and tau";
SI.ThermalConductivity lambda_0=0 "Dilute gas thermal conductivity";
SI.ThermalConductivity lambda_r=0
"Residual fluid thermal conductivity";
SI.ThermalConductivity lambda_c=0
"Thermal conductivity critical enhancement";
Real Omega "Collision integral";
SI.DynamicViscosity eta_0=0 "Dilute gas viscosity";
Real pddT;
Real pddTref;
Real pdTp;
Real xi;
Real xiref;
Real Omega_tilde;
Real Omega_0_tilde;
Real cv;
Real cp;
final constant Real[5] b={0.431,-0.4623,0.08406,0.005341,-0.00331};
final constant Real[9] Ncon={1.308,1.405,-1.036,8.743,14.76,-16.62,
3.793,-6.142,-0.3778};
final constant Real[9] tcon={0.0,-1.1,-0.3,0.1,0.0,0.5,2.7,0.3,1.3};
final constant Integer[9] dcon={0,0,0,1,2,3,7,7,11};
final constant Integer[9] lcon={0,0,0,0,0,2,2,2,2};
final constant Integer[9] gammacon={0,0,0,0,0,1,1,1,1};
algorithm
//chi_tilde in at the reference temperature 265.262
f := Basic.Helmholtz(d, 265.262);
pddTref := ReferenceAir.Air_Utilities.Basic.Constants.R_bar*265.262*(
1 + 2*f.delta*(f.fdelta - 1/f.delta) + f.delta^2*(f.fdeltadelta + 1
/f.delta^2));
xiref := ReferenceAir.Air_Utilities.Basic.Constants.pred*(d/
ReferenceAir.Air_Utilities.Basic.Constants.MM)/ReferenceAir.Air_Utilities.Basic.Constants.rhored
^2/pddTref;
//calculating f at the given state
f := Basic.Helmholtz(d, T);
Omega := exp(
Modelica.Math.Polynomials.evaluate(
{b[5],b[4],b[3],b[2],b[1]}, log(T/103.3)));
//Ideal-gas part of dynamic viscosity
eta_0 := 0.0266958*sqrt(1000*ReferenceAir.Air_Utilities.Basic.Constants.MM
*T)/(0.36^2*Omega);
//Ideal-gas part of thermal conductivity
lambda_0 := Ncon[1]*eta_0 + Ncon[2]*f.tau^tcon[2] + Ncon[3]*f.tau^
tcon[3];
//Residual part of thermal conductivity
for i in 4:9 loop
lambda_r := lambda_r + Ncon[i]*f.tau^tcon[i]*f.delta^dcon[i]*exp(-
gammacon[i]*f.delta^lcon[i]);
end for;
//Derivative of p w.r.t. d at constant temperature
pddT := ReferenceAir.Air_Utilities.Basic.Constants.R_s*T*(1 + 2*f.delta
*(f.fdelta - 1/f.delta) + f.delta^2*(f.fdeltadelta + 1/f.delta^2));
//chi_tilde at the given state
xi := ReferenceAir.Air_Utilities.Basic.Constants.pred*(d/ReferenceAir.Air_Utilities.Basic.Constants.MM)
/ReferenceAir.Air_Utilities.Basic.Constants.rhored^2/(pddT*
ReferenceAir.Air_Utilities.Basic.Constants.MM);
//Thermal conductivity critical enhancement
xi := xi - xiref*265.262/T;
if (xi <= 0) then
lambda_c := 0;
else
xi := 0.11*(xi/0.055)^(0.63/1.2415);
//Derivative of p w.r.t. T at constant p
pdTp := ReferenceAir.Air_Utilities.Basic.Constants.R_s*d*(1 + f.delta
*(f.fdelta - 1/f.delta) - f.delta*f.tau*f.fdeltatau);
//Specific isochoric heat capacity
cv := ReferenceAir.Air_Utilities.Basic.Constants.R_s*(-f.tau*f.tau*f.ftautau);
//Specific isobaric heat capacity
cp := cv + T*pdTp*pdTp/(d*d*pddT);
Omega_tilde := 2/Modelica.Constants.pi*((cp - cv)/cp*atan(xi/0.31)
+ cv/cp*xi/0.31);
Omega_0_tilde := 2/Modelica.Constants.pi*(1 - exp(-1/((0.31/xi) + 1
/3*(xi/0.31)^2*(ReferenceAir.Air_Utilities.Basic.Constants.rhored
/(d/ReferenceAir.Air_Utilities.Basic.Constants.MM))^2)));
lambda_c := d*cp*1.380658E-023*1.01*T/(6*Modelica.Constants.pi*xi*
eta_dT(d, T))*(Omega_tilde - Omega_0_tilde)*1E012;
end if;
lambda := (lambda_0 + lambda_r + lambda_c)/1000;
end lambda_dT;
end Transport;
function airBaseProp_ps "Intermediate property record for air"
extends Modelica.Icons.Function;
input SI.Pressure p "Pressure";
input SI.SpecificEntropy s "Specific entropy";
output Common.AuxiliaryProperties aux "Auxiliary record";
protected