changed reading hint
[gromacs/adressmacs.git] / src / tools / virtual.c
blobd6127039ec63c8e0293bca66a2d3708219d3b8a1
1 /*
2 * $Id$
3 *
4 * This source code is part of
5 *
6 * G R O M A C S
7 *
8 * GROningen MAchine for Chemical Simulations
9 *
10 * VERSION 2.0
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
16 * Please refer to:
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
23 * or e-mail to:
24 * gromacs@chem.rug.nl
26 * And Hey:
27 * Great Red Oystrich Makes All Chemists Sane
29 static char *SRCID_virtual_c = "$Id$";
31 int set_virtual (int *ATMS,int N,real margin,t_dist *d,int natoms)
33 /* Routine to add distances to virtual particle.
34 The virtual particle is placed 10A outside
35 the plane common to all atoms, straight above
36 the center of mass, which is calculated assuming
37 unit mass for all atoms.
39 Adam Kirrander 990211 */
41 int ndist=0,i,j;
42 real CONST=0.0,Ki,tmp,len,lb,ub;
44 /* Calculate the constant part */
45 for (i=1 ; i<N ; i++ ) {
46 for (j=0 ; j<i ; j++) {
47 tmp = d_len(d,natoms,ATMS[i],ATMS[j]);
48 CONST += tmp*tmp;
51 CONST = CONST/N;
53 /* Calculate and set distances */
54 for (i=0 ; i<N ; i++ ) {
55 Ki = 0.0;
56 for (j=0 ; j<N ; j++) { /*Calc. variable part*/
57 if (i == j) continue;
58 tmp = d_len(d,natoms,ATMS[i],ATMS[j]);
59 Ki += tmp*tmp;
61 len = sqrt(64.0+((Ki-CONST)/N)); /*Pythagoras*/
62 lb = (1.0-margin)*len;
63 ub = (1.0+margin)*len;
64 set_dist(d,natoms,ATMS[i],ATMS[N],lb,ub,len);
65 ndist++;
68 /* If number of virtual dist. should correspond to nr. atoms */
69 if (ndist != N) fprintf(stderr,"Check routine set_virtual!\n");
71 return ndist;