3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
33 * Green Red Orange Magenta Azure Cyan Skyblue
44 #include "gmx_fatal.h"
55 void optimize(FILE *fp
,int nx
,t_propfunc
*f
,t_pinp
*p
)
62 for(i
=0; (i
<nx
); i
++) {
69 do_mc(fp
,nx
,fact
,p
->step
,p
->v0
,p
->tol
,p
->nsteps
,f
);
71 fprintf(fp
,"MC Done\n");
72 fprintf(fp
,"Components are:\n");
74 for(i
=0; (i
<nx
); i
++) {
75 fprintf(fp
,"EV %5d: Fac: %8.3f\n",i
,fact
[i
]);
78 fprintf(fp
,"Norm of vector: %8.3f\n",sqrt(sf
));
84 static int nca
,natoms
,nframes
;
85 static atom_id
*ca_index
;
87 real
risefunc(int nx
,real x
[])
89 static rvec
*xxx
=NULL
;
99 for(j
=0; (j
<nframes
); j
++) {
100 /* Make a structure, we only have to do Z */
101 for(i
=0; (i
<nca
); i
++) {
106 for(n
=0; (n
<nx
); n
++) {
107 /*cx+=EV[n][ai][XX]*x[n]*evprj[n][j];
108 cy+=EV[n][ai][YY]*x[n]*evprj[n][j];*/
109 cz
+=EV
[n
][ai
][ZZ
]*x
[n
]*evprj
[n
][j
];
115 rrr
= rise(nca
,ca_index
,xxx
);
120 rrr
=sqrt(rav2
/nframes
-rav
*rav
);
125 real
radfunc(int nx
,real x
[])
127 static rvec
*xxx
=NULL
;
137 for(j
=0; (j
<nframes
); j
++) {
138 /* Make a structure, we only have to do X & Y */
139 for(i
=0; (i
<nca
); i
++) {
144 for(n
=0; (n
<nx
); n
++) {
145 cx
+=EV
[n
][ai
][XX
]*x
[n
]*evprj
[n
][j
];
146 cy
+=EV
[n
][ai
][YY
]*x
[n
]*evprj
[n
][j
];
147 cz
+=EV
[n
][ai
][ZZ
]*x
[n
]*evprj
[n
][j
];
153 rrr
= radius(NULL
,nca
,ca_index
,xxx
);
158 rrr
=sqrt(rav2
/nframes
-rav
*rav
);
163 void init_optim(int nx
,rvec
*xxav
,rvec
**EEV
,
164 real
**eevprj
,int nnatoms
,
165 int nnca
,atom_id
*cca_index
,
172 nframes
= p
->nframes
;
174 ca_index
= cca_index
;
177 void optim_rise(int nx
,rvec
*xxav
,rvec
**EEV
,
178 real
**eevprj
,int nnatoms
,
179 int nnca
,atom_id
*cca_index
,
184 fp
= ffopen("rise.log","w");
185 init_optim(nx
,xxav
,EEV
,eevprj
,nnatoms
,nnca
,cca_index
,p
);
186 optimize(fp
,nx
,risefunc
,p
);
190 void optim_radius(int nx
,rvec
*xxav
,rvec
**EEV
,
191 real
**eevprj
,int nnatoms
,
192 int nnca
,atom_id
*cca_index
,
197 fp
= ffopen("radius.log","w");
199 init_optim(nx
,xxav
,EEV
,eevprj
,nnatoms
,nnca
,cca_index
,p
);
200 optimize(fp
,nx
,radfunc
,p
);