ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/tcProps/tcProps.c
Revision: 1067
Committed: Tue Feb 24 17:13:06 2004 UTC (21 years, 2 months ago) by mmeineke
Content type: text/plain
File size: 10213 byte(s)
Log Message:
worked out the diagonalization bugs in head and whole

File Contents

# Content
1 #define _FILE_OFFSET_BITS 64
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6
7
8 #include "params.h"
9 #include "tcProps.h"
10 #include "readWrite.h"
11 #include "scdCorr.h"
12 #include "directorHead.h"
13 #include "directorWhole.h"
14
15
16 #define VERSION_MAJOR 0
17 #define VERSION_MINOR 1
18
19 char *programName; /*the name of the program */
20 void usage(void);
21
22 int main( int argC, char *argV[] ){
23
24 // list of 'a priori' constants
25
26 const int nLipAtoms = NL_ATOMS;
27 const int nBonds = NBONDS;
28 const int nLipids = NLIPIDS;
29 const int nSSD = NSSD;
30 const int nAtoms = nLipAtoms * nLipids + nSSD;
31
32 // different needed variables
33
34 struct atomCoord atoms[nAtoms];
35 int i,j,k;
36
37 char* outPrefix; // the output prefix
38 char currentFlag; // used in parsing the flags
39 int done = 0; // multipurpose boolean
40 int havePrefix; // boolean for the output prefix
41 int haveMaxLength;
42 char* conversionCheck;
43 int conversionError;
44 int optionError;
45 char* pair1;
46 char* pair2;
47 int scdCorr;
48 double startTime;
49 double maxLength;
50 int directorHead, directorWhole;
51
52 // system initialization
53
54 isScanned = 0;
55 fileOpen = 0;
56 nFrames = 0;
57 frameTimes = NULL;
58
59 outPrefix = NULL;
60 inName = NULL;
61
62 haveMaxLength = 0;
63 conversionError = 0;
64 optionError = 0;
65 havePrefix = 0;
66 scdCorr = 0;
67 startTime = 0.0;
68 directorHead = 0;
69 directorWhole = 0;
70
71
72 // parse the command line
73
74 programName = argV[0]; /*save the program name in case we need it*/
75
76 for( i = 1; i < argC; i++){
77
78 if(argV[i][0] =='-'){
79
80 // parse the option
81
82 if(argV[i][1] == '-' ){
83
84 // parse long word options
85
86 if( !strcmp( argV[i], "--gofr" ) ){
87
88 i++;
89 if( i>=argC ){
90 fprintf( stderr,
91 "\n"
92 "not enough arguments for --gofr\n");
93 usage();
94 exit(0);
95 }
96 pair1 = argV[i];
97
98 i++;
99 if( i>=argC ){
100 fprintf( stderr,
101 "\n"
102 "not enough arguments for --gofr\n");
103 usage();
104 exit(0);
105 }
106 pair2 = argV[i];
107
108 }
109
110 else if( !strcmp( argV[i], "--gofrTheta" ) ){
111
112 i++;
113 if( i>=argC ){
114 fprintf( stderr,
115 "\n"
116 "not enough arguments for --gofrTheta\n");
117 usage();
118 exit(0);
119 }
120 pair1 = argV[i];
121
122 i++;
123 if( i>=argC ){
124 fprintf( stderr,
125 "\n"
126 "not enough arguments for --gofrTheta\n");
127 usage();
128 exit(0);
129 }
130 pair2 = argV[i];
131
132 }
133
134 else if( !strcmp( argV[i], "--gofrOmega" ) ){
135
136 i++;
137 if( i>=argC ){
138 fprintf( stderr,
139 "\n"
140 "not enough arguments for --gofrOmega\n");
141 usage();
142 exit(0);
143 }
144 pair1 = argV[i];
145
146 i++;
147 if( i>=argC ){
148 fprintf( stderr,
149 "\n"
150 "not enough arguments for --gofrOmega\n");
151 usage();
152 exit(0);
153 }
154 pair2 = argV[i];
155
156 }
157
158 else if( !strcmp( argV[i], "--version") ){
159
160 printf("\n"
161 "tcProps version %d.%d\n"
162 "\n",
163 VERSION_MAJOR, VERSION_MINOR );
164 exit(0);
165
166 }
167
168 else if( !strcmp( argV[i], "--help") ){
169
170 usage();
171 exit(0);
172 }
173
174 // anything else is an error
175
176 else{
177 fprintf( stderr,
178 "Invalid option \"%s\"\n", argV[i] );
179 usage();
180 exit(0);
181 }
182 }
183
184 else{
185
186 // parse single character options
187
188 done =0;
189 j = 1;
190 currentFlag = argV[i][j];
191 while( (currentFlag != '\0') && (!done) ){
192
193 switch(currentFlag){
194
195 case 'o':
196 // -o <prefix> => the output prefix.
197
198 j++;
199 currentFlag = argV[i][j];
200
201 if( currentFlag != '\0' ) optionError = 1;
202
203 if( optionError ){
204 fprintf( stderr,
205 "\n"
206 "The -o flag should end an option sequence.\n"
207 " example: -r <outname> *NOT* -or <outname>\n" );
208 usage();
209 exit(0);
210 }
211
212 i++;
213 if( i>=argC ){
214 fprintf( stderr,
215 "\n"
216 "not enough arguments for -o\n");
217 usage();
218 exit(0);
219 }
220
221 outPrefix = argV[i];
222 if( outPrefix[0] == '-' ) optionError = 1;
223
224 if( optionError ){
225 fprintf( stderr,
226 "\n"
227 "\"%s\" is not a valid out prefix/name.\n"
228 "Out prefix/name should not begin with a dash.\n",
229 outPrefix );
230 usage();
231 exit(0);
232 }
233
234 havePrefix = 1;
235 done = 1;
236 break;
237
238 case 'l':
239 // -l <double> set <double> to the maxLength
240
241 haveMaxLength = 1;
242 j++;
243 currentFlag = argV[i][j];
244
245 if( currentFlag != '\0' ) optionError = 1;
246
247 if( optionError ){
248 fprintf( stderr,
249 "\n"
250 "The -l flag should end an option sequence.\n"
251 " example: -sl <double> *NOT* -ls <double>\n" );
252 usage();
253 exit(0);
254 }
255
256 i++;
257 if( i>=argC ){
258 fprintf( stderr,
259 "\n"
260 "not enough arguments for -l\n");
261 usage();
262 exit(0);
263 }
264
265 maxLength = atof( argV[i] );
266
267 done = 1;
268
269 break;
270
271 case 't':
272 // -t <double> set <double> to the startTime
273
274 j++;
275 currentFlag = argV[i][j];
276
277 if( currentFlag != '\0' ) optionError = 1;
278
279 if( optionError ){
280 fprintf( stderr,
281 "\n"
282 "The -t flag should end an option sequence.\n"
283 " example: -st <double> *NOT* -ts <double>\n" );
284 usage();
285 exit(0);
286 }
287
288 i++;
289 if( i>=argC ){
290 fprintf( stderr,
291 "\n"
292 "not enough arguments for -t\n");
293 usage();
294 exit(0);
295 }
296
297 startTime = atof( argV[i] );
298 done = 1;
299 break;
300
301 case 's':
302 // -s turn on Scd corr
303
304 scdCorr = 1;
305 break;
306
307 case 'h':
308 // -h turn on director head
309
310 directorHead = 1;
311 break;
312
313 case 'w':
314 // -h turn on director head
315
316 directorWhole = 1;
317 break;
318
319
320 default:
321
322 fprintf( stderr,
323 "\n"
324 "Bad option \"-%c\"\n", currentFlag);
325 usage();
326 exit(0);
327 }
328 j++;
329 currentFlag = argV[i][j];
330 }
331 }
332 }
333
334 else{
335
336 if( inName != NULL ){
337 fprintf( stderr,
338 "Error at \"%s\", program does not currently support\n"
339 "more than one input dump file.\n"
340 "\n",
341 argV[i]);
342 usage();
343 exit(0);
344 }
345
346 inName = argV[i];
347
348 }
349 }
350
351 if( inName == NULL ){
352 fprintf( stderr,
353 "Error, dump file is needed to run.\n" );
354 usage();
355 exit(0);
356 }
357
358 if( outPrefix == NULL )
359 outPrefix = inName;
360
361
362 // initialize the arrays
363
364 for(i=0;i<nLipids;i++){
365
366 atoms[nLipAtoms*i+0].type = HEAD;
367 atoms[nLipAtoms*i+0].mass = 72;
368 atoms[nLipAtoms*i+0].u[0] = 0.0;
369 atoms[nLipAtoms*i+0].u[1] = 0.0;
370 atoms[nLipAtoms*i+0].u[2] = 1.0;
371
372
373
374 atoms[nLipAtoms*i+1].type = CH2;
375 atoms[nLipAtoms*i+1].mass = 14.03;
376
377 atoms[nLipAtoms*i+2].type = CH;
378 atoms[nLipAtoms*i+2].mass = 13.02;
379
380 atoms[nLipAtoms*i+3].type = CH2;
381 atoms[nLipAtoms*i+3].mass = 14.03;
382
383 atoms[nLipAtoms*i+4].type = CH2;
384 atoms[nLipAtoms*i+4].mass = 14.03;
385
386 atoms[nLipAtoms*i+5].type = CH2;
387 atoms[nLipAtoms*i+5].mass = 14.03;
388
389 atoms[nLipAtoms*i+6].type = CH2;
390 atoms[nLipAtoms*i+6].mass = 14.03;
391
392 atoms[nLipAtoms*i+7].type = CH2;
393 atoms[nLipAtoms*i+7].mass = 14.03;
394
395 atoms[nLipAtoms*i+8].type = CH2;
396 atoms[nLipAtoms*i+8].mass = 14.03;
397
398 atoms[nLipAtoms*i+9].type = CH2;
399 atoms[nLipAtoms*i+9].mass = 14.03;
400
401 atoms[nLipAtoms*i+10].type = CH3;
402 atoms[nLipAtoms*i+10].mass = 15.04;
403
404 atoms[nLipAtoms*i+11].type = CH2;
405 atoms[nLipAtoms*i+11].mass = 14.03;
406
407 atoms[nLipAtoms*i+12].type = CH2;
408 atoms[nLipAtoms*i+12].mass = 14.03;
409
410 atoms[nLipAtoms*i+13].type = CH2;
411 atoms[nLipAtoms*i+13].mass = 14.03;
412
413 atoms[nLipAtoms*i+14].type = CH2;
414 atoms[nLipAtoms*i+14].mass = 14.03;
415
416 atoms[nLipAtoms*i+15].type = CH2;
417 atoms[nLipAtoms*i+15].mass = 14.03;
418
419 atoms[nLipAtoms*i+16].type = CH2;
420 atoms[nLipAtoms*i+16].mass = 14.03;
421
422 atoms[nLipAtoms*i+17].type = CH2;
423 atoms[nLipAtoms*i+17].mass = 14.03;
424
425 atoms[nLipAtoms*i+18].type = CH3;
426 atoms[nLipAtoms*i+18].mass = 15.04;
427 }
428
429 for(i=(nLipAtoms*nLipids);i<nAtoms;i++){
430 atoms[i].type = SSD;
431 atoms[i].mass = 18.03;
432 atoms[i].u[0] = 0.0;
433 atoms[i].u[1] = 0.0;
434 atoms[i].u[2] = 1.0;
435 }
436
437 // read and set the frames
438
439 openFile();
440
441 fprintf( stdout,
442 "\n"
443 "Counting the number of frames in \"%s\"...",
444 inName );
445 fflush(stdout);
446
447 setFrames();
448
449 fprintf( stdout,
450 "done.\n"
451 "nFrames = %d.\n",
452 nFrames );
453 fflush(stdout);
454
455 if(scdCorr){
456
457 fprintf ( stdout,
458 "Calculating the Scd correlation\n" );
459 fflush( stdout );
460
461 calcScdCorr( startTime, atoms, outPrefix );
462 }
463
464 if(directorHead){
465
466 fprintf ( stdout,
467 "Calculating the Head director\n" );
468 fflush( stdout );
469
470 calcDirHeadCorr( startTime, atoms, outPrefix );
471 }
472
473 if(directorWhole){
474
475 fprintf ( stdout,
476 "Calculating the bilayer director\n" );
477 fflush( stdout );
478
479 calcDirWholeCorr( startTime, atoms, outPrefix );
480 }
481
482
483 closeFile();
484
485 }
486
487
488 /***************************************************************************
489 * prints out the usage for the command line arguments, then exits.
490 ***************************************************************************/
491
492 void usage(){
493 (void)fprintf(stdout,
494 "\n"
495 "The proper usage is: %s [options] <input_file>\n"
496 "\n"
497 "Options:\n"
498 "\n"
499 " short:\n"
500 " ------\n"
501 " -o <name> The output prefix\n"
502 " -t <time> Set the start time for correlations\n"
503 " -l <maxLength> set the maximum value of r\n"
504 " *Defaults to 1/2 smallest length of first frame.\n"
505 " -s Calculate the Scd chain correlation.\n"
506 " -h Calculate the directors for the head groups\n"
507 " -w Calculate the director fro the bilayers\n"
508 "\n"
509 " long:\n"
510 " -----\n"
511 " --gofr <atom1> <atom2> g(r) for atom1 and atom2\n"
512 " --gofrTheta <atom1> <atom2> g(r, theta) for atom1 and atom2\n"
513 " --gofrOmega <atom1> <atom2> g(r, omega) for atom1 and atom2\n"
514 " --version displays the version number\n"
515 " --help displays this help message.\n"
516
517 "\n"
518 "\n",
519 programName);
520 }