ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/WATER.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/WATER.cpp (file contents):
Revision 989 by gezelter, Tue Jan 27 19:38:27 2004 UTC vs.
Revision 1224 by gezelter, Wed Jun 2 18:27:52 2004 UTC

# Line 305 | Line 305 | WATER::WATER(){
305    MPI_Type_commit(&mpiDirectionalStructType);
306  
307    // ***********************************************************************
308 <  
308 >
309    if( worldRank == 0 ){
310   #endif
311      
# Line 338 | Line 338 | WATER::WATER(){
338        if( frcFile == NULL ){
339          
340          sprintf( painCave.errMsg,
341 <                 "Error opening the force field parameter file: %s\n"
342 <                 "Have you tried setting the FORCE_PARAM_PATH environment "
341 >                 "Error opening the force field parameter file:\n"
342 >                 "\t%s\n"
343 >                 "\tHave you tried setting the FORCE_PARAM_PATH environment "
344                   "variable?\n",
345                   fileName );
346 +        painCave.severity = OOPSE_ERROR;
347          painCave.isFatal = 1;
348          simError();
349        }
# Line 399 | Line 401 | void WATER::readParams( void ){
401   void WATER::readParams( void ){
402  
403    int identNum;
404 +  int tempDirect0, tempDirect1;
405  
406    atomStruct atomInfo;
407    directionalStruct directionalInfo;
# Line 409 | Line 412 | void WATER::readParams( void ){
412    
413    atomPos = new fpos_t;
414    bigSigma = 0.0;
415 <
415 >  
416   #ifdef IS_MPI
417    if( worldRank == 0 ){
418   #endif
# Line 420 | Line 423 | void WATER::readParams( void ){
423      headDirectionalType = new LinkedDirectionalType;
424      
425      fastForward( "AtomTypes", "initializeAtoms" );
426 <
426 >    
427      // we are now at the AtomTypes section.
428      
429      eof_test = fgets( readLine, sizeof(readLine), frcFile );
# Line 428 | Line 431 | void WATER::readParams( void ){
431      
432      
433      // read a line, and start parsing out the atom types
434 <
434 >    
435      if( eof_test == NULL ){
436        sprintf( painCave.errMsg,
437                 "Error in reading Atoms from force file at line %d.\n",
# Line 469 | Line 472 | void WATER::readParams( void ){
472      }
473  
474   #ifdef IS_MPI
475 <    
475 >  
476      // send out the linked list to all the other processes
477      
478      sprintf( checkPointMsg,
479 <             "WATER atom structures read successfully." );
479 >           "WATER atom and directional structures read successfully." );
480      MPIcheckPoint();
481 <    currentAtomType = headAtomType->next; //skip the first element who is a place holder.
481 >    currentAtomType = headAtomType->next; //skip the first element place holder
482 >    currentDirectionalType = headDirectionalType->next; // same w/ directional
483 >    
484      while( currentAtomType != NULL ){
485        currentAtomType->duplicate( atomInfo );
486 <      
486 >
487        sendFrcStruct( &atomInfo, mpiAtomStructType );
488        
489        sprintf( checkPointMsg,
490                 "successfully sent WATER force type: \"%s\"\n",
491                 atomInfo.name );
487      MPIcheckPoint();
492        
493 +      if ( atomInfo.isDirectional ){
494 +        // send out the directional linked list to all the other processes
495 +        
496 +        currentDirectionalType->duplicate( directionalInfo );
497 +        sendFrcStruct( &directionalInfo, mpiDirectionalStructType );
498 +        
499 +        sprintf( checkPointMsg,
500 +                 "successfully sent WATER directional type: \"%s\"\n",
501 +                 directionalInfo.name );
502 +      }
503 +      
504 +      MPIcheckPoint();
505 +      tempDirect0 = atomInfo.isDirectional;
506        currentAtomType = currentAtomType->next;
507 +      if( tempDirect0 )
508 +        currentDirectionalType = currentDirectionalType->next;
509      }
510 <
510 >    
511      atomInfo.last = 1;
512      sendFrcStruct( &atomInfo, mpiAtomStructType );
513 <
514 <    if ( atomInfo.isDirectional ){
496 <      // send out the linked list to all the other processes
497 <      
498 <      sprintf( checkPointMsg,
499 <               "WATER directional structures read successfully." );
500 <      MPIcheckPoint();
501 <      
502 <      currentDirectionalType = headDirectionalType->next;
503 <      while( currentDirectionalType != NULL ){
504 <        currentDirectionalType->duplicate( directionalInfo );
505 <        sendFrcStruct( &directionalInfo, mpiDirectionalStructType );
506 <        currentDirectionalType = currentDirectionalType->next;
507 <      }
508 <      directionalInfo.last = 1;
513 >    directionalInfo.last = 1;
514 >    if ( atomInfo.isDirectional )
515        sendFrcStruct( &directionalInfo, mpiDirectionalStructType );
510    }
516    }
517 <
517 >  
518    else{
514    
519      // listen for node 0 to send out the force params
520      
521      MPIcheckPoint();
522  
523      headAtomType = new LinkedAtomType;
524 +    headDirectionalType = new LinkedDirectionalType;
525      receiveFrcStruct( &atomInfo, mpiAtomStructType );
526 <    
526 >
527 >    if ( atomInfo.isDirectional )
528 >      receiveFrcStruct( &directionalInfo, mpiDirectionalStructType );
529 >
530      while( !atomInfo.last ){
531 <      
531 >
532        headAtomType->add( atomInfo );
533        
534        MPIcheckPoint();
535 <      
535 >
536        receiveFrcStruct( &atomInfo, mpiAtomStructType );
529    }
537  
538 <    if ( atomInfo.isDirectional ) {
532 <      // listen for node 0 to send out the force params
533 <      
534 <      MPIcheckPoint();
535 <      
536 <      headDirectionalType = new LinkedDirectionalType;
537 <      receiveFrcStruct( &directionalInfo, mpiDirectionalStructType );
538 <      while( !directionalInfo.last ){
539 <        
538 >      if( atomInfo.isDirectional ){
539          headDirectionalType->add( directionalInfo );
540 +
541          receiveFrcStruct( &directionalInfo, mpiDirectionalStructType );
542        }
543      
544      sprintf( checkPointMsg,
545               "WATER directional structures broadcast successfully." );
546      MPIcheckPoint();
543      }
544    }
545  
# Line 636 | Line 632 | void WATER::readParams( void ){
632  
633   #ifdef IS_MPI
634    sprintf( checkPointMsg,
635 <           "WATER atom structures successfully sent to fortran\n" );
635 >           "WATER atom and directional structures successfully"
636 >           "sent to fortran\n" );
637    MPIcheckPoint();
638   #endif // is_mpi
639  
# Line 645 | Line 642 | void WATER::initializeAtoms( int nAtoms, Atom** the_at
642  
643   void WATER::initializeAtoms( int nAtoms, Atom** the_atoms ){
644    
645 <  int i,j;
645 >  int i,j,k;
646  
647    // initialize the atoms
648    DirectionalAtom* dAtom;
649 +  double ji[3];
650    double inertialMat[3][3];
651  
652    for( i=0; i<nAtoms; i++ ){
655    fprintf(stderr, "flag 1\n");
653      currentAtomType = headAtomType->find( the_atoms[i]->getType() );
657    fprintf(stderr, "%s is the type\n", the_atoms[i]->getType());
654      if( currentAtomType == NULL ){
655        sprintf( painCave.errMsg,
656                 "AtomType error, %s not found in force file.\n",
# Line 662 | Line 658 | void WATER::initializeAtoms( int nAtoms, Atom** the_at
658        painCave.isFatal = 1;
659        simError();
660      }
665    fprintf(stderr, "flag 2\n");
666    if( currentAtomType->isLJ ) the_atoms[i]->setLJ();
667    if( currentAtomType->isCharge ) the_atoms[i]->setCharged();
661      the_atoms[i]->setMass( currentAtomType->mass );
662      the_atoms[i]->setIdent( currentAtomType->ident );
663 <    fprintf(stderr, "flag 3\n");
663 >
664      if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma;
665  
666 +    the_atoms[i]->setHasCharge(currentAtomType->isCharge);
667 +
668      if( currentAtomType->isDirectional ){
674      fprintf(stderr, "flag 4\n");
669        currentDirectionalType =
670          headDirectionalType->find( the_atoms[i]->getType() );
677      fprintf(stderr, "%s is the type\n", the_atoms[i]->getType());
671        if( currentDirectionalType == NULL ){
672          sprintf( painCave.errMsg,
673                   "DirectionalType error, %s not found in force file.\n",
# Line 684 | Line 677 | void WATER::initializeAtoms( int nAtoms, Atom** the_at
677        }
678  
679        // zero out the moments of inertia matrix
680 <      for( i=0; i<3; i++ )
681 <        for( j=0; j<3; j++ )
682 <          inertialMat[i][j] = 0.0;
680 >      for( j=0; j<3; j++ )
681 >        for( k=0; k<3; k++ )
682 >          inertialMat[j][k] = 0.0;
683  
684        // load the force file moments of inertia
685        inertialMat[0][0] = currentDirectionalType->Ixx;
686        inertialMat[1][1] = currentDirectionalType->Iyy;
687        inertialMat[2][2] = currentDirectionalType->Izz;
688 <      fprintf(stderr, "Let's try pointing to isDirectional\n");
696 <      fprintf(stderr, "%i what is this\n",the_atoms[i]->isDirectional());
688 >
689        dAtom = (DirectionalAtom *) the_atoms[i];
698      fprintf(stderr, "%i is isDipole\n", currentDirectionalType->isDipole);
690        dAtom->setHasDipole( currentDirectionalType->isDipole );
691 <      dAtom->setMu( currentDirectionalType->dipole );
692 <      fprintf(stderr, "flag 5\n");
693 <      dAtom->setMu( currentDirectionalType->dipole );
694 <      fprintf(stderr,"flag 6\n");
695 <      // if it's sticky then it's an SSD type
705 <      dAtom->setSSD( currentDirectionalType->isSticky );
706 <      dAtom->setJx( 0.0 );
707 <      dAtom->setJy( 0.0 );
708 <      dAtom->setJz( 0.0 );
691 >
692 >      ji[0] = 0.0;
693 >      ji[1] = 0.0;
694 >      ji[2] = 0.0;
695 >      dAtom->setJ( ji );
696        dAtom->setI( inertialMat );
697 <      fprintf(stderr, "flag 7\n");
697 >
698        entry_plug->n_dipoles++;
712      fprintf(stderr, "flag 8\n");
713    }
714    else{
715      sprintf( painCave.errMsg,
716               "WATER error: Atom \"%s\" is directional, yet no standard"
717               " orientation was specifed in the BASS file.\n",
718               currentAtomType->name );
719      painCave.isFatal = 1;
720      simError();
699      }
700    }
701   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines