Nbody6
chpot.f
Go to the documentation of this file.
1  SUBROUTINE chpot(DP)
2 *
3 *
4 * Potential energy correction due to chain.
5 * -----------------------------------------
6 *
7  include 'common6.h'
8  common/chainc/ xc(3,ncmax),uc(3,ncmax),bodyc(ncmax),ich,
9  & listc(lmax)
10 *
11 *
12 * Obtain current global coordinates of chain components.
13  CALL xcpred(0)
14 *
15 * Consider contributions from all active perturbers.
16  dp = 0.0d0
17  jdum = 0
18  nnbc = listc(1) + 1
19 *
20  DO 10 l = 2,nnbc
21 * Subtract potential energy due to chain c.m.
22  j = listc(l)
23 * Replace any regularized c.m. body by individual components.
24  IF (j.GT.n) THEN
25  jdum = 2*(j - n) - 1
26  j = jdum
27  END IF
28  2 a1 = x(1,ich) - x(1,j)
29  a2 = x(2,ich) - x(2,j)
30  a3 = x(3,ich) - x(3,j)
31  rij2 = a1*a1 + a2*a2 + a3*a3
32  dp = dp - body(ich)*body(j)/sqrt(rij2)
33 *
34 * Add individual interactions to obtain differential correction.
35  DO 5 k = 1,nch
36  a1 = xc(1,k) - x(1,j)
37  a2 = xc(2,k) - x(2,j)
38  a3 = xc(3,k) - x(3,j)
39  rij2 = a1*a1 + a2*a2 + a3*a3
40  dp = dp + bodyc(k)*body(j)/sqrt(rij2)
41  5 CONTINUE
42 *
43 * Check for possible second KS component and restore dummy index.
44  IF (j.EQ.jdum) THEN
45  j = jdum + 1
46  jdum = 0
47  go to 2
48  END IF
49  10 CONTINUE
50 *
51  RETURN
52 *
53  END