-
Notifications
You must be signed in to change notification settings - Fork 1
/
ev_joseph_backup.f90
1298 lines (986 loc) · 24.9 KB
/
ev_joseph_backup.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
!3d two fluid newtonian pipe flow solver!
MODULE ev
USE prms
USE data
USE cheb
IMPLICIT none
INTEGER NOUT
PARAMETER (NOUT=6)
INTEGER NB, NMAX, lt
PARAMETER (NB=4000,NMAX=4000)
INTEGER LDA, LDB, LDVR, LWORK
PARAMETER (LDA=NMAX,LDB=NMAX,LDVR=NMAX,LWORK=NMAX+NMAX*NB)
COMPLEX *16 ii
PARAMETER (ii=(0,1.0))
!FLOW PARAMETERS
Real AA1,AA2
integer iter,iterMax,itermin
CONTAINS
SUBROUTINE evsolve
INTEGER INFO,LWKOPT, N, U, W
COMPLEX *16 A(LDA,NMAX), ALPHA(NMAX), B(LDB,NMAX),BETA(NMAX), DUMMY(1,1), VR(LDVR,NMAX),WORK(LWORK)
DOUBLE PRECISION RWORK(8*NMAX), SMALL, DLAMCH
integer :: i,j
character(30) :: fn
Real, allocatable, dimension(:,:,:) :: xDddr,x2Dddr,xDddt,x2Dddt,x3Dddr,x3Dddt,x4Dddr,x4Dddt
!stop if the number of collocation points in each domain is not the same
If (Ndt .ne. Ndr) Stop
allocate(xDddr(0:Ndr,0:Ndr,0:3))
allocate(x2Dddr(0:Ndr,0:Ndr,0:3))
allocate(x3Dddr(0:Ndr,0:Ndr,0:3))
allocate(x4Dddr(0:Ndr,0:Ndr,0:3))
allocate(xDddt(0:Ndr,0:Ndr,0:3))
allocate(x2Dddt(0:Ndr,0:Ndr,0:3))
allocate(x3Dddt(0:Ndr,0:Ndr,0:3))
allocate(x4Dddt(0:Ndr,0:Ndr,0:3))
lt=1
N=6*(Ndr+1)
iterMin=1
iterMax=100
!fix the sign error for odd derivatives
Dddr(:,:,1) = -1*Dddr(:,:,1)
Dddr(:,:,3) = -1*Dddr(:,:,3)
Dddt(:,:,1) = -1*Dddt(:,:,1)
Dddt(:,:,3) = -1*Dddt(:,:,3)
!make the xDddr matrix that premultiplies Dddr(:) by XXdr
Do i=0,3
xDddr(:,:,i) = Matmul(XXdr(:,:),Dddr(:,:,i))
xDddt(:,:,i) = Matmul(XXdt(:,:),Dddt(:,:,i))
End Do
!make the x2Dddr matrix that premultiplies Dddr(:) by x^2 vector matrix
Do i=0,3
x2Dddr(:,:,i) = Matmul(XX2dr(:,:),Dddr(:,:,i))
x2Dddt(:,:,i) = Matmul(XX2dt(:,:),Dddt(:,:,i))
End Do
Do i=0,3
x3Dddr(:,:,i) = Matmul(XX3dr(:,:),Dddr(:,:,i))
x3Dddt(:,:,i) = Matmul(XX3dt(:,:),Dddt(:,:,i))
End Do
Do i=0,3
x4Dddr(:,:,i) = Matmul(XX4dr(:,:),Dddr(:,:,i))
x4Dddt(:,:,i) = Matmul(XX4dt(:,:),Dddt(:,:,i))
End Do
!write the xDddr matrix
open(unit=13, file='graphDddr0.txt', ACTION="write", STATUS="replace")
do i=0,Ndr
write(13, '(1600F9.2)')( Real(xDddr(i,j,0)) ,j=0,Ndr)
end do
close(13)
!write the x2Dddr matrix
open(unit=157, file='graphDddt0.txt', ACTION="write", STATUS="replace")
do i=0,Ndr
write(157, '(1600F9.2)')( Real(xDddt(i,j,0)) ,j=0,Ndr)
end do
close(157)
Do iter=itermin,itermax,1
MU1 = MU2 * 8 * Real(iter)/Real(itermax) !joseph
print*, 'Mu1/Mu2 =', Mu1/Mu2
!print*, 'R1/R2 =', aa/HH
AA1 = (kap/4)*( (aa**2)*((1/mu1)-1/mu2) - ((HH**2)*(1/mu2)) )
AA2 = (-kap/4)*(HH**2)/mu2
call buildA(A,xDddr,x2Dddr,xDddt,x2Dddt,x3Dddr,x3Dddt,x4Dddr,x4Dddt)
call buildB(B,xDddr,x2Dddr,xDddt,x2Dddt,x3Dddr,x3Dddt,x4Dddr,x4Dddt)
!lapack gevp solver
IF (N.LE.NMAX) THEN
CALL ZGGEV('No left vectors','Vectors (right)',N,A,LDA,B,LDB,&
& ALPHA,BETA,DUMMY,1,VR,LDVR,WORK,LWORK,RWORK,INFO)
!write eigenvalues to files in directory D
Do J=1,N
write(fn,"('D/eval',I9.9)")iter
!write(fn,"('D/eval',I9.9)")Int(10000.*aa/HH)
open(1,file=fn)
If (Real(beta(j))>0.001) Then
write(1,"(3F30.20)") ALPHA(J)/BETA(J)
End if
End Do
close(1)
!write eigenvectors to files in directory V
Do lt=1,N
Do I=1,N
!If (Real(Beta(lt))>0.00001) Then
write(fn,"('V/x.',I9.9)")lt
open(2,file=fn)
write(2,"(3F30.20)") VR(I,lt)
!End if
End Do
End Do
close(2)
IF (INFO.GT.0) THEN
WRITE (NOUT,99999) 'Failure in ZGGEV. INFO =', INFO
ELSE
SMALL = DLAMCH('Sfmin')
DO 20 J = 1,N
IF ((ABS(ALPHA(J)))*SMALL.GE.ABS(BETA(J))) THEN
!WRITE (NOUT,99998) 'Eigenvalue(', J, ') is numerically infinite or undetermined'
ELSE
!print eigenvalues to the shell
!WRITE (NOUT,99997) 'Eigenvalue(', J, ') = ',ALPHA(J)/BETA(J)
END IF
!print eigenvectors to the shell
!WRITE (NOUT,*)
!WRITE (NOUT,99996) 'Eigenvector(', J, ')',&
!& (VR(I,J),I=1,N)
20 CONTINUE
LWKOPT = WORK(1)
IF (LWORK.LT.LWKOPT) THEN
WRITE (NOUT,99995) 'Optimum workspace required = ',&
& LWKOPT, 'Workspace provided = ', LWORK
END IF
END IF
ELSE
WRITE (NOUT,*) 'NMAX too small'
END IF
99999 FORMAT (1X,A,I4)
99998 FORMAT (1X,A,I3,2A,/1X,2(A,I3,A,'(',1P,E11.4,',',1P,E11.4,')'))
99997 FORMAT (1X,A,I2,A,'(',1P,E11.4,',',1P,E11.4,')')
99996 FORMAT (1X,A,I2,A,/3(1X,'(',1P,E11.4,',',1P,E11.4,')',:))
99995 FORMAT (1X,A,I5,/1X,A,I5)
End Do
END SUBROUTINE evsolve
SUBROUTINE buildA(A,xDddr,x2Dddr,xDddt,x2Dddt,x3Dddr,x3Dddt,x4Dddr,x4Dddt)
integer :: i,j
COMPLEX, allocatable, dimension(:,:) :: A11, A12, A13, A14, A15, A16, A21, A22, A23, A24, A25, A26, A31, A32, A33, A34, A35, A36
COMPLEX, allocatable, dimension(:,:) :: A41, A42, A43, A44, A45, A46, A51, A52, A53, A54, A55, A56, A61, A62, A63, A64, A65, A66
Real, allocatable, dimension(:,:,:) :: xDddr,x2Dddr,xDddt,x2Dddt,x3Dddr,x3Dddt,x4Dddr,x4Dddt
COMPLEX *16 :: A(LDA,NMAX)
!COMPLEX *16, allocatable, dimension(:,:) :: A
!allocate(A(0:LDA,0:NMAX))
allocate(A11(0:Ndr,0:Ndr))
allocate(A12(0:Ndr,0:Ndr))
allocate(A13(0:Ndr,0:Ndr))
allocate(A14(0:Ndr,0:Ndr))
allocate(A15(0:Ndr,0:Ndr))
allocate(A16(0:Ndr,0:Ndr))
allocate(A21(0:Ndr,0:Ndr))
allocate(A22(0:Ndr,0:Ndr))
allocate(A23(0:Ndr,0:Ndr))
allocate(A24(0:Ndr,0:Ndr))
allocate(A25(0:Ndr,0:Ndr))
allocate(A26(0:Ndr,0:Ndr))
allocate(A31(0:Ndr,0:Ndr))
allocate(A32(0:Ndr,0:Ndr))
allocate(A33(0:Ndr,0:Ndr))
allocate(A34(0:Ndr,0:Ndr))
allocate(A35(0:Ndr,0:Ndr))
allocate(A36(0:Ndr,0:Ndr))
allocate(A41(0:Ndr,0:Ndr))
allocate(A42(0:Ndr,0:Ndr))
allocate(A43(0:Ndr,0:Ndr))
allocate(A44(0:Ndr,0:Ndr))
allocate(A45(0:Ndr,0:Ndr))
allocate(A46(0:Ndr,0:Ndr))
allocate(A51(0:Ndr,0:Ndr))
allocate(A52(0:Ndr,0:Ndr))
allocate(A53(0:Ndr,0:Ndr))
allocate(A54(0:Ndr,0:Ndr))
allocate(A55(0:Ndr,0:Ndr))
allocate(A56(0:Ndr,0:Ndr))
allocate(A61(0:Ndr,0:Ndr))
allocate(A62(0:Ndr,0:Ndr))
allocate(A63(0:Ndr,0:Ndr))
allocate(A64(0:Ndr,0:Ndr))
allocate(A65(0:Ndr,0:Ndr))
allocate(A66(0:Ndr,0:Ndr))
!FLUID 1 EQUATIONS
!R-MOMENTUM
!A11
A11(:,:) = MU1 * x2Dddr(:,:,2) + MU1 * xDddr(:,:,1) - MU1*(K**2.)*x2Dddr(:,:,0) &
& - MU1*Dddr(:,:,0) - RHO1*ii*K*(KAP/(4.*MU1))*x4Dddr(:,:,0) - RHO1*ii*K*AA1*x2Dddr(:,:,0)
!BC for singularity condition on Ur at r=0
A11(0,:) = Dddr(0,:,0)
!BC for normal stress condition at r=aa
!!!! check the sign here !!!! this reflects page 15 of notes
A11(Ndr,:) = (-1)*Dddr(Ndr,:,0)*GAM*((K**2.)-1./(aa**2.)) -ii*K*(kap/(4.*MU2))*((HH**2.) - aa**2.) * (-2.*mu1*Dddr(Ndr,:,1))
!A12
A12(:,:) = 0
!BC for singularity on Ur
A12(0,:) = 0
!BC for stress at r=aa
A12(Ndr,:) = 0
!A13
A13(:,:) = (-1)*x2Dddr(:,:,1)
!BC singularity condition on Ur
A13(0,:) = 0
!BC for normal stress at r=aa
A13(Ndr,:) = -ii*K*(kap/(4.*MU2))*((HH**2) - aa**2) * Dddr(Ndr,:,0)
!A14
A14(:,:) = 0
!BC for normal stress at r=aa
A14(Ndr,:) = -ii*K*(kap/(4.*MU2))*((HH**2.) - aa**2.) * (2.*MU2*Dddt(0,:,1))
!A15
A15(:,:) = 0
!A16
A16(:,:) = 0
!BC for normal stress at r=aa
A16(Ndr,:) = -ii*K*(kap/(4.*MU2))*((HH**2.) - aa**2.) * (-1.*Dddt(0,:,0))
!X-MOMENTUM
!A21
A21(:,:) = -RHO1*(KAP/(MU1*2.))*x2Dddr(:,:,0)
!BC for singularity on Ux
A21(0,:) = 0
!tang stress BC at r=a
A21(Ndr,:) = (-1.)*MU1*ii*K*Dddr(Ndr,:,0)
!A22
A22(:,:) = MU1*xDddr(:,:,2) + MU1*xDddr(:,:,1) - K*MU1*xDddr(:,:,0) - &
& RHO1*ii*K*(KAP/(MU1*4.))*x3Dddr(:,:,0) - RHO1*ii*K*AA1*xDddr(:,:,0)
!BC singularity condition on Ux
A22(0,:) = Dddr(0,:,1)
!BC for tang stress at r=a
A22(Ndr,:) = (-1.)*MU1*Dddr(Ndr,:,1)
!A23
A23(:,:) = (-1.)*ii*K*xDddr(:,:,0)
!BC singularity condition on Ux
A23(0,:) = 0
!BC for tang stress at r=a
A23(Ndr,:) = 0
!A24
A24(:,:) = 0
!BC for tang stress at r=a
A24(Ndr,:) = MU2*ii*K*Dddt(0,:,0)
!A25
A25(:,:) = 0
!BC for tang stress at r=a
A25(Ndr,:) = MU2*Dddt(0,:,1)
!A26
A26(:,:) = 0
!CONTINUITY
!A31
A31(:,:) = Dddr(:,:,0) + xDddr(:,:,1)
!BC singularity condition on P
A31(0,:) = 0
!A32
A32(:,:) = ii*K*xDddr(:,:,0)
!BC singularity condition on P
A32(0,:) = 0
!A33
A33(:,:) = 0
!bc on singularity condition on P
A33(0,:) = Dddr(0,:,1)
!A34
A34(:,:) = 0
!A35
A35(:,:) = 0
!A36
A36(:,:) = 0
!FLUID 2 EQUATIONS
!R-MOMENTUM
!A41
A41(:,:) = 0
!bc for continuity at interface
A41(0,:) = Dddr(Ndr,:,0)
!A42
A42(:,:) = 0
!A43
A43(:,:) = 0
!A44
A44(:,:) = MU2*xDddt(:,:,1) + MU2*x2Dddt(:,:,2) - MU2*(K**2.)*x2Dddt(:,:,0) &
& - MU2*Dddt(:,:,0) - RHO2*ii*K*(KAP/(MU2*4.))*x4Dddt(:,:,0) - RHO2*ii*K*AA2*x2Dddt(:,:,0)
!bc for no penetration at r=H
A44(Ndr,:) = Dddt(Ndr,:,0)
!bc for continuity at interface
A44(0,:) = (-1.)*Dddt(0,:,0)
!A45
A45(:,:) = 0
!A46
A46(:,:) = (-1.)*x2Dddt(:,:,1)
!bc for no penetration at r=H
A46(Ndr,:) = 0
!bc for continuity at interface
A46(0,:) = 0
!X-MOMENTUM
!A51
A51(:,:) = 0
!bc for no slip at interface
A51(0,:) = Dddr(Ndr,:,0) * kap*aa*0.5*((1/mu1) - 1/mu2)
!A52
A52(:,:) = 0
!bc for no slip at interface
A52(0,:) = Dddr(Ndr,:,0) * ii*K* kap*0.25*(1/mu2)*((aa**2.) - HH**2.)
!A53
A53(:,:) = 0
!A54
A54(:,:) = -RHO2*(KAP/(2.*MU2))*x2Dddt(:,:,0)
!bc no slip at r=H
A54(Ndr,:) = 0
!bc no slip at interface
A54(0,:) = 0
!A55
A55(:,:) = MU2*xDddt(:,:,2) + MU2*Dddt(:,:,1) - (K**2.)*MU2*xDddt(:,:,0) - RHO2*ii*K*(KAP/(MU2*4.))*x3Dddt(:,:,0) &
& - RHO2*ii*K*AA2*xDddt(:,:,0)
!bc no slip at r=H
A55(Ndr,:) = Dddt(Ndr,:,0)
!bc no slip at interface
A55(0,:) = (-1.)*Dddt(0,:,0) * ii*K* kap*0.25*(1/mu2)*((aa**2) - HH**2)
!A56
A56(:,:) = -1.*ii*K*xDddt(:,:,0)
!bc for no slip at r=H
A56(Ndr,:) = 0
!bc no slip at interface
A56(0,:) = 0
!CONTINUITY
!A61
A61(:,:) = 0
!A62
A62(:,:) = 0
!A63
A63(:,:) = 0
!A64
A64(:,:) = Dddt(:,:,0) + xDddt(:,:,1)
!bc for wall pressure 2
A64(Ndr,:) = 0
!A65
A65(:,:) = ii*K*xDddt(:,:,0)
!bc for wall pressure 2
A65(Ndr,:) = 0
!A66
A66(:,:) = 0
!bc for wall pressure 2
A66(Ndr,:) = Dddt(Ndr,:,1)
!put together the LHS
!first row of blocks
Do i=0,Ndr
Do j=0,Ndr
A(i+1,j+1) = A11(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1,j+1+ 1*(Ndr+1)) = A12(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1,j+1+ 2*(Ndr+1)) = A13(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1,j+1+ 3*(Ndr+1)) = A14(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1,j+1+ 4*(Ndr+1)) = A15(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1,j+1+ 5*(Ndr+1)) = A16(i,j)
End Do
End Do
!second row of blocks
Do i=0,Ndr
Do j=0,Ndr
A(i+1+Ndr+1,j+1) = A21(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+Ndr+1,j+1+ 1*(Ndr+1)) = A22(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+Ndr+1,j+1+ 2*(Ndr+1)) = A23(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+Ndr+1,j+1+ 3*(Ndr+1)) = A24(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+Ndr+1,j+1+ 4*(Ndr+1)) = A25(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+Ndr+1,j+1+ 5*(Ndr+1)) = A26(i,j)
End Do
End Do
!third row of blocks
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 2*(Ndr+1),j+1) = A31(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 2*(Ndr+1),j+1+ 1*(Ndr+1)) = A32(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 2*(Ndr+1),j+1+ 2*(Ndr+1)) = A33(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 2*(Ndr+1),j+1+ 3*(Ndr+1)) = A34(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 2*(Ndr+1),j+1+ 4*(Ndr+1)) = A35(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 2*(Ndr+1),j+1+ 5*(Ndr+1)) = A36(i,j)
End Do
End Do
!fourth row of blocks
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 3*(Ndr+1),j+1) = A41(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 3*(Ndr+1),j+1+ 1*(Ndr+1)) = A42(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 3*(Ndr+1),j+1+ 2*(Ndr+1)) = A43(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 3*(Ndr+1),j+1+ 3*(Ndr+1)) = A44(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 3*(Ndr+1),j+1+ 4*(Ndr+1)) = A45(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 3*(Ndr+1),j+1+ 5*(Ndr+1)) = A46(i,j)
End Do
End Do
!fifth row of blocks
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 4*(Ndr+1),j+1) = A51(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 4*(Ndr+1),j+1+ 1*(Ndr+1)) = A52(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 4*(Ndr+1),j+1+ 2*(Ndr+1)) = A53(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 4*(Ndr+1),j+1+ 3*(Ndr+1)) = A54(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 4*(Ndr+1),j+1+ 4*(Ndr+1)) = A55(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 4*(Ndr+1),j+1+ 5*(Ndr+1)) = A56(i,j)
End Do
End Do
!sixth row of blocks
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 5*(Ndr+1),j+1) = A61(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 5*(Ndr+1),j+1+ 1*(Ndr+1)) = A62(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 5*(Ndr+1),j+1+ 2*(Ndr+1)) = A63(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 5*(Ndr+1),j+1+ 3*(Ndr+1)) = A64(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 5*(Ndr+1),j+1+ 4*(Ndr+1)) = A65(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
A(i+1+ 5*(Ndr+1),j+1+ 5*(Ndr+1)) = A66(i,j)
End Do
End Do
call matrixAPrint(A,A11,A12,A13,A21,A22,A23,A31,A32,A33)
END SUBROUTINE buildA
SUBROUTINE buildB(B,xDddr,x2Dddr,xDddt,x2Dddt,x3Dddr,x3Dddt,x4Dddr,x4Dddt)
integer :: i,j
COMPLEX, allocatable, dimension(:,:) :: B11, B12, B13, B14, B15, B16, B21, B22, B23, B24, B25, B26, B31, B32, B33, B34, B35, B36
COMPLEX, allocatable, dimension(:,:) :: B41, B42, B43, B44, B45, B46, B51, B52, B53, B54, B55, B56, B61, B62, B63, B64, B65, B66
Real, allocatable, dimension(:,:,:) :: xDddr,x2Dddr,xDddt,x2Dddt,x3Dddr,x3Dddt,x4Dddr,x4Dddt
COMPLEX *16 :: B(LDB,NMAX)
allocate(B11(0:Ndr,0:Ndr))
allocate(B12(0:Ndr,0:Ndr))
allocate(B13(0:Ndr,0:Ndr))
allocate(B14(0:Ndr,0:Ndr))
allocate(B15(0:Ndr,0:Ndr))
allocate(B16(0:Ndr,0:Ndr))
allocate(B21(0:Ndr,0:Ndr))
allocate(B22(0:Ndr,0:Ndr))
allocate(B23(0:Ndr,0:Ndr))
allocate(B24(0:Ndr,0:Ndr))
allocate(B25(0:Ndr,0:Ndr))
allocate(B26(0:Ndr,0:Ndr))
allocate(B31(0:Ndr,0:Ndr))
allocate(B32(0:Ndr,0:Ndr))
allocate(B33(0:Ndr,0:Ndr))
allocate(B34(0:Ndr,0:Ndr))
allocate(B35(0:Ndr,0:Ndr))
allocate(B36(0:Ndr,0:Ndr))
allocate(B41(0:Ndr,0:Ndr))
allocate(B42(0:Ndr,0:Ndr))
allocate(B43(0:Ndr,0:Ndr))
allocate(B44(0:Ndr,0:Ndr))
allocate(B45(0:Ndr,0:Ndr))
allocate(B46(0:Ndr,0:Ndr))
allocate(B51(0:Ndr,0:Ndr))
allocate(B52(0:Ndr,0:Ndr))
allocate(B53(0:Ndr,0:Ndr))
allocate(B54(0:Ndr,0:Ndr))
allocate(B55(0:Ndr,0:Ndr))
allocate(B56(0:Ndr,0:Ndr))
allocate(B61(0:Ndr,0:Ndr))
allocate(B62(0:Ndr,0:Ndr))
allocate(B63(0:Ndr,0:Ndr))
allocate(B64(0:Ndr,0:Ndr))
allocate(B65(0:Ndr,0:Ndr))
allocate(B66(0:Ndr,0:Ndr))
!FLUID 1 EQUATIONS
!R-MOMENTUM
!B11
B11(:,:) = RHO1*x2Dddr(:,:,0)
!singularity bc on Ur
B11(0,:) = 0
!normal stress at r=a
B11(Ndr,:) = -2.*MU1*Dddr(Ndr,:,1)
!B12
B12(:,:) = 0
!B13
B13(:,:) = 0
!bc for normal stress at r=a
B13(Ndr,:) = 1.*Dddr(Ndr,:,0)
!B14
B14(:,:) = 0
!bc for normal stress at r=a
B14(Ndr,:) = 2.*MU2*Dddt(0,:,1)
!B15
B15(:,:) = 0
!B16
B16(:,:) = 0
!bc for normal stress at r=a
B16(Ndr,:) = (-1.)*Dddt(0,:,0)
!X-MOMENTUM
!B21
B21(:,:) = 0
!B22
B22(:,:) = RHO1*xDddr(:,:,0)
!singularity BC on Ux
B22(0,:) = 0
!tang stress at r=a
B22(Ndr,:) = 0
!B23
B23(:,:) = 0
!B24
B24(:,:) = 0
!B25
B25(:,:) = 0
!B26
B26(:,:) = 0
!CONTINUITY
!B31
B31(:,:) = 0
!B32
B32(:,:) = 0
!B33
B33(:,:) = 0
!B34
B34(:,:) = 0
!B35
B35(:,:) = 0
!B36
B36(:,:) = 0
!FLUID 2 EQUATIONS
!R-MOMENTUM
!B41
B41(:,:) = 0
!B42
B42(:,:) = 0
!B43
B43(:,:) = 0
!B44
B44(:,:) = RHO2*x2Dddt(:,:,0)
!bc for no penetration at r=H
B44(Ndr,:) = 0
!bc for continuity at interface
B44(0,:) = 0
!B45
B45(:,:) = 0
!B46
B46(:,:) = 0
!X-MOMENTUM
!B51
B51(:,:) = 0
!B52
B52(:,:) = 0
!bc no slip at interface
B52(0,:) = (-1.) * Dddr(Ndr,:,0)
!B53
B53(:,:) = 0
!B54
B54(:,:) = 0
!B55
B55(:,:) = RHO2*xDddt(:,:,0)
!bc for no slip at r=H
B55(Ndr,:) = 0
!bc no slip at interface
B55(0,:) = Dddt(0,:,0)
!B56
B56(:,:) = 0
!CONTINUITY
!B61
B61(:,:) = 0
!B62
B62(:,:) = 0
!B63
B63(:,:) = 0
!B64
B64(:,:) = 0
!B65
B65(:,:) = 0
!B66
B66(:,:) = 0
!put together the RHS
!first row of blocks
Do i=0,Ndr
Do j=0,Ndr
B(i+1,j+1) = B11(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
B(i+1,j+1+ 1*(Ndr+1)) = B12(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
B(i+1,j+1+ 2*(Ndr+1)) = B13(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
B(i+1,j+1+ 3*(Ndr+1)) = B14(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
B(i+1,j+1+ 4*(Ndr+1)) = B15(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
B(i+1,j+1+ 5*(Ndr+1)) = B16(i,j)
End Do
End Do
!second row of blocks
Do i=0,Ndr
Do j=0,Ndr
B(i+1+Ndr+1,j+1) = B21(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
B(i+1+Ndr+1,j+1+ 1*(Ndr+1)) = B22(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
B(i+1+Ndr+1,j+1+ 2*(Ndr+1)) = B23(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
B(i+1+Ndr+1,j+1+ 3*(Ndr+1)) = B24(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
B(i+1+Ndr+1,j+1+ 4*(Ndr+1)) = B25(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
B(i+1+Ndr+1,j+1+ 5*(Ndr+1)) = B26(i,j)
End Do
End Do
!third row of blocks
Do i=0,Ndr
Do j=0,Ndr
B(i+1+ 2*(Ndr+1),j+1) = B31(i,j)
End Do
End Do
Do i=0,Ndr
Do j=0,Ndr
B(i+1+ 2*(Ndr+1),j+1+ 1*(Ndr+1)) = B32(i,j)