Nbody6
 All Files Functions Variables
nbpot.f
Go to the documentation of this file.
1  SUBROUTINE nbpot(NB,NP,POTS)
2 *
3 *
4 * Potential energy of subsystem.
5 * ------------------------------
6 *
7  include 'common6.h'
8 *
9 *
10 * Obtain potential energy of subsystem JLIST(NB) & JPERT(NP).
11  pots = 0.0d0
12  DO 10 l = 1,nb
13  i = jlist(l)
14  DO 5 k = 1,np
15  j = jpert(k)
16  IF (j.GT.n) THEN
17 * Skip outer binary c.m. or components during merger correction.
18  IF (j.EQ.i) go to 5
19  jp = j - n
20  IF (i.LT.ifirst) THEN
21  IF (jp.EQ.kvec(i)) go to 5
22  END IF
23 * Resolve c.m. of other perturbed KS pairs.
24  IF (list(1,2*jp-1).GT.0) THEN
25  j = 2*jp - 1
26  END IF
27  END IF
28  1 rij2 = (x(1,i) - x(1,j))**2 + (x(2,i) - x(2,j))**2 +
29  & (x(3,i) - x(3,j))**2
30  pots = pots + body(i)*body(j)/sqrt(rij2)
31 *
32 * Check for second component of perturbed KS pair.
33  IF (jpert(k).GT.n) THEN
34  IF (j.EQ.2*jp - 1) THEN
35  j = j + 1
36  go to 1
37  END IF
38  END IF
39  5 CONTINUE
40  10 CONTINUE
41 *
42 * Include any external potentials.
43  IF (kz(14).GT.0) THEN
44  DO 20 l = 1,nb
45  i = jlist(l)
46  CALL xtrnlv(i,i)
47  pots = pots - ht
48 * Note positive sign convention for potential energy.
49  20 CONTINUE
50  END IF
51 *
52  RETURN
53 *
54  END