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 * Green Red Orange Magenta Azure Cyan Skyblue
29 static char *SRCID_do_fit_c
= "$Id$";
40 real
rmsdev_ind(int nind
,atom_id index
[],real mass
[],rvec x
[],rvec xp
[])
47 for(j
=0; j
<nind
; j
++) {
51 sqd
+= mass
[i
]*(x
[i
][m
]-xp
[i
][m
])*(x
[i
][m
]-xp
[i
][m
]);
54 return sqrt(sqd
/totmass
);
57 real
rmsdev(int natoms
,real mass
[],rvec x
[],rvec xp
[])
64 for(i
=0; i
<natoms
; i
++) {
67 sqd
+= mass
[i
]*(x
[i
][m
]-xp
[i
][m
])*(x
[i
][m
]-xp
[i
][m
]);
70 return sqrt(sqd
/totmass
);
73 void do_fit(int natoms
,real
*w_rls
,rvec
*xp
,rvec
*x
)
76 double omega
[7][7],om
[7][7],d
[7],xnr
,xpc
;
79 matrix vh,vk,R,vh_d,vk_d,u;
94 /*calculate the matrix U*/
96 for(n
=0;(n
<natoms
);n
++) {
97 if ((mn
= w_rls
[n
]) != 0.0) {
98 for(c
=0; (c
<DIM
); c
++) {
100 for(r
=0; (r
<DIM
); r
++) {
109 /*omega is symmetric -> omega==omega' */
112 if ((r
>=3) && (c
<3)) {
113 omega
[r
+1][c
+1]=u
[r
-3][c
];
114 omega
[c
+1][r
+1]=u
[r
-3][c
];
121 /*determine h and k*/
122 jacobi(omega
,6,d
,om
,&irot
);
123 /*real **omega = input matrix a[1..n][1..n] must be symmetric
124 *int natoms = number of rows and columns
125 *real NULL = d[1]..d[n] are the eigenvalues of a[][]
126 *real **v = v[1..n][1..n] contains the vectors in columns
127 *int *irot = number of jacobi rotations
131 fprintf(stderr
,"IROT=0\n");
134 index
=0; /* For the compiler only */
136 /* Copy only the first two eigenvectors */
146 vh
[j
][i
]=M_SQRT2
*om
[i
+1][index
+1];
147 vk
[j
][i
]=M_SQRT2
*om
[i
+4][index
+1];
150 /* Calculate the last eigenvector as the outer-product of the first two.
151 * This insures that the conformation is not mirrored and
152 * prevents problems with completely flat reference structures.
154 oprod(vh
[0],vh
[1],vh
[2]);
155 oprod(vk
[0],vk
[1],vk
[2]);
160 R
[c
][r
]=vk
[0][r
]*vh
[0][c
]+
165 for(j
=0;(j
<natoms
);j
++) {
171 x
[j
][r
]+=R
[c
][r
]*x_old
[c
];
176 void reset_x(int ncm
,atom_id ind_cm
[],
177 int nrms
,atom_id ind_rms
[],
178 rvec x
[],real mass
[])
186 for(i
=0; (i
<ncm
); i
++) {
189 for(m
=0; (m
<DIM
); m
++)
193 for(m
=0; (m
<DIM
); m
++)
196 for(i
=0; (i
<nrms
); i
++)
197 rvec_dec(x
[ind_rms
[i
]],xcm
);