ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/UseTheForce/WATER.cpp
(Generate patch)

Comparing:
trunk/OOPSE-3.0/src/UseTheForce/WATER.cpp (file contents), Revision 1650 by gezelter, Tue Oct 26 22:24:52 2004 UTC vs.
branches/new_design/OOPSE-3.0/src/UseTheForce/WATER.cpp (file contents), Revision 1702 by tim, Wed Nov 3 18:00:36 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"
# Line 80 | Line 81 | namespace WATER_NS{
81      }
82      ~LinkedAtomType(){ if( next != NULL ) delete next; }
83  
84 <    LinkedAtomType* find(char* key){
84 >    LinkedAtomType* find(const char* key){
85        if( !strcmp(name, key) ) return this;
86        if( next != NULL ) return next->find(key);
87        return NULL;
# Line 152 | Line 153 | namespace WATER_NS{
153      }
154      ~LinkedDirectionalType(){ if( next != NULL ) delete next; }
155  
156 <    LinkedDirectionalType* find(char* key){
156 >    LinkedDirectionalType* find(const char* key){
157        if( !strcmp(name, key) ) return this;
158        if( next != NULL ) return next->find(key);
159        return NULL;
# Line 246 | Line 247 | WATER::WATER(){
247  
248   WATER::WATER(){
249  
250 <  char fileName[200];
251 <  char* ffPath_env = "FORCE_PARAM_PATH";
251 <  char* ffPath;
252 <  char temp[200];
250 >  string fileName;
251 >  string tempString;
252  
253    headAtomType = NULL;
254    currentAtomType = NULL;
# 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 <      }
329 <      
330 <      
331 <      strcpy( temp, ffPath );
332 <      strcat( temp, "/" );
333 <      strcat( temp, fileName );
334 <      strcpy( fileName, temp );
326 >      frcFile = fopen( fileName.c_str(), "r" );
327        
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 406 | Line 396 | void WATER::readParams( void ){
396    atomStruct atomInfo;
397    directionalStruct directionalInfo;
398    fpos_t *atomPos;
409
399    AtomType* at;
400  
401    atomInfo.last = 1;         // initialize last to have the last set.
# Line 555 | Line 544 | void WATER::readParams( void ){
544    while( currentAtomType != NULL ){
545      if( currentAtomType->name[0] != '\0' ){
546        if (currentAtomType->isDirectional)
547 <        DirectionalAtomType* at = new DirectionalAtomType();
547 >        at = new DirectionalAtomType();        
548        else
549 <        AtomType* at = new AtomType();
550 <
549 >        at = new AtomType();
550 >      
551        if (currentAtomType->isLJ) {
552          at->setLennardJones();
553        }
# Line 568 | Line 557 | void WATER::readParams( void ){
557        }
558  
559        if (currentAtomType->isDirectional) {
560 <        if (currentDirectionalType->isSticky) {
560 >        if (currentDirectionalType->isDipole) {
561            ((DirectionalAtomType*)at)->setDipole();
562            entry_plug->useDipoles = 1;
563          }
# Line 663 | Line 652 | void WATER::initializeAtoms( int nAtoms, Atom** the_at
652    double inertialMat[3][3];
653  
654    for( i=0; i<nAtoms; i++ ){
655 <    currentAtomType = headAtomType->find( the_atoms[i]->getType() );
655 >    currentAtomType = headAtomType->find(the_atoms[i]->getType().c_str() );
656      if( currentAtomType == NULL ){
657        sprintf( painCave.errMsg,
658                 "AtomType error, %s not found in force file.\n",
659 <               the_atoms[i]->getType() );
659 >               the_atoms[i]->getType().c_str() );
660        painCave.isFatal = 1;
661        simError();
662      }
# Line 680 | Line 669 | void WATER::initializeAtoms( int nAtoms, Atom** the_at
669  
670      if( currentAtomType->isDirectional ){
671        currentDirectionalType =
672 <        headDirectionalType->find( the_atoms[i]->getType() );
672 >        headDirectionalType->find(the_atoms[i]->getType().c_str() );
673        if( currentDirectionalType == NULL ){
674          sprintf( painCave.errMsg,
675                   "DirectionalType error, %s not found in force file.\n",
676 <                 the_atoms[i]->getType() );
676 >                 the_atoms[i]->getType().c_str() );
677          painCave.isFatal = 1;
678          simError();
679        }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines