ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/UseTheForce/WATER.cpp
(Generate patch)

Comparing trunk/src/UseTheForce/WATER.cpp (file contents):
Revision 135 by gezelter, Thu Oct 21 20:15:31 2004 UTC vs.
Revision 202 by gezelter, Thu Nov 4 16:20:28 2004 UTC

# Line 12 | Line 12 | using namespace std;
12   #include "UseTheForce/ForceFields.hpp"
13   #include "primitives/SRI.hpp"
14   #include "utils/simError.h"
15 <
16 <
17 < #include "UseTheForce/DarkSide/atype_interface.h"
15 > #include "types/AtomType.hpp"
16 > #include "types/DirectionalAtomType.hpp"
17 > #include "UseTheForce/DarkSide/lj_interface.h"
18 > #include "UseTheForce/DarkSide/charge_interface.h"
19 > #include "UseTheForce/DarkSide/dipole_interface.h"
20   #include "UseTheForce/DarkSide/sticky_interface.h"
21  
22   #ifdef IS_MPI
# Line 245 | Line 247 | WATER::WATER(){
247  
248   WATER::WATER(){
249  
250 <  char fileName[200];
251 <  char* ffPath_env = "FORCE_PARAM_PATH";
250 <  char* ffPath;
251 <  char temp[200];
250 >  string fileName;
251 >  string tempString;
252  
253    headAtomType = NULL;
254    currentAtomType = NULL;
# Line 308 | Line 308 | WATER::WATER(){
308    if( worldRank == 0 ){
309   #endif
310      
311 <    // generate the force file name
312 <    
313 <    strcpy( fileName, "WATER.frc" );
311 >    // generate the force file name  
312 >
313 >    fileName = "WATER.frc";
314 >
315      //    fprintf( stderr,"Trying to open %s\n", fileName );
316      
317      // attempt to open the file in the current directory first.
318      
319 <    frcFile = fopen( fileName, "r" );
319 >    frcFile = fopen( fileName.c_str(), "r" );
320      
321      if( frcFile == NULL ){
322        
323 <      // next see if the force path enviorment variable is set
323 >      tempString = ffPath + "/" + fileName;
324 >      fileName = tempString;
325        
326 <      ffPath = getenv( ffPath_env );
325 <      if( ffPath == NULL ) {
326 <        STR_DEFINE(ffPath, FRC_PATH );
327 <      }
326 >      frcFile = fopen( fileName.c_str(), "r" );
327        
329      
330      strcpy( temp, ffPath );
331      strcat( temp, "/" );
332      strcat( temp, fileName );
333      strcpy( fileName, temp );
334      
335      frcFile = fopen( fileName, "r" );
336      
328        if( frcFile == NULL ){
329          
330          sprintf( painCave.errMsg,
# Line 341 | Line 332 | WATER::WATER(){
332                   "\t%s\n"
333                   "\tHave you tried setting the FORCE_PARAM_PATH environment "
334                   "variable?\n",
335 <                 fileName );
335 >                 fileName.c_str() );
336          painCave.severity = OOPSE_ERROR;
337          painCave.isFatal = 1;
338          simError();
# Line 399 | Line 390 | void WATER::readParams( void ){
390  
391   void WATER::readParams( void ){
392  
393 <  int identNum;
393 >  int identNum, isError;
394    int tempDirect0, tempDirect1;
395  
396    atomStruct atomInfo;
397    directionalStruct directionalInfo;
398    fpos_t *atomPos;
399 +  AtomType* at;
400  
401    atomInfo.last = 1;         // initialize last to have the last set.
402    directionalInfo.last = 1;  // if things go well, last will be set to 0
# Line 544 | Line 536 | void WATER::readParams( void ){
536  
537   #endif // is_mpi
538    
547  // call new A_types in fortran
548  
549  int isError;
550
539    // dummy variables
552  int isGB = 0;
553  int isEAM = 0;
554  int notDipole = 0;
555  int notSSD = 0;
556  double noDipMoment = 0.0;
540  
558
541    currentAtomType = headAtomType->next;
542    currentDirectionalType = headDirectionalType->next;
543  
544    while( currentAtomType != NULL ){
545 <
546 <    if( currentAtomType->isLJ ) entry_plug->useLJ = 1;
547 <    if( currentAtomType->isCharge ) entry_plug->useCharges = 1;
548 <    if( currentAtomType->isDirectional ){
549 <      // only directional atoms can have dipoles or be sticky
550 <      if ( currentDirectionalType->isDipole ) entry_plug->useDipoles = 1;
551 <      if ( currentDirectionalType->isSticky ) {
552 <        entry_plug->useSticky = 1;
571 <        makeStickyType( &(currentDirectionalType->w0),
572 <                           &(currentDirectionalType->v0),
573 <                           &(currentDirectionalType->v0p),
574 <                           &(currentDirectionalType->rl),
575 <                           &(currentDirectionalType->ru),
576 <                           &(currentDirectionalType->rlp),
577 <                           &(currentDirectionalType->rup));
545 >    if( currentAtomType->name[0] != '\0' ){
546 >      if (currentAtomType->isDirectional)
547 >        at = new DirectionalAtomType();        
548 >      else
549 >        at = new AtomType();
550 >      
551 >      if (currentAtomType->isLJ) {
552 >        at->setLennardJones();
553        }
554 <      if( currentAtomType->name[0] != '\0' ){
555 <        isError = 0;
556 <        makeAtype( &(currentAtomType->ident),
557 <                   &(currentAtomType->isLJ),
558 <                   &(currentDirectionalType->isSticky),
559 <                   &(currentDirectionalType->isDipole),
560 <                   &isGB,
561 <                   &isEAM,
587 <                   &(currentAtomType->isCharge),
588 <                   &(currentAtomType->epslon),
589 <                   &(currentAtomType->sigma),
590 <                   &(currentAtomType->charge),
591 <                   &(currentDirectionalType->dipole),
592 <                   &isError );
593 <        if( isError ){
594 <          sprintf( painCave.errMsg,
595 <                   "Error initializing the \"%s\" atom type in fortran\n",
596 <                   currentAtomType->name );
597 <          painCave.isFatal = 1;
598 <          simError();
554 >
555 >      if (currentAtomType->isCharge) {
556 >        at->setCharge();
557 >      }
558 >
559 >      if (currentAtomType->isDirectional) {
560 >        if (currentDirectionalType->isDipole) {
561 >          ((DirectionalAtomType*)at)->setDipole();
562          }
563 +      
564 +        if (currentDirectionalType->isSticky) {
565 +          ((DirectionalAtomType*)at)->setSticky();
566 +        }
567        }
568 <      currentDirectionalType->next;
568 >      
569 >      at->setIdent(currentAtomType->ident);
570 >      at->setName(currentAtomType->name);    
571 >      at->complete();
572      }
573 +    currentAtomType = currentAtomType->next;
574 +  }
575  
576 <    else {
577 <      // use all dummy variables if this is not a directional atom
578 <      if( currentAtomType->name[0] != '\0' ){
579 <        isError = 0;
580 <        makeAtype( &(currentAtomType->ident),
581 <                   &(currentAtomType->isLJ),
582 <                   &notSSD,
583 <                   &notDipole,
584 <                   &isGB,
585 <                   &isEAM,
586 <                   &(currentAtomType->isCharge),
587 <                   &(currentAtomType->epslon),
588 <                   &(currentAtomType->sigma),
589 <                   &(currentAtomType->charge),
590 <                   &noDipMoment,
591 <                   &isError );
576 >  currentAtomType = headAtomType->next;
577 >  currentDirectionalType = headDirectionalType->next;
578 >
579 >  while( currentAtomType != NULL ){    
580 >
581 >    if( currentAtomType->isLJ ){
582 >      isError = 0;
583 >      newLJtype( &(currentAtomType->ident), &(currentAtomType->sigma),
584 >                 &(currentAtomType->epslon), &isError);
585 >      if( isError ){
586 >        sprintf( painCave.errMsg,
587 >                 "Error initializing the \"%s\" LJ type in fortran\n",
588 >                 currentAtomType->name );
589 >        painCave.isFatal = 1;
590 >        simError();
591 >      }
592 >    }
593 >
594 >    if (currentAtomType->isCharge) {
595 >      newChargeType(&(currentAtomType->ident), &(currentAtomType->charge),
596 >                    &isError);
597 >      if( isError ){
598 >        sprintf( painCave.errMsg,
599 >                 "Error initializing the \"%s\" charge type in fortran\n",
600 >                 currentAtomType->name );
601 >        painCave.isFatal = 1;
602 >        simError();
603 >      }
604 >    }
605 >
606 >    if (currentAtomType->isDirectional){
607 >      if (currentDirectionalType->isDipole) {
608 >        newDipoleType(&(currentAtomType->ident),
609 >                      &(currentDirectionalType->dipole),
610 >                      &isError);
611          if( isError ){
612            sprintf( painCave.errMsg,
613 <                   "Error initializing the \"%s\" atom type in fortran\n",
614 <                   currentAtomType->name );
613 >                   "Error initializing the \"%s\" dipole type in fortran\n",
614 >                   currentDirectionalType->name );
615            painCave.isFatal = 1;
616            simError();
617          }
618 +      }
619 +      
620 +      if(currentDirectionalType->isSticky) {        
621 +        makeStickyType( &(currentDirectionalType->w0),
622 +                        &(currentDirectionalType->v0),
623 +                        &(currentDirectionalType->v0p),
624 +                        &(currentDirectionalType->rl),
625 +                        &(currentDirectionalType->ru),
626 +                        &(currentDirectionalType->rlp),
627 +                        &(currentDirectionalType->rup));
628        }
629      }
630      currentAtomType = currentAtomType->next;
631    }
632 <
632 >  
633   #ifdef IS_MPI
634    sprintf( checkPointMsg,
635             "WATER atom and directional structures successfully"
636             "sent to fortran\n" );
637    MPIcheckPoint();
638   #endif // is_mpi
639 <
639 >  
640   }
641  
642  
# Line 659 | Line 660 | void WATER::initializeAtoms( int nAtoms, Atom** the_at
660      }
661      the_atoms[i]->setMass( currentAtomType->mass );
662      the_atoms[i]->setIdent( currentAtomType->ident );
663 +
664 +    if (currentAtomType->isLJ) entry_plug->useLennardJones = 1;
665 +    if (currentAtomType->isCharge) entry_plug->useCharges = 1;
666 +    if (currentAtomType->isDirectional) {
667 +      if (currentDirectionalType->isDipole) entry_plug->useDipoles = 1;      
668 +      if (currentDirectionalType->isSticky) entry_plug->useSticky = 1;
669 +    }
670  
671      if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma;
672  
# Line 1074 | Line 1082 | int WATER_NS::parseDirectional( char *lineBuffer, int
1082      return 1;
1083    }
1084    else return 0;
1077 }
1078 double WATER::getAtomTypeMass (char* atomType) {
1079
1080  currentAtomType = headAtomType->find( atomType );
1081  if( currentAtomType == NULL ){
1082    sprintf( painCave.errMsg,
1083            "AtomType error, %s not found in force file.\n",
1084             atomType );
1085    painCave.isFatal = 1;
1086    simError();
1087  }
1088
1089  return currentAtomType->mass;
1085   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines