22 |
|
int lineNum = 0; // keeps track of the line number |
23 |
|
int n_atoms; // the number of atoms |
24 |
|
int i,j; // loop counters |
25 |
+ |
int isFirst; |
26 |
|
|
27 |
|
char read_buffer[2000]; /*the line buffer for reading */ |
28 |
|
char *foo; /*the pointer to the current string token */ |
48 |
|
char cosCorr1[30]; |
49 |
|
char cosCorr2[30]; |
50 |
|
|
51 |
+ |
int startFrame = 0; |
52 |
+ |
int haveStartFrame = 0; |
53 |
+ |
int endFrame = 0; |
54 |
+ |
int haveEndFrame = 0; |
55 |
|
|
51 |
– |
|
56 |
|
program_name = argv[0]; /*save the program name in case we need it*/ |
57 |
|
|
58 |
|
for( i = 1; i < argc; i++){ |
68 |
|
if( !strcmp( argv[i], "--GofR" ) ){ |
69 |
|
calcGofR = 1; |
70 |
|
i++; |
71 |
+ |
strcpy( cosCorr1, argv[i] ); |
72 |
+ |
i++; |
73 |
+ |
strcpy( cosCorr2, argv[i] ); |
74 |
+ |
} |
75 |
+ |
|
76 |
+ |
else if( !strcmp( argv[i], "--CosCorr" ) ){ |
77 |
+ |
calcCosCorr = 1; |
78 |
+ |
i++; |
79 |
|
strcpy( gofR1, argv[i] ); |
80 |
|
i++; |
81 |
|
strcpy( gofR2, argv[i] ); |
87 |
|
strcpy( muCorr, argv[i] ); |
88 |
|
} |
89 |
|
|
90 |
< |
else if( !strcmp( argv[i], "--CosCorr" ) ){ |
91 |
< |
calcCosCorr = 1; |
90 |
> |
else if( !strcmp( argv[i], "--startFrame" ) ){ |
91 |
> |
haveStartFrame = 1; |
92 |
|
i++; |
93 |
< |
strcpy( cosCorr1, argv[i] ); |
93 |
> |
startFrame = atoi(argv[i]); |
94 |
> |
startFrame--; |
95 |
> |
} |
96 |
> |
|
97 |
> |
else if( !strcmp( argv[i], "--endFrame" ) ){ |
98 |
> |
haveEndFrame = 1; |
99 |
|
i++; |
100 |
< |
strcpy( cosCorr2, argv[i] ); |
100 |
> |
endFrame = atoi(argv[i]); |
101 |
|
} |
102 |
|
|
103 |
|
else{ |
185 |
|
fflush( stdout ); |
186 |
|
|
187 |
|
nFrames = frameCount( in_name ); |
188 |
+ |
if( !haveEndFrame ) endFrame = nFrames; |
189 |
|
|
190 |
|
printf( "done.\n" |
191 |
|
"nframes = %d\n" |
199 |
|
exit(8); |
200 |
|
} |
201 |
|
|
202 |
< |
// create the array of frames |
202 |
> |
// create and initialize the array of frames |
203 |
|
|
204 |
|
dumpArray = (struct xyz_frame*)calloc( nFrames, |
205 |
|
sizeof( struct xyz_frame ) ); |
206 |
+ |
for( i=0; i<nFrames; i++ ){ |
207 |
+ |
dumpArray[i].nAtoms = 0; |
208 |
+ |
dumpArray[i].time = 0.0; |
209 |
+ |
dumpArray[i].boxX = 0.0; |
210 |
+ |
dumpArray[i].boxY = 0.0; |
211 |
+ |
dumpArray[i].boxZ = 0.0; |
212 |
+ |
dumpArray[i].r = NULL; |
213 |
+ |
dumpArray[i].v = NULL; |
214 |
+ |
dumpArray[i].names = NULL; |
215 |
+ |
} |
216 |
|
|
217 |
|
// read the frames |
218 |
|
|
219 |
|
printf( "Reading the frames into the coordinate arrays..." ); |
220 |
|
fflush( stdout ); |
221 |
|
|
222 |
+ |
isFirst = 1; |
223 |
|
for(j =0; j<nFrames; j++ ){ |
224 |
|
|
225 |
|
// read the number of atoms |
232 |
|
|
233 |
|
dumpArray[j].r = |
234 |
|
(struct coords *)calloc(n_atoms, sizeof(struct coords)); |
235 |
+ |
|
236 |
+ |
if( isFirst ) { |
237 |
+ |
dumpArray[0].names = |
238 |
+ |
(atomID *)calloc( n_atoms, sizeof(atomID) ); |
239 |
+ |
isFirst = 0; |
240 |
+ |
} |
241 |
|
|
242 |
|
if( calcMuCorr || calcCosCorr ){ |
243 |
|
dumpArray[j].v = |
295 |
|
exit(8); |
296 |
|
} |
297 |
|
|
298 |
< |
strcpy(dumpArray[j].r[i].name, foo); /*copy the atom name */ |
298 |
> |
strcpy(dumpArray[0].names[i], foo); /*copy the atom name */ |
299 |
|
|
300 |
|
foo = strtok(NULL, " ,;\t"); |
301 |
|
if(foo == NULL){ |
373 |
|
fflush( stdout ); |
374 |
|
|
375 |
|
// gofr call |
376 |
< |
GofR( out_prefix, gofR1, gofR2, dumpArray, nFrames ); |
376 |
> |
GofR( out_prefix, gofR1, gofR2, dumpArray, nFrames, startFrame, endFrame ); |
377 |
|
|
378 |
|
fprintf( stdout, |
379 |
|
" done.\n" |
419 |
|
cosCorr1, cosCorr2 ); |
420 |
|
fflush( stdout ); |
421 |
|
|
422 |
< |
// cosCorr call |
423 |
< |
|
422 |
> |
cosCorr( out_prefix, cosCorr1, cosCorr2, dumpArray, nFrames, startFrame, |
423 |
> |
endFrame ); |
424 |
|
|
425 |
|
fprintf( stdout, |
426 |
|
" done.\n" |
428 |
|
fflush(stdout); |
429 |
|
} |
430 |
|
|
396 |
– |
|
431 |
|
return 0; |
432 |
|
|
433 |
|
} |
434 |
|
|
435 |
|
|
436 |
+ |
void map( double *x, double *y, double *z, |
437 |
+ |
double boxX, double boxY, double boxZ ){ |
438 |
+ |
|
439 |
+ |
*x -= boxX * copysign(1.0,*x) * floor( fabs( *x/boxX ) + 0.5 ); |
440 |
+ |
*y -= boxY * copysign(1.0,*y) * floor( fabs( *y/boxY ) + 0.5 ); |
441 |
+ |
*z -= boxZ * copysign(1.0,*z) * floor( fabs( *z/boxZ ) + 0.5 ); |
442 |
|
|
443 |
+ |
} |
444 |
+ |
|
445 |
+ |
|
446 |
|
/*************************************************************************** |
447 |
|
* prints out the usage for the command line arguments, then exits. |
448 |
|
***************************************************************************/ |
467 |
|
" -note: \"all\" will do all atoms\n" |
468 |
|
" --MuCorr <atom> Calculate mu correlation of atom\n" |
469 |
|
" --CosCorr <atom1> <atom2> Calculate the cos correlation between atom1 and atom2\n" |
470 |
+ |
" --startFrame <frame#> Specifies a frame to start correlating\n" |
471 |
+ |
" --endFrame <frame#> Specifies a frame to stop correlating.\n" |
472 |
|
|
428 |
– |
|
473 |
|
"\n" |
474 |
|
"\n", |
475 |
|
program_name); |