-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigrate.f
4703 lines (4261 loc) · 164 KB
/
migrate.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
program doit
implicit real*8 (a-h,o-z)
include 'param.h'
common/bfss4/rad,starm,pindex,jout(kmax2),jin(kmax2),ktop(jmax2)
common/bfss5/rho(jmax2,kmax2),drhor(jmax2,kmax2),
1 drhoz(jmax2,kmax2),angmo(jmax2)
common/bfss7/avquad(jmax2),davquad(jmax2)
common/poten2/delphi(2,jmax2,kmax2)
common/ivp1/time,dt,cc(15,jmax2,kmax2),ee(neq,jmax2,kmax2)
c potential solver common blocks
common/blok6/dtheta,cosign(lmax),sign(lmax),pi,grav
common/inside/tmass,enew,elost,edif,phichk,klocat
common/pois/phi3d(jmax2,kmax2,lmax)
common/grid/r(jmax2),z(kmax2),rhf(jmax1),zhf(kmax1),
1 g(jmax2),h(kmax2)
common/planet/rp,fp,xmp,cstar,rstar,growth,omega_max
common/tstep/max_steps
character*80 filen,pulsefile
pulsefile='pulse'
open(24,file='pulsefile',form='formatted',status='unknown')
write(6,12)
12 format(' version 11/21/2010 gfortran compiler only')
write(6,10)
10 format(' data file')
read(5,11) filen
write(6,17) filen
11 format(a80)
write(6,14)
14 format(' mode = ___ ')
read(5,15) mode
write(6,18) mode
15 format(2i5)
write(6,16)
16 format(' model = ___ ')
read(5,15) nevolve
write(6,18) nevolve
17 format(1x,a80)
18 format(1x,i5)
write(6,19)
19 format(' polytropic index:')
read(5,*) pindex,koji,rin
write(6,*) pindex
write(6,20) koji,rin
20 format(' koji = ___ ',i3,' rin = ___ ',f12.6)
read(5,*) angpow
write(6,21) angpow
21 format(' q =',1p1e9.3)
read(5,*) rp,xmp,cstar,growth
write(6,22) xmp,rp,cstar,growth
22 format(' planet M= ',1p1e12.4,' semi-major axis= ',1p1e12.4,/
&' stellar M= ',1p1e12.4,' growth time factor= ',1p1e12.4)
read(5,*) max_steps
open ( unit = 1 , file = filen , form = 'formatted',
1 status = 'old')
if (koji.ge.1) then
call kojima(koji,rin)
else
call reads_toman(nevolve,jrhomax)
end if
call equil(mode,scale,jrhomax,koji,jomegamax)
omega_max=avquad(jrhomax)
call perturbation(mode,jrhomax,koji)
call evolve(mode,scale,jrhomax,koji,jomegamax,angpow)
end
subroutine reads_brian(nevolve,jrhomax)
implicit real*8 (a-h,o-z)
include 'param.h'
common/bfss4/rad,starm,pindex,jout(kmax2),jin(kmax2),ktop(jmax2)
common/bfss5/rho(jmax2,kmax2),drhor(jmax2,kmax2),
1 drhoz(jmax2,kmax2),angmo(jmax2)
common/bfss7/avquad(jmax2),davquad(jmax2)
common/poten2/delphi(2,jmax2,kmax2)
common/ivp1/time,dt,cc(15,jmax2,kmax2),ee(neq,jmax2,kmax2)
c potential solver common blocks
common/blok6/dtheta,cosign(lmax),sign(lmax),pi,grav
common/inside/tmass,enew,elost,edif,phichk,klocat
common/pois/phi3d(jmax2,kmax2,lmax)
common/grid/r(jmax2),z(kmax2),rhf(jmax1),zhf(kmax1),
1 g(jmax2),h(kmax2)
common/angular/angold(jmax2)
common/contour/kcontour(jmax2,10)
dimension rho_read(jmax2,jmax2)
c.....read models
nrun = 0
10 nrun = nrun+1
read(1,*) pindex,c1,rad,c2,c3,tw,c6,c7,c8,jscf,kscf
write(6,*) pindex,c1,rad,c2,c3,tw,c6,c7,c8,jscf,kscf
read(1,*) rho_read
11 format(8(1pe22.15,2x))
rhomax=0.0
do j=1,jmax2
do k=1,kmax2
rho(j,k)=rho_read(j,k)
end do
if (rho(j,2).gt.rhomax) then
rhomax=rho(j,2)
jrhomax=j
end if
end do
do j=1,jmax2
do k=1,kmax2
if(rho(j,k).lt.1.0e-10*rhomax) then
rho(j,k)=0.0
end if
end do
end do
read(1,*,end=20) ((rho_read(j,k),j=1,jmax1),k=1,jmax1)
20 continue
do j=1,jmax2
angold(j)=rho_read(j,2)
end do
c....."correct" model number?
if(nrun.lt.nevolve) go to 10
c.....re-center angular momentum
angmo(2)=0.0
do j=3,jmax1
angmo(j)=0.5*(angold(j-1)+angold(j))
end do
angmo(1)=angmo(3)
c.....computational grid
delr=rad/float(jscf-2)
delz=delr
r(3)=delr
r(2)=0.0
r(1)=-r(3)
r(4)=2.0*delr
do j=5,jmax1
r(j)=r(j-1)+delr
end do
r(jmax2)=r(jmax1)+delr
z(3)=delz
z(2)=0.0
z(1)=-z(3)
z(4)=2.0*delz
do k=5,kmax1
z(k)=z(k-1)+delz
end do
z(kmax2)=z(kmax1)+delz
do j=1,jmax1
rhf(j)=0.5*(r(j+1)+r(j))
rho(j,kmax1)=0.0
end do
do k=1,kmax1
zhf(k)=0.5*(z(k+1)+z(k))
rho(jmax1,k)=0.0
end do
angmo(jmax1)=2.0*angmo(jmax)-angmo(jmax-1)
c.....zero coefficient array for linearized equations
c and locate the surface of the model
do j=1,jmax2
ktop(j)=2
do 500 k=1,kmax2
if(rho(j,k).gt.1.0e-07*rhomax) ktop(j)=k
if(rho(j,k).gt.0.9*rhomax) kcontour(j,1)=k
if(rho(j,k).gt.0.5*rhomax) kcontour(j,2)=k
if(rho(j,k).gt.0.1*rhomax) kcontour(j,3)=k
if(rho(j,k).gt.0.01*rhomax) kcontour(j,4)=k
if(rho(j,k).gt.0.001*rhomax) kcontour(j,5)=k
if(rho(j,k).gt.0.0001*rhomax) kcontour(j,6)=k
do 500 l = 1 , 15
cc(l,j,k) = 0.0
500 continue
end do
do 600 k=1,kmax2
jin(k)=0
jout(k)=0
600 continue
rhoc=1.0e-10*rhomax
do 650 k=2,kmax1
do 650 j=2,jmax1
if(jin(k).eq.0 .and. rho(j,k).gt.rhoc) jin(k)=j
if(jin(k).gt.0 .and. rho(j,k).gt.rhoc) jout(k)=j
650 continue
return
end
subroutine reads_toman(nevolve,jrhomax)
implicit real*8 (a-h,o-z)
include 'param.h'
common/bfss4/rad,starm,pindex,jout(kmax2),jin(kmax2),ktop(jmax2)
common/bfss5/rho(jmax2,kmax2),drhor(jmax2,kmax2),
1 drhoz(jmax2,kmax2),angmo(jmax2)
common/bfss7/avquad(jmax2),davquad(jmax2)
common/poten2/delphi(2,jmax2,kmax2)
common/ivp1/time,dt,cc(15,jmax2,kmax2),ee(neq,jmax2,kmax2)
c potential solver common blocks
common/blok6/dtheta,cosign(lmax),sign(lmax),pi,grav
common/inside/tmass,enew,elost,edif,phichk,klocat
common/pois/phi3d(jmax2,kmax2,lmax)
common/grid/r(jmax2),z(kmax2),rhf(jmax1),zhf(kmax1),
1 g(jmax2),h(kmax2)
common/angular/angold(jmax2)
common/contour/kcontour(jmax2,10)
common/tork/torkgrav(jmax2),torkadv(jmax2),torksum
dimension rho_read(jmax2,jmax2)
c.....read models
nrun = 0
10 nrun = nrun+1
c.....zero density array
do j=1,jmax2
do k=1,kmax2
rho(j,k)=0.0
end do
end do
read(1,*,end=9000) jscf,kscf
read(1,*) rad,starm
read(1,*) ((rho_read(j,k),j=2,jmax1),k=2,jmax1)
read(1,*) (angold(j),j=2,jmax1)
40 format(1p6e13.5)
c....."correct" model number?
if (nrun.lt.nevolve) go to 10
c
c find the stellar radius, the inner edge of the disk, and the
c outer edge of the disk
c
c star/disk model
go to 919
jbody=0
jdisk=0
do j=2,jmax1
if(rho_read(j,2).eq.0.0 .and. jbody.eq.0) then
js = j
jbody = 1
end if
if(rho_read(j,2).gt.0.0 .and. jbody.eq.1 .and. jdisk.eq.0) then
jd = j
jdisk = 1
end if
end do
rhostarmax=-100.0
rhodiskmax=-100.0
do j=2,jmax1
if(j.le.js) then
if(rho_read(j,2).gt.rhostarmax) rhostarmax=rho_read(j,2)
end if
if(j.ge.jd) then
if(rho_read(j,2).gt.rhodiskmax) rhodiskmax=rho_read(j,2)
end if
end do
c
write(6,*) 'rhomax ',js,jd,rhostarmax,rhodiskmax
c.....set rho cut-off
rhomax=-1.0e05
do j=2,jmax1
do k=2,kmax1
rho(j,k)=rho_read(j,k)
end do
if(rho(j,2).gt.rhomax) then
rhomax=rho(j,2)
jrhomax=j
end if
end do
rhomin=1.0e-10*rhostarmax
rhomind=1.0e-10*rhodiskmax
do j=2,jmax1
do k=2,kmax1
if(j.lt.js .and. rho(j,k).lt.rhomin) then
rho(j,k)=0.0e-00
end if
if(j.gt.jd .and. rho(j,k).lt.rhomind) then
rho(j,k)=0.0e-00
end if
end do
end do
c
c disk model
c
919 continue
rhomax=-100.0
do j=2,jmax1
if (rho_read(j,2).gt.rhomax) then
rhomax=rho_read(j,2)
jrhomax=j
end if
end do
do j=2,jmax1
do k=2,kmax1
if (rho_read(j,k).le.1.0e-10*rhomax) then
rho(j,k)=0.0
else
rho(j,k)=rho_read(j,k)
end if
end do
end do
c.....re-center angular momentum
do j=3,jmax1
angmo(j)=0.5*(angold(j-1)+angold(j))
end do
angmo(1)=angmo(3)
angmo(2)=angmo(3)
c.....computational grid
delr=rad/float(jscf-2)
delz=delr
r(3)=delr
r(2)=0.0
r(1)=-r(3)
r(4)=2.0*delr
do j=5,jmax1
r(j)=r(j-1)+delr
end do
r(jmax2)=r(jmax1)+delr
z(3)=delz
z(2)=0.0
z(1)=-z(3)
z(4)=2.0*delz
do k=5,kmax1
z(k)=z(k-1)+delz
end do
z(kmax2)=z(kmax1)+delz
do j=1,jmax1
rhf(j)=0.5*(r(j+1)+r(j))
rho(j,kmax1)=0.0
end do
do k=1,kmax1
zhf(k)=0.5*(z(k+1)+z(k))
rho(jmax1,k)=0.0
end do
angmo(jmax1)=2.0*angmo(jmax)-angmo(jmax-1)
c.....zero coefficient array for linearized equations
c and locate surface in pomega and z
do j=2,jmax1
ktop(j)=2
do 500 k=2,kmax1
if(rho(j,k).gt.1.0e-07*rhomax) ktop(j)=k
if(rho(j,k).gt.0.9*rhomax) kcontour(j,1)=k
if(rho(j,k).gt.0.5*rhomax) kcontour(j,2)=k
if(rho(j,k).gt.0.1*rhomax) kcontour(j,3)=k
if(rho(j,k).gt.0.01*rhomax) kcontour(j,4)=k
if(rho(j,k).gt.0.001*rhomax) kcontour(j,5)=k
if(rho(j,k).gt.0.0001*rhomax) kcontour(j,6)=k
do 500 l=1,15
cc(l,j,k)=0.0
500 continue
end do
do 600 k=1,kmax2
jin(k)=2
jout(k)=2
600 continue
do 650 k=2,kmax1
do 650 j=2,jmax1
if(jin(k).eq.2 .and. rho(j,k).gt.1.0e-10*rhomax) jin(k)=j
if(jin(k).gt.2 .and. rho(j,k).gt.1.0e-10*rhomax) jout(k)=j
650 continue
return
9000 continue
stop
end
subroutine boundary(jrhomax)
c ********************************************
c * *
c * boundary conditions *
c * *
c ********************************************
implicit real*8 (a-h,o-z)
include 'param.h'
common/ivp1/time,dt,cc(15,jmax2,kmax2),ee(neq,jmax2,kmax2)
common/bfss4/rad,starm,pindex,jout(kmax2),jin(kmax2),ktop(jmax2)
common/bfss5/rho(jmax2,kmax2),drhor(jmax2,kmax2),
1 drhoz(jmax2,kmax2),angmo(jmax2)
data surface/0.0e00/
do i = 1 , neq
do j = 2 , jmax
c symmetry about equatorial plane
if (i.le.6) then
ee(i,j,1) = ee(i,j,3)
else
ee(i,j,1) = -ee(i,j,3)
ee(i,j,2) = 0.0
end if
c "top" of polytrope
if (ktop(j).eq.2) go to 100
k_s = ktop(j)
if (i.ge.3) ee(i,j,k_s) = surface
cfree_old if (i.lt.3) ee(i,j,k_s) = surface
ee(i,j,k_s+1) = 2.0 * ee(i,j,k_s) - ee(i,j,k_s-1)
ee(i,j,k_s+1) = ee(i,j,k_s)
100 continue
end do
do k = 2 , kmax
c "outer" edge of torus
j_s = jout(k)
if (i.ge.3) ee(i,j_s,k) = surface
cfree_old if (i.lt.3) ee(i,j_s,k) = surface
ee(i,j_s+1,k) = 2.0 * ee(i,j_s,k) - ee(i,j_s-1,k)
ee(i,j_s+1,k) = ee(i,j_s,k)
c "inner" edge of torus
j_s = jin(k)
if (i.ge.3) ee(i,j_s,k) = surface
cfree_old if (i.lt.3) ee(i,j_s,k) = surface
ee(i,j_s-1,k) = 2.0 * ee(i,j_s,k) - ee(i,j_s+1,k)
ee(i,j_s-1,k) = ee(i,j_s,k)
end do
end do
return
end
subroutine equil(m_leg,scale,jrhomax,koji,jomegamax)
c
c***********************************************************************
c
c equilibrium values (cc array) for the coefficients
c
c***********************************************************************
c
implicit real*8 (a-h,o-z)
include 'param.h'
real*8 kesum,jsum
common/bfss4/rad,starm,pindex,jout(kmax2),jin(kmax2),ktop(jmax2)
common/bfss5/rho(jmax2,kmax2),drhor(jmax2,kmax2),
1 drhoz(jmax2,kmax2),angmo(jmax2)
common/bfss7/avquad(jmax2),davquad(jmax2)
common/poten2/delphi(2,jmax2,kmax2)
common/ivp1/time,dt,cc(15,jmax2,kmax2),ee(neq,jmax2,kmax2)
c potential solver common blocks
common/blok6/dtheta,cosign(lmax),sign(lmax),pi,grav
common/inside/tmass,enew,elost,edif,phichk,klocat
common/pois/phi3d(jmax2,kmax2,lmax)
common/grid/r(jmax2),z(kmax2),rhf(jmax1),zhf(kmax1),
1 g(jmax2),h(kmax2)
common/angular/angold(jmax2)
common/contour/kcontour(jmax2,10)
common/planet/rp,fp,xmp,cstar,rstar,growth,omega_max
dimension sigma(jmax2)
pi = acos(-1.0)
twopi = 2.0*pi
fourpi = 4.0*pi
gamma = 1.0+1.0/pindex
gmin1 = gamma-1.0
gmin2 = gamma-2.0
gmin3 = gamma-3.0
do j = 2 , jmax1
do k = ktop(j) + 1 , kmax1
rho(j,k) = 0.0
end do
end do
call angquad
call thermo
c -- potcal(1,m): "1" = axisymmetric density
call potcal(1,m_leg,koji)
c
c -- call planet potential
c
call coefficients(m_leg)
rad2 = rad*rad
rad3 = rad2*rad
volume = twopi*rad3
volsum = 0.0
smass = 0.0
xmass1 = 0.0
wsum = 0.0
wstar = 0.0
kesum = 0.0
jsum = 0.0
rhomax = 0.0
jrhomax = 2
omegamax = 0.0
jomegamax = 3
radmax = 0.0
do 1000 j = 2 , jmax
if (avquad(j).ge.fp) jcoro = j
write(16,106) j,ktop(j),kcontour(j,1),kcontour(j,2),
& kcontour(j,3),kcontour(j,4),kcontour(j,5),
& kcontour(j,6)
write(17,106) j,jin(j),jout(j)
106 format(8i5)
po = rhf(j)/rad
deltapo = (r(j+1)-r(j))/rad
avq = angold(j)/rhf(j)**2
if (avq.ne.0.0) then
davq1 = (po/avq)*(avquad(j+1)-avquad(j))/deltapo
davq = davquad(j)
end if
if(rho(j,2).gt.rhomax) then
rhomax = rho(j,2)
jrhomax = j
c omegamax = avq
radmax = rhf(j)
end if
if(avq.gt.omegamax) then
omegamax = avq
jomegamax = j
end if
velq = 0.5*(r(j+1)*avquad(j+1)+r(j)*avquad(j))
velq = angold(j)/rhf(j)
velqsq = velq*velq
if (j.ne.2) then
aq = avquad(j)
vq = aq*rhf(j)
else
aq = avq
vq = velq
end if
do 1100 k = 2 , kmax2
rhoq = rho(j,k)
if (rhoq .le. 0.0) go to 1100
deltaz = (z(k+1)-z(k))/rad
drhoqr = drhor(j,k)
drhoqz = drhoz(j,k)
weight = po*deltapo*deltaz
rhoqj = 0.5*(rho(j,k)+rho(j-1,k))
rhoqk = 0.5*(rho(j,k)+rho(j,k-1))
c.....coefficient array cc(m,j,k)
cc(1,j,k) = m_leg*avq
cc(2,j,k) = rhoq*(1.0+(rhf(j)/rhoq)*(rho(j+1,k)-
1 rho(j-1,k))/(rhf(j+1)-rhf(j-1)))/rhf(j)
cc(3,j,k) = m_leg*rhoq/rhf(j)
cc(4,j,k) = (rho(j,k+1)-rho(j,k-1))/(zhf(k+1)-zhf(k-1))
cc(12,j,k) = rhoq
cc(5,j,k) = gamma*gmin2*rhoqj**gmin3*drhoqr
cc(6,j,k) = m_leg*aq
cc(7,j,k) = gamma*rhoqj**gmin2
cc(13,j,k) = 1.0
cc(8,j,k) = m_leg*gamma*rhoq**gmin2/rhf(j)
cc(9,j,k) = avq*(2.0+davq)
cc(10,j,k) = m_leg/rhf(j)
cc(11,j,k) = gamma*gmin2*rhoqk**gmin3*drhoqz
cc(14,j,k) = gamma*rhoqk**gmin2
cc(15,j,k) = 1.0
c spheroid volume
volsum = volsum + weight
c spheroid mass
smass = smass + rhoq*weight
c rotational kinetic energy
kesum = kesum + 0.5*rhoq*velqsq*weight
c angular momentum
jsum = jsum + rhoq*velq*rhf(j)*weight
c gravitational potential energy
rjk = sqrt(rhf(j)**2+rhf(k)**2)
wsum = wsum + 0.25*rhoq*delphi(1,j,k)*weight
wstar = wstar - rhoq*(starm/rjk)*weight
c
sigma(j) = (smass-xmass1)/pi/(r(j+1)**2-r(j)**2)
1100 continue
xmass1 = smass
1000 continue
c
c
xplanet = xmp*(fp*rp)*rp
c
c calculate t/|w|
c
volsum = 2.0*volsum*volume
smass = 2.0*smass*volume
kesum = 2.0*kesum*volume
jsum = 2.0*jsum*volume
wsum = 2.0*wsum*volume
wstar = 2.0*wstar*volume
usum = 0.5*(-wsum-wstar-2.0*kesum)
toverw = kesum/abs(wsum+wstar)
c
c print the model parameters
c
write(6,1600) pindex,rad,toverw
1600 format (//' n =',f5.2,' radius = ',1pe12.5,
1 ' T/|W| =',1p3e12.5)
write(6,1610) kesum,wsum,wstar,usum,jsum
1610 format (' T,W,U =',1p4e12.4,
1 ' J =',1pe12.4)
write(6,1800) m_leg
1800 format ( ' azimuthal mode number: ',i5/)
c
cirp = twopi/avquad(3)
write(6,2600) volsum/4.18879/rad3,smass
2600 format(/' spheroid volume (4*pi*rad**3/3) and mass: '
1 ,1p2e12.5/)
scale = 2.0*acos(-1.0)/omegamax
scale = 2.0*acos(-1.0)/avquad(jrhomax+1)
write(6,2700) jrhomax,radmax,rhomax,scale,omegamax
2700 format(/' r(max): ',i5,1pe11.4,' rho(max): ',1pe11.4,
1 ' MIRP: ',1p2e11.4,/)
smode = m_leg
rolr = (smode/(smode+1.0))**(-2.0/3.0)
rilr = (smode/(smode-1.0))**(-2.0/3.0)
write(6,2710) xmp,fp,rp,xplanet
2710 format(' M(p),Omega(p),a(p),J(p): ',1p4e12.4)
write(6,2720) rilr*r(jcoro),rolr*r(jcoro),r(jcoro)
2720 format(/' r(ilr), r(olr), r(co): ',1p3e12.4,/)
c
do j=2,jmax
dhdr=(avquad(j+1)*r(j+1)**2-avquad(j-1)*r(j-1)**2)/
1 (r(j+1)-r(j-1))
if (r(j).ne.0.0) then
ep=(2.0*avquad(j)/r(j))*dhdr
else
ep=0.0
end if
if(rho(j,2).ne.0.0) then
vortensity=rho(j,2)/dhdr*rhf(j)
else
vortensity=0.0
end if
if(ep.gt.0.0) ep=sqrt(ep)/m_leg
avq=avquad(j)
write(6,2800) j,rhf(j),rho(j,2),avq,vortensity,sigma(j),
& delphi(1,j,2)
2800 format(i5,1p6e12.5)
end do
return
end
subroutine perturbation(m_leg,jrhomax,koji)
c
c***********************************************************************
c
c initial perturbation
c
c***********************************************************************
c
implicit real*8 (a-h,o-z)
include 'param.h'
c
common/bfss4/rad,starm,pindex,jout(kmax2),jin(kmax2),ktop(jmax2)
common/bfss5/rho(jmax2,kmax2),drhor(jmax2,kmax2),
1 drhoz(jmax2,kmax2),angmo(jmax2)
common/bfss7/avquad(jmax2),davquad(jmax2)
common/poten2/delphi(2,jmax2,kmax2)
common/ivp1/time,dt,cc(15,jmax2,kmax2),ee(neq,jmax2,kmax2)
c potential solver common blocks
common/blok6/dtheta,cosign(lmax),sign(lmax),pi,grav
common/inside/tmass,enew,elost,edif,phichk,klocat
common/pois/phi3d(jmax2,kmax2,lmax)
common/grid/r(jmax2),z(kmax2),rhf(jmax1),zhf(kmax1),
1 g(jmax2),h(kmax2)
common/stardelta/starq(2,2),starphi(2,jmax2,kmax2)
dimension cyl(jmax1)
c
data time /0.0/
pi = acos(-1.0)
twopi = 2.0*pi
cyl(1)=0.0
delta=twopi*(r(3)-r(2))
do j=2,jmax1
dcyl=0.0
dvol=delta*(r(j+1)**2-r(j)**2)
do k=2,kmax1
dcyl=dcyl+rho(j,k)*dvol
end do
cyl(j)=cyl(j-1)+dcyl
end do
do j=1,jmax1
cyl(j)=cyl(j)/cyl(jmax1)
end do
read(5,*) jump,tstart
if(jump.eq.1) then
read (11) ee
time = tstart
if(m_leg.eq.1) then
read (52) starq
return
end if
read(28,130) torksum
130 format(1p1e12.5)
else
torksum = 0
call angquad
delta = twopi / (jout(2)-jin(2))
do 2000 j = jin(2) , jout(2)
do 2000 k = 2 , kmax
rhoamp = 0.0
vamp = 0.0
vphi = 0.0
if (rho(j,k).gt.0.0) then
rhoamp = 1.0e-16*rand(0)
end if
phase = twopi*rand(0)
c
c m=1 perturbation
c
if(m_leg.eq.1 .and. rho(j,k).gt.0.0) then
rhoamp = 1.0e-10*(rho(j,k)/rhf(j))
phase = twopi*cyl(j)
vphi = -rhoamp*(avquad(j)*rhf(j)/rho(j,k))
end if
c
c Gaussian pulse
c
jpulse = 0
if(jpulse.eq.1) then
xpulse = 268 ! 0.321
xwidth = 6
xj = j
xk = k
gaussian = ((xj-xpulse)/xwidth)**2
rhoamp = exp(-gaussian)
gaussian = ((xk-2)/xwidth)**2
rhoamp = rhoamp*exp(-gaussian)
phase = twopi/8.0
end if
c
c Wave train
c
jwave = 0
if(jwave.eq.1) then
xpulse = 61
xwidth = 10
xlambda = 10.0
xfreq = 2.0*acos(-1.0)/100.0
xj = j
xk = k
gaussian = exp(-((xj-xpulse)/xwidth)**2)
rhoamp = gaussian*cos(2.0*acos(-1.0)*(xj-xpulse)/xlambda)
phase = twopi/8.0
end if
weight1 = cos(phase)
weight2 = sin(phase)
ee(1,j,k) = rhoamp * weight1
ee(2,j,k) = rhoamp * weight2
ee(3,j,k) = vamp * weight1
ee(4,j,k) = vamp * weight2
ee(5,j,k) = vphi * weight1
ee(6,j,k) = vphi * weight2
ee(7,j,k) = vamp * weight1
ee(8,j,k) = vamp * weight2
2000 continue
c.....boundary conditions
call boundary(jrhomax)
end if
c....center-of-mass and momentum conservation
call angquad
xc = 0.0
yc = 0.0
vxc = 0.0
vyc = 0.0
do j = jin(2),jout(2)
rdr = rhf(j)*(r(j+1)-r(j))
do k = 2,kmax1
if(rho(j,k).le.0.0) go to 9100
volc = twopi*rdr*(z(k+1)-z(k))
xc = xc+ee(1,j,k)*rhf(j)*volc
yc = yc+ee(2,j,k)*rhf(j)*volc
vxc = vxc+ee(1,j,k)*avquad(j)*rhf(j)*volc
vyc = vyc+ee(2,j,k)*avquad(j)*rhf(j)*volc
9100 continue
end do
end do
c
starq(1,1)=xc
starq(1,2)=yc
starq(2,1)=-vyc/starm
starq(2,2)=+vxc/starm
c
c
return
end
subroutine evolve(m_leg,scale,jrhomax,koji,jomegamax,angpow)
c
c ********************************************
c * *
c * solves Initial Value Problem (IVP) *
c * *
c ********************************************
c
implicit real*8 (a-h,o-z)
include 'param.h'
c
common/bfss4/rad,starm,pindex,jout(kmax2),jin(kmax2),ktop(jmax2)
common/bfss5/rho(jmax2,kmax2),drhor(jmax2,kmax2),
1 drhoz(jmax2,kmax2),angmo(jmax2)
common/bfss7/avquad(jmax2),davquad(jmax2)
common/poten2/delphi(2,jmax2,kmax2)
common/ivp1/time,dt,cc(15,jmax2,kmax2),ee(neq,jmax2,kmax2)
common/contour/kcontour(jmax2,10)
common/tstep/max_steps
c potential solver common blocks
common/blok6/dtheta,cosign(lmax),sign(lmax),pi,grav
common/inside/tmass,enew,elost,edif,phichk,klocat
common/pois/phi3d(jmax2,kmax2,lmax)
common/grid/r(jmax2),z(kmax2),rhf(jmax1),zhf(kmax1),
1 g(jmax2),h(kmax2)
common/stardelta/starq(2,2),starphi(2,jmax2,kmax2)
common/stardelta1/starold(2,2),deltastar(2,2)
c
dimension dqdr(neq),dedt(neq,jmax2,kmax2),eeold(neq,jmax2,kmax2),
1 delee(neq,jmax2,kmax2),rk(4),rt(4)
dimension star_step(2,2)
c
c...Fourth-order Runge-Kutta coefficients
c
data rk/0.16666667,0.3333333,0.3333333,0.16666667/
data rt/0.5,0.5,1.0,1.0/
c
pi = acos(-1.0)
twopi = 2.0*pi
raddeg = 360.0/twopi
c
c...time step controls
c
dt = 0.00002 * scale
tmin = 5.0e-04 * scale
tmax = 0.010 * scale
do 3000 m_s = 1 , max_steps
c.....initialize work arrays
do i = 1 , neq
do j = 1 , jmax2
do k = 1 , kmax2
delee(i,j,k) = 0.0
eeold(i,j,k) = ee(i,j,k)
end do
end do
end do
do j = 1 , 2
do k = 1 , 2
star_step(j,k) = 0.0
starold(j,k) = starq(j,k)
end do
end do
do 2000 n_rk = 1 , 4
c.....boundary conditions
call boundary(jrhomax)
c.....perturbed gravitational potential
call potcal(2,m_leg,koji)
c.....time derivatives