| 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 |
+ |
|
| 91 |
+ |
|
| 92 |
+ |
TraPPE_ExFF* currentTPEwrap; |
| 93 |
+ |
|
| 94 |
+ |
using namespace TPE; |
| 95 |
+ |
|
| 96 |
+ |
|
| 97 |
+ |
//**************************************************************** |
| 98 |
+ |
// begins the actual forcefield stuff. |
| 99 |
+ |
//**************************************************************** |
| 100 |
+ |
|
| 101 |
+ |
|
| 102 |
|
TraPPE_ExFF::TraPPE_ExFF(){ |
| 103 |
|
|
| 104 |
|
char fileName[200]; |
| 107 |
|
char temp[200]; |
| 108 |
|
char errMsg[1000]; |
| 109 |
|
|
| 110 |
+ |
// do the funtion wrapping |
| 111 |
+ |
currentTPEwrap = this; |
| 112 |
+ |
wrapMe(); |
| 113 |
+ |
|
| 114 |
+ |
|
| 115 |
|
#ifdef IS_MPI |
| 116 |
|
int i; |
| 117 |
|
|
| 118 |
< |
// ********************************************************************** |
| 118 |
> |
// ********************************************************************** |
| 119 |
|
// Init the atomStruct mpi type |
| 120 |
|
|
| 121 |
|
atomStruct atomProto; // mpiPrototype |
| 122 |
< |
int atomBC[3] = {15,4,2}; // block counts |
| 122 |
> |
int atomBC[3] = {15,6,4}; // block counts |
| 123 |
|
MPI_Aint atomDspls[3]; // displacements |
| 124 |
|
MPI_Datatype atomMbrTypes[3]; // member mpi types |
| 125 |
|
|
| 126 |
|
MPI_Address(&atomProto.name, &atomDspls[0]); |
| 127 |
|
MPI_Address(&atomProto.mass, &atomDspls[1]); |
| 128 |
< |
MPI_Address(&atomProto.isDipole, &atomDspls[2]); |
| 128 |
> |
MPI_Address(&atomProto.isSSD, &atomDspls[2]); |
| 129 |
|
|
| 130 |
|
atomMbrTypes[0] = MPI_CHAR; |
| 131 |
|
atomMbrTypes[1] = MPI_DOUBLE; |
| 275 |
|
#endif // is_mpi |
| 276 |
|
} |
| 277 |
|
|
| 278 |
+ |
|
| 279 |
+ |
void TraPPE_ExFF::wrapMe( void ){ |
| 280 |
+ |
|
| 281 |
+ |
char* currentFF = "TraPPE_Ex"; |
| 282 |
+ |
int isError = 0; |
| 283 |
+ |
|
| 284 |
+ |
forcefactory_( currentFF, &isError, TPEfunctionWrapper, strlen(currentFF) ); |
| 285 |
+ |
|
| 286 |
+ |
if( isError ){ |
| 287 |
+ |
|
| 288 |
+ |
sprintf( painCave.errMsg, |
| 289 |
+ |
"TraPPE_ExFF error: an error was returned from fortran when the " |
| 290 |
+ |
"the functions were being wrapped.\n" ); |
| 291 |
+ |
painCave.isFatal = 1; |
| 292 |
+ |
simError(); |
| 293 |
+ |
} |
| 294 |
+ |
|
| 295 |
+ |
#ifdef IS_MPI |
| 296 |
+ |
sprintf( checkPointMsg, "TraPPE_ExFF functions succesfully wrapped." ); |
| 297 |
+ |
MPIcheckPoint(); |
| 298 |
+ |
#endif // is_mpi |
| 299 |
+ |
} |
| 300 |
+ |
|
| 301 |
+ |
|
| 302 |
+ |
void TPEfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon, |
| 303 |
+ |
double* sigma, int* isDipole, |
| 304 |
+ |
int* isSSD, double* dipole, double* w0, |
| 305 |
+ |
double* v0, int* isError ), |
| 306 |
+ |
void (*p2)( int*, int*, int* ), |
| 307 |
+ |
void (*p3)( double*,double*,double*,double*, |
| 308 |
+ |
short int*, int* ) ){ |
| 309 |
+ |
|
| 310 |
+ |
|
| 311 |
+ |
newTPEtype = p1; |
| 312 |
+ |
initTPEfortran = p2; |
| 313 |
+ |
currentTPEwrap->setTPEfortran( p3 ); |
| 314 |
+ |
} |
| 315 |
+ |
|
| 316 |
+ |
|
| 317 |
+ |
|
| 318 |
|
void TraPPE_ExFF::initializeAtoms( void ){ |
| 319 |
|
|
| 320 |
|
class LinkedType { |
| 331 |
|
return NULL; |
| 332 |
|
} |
| 333 |
|
|
| 256 |
– |
#ifdef IS_MPI |
| 334 |
|
void add( atomStruct &info ){ |
| 335 |
+ |
|
| 336 |
+ |
// check for duplicates |
| 337 |
+ |
|
| 338 |
+ |
if( !strcmp( info.name, name ) ){ |
| 339 |
+ |
sprintf( painCave.errMsg, |
| 340 |
+ |
"Duplicate TraPPE_Ex atom type \"%s\" found in " |
| 341 |
+ |
"the TraPPE_ExFF param file./n", |
| 342 |
+ |
name ); |
| 343 |
+ |
painCave.isFatal = 1; |
| 344 |
+ |
simError(); |
| 345 |
+ |
} |
| 346 |
+ |
|
| 347 |
|
if( next != NULL ) next->add(info); |
| 348 |
|
else{ |
| 349 |
|
next = new LinkedType(); |
| 350 |
|
strcpy(next->name, info.name); |
| 351 |
< |
next->isDipole = info.dipole; |
| 351 |
> |
next->isDipole = info.isDipole; |
| 352 |
> |
next->isSSD = info.isSSD; |
| 353 |
|
next->mass = info.mass; |
| 354 |
|
next->epslon = info.epslon; |
| 355 |
|
next->sigma = info.sigma; |
| 356 |
|
next->dipole = info.dipole; |
| 357 |
+ |
next->w0 = info.w0; |
| 358 |
+ |
next->v0 = info.v0; |
| 359 |
+ |
next->ident = info.ident; |
| 360 |
|
} |
| 361 |
|
} |
| 362 |
+ |
|
| 363 |
+ |
#ifdef IS_MPI |
| 364 |
|
|
| 365 |
|
void duplicate( atomStruct &info ){ |
| 366 |
|
strcpy(info.name, name); |
| 367 |
< |
info.isDipole = dipole; |
| 367 |
> |
info.isDipole = isDipole; |
| 368 |
> |
info.isSSD = isSSD; |
| 369 |
|
info.mass = mass; |
| 370 |
|
info.epslon = epslon; |
| 371 |
|
info.sigma = sigma; |
| 372 |
|
info.dipole = dipole; |
| 373 |
+ |
info.w0 = w0; |
| 374 |
+ |
info.v0 = v0; |
| 375 |
|
info.last = 0; |
| 376 |
|
} |
| 377 |
|
|
| 380 |
|
|
| 381 |
|
char name[15]; |
| 382 |
|
int isDipole; |
| 383 |
+ |
int isSSD; |
| 384 |
|
double mass; |
| 385 |
|
double epslon; |
| 386 |
|
double sigma; |
| 387 |
|
double dipole; |
| 388 |
+ |
double w0; |
| 389 |
+ |
double v0; |
| 390 |
+ |
int ident; |
| 391 |
|
LinkedType* next; |
| 392 |
|
}; |
| 393 |
|
|
| 394 |
|
LinkedType* headAtomType; |
| 395 |
|
LinkedType* currentAtomType; |
| 294 |
– |
LinkedType* tempAtomType; |
| 295 |
– |
|
| 296 |
– |
#ifdef IS_MPI |
| 396 |
|
atomStruct info; |
| 397 |
|
info.last = 1; // initialize last to have the last set. |
| 398 |
|
// if things go well, last will be set to 0 |
| 399 |
< |
#endif |
| 399 |
> |
|
| 400 |
|
|
| 401 |
|
|
| 303 |
– |
char readLine[500]; |
| 304 |
– |
char* the_token; |
| 305 |
– |
char* eof_test; |
| 306 |
– |
int foundAtom = 0; |
| 307 |
– |
int lineNum = 0; |
| 402 |
|
int i; |
| 403 |
< |
|
| 403 |
> |
int identNum; |
| 404 |
|
|
| 405 |
+ |
Atom** the_atoms; |
| 406 |
+ |
int nAtoms; |
| 407 |
+ |
the_atoms = entry_plug->atoms; |
| 408 |
+ |
nAtoms = entry_plug->n_atoms; |
| 409 |
+ |
|
| 410 |
+ |
|
| 411 |
|
////////////////////////////////////////////////// |
| 412 |
|
// a quick water fix |
| 413 |
|
|
| 442 |
|
|
| 443 |
|
////////////////////////////////////////////////// |
| 444 |
|
|
| 445 |
< |
Atom** the_atoms; |
| 346 |
< |
int nAtoms; |
| 347 |
< |
the_atoms = entry_plug->atoms; |
| 348 |
< |
nAtoms = entry_plug->n_atoms; |
| 349 |
< |
|
| 350 |
< |
|
| 445 |
> |
|
| 446 |
|
#ifdef IS_MPI |
| 447 |
|
if( worldRank == 0 ){ |
| 448 |
|
#endif |
| 449 |
|
|
| 450 |
|
// read in the atom types. |
| 451 |
< |
|
| 357 |
< |
rewind( frcFile ); |
| 451 |
> |
|
| 452 |
|
headAtomType = new LinkedType; |
| 359 |
– |
currentAtomType = headAtomType; |
| 453 |
|
|
| 454 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 455 |
< |
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 |
< |
|
| 454 |
> |
fastForward( "AtomTypes", "initializeAtoms" ); |
| 455 |
> |
|
| 456 |
|
// we are now at the AtomTypes section. |
| 457 |
|
|
| 458 |
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 459 |
|
lineNum++; |
| 460 |
|
|
| 461 |
+ |
|
| 462 |
+ |
// read a line, and start parseing out the atom types |
| 463 |
+ |
|
| 464 |
|
if( eof_test == NULL ){ |
| 465 |
|
sprintf( painCave.errMsg, |
| 466 |
|
"Error in reading Atoms from force file at line %d.\n", |
| 469 |
|
simError(); |
| 470 |
|
} |
| 471 |
|
|
| 472 |
+ |
identNum = 1; |
| 473 |
+ |
// stop reading at end of file, or at next section |
| 474 |
|
while( readLine[0] != '#' && eof_test != NULL ){ |
| 475 |
< |
|
| 475 |
> |
|
| 476 |
> |
// toss comment lines |
| 477 |
|
if( readLine[0] != '!' ){ |
| 478 |
|
|
| 479 |
< |
the_token = strtok( readLine, " \n\t,;" ); |
| 480 |
< |
if( the_token != NULL ){ |
| 481 |
< |
|
| 482 |
< |
strcpy( currentAtomType->name, the_token ); |
| 483 |
< |
|
| 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 |
< |
} |
| 479 |
> |
// the parser returns 0 if the line was blank |
| 480 |
> |
if( parseAtom( readLine, lineNum, info ) ){ |
| 481 |
> |
info.ident = identNum; |
| 482 |
> |
headAtomType->add( info );; |
| 483 |
> |
identNum++; |
| 484 |
|
} |
| 485 |
|
} |
| 471 |
– |
|
| 472 |
– |
tempAtomType = new LinkedType; |
| 473 |
– |
currentAtomType->next = tempAtomType; |
| 474 |
– |
currentAtomType = tempAtomType; |
| 475 |
– |
|
| 486 |
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 487 |
|
lineNum++; |
| 488 |
|
} |
| 492 |
|
// send out the linked list to all the other processes |
| 493 |
|
|
| 494 |
|
sprintf( checkPointMsg, |
| 495 |
< |
"TraPPE_Ex atom structures read successfully." ); |
| 495 |
> |
"TraPPE_ExFF atom structures read successfully." ); |
| 496 |
|
MPIcheckPoint(); |
| 497 |
|
|
| 498 |
< |
currentAtomType = headAtomType; |
| 498 |
> |
currentAtomType = headAtomType->next; //skip the first element who is a place holder. |
| 499 |
|
while( currentAtomType != NULL ){ |
| 500 |
|
currentAtomType->duplicate( info ); |
| 501 |
+ |
|
| 502 |
+ |
|
| 503 |
+ |
|
| 504 |
|
sendFrcStruct( &info, mpiAtomStructType ); |
| 505 |
+ |
|
| 506 |
+ |
sprintf( checkPointMsg, |
| 507 |
+ |
"successfully sent TraPPE_Ex force type: \"%s\"\n", |
| 508 |
+ |
info.name ); |
| 509 |
+ |
MPIcheckPoint(); |
| 510 |
+ |
|
| 511 |
|
currentAtomType = currentAtomType->next; |
| 512 |
|
} |
| 513 |
|
info.last = 1; |
| 523 |
|
|
| 524 |
|
headAtomType = new LinkedType; |
| 525 |
|
recieveFrcStruct( &info, mpiAtomStructType ); |
| 526 |
+ |
|
| 527 |
|
while( !info.last ){ |
| 528 |
|
|
| 529 |
+ |
|
| 530 |
+ |
|
| 531 |
|
headAtomType->add( info ); |
| 532 |
+ |
|
| 533 |
+ |
MPIcheckPoint(); |
| 534 |
+ |
|
| 535 |
|
recieveFrcStruct( &info, mpiAtomStructType ); |
| 536 |
|
} |
| 537 |
|
} |
| 538 |
|
#endif // is_mpi |
| 539 |
|
|
| 540 |
+ |
// call new A_types in fortran |
| 541 |
|
|
| 542 |
+ |
int isError; |
| 543 |
+ |
currentAtomType = headAtomType; |
| 544 |
+ |
while( currentAtomType != NULL ){ |
| 545 |
+ |
|
| 546 |
+ |
if( currentAtomType->name[0] != '\0' ){ |
| 547 |
+ |
isError = 0; |
| 548 |
+ |
newTPEtype( &(currentAtomType->ident), |
| 549 |
+ |
&(currentAtomType->mass), |
| 550 |
+ |
&(currentAtomType->epslon), |
| 551 |
+ |
&(currentAtomType->sigma), |
| 552 |
+ |
&(currentAtomType->isDipole), |
| 553 |
+ |
&(currentAtomType->isSSD), |
| 554 |
+ |
&(currentAtomType->dipole), |
| 555 |
+ |
&(currentAtomType->w0), |
| 556 |
+ |
&(currentAtomType->v0), |
| 557 |
+ |
&isError ); |
| 558 |
+ |
if( isError ){ |
| 559 |
+ |
sprintf( painCave.errMsg, |
| 560 |
+ |
"Error initializing the \"%s\" atom type in fortran\n", |
| 561 |
+ |
currentAtomType->name ); |
| 562 |
+ |
painCave.isFatal = 1; |
| 563 |
+ |
simError(); |
| 564 |
+ |
} |
| 565 |
+ |
} |
| 566 |
+ |
currentAtomType = currentAtomType->next; |
| 567 |
+ |
} |
| 568 |
+ |
|
| 569 |
+ |
#ifdef IS_MPI |
| 570 |
+ |
sprintf( checkPointMsg, |
| 571 |
+ |
"TraPPE_ExFF atom structures successfully sent to fortran\n" ); |
| 572 |
+ |
MPIcheckPoint(); |
| 573 |
+ |
#endif // is_mpi |
| 574 |
+ |
|
| 575 |
+ |
|
| 576 |
|
// initialize the atoms |
| 577 |
|
|
| 578 |
+ |
double bigSigma = 0.0; |
| 579 |
|
DirectionalAtom* dAtom; |
| 580 |
|
|
| 581 |
|
for( i=0; i<nAtoms; i++ ){ |
| 594 |
|
the_atoms[i]->setSigma( currentAtomType->sigma ); |
| 595 |
|
the_atoms[i]->setLJ(); |
| 596 |
|
|
| 597 |
+ |
if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma; |
| 598 |
+ |
|
| 599 |
|
if( currentAtomType->isDipole ){ |
| 600 |
|
if( the_atoms[i]->isDirectional() ){ |
| 601 |
|
|
| 645 |
|
} |
| 646 |
|
} |
| 647 |
|
|
| 648 |
+ |
#ifdef IS_MPI |
| 649 |
+ |
double tempBig = bigSigma; |
| 650 |
+ |
MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX ); |
| 651 |
+ |
#endif //is_mpi |
| 652 |
|
|
| 653 |
+ |
//calc rCut and rList |
| 654 |
+ |
|
| 655 |
+ |
entry_plug->rCut = 2.5 * bigSigma; |
| 656 |
+ |
|
| 657 |
+ |
if(entry_plug->rCut > (entry_plug->box_x / 2.0)) |
| 658 |
+ |
entry_plug->rCut = entry_plug->box_x / 2.0; |
| 659 |
+ |
|
| 660 |
+ |
if(entry_plug->rCut > (entry_plug->box_y / 2.0)) |
| 661 |
+ |
entry_plug->rCut = entry_plug->box_y / 2.0; |
| 662 |
+ |
|
| 663 |
+ |
if(entry_plug->rCut > (entry_plug->box_z / 2.0)) |
| 664 |
+ |
entry_plug->rCut = entry_plug->box_z / 2.0; |
| 665 |
+ |
|
| 666 |
+ |
entry_plug->rList = entry_plug->rCut + 1.0; |
| 667 |
+ |
|
| 668 |
+ |
|
| 669 |
|
// clean up the memory |
| 670 |
|
|
| 671 |
|
delete headAtomType; |
| 696 |
|
return NULL; |
| 697 |
|
} |
| 698 |
|
|
| 699 |
< |
#ifdef IS_MPI |
| 699 |
> |
|
| 700 |
|
void add( bondStruct &info ){ |
| 701 |
+ |
|
| 702 |
+ |
// check for duplicates |
| 703 |
+ |
int dup = 0; |
| 704 |
+ |
|
| 705 |
+ |
if( !strcmp(nameA, info.nameA ) && !strcmp( nameB, info.nameB ) ) dup = 1; |
| 706 |
+ |
if( !strcmp(nameA, info.nameB ) && !strcmp( nameB, info.nameA ) ) dup = 1; |
| 707 |
+ |
|
| 708 |
+ |
if(dup){ |
| 709 |
+ |
sprintf( painCave.errMsg, |
| 710 |
+ |
"Duplicate TraPPE_Ex bond type \"%s - %s\" found in " |
| 711 |
+ |
"the TraPPE_ExFF param file./n", |
| 712 |
+ |
nameA, nameB ); |
| 713 |
+ |
painCave.isFatal = 1; |
| 714 |
+ |
simError(); |
| 715 |
+ |
} |
| 716 |
+ |
|
| 717 |
+ |
|
| 718 |
|
if( next != NULL ) next->add(info); |
| 719 |
|
else{ |
| 720 |
|
next = new LinkedType(); |
| 725 |
|
} |
| 726 |
|
} |
| 727 |
|
|
| 728 |
+ |
#ifdef IS_MPI |
| 729 |
|
void duplicate( bondStruct &info ){ |
| 730 |
|
strcpy(info.nameA, nameA); |
| 731 |
|
strcpy(info.nameB, nameB); |
| 749 |
|
|
| 750 |
|
LinkedType* headBondType; |
| 751 |
|
LinkedType* currentBondType; |
| 651 |
– |
LinkedType* tempBondType; |
| 652 |
– |
|
| 653 |
– |
#ifdef IS_MPI |
| 752 |
|
bondStruct info; |
| 753 |
|
info.last = 1; // initialize last to have the last set. |
| 754 |
|
// if things go well, last will be set to 0 |
| 657 |
– |
#endif |
| 755 |
|
|
| 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 |
– |
|
| 756 |
|
SRI **the_sris; |
| 757 |
|
Atom** the_atoms; |
| 758 |
|
int nBonds; |
| 760 |
|
the_atoms = entry_plug->atoms; |
| 761 |
|
nBonds = entry_plug->n_bonds; |
| 762 |
|
|
| 763 |
+ |
int i, a, b; |
| 764 |
+ |
char* atomA; |
| 765 |
+ |
char* atomB; |
| 766 |
|
|
| 767 |
|
#ifdef IS_MPI |
| 768 |
|
if( worldRank == 0 ){ |
| 770 |
|
|
| 771 |
|
// read in the bond types. |
| 772 |
|
|
| 682 |
– |
rewind( frcFile ); |
| 773 |
|
headBondType = new LinkedType; |
| 684 |
– |
currentBondType = headBondType; |
| 774 |
|
|
| 775 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 775 |
> |
fastForward( "BondTypes", "initializeBonds" ); |
| 776 |
> |
|
| 777 |
> |
// we are now at the bondTypes section |
| 778 |
> |
|
| 779 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 780 |
|
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 |
– |
} |
| 781 |
|
|
| 782 |
|
|
| 783 |
< |
while( !foundBond ){ |
| 784 |
< |
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 |
< |
|
| 783 |
> |
// read a line, and start parseing out the atom types |
| 784 |
> |
|
| 785 |
|
if( eof_test == NULL ){ |
| 786 |
|
sprintf( painCave.errMsg, |
| 787 |
< |
"Error in reading Bonds from force file at line %d.\n", |
| 787 |
> |
"Error in reading bonds from force file at line %d.\n", |
| 788 |
|
lineNum ); |
| 789 |
|
painCave.isFatal = 1; |
| 790 |
|
simError(); |
| 791 |
|
} |
| 792 |
|
|
| 793 |
+ |
// stop reading at end of file, or at next section |
| 794 |
|
while( readLine[0] != '#' && eof_test != NULL ){ |
| 795 |
< |
|
| 795 |
> |
|
| 796 |
> |
// toss comment lines |
| 797 |
|
if( readLine[0] != '!' ){ |
| 798 |
|
|
| 799 |
< |
the_token = strtok( readLine, " \n\t,;" ); |
| 800 |
< |
if( the_token != NULL ){ |
| 801 |
< |
|
| 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 |
< |
} |
| 799 |
> |
// the parser returns 0 if the line was blank |
| 800 |
> |
if( parseBond( readLine, lineNum, info ) ){ |
| 801 |
> |
headBondType->add( info ); |
| 802 |
|
} |
| 803 |
|
} |
| 786 |
– |
|
| 787 |
– |
tempBondType = new LinkedType; |
| 788 |
– |
currentBondType->next = tempBondType; |
| 789 |
– |
currentBondType = tempBondType; |
| 790 |
– |
|
| 804 |
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 805 |
|
lineNum++; |
| 806 |
|
} |
| 807 |
< |
|
| 807 |
> |
|
| 808 |
|
#ifdef IS_MPI |
| 809 |
|
|
| 810 |
|
// send out the linked list to all the other processes |
| 903 |
|
return NULL; |
| 904 |
|
} |
| 905 |
|
|
| 893 |
– |
#ifdef IS_MPI |
| 894 |
– |
|
| 906 |
|
void add( bendStruct &info ){ |
| 907 |
+ |
|
| 908 |
+ |
// check for duplicates |
| 909 |
+ |
int dup = 0; |
| 910 |
+ |
|
| 911 |
+ |
if( !strcmp( nameA, info.nameA ) && !strcmp( nameB, info.nameB ) |
| 912 |
+ |
&& !strcmp( nameC, info.nameC ) ) dup = 1; |
| 913 |
+ |
if( !strcmp( nameA, info.nameC ) && !strcmp( nameB, info.nameB ) |
| 914 |
+ |
&& !strcmp( nameC, info.nameA ) ) dup = 1; |
| 915 |
+ |
|
| 916 |
+ |
if(dup){ |
| 917 |
+ |
sprintf( painCave.errMsg, |
| 918 |
+ |
"Duplicate TraPPE_Ex bend type \"%s - %s - %s\" found in " |
| 919 |
+ |
"the TraPPE_ExFF param file./n", |
| 920 |
+ |
nameA, nameB, nameC ); |
| 921 |
+ |
painCave.isFatal = 1; |
| 922 |
+ |
simError(); |
| 923 |
+ |
} |
| 924 |
+ |
|
| 925 |
|
if( next != NULL ) next->add(info); |
| 926 |
|
else{ |
| 927 |
|
next = new LinkedType(); |
| 935 |
|
next->t0 = info.t0; |
| 936 |
|
} |
| 937 |
|
} |
| 938 |
< |
|
| 938 |
> |
|
| 939 |
> |
#ifdef IS_MPI |
| 940 |
> |
|
| 941 |
|
void duplicate( bendStruct &info ){ |
| 942 |
|
strcpy(info.nameA, nameA); |
| 943 |
|
strcpy(info.nameB, nameB); |
| 963 |
|
|
| 964 |
|
LinkedType* headBendType; |
| 965 |
|
LinkedType* currentBendType; |
| 935 |
– |
LinkedType* tempBendType; |
| 936 |
– |
|
| 937 |
– |
#ifdef IS_MPI |
| 966 |
|
bendStruct info; |
| 967 |
|
info.last = 1; // initialize last to have the last set. |
| 968 |
|
// if things go well, last will be set to 0 |
| 941 |
– |
#endif |
| 969 |
|
|
| 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; |
| 970 |
|
QuadraticBend* qBend; |
| 953 |
– |
|
| 971 |
|
SRI **the_sris; |
| 972 |
|
Atom** the_atoms; |
| 973 |
|
int nBends; |
| 975 |
|
the_atoms = entry_plug->atoms; |
| 976 |
|
nBends = entry_plug->n_bends; |
| 977 |
|
|
| 978 |
+ |
int i, a, b, c; |
| 979 |
+ |
char* atomA; |
| 980 |
+ |
char* atomB; |
| 981 |
+ |
char* atomC; |
| 982 |
|
|
| 983 |
+ |
|
| 984 |
|
#ifdef IS_MPI |
| 985 |
|
if( worldRank == 0 ){ |
| 986 |
|
#endif |
| 987 |
|
|
| 988 |
|
// read in the bend types. |
| 989 |
|
|
| 968 |
– |
rewind( frcFile ); |
| 990 |
|
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 ); |
| 991 |
|
|
| 992 |
< |
if( !foundBend ){ |
| 998 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 999 |
< |
lineNum++; |
| 992 |
> |
fastForward( "BendTypes", "initializeBends" ); |
| 993 |
|
|
| 994 |
< |
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 |
< |
} |
| 994 |
> |
// we are now at the bendTypes section |
| 995 |
|
|
| 996 |
< |
// we are now at the BendTypes section. |
| 1012 |
< |
|
| 1013 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 996 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 997 |
|
lineNum++; |
| 998 |
< |
|
| 998 |
> |
|
| 999 |
> |
// read a line, and start parseing out the bend types |
| 1000 |
> |
|
| 1001 |
|
if( eof_test == NULL ){ |
| 1002 |
|
sprintf( painCave.errMsg, |
| 1003 |
< |
"Error in reading Bends from force file at line %d.\n", |
| 1003 |
> |
"Error in reading bends from force file at line %d.\n", |
| 1004 |
|
lineNum ); |
| 1005 |
|
painCave.isFatal = 1; |
| 1006 |
|
simError(); |
| 1007 |
|
} |
| 1023 |
– |
|
| 1024 |
– |
while( readLine[0] != '#' && eof_test != NULL ){ |
| 1008 |
|
|
| 1009 |
< |
if( readLine[0] != '!' ){ |
| 1009 |
> |
// stop reading at end of file, or at next section |
| 1010 |
> |
while( readLine[0] != '#' && eof_test != NULL ){ |
| 1011 |
|
|
| 1012 |
< |
the_token = strtok( readLine, " \n\t,;" ); |
| 1013 |
< |
if( the_token != NULL ){ |
| 1012 |
> |
// toss comment lines |
| 1013 |
> |
if( readLine[0] != '!' ){ |
| 1014 |
|
|
| 1015 |
< |
strcpy( currentBendType->nameA, the_token ); |
| 1016 |
< |
|
| 1017 |
< |
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 |
< |
} |
| 1015 |
> |
// the parser returns 0 if the line was blank |
| 1016 |
> |
if( parseBend( readLine, lineNum, info ) ){ |
| 1017 |
> |
headBendType->add( info ); |
| 1018 |
|
} |
| 1019 |
|
} |
| 1108 |
– |
|
| 1109 |
– |
tempBendType = new LinkedType; |
| 1110 |
– |
currentBendType->next = tempBendType; |
| 1111 |
– |
currentBendType = tempBendType; |
| 1112 |
– |
|
| 1020 |
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1021 |
|
lineNum++; |
| 1022 |
|
} |
| 1023 |
< |
|
| 1023 |
> |
|
| 1024 |
|
#ifdef IS_MPI |
| 1025 |
|
|
| 1026 |
|
// send out the linked list to all the other processes |
| 1057 |
|
#endif // is_mpi |
| 1058 |
|
|
| 1059 |
|
// initialize the Bends |
| 1060 |
+ |
|
| 1061 |
+ |
int index; |
| 1062 |
|
|
| 1063 |
|
for( i=0; i<nBends; i++ ){ |
| 1064 |
|
|
| 1122 |
|
!strcmp( nameC, key3 ) && !strcmp( nameD, key4 ) ) return this; |
| 1123 |
|
|
| 1124 |
|
if( !strcmp( nameA, key4 ) && !strcmp( nameB, key3 ) && |
| 1125 |
< |
!strcmp( nameC, key2 ) && !strcmp( nameD, key4 ) ) return this; |
| 1125 |
> |
!strcmp( nameC, key2 ) && !strcmp( nameD, key1 ) ) return this; |
| 1126 |
|
|
| 1127 |
|
if( next != NULL ) return next->find(key1, key2, key3, key4); |
| 1128 |
|
return NULL; |
| 1129 |
|
} |
| 1221 |
– |
|
| 1222 |
– |
#ifdef IS_MPI |
| 1130 |
|
|
| 1131 |
|
void add( torsionStruct &info ){ |
| 1132 |
+ |
|
| 1133 |
+ |
// check for duplicates |
| 1134 |
+ |
int dup = 0; |
| 1135 |
+ |
|
| 1136 |
+ |
if( !strcmp( nameA, info.nameA ) && !strcmp( nameB, info.nameB ) && |
| 1137 |
+ |
!strcmp( nameC, info.nameC ) && !strcmp( nameD, info.nameD ) ) dup = 1; |
| 1138 |
+ |
|
| 1139 |
+ |
if( !strcmp( nameA, info.nameD ) && !strcmp( nameB, info.nameC ) && |
| 1140 |
+ |
!strcmp( nameC, info.nameB ) && !strcmp( nameD, info.nameA ) ) dup = 1; |
| 1141 |
+ |
|
| 1142 |
+ |
if(dup){ |
| 1143 |
+ |
sprintf( painCave.errMsg, |
| 1144 |
+ |
"Duplicate TraPPE_Ex torsion type \"%s - %s - %s - %s\" found in " |
| 1145 |
+ |
"the TraPPE_ExFF param file./n", nameA, nameB, nameC, nameD ); |
| 1146 |
+ |
painCave.isFatal = 1; |
| 1147 |
+ |
simError(); |
| 1148 |
+ |
} |
| 1149 |
+ |
|
| 1150 |
|
if( next != NULL ) next->add(info); |
| 1151 |
|
else{ |
| 1152 |
|
next = new LinkedType(); |
| 1160 |
|
next->k4 = info.k4; |
| 1161 |
|
} |
| 1162 |
|
} |
| 1163 |
+ |
|
| 1164 |
+ |
#ifdef IS_MPI |
| 1165 |
|
|
| 1166 |
|
void duplicate( torsionStruct &info ){ |
| 1167 |
|
strcpy(info.nameA, nameA); |
| 1190 |
|
|
| 1191 |
|
LinkedType* headTorsionType; |
| 1192 |
|
LinkedType* currentTorsionType; |
| 1266 |
– |
LinkedType* tempTorsionType; |
| 1267 |
– |
|
| 1268 |
– |
#ifdef IS_MPI |
| 1193 |
|
torsionStruct info; |
| 1194 |
|
info.last = 1; // initialize last to have the last set. |
| 1195 |
|
// if things go well, last will be set to 0 |
| 1272 |
– |
#endif |
| 1196 |
|
|
| 1274 |
– |
char readLine[500]; |
| 1275 |
– |
char* the_token; |
| 1276 |
– |
char* eof_test; |
| 1277 |
– |
int foundTorsion = 0; |
| 1278 |
– |
int lineNum = 0; |
| 1197 |
|
int i, a, b, c, d, index; |
| 1198 |
|
char* atomA; |
| 1199 |
|
char* atomB; |
| 1214 |
|
|
| 1215 |
|
// read in the torsion types. |
| 1216 |
|
|
| 1299 |
– |
rewind( frcFile ); |
| 1217 |
|
headTorsionType = new LinkedType; |
| 1301 |
– |
currentTorsionType = headTorsionType; |
| 1302 |
– |
|
| 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 |
– |
} |
| 1311 |
– |
|
| 1312 |
– |
|
| 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 |
– |
} |
| 1325 |
– |
|
| 1326 |
– |
the_token = strtok( readLine, " ,;\t#\n" ); |
| 1327 |
– |
foundTorsion = !strcmp( "TorsionTypes", the_token ); |
| 1218 |
|
|
| 1219 |
< |
if( !foundTorsion ){ |
| 1330 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1331 |
< |
lineNum++; |
| 1219 |
> |
fastForward( "TorsionTypes", "initializeTorsions" ); |
| 1220 |
|
|
| 1221 |
< |
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 |
< |
} |
| 1221 |
> |
// we are now at the torsionTypes section |
| 1222 |
|
|
| 1223 |
< |
// we are now at the TorsionTypes section. |
| 1344 |
< |
|
| 1345 |
< |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1223 |
> |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1224 |
|
lineNum++; |
| 1225 |
< |
|
| 1225 |
> |
|
| 1226 |
> |
|
| 1227 |
> |
// read a line, and start parseing out the atom types |
| 1228 |
> |
|
| 1229 |
|
if( eof_test == NULL ){ |
| 1230 |
|
sprintf( painCave.errMsg, |
| 1231 |
< |
"Error in reading Torsions from force file at line %d.\n", |
| 1231 |
> |
"Error in reading torsions from force file at line %d.\n", |
| 1232 |
|
lineNum ); |
| 1233 |
|
painCave.isFatal = 1; |
| 1234 |
|
simError(); |
| 1235 |
|
} |
| 1355 |
– |
|
| 1356 |
– |
while( readLine[0] != '#' && eof_test != NULL ){ |
| 1236 |
|
|
| 1237 |
+ |
// stop reading at end of file, or at next section |
| 1238 |
+ |
while( readLine[0] != '#' && eof_test != NULL ){ |
| 1239 |
+ |
|
| 1240 |
+ |
// toss comment lines |
| 1241 |
|
if( readLine[0] != '!' ){ |
| 1359 |
– |
|
| 1360 |
– |
the_token = strtok( readLine, " \n\t,;" ); |
| 1361 |
– |
if( the_token != NULL ){ |
| 1242 |
|
|
| 1243 |
< |
strcpy( currentTorsionType->nameA, the_token ); |
| 1244 |
< |
|
| 1245 |
< |
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 |
< |
} |
| 1243 |
> |
// the parser returns 0 if the line was blank |
| 1244 |
> |
if( parseTorsion( readLine, lineNum, info ) ){ |
| 1245 |
> |
headTorsionType->add( info ); |
| 1246 |
|
} |
| 1247 |
|
} |
| 1449 |
– |
|
| 1450 |
– |
tempTorsionType = new LinkedType; |
| 1451 |
– |
currentTorsionType->next = tempTorsionType; |
| 1452 |
– |
currentTorsionType = tempTorsionType; |
| 1453 |
– |
|
| 1248 |
|
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1249 |
|
lineNum++; |
| 1250 |
|
} |
| 1327 |
|
sprintf( checkPointMsg, "TraPPE_Ex torsions initialized succesfully" ); |
| 1328 |
|
MPIcheckPoint(); |
| 1329 |
|
#endif // is_mpi |
| 1330 |
+ |
|
| 1331 |
+ |
} |
| 1332 |
+ |
|
| 1333 |
+ |
void TraPPE_ExFF::fastForward( char* stopText, char* searchOwner ){ |
| 1334 |
+ |
|
| 1335 |
+ |
int foundText = 0; |
| 1336 |
+ |
char* the_token; |
| 1337 |
+ |
|
| 1338 |
+ |
rewind( frcFile ); |
| 1339 |
+ |
lineNum = 0; |
| 1340 |
+ |
|
| 1341 |
+ |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1342 |
+ |
lineNum++; |
| 1343 |
+ |
if( eof_test == NULL ){ |
| 1344 |
+ |
sprintf( painCave.errMsg, "Error fast forwarding force file for %s: " |
| 1345 |
+ |
" file is empty.\n", |
| 1346 |
+ |
searchOwner ); |
| 1347 |
+ |
painCave.isFatal = 1; |
| 1348 |
+ |
simError(); |
| 1349 |
+ |
} |
| 1350 |
+ |
|
| 1351 |
+ |
|
| 1352 |
+ |
while( !foundText ){ |
| 1353 |
+ |
while( eof_test != NULL && readLine[0] != '#' ){ |
| 1354 |
+ |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1355 |
+ |
lineNum++; |
| 1356 |
+ |
} |
| 1357 |
+ |
if( eof_test == NULL ){ |
| 1358 |
+ |
sprintf( painCave.errMsg, |
| 1359 |
+ |
"Error fast forwarding force file for %s at " |
| 1360 |
+ |
"line %d: file ended unexpectedly.\n", |
| 1361 |
+ |
searchOwner, |
| 1362 |
+ |
lineNum ); |
| 1363 |
+ |
painCave.isFatal = 1; |
| 1364 |
+ |
simError(); |
| 1365 |
+ |
} |
| 1366 |
+ |
|
| 1367 |
+ |
the_token = strtok( readLine, " ,;\t#\n" ); |
| 1368 |
+ |
foundText = !strcmp( stopText, the_token ); |
| 1369 |
+ |
|
| 1370 |
+ |
if( !foundText ){ |
| 1371 |
+ |
eof_test = fgets( readLine, sizeof(readLine), frcFile ); |
| 1372 |
+ |
lineNum++; |
| 1373 |
+ |
|
| 1374 |
+ |
if( eof_test == NULL ){ |
| 1375 |
+ |
sprintf( painCave.errMsg, |
| 1376 |
+ |
"Error fast forwarding force file for %s at " |
| 1377 |
+ |
"line %d: file ended unexpectedly.\n", |
| 1378 |
+ |
searchOwner, |
| 1379 |
+ |
lineNum ); |
| 1380 |
+ |
painCave.isFatal = 1; |
| 1381 |
+ |
simError(); |
| 1382 |
+ |
} |
| 1383 |
+ |
} |
| 1384 |
+ |
} |
| 1385 |
+ |
} |
| 1386 |
+ |
|
| 1387 |
+ |
|
| 1388 |
+ |
int parseAtom( char *lineBuffer, int lineNum, atomStruct &info ){ |
| 1389 |
+ |
|
| 1390 |
+ |
char* the_token; |
| 1391 |
+ |
|
| 1392 |
+ |
the_token = strtok( lineBuffer, " \n\t,;" ); |
| 1393 |
+ |
if( the_token != NULL ){ |
| 1394 |
+ |
|
| 1395 |
+ |
strcpy( info.name, the_token ); |
| 1396 |
|
|
| 1397 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1398 |
+ |
sprintf( painCave.errMsg, |
| 1399 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
| 1400 |
+ |
painCave.isFatal = 1; |
| 1401 |
+ |
simError(); |
| 1402 |
+ |
} |
| 1403 |
+ |
|
| 1404 |
+ |
info.isDipole = atoi( the_token ); |
| 1405 |
+ |
|
| 1406 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1407 |
+ |
sprintf( painCave.errMsg, |
| 1408 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
| 1409 |
+ |
painCave.isFatal = 1; |
| 1410 |
+ |
simError(); |
| 1411 |
+ |
} |
| 1412 |
+ |
|
| 1413 |
+ |
info.isSSD = atoi( the_token ); |
| 1414 |
+ |
|
| 1415 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1416 |
+ |
sprintf( painCave.errMsg, |
| 1417 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
| 1418 |
+ |
painCave.isFatal = 1; |
| 1419 |
+ |
simError(); |
| 1420 |
+ |
} |
| 1421 |
+ |
|
| 1422 |
+ |
info.mass = atof( the_token ); |
| 1423 |
+ |
|
| 1424 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1425 |
+ |
sprintf( painCave.errMsg, |
| 1426 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
| 1427 |
+ |
painCave.isFatal = 1; |
| 1428 |
+ |
simError(); |
| 1429 |
+ |
} |
| 1430 |
+ |
|
| 1431 |
+ |
info.epslon = atof( the_token ); |
| 1432 |
+ |
|
| 1433 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1434 |
+ |
sprintf( painCave.errMsg, |
| 1435 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
| 1436 |
+ |
painCave.isFatal = 1; |
| 1437 |
+ |
simError(); |
| 1438 |
+ |
} |
| 1439 |
+ |
|
| 1440 |
+ |
info.sigma = atof( the_token ); |
| 1441 |
+ |
|
| 1442 |
+ |
if( info.isDipole ){ |
| 1443 |
+ |
|
| 1444 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1445 |
+ |
sprintf( painCave.errMsg, |
| 1446 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
| 1447 |
+ |
painCave.isFatal = 1; |
| 1448 |
+ |
simError(); |
| 1449 |
+ |
} |
| 1450 |
+ |
|
| 1451 |
+ |
info.dipole = atof( the_token ); |
| 1452 |
+ |
} |
| 1453 |
+ |
else info.dipole = 0.0; |
| 1454 |
+ |
|
| 1455 |
+ |
if( info.isSSD ){ |
| 1456 |
+ |
|
| 1457 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1458 |
+ |
sprintf( painCave.errMsg, |
| 1459 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
| 1460 |
+ |
painCave.isFatal = 1; |
| 1461 |
+ |
simError(); |
| 1462 |
+ |
} |
| 1463 |
+ |
|
| 1464 |
+ |
info.w0 = atof( the_token ); |
| 1465 |
+ |
|
| 1466 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1467 |
+ |
sprintf( painCave.errMsg, |
| 1468 |
+ |
"Error parseing AtomTypes: line %d\n", lineNum ); |
| 1469 |
+ |
painCave.isFatal = 1; |
| 1470 |
+ |
simError(); |
| 1471 |
+ |
} |
| 1472 |
+ |
|
| 1473 |
+ |
info.v0 = atof( the_token ); |
| 1474 |
+ |
} |
| 1475 |
+ |
else info.v0 = info.w0 = 0.0; |
| 1476 |
+ |
|
| 1477 |
+ |
return 1; |
| 1478 |
+ |
} |
| 1479 |
+ |
else return 0; |
| 1480 |
|
} |
| 1481 |
+ |
|
| 1482 |
+ |
int parseBond( char *lineBuffer, int lineNum, bondStruct &info ){ |
| 1483 |
+ |
|
| 1484 |
+ |
char* the_token; |
| 1485 |
+ |
|
| 1486 |
+ |
the_token = strtok( lineBuffer, " \n\t,;" ); |
| 1487 |
+ |
if( the_token != NULL ){ |
| 1488 |
+ |
|
| 1489 |
+ |
strcpy( info.nameA, the_token ); |
| 1490 |
+ |
|
| 1491 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1492 |
+ |
sprintf( painCave.errMsg, |
| 1493 |
+ |
"Error parseing BondTypes: line %d\n", lineNum ); |
| 1494 |
+ |
painCave.isFatal = 1; |
| 1495 |
+ |
simError(); |
| 1496 |
+ |
} |
| 1497 |
+ |
|
| 1498 |
+ |
strcpy( info.nameB, the_token ); |
| 1499 |
+ |
|
| 1500 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1501 |
+ |
sprintf( painCave.errMsg, |
| 1502 |
+ |
"Error parseing BondTypes: line %d\n", lineNum ); |
| 1503 |
+ |
painCave.isFatal = 1; |
| 1504 |
+ |
simError(); |
| 1505 |
+ |
} |
| 1506 |
+ |
|
| 1507 |
+ |
strcpy( info.type, the_token ); |
| 1508 |
+ |
|
| 1509 |
+ |
if( !strcmp( info.type, "fixed" ) ){ |
| 1510 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1511 |
+ |
sprintf( painCave.errMsg, |
| 1512 |
+ |
"Error parseing BondTypes: line %d\n", lineNum ); |
| 1513 |
+ |
painCave.isFatal = 1; |
| 1514 |
+ |
simError(); |
| 1515 |
+ |
} |
| 1516 |
+ |
|
| 1517 |
+ |
info.d0 = atof( the_token ); |
| 1518 |
+ |
} |
| 1519 |
+ |
else{ |
| 1520 |
+ |
sprintf( painCave.errMsg, |
| 1521 |
+ |
"Unknown TraPPE_Ex bond type \"%s\" at line %d\n", |
| 1522 |
+ |
info.type, |
| 1523 |
+ |
lineNum ); |
| 1524 |
+ |
painCave.isFatal = 1; |
| 1525 |
+ |
simError(); |
| 1526 |
+ |
} |
| 1527 |
+ |
|
| 1528 |
+ |
return 1; |
| 1529 |
+ |
} |
| 1530 |
+ |
else return 0; |
| 1531 |
+ |
} |
| 1532 |
+ |
|
| 1533 |
+ |
|
| 1534 |
+ |
int parseBend( char *lineBuffer, int lineNum, bendStruct &info ){ |
| 1535 |
+ |
|
| 1536 |
+ |
char* the_token; |
| 1537 |
+ |
|
| 1538 |
+ |
the_token = strtok( lineBuffer, " \n\t,;" ); |
| 1539 |
+ |
if( the_token != NULL ){ |
| 1540 |
+ |
|
| 1541 |
+ |
strcpy( info.nameA, the_token ); |
| 1542 |
+ |
|
| 1543 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1544 |
+ |
sprintf( painCave.errMsg, |
| 1545 |
+ |
"Error parseing BondTypes: line %d\n", lineNum ); |
| 1546 |
+ |
painCave.isFatal = 1; |
| 1547 |
+ |
simError(); |
| 1548 |
+ |
} |
| 1549 |
+ |
|
| 1550 |
+ |
strcpy( info.nameB, the_token ); |
| 1551 |
+ |
|
| 1552 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1553 |
+ |
sprintf( painCave.errMsg, |
| 1554 |
+ |
"Error parseing BondTypes: line %d\n", lineNum ); |
| 1555 |
+ |
painCave.isFatal = 1; |
| 1556 |
+ |
simError(); |
| 1557 |
+ |
} |
| 1558 |
+ |
|
| 1559 |
+ |
strcpy( info.nameC, the_token ); |
| 1560 |
+ |
|
| 1561 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1562 |
+ |
sprintf( painCave.errMsg, |
| 1563 |
+ |
"Error parseing BondTypes: line %d\n", lineNum ); |
| 1564 |
+ |
painCave.isFatal = 1; |
| 1565 |
+ |
simError(); |
| 1566 |
+ |
} |
| 1567 |
+ |
|
| 1568 |
+ |
strcpy( info.type, the_token ); |
| 1569 |
+ |
|
| 1570 |
+ |
if( !strcmp( info.type, "quadratic" ) ){ |
| 1571 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1572 |
+ |
sprintf( painCave.errMsg, |
| 1573 |
+ |
"Error parseing BendTypes: line %d\n", lineNum ); |
| 1574 |
+ |
painCave.isFatal = 1; |
| 1575 |
+ |
simError(); |
| 1576 |
+ |
} |
| 1577 |
+ |
|
| 1578 |
+ |
info.k1 = atof( the_token ); |
| 1579 |
+ |
|
| 1580 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1581 |
+ |
sprintf( painCave.errMsg, |
| 1582 |
+ |
"Error parseing BendTypes: line %d\n", lineNum ); |
| 1583 |
+ |
painCave.isFatal = 1; |
| 1584 |
+ |
simError(); |
| 1585 |
+ |
} |
| 1586 |
+ |
|
| 1587 |
+ |
info.k2 = atof( the_token ); |
| 1588 |
+ |
|
| 1589 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1590 |
+ |
sprintf( painCave.errMsg, |
| 1591 |
+ |
"Error parseing BendTypes: line %d\n", lineNum ); |
| 1592 |
+ |
painCave.isFatal = 1; |
| 1593 |
+ |
simError(); |
| 1594 |
+ |
} |
| 1595 |
+ |
|
| 1596 |
+ |
info.k3 = atof( the_token ); |
| 1597 |
+ |
|
| 1598 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1599 |
+ |
sprintf( painCave.errMsg, |
| 1600 |
+ |
"Error parseing BendTypes: line %d\n", lineNum ); |
| 1601 |
+ |
painCave.isFatal = 1; |
| 1602 |
+ |
simError(); |
| 1603 |
+ |
} |
| 1604 |
+ |
|
| 1605 |
+ |
info.t0 = atof( the_token ); |
| 1606 |
+ |
} |
| 1607 |
+ |
|
| 1608 |
+ |
else{ |
| 1609 |
+ |
sprintf( painCave.errMsg, |
| 1610 |
+ |
"Unknown TraPPE_Ex bend type \"%s\" at line %d\n", |
| 1611 |
+ |
info.type, |
| 1612 |
+ |
lineNum ); |
| 1613 |
+ |
painCave.isFatal = 1; |
| 1614 |
+ |
simError(); |
| 1615 |
+ |
} |
| 1616 |
+ |
|
| 1617 |
+ |
return 1; |
| 1618 |
+ |
} |
| 1619 |
+ |
else return 0; |
| 1620 |
+ |
} |
| 1621 |
+ |
|
| 1622 |
+ |
int parseTorsion( char *lineBuffer, int lineNum, torsionStruct &info ){ |
| 1623 |
+ |
|
| 1624 |
+ |
char* the_token; |
| 1625 |
+ |
|
| 1626 |
+ |
the_token = strtok( lineBuffer, " \n\t,;" ); |
| 1627 |
+ |
if( the_token != NULL ){ |
| 1628 |
+ |
|
| 1629 |
+ |
strcpy( info.nameA, the_token ); |
| 1630 |
+ |
|
| 1631 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1632 |
+ |
sprintf( painCave.errMsg, |
| 1633 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1634 |
+ |
painCave.isFatal = 1; |
| 1635 |
+ |
simError(); |
| 1636 |
+ |
} |
| 1637 |
+ |
|
| 1638 |
+ |
strcpy( info.nameB, the_token ); |
| 1639 |
+ |
|
| 1640 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1641 |
+ |
sprintf( painCave.errMsg, |
| 1642 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1643 |
+ |
painCave.isFatal = 1; |
| 1644 |
+ |
simError(); |
| 1645 |
+ |
} |
| 1646 |
+ |
|
| 1647 |
+ |
strcpy( info.nameC, the_token ); |
| 1648 |
+ |
|
| 1649 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1650 |
+ |
sprintf( painCave.errMsg, |
| 1651 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1652 |
+ |
painCave.isFatal = 1; |
| 1653 |
+ |
simError(); |
| 1654 |
+ |
} |
| 1655 |
+ |
|
| 1656 |
+ |
strcpy( info.nameD, the_token ); |
| 1657 |
+ |
|
| 1658 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1659 |
+ |
sprintf( painCave.errMsg, |
| 1660 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1661 |
+ |
painCave.isFatal = 1; |
| 1662 |
+ |
simError(); |
| 1663 |
+ |
} |
| 1664 |
+ |
|
| 1665 |
+ |
strcpy( info.type, the_token ); |
| 1666 |
+ |
|
| 1667 |
+ |
if( !strcmp( info.type, "cubic" ) ){ |
| 1668 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1669 |
+ |
sprintf( painCave.errMsg, |
| 1670 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1671 |
+ |
painCave.isFatal = 1; |
| 1672 |
+ |
simError(); |
| 1673 |
+ |
} |
| 1674 |
+ |
|
| 1675 |
+ |
info.k1 = atof( the_token ); |
| 1676 |
+ |
|
| 1677 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1678 |
+ |
sprintf( painCave.errMsg, |
| 1679 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1680 |
+ |
painCave.isFatal = 1; |
| 1681 |
+ |
simError(); |
| 1682 |
+ |
} |
| 1683 |
+ |
|
| 1684 |
+ |
info.k2 = atof( the_token ); |
| 1685 |
+ |
|
| 1686 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1687 |
+ |
sprintf( painCave.errMsg, |
| 1688 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1689 |
+ |
painCave.isFatal = 1; |
| 1690 |
+ |
simError(); |
| 1691 |
+ |
} |
| 1692 |
+ |
|
| 1693 |
+ |
info.k3 = atof( the_token ); |
| 1694 |
+ |
|
| 1695 |
+ |
if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ |
| 1696 |
+ |
sprintf( painCave.errMsg, |
| 1697 |
+ |
"Error parseing TorsionTypes: line %d\n", lineNum ); |
| 1698 |
+ |
painCave.isFatal = 1; |
| 1699 |
+ |
simError(); |
| 1700 |
+ |
} |
| 1701 |
+ |
|
| 1702 |
+ |
info.k4 = atof( the_token ); |
| 1703 |
+ |
|
| 1704 |
+ |
} |
| 1705 |
+ |
|
| 1706 |
+ |
else{ |
| 1707 |
+ |
sprintf( painCave.errMsg, |
| 1708 |
+ |
"Unknown TraPPE_Ex torsion type \"%s\" at line %d\n", |
| 1709 |
+ |
info.type, |
| 1710 |
+ |
lineNum ); |
| 1711 |
+ |
painCave.isFatal = 1; |
| 1712 |
+ |
simError(); |
| 1713 |
+ |
} |
| 1714 |
+ |
|
| 1715 |
+ |
return 1; |
| 1716 |
+ |
} |
| 1717 |
+ |
|
| 1718 |
+ |
else return 0; |
| 1719 |
+ |
} |