-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrheology.f
executable file
·1015 lines (892 loc) · 40.6 KB
/
rheology.f
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
! Part of Dflow3d a 3D Navier Stokes solver with variable density for
! simulations of near field dredge plume mixing
! Copyright (C) 2012 Lynyrd de Wit
! This program is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
subroutine Kinetic_equation(ib,ie,jb,je,kb,ke)
USE nlist
implicit none
!include 'mpif.h'
integer ib,ie,jb,je,kb,ke
integer*8 kbed_dummy(0:i1,0:j1)
real lambda_advec(0:i1,0:j1,0:k1)
lambda_advec(:,:,:)=0.
kbed_dummy(:,:)=0
call advecc_VLE(lambda_advec(:,:,:),lambda_old(:,:,:),Unew,Vnew,Wnew,rnew,Ru,Rp,dr,phiv,phipt,dz,
+ i1,j1,k1,ib,ie,jb,je,kb,ke,dt,rank,px,periodicx,periodicy,'volufrac',kbed_dummy) !advection of lambda
do i=1,imax
do j=1,jmax
do k=1,kmax
lambda_new(i,j,k)=(lambda_old(i,j,k)+dt*(Kin_eq_a*Kin_eq_lambda_0+(lambda_advec(i,j,k))))/
& (1.+dt*(Kin_eq_a+Kin_eq_b*strain(i,j,k)))
enddo
enddo
enddo
call bound_3D(lambda_new) !Neumann B.C.
end subroutine Kinetic_equation
subroutine Houska_Papanastasiou(ib,ie,jb,je,kb,ke)
USE nlist
implicit none
!include 'mpif.h'
integer ib,ie,jb,je,kb,ke
call strain_magnitude(Unew,Vnew,Wnew)
call Kinetic_equation(ib,ie,jb,je,kb,ke)
do i=1,imax !start loop, in r-direction
do j=1,jmax !start loop, in phi-direction
do k=1,kmax !start loop, in z-direction
muA(i,j,k)= ((HOUSKA_tauy_inf+lambda_old(i,j,k)*(HOUSKA_tauy_0-HOUSKA_tauy_inf))/(1.e-12+strain(i,j,k)))*
& (1.-exp(-PAPANASTASIOUS_m*(1.e-12+strain(i,j,k))))+
& (HOUSKA_eta_inf+(lambda_old(i,j,k)*(HOUSKA_eta_0-HOUSKA_eta_inf)))*(strain(i,j,k)**(HOUSKA_n-1.))
ekm(i,j,k)= ekm(i,j,k) + muA(i,j,k)
enddo
enddo
enddo
lambda_old(:,:,:)=lambda_new(:,:,:)
end subroutine Houska_Papanastasiou
subroutine strain_magnitude(Uvel,Vvel,Wvel)
USE nlist
implicit none
!include 'mpif.h'
real dzi
real dRpp_i,dRp_i
real Uvel(0:i1,0:j1,0:k1),Vvel(0:i1,0:j1,0:k1),Wvel(0:i1,0:j1,0:k1)
real Uvel2(0:i1,0:j1,0:k1),Vvel2(0:i1,0:j1,0:k1),Wvel2(0:i1,0:j1,0:k1)
real dudx,dudy,dudz,strain2(0:i1,0:j1,0:k1)
real dvdx,dvdy,dvdz
real dwdx,dwdy,dwdz
real S11,S12,S13,S22,S23,S33,SijSij,shear,divergentie
integer n,im,ip,jm,jp,km,kp
SijSij=0.
IF (rheo_shear_method.eq.2) THEN !determine shear on rho*U and divide by rho at the end
Uvel = Uvel * rhU !before bound_rhoU so rhU belongs to Unew
Vvel = Vvel * rhV !before bound_rhoU so rhU belongs to Unew
Wvel = Wvel * rhW !before bound_rhoU so rhU belongs to Unew
dzi=1./dz
do i=1,imax
dRpp_i=1./(Rp(i+1)-Rp(i))
dRp_i=1./(Rp(i)-Rp(i-1))
do j=1,jmax
do k=1,kmax
shear = 2.0*(
1 ((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i))*((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i)) +
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i))*
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1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
1 ((Vvel(i ,j ,k+1)-Vvel(i ,j ,k ))*dzi +
2 ( Wvel(i ,j+1,k )-Wvel(i ,j ,k ))/(Rp(i)*(phip(j+1)-phip(j))) )**2 +
1 ((Vvel(i ,j ,k )-Vvel(i ,j ,k-1))*dzi +
2 ( Wvel(i ,j+1,k-1)-Wvel(i ,j ,k-1))/(Rp(i)*(phip(j+1)-phip(j))) )**2 +
1 ((Vvel(i ,j-1,k+1)-Vvel(i ,j-1,k ))*dzi +
2 ( Wvel(i ,j ,k )-Wvel(i ,j-1,k ))/(Rp(i)*(phip(j)-phip(j-1))) )**2 +
1 ((Vvel(i ,j-1,k )-Vvel(i ,j-1,k-1))*dzi +
2 ( Wvel(i ,j ,k-1)-Wvel(i ,j-1,k-1))/(Rp(i)*(phip(j)-phip(j-1))) )**2
e )
!!
divergentie= 2./3.*(( Ru(i)*Uvel(i,j,k) - Ru(i-1)*Uvel(i-1,j,k) ) / ( Rp(i)*dr(i) )
+ +
2 ( Vvel(i,j,k) - Vvel(i,j-1,k) ) / ( Rp(i)*(phiv(j)-phiv(j-1)) )
+ +
3 ( Wvel(i,j,k) - Wvel(i,j,k-1) ) / ( dz ))
shear = shear
+ +1.5*divergentie*divergentie
+ -divergentie*2.*((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i))
+ -divergentie*2.*((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1)))+0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i))
+ -divergentie*2.*((Wvel(i,j,k)-Wvel(i,j,k-1))*dzi)
strain(i,j,k) = Apvisc_shear_relax*sqrt(shear)/rnew(i,j,k) + (1.-Apvisc_shear_relax)*strain(i,j,k)
enddo
enddo
enddo
Uvel = Uvel / rhU !before bound_rhoU so rhU belongs to Unew
Vvel = Vvel / rhV !before bound_rhoU so rhU belongs to Unew
Wvel = Wvel / rhW !before bound_rhoU so rhU belongs to Unew
ELSEIF (rheo_shear_method.eq.3) THEN ! determine shear with horizontal velocity components only
dzi=1./dz
do i=1,imax
dRpp_i=1./(Rp(i+1)-Rp(i))
dRp_i=1./(Rp(i)-Rp(i-1))
do j=1,jmax
do k=1,kmax
shear = 2.0*(
1 ((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i))*((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i)) +
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i))*
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i)))
shear = shear + 0.25*(
1 ((Uvel(i ,j+1,k )-Uvel(i ,j ,k ))/(Ru(i)*(phip(j+1)-phip(j))) +
2 ( Vvel(i+1,j ,k )/Rp(i+1)-Vvel(i ,j ,k )/Rp(i))*dRpp_i*Ru(i) )**2 +
1 ((Uvel(i ,j ,k )-Uvel(i ,j-1,k ))/(Ru(i)*(phip(j)-phip(j-1))) +
2 ( Vvel(i+1,j-1,k )/Rp(i+1)-Vvel(i ,j-1,k )/Rp(i))*dRpp_i*Ru(i) )**2 +
1 ((Uvel(i-1,j+1,k )-Uvel(i-1,j ,k ))/(Ru(i-1)*(phip(j+1)-phip(j))) +
2 ( Vvel(i ,j ,k )/Rp(i)-Vvel(i-1,j ,k )/Rp(i-1))*dRp_i*Ru(i-1) )**2 +
1 ((Uvel(i-1,j ,k )-Uvel(i-1,j-1,k ))/(Ru(i-1)*(phip(j)-phip(j-1))) +
2 ( Vvel(i ,j-1,k )/Rp(i)-Vvel(i-1,j-1,k )/Rp(i-1))*dRp_i*Ru(i-1) )**2
e )
strain(i,j,k) = Apvisc_shear_relax*sqrt(shear) + (1.-Apvisc_shear_relax)*strain(i,j,k)
enddo
enddo
enddo
ELSEIF (rheo_shear_method.eq.4) THEN ! determine shear with horizontal velocity components only and including rho*U
Uvel = Uvel * rhU !before bound_rhoU so rhU belongs to Unew
Vvel = Vvel * rhV !before bound_rhoU so rhU belongs to Unew
! Wvel = Wvel * rhW !before bound_rhoU so rhU belongs to Unew
dzi=1./dz
do i=1,imax
dRpp_i=1./(Rp(i+1)-Rp(i))
dRp_i=1./(Rp(i)-Rp(i-1))
do j=1,jmax
do k=1,kmax
shear = 2.0*(
1 ((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i))*((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i)) +
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i))*
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i)))
shear = shear + 0.25*(
1 ((Uvel(i ,j+1,k )-Uvel(i ,j ,k ))/(Ru(i)*(phip(j+1)-phip(j))) +
2 ( Vvel(i+1,j ,k )/Rp(i+1)-Vvel(i ,j ,k )/Rp(i))*dRpp_i*Ru(i) )**2 +
1 ((Uvel(i ,j ,k )-Uvel(i ,j-1,k ))/(Ru(i)*(phip(j)-phip(j-1))) +
2 ( Vvel(i+1,j-1,k )/Rp(i+1)-Vvel(i ,j-1,k )/Rp(i))*dRpp_i*Ru(i) )**2 +
1 ((Uvel(i-1,j+1,k )-Uvel(i-1,j ,k ))/(Ru(i-1)*(phip(j+1)-phip(j))) +
2 ( Vvel(i ,j ,k )/Rp(i)-Vvel(i-1,j ,k )/Rp(i-1))*dRp_i*Ru(i-1) )**2 +
1 ((Uvel(i-1,j ,k )-Uvel(i-1,j-1,k ))/(Ru(i-1)*(phip(j)-phip(j-1))) +
2 ( Vvel(i ,j-1,k )/Rp(i)-Vvel(i-1,j-1,k )/Rp(i-1))*dRp_i*Ru(i-1) )**2
e )
strain(i,j,k) = Apvisc_shear_relax*sqrt(shear)/rnew(i,j,k) + (1.-Apvisc_shear_relax)*strain(i,j,k)
enddo
enddo
enddo
Uvel = Uvel / rhU !before bound_rhoU so rhU belongs to Unew
Vvel = Vvel / rhV !before bound_rhoU so rhU belongs to Unew
! Wvel = Wvel / rhW !before bound_rhoU so rhU belongs to Unew
ELSEIF (rheo_shear_method.eq.5) THEN !determine shear on only dudx dvdy dwdz
dzi=1./dz
do i=1,imax
dRpp_i=1./(Rp(i+1)-Rp(i))
dRp_i=1./(Rp(i)-Rp(i-1))
do j=1,jmax
do k=1,kmax
shear = 2.0*(
1 ((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i))*((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i)) +
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i))*
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i)) +
1 ((Wvel(i,j,k)-Wvel(i,j,k-1))*dzi)*((Wvel(i,j,k)-Wvel(i,j,k-1))*dzi) )
strain(i,j,k) = Apvisc_shear_relax*sqrt(shear) + (1.-Apvisc_shear_relax)*strain(i,j,k)
enddo
enddo
enddo
ELSEIF (rheo_shear_method.eq.6) THEN !determine shear on rho*U and divide by rho at the end + only dudx dvdy dwdz
Uvel = Uvel * rhU !before bound_rhoU so rhU belongs to Unew
Vvel = Vvel * rhV !before bound_rhoU so rhU belongs to Unew
Wvel = Wvel * rhW !before bound_rhoU so rhU belongs to Unew
dzi=1./dz
do i=1,imax
dRpp_i=1./(Rp(i+1)-Rp(i))
dRp_i=1./(Rp(i)-Rp(i-1))
do j=1,jmax
do k=1,kmax
shear = 2.0*(
1 ((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i))*((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i)) +
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i))*
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i)) +
1 ((Wvel(i,j,k)-Wvel(i,j,k-1))*dzi)*((Wvel(i,j,k)-Wvel(i,j,k-1))*dzi) )
strain(i,j,k) = Apvisc_shear_relax*sqrt(shear)/rnew(i,j,k) + (1.-Apvisc_shear_relax)*strain(i,j,k)
enddo
enddo
enddo
Uvel = Uvel / rhU !before bound_rhoU so rhU belongs to Unew
Vvel = Vvel / rhV !before bound_rhoU so rhU belongs to Unew
Wvel = Wvel / rhW !before bound_rhoU so rhU belongs to Unew
ELSEIF (rheo_shear_method.eq.7) THEN !determine shear on only dudx dvdy
dzi=1./dz
do i=1,imax
dRpp_i=1./(Rp(i+1)-Rp(i))
dRp_i=1./(Rp(i)-Rp(i-1))
do j=1,jmax
do k=1,kmax
shear = 2.0*(
1 ((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i))*((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i)) +
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i))*
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i)))
strain(i,j,k) = Apvisc_shear_relax*sqrt(shear) + (1.-Apvisc_shear_relax)*strain(i,j,k)
enddo
enddo
enddo
ELSEIF (rheo_shear_method.eq.8) THEN !determine shear on rho*U and divide by rho at the end + only dudx dvdy dwdz
Uvel = Uvel * rhU !before bound_rhoU so rhU belongs to Unew
Vvel = Vvel * rhV !before bound_rhoU so rhU belongs to Unew
dzi=1./dz
do i=1,imax
dRpp_i=1./(Rp(i+1)-Rp(i))
dRp_i=1./(Rp(i)-Rp(i-1))
do j=1,jmax
do k=1,kmax
shear = 2.0*(
1 ((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i))*((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i)) +
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i))*
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i)))
strain(i,j,k) = Apvisc_shear_relax*sqrt(shear)/rnew(i,j,k) + (1.-Apvisc_shear_relax)*strain(i,j,k)
enddo
enddo
enddo
Uvel = Uvel / rhU !before bound_rhoU so rhU belongs to Unew
Vvel = Vvel / rhV !before bound_rhoU so rhU belongs to Unew
ELSEIF (rheo_shear_method.eq.12) THEN !determine shear on Ctot*U and divide by Ctot at the end
Uvel2 = Uvel * SUM(cU(1:nfrac,:,:,:),DIM=1) !before bound_rhoU so cU belongs to Unew
Vvel2 = Vvel * SUM(cV(1:nfrac,:,:,:),DIM=1) !before bound_rhoU so cU belongs to Unew
Wvel2 = Wvel * SUM(cW(1:nfrac,:,:,:),DIM=1) !before bound_rhoU so cU belongs to Unew
dzi=1./dz
do i=1,imax
dRpp_i=1./(Rp(i+1)-Rp(i))
dRp_i=1./(Rp(i)-Rp(i-1))
do j=1,jmax
do k=1,kmax
shear = 2.0*(
1 ((Uvel2(i,j,k)-Uvel2(i-1,j,k))/dr(i))*((Uvel2(i,j,k)-Uvel2(i-1,j,k))/dr(i)) +
1 ((Vvel2(i,j,k)-Vvel2(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel2(i,j,k)+Uvel2(i-1,j,k))/Rp(i))*
1 ((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k )-Uvel2(i-1,j ,k-1))*dzi +
2 ( Wvel2(i ,j ,k-1)-Wvel2(i-1,j ,k-1))*dRp_i)**2
e )
shear = shear + 0.25*(
1 ((Vvel2(i ,j ,k+1)-Vvel2(i ,j ,k ))*dzi +
2 ( Wvel2(i ,j+1,k )-Wvel2(i ,j ,k ))/(Rp(i)*(phip(j+1)-phip(j))) )**2 +
1 ((Vvel2(i ,j ,k )-Vvel2(i ,j ,k-1))*dzi +
2 ( Wvel2(i ,j+1,k-1)-Wvel2(i ,j ,k-1))/(Rp(i)*(phip(j+1)-phip(j))) )**2 +
1 ((Vvel2(i ,j-1,k+1)-Vvel2(i ,j-1,k ))*dzi +
2 ( Wvel2(i ,j ,k )-Wvel2(i ,j-1,k ))/(Rp(i)*(phip(j)-phip(j-1))) )**2 +
1 ((Vvel2(i ,j-1,k )-Vvel2(i ,j-1,k-1))*dzi +
2 ( Wvel2(i ,j ,k-1)-Wvel2(i ,j-1,k-1))/(Rp(i)*(phip(j)-phip(j-1))) )**2
e )
!!
divergentie= 2./3.*(( Ru(i)*Uvel2(i,j,k) - Ru(i-1)*Uvel2(i-1,j,k) ) / ( Rp(i)*dr(i) )
+ +
2 ( Vvel2(i,j,k) - Vvel2(i,j-1,k) ) / ( Rp(i)*(phiv(j)-phiv(j-1)) )
+ +
3 ( Wvel2(i,j,k) - Wvel2(i,j,k-1) ) / ( dz ))
shear = shear
+ +1.5*divergentie*divergentie
+ -divergentie*2.*((Uvel2(i,j,k)-Uvel2(i-1,j,k))/dr(i))
+ -divergentie*2.*((Vvel2(i,j,k)-Vvel2(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1)))+0.5*(Uvel2(i,j,k)+Uvel2(i-1,j,k))/Rp(i))
+ -divergentie*2.*((Wvel2(i,j,k)-Wvel2(i,j,k-1))*dzi)
strain(i,j,k) = Apvisc_shear_relax*sqrt(shear)/(SUM(cnew(1:nfrac,i,j,k))+1.e-12) + (1.-Apvisc_shear_relax)*strain(i,j,k)
enddo
enddo
enddo
ELSE
dzi=1./dz
do i=1,imax
dRpp_i=1./(Rp(i+1)-Rp(i))
dRp_i=1./(Rp(i)-Rp(i-1))
do j=1,jmax
do k=1,kmax
! dudx = (Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i) !du/dx
! dvdy = (Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i) !dv/dy
! dwdz = (Wvel(i,j,k)-Wvel(i,j,k-1))*dzi !dw/dz
!
! dudy = ((Uvel(i ,j+1,k )-Uvel(i ,j ,k ))/(Ru(i)*(phip(j+1)-phip(j))) +
! & (Uvel(i ,j ,k )-Uvel(i ,j-1,k ))/(Ru(i)*(phip(j)-phip(j-1))) +
! & (Uvel(i-1,j+1,k )-Uvel(i-1,j ,k ))/(Ru(i-1)*(phip(j+1)-phip(j))) +
! & (Uvel(i-1,j ,k )-Uvel(i-1,j-1,k ))/(Ru(i-1)*(phip(j)-phip(j-1))) ) * 0.25
! dudz = ((Uvel(i ,j ,k+1)-Uvel(i ,j ,k ))*dzi +
! & (Uvel(i ,j ,k )-Uvel(i ,j ,k-1))*dzi +
! & (Uvel(i-1,j ,k+1)-Uvel(i-1,j ,k ))*dzi +
! & (Uvel(i-1,j ,k )-Uvel(i-1,j ,k-1))*dzi ) * 0.25
! dvdx = ((Vvel(i+1,j ,k )/Rp(i+1)-Vvel(i ,j ,k )/Rp(i))*dRpp_i*Ru(i) +
! & (Vvel(i+1,j-1,k )/Rp(i+1)-Vvel(i ,j-1,k )/Rp(i))*dRpp_i*Ru(i) +
! & (Vvel(i ,j ,k )/Rp(i)-Vvel(i-1,j ,k )/Rp(i-1))*dRp_i*Ru(i-1) +
! & (Vvel(i ,j-1,k )/Rp(i)-Vvel(i-1,j-1,k )/Rp(i-1))*dRp_i*Ru(i-1) ) * 0.25
! dvdz = ((Vvel(i ,j ,k+1)-Vvel(i ,j ,k ))*dzi +
! & (Vvel(i ,j ,k )-Vvel(i ,j ,k-1))*dzi +
! & (Vvel(i ,j-1,k+1)-Vvel(i ,j-1,k ))*dzi +
! & (Vvel(i ,j-1,k )-Vvel(i ,j-1,k-1))*dzi ) * 0.25
! dwdx = ((Wvel(i+1,j ,k )-Wvel(i ,j ,k ))*dRpp_i +
! & (Wvel(i+1,j ,k-1)-Wvel(i ,j ,k-1))*dRpp_i +
! & (Wvel(i ,j ,k )-Wvel(i-1,j ,k ))*dRp_i +
! & (Wvel(i ,j ,k-1)-Wvel(i-1,j ,k-1))*dRp_i ) * 0.25
! dwdy = ((Wvel(i ,j+1,k )-Wvel(i ,j ,k ))/(Rp(i)*(phip(j+1)-phip(j))) +
! & (Wvel(i ,j+1,k-1)-Wvel(i ,j ,k-1))/(Rp(i)*(phip(j+1)-phip(j))) +
! & (Wvel(i ,j ,k )-Wvel(i ,j-1,k ))/(Rp(i)*(phip(j)-phip(j-1))) +
! & (Wvel(i ,j ,k-1)-Wvel(i ,j-1,k-1))/(Rp(i)*(phip(j)-phip(j-1))) ) * 0.25
!
! S11 = dudx !strainrate tensor elements
! S22 = dvdy
! S33 = dwdz
! S12 = 0.5*(dvdx+dudy)
! S13 = 0.5*(dudz+dwdx)
! S23 = 0.5*(dvdz+dwdy)
! SijSij = S11*S11 + S22*S22 + S33*S33 + 2.*S12*S12 + 2.*S13*S13 + 2.*S23*S23
! strain(i,j,k)=sqrt(2*SijSij)
shear = 2.0*(
1 ((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i))*((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i)) +
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i))*
1 ((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1))) + 0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i)) +
1 ((Wv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,j+1,k )-Wvel(i ,j ,k ))/(Rp(i)*(phip(j+1)-phip(j))) )**2 +
1 ((Vvel(i ,j ,k )-Vvel(i ,j ,k-1))*dzi +
2 ( Wvel(i ,j+1,k-1)-Wvel(i ,j ,k-1))/(Rp(i)*(phip(j+1)-phip(j))) )**2 +
1 ((Vvel(i ,j-1,k+1)-Vvel(i ,j-1,k ))*dzi +
2 ( Wvel(i ,j ,k )-Wvel(i ,j-1,k ))/(Rp(i)*(phip(j)-phip(j-1))) )**2 +
1 ((Vvel(i ,j-1,k )-Vvel(i ,j-1,k-1))*dzi +
2 ( Wvel(i ,j ,k-1)-Wvel(i ,j-1,k-1))/(Rp(i)*(phip(j)-phip(j-1))) )**2
e )
!!
divergentie= 2./3.*(( Ru(i)*Uvel(i,j,k) - Ru(i-1)*Uvel(i-1,j,k) ) / ( Rp(i)*dr(i) )
+ +
2 ( Vvel(i,j,k) - Vvel(i,j-1,k) ) / ( Rp(i)*(phiv(j)-phiv(j-1)) )
+ +
3 ( Wvel(i,j,k) - Wvel(i,j,k-1) ) / ( dz ))
shear = shear
+ +1.5*divergentie*divergentie
+ -divergentie*2.*((Uvel(i,j,k)-Uvel(i-1,j,k))/dr(i))
+ -divergentie*2.*((Vvel(i,j,k)-Vvel(i,j-1,k))/(Rp(i)*(phiv(j)-phiv(j-1)))+0.5*(Uvel(i,j,k)+Uvel(i-1,j,k))/Rp(i))
+ -divergentie*2.*((Wvel(i,j,k)-Wvel(i,j,k-1))*dzi)
strain(i,j,k) = Apvisc_shear_relax*sqrt(shear) + (1.-Apvisc_shear_relax)*strain(i,j,k)
enddo
enddo
enddo
ENDIF
IF (rheo_shear_method.eq.21) THEN ! re-use rheo_shear_method also for other possibility in determination shear
strain2=strain
call bound_3D(strain2)
do i=1,imax
do j=1,jmax
do k=1,kmax
im=i-1
ip=i+1
jm=j-1
jp=j+1
km=k-1
kp=k+1
strain(i,j,k) = MIN(strain2(i,j,k),strain2(im,j,k),strain2(ip,j,k),strain2(i,jm,k),strain2(i,jp,k),
& strain2(i,j,km),strain2(i,j,kp))
enddo
enddo
enddo
ELSEIF (rheo_shear_method.eq.31) THEN
do i=1,imax
do j=1,jmax
do k=1,kmax
IF (SUM(cnew(1:nfrac,i,j,k))<1.e-6) THEN
strain(i,j,k)=0. !forces strain to 0 for cells outside patch of rheology material
ENDIF
enddo
enddo
enddo
ENDIF
!! IF (Apvisc_interp.eq.3.or.Apvisc_interp.eq.4) THEN ! apply high muA at edges patch for staggered arrangement:
!! strain2=strain
!! call bound_3D(strain2)
!! do i=1,imax
!! do j=1,jmax
!! do k=1,kmax
!! im=i-1
!! ip=i+1
!! jm=j-1
!! jp=j+1
!! km=k-1
!! kp=k+1
!! strain(i,j,k) = MIN(
!! & strain2(i,j,k),strain2(i,jm,k),strain2(i,jp,k),strain2(i,j,km),strain2(i,j,kp),
!! & strain2(i,jm,km),strain2(i,jp,km),strain2(i,jm,kp),strain2(i,jp,kp),
!! & strain2(im,j,k),strain2(im,jm,k),strain2(im,jp,k),strain2(im,j,km),strain2(im,j,kp),
!! & strain2(im,jm,km),strain2(im,jp,km),strain2(im,jm,kp),strain2(im,jp,kp),
!! & strain2(ip,j,k),strain2(ip,jm,k),strain2(ip,jp,k),strain2(ip,j,km),strain2(ip,j,kp),
!! & strain2(ip,jm,km),strain2(ip,jp,km),strain2(ip,jm,kp),strain2(ip,jp,kp))
!! enddo
!! enddo
!! enddo
!! ENDIF
end subroutine strain_magnitude
subroutine stress_magnitude
USE nlist
implicit none
!include 'mpif.h'
do i=1,imax
do j=1,jmax
do k=1,kmax
stress(i,j,k)=muA(i,j,k)*strain(i,j,k)
enddo
enddo
enddo
end subroutine stress_magnitude
subroutine Simple_Bingham
USE nlist
implicit none
!include 'mpif.h'
integer n
IF (MAXVAL(SIMPLE_climit)>1.e-12) THEN
muB=0.
tauY=0.
do n=1,nfrac
do i=1,imax
do j=1,jmax
do k=1,kmax
IF (Cnew(n,i,j,k)>SIMPLE_climit(n)) THEN
muB(i,j,k) = SIMPLE_muB
tauY(i,j,k) = SIMPLE_tauy
ENDIF
enddo
enddo
enddo
enddo
ELSE
muB(1:imax,1:jmax,1:kmax) = SIMPLE_muB
tauY(1:imax,1:jmax,1:kmax) = SIMPLE_tauy
ENDIF
end subroutine Simple_Bingham
subroutine Rheo_Jacobs_and_vKesteren
USE nlist
implicit none
!include 'mpif.h'
real phi_clay(0:i1,0:j1,0:k1),phi_silt(0:i1,0:j1,0:k1),phi_sand(0:i1,0:j1,0:k1)
real phi_solids(0:i1,0:j1,0:k1),phi_fines(0:i1,0:j1,0:k1)
real sol_frac(0:i1,0:j1,0:k1),W_rel(0:i1,0:j1,0:k1)
real lambda_b(0:i1,0:j1,0:k1),sol_eff(0:i1,0:j1,0:k1)
integer n
real rho_sed !temporary
rho_sed=2650.
phi_clay(:,:,:)=0.
phi_silt(:,:,:)=0.
phi_sand(:,:,:)=0.
phi_solids(:,:,:)=0.
phi_fines(:,:,:)=0.
do i=1,imax
do j=1,jmax
do k=1,kmax
do n=1,nfrac
if (frac(n)%dpart.le.2) then !check for clay fractions
phi_clay(i,j,k)= phi_clay(i,j,k) + cnew(n,i,j,k)
elseif (frac(n)%dpart.gt.2.and.frac(n)%dpart.le.63) then !check for silt fractions
phi_silt(i,j,k)= phi_silt(i,j,k) + cnew(n,i,j,k)
else
phi_sand(i,j,k)= phi_sand(i,j,k) + cnew(n,i,j,k)
endif
enddo
phi_fines(i,j,k)=phi_clay(i,j,k)+phi_silt(i,j,k)
phi_solids(i,j,k)=phi_fines(i,j,k)+phi_sand(i,j,k)
lambda_b(i,j,k)=1./(((BAGNOLD_phi_max/(1.e-12+phi_sand(i,j,k)))**(1./3.))-1.) !linear sand concentration Bagnold 1956
sol_eff(i,j,k)=exp(BAGNOLD_beta*lambda_b(i,j,k)) !exponential term expressing influens of sand and silt
W_rel(i,j,k)=(rho_b/(JACOBS_Aclay*rho_sed))*((1.-phi_solids(i,j,k))/(1.e-12+phi_fines(i,j,k))) !relative water content
tauY(i,j,k)=sol_eff(i,j,k)*JACOBS_Ky*(W_rel(i,j,k)**JACOBS_By)
muB(i,j,k)=sol_eff(i,j,k)*(JACOBS_muw+JACOBS_Kmu*(W_rel(i,j,k)**JACOBS_Bmu))
enddo
enddo
enddo
end subroutine Rheo_Jacobs_and_vKesteren
subroutine Rheo_Winterwerp_and_Kranenburg
USE nlist
implicit none
!include 'mpif.h'
real phi_clay(0:i1,0:j1,0:k1),phi_silt(0:i1,0:j1,0:k1),phi_sand(0:i1,0:j1,0:k1)
real phi_solids(0:i1,0:j1,0:k1),phi_fines(0:i1,0:j1,0:k1)
real lambda_b(0:i1,0:j1,0:k1),sol_eff(0:i1,0:j1,0:k1),sol_frac(0:i1,0:j1,0:k1)
real shear_thin(0:i1,0:j1,0:k1)
integer n
phi_clay(:,:,:)=0.
phi_silt(:,:,:)=0.
phi_sand(:,:,:)=0.
phi_solids(:,:,:)=0.
phi_fines(:,:,:)=0.
call strain_magnitude(Unew,Vnew,Wnew)
do i=1,imax
do j=1,jmax
do k=1,kmax
do n=1,nfrac
if (frac(n)%dpart.le.2) then !check for clay fractions
phi_clay(i,j,k)= phi_clay(i,j,k) + cnew(n,i,j,k)
elseif (frac(n)%dpart.gt.2.and.frac(n)%dpart.le.63) then !check for silt fractions
phi_silt(i,j,k)= phi_silt(i,j,k) + cnew(n,i,j,k)
else
phi_sand(i,j,k)= phi_sand(i,j,k) + cnew(n,i,j,k)
endif
enddo
phi_fines(i,j,k)=phi_clay(i,j,k)+phi_silt(i,j,k)
phi_solids(i,j,k)=phi_fines(i,j,k)+phi_sand(i,j,k)
lambda_b(i,j,k)=1./(((BAGNOLD_phi_max/(1.e-12+phi_sand(i,j,k)))**(1./3.))-1.) !linear sand concentration Bagnold 1956
sol_eff(i,j,k)=exp(BAGNOLD_beta*lambda_b(i,j,k)) !exponential term expressing influens of sand and silt
sol_frac(i,j,k)=phi_fines(i,j,k)/(1.-phi_sand(i,j,k))
tauY(i,j,k)=sol_eff(i,j,k)*WINTER_Ay*sol_frac(i,j,k)**(2./(3.-WINTER_nf))
shear_thin(i,j,k)=((1./(1.e-12+strain(i,j,k)))**(((WINTER_af+1.)*(3.-WINTER_nf))/3.))
muB(i,j,k)= sol_eff(i,j,k)*(WINTER_muw+WINTER_Amu*(sol_frac(i,j,k)**(((2.*(WINTER_af+1.))/3.)))*shear_thin(i,j,k))
enddo
enddo
enddo
end subroutine Rheo_Winterwerp_and_Kranenburg
subroutine Rheo_Thomas
USE nlist
implicit none
!include 'mpif.h'
real phi_sand(0:i1,0:j1,0:k1),phi_fines(0:i1,0:j1,0:k1),phi_solids(0:i1,0:j1,0:k1)
real sol_eff_y(0:i1,0:j1,0:k1),sol_eff_mu(0:i1,0:j1,0:k1)
integer n
phi_solids(:,:,:)=0.
phi_fines(:,:,:)=0.
phi_sand(:,:,:)=0.
do i=1,imax
do j=1,jmax
do k=1,kmax
do n=1,nfrac
if (frac(n)%dpart.le.44) then !fines < 45 micron
phi_fines(i,j,k)= phi_fines(i,j,k)+cnew(n,i,j,k)
elseif (frac(n)%dpart.gt.44) then !To include all fractions we let sand > 44 micron (instead of 63 micron)
phi_sand(i,j,k)= phi_sand(i,j,k)+cnew(n,i,j,k)
endif
enddo
phi_solids(i,j,k)=phi_fines(i,j,k)+phi_sand(i,j,k)
sol_eff_y(i,j,k)=(1.-(phi_sand(i,j,k)/(THOMAS_ky*THOMAS_phi_sand_max)))**-2.5 !solids effect
sol_eff_mu(i,j,k)=(1.-(phi_sand(i,j,k)/(THOMAS_kmu*THOMAS_phi_sand_max)))**-2.5
tauY(i,j,k)=THOMAS_Cy*((phi_fines(i,j,k)/(1.-phi_sand(i,j,k)))**THOMAS_Py)*sol_eff_y(i,j,k) !depends on definition of fines (in-/excluding silt)
muB(i,j,k)=THOMAS_Cmu*exp(THOMAS_Pmu*(phi_fines(i,j,k)/(1.-phi_solids(i,j,k))))*sol_eff_mu(i,j,k)
enddo
enddo
enddo
end subroutine Rheo_Thomas
subroutine Bingham_Papanastasiou !tauY and muB, yield stress and bingham viscosity (rr = density)
USE nlist
implicit none
!include 'mpif.h'
real ebb(0:i1,0:k1)
real ebf(0:i1,0:k1)
real muA2(0:i1,0:j1,0:k1)
real tau_app(0:i1,0:j1,0:k1),tau_app_u(0:i1,0:j1,0:k1),tau_app_v(0:i1,0:j1,0:k1)
real dppdx,dppdy,dy2,dx2,pppp(0:i1,0:j1,0:k1)
real driving_shearstressz,driving_shearstressy,driving_shearstressx,driving_shearstress,dpdz_hydr
integer im,ip,jm,jp,km,kp,n
if (Rheological_model.ne.'WINTER') then
call strain_magnitude(Unew,Vnew,Wnew) !determine the magnite of the strain rate
endif
tau_app=0.
if (Apvisc_force_eq.eq.1) then
!! try to split off horizontal dpdx,dpdy part of BYS to arrive at horizontal equilibrium numerically more stable
pppp(1:imax,1:jmax,1:kmax)=Pold+p !now full pold not just dp
call bound_3D(pppp)
call bound_3D(tauY)
do i=1,imax
do j=1,jmax
do k=1,kmax
im=i-1
ip=i+1
jm=j-1
jp=j+1
!! at U-loc:
dppdx = (pppp(ip,j,k)-pppp(i,j,k))/(Rp(ip)-Rp(i))
dppdy = (0.5*(pppp(i,jp,k)+pppp(ip,jp,k))-0.5*(pppp(i,jm,k)+pppp(ip,jm,k)))/( Ru(i) * (phip(jp)-phip(jm)) )
tau_app_u(i,j,k) = MIN(tauY(i,j,k),tauY(ip,j,k),dz*sqrt(dppdx**2+dppdy**2))
Ppropx(i,j,k) = Ppropx(i,j,k)+tau_app_u(i,j,k)/dz*dppdx/sqrt((dppdx)**2+(dppdy)**2+1.e-18) !sign of dppdx automatically gives right addition or subtraction to slow down driving force
!Ppropx(i,j,k) = Ppropx(i,j,k)+dppdx !check -> should give near-zero velocity -> yes it does
!! at V-loc:
dppdy = (pppp(i,jp,k)-pppp(i,j,k))/( Rp(i) * (phip(jp)-phip(j)) ) !
dppdx = (0.5*(pppp(ip,j,k)+pppp(ip,jp,k))-0.5*(pppp(im,j,k)+pppp(im,jp,k)))/(Rp(ip)-Rp(im))
tau_app_v(i,j,k) = MIN(tauY(i,j,k),tauY(i,jp,k),dz*sqrt(dppdx**2+dppdy**2))
Ppropy(i,j,k) = Ppropy(i,j,k)+tau_app_v(i,j,k)/dz*dppdy/sqrt((dppdx)**2+(dppdy)**2+1.e-18) !sign of dppdy automatically gives right addition or subtraction to slow down driving force
!Ppropy(i,j,k) = Ppropy(i,j,k)+dppdy !check -> should give near-zero velocity -> yes it does
enddo
enddo
enddo
call bound_3D(tau_app_u)
call bound_3D(tau_app_v)
do i=1,imax
do j=1,jmax
do k=1,kmax
im=i-1
jm=j-1
tau_app(i,j,k) = 0.25*(tau_app_u(i,j,k)+tau_app_u(im,j,k)+tau_app_v(i,j,k)+tau_app_v(i,jm,k))
enddo
enddo
enddo
endif
IF (Apvisc_interp.eq.3.or.Apvisc_interp.eq.4) THEN ! apply high muA at edges patch for staggered arrangement:
DO n=1,1 !10
muA2=tauY
call bound_3D(muA2)
do i=1,imax
do j=1,jmax
do k=1,kmax
im=i-1
ip=i+1
jm=j-1
jp=j+1
km=k-1
kp=k+1
tauY(i,j,k) = MAX(
& muA2(i,j,k),muA2(i,jm,k),muA2(i,jp,k),muA2(i,j,km),muA2(i,j,kp),
& muA2(i,jm,km),muA2(i,jp,km),muA2(i,jm,kp),muA2(i,jp,kp),
& muA2(im,j,k),muA2(im,jm,k),muA2(im,jp,k),muA2(im,j,km),muA2(im,j,kp),
& muA2(im,jm,km),muA2(im,jp,km),muA2(im,jm,kp),muA2(im,jp,kp),
& muA2(ip,j,k),muA2(ip,jm,k),muA2(ip,jp,k),muA2(ip,j,km),muA2(ip,j,kp),
& muA2(ip,jm,km),muA2(ip,jp,km),muA2(ip,jm,kp),muA2(ip,jp,kp))
enddo
enddo
enddo
ENDDO
ENDIF
if (Apvisc_force_eq.eq.2) then
pppp(1:imax,1:jmax,1:kmax)=Pold+p !now full pold not just dp
call bound_3D(pppp)
do i=1,imax !start loop, in r-direction
do j=1,jmax !start loop, in phi-direction
do k=1,kmax !start loop, in z-direction
! unyielded when: delta_Pz*dx*dy < BYS*dz*dy or delta_Pz*dx*dy < BYS*dz*dx &
! delta_Py*dz*dx < BYS*dy*dx or delta_Py*dz*dx < BYS*dy*dz
! delta_Px*dz*dy < BYS*dx*dy or delta_Px*dz*dy < BYS*dx*dz &
! assume very wide cells in laterally uniform situation: dy>>> then check #2 and #6 give yield
! or assume very wide cells in x-dir for uniform situation in x-dir with dx>>> then check #1 and #4 give yield
! or assume very high cells dz>>> then check #3 and #5 give yield
! each force-dir needs to be taken up by either one of the edges where BYS can counteract the pressure gradient, doesn't need to be able to counteract on both edges for each dir
dpdz_hydr = (rho_b-rnew(i,j,k))*gz !negative when rnew>rho_b
driving_shearstressz = ABS((pppp(i,j,k+1)-pppp(i,j,k-1))/(2.*dz)-dpdz_hydr)*dr(i)
driving_shearstressz = MIN(driving_shearstressz,ABS((pppp(i,j,k+1)-pppp(i,j,k-1))/(2.*dz)-dpdz_hydr)*Rp(i)*dphi2(j))
driving_shearstressy = ABS(pppp(i,j+1,k)-pppp(i,j-1,k))*dr(i)/(2.*Rp(i)*dphi2(j))
driving_shearstressy = MIN(driving_shearstressy,ABS(pppp(i,j+1,k)-pppp(i,j-1,k))*dz/(2.*Rp(i)*dphi2(j)))
driving_shearstressx = ABS(pppp(i+1,j,k)-pppp(i-1,j,k))*dz/(2.*dr(i))
driving_shearstressx = MIN(driving_shearstressx,ABS(pppp(i+1,j,k)-pppp(i-1,j,k))*Rp(i)*dphi2(j)/(2.*dr(i)))
driving_shearstress = MAX(driving_shearstressx,driving_shearstressy,driving_shearstressz)
if (driving_shearstress<tauY(i,j,k)) then !unyielded zone with maximum appararent viscosity
muA(i,j,k)= muB(i,j,k)+(tauY(i,j,k)-tau_app(i,j,k))*PAPANASTASIOUS_m
elseif (strain(i,j,k)>1.e-8) then
muA(i,j,k)= muB(i,j,k)+MAX(0.,tauY(i,j,k)-tau_app(i,j,k))/(max(1.e-12,strain(i,j,k)-shear0limit))*
& (1.-exp(-PAPANASTASIOUS_m*(max(1.e-12,strain(i,j,k)-shear0limit))))
else
muA(i,j,k)= muB(i,j,k)+(tauY(i,j,k)-tau_app(i,j,k))*PAPANASTASIOUS_m
endif
enddo
enddo
enddo
else
do i=1,imax !start loop, in r-direction
do j=1,jmax !start loop, in phi-direction
do k=1,kmax !start loop, in z-direction
if (strain(i,j,k)>1.e-8) then
muA(i,j,k)= muB(i,j,k)+MAX(0.,tauY(i,j,k)-tau_app(i,j,k))/(max(1.e-12,strain(i,j,k)-shear0limit))*
& (1.-exp(-PAPANASTASIOUS_m*(max(1.e-12,strain(i,j,k)-shear0limit))))
else
muA(i,j,k)= muB(i,j,k)+(tauY(i,j,k)-tau_app(i,j,k))*PAPANASTASIOUS_m
endif
enddo
enddo
enddo
endif
!! IF (Apvisc_interp.eq.3.or.Apvisc_interp.eq.4) THEN ! apply high muA at edges patch for staggered arrangement:
!! DO n=1,5
!! muA2=muA
!! call bound_3D(muA2)
!! do i=1,imax
!! do j=1,jmax
!! do k=1,kmax
!! im=i-1
!! ip=i+1
!! jm=j-1
!! jp=j+1
!! km=k-1
!! kp=k+1
!! muA(i,j,k) = MAX(
!! & muA2(i,j,k),muA2(i,jm,k),muA2(i,jp,k),muA2(i,j,km),muA2(i,j,kp),
!! & muA2(i,jm,km),muA2(i,jp,km),muA2(i,jm,kp),muA2(i,jp,kp),
!! & muA2(im,j,k),muA2(im,jm,k),muA2(im,jp,k),muA2(im,j,km),muA2(im,j,kp),
!! & muA2(im,jm,km),muA2(im,jp,km),muA2(im,jm,kp),muA2(im,jp,kp),
!! & muA2(ip,j,k),muA2(ip,jm,k),muA2(ip,jp,k),muA2(ip,j,km),muA2(ip,j,kp),
!! & muA2(ip,jm,km),muA2(ip,jp,km),muA2(ip,jm,kp),muA2(ip,jp,kp))
!! enddo
!! enddo
!! enddo
!! ENDDO
!! ENDIF
ekm= ekm + muA
call stress_magnitude !calculate the stress magnitude
call bound_3D(ekm)
call bound_3D(muA)
END subroutine Bingham_Papanastasiou
subroutine Bingham_Fluent_manner !tauY and muB, yield stress and bingham viscosity (rr = density)
USE nlist
implicit none
!include 'mpif.h'
real ebb(0:i1,0:k1)
real ebf(0:i1,0:k1)
real muA2(0:i1,0:j1,0:k1)
real tau_app(0:i1,0:j1,0:k1),tau_app_u(0:i1,0:j1,0:k1),tau_app_v(0:i1,0:j1,0:k1)
real dppdx,dppdy,dy2,dx2,pppp(0:i1,0:j1,0:k1)
real driving_shearstressz,driving_shearstressy,driving_shearstressx,driving_shearstress,dpdz_hydr
integer im,ip,jm,jp,km,kp,n
if (Rheological_model.ne.'WINTER') then
call strain_magnitude(Unew,Vnew,Wnew) !determine the magnite of the strain rate
endif
tau_app=0.
if (Apvisc_force_eq.eq.1) then
!! try to split off horizontal dpdx,dpdy part of BYS to arrive at horizontal equilibrium numerically more stable
pppp(1:imax,1:jmax,1:kmax)=Pold+p !now full pold not just dp
call bound_3D(pppp)
call bound_3D(tauY)
do i=1,imax
do j=1,jmax
do k=1,kmax
im=i-1
ip=i+1
jm=j-1
jp=j+1
!! at U-loc:
dppdx = (pppp(ip,j,k)-pppp(i,j,k))/(Rp(ip)-Rp(i))
dppdy = (0.5*(pppp(i,jp,k)+pppp(ip,jp,k))-0.5*(pppp(i,jm,k)+pppp(ip,jm,k)))/( Ru(i) * (phip(jp)-phip(jm)) )
tau_app_u(i,j,k) = MIN(tauY(i,j,k),tauY(ip,j,k),dz*sqrt(dppdx**2+dppdy**2))
Ppropx(i,j,k) = Ppropx(i,j,k)+tau_app_u(i,j,k)/dz*dppdx/sqrt((dppdx)**2+(dppdy)**2+1.e-18) !sign of dppdx automatically gives right addition or subtraction to slow down driving force
!Ppropx(i,j,k) = Ppropx(i,j,k)+dppdx !check -> should give near-zero velocity -> yes it does
!! at V-loc:
dppdy = (pppp(i,jp,k)-pppp(i,j,k))/( Rp(i) * (phip(jp)-phip(j)) ) !
dppdx = (0.5*(pppp(ip,j,k)+pppp(ip,jp,k))-0.5*(pppp(im,j,k)+pppp(im,jp,k)))/(Rp(ip)-Rp(im))
tau_app_v(i,j,k) = MIN(tauY(i,j,k),tauY(i,jp,k),dz*sqrt(dppdx**2+dppdy**2))
Ppropy(i,j,k) = Ppropy(i,j,k)+tau_app_v(i,j,k)/dz*dppdy/sqrt((dppdx)**2+(dppdy)**2+1.e-18) !sign of dppdy automatically gives right addition or subtraction to slow down driving force
!Ppropy(i,j,k) = Ppropy(i,j,k)+dppdy !check -> should give near-zero velocity -> yes it does
enddo
enddo
enddo
call bound_3D(tau_app_u)
call bound_3D(tau_app_v)
do i=1,imax
do j=1,jmax
do k=1,kmax
im=i-1
jm=j-1
tau_app(i,j,k) = 0.25*(tau_app_u(i,j,k)+tau_app_u(im,j,k)+tau_app_v(i,j,k)+tau_app_v(i,jm,k))
enddo
enddo
enddo
endif
IF (Apvisc_interp.eq.3.or.Apvisc_interp.eq.4) THEN ! apply high muA at edges patch for staggered arrangement:
DO n=1,1 !10
muA2=tauY
call bound_3D(muA2)
do i=1,imax
do j=1,jmax
do k=1,kmax
im=i-1
ip=i+1
jm=j-1
jp=j+1
km=k-1
kp=k+1
tauY(i,j,k) = MAX(
& muA2(i,j,k),muA2(i,jm,k),muA2(i,jp,k),muA2(i,j,km),muA2(i,j,kp),
& muA2(i,jm,km),muA2(i,jp,km),muA2(i,jm,kp),muA2(i,jp,kp),
& muA2(im,j,k),muA2(im,jm,k),muA2(im,jp,k),muA2(im,j,km),muA2(im,j,kp),
& muA2(im,jm,km),muA2(im,jp,km),muA2(im,jm,kp),muA2(im,jp,kp),
& muA2(ip,j,k),muA2(ip,jm,k),muA2(ip,jp,k),muA2(ip,j,km),muA2(ip,j,kp),
& muA2(ip,jm,km),muA2(ip,jp,km),muA2(ip,jm,kp),muA2(ip,jp,kp))
enddo
enddo
enddo
ENDDO
ENDIF
if (Apvisc_force_eq.eq.2) then
pppp(1:imax,1:jmax,1:kmax)=Pold+p !now full pold not just dp
call bound_3D(pppp)
do i=1,imax !start loop, in r-direction
do j=1,jmax !start loop, in phi-direction
do k=1,kmax !start loop, in z-direction
! unyielded when: delta_Pz*dx*dy < BYS*dz*dy or delta_Pz*dx*dy < BYS*dz*dx &
! delta_Py*dz*dx < BYS*dy*dx or delta_Py*dz*dx < BYS*dy*dz
! delta_Px*dz*dy < BYS*dx*dy or delta_Px*dz*dy < BYS*dx*dz &
! assume very wide cells in laterally uniform situation: dy>>> then check #2 and #6 give yield
! or assume very wide cells in x-dir for uniform situation in x-dir with dx>>> then check #1 and #4 give yield
! or assume very high cells dz>>> then check #3 and #5 give yield
! each force-dir needs to be taken up by either one of the edges where BYS can counteract the pressure gradient, doesn't need to be able to counteract on both edges for each dir
dpdz_hydr = (rho_b-rnew(i,j,k))*gz !negative when rnew>rho_b
driving_shearstressz = ABS((pppp(i,j,k+1)-pppp(i,j,k-1))/(2.*dz)-dpdz_hydr)*dr(i)
driving_shearstressz = MIN(driving_shearstressz,ABS((pppp(i,j,k+1)-pppp(i,j,k-1))/(2.*dz)-dpdz_hydr)*Rp(i)*dphi2(j))
driving_shearstressy = ABS(pppp(i,j+1,k)-pppp(i,j-1,k))*dr(i)/(2.*Rp(i)*dphi2(j))
driving_shearstressy = MIN(driving_shearstressy,ABS(pppp(i,j+1,k)-pppp(i,j-1,k))*dz/(2.*Rp(i)*dphi2(j)))
driving_shearstressx = ABS(pppp(i+1,j,k)-pppp(i-1,j,k))*dz/(2.*dr(i))
driving_shearstressx = MIN(driving_shearstressx,ABS(pppp(i+1,j,k)-pppp(i-1,j,k))*Rp(i)*dphi2(j)/(2.*dr(i)))
driving_shearstress = MAX(driving_shearstressx,driving_shearstressy,driving_shearstressz)
if (driving_shearstress<tauY(i,j,k)) then !unyielded zone with maximum appararent viscosity
muA(i,j,k)= muB(i,j,k)+2.*MAX(0.,tauY(i,j,k)-tau_app(i,j,k))/shear0limit
elseif (strain(i,j,k)>shear0limit) then
muA(i,j,k)= muB(i,j,k)+MAX(0.,tauY(i,j,k)-tau_app(i,j,k))/strain(i,j,k)
else
muA(i,j,k)= muB(i,j,k)+(2.-strain(i,j,k)/shear0limit)*MAX(0.,tauY(i,j,k)-tau_app(i,j,k))/shear0limit
endif
enddo
enddo
enddo
else
do i=1,imax !start loop, in r-direction
do j=1,jmax !start loop, in phi-direction
do k=1,kmax !start loop, in z-direction
if (strain(i,j,k)>shear0limit) then
muA(i,j,k)= muB(i,j,k)+MAX(0.,tauY(i,j,k)-tau_app(i,j,k))/strain(i,j,k)
else