4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
11 * Copyright (c) 1991-2001, University of Groningen, The Netherlands
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * If you want to redistribute modifications, please consider that
18 * scientific software is very special. Version control is crucial -
19 * bugs must be traceable. We will be happy to consider code for
20 * inclusion in the official distribution, but derived work must not
21 * be called official GROMACS. Details are found in the README & COPYING
22 * files - if they are missing, get the official version at www.gromacs.org.
24 * To help us fund GROMACS development, we humbly ask that you cite
25 * the papers on the package - you can find them in the top README file.
27 * For more info, check our website at http://www.gromacs.org
30 * Getting the Right Output Means no Artefacts in Calculating Stuff
32 static char *SRCID_clincs_c
= "$Id$";
39 void clincsp(rvec
*x
,rvec
*f
,rvec
*fp
,int ncons
,
40 int *bla1
,int *bla2
,int *blnr
,int *blbnb
,
41 real
*blc
,real
*blcc
,real
*blm
,
42 int nrec
,real
*invmass
,rvec
*r
,
43 real
*rhs1
,real
*rhs2
,real
*sol
)
46 real tmp0
,tmp1
,tmp2
,im1
,im2
,mvb
,rlen
,len
,wfac
,lam
;
47 real u0
,u1
,u2
,v0
,v1
,v2
;
50 /* Compute normalized i-j vectors */
51 for(b
=0;b
<ncons
;b
++) {
57 rlen
=invsqrt(tmp0
*tmp0
+tmp1
*tmp1
+tmp2
*tmp2
);
61 } /* 16 ncons flops */
63 for(b
=0;b
<ncons
;b
++) {
69 for(n
=blnr
[b
];n
<blnr
[b
+1];n
++) {
71 blm
[n
]=blcc
[n
]*(tmp0
*r
[k
][0]+tmp1
*r
[k
][1]+tmp2
*r
[k
][2]);
73 mvb
=blc
[b
]*(tmp0
*(f
[i
][0]-f
[j
][0])+
74 tmp1
*(f
[i
][1]-f
[j
][1])+
75 tmp2
*(f
[i
][2]-f
[j
][2]));
80 /* Together: 23*ncons + 6*nrtot flops */
83 for(rec
=0;rec
<nrec
;rec
++) {
84 for(b
=0;b
<ncons
;b
++) {
86 for(n
=blnr
[b
];n
<blnr
[b
+1];n
++) {
88 mvb
=mvb
+blm
[n
]*rhs1
[j
];
96 } /* nrec*(ncons+2*nrtot) flops */
98 for(b
=0;b
<ncons
;b
++) {
107 u0
=fp
[i
][0]-tmp0
*im1
;
108 u1
=fp
[i
][1]-tmp1
*im1
;
109 u2
=fp
[i
][2]-tmp2
*im1
;
110 v0
=fp
[j
][0]+tmp0
*im2
;
111 v1
=fp
[j
][1]+tmp1
*im2
;
112 v2
=fp
[j
][2]+tmp2
*im2
;
119 } /* 16 ncons flops */
122 void clincs(rvec
*x
,rvec
*xp
,int ncons
,
123 int *bla1
,int *bla2
,int *blnr
,int *blbnb
,real
*bllen
,
124 real
*blc
,real
*blcc
,real
*blm
,
125 int nit
,int nrec
,real
*invmass
,rvec
*r
,
126 real
*rhs1
,real
*rhs2
,real
*sol
,real wangle
,int *warn
,
129 int b
,i
,j
,k
,n
,it
,rec
;
130 real tmp0
,tmp1
,tmp2
,im1
,im2
,mvb
,rlen
,len
,wfac
,lam
;
131 real u0
,u1
,u2
,v0
,v1
,v2
;
136 /* Compute normalized i-j vectors */
137 for(b
=0;b
<ncons
;b
++) {
140 tmp0
=x
[i
][0]-x
[j
][0];
141 tmp1
=x
[i
][1]-x
[j
][1];
142 tmp2
=x
[i
][2]-x
[j
][2];
143 rlen
=invsqrt(tmp0
*tmp0
+tmp1
*tmp1
+tmp2
*tmp2
);
147 } /* 16 ncons flops */
149 for(b
=0;b
<ncons
;b
++) {
156 for(n
=blnr
[b
];n
<blnr
[b
+1];n
++) {
158 blm
[n
]=blcc
[n
]*(tmp0
*r
[k
][0]+tmp1
*r
[k
][1]+tmp2
*r
[k
][2]);
160 mvb
=blc
[b
]*(tmp0
*(xp
[i
][0]-xp
[j
][0])+
161 tmp1
*(xp
[i
][1]-xp
[j
][1])+
162 tmp2
*(xp
[i
][2]-xp
[j
][2])-len
);
167 /* Together: 24*ncons + 6*nrtot flops */
170 for(rec
=0;rec
<nrec
;rec
++) {
171 for(b
=0;b
<ncons
;b
++) {
173 for(n
=blnr
[b
];n
<blnr
[b
+1];n
++) {
175 mvb
=mvb
+blm
[n
]*rhs1
[j
];
183 } /* nrec*(ncons+2*nrtot) flops */
185 for(b
=0;b
<ncons
;b
++) {
195 u0
=xp
[i
][0]-tmp0
*im1
;
196 u1
=xp
[i
][1]-tmp1
*im1
;
197 u2
=xp
[i
][2]-tmp2
*im1
;
198 v0
=xp
[j
][0]+tmp0
*im2
;
199 v1
=xp
[j
][1]+tmp1
*im2
;
200 v2
=xp
[j
][2]+tmp2
*im2
;
207 } /* 16 ncons flops */
212 ******** Correction for centripetal effects ********
215 wfac
=cos(DEG2RAD
*wangle
);
218 for(it
=0; it
<nit
; it
++) {
220 for(b
=0;b
<ncons
;b
++) {
224 tmp0
=xp
[i
][0]-xp
[j
][0];
225 tmp1
=xp
[i
][1]-xp
[j
][1];
226 tmp2
=xp
[i
][2]-xp
[j
][2];
228 u0
=2.*u1
-(tmp0
*tmp0
+tmp1
*tmp1
+tmp2
*tmp2
);
229 if (u0
< wfac
*u1
) *warn
=b
;
231 mvb
=blc
[b
]*(len
-sqrt(u0
));
234 } /* 18*ncons flops */
236 for(rec
=0;rec
<nrec
;rec
++) {
237 for(b
=0;b
<ncons
;b
++) {
239 for(n
=blnr
[b
];n
<blnr
[b
+1];n
++) {
241 mvb
=mvb
+blm
[n
]*rhs1
[j
];
249 } /* nrec*(ncons+2*nrtot) flops */
251 for(b
=0;b
<ncons
;b
++) {
262 u0
=xp
[i
][0]-tmp0
*im1
;
263 u1
=xp
[i
][1]-tmp1
*im1
;
264 u2
=xp
[i
][2]-tmp2
*im1
;
265 v0
=xp
[j
][0]+tmp0
*im2
;
266 v1
=xp
[j
][1]+tmp1
*im2
;
267 v2
=xp
[j
][2]+tmp2
*im2
;
274 } /* 17 ncons flops */
275 } /* nit*ncons*(35+9*nrec) flops */
277 * 24*ncons + 6*nrtot + nrec*(ncons+2*nrtot)
278 * + nit * (18*ncons + nrec*(ncons+2*nrtot) + 17 ncons)
280 * (24+nrec)*ncons + (6+2*nrec)*nrtot
281 * + nit * ((35+nrec)*ncons + 2*nrec*nrtot)
283 * (59+nrec)*ncons + (6+4*nrec)*nrtot