4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1997
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://rugmd0.chem.rug.nl/~gmx
29 static char *SRCID_clincs_c
= "$Id$";
37 void clincs(rvec
*x
,rvec
*xp
,int ncons
,int ncm
,int cmax
,
38 int *bla1
,int *bla2
,int *blnr
,int *blbnb
,real
*bllen
,
39 real
*blc
,real
*blcc
,real
*blm
,
40 int nrec
,real
*invmass
,rvec
* r
,
41 real
*rhs1
,real
*rhs2
,real
*sol
,real wangle
,int *warn
,
44 int b
,i
,j
,k
,n
,b4
,rec
,nr
,n1
,nc4
;
45 real tmp0
,tmp1
,tmp2
,im1
,im2
,mvb
,rlen
,len
,wfac
,lam
;
46 real u0
,u1
,u2
,v0
,v1
,v2
;
53 /* Compute normalized i-j vectors */
54 for(b
=0;b
<ncons
;b
++) {
60 rlen
=invsqrt(tmp0
*tmp0
+tmp1
*tmp1
+tmp2
*tmp2
);
77 blm
[b4
+n
]=blcc
[b4
+n
]*(tmp0
*r
[k
][0]+tmp1
*r
[k
][1]+tmp2
*r
[k
][2]);
79 mvb
=blc
[b
]*(tmp0
*(xp
[i
][0]-xp
[j
][0])+
80 tmp1
*(xp
[i
][1]-xp
[j
][1])+
81 tmp2
*(xp
[i
][2]-xp
[j
][2])-len
);
86 for(b
=n1
;b
<ncons
;b
++) {
97 blm
[b4
+n
]=blcc
[b4
+n
]*(tmp0
*r
[k
][0]+tmp1
*r
[k
][1]+tmp2
*r
[k
][2]);
99 mvb
=blc
[b
]*(tmp0
*(xp
[i
][0]-xp
[j
][0])+
100 tmp1
*(xp
[i
][1]-xp
[j
][1])+
101 tmp2
*(xp
[i
][2]-xp
[j
][2])-len
);
107 for(rec
=0;rec
<nrec
;rec
++) {
113 mvb
=mvb
+blm
[b4
+n
]*rhs1
[j
];
118 for(b
=n1
;b
<ncons
;b
++) {
124 mvb
=mvb
+blm
[b4
+n
]*rhs1
[j
];
134 for(b
=0;b
<ncons
;b
++) {
144 u0
=xp
[i
][0]-tmp0
*im1
;
145 u1
=xp
[i
][1]-tmp1
*im1
;
146 u2
=xp
[i
][2]-tmp2
*im1
;
147 v0
=xp
[j
][0]+tmp0
*im2
;
148 v1
=xp
[j
][1]+tmp1
*im2
;
149 v2
=xp
[j
][2]+tmp2
*im2
;
161 ******** Correction for centripetal effects ********
164 wfac
=cos(DEG2RAD
*wangle
);
167 for(b
=0;b
<ncons
;b
++) {
171 tmp0
=xp
[i
][0]-xp
[j
][0];
172 tmp1
=xp
[i
][1]-xp
[j
][1];
173 tmp2
=xp
[i
][2]-xp
[j
][2];
175 u0
=2.*u1
-(tmp0
*tmp0
+tmp1
*tmp1
+tmp2
*tmp2
);
176 if (u0
< wfac
*u1
) *warn
=b
;
178 mvb
=blc
[b
]*(len
-sqrt(u0
));
183 for(rec
=0;rec
<nrec
;rec
++) {
189 mvb
=mvb
+blm
[b4
+n
]*rhs1
[j
];
194 for(b
=n1
;b
<ncons
;b
++) {
200 mvb
=mvb
+blm
[b4
+n
]*rhs1
[j
];
210 for(b
=0;b
<ncons
;b
++) {
221 u0
=xp
[i
][0]-tmp0
*im1
;
222 u1
=xp
[i
][1]-tmp1
*im1
;
223 u2
=xp
[i
][2]-tmp2
*im1
;
224 v0
=xp
[j
][0]+tmp0
*im2
;
225 v1
=xp
[j
][1]+tmp1
*im2
;
226 v2
=xp
[j
][2]+tmp2
*im2
;