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
64 calc_principal_axes(t_topology
* top
,
73 sub_xcm(x
,n
,index
,top
->atoms
.atom
,xcm
,FALSE
);
74 principal_comp(n
,index
,top
->atoms
.atom
,x
,axes
,inertia
);
77 int gmx_principal(int argc
,char *argv
[])
79 const char *desc
[] = {
80 "[TT]g_principal[tt] calculates the three principal axes of inertia for a group",
83 static gmx_bool foo
= FALSE
;
86 { "-foo", FALSE
, etBOOL
, {&foo
}, "Dummy option to avoid empty array" }
95 char *grpname
,title
[256];
96 int i
,j
,m
,gnx
,nam
,mol
;
105 gmx_rmpbc_t gpbc
=NULL
;
109 { efTRX
, "-f", NULL
, ffREAD
},
110 { efTPS
, NULL
, NULL
, ffREAD
},
111 { efNDX
, NULL
, NULL
, ffOPTRD
},
112 { efDAT
, "-a1", "axis1", ffWRITE
},
113 { efDAT
, "-a2", "axis2", ffWRITE
},
114 { efDAT
, "-a3", "axis3", ffWRITE
},
115 { efDAT
, "-om", "moi", ffWRITE
}
117 #define NFILE asize(fnm)
119 CopyRight(stderr
,argv
[0]);
120 parse_common_args(&argc
,argv
,
121 PCA_CAN_TIME
| PCA_TIME_UNIT
| PCA_CAN_VIEW
| PCA_BE_NICE
,
122 NFILE
,fnm
,asize(pa
),pa
,asize(desc
),desc
,0,NULL
,&oenv
);
124 axis1
=ffopen(opt2fn("-a1",NFILE
,fnm
),"w");
125 axis2
=ffopen(opt2fn("-a2",NFILE
,fnm
),"w");
126 axis3
=ffopen(opt2fn("-a3",NFILE
,fnm
),"w");
127 fmoi
=ffopen(opt2fn("-om",NFILE
,fnm
),"w");
129 read_tps_conf(ftp2fn(efTPS
,NFILE
,fnm
),title
,&top
,&ePBC
,NULL
,NULL
,box
,TRUE
);
131 get_index(&top
.atoms
,ftp2fn_null(efNDX
,NFILE
,fnm
),1,&gnx
,&index
,&grpname
);
133 natoms
=read_first_x(oenv
,&status
,ftp2fn(efTRX
,NFILE
,fnm
),&t
,&x
,box
);
135 gpbc
= gmx_rmpbc_init(&top
.idef
,ePBC
,natoms
,box
);
139 gmx_rmpbc(gpbc
,natoms
,box
,x
);
141 calc_principal_axes(&top
,x
,index
,gnx
,axes
,moi
);
143 fprintf(axis1
,"%15.10f %15.10f %15.10f %15.10f\n",t
,axes
[XX
][XX
],axes
[YY
][XX
],axes
[ZZ
][XX
]);
144 fprintf(axis2
,"%15.10f %15.10f %15.10f %15.10f\n",t
,axes
[XX
][YY
],axes
[YY
][YY
],axes
[ZZ
][YY
]);
145 fprintf(axis3
,"%15.10f %15.10f %15.10f %15.10f\n",t
,axes
[XX
][ZZ
],axes
[YY
][ZZ
],axes
[ZZ
][ZZ
]);
146 fprintf(fmoi
, "%15.10f %15.10f %15.10f %15.10f\n",t
,moi
[XX
],moi
[YY
],moi
[ZZ
]);
148 while(read_next_x(oenv
,status
,&t
,natoms
,x
,box
));
150 gmx_rmpbc_done(gpbc
);