Nbody6
 All Files Functions Variables
absorb.f
Go to the documentation of this file.
1  SUBROUTINE absorb(ISUB)
2 *
3 *
4 * Absorption of chain member(s).
5 * -----------------------------
6 *
7  include 'common6.h'
8  parameter(nmx=10,nmx3=3*nmx,nmx4=4*nmx,nmxm=nmx*(nmx-1)/2)
9  REAL*8 m,mass,mc,mij,mkk,xcm(3),vcm(3)
10  common/chain1/ xch(nmx3),vch(nmx3),m(nmx),
11  & zz(nmx3),wc(nmx3),mc(nmx),
12  & xi(nmx3),pi(nmx3),mass,rinv(nmxm),rsum,mkk(nmx),
13  & mij(nmx,nmx),tkk(nmx),tk1(nmx),iname(nmx),nn
14  common/chainc/ xc(3,ncmax),uc(3,ncmax),bodyc(ncmax),ich,
15  & listc(lmax)
16  common/chreg/ timec,tmax,rmaxc,cm(10),namec(6),nstep1,kz27,kz30
17  common/clump/ bodys(ncmax,5),t0s(5),ts(5),steps(5),rmaxs(5),
18  & names(ncmax,5),isys(5)
19  common/ccoll2/ qk(nmx4),pk(nmx4),rik(nmx,nmx),SIZE(nmx),vstar1,
20  & ecoll1,rcoll,qperi,istar(nmx),icoll,isync,ndiss1
21  common/incond/ x4(3,nmx),xdot4(3,nmx)
22 *
23 *
24 * Define discrete time for new polynomial (DT2 < 0 is OK).
25  dt2 = t0s(isub) + timec - tprev
26  dt8 = (tblock - tprev)/8.0d0
27 * Avoid zero since TBLOCK = TPREV during the first block-step.
28  IF (dt8.EQ.0.0d0) dt8 = step(ich)/8.0d0
29 *
30 * Adopt the nearest truncated step (at most 8 subdivisions).
31  IF (dt2.GT.0.0d0) THEN
32  CALL stepk(dt2,dtn2)
33  dtn = nint(dtn2/dt8)*dt8
34  ELSE
35 * Choose negative step if pericentre time < TPREV.
36  dt2 = -dt2
37  CALL stepk(dt2,dtn2)
38  dtn = -nint(dtn2/dt8)*dt8
39  END IF
40 *
41 * Update time for new polynomial initializations (but check T - T0).
42  time = tprev + dtn
43 *
44 * Avoid prediction skip by XVPRED in case TIME - T0 = 0.0.
45  IF (time - t0(ich).EQ.0.0d0) time = time + dt8/16.0d0
46 *
47 * Re-define initial epoch for consistency (ignore phase error).
48  t0s(isub) = time - timec
49 *
50  IF (kz(30).GT.2) THEN
51  WRITE (6,1) time+toff, dt2, dt8
52  1 FORMAT (' ABSORB: TIME DT2 DT8 ',f12.6,1p,2e10.2)
53  END IF
54 *
55 * Increase membership of chain (JCLOSE: single body or KS pair).
56  nch0 = nch
57  CALL setsys
58 *
59 * Improve coordinates & velocities of c.m. body to order F3DOT.
60  CALL xvpred(ich,-1)
61 *
62  sum = 0.0
63  DO 5 k = 1,3
64  xcm(k) = 0.0
65  vcm(k) = 0.0
66  5 CONTINUE
67 *
68 * Accumulate mass-weighted moments of absorbed particle(s).
69  DO 15 l = nch0+1,nch
70  j = jlist(l)
71  sum = sum + body(j)
72  DO 10 k = 1,3
73  xcm(k) = xcm(k) + body(j)*x(k,j)
74  vcm(k) = vcm(k) + body(j)*xdot(k,j)
75  10 CONTINUE
76  15 CONTINUE
77 *
78 * Form combined c.m. of old chain and new perturber(s).
79  DO 20 k = 1,3
80  xcm(k) = (body(ich)*x(k,ich) + xcm(k))/(body(ich) + sum)
81  vcm(k) = (body(ich)*xdot(k,ich) + vcm(k))/(body(ich) + sum)
82  20 CONTINUE
83 *
84 * Define new relative coordinates & velocities and add to chain.
85  lk = 3*nch0
86  DO 30 l = nch0+1,nch
87  j = jlist(l)
88  SIZE(l) = radius(j)
89  istar(l) = kstar(j)
90  rij2 = 0.0
91  DO 25 k = 1,3
92  lk = lk + 1
93  x4(k,l) = x(k,j) - xcm(k)
94  xdot4(k,l) = xdot(k,j) - vcm(k)
95  xch(lk) = x4(k,l)
96  vch(lk) = xdot4(k,l)
97  rij2 = rij2 + (x4(k,l) - x4(k,l-1))**2
98  25 CONTINUE
99 * Initialize new inverse distance(s) (some value needed in chpert.f).
100  rinv(l-1) = 1.0/sqrt(rij2)
101  30 CONTINUE
102 *
103 * Re-define old chain variables with respect to new c.m.
104  lk = 0
105  DO 40 l = 1,nch0
106  DO 35 k = 1,3
107  lk = lk + 1
108  xch(lk) = xch(lk) - (xcm(k) - x(k,ich))
109  vch(lk) = vch(lk) - (vcm(k) - xdot(k,ich))
110  35 CONTINUE
111  40 CONTINUE
112 *
113 * Create ghost particle(s) and remove from neighbour lists.
114  DO 50 l = nch0+1,nch
115  j = jlist(l)
116  CALL ghost(j)
117  50 CONTINUE
118 *
119 * Update total mass and initialize new c.m. body variables.
120  body(ich) = body(ich) + sum
121  cm(7) = body(ich)
122  t0(ich) = time
123  DO 60 k = 1,3
124  x(k,ich) = xcm(k)
125  x0(k,ich) = xcm(k)
126  xdot(k,ich) = vcm(k)
127  x0dot(k,ich) = vcm(k)
128  60 CONTINUE
129 *
130 * Remove ghost particle(s) from neighbour list of #ICH.
131  jpert(1) = ich
132  jlast = ntot + 1
133  DO 70 l = nch0+1,nch
134  jlist(1) = jlist(l)
135  CALL nbrem(jlast,1,1)
136  70 CONTINUE
137 *
138 * Perform re-initialization of c.m. polynomials & perturber list.
139  CALL reinit(isub)
140 *
141 * Check optional output for centre of mass condition.
142  IF (kz(30).GT.2) THEN
143  DO 80 k = 1,6
144  cm(k) = 0.0
145  80 CONTINUE
146 *
147  lk = 0
148  DO 90 l = 1,nch
149  DO 85 k = 1,3
150  lk = lk + 1
151  cm(k) = cm(k) + bodyc(l)*xch(lk)
152  cm(k+3) = cm(k+3) + bodyc(l)*vch(lk)
153  85 CONTINUE
154  90 CONTINUE
155 *
156  DO 95 k = 1,6
157  cm(k) = cm(k)/cm(7)
158  95 CONTINUE
159 *
160  WRITE (6,99) (cm(k),k=1,6)
161  99 FORMAT (' ABSORB: CM ',1p,6e9.1)
162  END IF
163 *
164  RETURN
165 *
166  END