9 |
|
#include "SRI.hpp" |
10 |
|
#include "simError.h" |
11 |
|
|
12 |
– |
|
12 |
|
#ifdef IS_MPI |
14 |
– |
|
13 |
|
#include "mpiForceField.h" |
14 |
+ |
#endif // is_mpi |
15 |
|
|
16 |
+ |
namespace TPE { // restrict the access of the folowing to this file only. |
17 |
|
|
18 |
– |
// Declare the structures that will be passed by MPI |
18 |
|
|
19 |
< |
typedef struct{ |
20 |
< |
char name[15]; |
21 |
< |
double mass; |
22 |
< |
double epslon; |
23 |
< |
double sigma; |
24 |
< |
double dipole; |
25 |
< |
int isDipole; |
26 |
< |
int last; // 0 -> default |
27 |
< |
// 1 -> tells nodes to stop listening |
28 |
< |
} atomStruct; |
29 |
< |
MPI_Datatype mpiAtomStructType; |
19 |
> |
// Declare the structures that will be passed by MPI |
20 |
> |
|
21 |
> |
typedef struct{ |
22 |
> |
char name[15]; |
23 |
> |
double mass; |
24 |
> |
double epslon; |
25 |
> |
double sigma; |
26 |
> |
double dipole; |
27 |
> |
double w0; |
28 |
> |
double v0; |
29 |
> |
int isSSD; |
30 |
> |
int isDipole; |
31 |
> |
int ident; |
32 |
> |
int last; // 0 -> default |
33 |
> |
// 1 -> tells nodes to stop listening |
34 |
> |
} atomStruct; |
35 |
> |
|
36 |
> |
|
37 |
> |
typedef struct{ |
38 |
> |
char nameA[15]; |
39 |
> |
char nameB[15]; |
40 |
> |
char type[30]; |
41 |
> |
double d0; |
42 |
> |
int last; // 0 -> default |
43 |
> |
// 1 -> tells nodes to stop listening |
44 |
> |
} bondStruct; |
45 |
> |
|
46 |
> |
|
47 |
> |
typedef struct{ |
48 |
> |
char nameA[15]; |
49 |
> |
char nameB[15]; |
50 |
> |
char nameC[15]; |
51 |
> |
char type[30]; |
52 |
> |
double k1, k2, k3, t0; |
53 |
> |
int last; // 0 -> default |
54 |
> |
// 1 -> tells nodes to stop listening |
55 |
> |
} bendStruct; |
56 |
> |
|
57 |
|
|
58 |
< |
typedef struct{ |
59 |
< |
char nameA[15]; |
60 |
< |
char nameB[15]; |
61 |
< |
char type[30]; |
62 |
< |
double d0; |
63 |
< |
int last; // 0 -> default |
64 |
< |
// 1 -> tells nodes to stop listening |
65 |
< |
} bondStruct; |
66 |
< |
MPI_Datatype mpiBondStructType; |
67 |
< |
|
68 |
< |
typedef struct{ |
69 |
< |
char nameA[15]; |
70 |
< |
char nameB[15]; |
71 |
< |
char nameC[15]; |
72 |
< |
char type[30]; |
73 |
< |
double k1, k2, k3, t0; |
74 |
< |
int last; // 0 -> default |
75 |
< |
// 1 -> tells nodes to stop listening |
76 |
< |
} bendStruct; |
51 |
< |
MPI_Datatype mpiBendStructType; |
58 |
> |
typedef struct{ |
59 |
> |
char nameA[15]; |
60 |
> |
char nameB[15]; |
61 |
> |
char nameC[15]; |
62 |
> |
char nameD[15]; |
63 |
> |
char type[30]; |
64 |
> |
double k1, k2, k3, k4; |
65 |
> |
int last; // 0 -> default |
66 |
> |
// 1 -> tells nodes to stop listening |
67 |
> |
} torsionStruct; |
68 |
> |
|
69 |
> |
|
70 |
> |
int parseAtom( char *lineBuffer, int lineNum, atomStruct &info ); |
71 |
> |
int parseBond( char *lineBuffer, int lineNum, bondStruct &info ); |
72 |
> |
int parseBend( char *lineBuffer, int lineNum, bendStruct &info ); |
73 |
> |
int parseTorsion( char *lineBuffer, int lineNum, torsionStruct &info ); |
74 |
> |
|
75 |
> |
|
76 |
> |
#ifdef IS_MPI |
77 |
|
|
78 |
< |
typedef struct{ |
79 |
< |
char nameA[15]; |
80 |
< |
char nameB[15]; |
81 |
< |
char nameC[15]; |
57 |
< |
char nameD[15]; |
58 |
< |
char type[30]; |
59 |
< |
double k1, k2, k3, k4; |
60 |
< |
int last; // 0 -> default |
61 |
< |
// 1 -> tells nodes to stop listening |
62 |
< |
} torsionStruct; |
63 |
< |
MPI_Datatype mpiTorsionStructType; |
78 |
> |
MPI_Datatype mpiAtomStructType; |
79 |
> |
MPI_Datatype mpiBondStructType; |
80 |
> |
MPI_Datatype mpiBendStructType; |
81 |
> |
MPI_Datatype mpiTorsionStructType; |
82 |
|
|
83 |
|
#endif |
84 |
|
|
85 |
+ |
} // namespace |
86 |
|
|
87 |
|
|
88 |
+ |
// declaration of functions needed to wrap the fortran module |
89 |
+ |
|
90 |
+ |
extern "C" { |
91 |
+ |
|
92 |
+ |
void forcefactory_( char* forceName, |
93 |
+ |
int* status, |
94 |
+ |
void (*wrapFunction)( void (*p1)( int* ident, |
95 |
+ |
double* mass, |
96 |
+ |
double* epslon, |
97 |
+ |
double* sigma, |
98 |
+ |
int* isDipole, |
99 |
+ |
int* isSSd, |
100 |
+ |
double* dipole, |
101 |
+ |
double* w0, |
102 |
+ |
double* v0, |
103 |
+ |
int* status ), |
104 |
+ |
void (*p2)( int *nLocal, |
105 |
+ |
int *identArray, |
106 |
+ |
int *isError ), |
107 |
+ |
void (*p3)( double* positionArray, |
108 |
+ |
double* forceArray, |
109 |
+ |
double* potentialEnergy, |
110 |
+ |
double* tau, |
111 |
+ |
short int* doPotentialCalc, |
112 |
+ |
int* isError)), |
113 |
+ |
int forceNameLength ); |
114 |
+ |
} |
115 |
+ |
|
116 |
+ |
|
117 |
+ |
void TPEfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon, |
118 |
+ |
double* sigma, int* isDipole, int* isSSD, |
119 |
+ |
double* dipole, double* w0, double* v0, |
120 |
+ |
int* status ), |
121 |
+ |
void (*p2)( int *nLocal, int *identArray, int *isError ), |
122 |
+ |
void (*p3)( double* positionArray,double* forceArray, |
123 |
+ |
double* potentialEnergy, double* tau, |
124 |
+ |
short int* doPotentialCalc, int* isError ) ); |
125 |
+ |
|
126 |
+ |
void (*newTPEtype)( int* ident, double* mass, double* epslon, double* sigma, |
127 |
+ |
int* isDipole, int* isSSD, double* dipole, double* w0, |
128 |
+ |
double* v0, int* status ); |
129 |
+ |
|
130 |
+ |
void (*initTPEfortran) ( int *nLocal, int *identArray, int *isError ); |
131 |
+ |
|
132 |
+ |
TraPPE_ExFF* currentTPEwrap; |
133 |
+ |
|
134 |
+ |
using namespace TPE; |
135 |
+ |
|
136 |
+ |
|
137 |
+ |
//**************************************************************** |
138 |
+ |
// begins the actual forcefield stuff. |
139 |
+ |
//**************************************************************** |
140 |
+ |
|
141 |
+ |
|
142 |
|
TraPPE_ExFF::TraPPE_ExFF(){ |
143 |
|
|
144 |
|
char fileName[200]; |
147 |
|
char temp[200]; |
148 |
|
char errMsg[1000]; |
149 |
|
|
150 |
+ |
// do the funtion wrapping |
151 |
+ |
currentTPEwrap = this; |
152 |
+ |
wrapMe(); |
153 |
+ |
|
154 |
+ |
|
155 |
|
#ifdef IS_MPI |
156 |
|
int i; |
157 |
|
|
158 |
< |
// ********************************************************************** |
158 |
> |
// ********************************************************************** |
159 |
|
// Init the atomStruct mpi type |
160 |
|
|
161 |
|
atomStruct atomProto; // mpiPrototype |
162 |
< |
int atomBC[3] = {15,4,2}; // block counts |
162 |
> |
int atomBC[3] = {15,6,4}; // block counts |
163 |
|
MPI_Aint atomDspls[3]; // displacements |
164 |
|
MPI_Datatype atomMbrTypes[3]; // member mpi types |
165 |
|
|
166 |
|
MPI_Address(&atomProto.name, &atomDspls[0]); |
167 |
|
MPI_Address(&atomProto.mass, &atomDspls[1]); |
168 |
< |
MPI_Address(&atomProto.isDipole, &atomDspls[2]); |
168 |
> |
MPI_Address(&atomProto.isSSD, &atomDspls[2]); |
169 |
|
|
170 |
|
atomMbrTypes[0] = MPI_CHAR; |
171 |
|
atomMbrTypes[1] = MPI_DOUBLE; |
315 |
|
#endif // is_mpi |
316 |
|
} |
317 |
|
|
318 |
+ |
|
319 |
+ |
void TraPPE_ExFF::wrapMe( void ){ |
320 |
+ |
|
321 |
+ |
char* currentFF = "TraPPE_Ex"; |
322 |
+ |
int isError = 0; |
323 |
+ |
|
324 |
+ |
forcefactory_( currentFF, &isError, TPEfunctionWrapper, strlen(currentFF) ); |
325 |
+ |
|
326 |
+ |
if( isError ){ |
327 |
+ |
|
328 |
+ |
sprintf( painCave.errMsg, |
329 |
+ |
"TraPPE_ExFF error: an error was returned from fortran when the " |
330 |
+ |
"the functions were being wrapped.\n" ); |
331 |
+ |
painCave.isFatal = 1; |
332 |
+ |
simError(); |
333 |
+ |
} |
334 |
+ |
|
335 |
+ |
#ifdef IS_MPI |
336 |
+ |
sprintf( checkPointMsg, "TraPPE_ExFF functions succesfully wrapped." ); |
337 |
+ |
MPIcheckPoint(); |
338 |
+ |
#endif // is_mpi |
339 |
+ |
} |
340 |
+ |
|
341 |
+ |
|
342 |
+ |
void TPEfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon, |
343 |
+ |
double* sigma, int* isDipole, |
344 |
+ |
int* isSSD, double* dipole, double* w0, |
345 |
+ |
double* v0, int* isError ), |
346 |
+ |
void (*p2)( int*, int*, int* ), |
347 |
+ |
void (*p3)( double*,double*,double*,double*, |
348 |
+ |
short int*, int* ) ){ |
349 |
+ |
|
350 |
+ |
|
351 |
+ |
newTPEtype = p1; |
352 |
+ |
initTPEfortran = p2; |
353 |
+ |
currentTPEwrap->setTPEfortran( p3 ); |
354 |
+ |
} |
355 |
+ |
|
356 |
+ |
|
357 |
+ |
|
358 |
|
void TraPPE_ExFF::initializeAtoms( void ){ |
359 |
|
|
360 |
|
class LinkedType { |
371 |
|
return NULL; |
372 |
|
} |
373 |
|
|
256 |
– |
#ifdef IS_MPI |
374 |
|
void add( atomStruct &info ){ |
375 |
+ |
|
376 |
+ |
// check for duplicates |
377 |
+ |
|
378 |
+ |
if( !strcmp( info.name, name ) ){ |
379 |
+ |
sprintf( painCave.errMsg, |
380 |
+ |
"Duplicate TraPPE_Ex atom type \"%s\" found in " |
381 |
+ |
"the TraPPE_ExFF param file./n", |
382 |
+ |
name ); |
383 |
+ |
painCave.isFatal = 1; |
384 |
+ |
simError(); |
385 |
+ |
} |
386 |
+ |
|
387 |
|
if( next != NULL ) next->add(info); |
388 |
|
else{ |
389 |
|
next = new LinkedType(); |
390 |
|
strcpy(next->name, info.name); |
391 |
< |
next->isDipole = info.dipole; |
391 |
> |
next->isDipole = info.isDipole; |
392 |
> |
next->isSSD = info.isSSD; |
393 |
|
next->mass = info.mass; |
394 |
|
next->epslon = info.epslon; |
395 |
|
next->sigma = info.sigma; |
396 |
|
next->dipole = info.dipole; |
397 |
+ |
next->w0 = info.w0; |
398 |
+ |
next->v0 = info.v0; |
399 |
+ |
next->ident = info.ident; |
400 |
|
} |
401 |
|
} |
402 |
+ |
|
403 |
+ |
#ifdef IS_MPI |
404 |
|
|
405 |
|
void duplicate( atomStruct &info ){ |
406 |
|
strcpy(info.name, name); |
407 |
< |
info.isDipole = dipole; |
407 |
> |
info.isDipole = isDipole; |
408 |
> |
info.isSSD = isSSD; |
409 |
|
info.mass = mass; |
410 |
|
info.epslon = epslon; |
411 |
|
info.sigma = sigma; |
412 |
|
info.dipole = dipole; |
413 |
+ |
info.w0 = w0; |
414 |
+ |
info.v0 = v0; |
415 |
|
info.last = 0; |
416 |
|
} |
417 |
|
|
420 |
|
|
421 |
|
char name[15]; |
422 |
|
int isDipole; |
423 |
+ |
int isSSD; |
424 |
|
double mass; |
425 |
|
double epslon; |
426 |
|
double sigma; |
427 |
|
double dipole; |
428 |
+ |
double w0; |
429 |
+ |
double v0; |
430 |
+ |
int ident; |
431 |
|
LinkedType* next; |
432 |
|
}; |
433 |
|
|
434 |
|
LinkedType* headAtomType; |
435 |
|
LinkedType* currentAtomType; |
294 |
– |
LinkedType* tempAtomType; |
295 |
– |
|
296 |
– |
#ifdef IS_MPI |
436 |
|
atomStruct info; |
437 |
|
info.last = 1; // initialize last to have the last set. |
438 |
|
// if things go well, last will be set to 0 |
439 |
< |
#endif |
439 |
> |
|
440 |
|
|
441 |
|
|
303 |
– |
char readLine[500]; |
304 |
– |
char* the_token; |
305 |
– |
char* eof_test; |
306 |
– |
int foundAtom = 0; |
307 |
– |
int lineNum = 0; |
442 |
|
int i; |
443 |
< |
|
443 |
> |
int identNum; |
444 |
|
|
445 |
+ |
Atom** the_atoms; |
446 |
+ |
int nAtoms; |
447 |
+ |
the_atoms = entry_plug->atoms; |
448 |
+ |
nAtoms = entry_plug->n_atoms; |
449 |
+ |
|
450 |
+ |
|
451 |
|
////////////////////////////////////////////////// |
452 |
|
// a quick water fix |
453 |
|
|
482 |
|
|
483 |
|
////////////////////////////////////////////////// |
484 |
|
|
485 |
< |
Atom** the_atoms; |
346 |
< |
int nAtoms; |
347 |
< |
the_atoms = entry_plug->atoms; |
348 |
< |
nAtoms = entry_plug->n_atoms; |
349 |
< |
|
350 |
< |
|
485 |
> |
|
486 |
|
#ifdef IS_MPI |
487 |
|
if( worldRank == 0 ){ |
488 |
|
#endif |
489 |
|
|
490 |
|
// read in the atom types. |
491 |
< |
|
357 |
< |
rewind( frcFile ); |
491 |
> |
|
492 |
|
headAtomType = new LinkedType; |
359 |
– |
currentAtomType = headAtomType; |
493 |
|
|
494 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
495 |
< |
lineNum++; |
363 |
< |
if( eof_test == NULL ){ |
364 |
< |
sprintf( painCave.errMsg, "Error in reading Atoms from force file.\n" ); |
365 |
< |
painCave.isFatal = 1; |
366 |
< |
simError(); |
367 |
< |
} |
368 |
< |
|
369 |
< |
|
370 |
< |
while( !foundAtom ){ |
371 |
< |
while( eof_test != NULL && readLine[0] != '#' ){ |
372 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
373 |
< |
lineNum++; |
374 |
< |
} |
375 |
< |
if( eof_test == NULL ){ |
376 |
< |
sprintf( painCave.errMsg, |
377 |
< |
"Error in reading Atoms from force file at line %d.\n", |
378 |
< |
lineNum ); |
379 |
< |
painCave.isFatal = 1; |
380 |
< |
simError(); |
381 |
< |
} |
382 |
< |
|
383 |
< |
the_token = strtok( readLine, " ,;\t#\n" ); |
384 |
< |
foundAtom = !strcmp( "AtomTypes", the_token ); |
385 |
< |
|
386 |
< |
if( !foundAtom ){ |
387 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
388 |
< |
lineNum++; |
389 |
< |
|
390 |
< |
if( eof_test == NULL ){ |
391 |
< |
sprintf( painCave.errMsg, |
392 |
< |
"Error in reading Atoms from force file at line %d.\n", |
393 |
< |
lineNum ); |
394 |
< |
painCave.isFatal = 1; |
395 |
< |
simError(); |
396 |
< |
} |
397 |
< |
} |
398 |
< |
} |
399 |
< |
|
494 |
> |
fastForward( "AtomTypes", "initializeAtoms" ); |
495 |
> |
|
496 |
|
// we are now at the AtomTypes section. |
497 |
|
|
498 |
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
499 |
|
lineNum++; |
500 |
|
|
501 |
+ |
|
502 |
+ |
// read a line, and start parseing out the atom types |
503 |
+ |
|
504 |
|
if( eof_test == NULL ){ |
505 |
|
sprintf( painCave.errMsg, |
506 |
|
"Error in reading Atoms from force file at line %d.\n", |
509 |
|
simError(); |
510 |
|
} |
511 |
|
|
512 |
+ |
identNum = 1; |
513 |
+ |
// stop reading at end of file, or at next section |
514 |
|
while( readLine[0] != '#' && eof_test != NULL ){ |
515 |
< |
|
515 |
> |
|
516 |
> |
// toss comment lines |
517 |
|
if( readLine[0] != '!' ){ |
518 |
|
|
519 |
< |
the_token = strtok( readLine, " \n\t,;" ); |
520 |
< |
if( the_token != NULL ){ |
521 |
< |
|
522 |
< |
strcpy( currentAtomType->name, the_token ); |
523 |
< |
|
422 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
423 |
< |
sprintf( painCave.errMsg, |
424 |
< |
"Error parseing AtomTypes: line %d\n", lineNum ); |
425 |
< |
painCave.isFatal = 1; |
426 |
< |
simError(); |
427 |
< |
} |
428 |
< |
|
429 |
< |
sscanf( the_token, "%d", ¤tAtomType->isDipole ); |
430 |
< |
|
431 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
432 |
< |
sprintf( painCave.errMsg, |
433 |
< |
"Error parseing AtomTypes: line %d\n", lineNum ); |
434 |
< |
painCave.isFatal = 1; |
435 |
< |
simError(); |
436 |
< |
} |
437 |
< |
|
438 |
< |
sscanf( the_token, "%lf", ¤tAtomType->mass ); |
439 |
< |
|
440 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
441 |
< |
sprintf( painCave.errMsg, |
442 |
< |
"Error parseing AtomTypes: line %d\n", lineNum ); |
443 |
< |
painCave.isFatal = 1; |
444 |
< |
simError(); |
445 |
< |
} |
446 |
< |
|
447 |
< |
sscanf( the_token, "%lf", ¤tAtomType->epslon ); |
448 |
< |
|
449 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
450 |
< |
sprintf( painCave.errMsg, |
451 |
< |
"Error parseing AtomTypes: line %d\n", lineNum ); |
452 |
< |
painCave.isFatal = 1; |
453 |
< |
simError(); |
454 |
< |
} |
455 |
< |
|
456 |
< |
sscanf( the_token, "%lf", ¤tAtomType->sigma ); |
457 |
< |
|
458 |
< |
if( currentAtomType->isDipole ){ |
459 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
460 |
< |
sprintf( painCave.errMsg, |
461 |
< |
"Error parseing AtomTypes: line %d\n", |
462 |
< |
lineNum ); |
463 |
< |
painCave.isFatal = 1; |
464 |
< |
simError(); |
465 |
< |
} |
466 |
< |
|
467 |
< |
sscanf( the_token, "%lf", ¤tAtomType->dipole ); |
468 |
< |
} |
519 |
> |
// the parser returns 0 if the line was blank |
520 |
> |
if( parseAtom( readLine, lineNum, info ) ){ |
521 |
> |
info.ident = identNum; |
522 |
> |
headAtomType->add( info );; |
523 |
> |
identNum++; |
524 |
|
} |
525 |
|
} |
471 |
– |
|
472 |
– |
tempAtomType = new LinkedType; |
473 |
– |
currentAtomType->next = tempAtomType; |
474 |
– |
currentAtomType = tempAtomType; |
475 |
– |
|
526 |
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
527 |
|
lineNum++; |
528 |
|
} |
532 |
|
// send out the linked list to all the other processes |
533 |
|
|
534 |
|
sprintf( checkPointMsg, |
535 |
< |
"TraPPE_Ex atom structures read successfully." ); |
535 |
> |
"TraPPE_ExFF atom structures read successfully." ); |
536 |
|
MPIcheckPoint(); |
537 |
|
|
538 |
< |
currentAtomType = headAtomType; |
538 |
> |
currentAtomType = headAtomType->next; //skip the first element who is a place holder. |
539 |
|
while( currentAtomType != NULL ){ |
540 |
|
currentAtomType->duplicate( info ); |
541 |
+ |
|
542 |
+ |
|
543 |
+ |
|
544 |
|
sendFrcStruct( &info, mpiAtomStructType ); |
545 |
+ |
|
546 |
+ |
sprintf( checkPointMsg, |
547 |
+ |
"successfully sent TraPPE_Ex force type: \"%s\"\n", |
548 |
+ |
info.name ); |
549 |
+ |
MPIcheckPoint(); |
550 |
+ |
|
551 |
|
currentAtomType = currentAtomType->next; |
552 |
|
} |
553 |
|
info.last = 1; |
563 |
|
|
564 |
|
headAtomType = new LinkedType; |
565 |
|
recieveFrcStruct( &info, mpiAtomStructType ); |
566 |
+ |
|
567 |
|
while( !info.last ){ |
568 |
|
|
569 |
+ |
|
570 |
+ |
|
571 |
|
headAtomType->add( info ); |
572 |
+ |
|
573 |
+ |
MPIcheckPoint(); |
574 |
+ |
|
575 |
|
recieveFrcStruct( &info, mpiAtomStructType ); |
576 |
|
} |
577 |
|
} |
578 |
|
#endif // is_mpi |
579 |
|
|
580 |
+ |
// call new A_types in fortran |
581 |
|
|
582 |
+ |
int isError; |
583 |
+ |
currentAtomType = headAtomType; |
584 |
+ |
while( currentAtomType != NULL ){ |
585 |
+ |
|
586 |
+ |
if( currentAtomType->name[0] != '\0' ){ |
587 |
+ |
isError = 0; |
588 |
+ |
newTPEtype( &(currentAtomType->ident), |
589 |
+ |
&(currentAtomType->mass), |
590 |
+ |
&(currentAtomType->epslon), |
591 |
+ |
&(currentAtomType->sigma), |
592 |
+ |
&(currentAtomType->isDipole), |
593 |
+ |
&(currentAtomType->isSSD), |
594 |
+ |
&(currentAtomType->dipole), |
595 |
+ |
&(currentAtomType->w0), |
596 |
+ |
&(currentAtomType->v0), |
597 |
+ |
&isError ); |
598 |
+ |
if( isError ){ |
599 |
+ |
sprintf( painCave.errMsg, |
600 |
+ |
"Error initializing the \"%s\" atom type in fortran\n", |
601 |
+ |
currentAtomType->name ); |
602 |
+ |
painCave.isFatal = 1; |
603 |
+ |
simError(); |
604 |
+ |
} |
605 |
+ |
} |
606 |
+ |
currentAtomType = currentAtomType->next; |
607 |
+ |
} |
608 |
+ |
|
609 |
+ |
#ifdef IS_MPI |
610 |
+ |
sprintf( checkPointMsg, |
611 |
+ |
"TraPPE_ExFF atom structures successfully sent to fortran\n" ); |
612 |
+ |
MPIcheckPoint(); |
613 |
+ |
#endif // is_mpi |
614 |
+ |
|
615 |
+ |
|
616 |
|
// initialize the atoms |
617 |
|
|
618 |
+ |
double bigSigma = 0.0; |
619 |
|
DirectionalAtom* dAtom; |
620 |
|
|
621 |
|
for( i=0; i<nAtoms; i++ ){ |
634 |
|
the_atoms[i]->setSigma( currentAtomType->sigma ); |
635 |
|
the_atoms[i]->setLJ(); |
636 |
|
|
637 |
+ |
if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma; |
638 |
+ |
|
639 |
|
if( currentAtomType->isDipole ){ |
640 |
|
if( the_atoms[i]->isDirectional() ){ |
641 |
|
|
684 |
|
} |
685 |
|
} |
686 |
|
} |
687 |
+ |
|
688 |
+ |
#ifdef IS_MPI |
689 |
+ |
double tempBig = bigSigma; |
690 |
+ |
MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX ); |
691 |
+ |
#endif //is_mpi |
692 |
+ |
|
693 |
+ |
//calc rCut and rList |
694 |
+ |
|
695 |
+ |
entry_plug->rCut = 2.5 * bigSigma; |
696 |
+ |
|
697 |
+ |
if(entry_plug->rCut > (entry_plug->box_x / 2.0)) |
698 |
+ |
entry_plug->rCut = entry_plug->box_x / 2.0; |
699 |
+ |
|
700 |
+ |
if(entry_plug->rCut > (entry_plug->box_y / 2.0)) |
701 |
+ |
entry_plug->rCut = entry_plug->box_y / 2.0; |
702 |
+ |
|
703 |
+ |
if(entry_plug->rCut > (entry_plug->box_z / 2.0)) |
704 |
+ |
entry_plug->rCut = entry_plug->box_z / 2.0; |
705 |
|
|
706 |
+ |
entry_plug->rList = entry_plug->rCut + 1.0; |
707 |
|
|
708 |
+ |
|
709 |
|
// clean up the memory |
710 |
|
|
711 |
|
delete headAtomType; |
736 |
|
return NULL; |
737 |
|
} |
738 |
|
|
739 |
< |
#ifdef IS_MPI |
739 |
> |
|
740 |
|
void add( bondStruct &info ){ |
741 |
+ |
|
742 |
+ |
// check for duplicates |
743 |
+ |
int dup = 0; |
744 |
+ |
|
745 |
+ |
if( !strcmp(nameA, info.nameA ) && !strcmp( nameB, info.nameB ) ) dup = 1; |
746 |
+ |
if( !strcmp(nameA, info.nameB ) && !strcmp( nameB, info.nameA ) ) dup = 1; |
747 |
+ |
|
748 |
+ |
if(dup){ |
749 |
+ |
sprintf( painCave.errMsg, |
750 |
+ |
"Duplicate TraPPE_Ex bond type \"%s - %s\" found in " |
751 |
+ |
"the TraPPE_ExFF param file./n", |
752 |
+ |
nameA, nameB ); |
753 |
+ |
painCave.isFatal = 1; |
754 |
+ |
simError(); |
755 |
+ |
} |
756 |
+ |
|
757 |
+ |
|
758 |
|
if( next != NULL ) next->add(info); |
759 |
|
else{ |
760 |
|
next = new LinkedType(); |
765 |
|
} |
766 |
|
} |
767 |
|
|
768 |
+ |
#ifdef IS_MPI |
769 |
|
void duplicate( bondStruct &info ){ |
770 |
|
strcpy(info.nameA, nameA); |
771 |
|
strcpy(info.nameB, nameB); |
789 |
|
|
790 |
|
LinkedType* headBondType; |
791 |
|
LinkedType* currentBondType; |
651 |
– |
LinkedType* tempBondType; |
652 |
– |
|
653 |
– |
#ifdef IS_MPI |
792 |
|
bondStruct info; |
793 |
|
info.last = 1; // initialize last to have the last set. |
794 |
|
// if things go well, last will be set to 0 |
657 |
– |
#endif |
795 |
|
|
659 |
– |
char readLine[500]; |
660 |
– |
char* the_token; |
661 |
– |
char* eof_test; |
662 |
– |
int foundBond = 0; |
663 |
– |
int lineNum = 0; |
664 |
– |
int i, a, b; |
665 |
– |
char* atomA; |
666 |
– |
char* atomB; |
667 |
– |
|
796 |
|
SRI **the_sris; |
797 |
|
Atom** the_atoms; |
798 |
|
int nBonds; |
800 |
|
the_atoms = entry_plug->atoms; |
801 |
|
nBonds = entry_plug->n_bonds; |
802 |
|
|
803 |
+ |
int i, a, b; |
804 |
+ |
char* atomA; |
805 |
+ |
char* atomB; |
806 |
|
|
807 |
|
#ifdef IS_MPI |
808 |
|
if( worldRank == 0 ){ |
810 |
|
|
811 |
|
// read in the bond types. |
812 |
|
|
682 |
– |
rewind( frcFile ); |
813 |
|
headBondType = new LinkedType; |
684 |
– |
currentBondType = headBondType; |
814 |
|
|
815 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
815 |
> |
fastForward( "BondTypes", "initializeBonds" ); |
816 |
> |
|
817 |
> |
// we are now at the bondTypes section |
818 |
> |
|
819 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
820 |
|
lineNum++; |
688 |
– |
if( eof_test == NULL ){ |
689 |
– |
sprintf( painCave.errMsg, "Error in reading Bonds from force file.\n" ); |
690 |
– |
painCave.isFatal = 1; |
691 |
– |
simError(); |
692 |
– |
} |
821 |
|
|
822 |
|
|
823 |
< |
while( !foundBond ){ |
824 |
< |
while( eof_test != NULL && readLine[0] != '#' ){ |
697 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
698 |
< |
lineNum++; |
699 |
< |
} |
700 |
< |
if( eof_test == NULL ){ |
701 |
< |
sprintf( painCave.errMsg, |
702 |
< |
"Error in reading Bonds from force file at line %d.\n", |
703 |
< |
lineNum ); |
704 |
< |
painCave.isFatal = 1; |
705 |
< |
simError(); |
706 |
< |
} |
707 |
< |
|
708 |
< |
the_token = strtok( readLine, " ,;\t#\n" ); |
709 |
< |
foundBond = !strcmp( "BondTypes", the_token ); |
710 |
< |
|
711 |
< |
if( !foundBond ){ |
712 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
713 |
< |
lineNum++; |
714 |
< |
|
715 |
< |
if( eof_test == NULL ){ |
716 |
< |
sprintf( painCave.errMsg, |
717 |
< |
"Error in reading Bonds from force file at line %d.\n", |
718 |
< |
lineNum ); |
719 |
< |
painCave.isFatal = 1; |
720 |
< |
simError(); |
721 |
< |
} |
722 |
< |
} |
723 |
< |
} |
724 |
< |
|
725 |
< |
// we are now at the BondTypes section. |
726 |
< |
|
727 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
728 |
< |
lineNum++; |
729 |
< |
|
823 |
> |
// read a line, and start parseing out the atom types |
824 |
> |
|
825 |
|
if( eof_test == NULL ){ |
826 |
|
sprintf( painCave.errMsg, |
827 |
< |
"Error in reading Bonds from force file at line %d.\n", |
827 |
> |
"Error in reading bonds from force file at line %d.\n", |
828 |
|
lineNum ); |
829 |
|
painCave.isFatal = 1; |
830 |
|
simError(); |
831 |
|
} |
832 |
|
|
833 |
+ |
// stop reading at end of file, or at next section |
834 |
|
while( readLine[0] != '#' && eof_test != NULL ){ |
835 |
< |
|
835 |
> |
|
836 |
> |
// toss comment lines |
837 |
|
if( readLine[0] != '!' ){ |
838 |
|
|
839 |
< |
the_token = strtok( readLine, " \n\t,;" ); |
840 |
< |
if( the_token != NULL ){ |
841 |
< |
|
745 |
< |
strcpy( currentBondType->nameA, the_token ); |
746 |
< |
|
747 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
748 |
< |
sprintf( painCave.errMsg, |
749 |
< |
"Error parseing BondTypes: line %d\n", lineNum ); |
750 |
< |
painCave.isFatal = 1; |
751 |
< |
simError(); |
752 |
< |
} |
753 |
< |
|
754 |
< |
strcpy( currentBondType->nameB, the_token ); |
755 |
< |
|
756 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
757 |
< |
sprintf( painCave.errMsg, |
758 |
< |
"Error parseing BondTypes: line %d\n", lineNum ); |
759 |
< |
painCave.isFatal = 1; |
760 |
< |
simError(); |
761 |
< |
} |
762 |
< |
|
763 |
< |
strcpy( currentBondType->type, the_token ); |
764 |
< |
|
765 |
< |
if( !strcmp( currentBondType->type, "fixed" ) ){ |
766 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
767 |
< |
sprintf( painCave.errMsg, |
768 |
< |
"Error parseing BondTypes: line %d\n", lineNum ); |
769 |
< |
painCave.isFatal = 1; |
770 |
< |
simError(); |
771 |
< |
} |
772 |
< |
|
773 |
< |
sscanf( the_token, "%lf", ¤tBondType->d0 ); |
774 |
< |
} |
775 |
< |
|
776 |
< |
else{ |
777 |
< |
sprintf( painCave.errMsg, |
778 |
< |
"Unknown TraPPE_Ex bond type \"%s\" at line %d\n", |
779 |
< |
currentBondType->type, |
780 |
< |
lineNum ); |
781 |
< |
painCave.isFatal = 1; |
782 |
< |
simError(); |
783 |
< |
} |
839 |
> |
// the parser returns 0 if the line was blank |
840 |
> |
if( parseBond( readLine, lineNum, info ) ){ |
841 |
> |
headBondType->add( info ); |
842 |
|
} |
843 |
|
} |
786 |
– |
|
787 |
– |
tempBondType = new LinkedType; |
788 |
– |
currentBondType->next = tempBondType; |
789 |
– |
currentBondType = tempBondType; |
790 |
– |
|
844 |
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
845 |
|
lineNum++; |
846 |
|
} |
847 |
< |
|
847 |
> |
|
848 |
|
#ifdef IS_MPI |
849 |
|
|
850 |
|
// send out the linked list to all the other processes |
943 |
|
return NULL; |
944 |
|
} |
945 |
|
|
893 |
– |
#ifdef IS_MPI |
894 |
– |
|
946 |
|
void add( bendStruct &info ){ |
947 |
+ |
|
948 |
+ |
// check for duplicates |
949 |
+ |
int dup = 0; |
950 |
+ |
|
951 |
+ |
if( !strcmp( nameA, info.nameA ) && !strcmp( nameB, info.nameB ) |
952 |
+ |
&& !strcmp( nameC, info.nameC ) ) dup = 1; |
953 |
+ |
if( !strcmp( nameA, info.nameC ) && !strcmp( nameB, info.nameB ) |
954 |
+ |
&& !strcmp( nameC, info.nameA ) ) dup = 1; |
955 |
+ |
|
956 |
+ |
if(dup){ |
957 |
+ |
sprintf( painCave.errMsg, |
958 |
+ |
"Duplicate TraPPE_Ex bend type \"%s - %s - %s\" found in " |
959 |
+ |
"the TraPPE_ExFF param file./n", |
960 |
+ |
nameA, nameB, nameC ); |
961 |
+ |
painCave.isFatal = 1; |
962 |
+ |
simError(); |
963 |
+ |
} |
964 |
+ |
|
965 |
|
if( next != NULL ) next->add(info); |
966 |
|
else{ |
967 |
|
next = new LinkedType(); |
975 |
|
next->t0 = info.t0; |
976 |
|
} |
977 |
|
} |
978 |
< |
|
978 |
> |
|
979 |
> |
#ifdef IS_MPI |
980 |
> |
|
981 |
|
void duplicate( bendStruct &info ){ |
982 |
|
strcpy(info.nameA, nameA); |
983 |
|
strcpy(info.nameB, nameB); |
1003 |
|
|
1004 |
|
LinkedType* headBendType; |
1005 |
|
LinkedType* currentBendType; |
935 |
– |
LinkedType* tempBendType; |
936 |
– |
|
937 |
– |
#ifdef IS_MPI |
1006 |
|
bendStruct info; |
1007 |
|
info.last = 1; // initialize last to have the last set. |
1008 |
|
// if things go well, last will be set to 0 |
941 |
– |
#endif |
1009 |
|
|
943 |
– |
char readLine[500]; |
944 |
– |
char* the_token; |
945 |
– |
char* eof_test; |
946 |
– |
int foundBend = 0; |
947 |
– |
int lineNum = 0; |
948 |
– |
int i, a, b, c, index; |
949 |
– |
char* atomA; |
950 |
– |
char* atomB; |
951 |
– |
char* atomC; |
1010 |
|
QuadraticBend* qBend; |
953 |
– |
|
1011 |
|
SRI **the_sris; |
1012 |
|
Atom** the_atoms; |
1013 |
|
int nBends; |
1015 |
|
the_atoms = entry_plug->atoms; |
1016 |
|
nBends = entry_plug->n_bends; |
1017 |
|
|
1018 |
+ |
int i, a, b, c; |
1019 |
+ |
char* atomA; |
1020 |
+ |
char* atomB; |
1021 |
+ |
char* atomC; |
1022 |
|
|
1023 |
+ |
|
1024 |
|
#ifdef IS_MPI |
1025 |
|
if( worldRank == 0 ){ |
1026 |
|
#endif |
1027 |
|
|
1028 |
|
// read in the bend types. |
1029 |
|
|
968 |
– |
rewind( frcFile ); |
1030 |
|
headBendType = new LinkedType; |
970 |
– |
currentBendType = headBendType; |
971 |
– |
|
972 |
– |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
973 |
– |
lineNum++; |
974 |
– |
if( eof_test == NULL ){ |
975 |
– |
sprintf( painCave.errMsg, "Error in reading Bends from force file.\n" ); |
976 |
– |
painCave.isFatal = 1; |
977 |
– |
simError(); |
978 |
– |
} |
979 |
– |
|
980 |
– |
|
981 |
– |
while( !foundBend ){ |
982 |
– |
while( eof_test != NULL && readLine[0] != '#' ){ |
983 |
– |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
984 |
– |
lineNum++; |
985 |
– |
} |
986 |
– |
if( eof_test == NULL ){ |
987 |
– |
sprintf( painCave.errMsg, |
988 |
– |
"Error in reading Bends from force file at line %d.\n", |
989 |
– |
lineNum ); |
990 |
– |
painCave.isFatal = 1; |
991 |
– |
simError(); |
992 |
– |
} |
993 |
– |
|
994 |
– |
the_token = strtok( readLine, " ,;\t#\n" ); |
995 |
– |
foundBend = !strcmp( "BendTypes", the_token ); |
1031 |
|
|
1032 |
< |
if( !foundBend ){ |
998 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
999 |
< |
lineNum++; |
1032 |
> |
fastForward( "BendTypes", "initializeBends" ); |
1033 |
|
|
1034 |
< |
if( eof_test == NULL ){ |
1002 |
< |
sprintf( painCave.errMsg, |
1003 |
< |
"Error in reading Bends from force file at line %d.\n", |
1004 |
< |
lineNum ); |
1005 |
< |
painCave.isFatal = 1; |
1006 |
< |
simError(); |
1007 |
< |
} |
1008 |
< |
} |
1009 |
< |
} |
1034 |
> |
// we are now at the bendTypes section |
1035 |
|
|
1036 |
< |
// we are now at the BendTypes section. |
1012 |
< |
|
1013 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
1036 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
1037 |
|
lineNum++; |
1038 |
< |
|
1038 |
> |
|
1039 |
> |
// read a line, and start parseing out the bend types |
1040 |
> |
|
1041 |
|
if( eof_test == NULL ){ |
1042 |
|
sprintf( painCave.errMsg, |
1043 |
< |
"Error in reading Bends from force file at line %d.\n", |
1043 |
> |
"Error in reading bends from force file at line %d.\n", |
1044 |
|
lineNum ); |
1045 |
|
painCave.isFatal = 1; |
1046 |
|
simError(); |
1047 |
|
} |
1023 |
– |
|
1024 |
– |
while( readLine[0] != '#' && eof_test != NULL ){ |
1048 |
|
|
1049 |
< |
if( readLine[0] != '!' ){ |
1049 |
> |
// stop reading at end of file, or at next section |
1050 |
> |
while( readLine[0] != '#' && eof_test != NULL ){ |
1051 |
|
|
1052 |
< |
the_token = strtok( readLine, " \n\t,;" ); |
1053 |
< |
if( the_token != NULL ){ |
1052 |
> |
// toss comment lines |
1053 |
> |
if( readLine[0] != '!' ){ |
1054 |
|
|
1055 |
< |
strcpy( currentBendType->nameA, the_token ); |
1056 |
< |
|
1057 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1034 |
< |
sprintf( painCave.errMsg, |
1035 |
< |
"Error parseing BendTypes: line %d\n", lineNum ); |
1036 |
< |
painCave.isFatal = 1; |
1037 |
< |
simError(); |
1038 |
< |
} |
1039 |
< |
|
1040 |
< |
strcpy( currentBendType->nameB, the_token ); |
1041 |
< |
|
1042 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1043 |
< |
sprintf( painCave.errMsg, |
1044 |
< |
"Error parseing BendTypes: line %d\n", lineNum ); |
1045 |
< |
painCave.isFatal = 1; |
1046 |
< |
simError(); |
1047 |
< |
} |
1048 |
< |
|
1049 |
< |
strcpy( currentBendType->nameC, the_token ); |
1050 |
< |
|
1051 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1052 |
< |
sprintf( painCave.errMsg, |
1053 |
< |
"Error parseing BendTypes: line %d\n", lineNum ); |
1054 |
< |
painCave.isFatal = 1; |
1055 |
< |
simError(); |
1056 |
< |
} |
1057 |
< |
|
1058 |
< |
strcpy( currentBendType->type, the_token ); |
1059 |
< |
|
1060 |
< |
if( !strcmp( currentBendType->type, "quadratic" ) ){ |
1061 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1062 |
< |
sprintf( painCave.errMsg, |
1063 |
< |
"Error parseing BendTypes: line %d\n", lineNum ); |
1064 |
< |
painCave.isFatal = 1; |
1065 |
< |
simError(); |
1066 |
< |
} |
1067 |
< |
|
1068 |
< |
sscanf( the_token, "%lf", ¤tBendType->k1 ); |
1069 |
< |
|
1070 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1071 |
< |
sprintf( painCave.errMsg, |
1072 |
< |
"Error parseing BendTypes: line %d\n", lineNum ); |
1073 |
< |
painCave.isFatal = 1; |
1074 |
< |
simError(); |
1075 |
< |
} |
1076 |
< |
|
1077 |
< |
sscanf( the_token, "%lf", ¤tBendType->k2 ); |
1078 |
< |
|
1079 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1080 |
< |
sprintf( painCave.errMsg, |
1081 |
< |
"Error parseing BendTypes: line %d\n", lineNum ); |
1082 |
< |
painCave.isFatal = 1; |
1083 |
< |
simError(); |
1084 |
< |
} |
1085 |
< |
|
1086 |
< |
sscanf( the_token, "%lf", ¤tBendType->k3 ); |
1087 |
< |
|
1088 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1089 |
< |
sprintf( painCave.errMsg, |
1090 |
< |
"Error parseing BendTypes: line %d\n", lineNum ); |
1091 |
< |
painCave.isFatal = 1; |
1092 |
< |
simError(); |
1093 |
< |
} |
1094 |
< |
|
1095 |
< |
sscanf( the_token, "%lf", ¤tBendType->t0 ); |
1096 |
< |
} |
1097 |
< |
|
1098 |
< |
else{ |
1099 |
< |
sprintf( painCave.errMsg, |
1100 |
< |
"Unknown TraPPE_Ex bend type \"%s\" at line %d\n", |
1101 |
< |
currentBendType->type, |
1102 |
< |
lineNum ); |
1103 |
< |
painCave.isFatal = 1; |
1104 |
< |
simError(); |
1105 |
< |
} |
1055 |
> |
// the parser returns 0 if the line was blank |
1056 |
> |
if( parseBend( readLine, lineNum, info ) ){ |
1057 |
> |
headBendType->add( info ); |
1058 |
|
} |
1059 |
|
} |
1108 |
– |
|
1109 |
– |
tempBendType = new LinkedType; |
1110 |
– |
currentBendType->next = tempBendType; |
1111 |
– |
currentBendType = tempBendType; |
1112 |
– |
|
1060 |
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
1061 |
|
lineNum++; |
1062 |
|
} |
1063 |
< |
|
1063 |
> |
|
1064 |
|
#ifdef IS_MPI |
1065 |
|
|
1066 |
|
// send out the linked list to all the other processes |
1097 |
|
#endif // is_mpi |
1098 |
|
|
1099 |
|
// initialize the Bends |
1100 |
+ |
|
1101 |
+ |
int index; |
1102 |
|
|
1103 |
|
for( i=0; i<nBends; i++ ){ |
1104 |
|
|
1162 |
|
!strcmp( nameC, key3 ) && !strcmp( nameD, key4 ) ) return this; |
1163 |
|
|
1164 |
|
if( !strcmp( nameA, key4 ) && !strcmp( nameB, key3 ) && |
1165 |
< |
!strcmp( nameC, key2 ) && !strcmp( nameD, key4 ) ) return this; |
1165 |
> |
!strcmp( nameC, key2 ) && !strcmp( nameD, key1 ) ) return this; |
1166 |
|
|
1167 |
|
if( next != NULL ) return next->find(key1, key2, key3, key4); |
1168 |
|
return NULL; |
1169 |
|
} |
1221 |
– |
|
1222 |
– |
#ifdef IS_MPI |
1170 |
|
|
1171 |
|
void add( torsionStruct &info ){ |
1172 |
+ |
|
1173 |
+ |
// check for duplicates |
1174 |
+ |
int dup = 0; |
1175 |
+ |
|
1176 |
+ |
if( !strcmp( nameA, info.nameA ) && !strcmp( nameB, info.nameB ) && |
1177 |
+ |
!strcmp( nameC, info.nameC ) && !strcmp( nameD, info.nameD ) ) dup = 1; |
1178 |
+ |
|
1179 |
+ |
if( !strcmp( nameA, info.nameD ) && !strcmp( nameB, info.nameC ) && |
1180 |
+ |
!strcmp( nameC, info.nameB ) && !strcmp( nameD, info.nameA ) ) dup = 1; |
1181 |
+ |
|
1182 |
+ |
if(dup){ |
1183 |
+ |
sprintf( painCave.errMsg, |
1184 |
+ |
"Duplicate TraPPE_Ex torsion type \"%s - %s - %s - %s\" found in " |
1185 |
+ |
"the TraPPE_ExFF param file./n", nameA, nameB, nameC, nameD ); |
1186 |
+ |
painCave.isFatal = 1; |
1187 |
+ |
simError(); |
1188 |
+ |
} |
1189 |
+ |
|
1190 |
|
if( next != NULL ) next->add(info); |
1191 |
|
else{ |
1192 |
|
next = new LinkedType(); |
1200 |
|
next->k4 = info.k4; |
1201 |
|
} |
1202 |
|
} |
1203 |
+ |
|
1204 |
+ |
#ifdef IS_MPI |
1205 |
|
|
1206 |
|
void duplicate( torsionStruct &info ){ |
1207 |
|
strcpy(info.nameA, nameA); |
1230 |
|
|
1231 |
|
LinkedType* headTorsionType; |
1232 |
|
LinkedType* currentTorsionType; |
1266 |
– |
LinkedType* tempTorsionType; |
1267 |
– |
|
1268 |
– |
#ifdef IS_MPI |
1233 |
|
torsionStruct info; |
1234 |
|
info.last = 1; // initialize last to have the last set. |
1235 |
|
// if things go well, last will be set to 0 |
1272 |
– |
#endif |
1236 |
|
|
1274 |
– |
char readLine[500]; |
1275 |
– |
char* the_token; |
1276 |
– |
char* eof_test; |
1277 |
– |
int foundTorsion = 0; |
1278 |
– |
int lineNum = 0; |
1237 |
|
int i, a, b, c, d, index; |
1238 |
|
char* atomA; |
1239 |
|
char* atomB; |
1254 |
|
|
1255 |
|
// read in the torsion types. |
1256 |
|
|
1299 |
– |
rewind( frcFile ); |
1257 |
|
headTorsionType = new LinkedType; |
1258 |
< |
currentTorsionType = headTorsionType; |
1259 |
< |
|
1303 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
1304 |
< |
lineNum++; |
1305 |
< |
if( eof_test == NULL ){ |
1306 |
< |
sprintf( painCave.errMsg, |
1307 |
< |
"Error in reading Torsions from force file.\n" ); |
1308 |
< |
painCave.isFatal = 1; |
1309 |
< |
simError(); |
1310 |
< |
} |
1258 |
> |
|
1259 |
> |
fastForward( "TorsionTypes", "initializeTorsions" ); |
1260 |
|
|
1261 |
< |
|
1313 |
< |
while( !foundTorsion ){ |
1314 |
< |
while( eof_test != NULL && readLine[0] != '#' ){ |
1315 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
1316 |
< |
lineNum++; |
1317 |
< |
} |
1318 |
< |
if( eof_test == NULL ){ |
1319 |
< |
sprintf( painCave.errMsg, |
1320 |
< |
"Error in reading Torsions from force file at line %d.\n", |
1321 |
< |
lineNum ); |
1322 |
< |
painCave.isFatal = 1; |
1323 |
< |
simError(); |
1324 |
< |
} |
1261 |
> |
// we are now at the torsionTypes section |
1262 |
|
|
1263 |
< |
the_token = strtok( readLine, " ,;\t#\n" ); |
1264 |
< |
foundTorsion = !strcmp( "TorsionTypes", the_token ); |
1263 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
1264 |
> |
lineNum++; |
1265 |
|
|
1266 |
< |
if( !foundTorsion ){ |
1267 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
1331 |
< |
lineNum++; |
1332 |
< |
|
1333 |
< |
if( eof_test == NULL ){ |
1334 |
< |
sprintf( painCave.errMsg, |
1335 |
< |
"Error in reading Torsions from force file at line %d.\n", |
1336 |
< |
lineNum ); |
1337 |
< |
painCave.isFatal = 1; |
1338 |
< |
simError(); |
1339 |
< |
} |
1340 |
< |
} |
1341 |
< |
} |
1266 |
> |
|
1267 |
> |
// read a line, and start parseing out the atom types |
1268 |
|
|
1343 |
– |
// we are now at the TorsionTypes section. |
1344 |
– |
|
1345 |
– |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
1346 |
– |
lineNum++; |
1347 |
– |
|
1269 |
|
if( eof_test == NULL ){ |
1270 |
|
sprintf( painCave.errMsg, |
1271 |
< |
"Error in reading Torsions from force file at line %d.\n", |
1271 |
> |
"Error in reading torsions from force file at line %d.\n", |
1272 |
|
lineNum ); |
1273 |
|
painCave.isFatal = 1; |
1274 |
|
simError(); |
1275 |
|
} |
1355 |
– |
|
1356 |
– |
while( readLine[0] != '#' && eof_test != NULL ){ |
1276 |
|
|
1277 |
+ |
// stop reading at end of file, or at next section |
1278 |
+ |
while( readLine[0] != '#' && eof_test != NULL ){ |
1279 |
+ |
|
1280 |
+ |
// toss comment lines |
1281 |
|
if( readLine[0] != '!' ){ |
1359 |
– |
|
1360 |
– |
the_token = strtok( readLine, " \n\t,;" ); |
1361 |
– |
if( the_token != NULL ){ |
1282 |
|
|
1283 |
< |
strcpy( currentTorsionType->nameA, the_token ); |
1284 |
< |
|
1285 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1366 |
< |
sprintf( painCave.errMsg, |
1367 |
< |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1368 |
< |
painCave.isFatal = 1; |
1369 |
< |
simError(); |
1370 |
< |
} |
1371 |
< |
|
1372 |
< |
strcpy( currentTorsionType->nameB, the_token ); |
1373 |
< |
|
1374 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1375 |
< |
sprintf( painCave.errMsg, |
1376 |
< |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1377 |
< |
painCave.isFatal = 1; |
1378 |
< |
simError(); |
1379 |
< |
} |
1380 |
< |
|
1381 |
< |
strcpy( currentTorsionType->nameC, the_token ); |
1382 |
< |
|
1383 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1384 |
< |
sprintf( painCave.errMsg, |
1385 |
< |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1386 |
< |
painCave.isFatal = 1; |
1387 |
< |
simError(); |
1388 |
< |
} |
1389 |
< |
|
1390 |
< |
strcpy( currentTorsionType->nameD, the_token ); |
1391 |
< |
|
1392 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1393 |
< |
sprintf( painCave.errMsg, |
1394 |
< |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1395 |
< |
painCave.isFatal = 1; |
1396 |
< |
simError(); |
1397 |
< |
} |
1398 |
< |
|
1399 |
< |
strcpy( currentTorsionType->type, the_token ); |
1400 |
< |
|
1401 |
< |
if( !strcmp( currentTorsionType->type, "cubic" ) ){ |
1402 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1403 |
< |
sprintf( painCave.errMsg, |
1404 |
< |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1405 |
< |
painCave.isFatal = 1; |
1406 |
< |
simError(); |
1407 |
< |
} |
1408 |
< |
|
1409 |
< |
sscanf( the_token, "%lf", ¤tTorsionType->k1 ); |
1410 |
< |
|
1411 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1412 |
< |
sprintf( painCave.errMsg, |
1413 |
< |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1414 |
< |
painCave.isFatal = 1; |
1415 |
< |
simError(); |
1416 |
< |
} |
1417 |
< |
|
1418 |
< |
sscanf( the_token, "%lf", ¤tTorsionType->k2 ); |
1419 |
< |
|
1420 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1421 |
< |
sprintf( painCave.errMsg, |
1422 |
< |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1423 |
< |
painCave.isFatal = 1; |
1424 |
< |
simError(); |
1425 |
< |
} |
1426 |
< |
|
1427 |
< |
sscanf( the_token, "%lf", ¤tTorsionType->k3 ); |
1428 |
< |
|
1429 |
< |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1430 |
< |
sprintf( painCave.errMsg, |
1431 |
< |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1432 |
< |
painCave.isFatal = 1; |
1433 |
< |
simError(); |
1434 |
< |
} |
1435 |
< |
|
1436 |
< |
sscanf( the_token, "%lf", ¤tTorsionType->k4 ); |
1437 |
< |
} |
1438 |
< |
|
1439 |
< |
else{ |
1440 |
< |
sprintf( painCave.errMsg, |
1441 |
< |
"Unknown TraPPE_Ex torsion type \"%s\" at line %d\n", |
1442 |
< |
currentTorsionType->type, |
1443 |
< |
lineNum ); |
1444 |
< |
painCave.isFatal = 1; |
1445 |
< |
simError(); |
1446 |
< |
} |
1283 |
> |
// the parser returns 0 if the line was blank |
1284 |
> |
if( parseTorsion( readLine, lineNum, info ) ){ |
1285 |
> |
headTorsionType->add( info ); |
1286 |
|
} |
1287 |
|
} |
1449 |
– |
|
1450 |
– |
tempTorsionType = new LinkedType; |
1451 |
– |
currentTorsionType->next = tempTorsionType; |
1452 |
– |
currentTorsionType = tempTorsionType; |
1453 |
– |
|
1288 |
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
1289 |
|
lineNum++; |
1290 |
|
} |
1369 |
|
#endif // is_mpi |
1370 |
|
|
1371 |
|
} |
1372 |
+ |
|
1373 |
+ |
void TraPPE_ExFF::fastForward( char* stopText, char* searchOwner ){ |
1374 |
+ |
|
1375 |
+ |
int foundText = 0; |
1376 |
+ |
char* the_token; |
1377 |
+ |
|
1378 |
+ |
rewind( frcFile ); |
1379 |
+ |
lineNum = 0; |
1380 |
+ |
|
1381 |
+ |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
1382 |
+ |
lineNum++; |
1383 |
+ |
if( eof_test == NULL ){ |
1384 |
+ |
sprintf( painCave.errMsg, "Error fast forwarding force file for %s: " |
1385 |
+ |
" file is empty.\n", |
1386 |
+ |
searchOwner ); |
1387 |
+ |
painCave.isFatal = 1; |
1388 |
+ |
simError(); |
1389 |
+ |
} |
1390 |
+ |
|
1391 |
+ |
|
1392 |
+ |
while( !foundText ){ |
1393 |
+ |
while( eof_test != NULL && readLine[0] != '#' ){ |
1394 |
+ |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
1395 |
+ |
lineNum++; |
1396 |
+ |
} |
1397 |
+ |
if( eof_test == NULL ){ |
1398 |
+ |
sprintf( painCave.errMsg, |
1399 |
+ |
"Error fast forwarding force file for %s at " |
1400 |
+ |
"line %d: file ended unexpectedly.\n", |
1401 |
+ |
searchOwner, |
1402 |
+ |
lineNum ); |
1403 |
+ |
painCave.isFatal = 1; |
1404 |
+ |
simError(); |
1405 |
+ |
} |
1406 |
+ |
|
1407 |
+ |
the_token = strtok( readLine, " ,;\t#\n" ); |
1408 |
+ |
foundText = !strcmp( stopText, the_token ); |
1409 |
+ |
|
1410 |
+ |
if( !foundText ){ |
1411 |
+ |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
1412 |
+ |
lineNum++; |
1413 |
+ |
|
1414 |
+ |
if( eof_test == NULL ){ |
1415 |
+ |
sprintf( painCave.errMsg, |
1416 |
+ |
"Error fast forwarding force file for %s at " |
1417 |
+ |
"line %d: file ended unexpectedly.\n", |
1418 |
+ |
searchOwner, |
1419 |
+ |
lineNum ); |
1420 |
+ |
painCave.isFatal = 1; |
1421 |
+ |
simError(); |
1422 |
+ |
} |
1423 |
+ |
} |
1424 |
+ |
} |
1425 |
+ |
} |
1426 |
+ |
|
1427 |
+ |
|
1428 |
+ |
int parseAtom( char *lineBuffer, int lineNum, atomStruct &info ){ |
1429 |
+ |
|
1430 |
+ |
char* the_token; |
1431 |
+ |
|
1432 |
+ |
the_token = strtok( lineBuffer, " \n\t,;" ); |
1433 |
+ |
if( the_token != NULL ){ |
1434 |
+ |
|
1435 |
+ |
strcpy( info.name, the_token ); |
1436 |
+ |
|
1437 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1438 |
+ |
sprintf( painCave.errMsg, |
1439 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
1440 |
+ |
painCave.isFatal = 1; |
1441 |
+ |
simError(); |
1442 |
+ |
} |
1443 |
+ |
|
1444 |
+ |
info.isDipole = atoi( the_token ); |
1445 |
+ |
|
1446 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1447 |
+ |
sprintf( painCave.errMsg, |
1448 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
1449 |
+ |
painCave.isFatal = 1; |
1450 |
+ |
simError(); |
1451 |
+ |
} |
1452 |
+ |
|
1453 |
+ |
info.isSSD = atoi( the_token ); |
1454 |
+ |
|
1455 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1456 |
+ |
sprintf( painCave.errMsg, |
1457 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
1458 |
+ |
painCave.isFatal = 1; |
1459 |
+ |
simError(); |
1460 |
+ |
} |
1461 |
+ |
|
1462 |
+ |
info.mass = atof( the_token ); |
1463 |
+ |
|
1464 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1465 |
+ |
sprintf( painCave.errMsg, |
1466 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
1467 |
+ |
painCave.isFatal = 1; |
1468 |
+ |
simError(); |
1469 |
+ |
} |
1470 |
+ |
|
1471 |
+ |
info.epslon = atof( the_token ); |
1472 |
+ |
|
1473 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1474 |
+ |
sprintf( painCave.errMsg, |
1475 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
1476 |
+ |
painCave.isFatal = 1; |
1477 |
+ |
simError(); |
1478 |
+ |
} |
1479 |
+ |
|
1480 |
+ |
info.sigma = atof( the_token ); |
1481 |
+ |
|
1482 |
+ |
if( info.isDipole ){ |
1483 |
+ |
|
1484 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1485 |
+ |
sprintf( painCave.errMsg, |
1486 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
1487 |
+ |
painCave.isFatal = 1; |
1488 |
+ |
simError(); |
1489 |
+ |
} |
1490 |
+ |
|
1491 |
+ |
info.dipole = atof( the_token ); |
1492 |
+ |
} |
1493 |
+ |
else info.dipole = 0.0; |
1494 |
+ |
|
1495 |
+ |
if( info.isSSD ){ |
1496 |
+ |
|
1497 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1498 |
+ |
sprintf( painCave.errMsg, |
1499 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
1500 |
+ |
painCave.isFatal = 1; |
1501 |
+ |
simError(); |
1502 |
+ |
} |
1503 |
+ |
|
1504 |
+ |
info.w0 = atof( the_token ); |
1505 |
+ |
|
1506 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1507 |
+ |
sprintf( painCave.errMsg, |
1508 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
1509 |
+ |
painCave.isFatal = 1; |
1510 |
+ |
simError(); |
1511 |
+ |
} |
1512 |
+ |
|
1513 |
+ |
info.v0 = atof( the_token ); |
1514 |
+ |
} |
1515 |
+ |
else info.v0 = info.w0 = 0.0; |
1516 |
+ |
|
1517 |
+ |
return 1; |
1518 |
+ |
} |
1519 |
+ |
else return 0; |
1520 |
+ |
} |
1521 |
+ |
|
1522 |
+ |
int parseBond( char *lineBuffer, int lineNum, bondStruct &info ){ |
1523 |
+ |
|
1524 |
+ |
char* the_token; |
1525 |
+ |
|
1526 |
+ |
the_token = strtok( lineBuffer, " \n\t,;" ); |
1527 |
+ |
if( the_token != NULL ){ |
1528 |
+ |
|
1529 |
+ |
strcpy( info.nameA, the_token ); |
1530 |
+ |
|
1531 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1532 |
+ |
sprintf( painCave.errMsg, |
1533 |
+ |
"Error parseing BondTypes: line %d\n", lineNum ); |
1534 |
+ |
painCave.isFatal = 1; |
1535 |
+ |
simError(); |
1536 |
+ |
} |
1537 |
+ |
|
1538 |
+ |
strcpy( info.nameB, the_token ); |
1539 |
+ |
|
1540 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1541 |
+ |
sprintf( painCave.errMsg, |
1542 |
+ |
"Error parseing BondTypes: line %d\n", lineNum ); |
1543 |
+ |
painCave.isFatal = 1; |
1544 |
+ |
simError(); |
1545 |
+ |
} |
1546 |
+ |
|
1547 |
+ |
strcpy( info.type, the_token ); |
1548 |
+ |
|
1549 |
+ |
if( !strcmp( info.type, "fixed" ) ){ |
1550 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1551 |
+ |
sprintf( painCave.errMsg, |
1552 |
+ |
"Error parseing BondTypes: line %d\n", lineNum ); |
1553 |
+ |
painCave.isFatal = 1; |
1554 |
+ |
simError(); |
1555 |
+ |
} |
1556 |
+ |
|
1557 |
+ |
info.d0 = atof( the_token ); |
1558 |
+ |
} |
1559 |
+ |
else{ |
1560 |
+ |
sprintf( painCave.errMsg, |
1561 |
+ |
"Unknown TraPPE_Ex bond type \"%s\" at line %d\n", |
1562 |
+ |
info.type, |
1563 |
+ |
lineNum ); |
1564 |
+ |
painCave.isFatal = 1; |
1565 |
+ |
simError(); |
1566 |
+ |
} |
1567 |
+ |
|
1568 |
+ |
return 1; |
1569 |
+ |
} |
1570 |
+ |
else return 0; |
1571 |
+ |
} |
1572 |
+ |
|
1573 |
+ |
|
1574 |
+ |
int parseBend( char *lineBuffer, int lineNum, bendStruct &info ){ |
1575 |
+ |
|
1576 |
+ |
char* the_token; |
1577 |
+ |
|
1578 |
+ |
the_token = strtok( lineBuffer, " \n\t,;" ); |
1579 |
+ |
if( the_token != NULL ){ |
1580 |
+ |
|
1581 |
+ |
strcpy( info.nameA, the_token ); |
1582 |
+ |
|
1583 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1584 |
+ |
sprintf( painCave.errMsg, |
1585 |
+ |
"Error parseing BondTypes: line %d\n", lineNum ); |
1586 |
+ |
painCave.isFatal = 1; |
1587 |
+ |
simError(); |
1588 |
+ |
} |
1589 |
+ |
|
1590 |
+ |
strcpy( info.nameB, the_token ); |
1591 |
+ |
|
1592 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1593 |
+ |
sprintf( painCave.errMsg, |
1594 |
+ |
"Error parseing BondTypes: line %d\n", lineNum ); |
1595 |
+ |
painCave.isFatal = 1; |
1596 |
+ |
simError(); |
1597 |
+ |
} |
1598 |
+ |
|
1599 |
+ |
strcpy( info.nameC, the_token ); |
1600 |
+ |
|
1601 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1602 |
+ |
sprintf( painCave.errMsg, |
1603 |
+ |
"Error parseing BondTypes: line %d\n", lineNum ); |
1604 |
+ |
painCave.isFatal = 1; |
1605 |
+ |
simError(); |
1606 |
+ |
} |
1607 |
+ |
|
1608 |
+ |
strcpy( info.type, the_token ); |
1609 |
+ |
|
1610 |
+ |
if( !strcmp( info.type, "quadratic" ) ){ |
1611 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1612 |
+ |
sprintf( painCave.errMsg, |
1613 |
+ |
"Error parseing BendTypes: line %d\n", lineNum ); |
1614 |
+ |
painCave.isFatal = 1; |
1615 |
+ |
simError(); |
1616 |
+ |
} |
1617 |
+ |
|
1618 |
+ |
info.k1 = atof( the_token ); |
1619 |
+ |
|
1620 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1621 |
+ |
sprintf( painCave.errMsg, |
1622 |
+ |
"Error parseing BendTypes: line %d\n", lineNum ); |
1623 |
+ |
painCave.isFatal = 1; |
1624 |
+ |
simError(); |
1625 |
+ |
} |
1626 |
+ |
|
1627 |
+ |
info.k2 = atof( the_token ); |
1628 |
+ |
|
1629 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1630 |
+ |
sprintf( painCave.errMsg, |
1631 |
+ |
"Error parseing BendTypes: line %d\n", lineNum ); |
1632 |
+ |
painCave.isFatal = 1; |
1633 |
+ |
simError(); |
1634 |
+ |
} |
1635 |
+ |
|
1636 |
+ |
info.k3 = atof( the_token ); |
1637 |
+ |
|
1638 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1639 |
+ |
sprintf( painCave.errMsg, |
1640 |
+ |
"Error parseing BendTypes: line %d\n", lineNum ); |
1641 |
+ |
painCave.isFatal = 1; |
1642 |
+ |
simError(); |
1643 |
+ |
} |
1644 |
+ |
|
1645 |
+ |
info.t0 = atof( the_token ); |
1646 |
+ |
} |
1647 |
+ |
|
1648 |
+ |
else{ |
1649 |
+ |
sprintf( painCave.errMsg, |
1650 |
+ |
"Unknown TraPPE_Ex bend type \"%s\" at line %d\n", |
1651 |
+ |
info.type, |
1652 |
+ |
lineNum ); |
1653 |
+ |
painCave.isFatal = 1; |
1654 |
+ |
simError(); |
1655 |
+ |
} |
1656 |
+ |
|
1657 |
+ |
return 1; |
1658 |
+ |
} |
1659 |
+ |
else return 0; |
1660 |
+ |
} |
1661 |
+ |
|
1662 |
+ |
int parseTorsion( char *lineBuffer, int lineNum, torsionStruct &info ){ |
1663 |
+ |
|
1664 |
+ |
char* the_token; |
1665 |
+ |
|
1666 |
+ |
the_token = strtok( lineBuffer, " \n\t,;" ); |
1667 |
+ |
if( the_token != NULL ){ |
1668 |
+ |
|
1669 |
+ |
strcpy( info.nameA, the_token ); |
1670 |
+ |
|
1671 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1672 |
+ |
sprintf( painCave.errMsg, |
1673 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1674 |
+ |
painCave.isFatal = 1; |
1675 |
+ |
simError(); |
1676 |
+ |
} |
1677 |
+ |
|
1678 |
+ |
strcpy( info.nameB, the_token ); |
1679 |
+ |
|
1680 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1681 |
+ |
sprintf( painCave.errMsg, |
1682 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1683 |
+ |
painCave.isFatal = 1; |
1684 |
+ |
simError(); |
1685 |
+ |
} |
1686 |
+ |
|
1687 |
+ |
strcpy( info.nameC, the_token ); |
1688 |
+ |
|
1689 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1690 |
+ |
sprintf( painCave.errMsg, |
1691 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1692 |
+ |
painCave.isFatal = 1; |
1693 |
+ |
simError(); |
1694 |
+ |
} |
1695 |
+ |
|
1696 |
+ |
strcpy( info.nameD, the_token ); |
1697 |
+ |
|
1698 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1699 |
+ |
sprintf( painCave.errMsg, |
1700 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1701 |
+ |
painCave.isFatal = 1; |
1702 |
+ |
simError(); |
1703 |
+ |
} |
1704 |
+ |
|
1705 |
+ |
strcpy( info.type, the_token ); |
1706 |
+ |
|
1707 |
+ |
if( !strcmp( info.type, "cubic" ) ){ |
1708 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1709 |
+ |
sprintf( painCave.errMsg, |
1710 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1711 |
+ |
painCave.isFatal = 1; |
1712 |
+ |
simError(); |
1713 |
+ |
} |
1714 |
+ |
|
1715 |
+ |
info.k1 = atof( the_token ); |
1716 |
+ |
|
1717 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1718 |
+ |
sprintf( painCave.errMsg, |
1719 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1720 |
+ |
painCave.isFatal = 1; |
1721 |
+ |
simError(); |
1722 |
+ |
} |
1723 |
+ |
|
1724 |
+ |
info.k2 = atof( the_token ); |
1725 |
+ |
|
1726 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1727 |
+ |
sprintf( painCave.errMsg, |
1728 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1729 |
+ |
painCave.isFatal = 1; |
1730 |
+ |
simError(); |
1731 |
+ |
} |
1732 |
+ |
|
1733 |
+ |
info.k3 = atof( the_token ); |
1734 |
+ |
|
1735 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
1736 |
+ |
sprintf( painCave.errMsg, |
1737 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
1738 |
+ |
painCave.isFatal = 1; |
1739 |
+ |
simError(); |
1740 |
+ |
} |
1741 |
+ |
|
1742 |
+ |
info.k4 = atof( the_token ); |
1743 |
+ |
|
1744 |
+ |
} |
1745 |
+ |
|
1746 |
+ |
else{ |
1747 |
+ |
sprintf( painCave.errMsg, |
1748 |
+ |
"Unknown TraPPE_Ex torsion type \"%s\" at line %d\n", |
1749 |
+ |
info.type, |
1750 |
+ |
lineNum ); |
1751 |
+ |
painCave.isFatal = 1; |
1752 |
+ |
simError(); |
1753 |
+ |
} |
1754 |
+ |
|
1755 |
+ |
return 1; |
1756 |
+ |
} |
1757 |
+ |
|
1758 |
+ |
else return 0; |
1759 |
+ |
} |