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 236 by mmeineke, Mon Jan 13 22:06:21 2003 UTC vs.
Revision 248 by chuckv, Mon Jan 27 19:28:21 2003 UTC

# Line 43 | Line 43 | extern "C" {
43                                                          double* epslon,
44                                                          double* sigma,
45                                                          int* status ),
46 <                                            void (*p2)( void ),
46 >                                            void (*p2)( int *nLocal,
47 >                                                        int *identArray,
48 >                                                        int *isError ),
49                                              void (*p3)( double* positionArray,
50                                                          double* forceArray,
51                                                          double* potentialEnergy,
# Line 54 | Line 56 | void LJfunctionWrapper( void (*p1)( int* ident, double
56  
57   void LJfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon,
58                                     double* sigma, int* status ),
59 <                        void (*p2)( void ),
59 >                        void (*p2)( int *nLocal, int *identArray, int *isError ),
60                          void (*p3)( double* positionArray,double* forceArray,
61                                      double* potentialEnergy,
62                                      short int* doPotentialCalc ) );
# Line 62 | Line 64 | void (*newLJtype)( int* ident, double* mass, double* e
64   void (*newLJtype)( int* ident, double* mass, double* epslon, double* sigma,
65                     int* status );
66  
67 < void (*initLJfortran)( void );
67 > void (*initLJfortran) ( int *nLocal, int *identArray, int *isError )
68  
69   LJ_FF* currentLJwrap;
70  
# Line 377 | Line 379 | void LJ_FF::initializeAtoms( void ){
379   #endif // is_mpi
380  
381    // call new A_types in fortran
382 +  
383 +  int isError;
384 +  currentAtomType = headAtomType;
385 +  while( currentAtomType != NULL ){
386 +    
387 +    if( currentAtomType->name[0] != '\0' ){
388 +      isError = 0;
389 +      newLJtype( &(currentAtomType->ident),
390 +                 &(currentAtomType->mass),
391 +                 &(currentAtomType->epslon),
392 +                 &(currentAtomType->sigma),
393 +                 &isError );
394 +      if( isError ){
395 +        sprintf( painCave.errMsg,
396 +                 "Error initializing the \"%s\" atom type in fortran\n",
397 +                 currentAtomType->name );
398 +        painCave.isFatal = 1;
399 +        simError();
400 +      }
401 +    }
402 +    currentAtomType = currentAtomType->next;
403 +  }
404 +      
405 + #ifdef IS_MPI
406 +  sprintf( checkPointMsg,
407 +           "LJ_FF atom structures successfully sent to fortran\n" );
408 +  MPIcheckPoint();
409 + #endif // is_mpi
410  
411 +  
412  
413    // initialize the atoms
414    
415 +  double bigSigma = 0.0;
416    Atom* thisAtom;
417  
418    for( i=0; i<nAtoms; i++ ){
# Line 399 | Line 431 | void LJ_FF::initializeAtoms( void ){
431      the_atoms[i]->setSigma( currentAtomType->sigma );
432      the_atoms[i]->setIdent( currentAtomType->ident );
433      the_atoms[i]->setLJ();
434 +
435 +    if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma;
436    }
437  
438 +  
439 + #ifdef IS_MPI
440 +  double tempBig = bigSigma;
441 +  MPI::COMM_WORLD::Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX );
442 + #endif  //is_mpi
443  
444 +  //calc rCut and rList
445 +
446 +  entry_plug->rCut = 2.5 * bigSigma;
447 +  if(entry_plug->rCut > (entry_plug->box_x / 2.0)) entry_plug->rCut = entry_plug->box_x / 2.0;
448 +  if(entry_plug->rCut > (entry_plug->box_y / 2.0)) entry_plug->rCut = entry_plug->box_y / 2.0;
449 +  if(entry_plug->rCut > (entry_plug->box_z / 2.0)) entry_plug->rCut = entry_plug->box_z / 2.0;
450 +
451 +  entry_plug->rList = entry_plug->rCut + 1.0;
452 +
453    // clean up the memory
454    
455    delete headAtomType;
# Line 411 | Line 459 | void LJ_FF::initializeAtoms( void ){
459    MPIcheckPoint();
460   #endif // is_mpi
461  
462 +  initFortran();
463 +  entry_plug->refreshSim();
464 +
465   }
466  
467   void LJ_FF::initializeBonds( bond_pair* the_bonds ){
# Line 552 | Line 603 | int parseAtomLJ( char *lineBuffer, int lineNum,  atomS
603    }
604    else return 0;
605   }
606 +
607 +
608 + void LJ_FF::doForces( void ){
609 +
610 +  int i;
611 +  double* frc;
612 +  double* pos;
613 +  double potE;
614 +  short int calcPot = 0;
615 +
616 +  // forces are zeroed here, before any are acumulated.
617 +  // NOTE: do not rezero the forces in Fortran.
618 +
619 +  for(i=0; i<entry_plug->n_atoms; i++){
620 +    entry_plug->atoms[i]->zeroForces();
621 +  }
622 +
623 +  frc = Atom::getFrcArray();
624 +  pos = Atom::getPosArray();
625 +
626 +  doLJfortran( pos, frc, potE, calcPot );
627 + }
628 +  
629 + void LJ_FF::initFortran( void ){
630 +  
631 +  int nLocal = entry_plug->n_atoms;
632 +  int *ident;
633 +  int isError;
634 +  int i;
635 +
636 +  ident = new int[nLocal];
637 +
638 +  for(i=0; i<nLocal; i++){
639 +    ident[i] = entryplug->atoms[i]->getIdent();
640 +  }
641 +
642 +  isError = 0;
643 +  initLJfortran( &nLocal, ident, &isError );
644 +  
645 +  if(isError){
646 +    sprintf( painCave.errMsg,
647 +             "LJ_FF error: There was an error initializing the component list in fortran.\n" );
648 +    painCave.isFatal = 1;
649 +    simError();
650 +  }
651 +
652 +  
653 + #ifdef IS_MPI
654 +  sprintf( checkPointMsg, "LJ_FF successfully initialized the fortran component list.\n" );
655 +  MPIcheckPoint();
656 + #endif // is_mpi
657 +  
658 +  delete[] ident;
659 +
660 + }
661 +  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines