8 REAL*8 rsave(3,nmax),vsave(3,nmax),bsave(nmax)
9 real*8 g, m_sun, r_sun, pc, km, kmps
10 real*8 mscale, lscale, vscale
11 SAVE rsave,vsave,bsave
22 READ (5,*) q, vxrot, vzrot, rtide, smax
35 zmass = zmass + body(i)
37 cmr(k) = cmr(k) + body(i)*x(k,i)
38 cmrdot(k) = cmrdot(k) + body(i)*xdot(k,i)
45 x(k,i) = x(k,i) - cmr(k)/zmass
46 xdot(k,i) = xdot(k,i) - cmrdot(k)/zmass
53 READ (5,*) semi, ecc, body1, body2
55 body(1) = (body1 + body2)/zmbar
74 DO 42 i = nbh0+1,ilast
75 READ (5,*) body(i), (x(k,i),k=1,3), (xdot(k,i),k=1,3)
76 body(i) = body(i)/zmbar
84 IF ((kz(22).EQ.4.OR.kz(22).EQ.-1).AND.(nbin0.GT.0))
THEN
90 vsave(k,i) = xdot(k,i)
103 x(k,i) = (b1*x(k,i1) + b2*x(k,i2))/zmb
104 xdot(k,i) = (b1*xdot(k,i1) +
113 body(nbin0+i) = body(2*nbin0+i)
115 x(k,nbin0+i) = x(k,2*nbin0+i)
116 xdot(k,nbin0+i) = xdot(k,2*nbin0+i)
124 491
format (/,12x,
'SCALE: ', i5,
125 &
' Binaries converted to barycentres')
131 IF (kz(22).GT.2.OR.kz(22).EQ.-1.OR.kz(5).EQ.3) go to 52
135 body(i) = body(i)/zmass
143 if (kz(22).EQ.-1)
then
152 zkin = zkin*km**2/pc**2
155 IF (eph.GT.0.0) eph = -eph
158 lscale = g*mscale**2*(-0.25/eph)
159 vscale = sqrt(g*mscale/lscale)*(pc/km)
162 zmbar = zmass/(n+nbin0)
164 write (6,53) mscale, lscale, vscale
165 53
format (/,12x,
'SCALE: Conversion factors: MSCALE = ',f10.3,
166 &
' M_sun; LSCALE = ',f6.3,
' pc; VSCALE = ',
171 IF (kz(14).GT.0)
THEN
174 az = az + body(i)*(x(1,i)*xdot(2,i) - x(2,i)*xdot(1,i))
176 IF (kz(14).EQ.1)
THEN
178 vir = pot - 2.0*(etide + 0.5*tidal(4)*az)
180 vir = pot - 2.0*etide
187 IF (kz(22).EQ.3.OR.kz(5).EQ.2.OR.kz(5).EQ.3)
THEN
188 qv = sqrt(q*vir/zkin)
189 e0 = zkin*qv**2 - pot + etide
196 xdot(k,i) = xdot(k,i)*qv
197 zkin = zkin + 0.5*body(i)*xdot(k,i)**2
200 e0 = zkin - pot + etide
202 WRITE (6,59) e0, zkin/pot
203 59
FORMAT (/,12x,
'UNSCALED ENERGY E =',f10.6,
206 IF (kz(5).EQ.3) e0 = zkin - pot
208 54
FORMAT (/,12x,
'UNSCALED ENERGY E =',f10.6)
210 ELSE IF(kz(22).NE.-1)
THEN
212 IF (zkin.GT.0.0d0)
THEN
213 qv = sqrt(q*vir/zkin)
216 xdot(k,i) = xdot(k,i)*qv
226 IF (kz(29).GT.0.AND.q.GT.1.0) e0 = 0.25
228 etot = zkin*qv**2 - pot + etide
236 WRITE (6,65) sx, etot, body(1), body(n), zmass/float(n)
237 65
FORMAT (/,12x,
'SCALING: SX =',f6.2,
' E =',1pe10.2,
238 &
' M(1) =',e9.2,
' M(N) =',e9.2,
' <M> =',e9.2)
244 xdot(k,i) = xdot(k,i)*sqrt(sx)
254 IF ((kz(22).EQ.4.OR.kz(22).EQ.-1).AND.(nbin0.GT.0))
THEN
259 body(l2+i) = body(l1+i)
261 x(k,l2+i) = x(k,l1+i)
262 xdot(k,l2+i) = xdot(k,l1+i)
268 body(2*ip-1) = bsave(2*ip-1)
269 body(2*ip) = bsave(2*ip)
270 zmb = body(2*ip-1) + body(2*ip)
273 xrel = rsave(k,2*ip-1) - rsave(k,2*ip)
274 vrel = vsave(k,2*ip-1) - vsave(k,2*ip)
278 x(k,2*ip-1) = x(k,ip) + bsave(2*ip)*xrel/zmb
279 x(k,2*ip) = x1 - bsave(2*ip-1)*xrel/zmb
280 xdot(k,2*ip-1) = xdot(k,ip) + bsave(2*ip)*vrel/zmb
281 xdot(k,2*ip) = v1 - bsave(2*ip-1)*vrel/zmb
290 741
format (/,12x,
'SCALE: ', i5,
' Binaries restored')
294 if (kz(22).EQ.-1)
then
298 body(i) = body(i)/mscale
299 zmass = zmass + body(i)
301 x(k,i) = x(k,i)/lscale
302 xdot(k,i) = xdot(k,i)/vscale
308 write (6,745) zkin - pot
309 745
format (/,12x,
'SCALE: Scaled total energy: ',f8.5)
313 zkin = zcm/(mscale*vscale**2)
314 pot = pcm*lscale/mscale**2
317 746
format (/,12x,
'SCALE: Scaled C.M. energy: ',f8.5)
321 IF (kz(11).GT.0)
THEN
322 IF (semi.GT.0.0)
THEN
325 body(1) = body1/(body1 + body2)*zmb
326 body(2) = body2/(body1 + body2)*zmb
327 rap = semi*(1.0 + ecc)
328 vap = sqrt(zmb*(1.0 - ecc)/(semi*(1.0 + ecc)))
330 x(1,2) = x(1,1) - body(1)*rap/zmb
331 x(1,1) = x(1,1) + body(2)*rap/zmb
332 xdot(2,2) = xdot(2,1) - body(1)*vap/zmb
333 xdot(2,1) = xdot(2,1) + body(2)*vap/zmb
342 WRITE (6,76) body(i), (x(k,i),k=1,3), (xdot(k,i),k=1,3)
343 76
FORMAT (12x,
'BH COMPONENTS M X XDOT ',
344 & 1p,e10.2,0p,2(2x,3f7.3))
349 IF (vxrot.GT.0.0d0)
THEN
352 omega = -sx*sqrt(zmass*sx)
353 WRITE (6,78) vxrot, vzrot, omega
354 78
FORMAT (/,12x,
'VXROT =',f6.2,
' VZROT =',f6.2,
359 xdot(1,i) = xdot(1,i)*vxrot - x(2,i)*omega
360 xdot(2,i) = xdot(2,i)*vxrot + x(1,i)*omega
361 xdot(3,i) = xdot(3,i)*vzrot
366 IF (kz(22).EQ.1)
THEN
368 WRITE (10,84) body(i), (x(k,i),k=1,3), (xdot(k,i),k=1,3)
369 84
FORMAT (1p,7e14.6)
374 IF (kz(22).EQ.-1.OR.kz(22).EQ.5)
THEN
376 write (99,84) body(i)*mscale, (x(k,i)*lscale,k=1,3),
377 & (xdot(k,i)*vscale,k=1,3)
382 IF (kz(24).GT.0)
THEN
385 READ (5,*) body(i), (x(j,i),j=1,3), (xdot(j,i),j=1,3)
386 body(i) = body(i)/(zmbar*float(n))
391 tcr = zmass**2.5/(2.0d0*abs(e0))**1.5
395 rscale = 0.5*zmass**2/pot
397 rsph2 = (rsph2*rscale)**2
399 vc = sqrt(2.0d0*abs(e0)/zmass)
408 trh = 4.0*twopi/3.0*(vc*rscale)**3/(15.4*zmass**2*log(a1)/a1)
409 WRITE (6,95) trh, tcr, 2.0*rscale/vc, smax
410 95
FORMAT (/,12x,
'TIME SCALES: TRH =',1p,e8.1,
' TCR =',0p,f6.2,
411 &
' 2<R>/<V> =',f6.2,
' SMAX =',f7.3,/)