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 3 by tim, Fri Sep 24 16:27:58 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 + #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  
16 #include "UseTheForce/fortranWrappers.hpp"
17
22   #ifdef IS_MPI
23   #include "UseTheForce/mpiForceField.h"
24   #endif // is_mpi
# Line 243 | Line 247 | WATER::WATER(){
247  
248   WATER::WATER(){
249  
250 <  char fileName[200];
251 <  char* ffPath_env = "FORCE_PARAM_PATH";
248 <  char* ffPath;
249 <  char temp[200];
250 >  string fileName;
251 >  string tempString;
252  
253    headAtomType = NULL;
254    currentAtomType = NULL;
255    headDirectionalType = NULL;
256    currentDirectionalType = NULL;
257  
256  // do the funtion wrapping
257  wrapMeFF( this );
258
258   #ifdef IS_MPI
259    int i;
260    
# Line 309 | 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 );
326 <      if( ffPath == NULL ) {
327 <        STR_DEFINE(ffPath, FRC_PATH );
328 <      }
326 >      frcFile = fopen( fileName.c_str(), "r" );
327        
330      
331      strcpy( temp, ffPath );
332      strcat( temp, "/" );
333      strcat( temp, fileName );
334      strcpy( fileName, temp );
335      
336      frcFile = fopen( fileName, "r" );
337      
328        if( frcFile == NULL ){
329          
330          sprintf( painCave.errMsg,
# Line 342 | 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 392 | Line 382 | void WATER::cleanMe( void ){
382   }
383  
384  
385 < void WATER::initForceField( int ljMixRule ){
385 > void WATER::initForceField(){
386    
387 <  initFortran( ljMixRule, entry_plug->useReactionField );
387 >  initFortran(entry_plug->useReactionField );
388   }
389  
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 545 | Line 536 | void WATER::readParams( void ){
536  
537   #endif // is_mpi
538    
548  // call new A_types in fortran
549  
550  int isError;
551
539    // dummy variables
553  int isGB = 0;
554  int isEAM = 0;
555  int notDipole = 0;
556  int notSSD = 0;
557  double noDipMoment = 0.0;
540  
559
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;
572 <        set_sticky_params( &(currentDirectionalType->w0),
573 <                           &(currentDirectionalType->v0),
574 <                           &(currentDirectionalType->v0p),
575 <                           &(currentDirectionalType->rl),
576 <                           &(currentDirectionalType->ru),
577 <                           &(currentDirectionalType->rlp),
578 <                           &(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,
588 <                   &(currentAtomType->isCharge),
589 <                   &(currentAtomType->epslon),
590 <                   &(currentAtomType->sigma),
591 <                   &(currentAtomType->charge),
592 <                   &(currentDirectionalType->dipole),
593 <                   &isError );
594 <        if( isError ){
595 <          sprintf( painCave.errMsg,
596 <                   "Error initializing the \"%s\" atom type in fortran\n",
597 <                   currentAtomType->name );
598 <          painCave.isFatal = 1;
599 <          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 660 | 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 1076 | Line 1083 | int WATER_NS::parseDirectional( char *lineBuffer, int
1083    }
1084    else return 0;
1085   }
1079 double WATER::getAtomTypeMass (char* atomType) {
1080
1081  currentAtomType = headAtomType->find( atomType );
1082  if( currentAtomType == NULL ){
1083    sprintf( painCave.errMsg,
1084            "AtomType error, %s not found in force file.\n",
1085             atomType );
1086    painCave.isFatal = 1;
1087    simError();
1088  }
1089
1090  return currentAtomType->mass;
1091 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines