-
Notifications
You must be signed in to change notification settings - Fork 0
/
m_inoutvar.f90
2826 lines (2535 loc) · 86.8 KB
/
m_inoutvar.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
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
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Module computing pre-/post-processing data
!
! Last update: July 23, 2010
! Author: Keita Ando
! Department of Mechanical Engineering
! Division of Engineering and Applied Science
! California Institute of Technology, Pasadena CA 91125
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
MODULE m_inoutvar
USE m_globalvar
USE m_misc
USE mpi_setup
IMPLICIT NONE
! two probes to measure pressure
! used to compute dispersion relation of linear wave propagation
INTEGER :: mpi_rank_probe1, mpi_rank_probe2
INTEGER :: i_probe1, i_probe2
! used to output integrands R(x,t;R0)
INTEGER :: mpi_rank_integ1, mpi_rank_integ2
INTEGER :: i_integ1, i_integ2
! grid for entire domain
REAL(KIND(0.D0)), DIMENSION(:), ALLOCATABLE :: xgrid_tot
REAL(KIND(0.D0)), DIMENSION(:), ALLOCATABLE :: dxs_tot
! cell-edge location
REAL(KIND(0.D0)), DIMENSION(:), ALLOCATABLE :: xhalf_tot
! primitive variables and bubble radius for entire domain
TYPE(coordinate), DIMENSION(:), ALLOCATABLE :: prim_tot
TYPE(coordinate), DIMENSION(:), ALLOCATABLE :: rad_tot
INTEGER, DIMENSION(:), ALLOCATABLE :: i_Nx_nopad
! used for MPI_GATHERV
REAL(KIND(0.D0)), DIMENSION(:), ALLOCATABLE :: psend
REAL(KIND(0.D0)), DIMENSION(:), ALLOCATABLE :: precv
REAL(KIND(0.D0)), DIMENSION(:), ALLOCATABLE :: psend1
REAL(KIND(0.D0)), DIMENSION(:), ALLOCATABLE :: precv1
INTEGER, DIMENSION(:), ALLOCATABLE :: ircnt
INTEGER, DIMENSION(:), ALLOCATABLE :: idisp
INTEGER, DIMENSION(:), ALLOCATABLE :: ircnt1
INTEGER, DIMENSION(:), ALLOCATABLE :: idisp1
! bubble size
REAL(KIND(0.D0)) :: R0ref
REAL(KIND(0.D0)) :: sd
! initial void fraction
REAL(KIND(0.D0)) :: vf0
! steady shock speed & shock Mach number
REAL(KIND(0.D0)) :: Us, Ms
! new liquid pressure deviated from pl0
REAL(KIND(0.D0)) :: plnew
! max. CFL
REAL(KIND(0.D0)) :: CFLmx
! UNDEX & FSI properties
REAL(KIND(0.D0)) :: xs, ps, fsi
! no. of flow files
INTEGER :: Nout
! measure computation time
REAL(KIND(0.D0)) :: elp1, elp2
! label for outputing bubble sizes
INTEGER, DIMENSION(:), ALLOCATABLE :: iR1
! no. of bubble sizes for output
INTEGER :: NR0out
REAL(KIND(0.D0)), dimension(:),allocatable :: myRho, myVf, myN
REAL(KIND(0.D0)), dimension(:,:),allocatable :: myR
CONTAINS
!========================================================================
SUBROUTINE s_parameter
!!! computational conditions for Euler equations !!!
timescheme = 'rk3tvd' ! euler, rk3tvd
timesplit = 'unsplit' ! unsplit, godunov, strang
mpweno = 'y' ! y or n (MP-WENO: Balsara 2000)
chardecomp = 'n' ! y or n (characteristic decomposition)
stretch = 'n' ! y or n (grid stretching)
negative = 'n' ! correct negative void fraction at cell edges
source = 'y' ! y or n (static bubbles, zero sources)
wenoord = 5 ! 1, 3, 5
wenonum = ( wenoord-1 )/2
!!! WENO tolerance !!!
! 10^{-40} for cavitation cases
! Otherwise, 10^{-12} for example.
! eps = 1.D-40
eps = 1.D-12
!!! Accuracy for adaptive RK (godunov, strang) !!!
accuracy = 1.D-6
!!! computational conditions for bubble dynamics !!!
viscous = 'n' ! n for Re = \infty
polytropic = 'y' ! 'n' for Preston's or Sugiyama's model
thermal = 'adiabat' ! transfer, adiabat, isotherm
model = 'Preston' ! Preston or Sugiyama
nquad = 's' ! s (Simpson) or g (Gauss-Hermite)
!!! liquid and gas !!!
liquid = 'water' ! water, silicone, glycerol
gas = 'air' ! air, nitrogen, SF6
vapor = 'n'
!!! lognormal bubble size distribution !!!
R0ref = 50.D-6
sd = 0.D0
disperse = 'mono' ! mono or poly
!!! initial void fraction at pl0 !!!
! 10^{-6} to 10^{-5} for distilled water
vf0 = 0.5D-2
!!! ICs !!!
! for linear computation
! 1: narrow pressure perturbation
! 2: bubble screen
! 3: Leroy et al. (2008), sample 3
! 4: narrow pressure perturbation (convergence test)
! for nonlinear computation
! 1: steady shock, user-defined
! 2: Kameda (1998), nitrogen/silicone
! 3: Kameda (1998), SF6/silicone
! 4: Beylich (1990), SF6/glycerine
! 5: bubble screen
! 6: cavitation tube
! 7: UNDEX
nonlin = 'y'
smoothic = 'n'
ictype = '98'
!!! no. of cells, domain size & CFL !!!
Nx_tot = 2500
length%x = 2500.D0
CFL = 0.1D0
!!! BCs (reflect, nonreflect): periodic BC for single-processor ver. !!!
! for reflective BCs, solid walls placed at celledges (s_celledgevalue)
! but possibly placed at cell centers (see Johnsen 2007)
! for nonreflective BCs, Thompson-type BCs (1987) implemented
xbound%beg = 'nonreflect'
xbound%end = 'nonreflect'
! modification of sonic speed at boundaries
! y for shock computation
! n for cavitation computation
modifycl = 'y'
!!! BCs (freeplate, undex) for FSI & UNDEX !!!
! free plate (n, freeplate) at the left boundary
xincoming%beg = 'n'
IF ( xincoming%beg=='freeplate' ) xbound%beg = 'reflect'
! incoming waves (n, undex) at the right boundary
xincoming%end = 'n'
IF ( xincoming%end=='undex' ) xbound%end = 'nonreflect'
!!! probe measurement !!!
timehis = 'y'
!!! no. of flow files (excluding IC) !!!
Nout = 20
!!! given setups !!!
CALL s_given_setup
!!! allocate global variables !!!
CALL s_start_inoutvar
!!! nondimensional parameters !!!
! Bubble-dynamics-related parameters are computed, assuming that
! all the bubbles are initially at equilibrium (pl0,Tl0).
IF ( polytropic=='y' ) CALL s_physprop_poly
IF ( polytropic=='n' ) CALL s_physprop_trans
END SUBROUTINE s_parameter
!========================================================================
SUBROUTINE s_given_setup
IF ( nonlin=='y'.AND.ictype=='2' ) THEN
liquid = 'silicone'
gas = 'nitrogen'
vapor = 'n'
R0ref = 573.D-6
vf0 = 0.18D-2
Nx_tot = 7000
length%x = 8930.191972D0
CFL = 0.8D0
xbound%beg = 'nonreflect'
xbound%end = 'nonreflect'
smoothic = 'n'
ELSE IF ( nonlin=='y'.AND.ictype=='99'.or.ictype=='98' ) THEN
liquid = 'test_liquid'
gas = 'air'
vapor = 'n'
R0ref = 1.d0 !10.e-6
vf0 = 0.005d0
Nx_tot = 299 !601
length%x = 1.d0
cfl = 0.1d0
xbound%beg = 'nonreflect'
xbound%end = 'nonreflect'
timehis = 'n'
ELSE IF ( nonlin=='y'.AND.ictype=='3' ) THEN
liquid = 'silicone'
gas = 'SF6'
vapor = 'n'
R0ref = 613.D-6
vf0 = 0.24D-2
Nx_tot = 7000
length%x = 8347.5D0
CFL = 0.1D0
xbound%beg = 'nonreflect'
xbound%end = 'nonreflect'
smoothic = 'n'
ELSE IF ( nonlin=='y'.AND.ictype=='4' ) THEN
liquid = 'glycerol'
gas = 'SF6'
vapor = 'n'
R0ref = 1.15D-3
vf0 = 0.25D-2
Nx_tot = 1200
length%x = 2543.5D0
CFL = 0.8D0
xbound%beg = 'nonreflect'
xbound%end = 'nonreflect'
smoothic = 'n'
ELSE IF ( nonlin=='y'.AND.ictype=='5' ) THEN
!bubble screen
liquid = 'water'
gas = 'air'
vapor = 'y'
R0ref = 50.D-6
vf0 = 0.5D-2
! Nx_tot = 500
! length%x = 500.D0
Nx_tot = 800
length%x = 800.D0
CFL = 0.1D0
xbound%beg = 'nonreflect'
xbound%end = 'nonreflect'
smoothic = 'n'
ELSE IF ( nonlin=='y'.AND.ictype=='6' ) THEN
liquid = 'water'
gas = 'air'
vapor = 'y'
R0ref = 50.D-6
vf0 = 1.D-6
! Nx_tot = 1200
Nx_tot = 6000
length%x = 6000.D0
CFL = 0.1D0
xbound%beg = 'reflect'
xbound%end = 'nonreflect'
smoothic = 'n'
ELSE IF ( nonlin=='y'.AND.ictype=='7' ) THEN
liquid = 'water'
gas = 'air'
vapor = 'y'
R0ref = 50.D-6
vf0 = 1.D-5
Nx_tot = 3000
length%x = 18000.D0
! Nx_tot = 5000
! length%x = 25000.D0
! Nx_tot = 2000
! length%x = 8000.D0
CFL = 0.1D0
xbound%beg = 'reflect'
xbound%end = 'nonreflect'
xincoming%beg = 'freeplate'
xincoming%end = 'undex'
smoothic = 'n'
ELSE IF ( nonlin=='n'.AND.ictype=='1' ) THEN
liquid = 'water'
gas = 'air'
vapor = 'n'
R0ref = 10.D-6
vf0 = 0.1D-2
Nx_tot = 5000
length%x = 5000.D0
CFL = 0.1D0
xbound%beg = 'reflect'
xbound%end = 'nonreflect'
ELSE IF ( nonlin=='n'.AND.ictype=='2' ) THEN
liquid = 'water'
gas = 'air'
vapor = 'n'
R0ref = 10.D-6
vf0 = 0.1D-2
Nx_tot = 3000
length%x = 3000.D0
CFL = 0.1D0
xbound%beg = 'nonreflect'
xbound%end = 'nonreflect'
ELSE IF ( nonlin=='n'.AND.ictype=='3' ) THEN
liquid = 'water'
gas = 'air'
vapor = 'n'
R0ref = 100.D-6
sd = 0.2D0
disperse = 'poly'
vf0 = 0.91D-2
Nx_tot = 5000
length%x = 5000.D0
CFL = 0.1D0
xbound%beg = 'reflect'
xbound%end = 'nonreflect'
ELSE IF ( nonlin=='n'.AND.ictype=='4' ) THEN
liquid = 'water'
gas = 'air'
vapor = 'n'
R0ref = 10.D-6
vf0 = 0.1D-2
Nx_tot = 800
length%x = 800.D0
CFL = 0.1D0
xbound%beg = 'reflect'
xbound%end = 'nonreflect'
END IF
! time-step splitting
IF ( source=='n' ) timesplit = 'unsplit'
END SUBROUTINE s_given_setup
!========================================================================
SUBROUTINE s_start_inoutvar
INTEGER :: ir
! no. of conserved variables for the Euler equations
Nveul = 3
! no. of bubble-dynamics-related variables
IF ( polytropic=='y' ) Nb = 2
IF ( polytropic=='n'.AND.vapor=='n' ) Nb = 3
IF ( polytropic=='n'.AND.vapor=='y' ) Nb = 4
! odd no. of descretization points in R0
IF ( disperse=='mono' ) NR0 = 1
! IF ( disperse=='poly' ) NR0 = 101
IF ( disperse=='poly' ) NR0 = 401
! no. of conserved variables for the entire system
Nv = Nveul + Nb*NR0
! used for left & right eigenvectors
Neig1 = 5
Neig = Neig1 + Nb*NR0
! no. of bubble sizes for output
IF ( disperse=='poly'.AND.sd==0.7D0 ) THEN
NR0out = 5
ELSE
NR0out = 1
END IF
! allocation
ALLOCATE( ibub(Nb,NR0) )
ALLOCATE( ieig(Nb,NR0) )
ALLOCATE( iR1(NR0out) )
IF ( polytropic=='n' ) THEN
ALLOCATE( k_n(NR0) )
ALLOCATE( k_v(NR0) )
ALLOCATE( pb0(NR0) )
ALLOCATE( mass_n0(NR0) )
ALLOCATE( mass_v0(NR0) )
ALLOCATE( Pe_T(NR0) )
ALLOCATE( Re_trans_T(NR0) )
ALLOCATE( Re_trans_c(NR0) )
ALLOCATE( Im_trans_T(NR0) )
ALLOCATE( Im_trans_c(NR0) )
ALLOCATE( omegaN(NR0) )
END IF
ALLOCATE( R0(NR0) )
ALLOCATE( weight(NR0) )
IF ( timesplit/='unsplit' ) ALLOCATE( dttry(NR0) )
! index matrices
DO ir = 1,NR0
! for bubble-dynamic variables
! (1,:): nR, (2,:): n\dot{R}, (3,:): np_b, (4,:): nm_v
ibub(1,ir) = ir + Nveul
ibub(2,ir) = ibub(1,ir) + NR0
IF ( polytropic=='n' ) THEN
ibub(3,ir) = ibub(2,ir) + NR0
IF ( vapor=='y' ) THEN
ibub(4,ir) = ibub(3,ir) + NR0
END IF
END IF
! for eigenvectors
ieig(1,ir) = ir + Neig1
ieig(2,ir) = ieig(1,ir) + NR0
IF ( polytropic=='n' ) THEN
ieig(3,ir) = ieig(2,ir) + NR0
IF ( vapor=='y' ) THEN
ieig(4,ir) = ieig(3,ir) + NR0
END IF
END IF
END DO
END SUBROUTINE s_start_inoutvar
!========================================================================
SUBROUTINE s_physprop_poly
REAL(KIND(0.D0)) :: rhol0
REAL(KIND(0.D0)) :: mul0
REAL(KIND(0.D0)) :: ss
REAL(KIND(0.D0)) :: uu
REAL(KIND(0.D0)), DIMENSION(NR0) :: omega_R0
!!! dimensional, physical properties !!!
! liquid at STP
IF ( liquid=='water' ) THEN
n_tait = 7.15D0
B_tait = 304.9D6
rhol0 = 998.2063D0
mul0 = 1.002D-3
ss = 0.07275D0
! vapor
pv = 2.3388D3
ELSE IF ( liquid=='test_liquid' ) THEN
print*, 'test_liquid'
n_tait = 4.4D0
B_tait = 1.d0
rhol0 = 1.D0
mul0 = 0.d0 !no viscosity
ss = 0.d0 !no surface tension !1.25D0
! vapor
pv = 0.D0
ELSE IF ( liquid=='silicone' ) THEN
n_tait = 10.D0
B_tait = 92.4D6
rhol0 = 960.D0
mul0 = 0.048D0
ss = 20.8D-3
! vapor
pv = 0.D0
ELSE IF ( liquid=='glycerol' ) THEN
n_tait = 8.75D0
B_tait = 494.6D6
rhol0 = 1220.D0
mul0 = 0.0802D0
ss = 69.D-3
! vapor
pv = 0.D0
END IF
pl0 = 101325.D0
IF ( nonlin=='y'.AND.ictype=='2' ) pl0 = 114.4D3
IF ( nonlin=='y'.AND.ictype=='3' ) pl0 = 112.9D3
IF ( nonlin=='y'.AND.ictype=='4' ) pl0 = 111.0D3
IF ( xincoming%end=='undex' ) pl0 = 120.9D3 ! at 2m from water surface
IF ( vapor=='n' ) pv = 0.D0
IF ( viscous=='n' ) mul0 = 0.D0
IF ( ictype=='99' ) pl0 = 1.D0
IF ( ictype=='98' ) pl0 = 1.D0
! gas
IF ( gas=='air' ) gamma_b = 1.4D0
IF ( gas=='nitrogen' ) gamma_b = 1.399D0
IF ( gas=='SF6' ) gamma_b = 1.09D0
IF ( thermal=='isotherm' ) gamma_b = 1.D0
! characteristic velocity
uu = DSQRT( pl0/rhol0 )
!!! nondimensional parameters !!!
! initial radius
IF ( NR0==1 ) THEN
! monodisperse
R0(1) = 1.D0
weight(1) = 1.D0
sd = 0.D0
iR1(1) = 1
ELSE
! polydisperse (lognormal distributions)
IF ( nquad=='g' ) THEN
! Gauss-Hermite quadrature
CALL s_gauher( NR0 )
ELSE IF ( nquad=='s' ) THEN
! Simpson's rule
CALL s_simpson( NR0 )
END IF
! find R0 \approx 1
CALL s_find_iR1
END IF
! cavitation, Weber & Reynolds no. based on R0ref
Ca = ( pl0-pv )/( rhol0*uu**2 )
We = rhol0*uu**2*R0ref/ss
Re_inv = mul0/( rhol0*uu*R0ref )
B_tait = B_tait/pl0
!!! normalized vapor & ambient pressure, and sonic speed of liquid !!!
pv = pv/pl0
pl0 = 1.D0
cl0 = DSQRT( n_tait*(pl0+B_tait) )
!!! gussed timestep for timestep splitting !!!
IF ( timesplit/='unsplit' ) THEN
omega_R0 = ( 3.D0*gamma_b*Ca+2.D0*(3.D0*gamma_b-1.D0)/We/R0 )/R0**2
omega_R0 = DSQRT( omega_R0 )
dttry = 1.D-3*( 2.D0*pi/omega_R0 )
END IF
print*, 'Re_inv, We, Ca'
print*, Re_inv, We, Ca
END SUBROUTINE s_physprop_poly
!========================================================================
SUBROUTINE s_physprop_trans
INTEGER :: ir
REAL(KIND(0.D0)) :: rhol0
REAL(KIND(0.D0)) :: mul0
REAL(KIND(0.D0)) :: ss
REAL(KIND(0.D0)) :: uu
REAL(KIND(0.D0)) :: mu_n, mu_v
REAL(KIND(0.D0)) :: D_b
REAL(KIND(0.D0)) :: gamma_n, gamma_v
REAL(KIND(0.D0)) :: temp
REAL(KIND(0.D0)), DIMENSION(NR0) :: chi_vw0
REAL(KIND(0.D0)), DIMENSION(NR0) :: cp_b0
REAL(KIND(0.D0)), DIMENSION(NR0) :: k_b0
REAL(KIND(0.D0)), DIMENSION(NR0) :: rho_b0
REAL(KIND(0.D0)), DIMENSION(NR0) :: x_vw
! polytropic index used to compute isothermal natural frequency
REAL(KIND(0.D0)), PARAMETER :: k_poly = 1.D0
! universal gas constant
REAL(KIND(0.D0)), PARAMETER :: Ru = 8314.D0
!!! dimensional, physical properties !!!
! liquid
IF ( liquid=='water' ) THEN
n_tait = 7.15D0
B_tait = 304.9D6
rhol0 = 998.2063D0
mul0 = 1.002D-3
ss = 0.07275D0
! vapor
pv = 2.3388D3
gamma_v = 1.33D0
M_v = 18.02D0
mu_v = 0.8816D-5
k_v = 0.019426D0
ELSE IF ( liquid=='silicone' ) THEN
n_tait = 10.D0
B_tait = 92.4D6
rhol0 = 960.D0
mul0 = 0.048D0
ss = 20.8D-3
! vapor (irrelevant)
pv = 0.D0
gamma_v = 1.33D0
M_v = 18.02D0
mu_v = 0.8816D-5
k_v = 0.019426D0
ELSE IF ( liquid=='glycerol' ) THEN
n_tait = 8.75D0
B_tait = 494.6D6
rhol0 = 1220.D0
mul0 = 0.0802D0
ss = 69.D-3
! vapor (irrelevant)
pv = 0.D0
gamma_v = 1.33D0
M_v = 18.02D0
mu_v = 0.8816D-5
k_v = 0.019426D0
END IF
pl0 = 101325.D0
IF ( nonlin=='y'.AND.ictype=='2' ) pl0 = 114.4D3
IF ( nonlin=='y'.AND.ictype=='3' ) pl0 = 112.9D3
IF ( nonlin=='y'.AND.ictype=='4' ) pl0 = 111.0D3
IF ( xincoming%end=='undex' ) pl0 = 120.9D3 ! at 2m from water surface
temp = 293.15D0
IF ( nonlin=='y'.AND.ictype=='2' ) temp = 298.15D0
IF ( nonlin=='y'.AND.ictype=='3' ) temp = 298.15D0
IF ( nonlin=='y'.AND.ictype=='4' ) temp = 298.D0
IF ( vapor=='n' ) pv = 0.D0
IF ( viscous=='n' ) mul0 = 0.D0
! gas
IF ( gas=='air' ) THEN
gamma_n = 1.4D0
gamma_b = gamma_n
M_n = 28.97D0
mu_n = 1.8D-5
k_n = 0.02556D0
ELSE IF ( gas=='nitrogen' ) THEN
gamma_n = 1.399D0
gamma_b = gamma_n
M_n = 28.013D0
mu_n = 1.76D-5
k_n = 0.02534D0
ELSE IF ( gas=='SF6' ) THEN
gamma_n = 1.09D0
gamma_b = gamma_n
M_n = 146.06D0
mu_n = 1.76D-5
k_n = 14.D-3
END IF
IF ( thermal=='isotherm' ) gamma_b = 1.D0
! mass diffusion
IF ( gas=='air'.AND.liquid=='water' ) THEN
D_b = 0.242D-4
ELSE
! temporary value
D_b = 0.242D-4
END IF
! characteristic velocity
uu = DSQRT( pl0/rhol0 )
!!! nondimensional parameters !!!
! initial radius
IF ( NR0==1 ) THEN
! monodisperse
R0(1) = 1.D0
weight(1) = 1.D0
sd = 0.D0
iR1(1) = 1
ELSE
! polydisperse (lognormal distributions)
IF ( nquad=='g' ) THEN
! Gauss-Hermite quadrature
CALL s_gauher( NR0 )
ELSE IF ( nquad=='s' ) THEN
! Simpson's rule
CALL s_simpson( NR0 )
END IF
! find R0 \approx 1
CALL s_find_iR1
END IF
! cavitation, Weber & Reynolds no. based on R0ref
Ca = ( pl0-pv )/( rhol0*uu**2 )
We = rhol0*uu**2*R0ref/ss
Re_inv = mul0/( rhol0*uu*R0ref )
B_tait = B_tait/pl0
!!! thermal properties !!!
! gas constants
R_n = Ru/M_n
R_v = Ru/M_v
! phi_vn & phi_nv (phi_nn = phi_vv = 1)
phi_vn = ( 1.D0+DSQRT(mu_v/mu_n)*(M_n/M_v)**(0.25D0) )**2 &
/ ( DSQRT(8.D0)*DSQRT(1.D0+M_v/M_n) )
phi_nv = ( 1.D0+DSQRT(mu_n/mu_v)*(M_v/M_n)**(0.25D0) )**2 &
/ ( DSQRT(8.D0)*DSQRT(1.D0+M_n/M_v) )
! internal bubble pressure
pb0 = pl0 + 2.D0*ss/( R0ref*R0 )
IF ( vapor=='n' ) THEN
! mass fraction of vapor
chi_vw0 = 0.D0
! specific heat for gas
cp_b0 = R_n*gamma_n/( gamma_n-1.D0 )
! mole fraction of vapor
x_vw = 0.D0
! thermal conductivity for gas
k_b0 = k_n
! gas density
rho_b0 = pb0/( R_n*temp )
ELSE
! mass fraction of vapor
chi_vw0 = 1.D0/( 1.D0+R_v/R_n*(pb0/pv-1.D0) )
! specific heat for gas/vapor mixture
cp_b0 = chi_vw0*R_v*gamma_v/( gamma_v-1.D0 ) &
+ ( 1.D0-chi_vw0 )*R_n*gamma_n/( gamma_n-1.D0 )
! mole fraction of vapor
x_vw = M_n*chi_vw0/( M_v+(M_n-M_v)*chi_vw0 )
! thermal conductivity for gas/vapor mixture
k_b0 = x_vw*k_v/( x_vw+(1.D0-x_vw)*phi_vn ) &
+ ( 1.D0-x_vw )*k_n/( x_vw*phi_nv+1.D0-x_vw )
! mixture density
rho_b0 = pv/( chi_vw0*R_v*temp )
END IF
! mass of gas/vapor computed using dimensional quantities
mass_n0 = 4.D0*( pb0-pv )*pi/( 3.D0*R_n*temp*rhol0 )*R0**3
mass_v0 = 4.D0*pv*pi/( 3.D0*R_v*temp*rhol0 )*R0**3
! Peclet numbers
Pe_T = rho_b0*cp_b0*uu*R0ref/k_b0
Pe_c = uu*R0ref/D_b
! nondimensional properties
R_n = rhol0*R_n*temp/pl0
R_v = rhol0*R_v*temp/pl0
k_n = k_n/k_b0
k_v = k_v/k_b0
pb0 = pb0/pl0
pv = pv/pl0
! bubble wall temperature, normalized by T0, in the liquid
! keeps a constant (cold liquid assumption)
Tw = 1.D0
! natural frequencies
omegaN = DSQRT( 3.D0*k_poly*Ca+2.D0*(3.D0*k_poly-1.D0)/(We*R0) )/R0
!!! normalized ambient pressure & sonic speed of liquid !!!
pl0 = 1.D0
cl0 = DSQRT( n_tait*(pl0+B_tait) )
!!! constant transfer coefficients !!!
! use of natural frequency is recommended by Preston (2004).
DO ir = 1,NR0
CALL s_transcoeff( omegaN(ir)*R0(ir),Pe_T(ir)*R0(ir), &
Re_trans_T(ir),Im_trans_T(ir) )
CALL s_transcoeff( omegaN(ir)*R0(ir),Pe_c*R0(ir), &
Re_trans_c(ir),Im_trans_c(ir) )
END DO
IF ( model=='Preston' ) THEN
Im_trans_T = 0.D0
Im_trans_c = 0.D0
END IF
!!! gussed timestep for timestep splitting !!!
IF ( timesplit/='unsplit' ) THEN
dttry = 1.D-3*( 2.D0*pi/omegaN )
END IF
END SUBROUTINE s_physprop_trans
!========================================================================
SUBROUTINE s_transcoeff( omega,peclet,Re_trans,Im_trans )
REAL(KIND(0.D0)), INTENT(IN) :: omega
REAL(KIND(0.D0)), INTENT(IN) :: peclet
REAL(KIND(0.D0)), INTENT(OUT) :: Re_trans
REAL(KIND(0.D0)), INTENT(OUT) :: Im_trans
COMPLEX :: trans, c1, c2, c3
COMPLEX :: imag = ( 0.,1. )
REAL(KIND(0.D0)) :: f_transcoeff
c1 = imag*omega*peclet
c2 = CSQRT( c1 )
c3 = ( CEXP(c2)-CEXP(-c2) )/( CEXP(c2)+CEXP(-c2) ) ! TANH(c2)
trans = ( (c2/c3-1.D0)**(-1)-3.D0/c1 )**( -1 ) ! transfer function
Re_trans = DBLE( trans )
Im_trans = AIMAG( trans )
END SUBROUTINE s_transcoeff
!========================================================================
SUBROUTINE s_gauher( Npt )
REAL(KIND(0.D0)), PARAMETER :: psmall = 3.D-14
REAL(KIND(0.D0)), PARAMETER :: pim4 = 0.7511255444649425D0 ! pi^(-1/4)
INTEGER, PARAMETER :: mxit = 10
INTEGER :: i, j
INTEGER :: its, m
INTEGER, INTENT(IN) :: Npt
REAL(KIND(0.D0)) :: p1, p2, p3, pp
REAL(KIND(0.D0)) :: z, z1
REAL(KIND(0.D0)), DIMENSION(Npt) :: phi_tld
! routine for Gauss-Hermite abscissas and weights (Numerical Recipe)
! Roots are symmetric about the origin, then find only half of them
m = ( Npt+1 )/2
DO i = 1,m
IF ( i==1 ) THEN
z = DSQRT( DBLE(2*Npt+1) ) - 1.85575D0*( DBLE(2*Npt+1) ) &
**( -0.16667D0 )
ELSE IF ( i==2 ) THEN
z = z - 1.14D0*( DBLE(Npt) )**0.426D0/z
ELSE IF ( i==3 ) THEN
z = 1.86D0*z - 0.86D0*phi_tld(1)
ELSE IF ( i==4 ) THEN
z = 1.91D0*z - 0.91D0*phi_tld(2)
ELSE
z = 2.D0*z - phi_tld(i-2)
END IF
its = 1
DO
IF ( its>mxit.OR.DABS(z-z1)<=psmall ) EXIT
p1 = pim4
p2 = 0.D0
DO j = 1,Npt
p3 = p2
p2 = p1
p1 = z*DSQRT( 2.D0/DBLE(j) )*p2 &
- DSQRT( DBLE(j-1)/DBLE(j) )*p3
END DO
pp = DSQRT( 2.D0*DBLE(Npt) )*p2
z1 = z
z = z1 - p1/pp
its = its + 1
END DO
! assign the root
phi_tld(i) = z
phi_tld(Npt+1-i) = -z
! assign the weight
weight(i) = 2.D0/( pp*pp )
weight(Npt+1-i) = weight(i)
END DO
! normalize the weights
weight = weight/DSQRT( pi )
! transform phi_tld into R0, R0(1) = R0mx, R0(Npt) = R0mn
R0 = DEXP( DSQRT(2.D0)*sd*phi_tld )
! sorting R0 s.t. R0(1) = R0mn, R0(Npt) = R0mx
! phi_tld is dummy
DO i = 1,Npt
phi_tld(Npt+1-i) = R0(i)
END DO
R0 = phi_tld
END SUBROUTINE s_gauher
!========================================================================
SUBROUTINE s_simpson( Npt )
INTEGER, INTENT(IN) :: Npt
INTEGER :: ir
REAL(KIND(0.D0)) :: R0mn
REAL(KIND(0.D0)) :: R0mx
REAL(KIND(0.D0)) :: dphi
REAL(KIND(0.D0)) :: tmp
REAL(KIND(0.D0)), DIMENSION(Npt) :: phi
! nondiml. min. & max. initial radii for numerical quadrature
IF ( sd==0.05D0 ) THEN
R0mn = 0.75D0
R0mx = 1.3D0
ELSE IF ( sd==0.1D0 ) THEN
R0mn = 0.6D0
R0mx = 1.7D0
ELSE IF ( sd==0.2D0 ) THEN
R0mn = 0.4D0
R0mx = 3.D0
ELSE IF ( sd==0.3D0 ) THEN
R0mn = 0.3D0
R0mx = 6.D0
ELSE IF ( sd==0.5D0 ) THEN
! R0mn = 0.17D0
R0mn = 0.15D0
R0mx = 25.D0
ELSE IF ( sd==0.7D0 ) THEN
R0mn = 0.1D0
R0mx = 200.D0
! R0mn = 0.16D0
! R0mx = 25.D0
! R0mn = 0.12D0
! R0mx = 150.D0
! IF ( nonlin=='y'.AND.ictype=='7' ) THEN
! R0mn = 0.5D0
! R0mx = 50.D0
! ELSE
! R0mn = 0.1D0
! R0mx = 200.D0
! R0mn = 0.12D0
! R0mx = 150.D0
! END IF
END IF
! phi = ln( R0 ) & return R0
DO ir = 1,Npt
phi(ir) = DLOG( R0mn ) &
+ DBLE( ir-1 )*DLOG( R0mx/R0mn )/DBLE( Npt-1 )
R0(ir) = DEXP( phi(ir) )
END DO
dphi = phi(2) - phi(1)
! weights for quadrature using Simpson's rule
DO ir = 2,Npt-1
! Gaussian
tmp = DEXP( -0.5D0*(phi(ir)/sd)**2 )/DSQRT( 2.D0*pi )/sd
IF ( MOD(ir,2)==0 ) THEN
weight(ir) = tmp*4.D0*dphi/3.D0
ELSE
weight(ir) = tmp*2.D0*dphi/3.D0
END IF
END DO
tmp = DEXP( -0.5D0*(phi(1)/sd)**2 )/DSQRT( 2.D0*pi )/sd
weight(1) = tmp*dphi/3.D0
tmp = DEXP( -0.5D0*(phi(Npt)/sd)**2 )/DSQRT( 2.D0*pi )/sd
weight(Npt) = tmp*dphi/3.D0
END SUBROUTINE s_simpson
!========================================================================
SUBROUTINE s_find_iR1
INTEGER :: ir
INTEGER :: iout
REAL(KIND(0.D0)) :: tmp
REAL(KIND(0.D0)) :: tmpmin
REAL(KIND(0.D0)) :: R0tmp
IF ( sd==0.7D0 ) THEN
DO iout = 1,NR0out
tmpmin = 1.D9
IF ( iout==1 ) R0tmp = 0.25D0
IF ( iout==2 ) R0tmp = 0.5D0
! IF ( iout==1 ) R0tmp = 0.5D0
! IF ( iout==2 ) R0tmp = 0.75D0
IF ( iout==3 ) R0tmp = 1.D0
IF ( iout==4 ) R0tmp = 2.D0
IF ( iout==5 ) R0tmp = 4.D0
! find the closest point
DO ir = 1,NR0
tmp = DABS( R0(ir)-R0tmp )
IF ( tmp<tmpmin ) THEN
tmpmin = tmp
iR1(iout) = ir
END IF
END DO
END DO
ELSE
tmpmin = 1.D9
R0tmp = 1.D0
DO ir = 1,NR0
tmp = DABS( R0(ir)-R0tmp )
IF ( tmp<tmpmin ) THEN
tmpmin = tmp
iR1(1) = ir
END IF
END DO
END IF
END SUBROUTINE s_find_iR1
!========================================================================
SUBROUTINE s_newequilibrium( plnew_tmp,Rnew,pbnew,mvnew )
! compute new equliribrium states corresponding to plnew
! The new state is achieved in an isothermal process.
! subscripts "i" denote initial conditions (0) associated with pl0
REAL(KIND(0.D0)), INTENT(IN) :: plnew_tmp
REAL(KIND(0.D0)), INTENT(OUT) :: Rnew
REAL(KIND(0.D0)), INTENT(OUT) :: pbnew
REAL(KIND(0.D0)), INTENT(OUT) :: mvnew
REAL(KIND(0.D0)), PARAMETER :: acc = 1.D-8
REAL(KIND(0.D0)), PARAMETER :: Rmn = 1.D-30
REAL(KIND(0.D0)) :: Rmx
! find Rnew using Newton-Raphson
plnew = plnew_tmp
IF ( plnew>= pl0 ) THEN
Rmx = R0(iR0) + acc
ELSE
Rmx = R0(iR0)*1.D6
END IF
Rnew = f_rtsafe( Rmn,Rmx,acc )
! new internal bubble pressure
pbnew = plnew + 2.D0/We/Rnew
! new mass of vapor
mvnew = 4.D0*pv*pi/( 3.D0*R_v )*Rnew**3
END SUBROUTINE s_newequilibrium
!========================================================================
SUBROUTINE s_funcd( x,y,dydx )
REAL(KIND(0.D0)), INTENT(IN) :: x
REAL(KIND(0.D0)), INTENT(OUT) :: y
REAL(KIND(0.D0)), INTENT(OUT) :: dydx
REAL(KIND(0.D0)) :: pni
REAL(KIND(0.D0)) :: power
! initial partial pressure for non-condensible gas
IF ( polytropic=='n' ) pni = pb0(iR0) - pv
IF ( polytropic=='y' ) pni = Ca + 2.D0/We/R0(iR0)
! returns both the function value and the first derivative
IF ( thermal=='adiabat' ) THEN
power = 3.D0*gamma_b
y = pni*( R0(iR0)/x )**power - 2.D0/We/x + pv - plnew
dydx = 2.D0/We/x**2 - power*pni*R0(iR0)**power/x**( power+1 )
ELSE ! isothermal
y = pni*( R0(iR0)/x )**3 - 2.D0/We/x + pv - plnew
dydx = 2.D0/We/x**2 - 3.D0*pni*R0(iR0)**3/x**4
END IF
END SUBROUTINE s_funcd
!========================================================================
FUNCTION f_rtsafe( x1,x2,xacc )
REAL(KIND(0.D0)), INTENT(IN) :: x1
REAL(KIND(0.D0)), INTENT(IN) :: x2
REAL(KIND(0.D0)), INTENT(IN) :: xacc
REAL(KIND(0.D0)) :: f_rtsafe ! return the root