--- trunk/mdtools/interface_implementation/LJ_FF.cpp 2003/01/17 21:53:36 238 +++ trunk/mdtools/interface_implementation/LJ_FF.cpp 2003/01/30 15:20:21 253 @@ -43,7 +43,9 @@ extern "C" { double* epslon, double* sigma, int* status ), - void (*p2)( void ), + void (*p2)( int *nLocal, + int *identArray, + int *isError ), void (*p3)( double* positionArray, double* forceArray, double* potentialEnergy, @@ -54,7 +56,7 @@ void LJfunctionWrapper( void (*p1)( int* ident, double void LJfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon, double* sigma, int* status ), - void (*p2)( void ), + void (*p2)( int *nLocal, int *identArray, int *isError ), void (*p3)( double* positionArray,double* forceArray, double* potentialEnergy, short int* doPotentialCalc ) ); @@ -62,7 +64,7 @@ void (*initLJfortran)( void ); void (*newLJtype)( int* ident, double* mass, double* epslon, double* sigma, int* status ); -void (*initLJfortran)( void ); +void (*initLJfortran) ( int *nLocal, int *identArray, int *isError ); LJ_FF* currentLJwrap; @@ -205,15 +207,15 @@ void LJfunctionWrapper( void (*p1)( int* ident, double void LJfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon, double* sigma, int* status ), - void (*p2)( void ), + void (*p2)( int*, int*, int* ), void (*p3)( double* positionArray,double* forceArray, double* potentialEnergy, short int* doPotentialCalc ) ){ - p1 = newLJtype; - p2 = initLJfortran; - this->setLJfortran( p3 ); + newLJtype = p1; + initLJfortran = p2; + currentLJwrap->setLJfortran( p3 ); } @@ -240,7 +242,7 @@ void LJ_FF::initializeAtoms( void ){ // check for duplicates if( !strcmp( info.name, name ) ){ - sprintf( simError.painCave, + sprintf( painCave.errMsg, "Duplicate LJ atom type \"%s\" found in " "the LJ_FF param file./n", name ); @@ -305,7 +307,7 @@ void LJ_FF::initializeAtoms( void ){ headAtomType = new LinkedType; - fastFoward( "AtomTypes", "initializeAtoms" ); + fastForward( "AtomTypes", "initializeAtoms" ); // we are now at the AtomTypes section. @@ -382,13 +384,13 @@ void LJ_FF::initializeAtoms( void ){ currentAtomType = headAtomType; while( currentAtomType != NULL ){ - if( currentAtomType->name[0] != NULL ){ + if( currentAtomType->name[0] != '\0' ){ isError = 0; - newLJtype( &(currentAtomType->ident), + newLJtype( &(currentAtomType->ident), &(currentAtomType->mass), &(currentAtomType->epslon), &(currentAtomType->sigma), - isError ); + &isError ); if( isError ){ sprintf( painCave.errMsg, "Error initializing the \"%s\" atom type in fortran\n", @@ -410,6 +412,7 @@ void LJ_FF::initializeAtoms( void ){ // initialize the atoms + double bigSigma = 0.0; Atom* thisAtom; for( i=0; isetSigma( currentAtomType->sigma ); the_atoms[i]->setIdent( currentAtomType->ident ); the_atoms[i]->setLJ(); + + if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma; } + +#ifdef IS_MPI + double tempBig = bigSigma; + MPI::COMM_WORLD::Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX ); +#endif //is_mpi + //calc rCut and rList + + entry_plug->rCut = 2.5 * bigSigma; + if(entry_plug->rCut > (entry_plug->box_x / 2.0)) entry_plug->rCut = entry_plug->box_x / 2.0; + if(entry_plug->rCut > (entry_plug->box_y / 2.0)) entry_plug->rCut = entry_plug->box_y / 2.0; + if(entry_plug->rCut > (entry_plug->box_z / 2.0)) entry_plug->rCut = entry_plug->box_z / 2.0; + + entry_plug->rList = entry_plug->rCut + 1.0; + // clean up the memory delete headAtomType; @@ -439,6 +458,9 @@ void LJ_FF::initializeAtoms( void ){ sprintf( checkPointMsg, "LJ_FF atoms initialized succesfully" ); MPIcheckPoint(); #endif // is_mpi + + initFortran(); + entry_plug->refreshSim(); } @@ -583,13 +605,12 @@ void LJ_FF::doForces( void ){ } -void LJ_FF::doForces( void ){ +void LJ_FF::doForces( int calcPot ){ int i; double* frc; double* pos; - double potE; - short int calcPot = 0; + short int passedCalcPot = (short int)calcPot; // forces are zeroed here, before any are acumulated. // NOTE: do not rezero the forces in Fortran. @@ -601,6 +622,45 @@ void LJ_FF::doForces( void ){ frc = Atom::getFrcArray(); pos = Atom::getPosArray(); - doLJfortran( pos, frc, potE, calcPot ); +// entry_plug->lrPot = -1; + doLJfortran( pos, frc, &(entry_plug->lrPot), &passedCalcPot ); + + + // fprintf( stderr, +// "lrPot = %lf\n", entry_plug->lrPot ); + } +void LJ_FF::initFortran( void ){ + + int nLocal = entry_plug->n_atoms; + int *ident; + int isError; + int i; + + ident = new int[nLocal]; + + for(i=0; iatoms[i]->getIdent(); + } + + isError = 0; + initLJfortran( &nLocal, ident, &isError ); + + if(isError){ + sprintf( painCave.errMsg, + "LJ_FF error: There was an error initializing the component list in fortran.\n" ); + painCave.isFatal = 1; + simError(); + } + + +#ifdef IS_MPI + sprintf( checkPointMsg, "LJ_FF successfully initialized the fortran component list.\n" ); + MPIcheckPoint(); +#endif // is_mpi + + delete[] ident; + +} +