-
Notifications
You must be signed in to change notification settings - Fork 0
/
Properties.f90
768 lines (703 loc) · 23.6 KB
/
Properties.f90
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
!---------------------------------------------------------------------------------------------------
! All the formulations have been taken from the original
! article,the Span-Wagner EoS for CO2.
! The EoS has been published in J. Phys. Chem. Ref. Data, Vol.25,
! pp. 1509-1596, 1996.
!---------------------------------------------------------------------------------------------------
!--------------------------------------------------------------------------------------------------
! MODULE properties
! @brief Compute thermodynamic properties in IS p.1517 Table3:
! Pressure, specific internal energy , specific Cv, specific Cp, speed of sound,
! specific entropy, specific helmholtz energy, specific gibbs energy
! @routine helmholtz_deriv.f90, helmholtz_dimless.f90
! @authors Yu Fang
! @date 10-02-2017
! NOTE: derivatives are added 27/11/2017
!--------------------------------------------------------------------------------------------------
MODULE properties
!
USE def_constants
!
USE def_variables, ONLY: saturP, saturP_sat, vL_psat_spline, vV_psat_spline,&
& uL_psat_spline, uV_psat_spline, Tsat_psat_spline, &
& saturP2, saturP_sat2, vL_psat_spline2, vV_psat_spline2,&
& uL_psat_spline2, uV_psat_spline2, Tsat_psat_spline2
IMPLICIT NONE
!
PRIVATE
PUBLIC :: pressure, inter_energy, heat_cap_v, heat_cap_p,dpdv_T, dpdT_v,&
& sound_speed, entropy, helmho, gibbs,dpdu_v, dpdr_u, satprop, satderiv, axlpress,&
& dedr_T
CONTAINS
!
!
!===============================================================================================
SUBROUTINE pressure(T,v,p) !Pa
!===============================================================================================
IMPLICIT NONE
!
!IN/OUT
REAL(pr) :: T,v
REAL(pr) :: p
!LOCAL
REAL(pr) :: rho,delt
!
!for helmholtz_deriv
!
REAL(pr) :: phi_r_ddelt, phi_r_dtau,&
phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
!Pre-compute
!
rho = 1_pr / v
delt = 1_pr / (rho_cr*v)
!
CALL helmholtz_deriv( T, v, phi_r_ddelt, phi_r_dtau,&
phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau )
! print*, phi_r_ddelt, phi_r_dtau,phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
!
p = (1_pr + delt * phi_r_ddelt) * R * T * rho
!
END SUBROUTINE pressure
!
!=================================================================================================
SUBROUTINE inter_energy(T,v,e) !J/kg
!=================================================================================================
IMPLICIT NONE
!
!IN/OUT
REAL(pr) :: T,v,e
!LOCAL
REAL(pr) :: tau
!for helmholtz_deriv
REAL(pr) :: phi_r_ddelt, phi_r_dtau,&
phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
!for helmholtz_dimless
REAL(pr) :: phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau
!
!Pre-compute
tau = T_cr / T
!initialisation
phi_0 = 0_pr
phi_r = 0_pr
phi0_ddelt = 0_pr
phi0_dtau = 0_pr
phi0_dddelt = 0_pr
phi0_ddtau = 0_pr
phi_r_ddelt= 0_pr
phi_r_dtau = 0_pr
phi_r_dddelt = 0_pr
phi_r_ddtau = 0_pr
phi_r_ddeltdtau = 0_pr
!
CALL helmholtz_dimless (T,v,phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau)
! print*, phi_0,phi_r,phi0_ddelt,phi0_dtau,phi0_dddelt,phi0_ddtau
!
! print*, T,v
CALL helmholtz_deriv( T, v, phi_r_ddelt, phi_r_dtau,&
phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau )
! print*, phi_r_ddelt, phi_r_dtau,phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
!
!
e = tau * ( phi0_dtau + phi_r_dtau) * R * T
!
! print*, 'phi_r_dtau(properties) = ',phi_r_dtau
!
END SUBROUTINE inter_energy
!
!============================================================================================================
SUBROUTINE heat_cap_v(T,v,cv) !J/kgK
!============================================================================================================
IMPLICIT NONE
!
!IN/OUT
REAL(pr) :: T,v,cv
!LOCAL
REAL(pr) :: tau, tau2
!for helmholtz_deriv
REAL(pr) :: phi_r_ddelt, phi_r_dtau,&
phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
!for helmholtz_dimless
REAL(pr) :: phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau
!
!Pre-compute
tau = T_cr / T
tau2 = tau * tau
!initialisation
phi_0 = 0_pr
phi_r = 0_pr
phi0_ddelt = 0_pr
phi0_dtau = 0_pr
phi0_dddelt = 0_pr
phi0_ddtau = 0_pr
phi_r_ddelt= 0_pr
phi_r_dtau = 0_pr
phi_r_dddelt = 0_pr
phi_r_ddtau = 0_pr
phi_r_ddeltdtau = 0_pr
CALL helmholtz_dimless (T,v,phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau)
! print*, phi_0,phi_r,phi0_ddelt,phi0_dtau,phi0_dddelt,phi0_ddtau
CALL helmholtz_deriv( T, v, phi_r_ddelt, phi_r_dtau,&
phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau )
! print*, phi_r_ddelt, phi_r_dtau,phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
!
!
!
cv = -tau2 * ( phi0_ddtau + phi_r_ddtau ) * R
! print*, phi0_ddtau , phi_r_ddtau , tau2
!
!
END SUBROUTINE heat_cap_v
!
!================================================================================================================
SUBROUTINE heat_cap_p(T,v,cp) !J/kgK
!================================================================================================================
IMPLICIT NONE
!IN/OUT
REAL(pr) :: T,v,cp
!LOCAL
REAL(pr) :: rho,delt,tau,tau2,delt2
!for helmholtz_deriv
REAL(pr) :: phi_r_ddelt, phi_r_dtau,&
phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
!for helmholtz_dimless
REAL(pr) :: phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau
!Pre-compute
rho = 1_pr / v
delt = rho / rho_cr
tau = T_cr / T
tau2 = tau * tau
delt2 = delt * delt
!initialisation
phi_0 = 0_pr
phi_r = 0_pr
phi0_ddelt = 0_pr
phi0_dtau = 0_pr
phi0_dddelt = 0_pr
phi0_ddtau = 0_pr
phi_r_ddelt= 0_pr
phi_r_dtau = 0_pr
phi_r_dddelt = 0_pr
phi_r_ddtau = 0_pr
phi_r_ddeltdtau = 0_pr
CALL helmholtz_dimless (T,v,phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau)
! print*, phi_0,phi_r,phi0_ddelt,phi0_dtau,phi0_dddelt,phi0_ddtau
CALL helmholtz_deriv( T, v, phi_r_ddelt, phi_r_dtau,&
phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau )
! print*, phi_r_ddelt, phi_r_dtau,phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
!
!
cp = ( -tau2 * ( phi0_ddtau + phi_r_ddtau ) + &
(1_pr+delt*phi_r_ddelt-delt*tau*phi_r_ddeltdtau)**(2_pr) / &
(1_pr+2_pr*delt*phi_r_ddelt+delt2*phi_r_dddelt) ) * R
!
!
END SUBROUTINE heat_cap_p
!
!=============================================================================================================
SUBROUTINE sound_speed(T,v,c) !m/s
!=============================================================================================================
IMPLICIT NONE
!IN/OUT
REAL(pr) :: T,v,c
!LOCAL
REAL(pr) :: rho,delt,tau,tau2,delt2,c_2
!for helmholtz_deriv
REAL(pr) :: phi_r_ddelt, phi_r_dtau,&
phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
!for helmholtz_dimless
REAL(pr) :: phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau
!Pre-compute
rho = 1_pr / v
delt = 1_pr / (rho_cr*v)
tau = T_cr / T
tau2 = tau * tau
delt2 = delt * delt
!initialisation
phi_0 = 0_pr
phi_r = 0_pr
phi0_ddelt = 0_pr
phi0_dtau = 0_pr
phi0_dddelt = 0_pr
phi0_ddtau = 0_pr
phi_r_ddelt= 0_pr
phi_r_dtau = 0_pr
phi_r_dddelt = 0_pr
phi_r_ddtau = 0_pr
phi_r_ddeltdtau = 0_pr
CALL helmholtz_dimless (T,v,phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau)
! print*, phi_0,phi_r,phi0_ddelt,phi0_dtau,phi0_dddelt,phi0_ddtau
CALL helmholtz_deriv( T, v, phi_r_ddelt, phi_r_dtau,&
phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau )
! print*, phi_r_ddelt, phi_r_dtau,phi_r_dddelt, phi_r_ddtau,
! phi_r_ddeltdtau
!
!
c_2 = ( 1_pr + 2_pr*delt*phi_r_ddelt + delt2*phi_r_dddelt - &
(1_pr + delt*phi_r_ddelt - delt*tau*phi_r_ddeltdtau)**(2_pr) / &
( tau2 * (phi0_ddtau+phi_r_ddtau) ) ) * R * T
! print*, tau2 * (phi0_ddtau+phi_r_ddtau)
! print*, delt*phi_r_dddelt,delt*tau* phi_r_ddeltdtau
! print*, (1_pr + delt*phi_r_ddelt - delt*tau*phi_r_ddeltdtau)
! print*, delt*phi_r_ddelt
c = abs( sqrt(c_2) )
!
!
END SUBROUTINE sound_speed
!
!
!====================================================================================================================
SUBROUTINE entropy(T,v,s) !J/kgK
!====================================================================================================================
IMPLICIT NONE
!IN/OUT
REAL(pr) :: T,v,s
!LOCAL
REAL(pr) :: tau
!for helmholtz_deriv
REAL(pr) :: phi_r_ddelt, phi_r_dtau,&
phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
!for helmholtz_dimless
REAL(pr) :: phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau
!Pre-compute
tau = T_cr / T
!
!initialisation
phi_0 = 0_pr
phi_r = 0_pr
phi0_ddelt = 0_pr
phi0_dtau = 0_pr
phi0_dddelt = 0_pr
phi0_ddtau = 0_pr
phi_r_ddelt= 0_pr
phi_r_dtau = 0_pr
phi_r_dddelt = 0_pr
phi_r_ddtau = 0_pr
phi_r_ddeltdtau = 0_pr
CALL helmholtz_dimless (T,v,phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau)
! print*, phi_0,phi_r,phi0_ddelt,phi0_dtau,phi0_dddelt,phi0_ddtau
CALL helmholtz_deriv( T, v, phi_r_ddelt, phi_r_dtau,&
phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau )
! print*, phi_r_ddelt, phi_r_dtau,phi_r_dddelt, phi_r_ddtau,
! phi_r_ddeltdtau
!
!
s = (tau * ( phi0_dtau + phi_r_dtau) - phi_0 - phi_r) * R
!
!
END SUBROUTINE entropy
!
!================================================================================================================
SUBROUTINE helmho(T,v,h_helmho) !J/kg
!================================================================================================================
IMPLICIT NONE
!IN/OUT
REAL(pr) :: T,v,h_helmho
!LOCAL
REAL(pr) :: phi
!for helmholtz_dimless
REAL(pr) :: phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau
!
!initialisation
phi_0 = 0_pr
phi_r = 0_pr
phi0_ddelt = 0_pr
phi0_dtau = 0_pr
phi0_dddelt = 0_pr
phi0_ddtau = 0_pr
!
CALL helmholtz_dimless (T,v,phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau)
!
!
phi = phi_0 + phi_r
! print*, 'propoerties phi0, phir',phi_0, phi_r
! phi is a dimensionless magnitude, R is in [J/kg/K], T in [K]:
!
h_helmho = phi * R * T ! [J/kg]
!
!
END SUBROUTINE helmho
!
!
!=================================================================================================================
SUBROUTINE gibbs(T,v,g) !J/kg
!=================================================================================================================
IMPLICIT NONE
!IN/OUT
REAL(pr) :: T,v,g
!LOCAL
REAL(pr) :: h_helmho, p
!
!
CALL helmho(T,v,h_helmho)
CALL pressure(T,v,p)
!
!
g = h_helmho + p * v
!
!
END SUBROUTINE gibbs
!
!
!==================================================================================================================
SUBROUTINE dpdr_u(T,v,deriv) !Pa.m3/kg
!=================================================================================================================
IMPLICIT NONE
!IN/OUT
REAL(pr) :: T,v,deriv
!LOCAL
REAL(pr) :: rho, delt, phi_r_ddelt, phi_r_dtau,&
& phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
REAL(pr) :: phi_0,phi_r,phi0_ddelt,phi0_dtau,phi0_dddelt,phi0_ddtau,tau
REAL(pr) :: dp_dr_T, dp_du_r, du_dr_T
!
rho = 1_pr / v
delt = 1_pr / (rho_cr*v)
tau = T_cr/T
phi_r_ddelt = 0_pr
phi_r_dtau = 0_pr
phi_r_dddelt= 0_pr
phi_r_ddtau = 0_pr
phi_r_ddeltdtau = 0_pr
!
CALL helmholtz_dimless (T,v,phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau)
CALL helmholtz_deriv( T, v, phi_r_ddelt, phi_r_dtau,&
& phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau )
!
CALL dpdu_v(T,v,dp_du_r)
dp_dr_T = (1_pr + 2_pr*delt*phi_r_ddelt + delt*delt*phi_r_dddelt) *R *T
du_dr_T = R*T*tau/rho_cr * phi_r_ddeltdtau
!
deriv = dp_dr_T - dp_du_r*du_dr_T
END SUBROUTINE dpdr_u
!==================================================================================================================
SUBROUTINE dpdv_T(T,v,deriv) !Pa.m3/kg
!=================================================================================================================
IMPLICIT NONE
!IN/OUT
REAL(pr) :: T,v,deriv
!LOCAL
REAL(pr) :: rho, delt, phi_r_ddelt, phi_r_dtau,&
& phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
REAL(pr) :: phi_0,phi_r,phi0_ddelt,phi0_dtau,phi0_dddelt,phi0_ddtau,tau
REAL(pr) :: dp_dr_T, dp_du_r, du_dr_T
!
rho = 1_pr / v
delt = 1_pr / (rho_cr*v)
tau = T_cr/T
phi_r_ddelt = 0_pr
phi_r_dtau = 0_pr
phi_r_dddelt= 0_pr
phi_r_ddtau = 0_pr
phi_r_ddeltdtau = 0_pr
!
CALL helmholtz_dimless (T,v,phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau)
CALL helmholtz_deriv( T, v, phi_r_ddelt, phi_r_dtau,&
& phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau )
!
CALL dpdu_v(T,v,dp_du_r)
dp_dr_T = (1_pr + 2_pr*delt*phi_r_ddelt + delt*delt*phi_r_dddelt) *R *T
!
deriv = dp_dr_T *(-rho*rho)
END SUBROUTINE dpdv_T
!
!==================================================================================================================
SUBROUTINE dpdT_v(T,v,deriv)
!=================================================================================================================
IMPLICIT NONE
!IN/OUT
REAL(pr) :: T,v,deriv
!LOCAL
REAL(pr) :: rho, delt, phi_r_ddelt, phi_r_dtau,&
& phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
REAL(pr) :: tau
!
REAL(pr) :: dp_dT_v, du_dT_v
rho = 1_pr / v
delt = 1_pr / (rho_cr*v)
tau = T_cr/T
phi_r_ddelt = 0_pr
phi_r_dtau = 0_pr
phi_r_dddelt= 0_pr
phi_r_ddtau = 0_pr
phi_r_ddeltdtau = 0_pr
!
!
CALL helmholtz_deriv( T, v, phi_r_ddelt, phi_r_dtau,&
& phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau )
!
dp_dT_v = rho * R * (1_pr+delt*phi_r_ddelt-tau*delt*phi_r_ddeltdtau )
deriv = dp_dT_v
END SUBROUTINE dpdT_v
!
!
!==================================================================================================================
SUBROUTINE dpdu_v(T,v,deriv) !Pa/J.kg/m3
!=================================================================================================================
IMPLICIT NONE
!IN/OUT
REAL(pr) :: T,v,deriv
!LOCAL
REAL(pr) :: rho, delt, phi_r_ddelt, phi_r_dtau,&
& phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
REAL(pr) :: phi_0,phi_r,phi0_ddelt,phi0_dtau,phi0_dddelt,phi0_ddtau,tau
!
REAL(pr) :: dp_dT_v, du_dT_v
rho = 1_pr / v
delt = 1_pr / (rho_cr*v)
tau = T_cr/T
phi_r_ddelt = 0_pr
phi_r_dtau = 0_pr
phi_r_dddelt= 0_pr
phi_r_ddtau = 0_pr
phi_r_ddeltdtau = 0_pr
!
!
!
CALL helmholtz_dimless (T,v,phi_0,phi_r,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau)
!
CALL helmholtz_deriv( T, v, phi_r_ddelt, phi_r_dtau,&
& phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau )
!
dp_dT_v = rho * R * (1_pr+delt*phi_r_ddelt-tau*delt*phi_r_ddeltdtau )
du_dT_v = -R*tau*tau*( phi0_ddtau + phi_r_ddtau )
deriv = dp_dT_v / du_dT_v
END SUBROUTINE dpdu_v
!
!
!=================================================================================
!
SUBROUTINE satprop(mode, psat, Tsat, vvsat, vlsat, uvsat, ulsat)
!
!=================================================================================
IMPLICIT NONE
!
INTEGER :: i, j, j_sat
!
REAL(pr), INTENT(in) :: psat
INTEGER , INTENT(in) :: mode
!
REAL(pr), INTENT(out) :: Tsat, vvsat,vlsat,uvsat,ulsat
!
REAL(pr) :: delta, pp, temp
REAL(pr) :: vL, uL, vV, uV
!
!
!use 3e order spline
!
IF (mode == 3) THEN
!
delta = saturP(2) - saturP(1)
j_sat = INT((psat - saturP(1))/delta) + 1
!
!##computing saturation quantities
!
vL = 0_pr; uL = 0_pr; vV = 0_pr; uV = 0_pr; temp = 0_pr
DO i = 1, ord_spline+1
pp = psat**(i-1)
vL = vL + vL_psat_spline (ord_spline+2-i, j_sat) * pp
uL = uL + uL_psat_spline (ord_spline+2-i, j_sat) * pp
vV = vV + vV_psat_spline (ord_spline+2-i, j_sat) * pp
uV = uV + uV_psat_spline (ord_spline+2-i, j_sat) * pp
temp = temp+ Tsat_psat_spline(ord_spline+2-i, j_sat) * pp
ENDDO
!
!##for output saturation quantities
!
Tsat = temp
vvsat = vV
vlsat = vL
uvsat = uV
ulsat = uL
!
!use 5e order spline
!
ELSEIF (mode == 5) THEN
!
delta = saturP2(2) - saturP2(1)
j_sat = INT((psat - saturP2(1))/delta) + 1
!
!##computing saturation quantities
!
vL = 0_pr; uL = 0_pr; vV = 0_pr; uV = 0_pr
DO i = 1, 6
pp = psat**(i-1)
vL = vL + vL_psat_spline2 (5+2-i, j_sat) * pp
uL = uL + uL_psat_spline2 (5+2-i, j_sat) * pp
vV = vV + vV_psat_spline2 (5+2-i, j_sat) * pp
uV = uV + uV_psat_spline2 (5+2-i, j_sat) * pp
temp = temp+ Tsat_psat_spline2(5+2-i, j_sat) * pp
ENDDO
!
!##for output saturation quantities
!
Tsat = temp
vvsat = vV
vlsat = vL
uvsat = uV
ulsat = uL
!
ENDIF
END SUBROUTINE satprop
!
!=================================================================================
!
SUBROUTINE satderiv(mode, psat, duL_dp, duV_dp, dvL_dp, dvV_dp)
!
!=================================================================================
IMPLICIT NONE
!
INTEGER :: i, j, j_sat
!
REAL(pr), INTENT(in) :: psat
INTEGER , INTENT(in) :: mode
!
REAL(pr), INTENT(out) :: duL_dp, duV_dp, dvL_dp, dvV_dp
!
REAL(pr) :: delta, pp
REAL(pr) :: duLdp, duVdp, dvLdp, dvVdp
!
!
!use 3e order spline
!
IF (mode == 3) THEN
!
delta = saturP(2) - saturP(1)
j_sat = INT((psat - saturP(1))/delta) + 1
!
!##computing derivatives
!
duLdp = 0_pr; duVdp = 0_pr; dvLdp = 0_pr; dvVdp = 0_pr
DO i = 1, ord_spline
pp = psat**(ord_spline - i)
duLdp = duLdp + (ord_spline+1-i) * uL_psat_spline(i,j_sat) *pp
duVdp = duVdp + (ord_spline+1-i) * uV_psat_spline(i,j_sat) *pp
dvLdp = dvLdp + (ord_spline+1-i) * vL_psat_spline(i,j_sat) *pp
dvVdp = dvVdp + (ord_spline+1-i) * vV_psat_spline(i,j_sat) *pp
ENDDO
!
!##for output saturation quantities
!
duL_dp = duLdp
duV_dp = duVdp
dvL_dp = dvLdp
dvV_dp = dvVdp
!
!use 5e order spline
!
ELSEIF (mode == 5) THEN
!
delta = saturP2(2) - saturP2(1)
j_sat = INT((psat - saturP2(1))/delta) + 1
!
!##computing derivatives
!
duLdp = 0_pr; duVdp = 0_pr; dvLdp = 0_pr; dvVdp = 0_pr
DO i = 1, 5
pp = psat**(5 - i)
duLdp = duLdp + (5+1-i) * uL_psat_spline2(i,j_sat) *pp
duVdp = duVdp + (5+1-i) * uV_psat_spline2(i,j_sat) *pp
dvLdp = dvLdp + (5+1-i) * vL_psat_spline2(i,j_sat) *pp
dvVdp = dvVdp + (5+1-i) * vV_psat_spline2(i,j_sat) *pp
ENDDO
!
!##for output saturation quantities
!
duL_dp = duLdp
duV_dp = duVdp
dvL_dp = dvLdp
dvV_dp = dvVdp
!
ENDIF
END SUBROUTINE satderiv
!==================================================================================================================
SUBROUTINE axlpress(T,vvap, vliq, p1, p2, p3) !Pa
!=================================================================================================================
IMPLICIT NONE
!IN/OUT
REAL(pr), INTENT(IN) :: vvap,vliq,T
REAL(pr), INTENT(OUT) :: p1,p2,p3
!LOCAL
REAL(pr) :: deltp,deltpp,tau
REAL(pr) :: phi_r_ddelt1, phi_r_ddelt2, phi_r_dtau,&
& phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
REAL(pr) :: phi_0,phi_r1,phi_r2,phi0_ddelt,phi0_dtau,phi0_dddelt,phi0_ddtau
!
deltp = 1_pr / (rho_cr*vliq)
deltpp = 1_pr / (rho_cr*vvap)
tau = T_cr/T
!
phi_r1 = 0_pr
phi_r2 = 0_pr
phi_r_ddelt1 = 0_pr
phi_r_ddelt2 = 0_pr
phi_r_dtau = 0_pr
phi_r_dddelt= 0_pr
phi_r_ddtau = 0_pr
phi_r_ddeltdtau = 0_pr
!
!
!
CALL helmholtz_dimless (T,vliq,phi_0,phi_r1,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau)
!
CALL helmholtz_deriv( T, vliq, phi_r_ddelt1, phi_r_dtau,&
& phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau )
!
CALL helmholtz_dimless (T,vvap,phi_0,phi_r2,phi0_ddelt,phi0_dtau,&
phi0_dddelt,phi0_ddtau)
!
CALL helmholtz_deriv( T, vvap, phi_r_ddelt2, phi_r_dtau,&
& phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau )
!----------eq2.2a, 2.2b, 2.2C--------------
p1 = R*T/vliq * (1.0+deltp*phi_r_ddelt1)
p2 = R*T/vvap * (1.0+deltpp*phi_r_ddelt2)
p3 = ( phi_r1 - phi_r2 + dlog(vvap/vliq) ) * R*T / (vvap-vliq)
!
!
END SUBROUTINE axlpress
!
!==================================================================================================================
SUBROUTINE dedr_T(T,v,deriv)
!=================================================================================================================
IMPLICIT NONE
!IN/OUT
REAL(pr) :: T,v,deriv
!LOCAL
REAL(pr) :: rho, delt, phi_r_ddelt, phi_r_dtau,&
& phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau
!
REAL(pr) :: de_dr_T, tau
rho = 1_pr / v
delt = 1_pr / (rho_cr*v)
tau = T_cr/T
phi_r_ddelt = 0_pr
phi_r_dtau = 0_pr
phi_r_dddelt= 0_pr
phi_r_ddtau = 0_pr
phi_r_ddeltdtau = 0_pr
!
!
CALL helmholtz_deriv( T, v, phi_r_ddelt, phi_r_dtau,&
& phi_r_dddelt, phi_r_ddtau, phi_r_ddeltdtau )
!
de_dr_T = R * T_cr / rho_cr * phi_r_ddeltdtau
deriv = de_dr_T
END SUBROUTINE dedr_T
!
!
END MODULE properties