4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
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://md.chem.rug.nl/~gmx
27 * GRowing Old MAkes el Chrono Sweat
29 static char *SRCID_cshake_c
= "$Id$";
41 void cshake(atom_id iatom
[],int ncon
,int *nnit
,int maxnit
,
42 real dist2
[],real xp
[],real rij
[],real m2
[],
43 real invmass
[],real tt
[],int *nerror
)
45 const real mytol
=1e-6;
48 int ix
,iy
,iz
,jx
,jy
,jz
;
49 real toler
,rpij2
,rrpr
,tx
,ty
,tz
,diff
,acor
,im
,jm
;
50 real xh
,yh
,zh
,rijx
,rijy
,rijz
;
53 int nit
,error
,iconv
,nconv
;
57 for (nit
=0; (nit
<maxnit
) && (nconv
!= 0) && (error
== 0); nit
++) {
59 for(ll
=0; (ll
<ncon
) && (error
== 0); ll
++) {
78 rpij2
= tx
*tx
+ty
*ty
+tz
*tz
;
82 /* iconv is zero when the error is smaller than a bound */
83 iconv
= fabs(diff
)*tt
[ll
];
86 nconv
= nconv
+ iconv
;
87 rrpr
= rijx
*tx
+rijy
*ty
+rijz
*tz
;
89 if (rrpr
< toler
*mytol
)
92 acor
= diff
*m2
[ll
]/rrpr
;
100 tiz
= xp
[iz
] + zh
*im
;
101 tjx
= xp
[jx
] - xh
*jm
;
102 tjy
= xp
[jy
] - yh
*jm
;
103 tjz
= xp
[jz
] - zh
*jm
;