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_g_gyrate_c
= "$Id$";
51 real
calc_gyro(rvec x
[],int gnx
,atom_id index
[],t_atom atom
[],real tm
,
52 rvec gvec
,rvec d
,bool bQ
,bool bRot
)
60 principal_comp(gnx
,index
,atom
,x
,trans
,d
);
61 for(m
=0; (m
<DIM
); m
++)
64 pr_rvecs(stderr
,0,"trans",trans
,DIM
);
66 /* rotate_atoms(gnx,index,x,trans); */
69 for(i
=0; (i
<gnx
); i
++) {
75 for(m
=0; (m
<DIM
); m
++) {
76 dx2
=x
[ii
][m
]*x
[ii
][m
];
80 gyro
=comp
[XX
]+comp
[YY
]+comp
[ZZ
];
82 for(m
=0; (m
<DIM
); m
++)
83 gvec
[m
]=sqrt((gyro
-comp
[m
])/tm
);
88 int main(int argc
,char *argv
[])
90 static char *desc
[] = {
91 "g_gyrate computes the radius of gyration of a group of atoms",
92 "and the radii of gyration about the x, y and z axes,"
93 "as a function of time. The atoms are explicitly mass weighted."
95 static bool bQ
=FALSE
,bRot
=FALSE
;
97 { "-q", FALSE
, etBOOL
, {&bQ
},
98 "Use absolute value of the charge of an atom as weighting factor instead of mass" },
99 { "-p", FALSE
, etBOOL
, {&bRot
},
100 "Calculate the radii of gyration about the principal axes." }
107 rvec d
; /* eigenvalues of inertia tensor */
111 char *grpname
,title
[256];
114 char *leg
[] = { "Rg", "RgX", "RgY", "RgZ" };
115 #define NLEG asize(leg)
117 { efTRX
, "-f", NULL
, ffREAD
},
118 { efTPS
, NULL
, NULL
, ffREAD
},
119 { efXVG
, NULL
, "gyrate", ffWRITE
},
120 { efNDX
, NULL
, NULL
, ffOPTRD
}
122 #define NFILE asize(fnm)
124 CopyRight(stderr
,argv
[0]);
125 parse_common_args(&argc
,argv
,PCA_CAN_TIME
| PCA_CAN_VIEW
,TRUE
,
126 NFILE
,fnm
,asize(pa
),pa
,asize(desc
),desc
,0,NULL
);
129 for(i
=1; (i
<argc
); i
++) {
130 if (strcmp(argv
[i
],"-q") == 0) {
132 fprintf(stderr
,"Will print radius normalised by charge\n");
134 else if (strcmp(argv
[i
],"-r") == 0) {
136 fprintf(stderr
,"Will rotate system along principal axes\n");
139 read_tps_conf(ftp2fn(efTPS
,NFILE
,fnm
),title
,&top
,&x
,NULL
,box
,TRUE
);
140 get_index(&top
.atoms
,ftp2fn_null(efNDX
,NFILE
,fnm
),1,&gnx
,&index
,&grpname
);
142 natoms
=read_first_x(&status
,ftp2fn(efTRX
,NFILE
,fnm
),&t
,&x
,box
);
147 out
=xvgropen(ftp2fn(efXVG
,NFILE
,fnm
),
148 "Radius of Charge","Time (ps)","Rg (nm)");
150 out
=xvgropen(ftp2fn(efXVG
,NFILE
,fnm
),
151 "Radius of gyration","Time (ps)","Rg (nm)");
153 fprintf(out
,"@ subtitle \"Axes are principal component axes\"\n");
154 xvgr_legend(out
,NLEG
,leg
);
156 rm_pbc(&top
.idef
,natoms
,box
,x
,x_s
);
157 tm
=sub_xcm(x_s
,gnx
,index
,top
.atoms
.atom
,xcm
,bQ
);
158 gyro
=calc_gyro(x_s
,gnx
,index
,top
.atoms
.atom
,tm
,gvec
,d
,bQ
,bRot
);
161 fprintf(out
,"%10g %10g %10g %10g %10g\n",
162 t
,gyro
,d
[XX
],d
[YY
],d
[ZZ
]); }
164 fprintf(out
,"%10g %10g %10g %10g %10g\n",
165 t
,gyro
,gvec
[XX
],gvec
[YY
],gvec
[ZZ
]); }
167 } while(read_next_x(status
,&t
,natoms
,x
,box
));
172 xvgr_file(ftp2fn(efXVG
,NFILE
,fnm
),"-nxy");