--- trunk/OOPSE-2.0/src/UseTheForce/DUFF.cpp 2004/10/21 20:15:31 1628 +++ trunk/OOPSE-2.0/src/UseTheForce/DUFF.cpp 2004/10/27 00:01:29 1653 @@ -8,11 +8,10 @@ using namespace std; #include "UseTheForce/ForceFields.hpp" #include "primitives/SRI.hpp" #include "utils/simError.h" +#include "types/DirectionalAtomType.hpp" +#include "UseTheForce/DarkSide/lj_interface.h" +#include "UseTheForce/DarkSide/dipole_interface.h" #include "UseTheForce/DarkSide/sticky_interface.h" -#include "UseTheForce/DarkSide/atype_interface.h" - -//#include "UseTheForce/fortranWrappers.hpp" - #ifdef IS_MPI #include "UseTheForce/mpiForceField.h" @@ -455,10 +454,8 @@ DUFF::DUFF(){ DUFF::DUFF(){ - char fileName[200]; - char* ffPath_env = "FORCE_PARAM_PATH"; - char* ffPath; - char temp[200]; + string fileName; + string tempString; headAtomType = NULL; currentAtomType = NULL; @@ -568,30 +565,22 @@ DUFF::DUFF(){ // generate the force file name - strcpy( fileName, "DUFF.frc" ); + fileName = "DUFF.frc"; // fprintf( stderr,"Trying to open %s\n", fileName ); // attempt to open the file in the current directory first. - frcFile = fopen( fileName, "r" ); + frcFile = fopen( fileName.c_str(), "r" ); if( frcFile == NULL ){ // next see if the force path enviorment variable is set - - ffPath = getenv( ffPath_env ); - if( ffPath == NULL ) { - STR_DEFINE(ffPath, FRC_PATH ); - } + + tempString = ffPath + "/" + fileName; + fileName = tempString; + + frcFile = fopen( fileName.c_str(), "r" ); - - strcpy( temp, ffPath ); - strcat( temp, "/" ); - strcat( temp, fileName ); - strcpy( fileName, temp ); - - frcFile = fopen( fileName, "r" ); - if( frcFile == NULL ){ sprintf( painCave.errMsg, @@ -599,7 +588,7 @@ DUFF::DUFF(){ "\t%s\n" "\tHave you tried setting the FORCE_PARAM_PATH environment " "variable?\n", - fileName ); + fileName.c_str() ); painCave.severity = OOPSE_ERROR; painCave.isFatal = 1; simError(); @@ -657,29 +646,18 @@ void DUFF::initForceField(){ initFortran( entry_plug->useReactionField ); } - -double DUFF::getAtomTypeMass (char* atomType) { - - currentAtomType = headAtomType->find( atomType ); - if( currentAtomType == NULL ){ - sprintf( painCave.errMsg, - "AtomType error, %s not found in force file.\n", - atomType ); - painCave.isFatal = 1; - simError(); - } - return currentAtomType->mass; -} void DUFF::readParams( void ){ - int identNum; + int identNum, isError; atomStruct atomInfo; bondStruct bondInfo; bendStruct bendInfo; torsionStruct torsionInfo; + + AtomType* at; bigSigma = 0.0; @@ -780,54 +758,71 @@ void DUFF::readParams( void ){ } #endif // is_mpi - - - - // call new A_types in fortran - - int isError; - + // dummy variables - - int isGB = 0; - int isLJ = 1; - int isEAM =0; - int isCharge = 0; - double charge=0.0; - + currentAtomType = headAtomType->next;; - while( currentAtomType != NULL ){ - - if(currentAtomType->isDipole) entry_plug->useDipoles = 1; - if(currentAtomType->isSSD) { - entry_plug->useSticky = 1; - makeStickyType( &(currentAtomType->w0), &(currentAtomType->v0), - &(currentAtomType->v0p), - &(currentAtomType->rl), &(currentAtomType->ru), - &(currentAtomType->rlp), &(currentAtomType->rup)); + while( currentAtomType != NULL ){ + + if( currentAtomType->name[0] != '\0' ){ + + if (currentAtomType->isSSD || currentAtomType->isDipole) + DirectionalAtomType* at = new DirectionalAtomType(); + else + AtomType* at = new AtomType(); + + if (currentAtomType->isSSD) { + ((DirectionalAtomType*)at)->setSticky(); + entry_plug->useSticky = 1; + } + + if (currentAtomType->isDipole) { + ((DirectionalAtomType*)at)->setDipole(); + entry_plug->useDipoles = 1; + } + + at->setIdent(currentAtomType->ident); + at->setName(currentAtomType->name); + at->setLennardJones(); + at->complete(); } + currentAtomType = currentAtomType->next; + } + + currentAtomType = headAtomType->next;; + while( currentAtomType != NULL ){ if( currentAtomType->name[0] != '\0' ){ isError = 0; - makeAtype( &(currentAtomType->ident), - &isLJ, - &(currentAtomType->isSSD), - &(currentAtomType->isDipole), - &isGB, - &isEAM, - &isCharge, - &(currentAtomType->epslon), - &(currentAtomType->sigma), - &charge, - &(currentAtomType->dipole), - &isError ); + newLJtype( &(currentAtomType->ident), &(currentAtomType->sigma), + &(currentAtomType->epslon), &isError); if( isError ){ - sprintf( painCave.errMsg, - "Error initializing the \"%s\" atom type in fortran\n", - currentAtomType->name ); - painCave.isFatal = 1; - simError(); + sprintf( painCave.errMsg, + "Error initializing the \"%s\" LJ type in fortran\n", + currentAtomType->name ); + painCave.isFatal = 1; + simError(); + } + + if (currentAtomType->isDipole) { + newDipoleType(&(currentAtomType->ident), &(currentAtomType->dipole), + &isError); + if( isError ){ + sprintf( painCave.errMsg, + "Error initializing the \"%s\" dipole type in fortran\n", + currentAtomType->name ); + painCave.isFatal = 1; + simError(); + } + } + + if(currentAtomType->isSSD) { + makeStickyType( &(currentAtomType->w0), &(currentAtomType->v0), + &(currentAtomType->v0p), + &(currentAtomType->rl), &(currentAtomType->ru), + &(currentAtomType->rlp), &(currentAtomType->rup)); } + } currentAtomType = currentAtomType->next; } @@ -1091,7 +1086,7 @@ void DUFF::readParams( void ){ #endif // is_mpi - entry_plug->useLJ = 1; + entry_plug->useLennardJones = 1; }