Nbody6
 All Files Functions Variables
hirect.f
Go to the documentation of this file.
1  SUBROUTINE hirect(IM)
2 *
3 *
4 * Rectification of hierarchical binary.
5 * -------------------------------------
6 *
7  include 'common6.h'
8  common/binary/ cm(4,mmax),xrel(3,mmax),vrel(3,mmax),
9  & hm(mmax),um(4,mmax),umdot(4,mmax),tmdis(mmax),
10  & namem(mmax),nameg(mmax),kstarm(mmax),iflagm(mmax)
11 *
12 *
13 * Include diagnostic error check.
14  rb = 0.0
15  upr2 = 0.0
16  td2 = 0.0
17  DO 5 k = 1,4
18  rb = rb + um(k,im)**2
19  upr2 = upr2 + umdot(k,im)**2
20  td2 = td2 + 2.0*um(k,im)*umdot(k,im)
21  5 CONTINUE
22 *
23  zmb = cm(1,im) + cm(2,im)
24  hi = (2.0*upr2 - zmb)/rb
25  err = (hi - hm(im))/hi
26  zmu = cm(1,im)*cm(2,im)/zmb
27  db = zmu*(hi - hm(im))
28  IF (abs(db).GT.1.0d-08) THEN
29  semi = -0.5*zmb/hm(im)
30  ecc2 = (1.0 - rb/semi)**2 + td2**2/(zmb*semi)
31  ecc = sqrt(ecc2)
32  ra = rb/semi
33  WRITE (16,3) ttot, nameg(im), kstarm(im), ecc, ra, hm(im), db, err
34  3 FORMAT (' HIRECT: T NM K* E R/A H DB DH/H ',
35  & f9.3,i6,i4,f8.4,f8.4,f9.2,1p,2e10.1)
36  CALL flush(16)
37  END IF
38 * Initialize iteration counter for difficult case (SJA 10/97).
39  iter = 0
40 *
41 * Form square regularized velocity for the explicit binding energy.
42  10 rb = 0.0d0
43  upr2 = 0.0
44  DO 15 k = 1,4
45  rb = rb + um(k,im)**2
46  upr2 = upr2 + umdot(k,im)**2
47  15 CONTINUE
48 *
49 * Form KS scaling factors from energy and angular momentum relation.
50  a1 = 0.25d0*zmb/upr2
51 * Solve for C1 from H = (2*U'*U'*C1**2 - M)/(U*U*C2**2) with C2 = 1/C1.
52  a2 = a1**2 + 0.5d0*hm(im)*rb/upr2
53 *
54 * Avoid negative round-off value on second try (NB! no change in CK).
55  IF (iter.EQ.2.AND.a2.LT.0.0) a2 = 0.0d0
56 *
57 * Check for undefined case (circular orbit or eccentric anomaly = 90).
58  IF (a2.GE.0.0d0) THEN
59  IF (a1.LT.1.0) THEN
60 * Choose square root sign from eccentric anomaly (e*cos(E) = 1 - R/a).
61  c1 = sqrt(a1 + sqrt(a2))
62  ELSE
63  c1 = sqrt(a1 - sqrt(a2))
64  END IF
65  ck = 1.0
66  ELSE
67 * Adopt C1*C2 = CK for difficult case (Seppo's suggestion of 1991).
68  c1 = 1.0
69  ck = zmb/sqrt(-8.0d0*hm(im)*rb*upr2)
70  WRITE (6,20) im, kstarm(im), rb, hm(im), upr2, a2, ck-1.0
71  20 FORMAT (' WARNING! HIRECT IM K* R H UPR2 A2 CK-1 ',
72  & 2i4,1p,5e10.2)
73  iter = iter + 1
74  END IF
75 *
76 * Specify KS coordinate scaling from angular momentum conservation.
77  c2 = ck/c1
78 *
79 * Transform KS variables to yield the prescribed elements.
80  DO 25 k = 1,4
81  um(k,im) = c2*um(k,im)
82  umdot(k,im) = c1*umdot(k,im)
83  25 CONTINUE
84 *
85 * Improve solution by second iteration in case of CK procedure.
86  iter = iter + 1
87  IF (iter.EQ.2) go to 10
88 *
89  RETURN
90 *
91  END