ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/interface_implementation/LJ_FF.cpp
(Generate patch)

Comparing trunk/mdtools/interface_implementation/LJ_FF.cpp (file contents):
Revision 240 by chuckv, Wed Jan 22 21:45:20 2003 UTC vs.
Revision 254 by chuckv, Thu Jan 30 20:03:37 2003 UTC

# Line 9 | Line 9 | using namespace std;
9   #include "SRI.hpp"
10   #include "simError.h"
11  
12
12   // Declare the structures that will be passed by the parser and  MPI
13  
14   typedef struct{
# Line 25 | Line 24 | int parseAtomLJ( char *lineBuffer, int lineNum, atomSt
24   int parseAtomLJ( char *lineBuffer, int lineNum, atomStruct &info );
25  
26   #ifdef IS_MPI
28
27   #include "mpiForceField.h"
28  
29   MPI_Datatype mpiAtomStructType;
# Line 64 | Line 62 | void (*initLJfortran) ( int *nLocal, int *identArray,
62   void (*newLJtype)( int* ident, double* mass, double* epslon, double* sigma,
63                     int* status );
64  
65 < void (*initLJfortran) ( int *nLocal, int *identArray, int *isError )
65 > void (*initLJfortran) ( int *nLocal, int *identArray, int *isError );
66  
67   LJ_FF* currentLJwrap;
68  
# Line 73 | Line 71 | LJ_FF::LJ_FF(){
71   // begins the actual forcefield stuff.  
72   //****************************************************************
73  
74 +
75   LJ_FF::LJ_FF(){
76  
77    char fileName[200];
# Line 207 | Line 206 | void LJfunctionWrapper( void (*p1)( int* ident, double
206  
207   void LJfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon,
208                                     double* sigma, int* status ),
209 <                        void (*p2)( void ),
209 >                        void (*p2)( int*, int*, int* ),
210                          void (*p3)( double* positionArray,double* forceArray,
211                                      double* potentialEnergy,
212                                      short int* doPotentialCalc ) ){
213    
214    
215 <  p1 = newLJtype;
216 <  p2 = initLJfortran;
217 <  this->setLJfortran( p3 );
215 >  newLJtype = p1;
216 >  initLJfortran = p2;
217 >  currentLJwrap->setLJfortran( p3 );
218   }
219  
220  
# Line 242 | Line 241 | void LJ_FF::initializeAtoms( void ){
241        // check for duplicates
242        
243        if( !strcmp( info.name, name ) ){
244 <        sprintf( simError.painCave,
244 >        sprintf( painCave.errMsg,
245                   "Duplicate LJ atom type \"%s\" found in "
246                   "the LJ_FF param file./n",
247                   name );
# Line 307 | Line 306 | void LJ_FF::initializeAtoms( void ){
306  
307      headAtomType = new LinkedType;
308      
309 <    fastFoward( "AtomTypes", "initializeAtoms" );
309 >    fastForward( "AtomTypes", "initializeAtoms" );
310  
311      // we are now at the AtomTypes section.
312      
# Line 386 | Line 385 | void LJ_FF::initializeAtoms( void ){
385      
386      if( currentAtomType->name[0] != '\0' ){
387        isError = 0;
388 <      newLJtype( &(currentAtomType->ident),
388 >          newLJtype( &(currentAtomType->ident),
389                   &(currentAtomType->mass),
390                   &(currentAtomType->epslon),
391                   &(currentAtomType->sigma),
# Line 412 | Line 411 | void LJ_FF::initializeAtoms( void ){
411  
412    // initialize the atoms
413    
414 +  double bigSigma = 0.0;
415    Atom* thisAtom;
416  
417    for( i=0; i<nAtoms; i++ ){
# Line 430 | Line 430 | void LJ_FF::initializeAtoms( void ){
430      the_atoms[i]->setSigma( currentAtomType->sigma );
431      the_atoms[i]->setIdent( currentAtomType->ident );
432      the_atoms[i]->setLJ();
433 +
434 +    if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma;
435    }
436 +
437 +  
438 + #ifdef IS_MPI
439 +  double tempBig = bigSigma;
440 +  MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX );
441 + #endif  //is_mpi
442  
443 +  //calc rCut and rList
444  
445 +  entry_plug->rCut = 2.5 * bigSigma;
446 +  if(entry_plug->rCut > (entry_plug->box_x / 2.0)) entry_plug->rCut = entry_plug->box_x / 2.0;
447 +  if(entry_plug->rCut > (entry_plug->box_y / 2.0)) entry_plug->rCut = entry_plug->box_y / 2.0;
448 +  if(entry_plug->rCut > (entry_plug->box_z / 2.0)) entry_plug->rCut = entry_plug->box_z / 2.0;
449 +
450 +  entry_plug->rList = entry_plug->rCut + 1.0;
451 +
452    // clean up the memory
453    
454    delete headAtomType;
# Line 443 | Line 459 | void LJ_FF::initializeAtoms( void ){
459   #endif // is_mpi
460  
461    initFortran();
462 +  entry_plug->refreshSim();
463  
464   }
465  
# Line 587 | Line 604 | void LJ_FF::doForces( void ){
604   }
605  
606  
607 < void LJ_FF::doForces( void ){
607 > void LJ_FF::doForces( int calcPot ){
608  
609    int i;
610    double* frc;
611    double* pos;
612 <  double potE;
596 <  short int calcPot = 0;
612 >  short int passedCalcPot = (short int)calcPot;
613  
614    // forces are zeroed here, before any are acumulated.
615    // NOTE: do not rezero the forces in Fortran.
# Line 605 | Line 621 | void LJ_FF::doForces( void ){
621    frc = Atom::getFrcArray();
622    pos = Atom::getPosArray();
623  
624 <  doLJfortran( pos, frc, potE, calcPot );
624 > //   entry_plug->lrPot = -1;
625 >  doLJfortran( pos, frc, &(entry_plug->lrPot), &passedCalcPot );
626 >
627 >
628 > //  fprintf( stderr,
629 > //         "lrPot =  %lf\n", entry_plug->lrPot );
630 >  
631   }
632    
633   void LJ_FF::initFortran( void ){
# Line 618 | Line 640 | void LJ_FF::initFortran( void ){
640    ident = new int[nLocal];
641  
642    for(i=0; i<nLocal; i++){
643 <    ident[i] = entryplug->atoms[i]->getIdent();
643 >    ident[i] = entry_plug->atoms[i]->getIdent();
644    }
645  
646    isError = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines