Nbody6
 All Files Functions Variables
kslist.f
Go to the documentation of this file.
1  SUBROUTINE kslist(IPAIR)
2 *
3 *
4 * KS perturber selection.
5 * -----------------------
6 *
7  include 'common6.h'
8 *
9 *
10 * Set component & c.m. index and form semi-major axis & eccentricity.
11  i1 = 2*ipair - 1
12  i = n + ipair
13  semi = -0.5d0*body(i)/h(ipair)
14  eb = -0.5*body(i1)*body(i1+1)/semi
15  ecc2 = (1.0 - r(ipair)/semi)**2 + tdot2(ipair)**2/(body(i)*semi)
16  ecc = sqrt(ecc2)
17  it = 0
18 *
19 * Use semi-major axis and/or RMIN for perturber selection.
20  IF (eb.LT.ebh) THEN
21  rap = semi*(1.0 + ecc)
22  ELSE
23 * Include a tapered criterion depending on energy for soft binaries.
24  IF (eb.LT.0.0) THEN
25  zfac = 1.0 + abs(eb - ebh)/abs(ebh)
26  ELSE
27  zfac = 1.0
28  END IF
29 * Adopt actual apocentre for perturber selection if R > SEMI.
30  IF (semi.GT.0.0d0.AND.r(ipair).GT.semi) THEN
31  rap = semi*(1.0 + ecc)
32  ELSE
33 * Accept separation limit for hyperbolic cases.
34  rap = max(zfac*semi,r(ipair))
35  END IF
36 * Ensure extra perturbers at new regularizations (R may be small).
37  IF (iphase.GT.0.AND.semi.GT.0.0) THEN
38  rap = semi*(1.0 + ecc)
39  END IF
40  END IF
41 *
42 * Restrict perturber selection for massive eccentric binary.
43  IF (body(i).GT.100.0*bodym.AND.
44  & (r(ipair).LT.0.1*semi.OR.semi.LT.0)) THEN
45  rap = min(rmin,0.1*abs(semi))
46  END IF
47 *
48  rcrit2 = 2.0*rap**2/body(i)
49  rcrit3 = rcrit2*rap/gmin
50 * Base fast search on maximum binary mass (BODY1).
51  rcrit2 = rcrit2*body1*cmsep2
52 *
53 * Select new perturbers from the neighbour list.
54  6 nnb1 = 1
55  nnb2 = list(1,i) + 1
56  DO 10 l = 2,nnb2
57  j = list(l,i)
58  w1 = x(1,j) - x(1,i)
59  w2 = x(2,j) - x(2,i)
60  w3 = x(3,j) - x(3,i)
61  rsep2 = w1*w1 + w2*w2 + w3*w3
62 * Include any merged c.m. or chain c.m. bodies in the fast test.
63  IF (rsep2.LT.rcrit2.OR.name(j).LE.0) THEN
64  rij3 = rsep2*sqrt(rsep2)
65 * Estimate unperturbed distance from tidal limit approximation.
66  IF (rij3.LT.body(j)*rcrit3) THEN
67  nnb1 = nnb1 + 1
68  list(nnb1,i1) = j
69  ELSE IF (j.GT.n) THEN
70 * Employ a more generous criterion for possible wide binary.
71  rj = min(10.0*abs(semi),-body(j)/h(j-n))
72  IF (rsep2.LT.cmsep2*rj**2) THEN
73  nnb1 = nnb1 + 1
74  list(nnb1,i1) = j
75  END IF
76  END IF
77  END IF
78  10 CONTINUE
79 *
80 * Ensure at least one perturber first time (max 5 tries except CHAOS).
81  IF (nnb1.EQ.1.AND.iphase.GT.0.AND.nnb2.GT.1.AND.time.GT.0.0) THEN
82  rcrit2 = 2.0*rcrit2
83  rcrit3 = 2.0*rcrit3
84  it = it + 1
85 * Skip repeat for small size (next KSLIST requires many periods).
86  IF ((semi*su.GT.10.0.AND.it.LE.5).OR.kstar(i).EQ.-1) go to 6
87  END IF
88 *
89 * Check case of no perturbers (dual purpose).
90  IF (nnb1.EQ.1) THEN
91 * Add distant perturber for hyperbolic orbit.
92  IF (semi.LT.0.0) THEN
93  nnb1 = 2
94  list(2,i1) = list(2,i)
95  go to 20
96  END IF
97 * ELSE IF (KZ(27).LE.0) THEN
98  IF (kz(27).LE.0) THEN
99 * Specify one unperturbed period at apocentre (NB! check STEP(I)).
100  step(i1) = twopi*semi*sqrt(semi/body(i))
101  step(i1) = min(step(i1),step(i))
102  ELSE
103 * Maintain perturbed motion during Chaos event (not ROCHE/SPIRAL).
104  IF (kstar(i).EQ.-1) THEN
105  IF (list(1,i1).GT.0) THEN
106  nnb1 = 2
107  list(2,i1) = n
108  END IF
109  ELSE
110  step(i1) = twopi*semi*sqrt(semi/body(i))
111  step(i1) = min(step(i1),step(i))
112  END IF
113  END IF
114  END IF
115 *
116 * Save perturber membership.
117  20 list(1,i1) = nnb1 - 1
118 *
119  RETURN
120 *
121  END