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 * Great Red Oystrich Makes All Chemists Sane
29 static char *SRCID_mk_angndx_c
= "$Id$";
41 static int calc_nftype(int FTYPE
,t_idef
*idef
)
45 for(i
=0; (i
<idef
->ntypes
); i
++)
46 if (idef
->functype
[i
] == FTYPE
)
52 static void fill_ft_ind(int FTYPE
,int ft_ind
[],t_idef
*idef
,char *grpnames
[])
57 for(i
=0; (i
<idef
->ntypes
); i
++) {
63 sprintf(buf
,"Theta=%.1f_%g",idef
->iparams
[i
].harmonic
.rA
,
64 idef
->iparams
[i
].harmonic
.krA
);
67 sprintf(buf
,"Theta=%.1f_%g",idef
->iparams
[i
].harmonic
.rA
,
68 idef
->iparams
[i
].harmonic
.krA
);
71 sprintf(buf
,"Phi=%.1f_%d_%g",idef
->iparams
[i
].pdihs
.phiA
,
72 idef
->iparams
[i
].pdihs
.mult
,idef
->iparams
[i
].pdihs
.cpA
);
75 sprintf(buf
,"Xi=%.1f_%g",idef
->iparams
[i
].harmonic
.rA
,
76 idef
->iparams
[i
].harmonic
.krA
);
79 sprintf(buf
,"RB-Dihs");
82 fatal_error(0,"kjdshfgkajhgajytgajtgasuyf");
84 grpnames
[ind
]=strdup(buf
);
92 static void fill_ang(int FTYPE
,int fac
,
93 int nr
[],int *index
[],int ft_ind
[],t_idef
*idef
)
95 int i
,j
,ft
,fft
,nr_fac
;
98 ia
=idef
->il
[FTYPE
].iatoms
;
99 for(i
=0; (i
<idef
->il
[FTYPE
].nr
); ) {
100 ft
= idef
->functype
[ia
[0]];
104 for(j
=0; (j
<fac
); j
++)
105 index
[fft
][nr_fac
+j
]=ia
[j
+1];
107 ia
+= interaction_function
[ft
].nratoms
+1;
108 i
+= interaction_function
[ft
].nratoms
+1;
112 int main(int argc
,char *argv
[])
114 static char *desc
[] = {
115 "mk_angndx makes an index file for calculation of",
116 "angle distributions etc. It uses a run input file ([TT].tpx[tt]) for the",
117 "definitions of the angles, dihedrals etc."
119 static char *opt
[] = { NULL
, "angle", "g96-angle", "dihedral", "improper", "ryckaert-bellemans", "phi-psi", NULL
};
121 { "-type", FALSE
, etENUM
, {opt
},
135 { efTPX
, NULL
, NULL
, ffREAD
},
136 { efNDX
, NULL
, "angle", ffWRITE
}
138 #define NFILE asize(fnm)
140 CopyRight(stderr
,argv
[0]);
141 parse_common_args(&argc
,argv
,0,FALSE
,NFILE
,fnm
,asize(pa
),pa
,
142 asize(desc
),desc
,0,NULL
);
171 top
=read_top(ftp2fn(efTPX
,NFILE
,fnm
));
174 nftype
=calc_nftype(FTYPE
,&(top
->idef
));
175 snew(grpnames
,nftype
);
176 snew(ft_ind
,top
->idef
.ntypes
);
177 fill_ft_ind(FTYPE
,ft_ind
,&top
->idef
,grpnames
);
178 nang
=top
->idef
.il
[FTYPE
].nr
;
182 for(i
=0; (i
<nftype
); i
++)
183 snew(index
[i
],nang
*mult
);
185 fill_ang(FTYPE
,mult
,nr
,index
,ft_ind
,&(top
->idef
));
187 out
=ftp2FILE(efNDX
,NFILE
,fnm
,"w");
188 for(i
=0; (i
<nftype
); i
++) {
189 fprintf(out
,"[ %s ]\n",grpnames
[i
]);
190 for(j
=0; (j
<nr
[i
]*mult
); j
++) {
191 fprintf(out
," %5d",index
[i
][j
]+1);
200 fprintf(stderr
,"Sorry, maybe later...\n");